Skip to content

Commit 061543e

Browse files
t3dotggclaude
andauthored
fix(mcp): keep preview snapshots usable by the agent and let it save them (#10501)
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
1 parent b5d8903 commit 061543e

6 files changed

Lines changed: 594 additions & 66 deletions

File tree

apps/desktop/src/preview/Manager.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ const ZOOM_EPSILON = 0.001;
117117
const MAX_EVALUATION_BYTES = 64_000;
118118
const MAX_VISIBLE_TEXT_LENGTH = 20_000;
119119
const MAX_INTERACTIVE_ELEMENTS = 200;
120+
/**
121+
* A `[role]` container's innerText is its whole subtree, which turned one
122+
* snapshot's element list into 60 KB of repeated page text. Names are labels,
123+
* not content, so cap them where they are read.
124+
*/
125+
const MAX_INTERACTIVE_ELEMENT_NAME_LENGTH = 200;
120126
const MAX_SCREENSHOT_WIDTH = 1280;
121127
/** How long an armed tab keeps the exclusive display-media slot before another tab may take it. */
122128
const RECORDING_ARM_GRACE_MS = 10_000;
@@ -3582,7 +3588,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
35823588
return {
35833589
tag: element.tagName.toLowerCase(),
35843590
role: element.getAttribute("role"),
3585-
name: element.getAttribute("aria-label") || element.innerText || element.getAttribute("name") || "",
3591+
name: (element.getAttribute("aria-label") || element.innerText || element.getAttribute("name") || "").slice(0, ${MAX_INTERACTIVE_ELEMENT_NAME_LENGTH}),
35863592
selector: selectorFor(element),
35873593
x: rect.x,
35883594
y: rect.y,

apps/server/src/config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export interface ServerDerivedPaths {
3838
readonly providerStatusCacheDir: string;
3939
readonly worktreesDir: string;
4040
readonly attachmentsDir: string;
41+
/** Screenshots the agent asks the collaborative browser to keep for the user. */
42+
readonly browserArtifactsDir: string;
4143
readonly logsDir: string;
4244
readonly serverLogPath: string;
4345
readonly serverTracePath: string;
@@ -125,6 +127,7 @@ export const deriveServerPaths = Effect.fn(function* (
125127
providerStatusCacheDir,
126128
worktreesDir: join(baseDir, "worktrees"),
127129
attachmentsDir,
130+
browserArtifactsDir: join(stateDir, "browser-artifacts"),
128131
logsDir,
129132
serverLogPath: join(logsDir, "server.log"),
130133
serverTracePath: join(logsDir, "server.trace.ndjson"),

0 commit comments

Comments
 (0)