Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 4 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"native-keymap": "^3.3.5",
"node-pty": "^1.2.0-beta.12",
"open": "^10.1.2",
"playwright-core": "1.59.0-alpha-2026-02-20",
"playwright-core": "1.59.1",
"ssh2": "^1.16.0",
"tas-client": "0.3.1",
"undici": "^7.24.0",
Expand Down
18 changes: 14 additions & 4 deletions src/vs/platform/browserView/node/playwrightTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import { Emitter, Event } from '../../../base/common/event.js';
import { CancellationToken } from '../../../base/common/cancellation.js';
import { createCancelablePromise, raceCancellablePromises } from '../../../base/common/async.js';

type IAiAriaSnapshotOptions = NonNullable<Parameters<playwright.Locator['ariaSnapshot']>[0]> & { _track?: string };

declare module 'playwright-core' {
interface Page {
// A hidden Playwright method that returns an AI-friendly snapshot of the page.
_snapshotForAI(options?: { track?: string }): Promise<{ full: string; incremental?: string }>;
// We defined this here to be able to use the unofficial `_track` option
ariaSnapshot(options?: IAiAriaSnapshotOptions): Promise<string>;
}
}

Expand Down Expand Up @@ -165,7 +167,7 @@ export class PlaywrightTab {
this._needsFullSnapshot = false;
}

const snapshotFromPage = await this.safeRunAgainstPage((page) => page._snapshotForAI({ track: 'response' })).catch(() => {
const snapshotFromPage = await this.safeRunAgainstPage((page) => this.getAiSnapshot(page, full)).catch(() => {
this._needsFullSnapshot = true;
return undefined;
});
Expand All @@ -174,7 +176,7 @@ export class PlaywrightTab {
const logs = this._logs;
this._logs = [];

const snapshot = (full ? snapshotFromPage?.full : snapshotFromPage?.incremental ?? snapshotFromPage?.full)?.trim() ?? '';
const snapshot = snapshotFromPage?.trim() ?? '';

return [
...(title ? [`Page Title: ${title}`] : []),
Expand All @@ -189,6 +191,14 @@ export class PlaywrightTab {
].join('\n');
}

private getAiSnapshot(page: playwright.Page, full: boolean): Promise<string> {
const options: IAiAriaSnapshotOptions = { mode: 'ai' };
if (!full) {
options._track = 'response';
}
return page.ariaSnapshot(options);
}

private async runAndWaitForCompletion<T>(callback: (token: CancellationToken) => Promise<T>, token = CancellationToken.None): Promise<T> {
const requests: playwright.Request[] = [];

Expand Down
Loading