Skip to content

The agent that grows with you

fix(desktop): port the drain-failure budget helpers onto the live persisted queue

Brooklyn Nicholson8205b8dd9c27
diff --git a/apps/desktop/src/store/composer-queue.ts b/apps/desktop/src/store/composer-queue.ts
index 515bc84f859..d86e2c65863 100644
--- a/apps/desktop/src/store/composer-queue.ts
+++ b/apps/desktop/src/store/composer-queue.ts
@@ -292,16 +292,13 @@ export const noteQueuedPromptDrainFailure = (key: string | null | undefined, id:
return
}
- const queue = queueFor(sid)
-
- if (!queue.some(e => e.id === id)) {
- return
- }
+ mutateSession(sid, queue => {
+ if (!queue.some(e => e.id === id)) {
+ return null
+ }
- writeSession(
- sid,
- queue.map(e => (e.id === id ? { ...e, drainFailures: (e.drainFailures ?? 0) + 1 } : e))
- )
+ return queue.map(e => (e.id === id ? { ...e, drainFailures: (e.drainFailures ?? 0) + 1 } : e))
+ })
}
/** Clear a queued entry's persisted drain-failure budget — the queue-panel
@@ -315,16 +312,13 @@ export const clearQueuedPromptDrainFailures = (key: string | null | undefined, i
return
}
- const queue = queueFor(sid)
-
- if (!queue.some(e => e.id === id && e.drainFailures)) {
- return
- }
+ mutateSession(sid, queue => {
+ if (!queue.some(e => e.id === id && e.drainFailures)) {
+ return null
+ }
- writeSession(
- sid,
- queue.map(e => (e.id === id ? { ...e, drainFailures: undefined } : e))
- )
+ return queue.map(e => (e.id === id ? { ...e, drainFailures: undefined } : e))
+ })
}
export const promoteQueuedPrompt = (key: string | null | undefined, id: string): boolean => {