Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): text-only browser snapshots no longer hang on hidden tabs #21494

ClosedByntham(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/21494/headopened View on GitHub

Showing 8 changed files with 29 additions and 11 deletions (loading 5).

x
0 of 8 viewed, 8 left
8 additions and 2 deletionsapps/server/src/mcp/toolkits/preview/handlers.tsModified
View file
@@ -202,8 +202,14 @@
invokeTargeted<PreviewAutomationSetColorSchemeResult>("setColorScheme", input),
preview_snapshot: McpToolAccess.readsAsCaller((input) => {
- const { includeImage: _includeImage, save: _save, ...operationInput } = input ?? {};
- return invokeTargeted<PreviewAutomationSnapshot>("snapshot", operationInput);
+ const { includeImage, save, ...operationInput } = input ?? {};
+ // A capture makes a hidden desktop tab paint until it answers; skip one nobody reads.
+ return invokeTargeted<PreviewAutomationSnapshot>(
+ "snapshot",
+ includeImage === true || save === true
+ ? operationInput
+ : { ...operationInput, screenshot: false },
+ );
}),
preview_click: McpToolAccess.actsAsCaller((input) =>
invokeTargeted<object>("click", input, input.timeoutMs),
1 addition and 1 deletionapps/server/src/mcp/toolkits/preview/tools.tsModified
View file
@@ -137,7 +137,7 @@
export const PreviewSnapshotTool = safeBrowserTool(
Tool.make("preview_snapshot", {
description:
- "Use it only when the current request asks for browser work, including checking an edit in the browser. Never use it unasked to verify your own edit, or to repeat a snapshot from an earlier turn. Works on a tab the user is driving. Returns page state, elements, diagnostics, and screenshot size. Target one element with `locator='aria-ref=<ref>'` from `accessibilityTree`, even in frames. Refs die on navigation, a new snapshot, or handoff. Text caps near 20 KB; on your own or an unclaimed tab, `preview_evaluate` reads more. To show a screenshot: `save=true`, then embed ![alt](screenshotPath).",
+ "Use it only when the current request asks for browser work, including checking an edit in the browser. Never use it unasked to verify your own edit, or to repeat a snapshot from an earlier turn. Works on a tab the user is driving. Returns page state, elements, and diagnostics, plus screenshot size with `includeImage`. Target one element with `locator='aria-ref=<ref>'` from `accessibilityTree`, even in frames. Refs die on navigation, a new snapshot, or handoff. Text caps near 20 KB; on your own or an unclaimed tab, `preview_evaluate` reads more. To show a screenshot: `save=true`, then embed ![alt](screenshotPath).",
parameters: Schema.Struct({
...PreviewAutomationTabTargetInput.fields,
includeImage: Schema.optional(