Skip to content

Commit 5228114

Browse files
committed
fix: surface git status stream errors to UI via onError callback
The subscribeToGitStatus function only updated the atom's data field on stream events but never populated error or cause. This meant the error display UI in GitActionsControl was dead code — gitStatusError was always null. Added an onError callback to SubscribeOptions (WsTransport) and StreamSubscriptionOptions (wsRpcClient), invoked when the stream disconnects with an error. subscribeToGitStatus now uses this callback to set the error and cause fields on the git status atom, allowing the existing UI error rendering path to work.
1 parent e234ed0 commit 5228114

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

apps/web/src/lib/gitStatusState.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,17 @@ function subscribeToGitStatus(cwd: string): () => void {
193193
onResubscribe: () => {
194194
markGitStatusPending(cwd);
195195
},
196+
onError: (error) => {
197+
const atom = gitStatusStateAtom(cwd);
198+
const current = appAtomRegistry.get(atom);
199+
const cause = Cause.fail(error as GitStatusStreamError);
200+
appAtomRegistry.set(atom, {
201+
data: current.data,
202+
error: error as GitStatusStreamError,
203+
cause,
204+
isPending: false,
205+
});
206+
},
196207
},
197208
);
198209
}

apps/web/src/wsRpcClient.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type RpcInput<TTag extends RpcTag> = Parameters<RpcMethod<TTag>>[0];
2222

2323
interface StreamSubscriptionOptions {
2424
readonly onResubscribe?: () => void;
25+
readonly onError?: (error: unknown) => void;
2526
}
2627

2728
type RpcUnaryMethod<TTag extends RpcTag> =

apps/web/src/wsTransport.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
interface SubscribeOptions {
2222
readonly retryDelay?: Duration.Input;
2323
readonly onResubscribe?: () => void;
24+
readonly onError?: (error: unknown) => void;
2425
}
2526

2627
interface RequestOptions {
@@ -147,6 +148,11 @@ export class WsTransport {
147148
console.warn("WebSocket RPC subscription disconnected", {
148149
error: formatErrorMessage(error),
149150
});
151+
try {
152+
options?.onError?.(error);
153+
} catch {
154+
// Swallow onError callback errors so the retry loop continues.
155+
}
150156
await sleep(retryDelayMs);
151157
}
152158
}

0 commit comments

Comments
 (0)