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

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

fix(preview): always return evaluated results by value (#22948)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Nov 11, 2026 at 02:51 UTC c266631bde2a77e4c5bb52f0e56a115af205889f
4 files changed +15 -7
apps/server/src/preview/ServerBrowserPage.test.ts
+13
@@ -1,3 +1,5 @@
1 +import { PreviewAutomationEvaluateInput } from "@t3tools/contracts";
2 +import * as Schema from "effect/Schema";
3 import {
4 chromium,
5 type Browser,
@@ -18,6 +20,8 @@ import {
20
21 import * as ServerBrowserPage from "./ServerBrowserPage.ts";
22
23 +const decodeEvaluateInput = Schema.decodeUnknownSync(PreviewAutomationEvaluateInput);
24 +
25 describe("server browser element refs", () => {
26 let browser: Browser;
27 let context: BrowserContext;
@@ -288,6 +292,15 @@ describe("server browser element refs", () => {
292 expect(result).toBe("Ready");
293 });
294
295 + it("returns object contents even when a legacy caller asks for a remote reference", async () => {
296 + const input = decodeEvaluateInput({
297 + expression: "({ answer: 42, nested: { ready: true } })",
298 + returnByValue: false,
299 + });
300 + const result = await ServerBrowserPage.evaluate(cdp, input, 5_000);
301 + expect(result).toEqual({ answer: 42, nested: { ready: true } });
302 + });
303 +
304 it("still awaits the promise an async function returns", async () => {
305 const result = await ServerBrowserPage.evaluate(
306 cdp,
apps/server/src/preview/ServerBrowserPage.ts
+1 -1
@@ -909,7 +909,7 @@ export const evaluate = async (
909 const params = {
910 expression: input.expression,
911 awaitPromise: input.awaitPromise ?? true,
912 - returnByValue: input.returnByValue ?? true,
912 + returnByValue: true,
913 };
914 // The devtools console's replMode allows top-level await but returns a trailing promise unawaited,
915 // so it only retries what the page's parser rejected. A parse error has a scriptId but no stack and
apps/server/src/provider/agentContextBudget.json
+1 -1
@@ -1,5 +1,5 @@
1 {
2 "claudeSystemAppendBytes": 5597,
3 "codexAdditionalContextBytes": 7327,
4 - "mcpToolListJsonBytes": 48217
4 + "mcpToolListJsonBytes": 48131
5 }
packages/contracts/src/previewAutomation.ts
-5
@@ -463,11 +463,6 @@ export const PreviewAutomationEvaluateInput = Schema.Struct({
463 .check(Schema.isNonEmpty())
464 .check(Schema.isMaxLength(64_000)),
465 awaitPromise: Schema.optional(Schema.Boolean.annotate({ description: "Default true." })),
466 - returnByValue: Schema.optional(
467 - Schema.Boolean.annotate({
468 - description: "False returns a ref. Default true.",
469 - }),
470 - ),
466 });
467 export type PreviewAutomationEvaluateInput = typeof PreviewAutomationEvaluateInput.Type;
468