The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): show a queued prompt returned from a steer in its FIFO place
unsupportedpastelsf96673cc12a0
diff --git a/apps/desktop/src/store/pending-submissions.test.ts b/apps/desktop/src/store/pending-submissions.test.tsindex ebc4b387013..b0eb473252b 100644--- a/apps/desktop/src/store/pending-submissions.test.ts+++ b/apps/desktop/src/store/pending-submissions.test.ts@@ -46,17 +46,24 @@ it('carries the queued-row controls the owner lists onto the card, and none whenexpect(Object.values(readPendingSubmissions('chat')).some(entry => 'controls' in entry)).toBe(false)})-it('a steer in transfer hides its card without retiring it, so a return to the queue repaints it (RT-35)', () => {- reconcilePendingSubmissions('chat', [{ admission_id: 'moving', status: 'queued', user: 'steer me' }])+it('a steer in transfer hides its card without retiring it, so a return to the queue repaints it in place (RT-35)', () => {+ const later = { admission_id: 'later', status: 'queued', user: 'queued after it' }+ reconcilePendingSubmissions('chat', [{ admission_id: 'moving', status: 'queued', user: 'steer me' }, later])// Handed to the running turn: listed `started` and `steering` until that turn settles it.- reconcilePendingSubmissions('chat', [{ admission_id: 'moving', status: 'started', steering: true, user: 'steer me' }])- expect(getQueuedPrompts('chat')).toEqual([])+ reconcilePendingSubmissions('chat', [+ { admission_id: 'moving', status: 'started', steering: true, user: 'steer me' },+ later+ ])+ expect(getQueuedPrompts('chat').map(({ id }) => id)).toEqual(['later'])- // The text never reached the turn: the owner puts the same admission back in its queue place.- reconcilePendingSubmissions('chat', [{ admission_id: 'moving', status: 'queued', user: 'steer me' }])+ // The text never reached the turn: the owner puts the same admission back in its FIFO place, ahead+ // of the admission queued after it, and the card is shown where the gateway will run it.+ reconcilePendingSubmissions('chat', [{ admission_id: 'moving', status: 'queued', user: 'steer me' }, later])expect(getQueuedPrompts('chat').map(({ id, serverStatus }) => ({ id, serverStatus }))).toEqual([- { id: 'moving', serverStatus: 'queued' }+ { id: 'moving', serverStatus: 'queued' },+ { id: 'later', serverStatus: 'queued' }])+ reconcilePendingSubmissions('chat', [later])// An ordinary claim still only moves forward: a replayed `queued` never repaints a started row.reconcilePendingSubmissions('chat', [{ admission_id: 'moving', status: 'started', user: 'steer me' }])diff --git a/apps/desktop/src/store/pending-submissions.ts b/apps/desktop/src/store/pending-submissions.tsindex 0241a240a98..9941923bc07 100644--- a/apps/desktop/src/store/pending-submissions.ts+++ b/apps/desktop/src/store/pending-submissions.ts@@ -217,6 +217,9 @@ function projectQueue(admissionByInput: Map<string, string>,stillPending: Set<string>): QueuedPromptEntry[] {+ // The owner lists its admissions in FIFO order: a card it lists is shown in that order, so an+ // admission back in its queue place (a steer that never reached the turn) is not shown last.+ const order = new Map([...receipts.keys()].map((id, index) => [id, index]))const next: QueuedPromptEntry[] = []for (const entry of current) {@@ -247,6 +250,19 @@ function projectQueue(}}+ return inOwnerOrder(next, order)+}++/** Listed cards take the owner's order among the slots they hold; every other card keeps its slot. */+function inOwnerOrder(entries: QueuedPromptEntry[], order: Map<string, number>): QueuedPromptEntry[] {+ const slots = entries.flatMap((entry, index) => (order.has(entry.id) ? [index] : []))+ const listed = slots.map(index => entries[index]).sort((a, b) => (order.get(a.id) ?? 0) - (order.get(b.id) ?? 0))+ const next = [...entries]++ slots.forEach((slot, index) => {+ next[slot] = listed[index]+ })+return next}