From 6cc4e616bbb65c181138245cce7a4e250dfa15e6 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 9 Feb 2026 22:40:23 +0000 Subject: [PATCH] Surface runtime connectivity errors in renderer bootstrap Co-authored-by: Theo Browne --- apps/renderer/src/App.tsx | 16 ++++++++++++++-- apps/renderer/src/store.test.ts | 14 ++++++++++++++ apps/renderer/src/store.ts | 12 +++++++++++- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/apps/renderer/src/App.tsx b/apps/renderer/src/App.tsx index 235c55b252..83b734ff71 100644 --- a/apps/renderer/src/App.tsx +++ b/apps/renderer/src/App.tsx @@ -41,8 +41,15 @@ function BootstrapRouter() { bootstrap, }); }) - .catch(() => { - // Keep existing renderer state if bootstrap is unavailable. + .catch((error) => { + if (cancelled) return; + dispatch({ + type: "SET_RUNTIME_ERROR", + error: + error instanceof Error + ? error.message + : "Could not connect to the local t3 runtime.", + }); }); return () => { @@ -72,6 +79,11 @@ function Layout() {
+ {state.runtimeError && state.projects.length === 0 && ( +
+ Runtime connection failed: {state.runtimeError} +
+ )} {state.diffOpen && } diff --git a/apps/renderer/src/store.test.ts b/apps/renderer/src/store.test.ts index b7ffa00d65..c4674fe7bd 100644 --- a/apps/renderer/src/store.test.ts +++ b/apps/renderer/src/store.test.ts @@ -58,6 +58,7 @@ function makeState(thread: Thread): AppState { activeThreadId: thread.id, runtimeMode: "full-access", diffOpen: false, + runtimeError: null, }; } @@ -69,6 +70,7 @@ describe("store reducer thread continuity", () => { activeThreadId: null, runtimeMode: "full-access", diffOpen: false, + runtimeError: null, }; const session = makeSession({ sessionId: "sess-bootstrap", @@ -100,6 +102,7 @@ describe("store reducer thread continuity", () => { activeThreadId: null, runtimeMode: "full-access", diffOpen: false, + runtimeError: null, }; const next = reducer(state, { @@ -120,6 +123,17 @@ describe("store reducer thread continuity", () => { expect(next.threads[0]?.error).toBe("Timed out waiting for initialize."); }); + it("stores runtime connection errors separately from thread errors", () => { + const state = makeState(makeThread()); + const next = reducer(state, { + type: "SET_RUNTIME_ERROR", + error: "Connection refused", + }); + + expect(next.runtimeError).toBe("Connection refused"); + expect(next.threads[0]?.error).toBeNull(); + }); + it("stores codexThreadId from UPDATE_SESSION", () => { const state = makeState( makeThread({ diff --git a/apps/renderer/src/store.ts b/apps/renderer/src/store.ts index 24a28ab76f..56d11e11c7 100644 --- a/apps/renderer/src/store.ts +++ b/apps/renderer/src/store.ts @@ -33,6 +33,7 @@ type Action = | { type: "SET_THREAD_TITLE"; threadId: string; title: string } | { type: "SET_THREAD_MODEL"; threadId: string; model: string } | { type: "SET_RUNTIME_MODE"; mode: RuntimeMode } + | { type: "SET_RUNTIME_ERROR"; error: string | null } | { type: "BOOTSTRAP_FROM_SERVER"; bootstrap: AppBootstrapResult }; // ── State ──────────────────────────────────────────────────────────── @@ -43,6 +44,7 @@ export interface AppState { activeThreadId: string | null; runtimeMode: RuntimeMode; diffOpen: boolean; + runtimeError: string | null; } const PERSISTED_STATE_KEY = "codething:renderer-state:v4"; @@ -58,6 +60,7 @@ const initialState: AppState = { activeThreadId: null, runtimeMode: DEFAULT_RUNTIME_MODE, diffOpen: false, + runtimeError: null, }; // ── Helpers ────────────────────────────────────────────────────────── @@ -79,7 +82,7 @@ function readPersistedState(): AppState { ); if (!hydrated) return initialState; - return { ...hydrated, diffOpen: false }; + return { ...hydrated, diffOpen: false, runtimeError: null }; } catch { return initialState; } @@ -305,6 +308,12 @@ export function reducer(state: AppState, action: Action): AppState { runtimeMode: action.mode, }; + case "SET_RUNTIME_ERROR": + return { + ...state, + runtimeError: action.error, + }; + case "BOOTSTRAP_FROM_SERVER": { const { bootstrap } = action; const existingProject = state.projects.find((project) => project.cwd === bootstrap.launchCwd); @@ -370,6 +379,7 @@ export function reducer(state: AppState, action: Action): AppState { ) .concat(existingThread ? [] : [thread]), activeThreadId, + runtimeError: null, }; }