Skip to content

The agent that grows with you

fix: reconcile queue input IDs with canonical admission identities

Tekniuma877aa6e5a11
diff --git a/apps/desktop/src/store/pending-submissions.test.ts b/apps/desktop/src/store/pending-submissions.test.ts
index 49680d75c5f..bdda28b5ecb 100644
--- a/apps/desktop/src/store/pending-submissions.test.ts
+++ b/apps/desktop/src/store/pending-submissions.test.ts
@@ -61,6 +61,16 @@ it('recovers remote pending text into the queue and journal without a local subm
}
})
+it('maps optimistic input identity to the admission identity before local drain can replay it', () => {
+ enqueueQueuedPrompt('mapped', { id: 'input-id', text: 'same', attachments: [] })
+ const receipt = { admission_id: 'admission-id', input_id: 'input-id', status: 'queued', user: 'same' }
+ reconcilePendingSubmissions('mapped', [receipt])
+ expect(getQueuedPrompts('mapped')).toMatchObject([{ id: 'admission-id', serverStatus: 'queued', text: 'same' }])
+ expect(getQueuedPrompts('mapped')).toHaveLength(1)
+ reconcilePendingSubmissions('mapped', [{ ...receipt, status: 'started' }])
+ expect(getQueuedPrompts('mapped')).toEqual([])
+})
+
it('persists identified direct submissions independently of the automatic local queue', () => {
trackPendingSubmission('chat', { id: 'direct', text: 'hello' })
const stored = JSON.parse(window.localStorage.getItem('hermes.desktop.pendingSubmissions.v1')!)
diff --git a/apps/desktop/src/store/pending-submissions.ts b/apps/desktop/src/store/pending-submissions.ts
index 5bb828039ce..6204379aa83 100644
--- a/apps/desktop/src/store/pending-submissions.ts
+++ b/apps/desktop/src/store/pending-submissions.ts
@@ -21,10 +21,12 @@ export function reconcilePendingSubmissions(key: string, value: unknown): void {
const journal = readJournal()
const known = journal[key] ?? {}
const receipts = new Map<string, PendingSubmission>()
+ const admissionByInput = new Map<string, string>()
for (const raw of value) {
if (!raw || typeof raw.admission_id !== 'string' || !['queued', 'started', 'unknown'].includes(raw.status)) { continue }
const id = raw.admission_id
+ if (typeof raw.input_id === 'string') { admissionByInput.set(raw.input_id, id) }
receipts.set(id, { ...known[id], id, text: typeof raw.user === 'string' ? raw.user : known[id]?.text ?? '', status: raw.status })
}
@@ -32,11 +34,11 @@ export function reconcilePendingSubmissions(key: string, value: unknown): void {
const next: QueuedPromptEntry[] = []
for (const entry of current) {
- const receipt = receipts.get(entry.id)
+ const receipt = receipts.get(admissionByInput.get(entry.id) ?? entry.id)
if (receipt) {
- if (receipt.status !== 'started') { next.push({ ...entry, serverStatus: receipt.status }) }
- receipts.delete(entry.id)
+ if (receipt.status !== 'started') { next.push({ ...entry, id: receipt.id, serverStatus: receipt.status }) }
+ receipts.delete(receipt.id)
} else if (!entry.serverStatus) { next.push(entry) }
}