@devries-cameron20 / t3code-1 / commits / b8ca826bf6
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): preview status and snapshot never echo a data: page's contents (#22302)

Co-authored-by: PR Batch Tester <agent@local.test> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>

shivam committed Nov 1, 2026 at 07:34 UTC b8ca826bf6a95c5ed3323df7aafc626042d12fd0
5 files changed +55 -5
apps/server/src/preview/ServerBrowser.test.ts
+39
@@ -1236,6 +1236,45 @@ it.live.each([false, true])(
1236 ).pipe(Effect.provide(layer)),
1237 );
1238
1239 +it.effect("a tab showing a data: page reports its URL without the content", () =>
1240 + Effect.scoped(
1241 + Effect.gen(function* () {
1242 + const { broker, tabId } = yield* ready;
1243 + const sibling = yield* broker.invoke<PreviewAutomationStatus>({
1244 + scope: asSession("agent-b"),
1245 + operation: "open",
1246 + input: { reuseExistingTab: false, show: false },
1247 + });
1248 + yield* Effect.promise(() => contexts[1]!.page.goto("data:text/html,<p>SIBLING-SECRET</p>"));
1249 + const manager = yield* Manager.PreviewManager;
1250 + const events = yield* manager.subscribeEvents;
1251 + yield* Effect.promise(() => contexts[0]!.page.goto("data:text/html,<p>SECRET-KEY</p>"));
1252 + let event = yield* PubSub.take(events);
1253 + while (
1254 + event.type !== "navigated" ||
1255 + event.tabId !== tabId ||
1256 + event.snapshot.navStatus._tag !== "Success"
1257 + ) {
1258 + event = yield* PubSub.take(events);
1259 + }
1260 + const status = yield* broker.invoke<PreviewAutomationStatus>({
1261 + scope,
1262 + tabId,
1263 + operation: "status",
1264 + input: {},
1265 + });
1266 + expect(event.snapshot.navStatus).toMatchObject({ url: "data:text/html,…" });
1267 + expect(status.url).toBe("data:text/html,…");
1268 + expect(status.tabs?.find((entry) => entry.tabId === tabId)?.url).toBe("data:text/html,…");
1269 + expect(status.tabs?.find((entry) => entry.tabId === sibling.tabId)?.url).toBe(
1270 + "data:text/html,…",
1271 + );
1272 + expect(JSON.stringify([event, status])).not.toContain("SECRET-KEY");
1273 + expect(JSON.stringify([event, status])).not.toContain("SIBLING-SECRET");
1274 + }),
1275 + ).pipe(Effect.provide(layer)),
1276 +);
1277 +
1278 it.live.each(["save failed", "oversized"])(
1279 "a rejected download releases the original and keeps no saved copy (%s)",
1280 (outcome) =>
apps/server/src/preview/ServerBrowser.ts
+10 -3
@@ -592,7 +592,11 @@ const make = Effect.gen(function* () {
592 if (url === "about:blank" || url.startsWith("chrome-error://")) return;
593 const title = (await tab.page.title().catch(() => "")).slice(0, 512);
594 if (tab.loading || tab.page.url() !== url) return;
595 - report(tab, { _tag: "Success", url: url.slice(0, 2048), title });
595 + report(tab, {
596 + _tag: "Success",
597 + url: ServerBrowserPage.withoutDataPayload(url).slice(0, 2048),
598 + title,
599 + });
600 };
601
602 const reportLiveTabs = () => {
@@ -1560,7 +1564,7 @@ const make = Effect.gen(function* () {
1564 ...profileStatus(),
1565 };
1566 }
1563 - const url = tab.page.url();
1567 + const url = ServerBrowserPage.withoutDataPayload(tab.page.url());
1568 const viewport = tab.desktop ? await layoutSize(tab) : tab.page.viewportSize();
1569 const status = {
1570 available: true,
@@ -1584,7 +1588,10 @@ const make = Effect.gen(function* () {
1588 .filter((candidate) => candidate.threadId === tab.threadId)
1589 .map((candidate) => ({
1590 tabId: candidate.tabId,
1587 - url: candidate.page.url() === "about:blank" ? null : candidate.page.url(),
1591 + url:
1592 + candidate.page.url() === "about:blank"
1593 + ? null
1594 + : ServerBrowserPage.withoutDataPayload(candidate.page.url()),
1595 ...(candidate.openerTabId === undefined ? {} : { openerTabId: candidate.openerTabId }),
1596 owner: tabOwner(candidate),
1597 ownedByCaller: candidate.control.agentId === agentSessionId,
apps/server/src/preview/ServerBrowserPage.test.ts
+5
@@ -212,6 +212,11 @@ describe("server browser element refs", () => {
212 expect(tree).not.toContain("PAYLOAD");
213 });
214
215 + it("shows a data: page's own URL by media type only", async () => {
216 + await page.goto("data:text/html,<title>Key</title>PAYLOAD");
217 + expect((await takeSnapshot()).url).toBe("data:text/html,…");
218 + });
219 +
220 it("rejects refs from another tab", async () => {
221 await page.setContent("<button>same label</button>");
222 const locator = buttonLocator((await takeSnapshot()).accessibilityTree, "same label");
apps/server/src/preview/ServerBrowserPage.ts
+1
@@ -583,6 +583,7 @@ const capture = async (
583 });
584 return {
585 ...page,
586 + url: withoutDataPayload(page.url),
587 // Mask text before truncating so a value crossing the cut cannot leak its prefix.
588 visibleText: mask(page.visibleText).slice(0, MAX_VISIBLE_TEXT_LENGTH),
589 accessibilityTree,
packages/shared/src/preview.ts
-2
@@ -200,8 +200,6 @@ export function normalizePreviewUrl(rawUrl: string): string {
200 cause,
201 });
202 }
203 - // The server preview browser reports page URLs unredacted; a data: URL would put its
204 - // content in tool results and logs.
203 if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
204 throw new PreviewUrlNormalizationError({
205 inputLength: rawUrl.length,