mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
feat: add session status store with optimistic active state and SSE polling (#272)
* feat: add session status store with optimistic active state and SSE polling - Adds sessionStatusStore with setOptimisticActive (auto-timeout), statusCache deduplication, and replaceStatuses/clearStatus - Integrates store in useSendPrompt (set optimistic on send, clear on error) - Adds session.status SSE event handling in useSSE with 5s polling fallback - Refactors test to mock the store instead of using real store instance - Fixes repoId null check in useRepoActivity * feat: replace event-source-polyfill with native SSE for PromptInput * fix: keep stop button visible and hide clear prompt button during active session * feat: restore failed queued prompts and preserve optimistic active status during poll * test: add MessageThread tests for optimistic editing state and resend flow * fix: handle queued prompt edge cases during pending submission and SSE errors
This commit is contained in:
1 parent
931f1215e6
commit
4e32fd5b00
16 files changed
+833
-61
No files matched your search
@@ -5,22 +5,55 @@ export interface SendError {
|
||||
title: string
|
||||
message: string
|
||||
detail?: string
|
||||
failedPrompt?: string
|
||||
}
|
||||
|
||||
interface SendErrorStore {
|
||||
errors: Record<string, SendError>
|
||||
queuedPrompts: Record<string, string>
|
||||
setError: (err: SendError) => void
|
||||
setQueuedPrompt: (sessionID: string, prompt: string) => void
|
||||
clearQueuedPrompt: (sessionID: string) => void
|
||||
failQueuedPrompt: (err: Omit<SendError, 'failedPrompt'>) => void
|
||||
clearError: (sessionID: string) => void
|
||||
getError: (sessionID: string) => SendError | null
|
||||
}
|
||||
|
||||
export const useSendErrorStore = create<SendErrorStore>((set, get) => ({
|
||||
errors: {},
|
||||
queuedPrompts: {},
|
||||
setError: (err: SendError) => {
|
||||
set((state) => ({
|
||||
errors: { ...state.errors, [err.sessionID]: err },
|
||||
}))
|
||||
},
|
||||
setQueuedPrompt: (sessionID: string, prompt: string) => {
|
||||
set((state) => ({
|
||||
queuedPrompts: { ...state.queuedPrompts, [sessionID]: prompt },
|
||||
}))
|
||||
},
|
||||
clearQueuedPrompt: (sessionID: string) => {
|
||||
set((state) => {
|
||||
const queuedPrompts = { ...state.queuedPrompts }
|
||||
delete queuedPrompts[sessionID]
|
||||
return { queuedPrompts }
|
||||
})
|
||||
},
|
||||
failQueuedPrompt: (err: Omit<SendError, 'failedPrompt'>) => {
|
||||
set((state) => {
|
||||
const failedPrompt = state.queuedPrompts[err.sessionID]
|
||||
if (!failedPrompt) return state
|
||||
const queuedPrompts = { ...state.queuedPrompts }
|
||||
delete queuedPrompts[err.sessionID]
|
||||
return {
|
||||
errors: {
|
||||
...state.errors,
|
||||
[err.sessionID]: { ...err, failedPrompt },
|
||||
},
|
||||
queuedPrompts,
|
||||
}
|
||||
})
|
||||
},
|
||||
clearError: (sessionID: string) => {
|
||||
set((state) => {
|
||||
const newErrors = { ...state.errors }
|
||||
|
||||
Reference in new issue
Block a user