Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(trace-viewer): embedded mode support PoC #483

Closed

Conversation

ruifigueira
Copy link
Contributor

@ruifigueira ruifigueira commented May 18, 2024

PoC of trace-viewer embedded in VSCode.

It allows to open trace zip files as well as live traces of running tests.

embedded_trace_viewer.mp4

Depends on microsoft/playwright#30885

@pavelfeldman
Copy link
Member

I'm supportive for those, let me know when they are no longer drafts!

@ruifigueira ruifigueira marked this pull request as ready for review May 21, 2024 19:55
@ruifigueira
Copy link
Contributor Author

It now supports toggle between dark / light theme:

theme_toggle.mp4

@ruifigueira ruifigueira force-pushed the feat/embedded-trace-viewer branch from 090eaeb to 9cc5f7e Compare May 22, 2024 22:12
@ruifigueira ruifigueira force-pushed the feat/embedded-trace-viewer branch from 009bbe1 to 9007b22 Compare June 11, 2024 02:42
@ruifigueira
Copy link
Contributor Author

I added a few tests. They require a playwright version with changes from microsoft/playwright#30885 , and that's why I left them as wip for now.

@ruifigueira
Copy link
Contributor Author

It's now working with vscode SSH remote dev and dev containers.

One nice thing is that there's no need to expose playwright server as 0.0.0.0 because trace viewer is opened by vscode and therefore we can take advantage of vscode.env.asExternalUri to perform a localhost port forwarding.

@ruifigueira ruifigueira force-pushed the feat/embedded-trace-viewer branch 2 times, most recently from 1bb183d to 1f55027 Compare June 16, 2024 17:46
@ruifigueira
Copy link
Contributor Author

It also works in codespaces:

codespaces.mp4

@ruifigueira ruifigueira force-pushed the feat/embedded-trace-viewer branch from 1f55027 to 9423cd2 Compare June 26, 2024 12:04
Copy link
Member

@pavelfeldman pavelfeldman left a comment

Choose a reason for hiding this comment

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

Looks like a good start, I reviewed everything except for actual trace viewer / web view and the tests.

src/extension.ts Show resolved Hide resolved
src/extension.ts Outdated Show resolved Hide resolved
src/extension.ts Outdated Show resolved Hide resolved
src/extension.ts Outdated Show resolved Hide resolved
src/settingsModel.ts Outdated Show resolved Hide resolved
src/testModel.ts Outdated Show resolved Hide resolved
src/testModel.ts Outdated Show resolved Hide resolved
src/playwrightTestServer.ts Outdated Show resolved Hide resolved
src/playwrightTestServer.ts Outdated Show resolved Hide resolved
tests/mock/vscode.ts Outdated Show resolved Hide resolved
pavelfeldman pushed a commit to microsoft/playwright that referenced this pull request Jun 28, 2024
ruifigueira added a commit to ruifigueira/playwright-vscode that referenced this pull request Jul 2, 2024
@ruifigueira ruifigueira force-pushed the feat/embedded-trace-viewer branch from 4dc39ac to e782ce5 Compare July 4, 2024 13:37
@ruifigueira ruifigueira force-pushed the feat/embedded-trace-viewer branch from 2c1d2e7 to cfc7901 Compare July 23, 2024 00:41
@ruifigueira ruifigueira requested a review from pavelfeldman July 23, 2024 05:00
@ruifigueira ruifigueira force-pushed the feat/embedded-trace-viewer branch from 6a87213 to b5f3b90 Compare July 23, 2024 09:37
Copy link
Member

@pavelfeldman pavelfeldman left a comment

Choose a reason for hiding this comment

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

The change looks good. Please split it into the chunks so that I could do thorough review. These look like good chunks, but open to variations:

  • WebView support (nonce)
  • Selection strategy (selected item)
  • Trace viewer abstraction + ShallowTraceViewer
  • Additional embedded trace viewer

@@ -70,6 +70,11 @@
"command": "pw.extension.toggle.showTrace",
"title": "%contributes.command.pw.extension.toggle.showTrace%"
},
{
"category": "Test",
"command": "pw.extension.toggle.embedTraceViewer",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"command": "pw.extension.toggle.embedTraceViewer",
"command": "pw.extension.toggle.embeddedTraceViewer",

@@ -208,6 +207,12 @@ export class Extension implements RunHooks {
vscode.commands.registerCommand('pw.extension.command.clearCache', async () => {
await this._models.selectedModel()?.clearCache();
}),
vscode.commands.registerCommand('pw.extension.command.openTrace', async (uri?: vscodeTypes.Uri) => {
Copy link
Member

Choose a reason for hiding this comment

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

Let's add this separately.

src/extension.ts Show resolved Hide resolved
src/extension.ts Show resolved Hide resolved
this._traceViewers = undefined;
}

async availableTraceViewers(): Promise<TraceViewer[]> {
Copy link
Member

Choose a reason for hiding this comment

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

Why not traceViewer() that would return enabled instance? You don't seem to save much via having the enabled check on the call site. Also, if those are shallow objects, why not created them in the constructor? It would read better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was doing it that way because I was only checking if the trace viewer supported the playwright version in the extension, so I needed to send both implementations.

I'm now changing that to ensure that we only request the enabled trace viewer when needed, and so checking the playwright version can be done here or in testModel, so that we can only pass the right trace viewer to the call site.

src/traceViewer.ts Show resolved Hide resolved
src/settingsView.ts Show resolved Hide resolved

export type TraceViewer = SpawnTraceViewer | EmbeddedTraceViewer;

export class SpawnTraceViewer extends DisposableBase {
Copy link
Member

Choose a reason for hiding this comment

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

Let's put these into separate files. When splitting the change, we can land SpawnTraceViewer in one PR and follow up with adding EmbeddedTraceViewer. That way we would see if there is something funny with the chosen modularity.

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