fix: follow up prompt preservation changes (#292)

* fix: remove unused disabled prop, throttle SW update checks, precache icon

* fix: retract transient send error and restored prompt once server confirms send

When a long-running prompt request drops (gateway timeout or network error)
while the agent is actually working, the send error banner and the restored
prompt text were left in place. Tag send errors as 'network' and clear them
when the server confirms session activity (message.updated / session.idle),
also clearing the restored input text. Genuine server-reported session errors
(kind 'session') are preserved.

* style: restyle ErrorBanner with neutral card fill and destructive accent bar

Replace the all-red destructive Alert variant (transparent background, full
red text) with a neutral card-filled banner, a left destructive accent bar,
red icon, foreground title, and muted body/detail text. Improves the send-error
and git-error banners on the dark theme.
This commit is contained in:
Chris Scott authored and GitHub committed 2026-06-27 09:26:37 -04:00
1 parent 71ba7371bc
commit 8d93f2f1f9
11 files changed
+215 -31

No files matched your search

+1 -1
View File
@@ -506,6 +506,7 @@ export const useSendPrompt = (opcodeUrl: string | null | undefined, directory?:
message: parsed.message,
detail: error instanceof FetchError ? error.detail : undefined,
failedPrompt: failedPrompt || undefined,
kind: 'network',
});
},
onSuccess: async (data, variables) => {
@@ -535,7 +536,6 @@ export const useSendPrompt = (opcodeUrl: string | null | undefined, directory?:
return [...old, { info: response.info, parts: response.parts }];
},
);
},
});
};
+117
View File
@@ -396,11 +396,128 @@ describe('useSSE', () => {
title: 'Error',
message: 'Queued send failed',
failedPrompt: 'queued message',
kind: 'session',
})
unmount()
})
it('retracts a network send error when the server confirms session activity', async () => {
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } })
const wrapper = ({ children }: { children: ReactNode }) => (
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
)
useSendErrorStore.getState().setError({
sessionID: 'session-1',
title: 'Connection Failed',
message: 'Could not connect to the server.',
failedPrompt: 'in-flight prompt',
kind: 'network',
})
const { result, unmount } = renderHook(
() => useSSE('http://localhost:5551', '/repo', 'session-1'),
{ wrapper },
)
await waitFor(() => expect(MockEventSource.instances).toHaveLength(1))
act(() => {
MockEventSource.instances[0].emit('connected', { clientId: 'client-1' })
})
await waitFor(() => expect(result.current.isConnected).toBe(true))
act(() => {
MockEventSource.instances[0].emit('message', {
type: 'message.updated',
properties: {
info: { id: 'assistant-1', role: 'assistant', sessionID: 'session-1', time: { created: 1 } },
},
})
})
expect(useSendErrorStore.getState().getError('session-1')).toBeNull()
unmount()
})
it('retracts a network send error when the session goes idle', async () => {
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } })
const wrapper = ({ children }: { children: ReactNode }) => (
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
)
useSendErrorStore.getState().setError({
sessionID: 'session-1',
title: 'Request Timeout',
message: 'The request took too long.',
kind: 'network',
})
const { result, unmount } = renderHook(
() => useSSE('http://localhost:5551', '/repo', 'session-1'),
{ wrapper },
)
await waitFor(() => expect(MockEventSource.instances).toHaveLength(1))
act(() => {
MockEventSource.instances[0].emit('connected', { clientId: 'client-1' })
})
await waitFor(() => expect(result.current.isConnected).toBe(true))
act(() => {
MockEventSource.instances[0].emit('message', {
type: 'session.idle',
properties: { sessionID: 'session-1' },
})
})
expect(useSendErrorStore.getState().getError('session-1')).toBeNull()
unmount()
})
it('preserves a server-reported session error when the session later goes idle', async () => {
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } })
const wrapper = ({ children }: { children: ReactNode }) => (
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
)
useSendErrorStore.getState().setQueuedPrompt('session-1', 'queued message')
const { result, unmount } = renderHook(
() => useSSE('http://localhost:5551', '/repo', 'session-1'),
{ wrapper },
)
await waitFor(() => expect(MockEventSource.instances).toHaveLength(1))
act(() => {
MockEventSource.instances[0].emit('connected', { clientId: 'client-1' })
})
await waitFor(() => expect(result.current.isConnected).toBe(true))
act(() => {
MockEventSource.instances[0].emit('message', {
type: 'session.error',
properties: {
sessionID: 'session-1',
error: { name: 'UnknownError', data: { message: 'Queued send failed' } },
},
})
})
act(() => {
MockEventSource.instances[0].emit('message', {
type: 'session.idle',
properties: { sessionID: 'session-1' },
})
})
expect(useSendErrorStore.getState().getError('session-1')).not.toBeNull()
unmount()
})
it('does not create a send error banner once the queued prompt has been cleared', async () => {
const queryClient = new QueryClient({
defaultOptions: {
+2
View File
@@ -156,6 +156,7 @@ export const useSSE = (opcodeUrl: string | null | undefined, directory?: string
const { info } = event.properties
const sessionID = info.sessionID
useSendErrorStore.getState().clearNetworkError(sessionID)
if (info.role === 'user') {
useSendErrorStore.getState().clearQueuedPrompt(sessionID)
}
@@ -231,6 +232,7 @@ export const useSSE = (opcodeUrl: string | null | undefined, directory?: string
const { sessionID } = event.properties
setSessionStatus(sessionID, { type: 'idle' })
useSendErrorStore.getState().clearNetworkError(sessionID)
batcherRef.current?.flush({ sessionID, directory: cacheDirectory })