Skip to content

chore: move Copy Prompt rendering to UI #36089

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

Closed
wants to merge 10 commits into from

Conversation

Skn0tt
Copy link
Member

@Skn0tt Skn0tt commented May 26, 2025

Trims down the error-context attachment to the actual context bit, which is only the page snapshot. All other parts are dropped.
The error context can be rendered into a "Copy Prompt" prompt with the copyPrompt function. This now lives in packages/web and is shared by Trace Viewer and HTML report.

Here's how we change behaviour:

  1. "Error Context" file linked in terminal reporters doesn't contain error info anymore. This is a good thing - a consuming agent already knows all of that from the terminal report.
  2. "Copy Prompt" in HTML report doesn't contain # Test source section when opened on remote server anymore, because we don't attach the sources and it can only get it via the local server
  3. Trace Viewer shows slightly different formatting for # Test Info section

The VS Code extension can take the error-context attachment and blindly tack it onto the error message.

@Skn0tt Skn0tt self-assigned this May 26, 2025

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

Test results for "tests 1"

4 failed
❌ [default] › run-tests.spec.ts:1305:5 › should provide page snapshot to copilot @vscode-extension
❌ [default-reuse] › run-tests.spec.ts:1305:5 › should provide page snapshot to copilot @vscode-extension
❌ [default-trace] › run-tests.spec.ts:1305:5 › should provide page snapshot to copilot @vscode-extension
❌ [webkit-library] › library/video.spec.ts:475:5 › screencast › should scale frames down to the requested size @webkit-ubuntu-22.04-node18

7 flaky ⚠️ [chromium-library] › library/browsercontext-reuse.spec.ts:256:1 › should work with clock emulation @chromium-ubuntu-22.04-node18
⚠️ [chromium-library] › library/browsercontext-reuse.spec.ts:256:1 › should work with clock emulation @chromium-ubuntu-22.04-node20
⚠️ [chromium-library] › library/browsercontext-reuse.spec.ts:256:1 › should work with clock emulation @chromium-ubuntu-22.04-node22
⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:986:7 › cli codegen › should not throw csp directive violation errors @firefox-ubuntu-22.04-node18
⚠️ [chromium-library] › library/browsercontext-reuse.spec.ts:256:1 › should work with clock emulation @ubuntu-22.04-chromium-tip-of-tree
⚠️ [webkit-library] › library/ignorehttpserrors.spec.ts:30:3 › should isolate contexts @webkit-ubuntu-22.04-node18
⚠️ [webkit-page] › page/page-screenshot.spec.ts:345:5 › page screenshot › should work while navigating @webkit-ubuntu-22.04-node18

39248 passed, 808 skipped
✔️✔️✔️

Merge workflow run.

@Skn0tt Skn0tt requested a review from dgozman May 28, 2025 08:45
Copy link
Contributor

@dgozman dgozman left a comment

Choose a reason for hiding this comment

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

I feel like this PR is too large to be reviewed effectively. Could you please split it up?

@@ -4,8 +4,12 @@
"version": "0.0.0",
"scripts": {},
"dependencies": {
"@babel/code-frame": "^7.27.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

So, we are brining babel into our web properties. How large is this one? Does it run in the browser?

"version": "7.26.2",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.26.2.tgz",
"integrity": "sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==",
"version": "7.27.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we stick with the old version we already had to avoid unnecessary deps churn?

@@ -223,7 +223,6 @@ test('should record trace', async ({ runInlineTest }) => {
'After Hooks',
'Fixture "page"',
'Fixture "context"',
'Attach "error-context-0"',
Copy link
Contributor

Choose a reason for hiding this comment

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

What happened here?

@@ -992,6 +991,7 @@ test('should record nested steps, even after timeout', async ({ runInlineTest },
' Expect "barPage teardown"',
' Step "step in barPage teardown"',
' Close context',
'Attach "error-context"',
Copy link
Contributor

Choose a reason for hiding this comment

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

I am missing where all the changes to the steps are coming from.

@@ -358,9 +358,6 @@ test('should report parallelIndex', async ({ runInlineTest }, testInfo) => {

test('attaches error context', async ({ runInlineTest }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure this test brings any value. Why is it in reporter-json of all things?

metadata,
errorContextContent,
async file => {
const response = await fetch('trace/file?' + new URLSearchParams({ path: `${rootDir}/${file}` }));
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer that html report does not know about rootDir or anything filesystem-related. Can we instead fetch sources while building the report, and include them explicitly? This way, you can also open the report from anywhere at any time, and things will work.

</CodeSnippet>
);
}> = ({ error, testId }) => {
return <CodeSnippet code={error} testId={testId}/>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we even need this component now? Even better, inline CodeSnippet here?

const otherAttachments = new Set<TestAttachment>(attachments);
[...screenshots, ...videos, ...traces].forEach(a => otherAttachments.delete(a));
if (errorContext)
otherAttachments.delete(errorContext);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this to hide the error-context from the list of attachments I can download? Why do that?

}, [result]);

const prompt = useAsyncMemo(
async () => {
const errorContextContent = errorContext?.path ? await fetch(errorContext.path).then(r => r.text()) : errorContext?.body;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this using fetch() instead of LoadedReport.entry()?

@@ -56,7 +57,8 @@ export const Workbench: React.FunctionComponent<{
inert?: boolean,
onOpenExternally?: (location: modelUtil.SourceLocation) => void,
revealSource?: boolean,
}> = ({ model, showSourcesFirst, rootDir, fallbackLocation, isLive, hideTimeline, status, annotations, inert, onOpenExternally, revealSource }) => {
metadata?: MetadataWithCommitInfo,
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's call this testRunMetadata to differentiate from "Metadata" tab in the trace viewer.

@Skn0tt
Copy link
Member Author

Skn0tt commented May 28, 2025

Splitting it up!

@Skn0tt Skn0tt closed this May 28, 2025
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