Skip to content

The agent that grows with you

fix(desktop): a queued entry's new terminal selection mints a new submission id

Tekniumfdbdcfd98648
diff --git a/apps/desktop/src/store/composer-queue.test.ts b/apps/desktop/src/store/composer-queue.test.ts
index 09da587b26c..a4795173da2 100644
--- a/apps/desktop/src/store/composer-queue.test.ts
+++ b/apps/desktop/src/store/composer-queue.test.ts
@@ -13,6 +13,7 @@ import {
migrateQueuedPrompts,
parkQueuedPrompts,
promoteQueuedPrompt,
+ queuedSubmissionId,
removeQueuedPrompt,
resetFrozenQueuedTransportsForTests,
resolveQueuedPromptTransport,
@@ -498,6 +499,24 @@ describe('composer queue terminal payload persistence', () => {
})
})
+ it('drains an entry whose terminal selection was replaced under a new submission id', () => {
+ const entry = enqueueQueuedPrompt(SESSION_KEY, {
+ attachments: [],
+ text: TERMINAL_CHIP_DRAFT,
+ displayText: TERMINAL_CHIP_DRAFT,
+ frozenTransport: SELECTION_A_TRANSPORT
+ })
+
+ // Same chip text, a different selection behind it: the payload sent changed.
+ updateQueuedPrompt(SESSION_KEY, entry!.id, {
+ text: TERMINAL_CHIP_DRAFT,
+ displayText: TERMINAL_CHIP_DRAFT,
+ frozenTransport: '```terminal\nselection B\n```\n\nlook at'
+ })
+
+ expect(queuedSubmissionId(getQueuedPrompts(SESSION_KEY)[0]!)).not.toBe(entry!.id)
+ })
+
it('cleans the ephemeral payload on remove and clear', () => {
const first = enqueueQueuedPrompt(SESSION_KEY, {
attachments: [],
diff --git a/apps/desktop/src/store/composer-queue.ts b/apps/desktop/src/store/composer-queue.ts
index 9d129b3ef33..afb905e9288 100644
--- a/apps/desktop/src/store/composer-queue.ts
+++ b/apps/desktop/src/store/composer-queue.ts
@@ -338,8 +338,18 @@ const cloneAttachments = (attachments: ComposerAttachment[]) => attachments.map(
const attachmentKeys = (attachments: ComposerAttachment[]) => JSON.stringify(attachments.map(a => a.id))
// An edited local entry is a new message: it drains under a fresh submission id (see `submissionId`).
-const editedSubmission = (entry: QueuedPromptEntry, text: string, attachments: ComposerAttachment[]) =>
- !entry.serverStatus && (entry.text !== text || attachmentKeys(entry.attachments) !== attachmentKeys(attachments))
+// The frozen `@terminal` transport is part of what is sent: a new selection behind the same chip text
+// changes the payload, so under the old id it would read as the original's retry and be dropped.
+const editedSubmission = (
+ entry: QueuedPromptEntry,
+ text: string,
+ attachments: ComposerAttachment[],
+ previousTransport: string | undefined
+) =>
+ !entry.serverStatus &&
+ (entry.text !== text ||
+ attachmentKeys(entry.attachments) !== attachmentKeys(attachments) ||
+ (previousTransport?.trim() ?? '') !== (frozenQueuedTransportById.get(entry.id)?.trim() ?? ''))
? { submissionId: randomUuid() }
: {}
@@ -557,6 +567,7 @@ export const updateQueuedPrompt = (
}
changed = true
+ const previousTransport = frozenQueuedTransportById.get(entry.id)
if (update.frozenTransport !== undefined) {
const nextFrozen = update.frozenTransport?.trim() ?? ''
@@ -577,7 +588,7 @@ export const updateQueuedPrompt = (
return {
...rest,
- ...editedSubmission(entry, update.text, attachments),
+ ...editedSubmission(entry, update.text, attachments, previousTransport),
text: update.text,
attachments,
...(nextDisplay ? { displayText: nextDisplay } : {})