Skip to content

chore(protocol): split channel and dispatcher types#41321

Open
Skn0tt wants to merge 6 commits into
microsoft:mainfrom
Skn0tt:proto-dispatcher-split
Open

chore(protocol): split channel and dispatcher types#41321
Skn0tt wants to merge 6 commits into
microsoft:mainfrom
Skn0tt:proto-dispatcher-split

Conversation

@Skn0tt

@Skn0tt Skn0tt commented Jun 16, 2026

Copy link
Copy Markdown
Member

Summary

  • generate separate channel and dispatcher protocol method surfaces
  • keep client calls free of progress while dispatcher methods receive Progress
  • split channel/dispatcher params, results, events, and initializers for typed channel references

Comment thread utils/generate_channels.js Outdated
eventTypes.push({eventName, eventType: paramsName});
const dispatcherParamsName = `${channelName}${titleCase(eventName)}DispatcherEvent`;
ts_types.set(paramsName, channelParameters.ts);
ts_types.set(dispatcherParamsName, dispatcherParameters.ts);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be fair to generate src/client/channels.d.ts and src/server/channels.d.ts as two separate files. This way we can also avoid duplicating all the code here in the generator, and instead call generate() function twice with different arguments.

Comment thread utils/generate_channels.js Outdated
}

channels_ts.push(` ${methodName}(params${method.parameters ? '' : '?'}: ${paramsName}, progress?: Progress): Promise<${resultName}>;`);
channelMethods.push(` ${methodName}(params${method.parameters ? '' : '?'}: ${channelParamsName}, signal?: AbortSignal): Promise<${channelResultName}>;`);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding signal should be done in another PR 😄

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@Skn0tt Skn0tt force-pushed the proto-dispatcher-split branch from cb538f2 to d3a0b6e Compare June 16, 2026 12:54
@Skn0tt Skn0tt requested a review from dgozman June 16, 2026 12:54
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Comment thread packages/injected/src/injectedScript.ts Outdated
import type { Language } from '@isomorphic/locatorGenerators';
import type { AttributeSelectorPart, NestedSelectorBody, ParsedSelector, ParsedSelectorPart } from '@isomorphic/selectorParser';
import type * as channels from '@protocol/channels';
import type * as channels from '../../playwright-core/src/client/channel';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this one using client channels instead of server channels? Even better - let's not use channels here, and declare an explicit type?

Comment thread packages/injected/src/storageScript.ts Outdated
import { parseEvaluationResultValue, serializeAsCallArgument } from '@isomorphic/utilityScriptSerializers';

import type * as channels from '@protocol/channels';
import type * as channels from '../../playwright-core/src/client/channel';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question.

Comment thread packages/isomorphic/trace/traceModel.ts Outdated
import type { ActionTraceEvent } from '@trace/trace';
import type { ActionEntry, ContextEntry, PageEntry } from './entries';
import type { StackFrame } from '@protocol/channels';
import type { StackFrame } from '../../playwright-core/src/client/channel';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one can also use a custom type, that's fine.

Comment thread packages/isomorphic/trace/traceUtils.ts Outdated
*/

import type { ClientSideCallMetadata, StackFrame } from '@protocol/channels';
import type { ClientSideCallMetadata, StackFrame } from '../../playwright-core/src/client/channel';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one as well.

Comment thread packages/isomorphic/expectUtils.ts Outdated

import { isRegExp, isString } from './rtti';
import type { ExpectedTextValue } from '@protocol/channels';
import type { ExpectedTextValue } from '../playwright-core/src/client/channel';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file does not make sense anymore, because one caller wants to produce client-side options, and another wants to produce server-side options.

We can probably make all these random imports work by generating a single @protocol/channels with options/params, and two different client/server files for the actual FooBar interfaces. What do you think? Sorry for going back and worth.

*/

import type { SerializedError } from './channels';
import type { SerializedError } from './channel';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this file move! That said, we can inline it into packages/playwright-core/src/server/instrumentation.ts right away.

import type { CallMetadata, SdkObject } from './instrumentation';

export type { Progress } from '@protocol/progress';
export interface Progress {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic!

import type { FullConfig, Location } from '../../types/testReporter';
import type { config as commonConfig, FullConfigInternal, test as testNs } from '../common';
import type { StackFrame } from '@protocol/channels';
import type { StackFrame } from '../../../playwright-core/src/client/channel';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it surprising that we use the same StackFrame in so many places.

}
channels_ts.push(` undefined;`);
channels_ts.push(``);
function generateChannels(target) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope this is just a big indentation change. Otherwise, it's hard to review 😄

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

7341 passed, 1122 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

7 flaky ⚠️ [chromium-library] › library/video.spec.ts:717 › screencast › should work with video+trace `@chromium-ubuntu-22.04-node24`
⚠️ [chromium-page] › page/page-request-continue.spec.ts:756 › propagate headers cross origin redirect after interception `@chromium-ubuntu-22.04-node24`
⚠️ [chromium-library] › library/beforeunload.spec.ts:130 › should support dismissing the dialog multiple times `@chromium-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/inspector/cli-codegen-3.spec.ts:224 › cli codegen › should generate frame locators (4) `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/trace-viewer.spec.ts:1621 › should highlight locator in iframe while typing `@firefox-ubuntu-22.04-node20`
⚠️ [webkit-page] › page/page-set-input-files.spec.ts:295 › should detect mime type `@webkit-ubuntu-22.04-node20`
⚠️ [playwright-test] › ui-mode-test-watch.spec.ts:185 › should watch new file `@ubuntu-latest-node26`

39590 passed, 743 skipped


Merge workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants