The best way to control Claude Code, Codex and more from any computer or phone
fix(server): saved preview snapshot failures name the screenshot destination (#35649)
Julius Marminge committed
Nov 12, 2026 at 14:50 UTC
2ff2770f424d04eb6dc17a9e6425216c2953a4d2
2 files changed
+25
-3
apps/server/src/mcp/McpHttpServer.test.ts
+20
@@ -535,6 +535,26 @@ it.effect("saves the uncapped screenshot while the agent sees the capped one", (
535
).pipe(Effect.provide(layerTest)),
536
);
537
538
+it.effect("names the screenshot destination when saving it fails", () =>
539
+ Effect.scoped(
540
+ Effect.gen(function* () {
541
+ const config = yield* ServerConfig.ServerConfig;
542
+ yield* (yield* FileSystem.FileSystem).writeFileString(config.browserArtifactsDir, "occupied");
543
+ yield* serveSnapshots("mcp-save-failure-client", snapshotResult);
544
+
545
+ const snapshot = yield* callSnapshot({ tabId: alternateTabId, save: true });
546
+ const text = snapshot.content[0]?.type === "text" ? snapshot.content[0].text : "";
547
+
548
+ expect(snapshot.isError).toBe(true);
549
+ expect(text).toMatch(/^Preview snapshot failed: Could not save preview screenshot to /);
550
+ expect(text).toContain(config.browserArtifactsDir);
551
+ expect(snapshot.structuredContent).toMatchObject({
552
+ error: { _tag: "PreviewScreenshotSaveError", message: text.slice(25) },
553
+ });
554
+ }),
555
+ ).pipe(Effect.provide(layerTest)),
556
+);
557
+
558
it.effect("refuses preview tools to a client outside a thread before they run", () =>
559
Effect.gen(function* () {
560
const server = yield* McpServer.McpServer;
apps/server/src/mcp/McpHttpServer.ts
+5
-3
@@ -549,6 +549,7 @@ const parameterValidationMessage = (error: unknown) =>
549
: undefined;
550
551
const isPreviewAutomationError = Schema.is(PreviewAutomationError);
552
+const isPreviewScreenshotSaveError = Schema.is(PreviewScreenshotSaveError);
553
554
const previewSnapshotFailure = Effect.fn("previewSnapshotFailure")(function <E>(
555
cause: Cause.Cause<E>,
@@ -566,9 +567,10 @@ const previewSnapshotFailure = Effect.fn("previewSnapshotFailure")(function <E>(
567
? firstFailure._tag
568
: "PreviewSnapshotError";
569
// Preview errors contain server-authored recovery guidance, never page output.
569
- const message = isPreviewAutomationError(firstFailure)
570
- ? firstFailure.message
571
- : parameterValidationMessage(firstFailure);
570
+ const message =
571
+ isPreviewAutomationError(firstFailure) || isPreviewScreenshotSaveError(firstFailure)
572
+ ? firstFailure.message
573
+ : parameterValidationMessage(firstFailure);
574
const result = new McpSchema.CallToolResult({
575
isError: true,
576
structuredContent: {