The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(webapp): retire only the legacy journal entry carrying the acknowledged id
unsupportedpastels371208bb7a57
diff --git a/apps/desktop/src/app/session/hooks/use-prompt-actions/prepared-submissions-tabs.test.ts b/apps/desktop/src/app/session/hooks/use-prompt-actions/prepared-submissions-tabs.test.tsindex e1f7fbe1897..eda77072e3c 100644--- a/apps/desktop/src/app/session/hooks/use-prompt-actions/prepared-submissions-tabs.test.ts+++ b/apps/desktop/src/app/session/hooks/use-prompt-actions/prepared-submissions-tabs.test.ts@@ -112,3 +112,14 @@ test('a tab of the earlier build still open keeps a newer entry it writes underlocalStorage.setItem(LEGACY_KEY, JSON.stringify({ [key]: entry('second', 'same words') }))expect(await journal.adoptPreparedSubmission(key, 'second')).toEqual({ key, entry: entry('second', 'same words') })})++test('retiring an entry never hides a different send the earlier build left under the same key', async () => {+ const key = intent('same words')+ const journal: Journal = await import('./prepared-submissions')+ await journal.writePreparedSubmission(key, entry('new', 'same words'))++ // A tab of the earlier build, which cannot see the new entry, journals its own send of the same words.+ localStorage.setItem(LEGACY_KEY, JSON.stringify({ [key]: entry('earlier', 'same words') }))+ await journal.removePreparedSubmission(key, 'new')+ expect(await journal.adoptPreparedSubmission(key, 'earlier')).toEqual({ key, entry: entry('earlier', 'same words') })+})diff --git a/apps/desktop/src/app/session/hooks/use-prompt-actions/prepared-submissions.ts b/apps/desktop/src/app/session/hooks/use-prompt-actions/prepared-submissions.tsindex 49f3ac86b17..6ee2c057422 100644--- a/apps/desktop/src/app/session/hooks/use-prompt-actions/prepared-submissions.ts+++ b/apps/desktop/src/app/session/hooks/use-prompt-actions/prepared-submissions.ts@@ -103,7 +103,7 @@ async function readJournal(): Promise<Record<string, PreparedSubmission>> {if (journal[key]?.id === id) {delete journal[key]// Storage may have recovered since: finish the retirement so the stale entry stops lingering.- await retireJournalEntry(key).then(() => clearSpent(key), error => console.warn('[prepared-submission-retire]', error))+ await retireJournalEntry(key, id).then(() => clearSpent(key), error => console.warn('[prepared-submission-retire]', error))} else {// Gone, or replaced by a newer send under the same key: the spent entry no longer exists.clearSpent(key)@@ -129,7 +129,7 @@ function clearSpent(key: string): void {writeSpent(key, undefined)}-async function retireJournalEntry(key: string): Promise<void> {+async function retireJournalEntry(key: string, id: string): Promise<void> {const native = window.hermesDesktop?.preparedSubmissionsif (native) {@@ -142,7 +142,8 @@ async function retireJournalEntry(key: string): Promise<void> {window.localStorage.removeItem(ENTRY_PREFIX + key)const legacy: Record<string, PreparedSubmission> = JSON.parse(window.localStorage.getItem(STORAGE_KEY) || '{}')- if (legacy[key]) { window.localStorage.setItem(LEGACY_RETIRED_PREFIX + key, legacy[key].id) }+ // Only the entry carrying this id: the blob may hold a different send an earlier-build tab wrote.+ if (legacy[key]?.id === id) { window.localStorage.setItem(LEGACY_RETIRED_PREFIX + key, id) }}export function preparedSubmissionKey(@@ -294,7 +295,7 @@ export async function removePreparedSubmission(key: string, id: string): Promise// The tombstone store failing too (quota) leaves the in-memory mark; the removal still runs.try { writeSpent(key, id) } catch (error) { console.warn('[prepared-submission-tombstone]', error) }- await retireJournalEntry(key)+ await retireJournalEntry(key, id)clearSpent(key)owned.get(key)?.()owned.delete(key)