Surface runtime connectivity errors in renderer bootstrap

Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
Cursor AgentandTheo Browne committed 2026-02-09 22:40:23 +00:00
1 parent 39adcb6f04
commit 6cc4e616bb
3 files changed
+39 -3

No files matched your search

+14 -2
View File
@@ -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() {
<div className="flex h-screen overflow-hidden bg-background text-foreground">
<BootstrapRouter />
<EventRouter />
{state.runtimeError && state.projects.length === 0 && (
<div className="pointer-events-none fixed right-4 top-4 z-50 max-w-[440px] rounded-lg border border-rose-400/30 bg-rose-500/10 px-3 py-2 text-xs text-rose-100">
Runtime connection failed: {state.runtimeError}
</div>
)}
<Sidebar />
<ChatView />
{state.diffOpen && <DiffPanel />}
+14
View File
@@ -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({
+11 -1
View File
@@ -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,
};
}