Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(mcp): keep preview snapshots usable by the agent and let it save them #10501

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 5 commits intomain fromrefs/pull/10501/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 6 changed files with 32 additions and 7 deletions (loading 3).

x
0 of 6 viewed, 6 left
7 additions and 1 deletionapps/desktop/src/preview/Manager.tsModified
View file
@@ -117,6 +117,12 @@
const MAX_EVALUATION_BYTES = 64_000;
const MAX_VISIBLE_TEXT_LENGTH = 20_000;
const MAX_INTERACTIVE_ELEMENTS = 200;
+/**
+ * A `[role]` container's innerText is its whole subtree, which turned one
+ * snapshot's element list into 60 KB of repeated page text. Names are labels,
+ * not content, so cap them where they are read.
+ */
+const MAX_INTERACTIVE_ELEMENT_NAME_LENGTH = 200;
const MAX_SCREENSHOT_WIDTH = 1280;
/** How long an armed tab keeps the exclusive display-media slot before another tab may take it. */
const RECORDING_ARM_GRACE_MS = 10_000;
@@ -3582,7 +3588,7 @@
return {
tag: element.tagName.toLowerCase(),
role: element.getAttribute("role"),
- name: element.getAttribute("aria-label") || element.innerText || element.getAttribute("name") || "",
+ name: (element.getAttribute("aria-label") || element.innerText || element.getAttribute("name") || "").slice(0, ${MAX_INTERACTIVE_ELEMENT_NAME_LENGTH}),
selector: selectorFor(element),
x: rect.x,
y: rect.y,
5 additions and 3 deletionsapps/server/src/mcp/toolkits/preview/handlers.tsModified
View file
@@ -166,8 +166,8 @@
preview_set_appearance: (input) =>
invokeTargeted<PreviewAutomationSetColorSchemeResult>("setColorScheme", input),