From 6e9fae8c56c18091ce0d6e90f7def462a8aaf506 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 9 Feb 2026 23:41:00 +0000 Subject: [PATCH] Cover bootstrap error passthrough in runtime and ws adapter tests Co-authored-by: Theo Browne --- apps/renderer/src/wsNativeApi.test.ts | 45 +++++++++++++++++++++++++++ apps/t3/src/runtimeApiServer.test.ts | 2 ++ 2 files changed, 47 insertions(+) diff --git a/apps/renderer/src/wsNativeApi.test.ts b/apps/renderer/src/wsNativeApi.test.ts index bf4d171a31..9992c6b3d1 100644 --- a/apps/renderer/src/wsNativeApi.test.ts +++ b/apps/renderer/src/wsNativeApi.test.ts @@ -230,6 +230,51 @@ describe("wsNativeApi", () => { }); }); + it("preserves bootstrapError field in bootstrap payloads", async () => { + setWindowSearch("?ws=ws%3A%2F%2F127.0.0.1%3A4420"); + const { getOrCreateWsNativeApi } = await import("./wsNativeApi"); + const api = getOrCreateWsNativeApi(); + + const request = api.app.bootstrap(); + const socket = MockWebSocket.instances[0]; + await waitForCondition(() => (socket?.sentMessages.length ?? 0) > 0); + const requestEnvelope = JSON.parse(socket?.sentMessages[0] ?? "{}") as { + id: string; + }; + + socket?.emitMessage( + JSON.stringify({ + type: "response", + id: requestEnvelope.id, + ok: true, + result: { + launchCwd: "/workspace", + projectName: "workspace", + provider: "codex", + model: "gpt-5-codex", + session: { + sessionId: "bootstrap-error", + provider: "codex", + status: "error", + cwd: "/workspace", + model: "gpt-5-codex", + createdAt: "2026-02-01T00:00:00.000Z", + updatedAt: "2026-02-01T00:00:00.000Z", + lastError: "Timed out waiting for initialize.", + }, + bootstrapError: "Timed out waiting for initialize.", + }, + }), + ); + + await expect(request).resolves.toMatchObject({ + bootstrapError: "Timed out waiting for initialize.", + session: { + status: "error", + }, + }); + }); + it("falls back to default local runtime URL when ws query is missing", async () => { setWindowSearch(""); const { getOrCreateWsNativeApi } = await import("./wsNativeApi"); diff --git a/apps/t3/src/runtimeApiServer.test.ts b/apps/t3/src/runtimeApiServer.test.ts index ceb5fa8b08..6df6c14681 100644 --- a/apps/t3/src/runtimeApiServer.test.ts +++ b/apps/t3/src/runtimeApiServer.test.ts @@ -479,9 +479,11 @@ describe("runtimeApiServer", () => { } const payload = response.result as { + launchCwd: string; session: { status: string }; bootstrapError?: string; }; + expect(payload.launchCwd).toBe(process.cwd()); expect(payload.session.status).toBe("error"); expect(typeof payload.bootstrapError).toBe("string"); expect((payload.bootstrapError ?? "").length).toBeGreaterThan(0);