Skip to content

The agent that grows with you

fix(desktop): show the lost-turn card and Discard without expanding the queue

Teknium6f397ca74fad
diff --git a/apps/desktop/src/app/chat/composer/queue-panel.test.tsx b/apps/desktop/src/app/chat/composer/queue-panel.test.tsx
index b9988cf3e77..0c46d8c3772 100644
--- a/apps/desktop/src/app/chat/composer/queue-panel.test.tsx
+++ b/apps/desktop/src/app/chat/composer/queue-panel.test.tsx
@@ -13,7 +13,7 @@ const entry = (id: string, text: string): QueuedPromptEntry => ({
text
})
-function renderPanel(entries: QueuedPromptEntry[]) {
+function renderPanel(entries: QueuedPromptEntry[], onDiscardLost?: (id: string) => void) {
return render(
<I18nProvider configClient={{ getConfig: async () => ({}), saveConfig: async () => ({ ok: true }) }}>
<QueuePanel
@@ -21,6 +21,7 @@ function renderPanel(entries: QueuedPromptEntry[]) {
editingId={null}
entries={entries}
onDelete={vi.fn()}
+ onDiscardLost={onDiscardLost}
onEdit={vi.fn()}
onResume={vi.fn()}
onSendNow={vi.fn()}
@@ -80,3 +81,41 @@ describe('QueuePanel expandable previews', () => {
expect(screen.getByRole('button', { name: /expand/i }).getAttribute('aria-expanded')).toBe('false')
})
})
+
+// #134889 NF2: after the gateway is killed mid-turn, owner recovery fences the turn `unknown` and
+// pauses the FIFO behind it. The Discard choice lived inside the collapsed queue section, so the
+// chat showed only "1 Queued" (then "2 Queued" for a follow-up) with no reason and no action.
+describe('QueuePanel lost turn', () => {
+ it('shows the lost turn and its Discard without expanding, and names the pause', async () => {
+ const onDiscardLost = vi.fn()
+ renderPanel([{ ...entry('lost', 'doomed turn'), serverStatus: 'unknown' }, entry('next', 'follow up')], onDiscardLost)
+
+ expect(await screen.findByText('Turn lost during restart')).toBeTruthy()
+ expect(screen.getByRole('button', { name: /2 queued — paused/i })).toBeTruthy()
+ // Only the lost row is previewed while collapsed; the healthy follow-up stays inside the section.
+ expect(screen.queryByText('follow up')).toBeNull()
+ fireEvent.click(screen.getByRole('button', { name: 'Discard' }))
+ expect(onDiscardLost).toHaveBeenCalledWith('lost')
+ })
+
+ it('opens when a queued row turns lost after the panel mounted', async () => {
+ const view = renderPanel([entry('a', 'first')])
+ expect(view.queryByText('Turn lost during restart')).toBeNull()
+ view.rerender(
+ <I18nProvider configClient={{ getConfig: async () => ({}), saveConfig: async () => ({ ok: true }) }}>
+ <QueuePanel
+ busy={false}
+ editingId={null}
+ entries={[{ ...entry('a', 'first'), serverStatus: 'unknown' }]}
+ onDelete={vi.fn()}
+ onDiscardLost={vi.fn()}
+ onEdit={vi.fn()}
+ onResume={vi.fn()}
+ onSendNow={vi.fn()}
+ parked={false}
+ />
+ </I18nProvider>
+ )
+ expect(await screen.findByText('Turn lost during restart')).toBeTruthy()
+ })
+})
diff --git a/apps/desktop/src/app/chat/composer/queue-panel.tsx b/apps/desktop/src/app/chat/composer/queue-panel.tsx
index ca3a83f1a90..0a1f5fdf858 100644
--- a/apps/desktop/src/app/chat/composer/queue-panel.tsx
+++ b/apps/desktop/src/app/chat/composer/queue-panel.tsx
@@ -72,6 +72,102 @@ export function QueuePanel({
return null
}
+ const renderRow = (entry: QueuedPromptEntry) => {
+ const isEditing = editingId === entry.id
+ const attachmentsCount = entry.attachments.length
+
+ // Steer only surfaces where it can actually deliver: a live turn to
+ // redirect and an entry the redirect can carry (text-only, no slash).
+ // A server row can be steered only when its owner serves the verb for it.
+ const canSteer =
+ busy &&
+ Boolean(onSteerNow) &&
+ (entry.serverStatus ? Boolean(entry.serverControls?.includes('steer')) : isSteerableEntry(entry))
+
+ // The owner died mid-turn and recovered this row as `unknown`: the
+ // FIFO behind it is paused until someone acknowledges the loss.
+ const lost = entry.serverStatus === 'unknown'
+ const preview = entryPreview(entry, c)
+ const canExpand = shouldOfferExpandedPreview(preview)
+ const isExpanded = expandedIds.has(entry.id)
+
+ return (
+ <StatusRow
+ className={cn(
+ isEditing &&
+ 'ring-1 ring-inset ring-[color-mix(in_srgb,var(--dt-composer-ring)_40%,transparent)] bg-accent/25'
+ )}
+ dismiss={{ label: c.queueDelete, onDismiss: () => onDelete(entry.id) }}
+ key={entry.id}
+ leading={<Codicon className="text-muted-foreground/70" name="comment" size="0.8rem" />}
+ trailing={
+ <>
+ {canExpand && (
+ <Tip label={isExpanded ? c.queueCollapse : c.queueExpand}>
+ <Button
+ aria-expanded={isExpanded}
+ aria-label={isExpanded ? c.queueCollapse : c.queueExpand}
+ className="size-5 rounded-md"
+ onClick={() => toggleExpanded(entry.id)}
+ size="icon-xs"
+ type="button"
+ variant="ghost"
+ >
+ <Codicon
+ className={cn('transition-transform', isExpanded && 'rotate-180')}
+ name="chevron-down"
+ size={iconSize.xs}
+ />
+ </Button>
+ </Tip>
+ )}
+ {renderEntryActions({
+ busy,
+ c,
+ editingId,
+ entry,
+ isEditing,
+ lost,
+ onDiscardLost,
+ onEdit,
+ onSendNow,
+ onSteerNow,
+ canSteer
+ })}
+ </>
+ }
+ trailingVisible={isEditing || lost}
+ >
+ <div className="min-w-0 flex-1">
+ <p
+ className={cn(
+ 'text-[0.73rem] leading-4 text-foreground/92',
+ isExpanded ? 'max-h-40 overflow-y-auto whitespace-pre-wrap pr-1' : 'line-clamp-2 break-words'
+ )}
+ >
+ {preview}
+ </p>
+ {(attachmentsCount > 0 || isEditing || lost) && (
+ <div className="mt-0.5 flex items-center gap-1.5 text-[0.64rem] text-muted-foreground/75">
+ {lost && <span data-slot="queue-lost-note">{c.queueLostNote}</span>}
+ {attachmentsCount > 0 && <span>{c.attachments(attachmentsCount)}</span>}
+ {isEditing && (
+ <span className="text-[color-mix(in_srgb,var(--dt-composer-ring)_78%,var(--muted-foreground))]">
+ {c.editingInComposer}
+ </span>
+ )}
+ </div>
+ )}
+ </div>
+ </StatusRow>
+ )
+ }
+
+ // A lost (`unknown`) turn pauses the FIFO until someone acknowledges it: its card and Discard
+ // must be on screen without expanding the section, and the header names the pause (#134889 NF2).
+ const lostEntries = entries.filter(entry => entry.serverStatus === 'unknown')
+ const paused = parked || lostEntries.length > 0
+
return (
<StatusSection
accessory={
@@ -89,99 +185,11 @@ export function QueuePanel({
</Tip>
) : undefined
}
- icon={<Codicon className="text-muted-foreground/70" name={parked ? 'debug-pause' : 'layers'} size="0.8rem" />}
- label={parked ? c.queuedPaused(entries.length) : c.queued(entries.length)}
+ icon={<Codicon className="text-muted-foreground/70" name={paused ? 'debug-pause' : 'layers'} size="0.8rem" />}
+ label={paused ? c.queuedPaused(entries.length) : c.queued(entries.length)}
+ preview={lostEntries.length > 0 ? lostEntries.map(renderRow) : undefined}
>
- {entries.map(entry => {
- const isEditing = editingId === entry.id
- const attachmentsCount = entry.attachments.length
-
- // Steer only surfaces where it can actually deliver: a live turn to
- // redirect and an entry the redirect can carry (text-only, no slash).
- // A server row can be steered only when its owner serves the verb for it.
- const canSteer =
- busy &&
- Boolean(onSteerNow) &&
- (entry.serverStatus ? Boolean(entry.serverControls?.includes('steer')) : isSteerableEntry(entry))
-
- // The owner died mid-turn and recovered this row as `unknown`: the
- // FIFO behind it is paused until someone acknowledges the loss.
- const lost = entry.serverStatus === 'unknown'
- const preview = entryPreview(entry, c)
- const canExpand = shouldOfferExpandedPreview(preview)
- const isExpanded = expandedIds.has(entry.id)
-
- return (
- <StatusRow
- className={cn(
- isEditing &&
- 'ring-1 ring-inset ring-[color-mix(in_srgb,var(--dt-composer-ring)_40%,transparent)] bg-accent/25'
- )}
- dismiss={{ label: c.queueDelete, onDismiss: () => onDelete(entry.id) }}
- key={entry.id}
- leading={<Codicon className="text-muted-foreground/70" name="comment" size="0.8rem" />}
- trailing={
- <>
- {canExpand && (
- <Tip label={isExpanded ? c.queueCollapse : c.queueExpand}>
- <Button
- aria-expanded={isExpanded}
- aria-label={isExpanded ? c.queueCollapse : c.queueExpand}
- className="size-5 rounded-md"
- onClick={() => toggleExpanded(entry.id)}
- size="icon-xs"
- type="button"
- variant="ghost"
- >
- <Codicon
- className={cn('transition-transform', isExpanded && 'rotate-180')}
- name="chevron-down"
- size={iconSize.xs}
- />
- </Button>
- </Tip>
- )}
- {renderEntryActions({
- busy,
- c,
- editingId,
- entry,
- isEditing,
- lost,
- onDiscardLost,
- onEdit,
- onSendNow,
- onSteerNow,
- canSteer
- })}
- </>
- }
- trailingVisible={isEditing || lost}
- >
- <div className="min-w-0 flex-1">
- <p
- className={cn(
- 'text-[0.73rem] leading-4 text-foreground/92',
- isExpanded ? 'max-h-40 overflow-y-auto whitespace-pre-wrap pr-1' : 'line-clamp-2 break-words'
- )}
- >
- {preview}
- </p>
- {(attachmentsCount > 0 || isEditing || lost) && (
- <div className="mt-0.5 flex items-center gap-1.5 text-[0.64rem] text-muted-foreground/75">
- {lost && <span data-slot="queue-lost-note">{c.queueLostNote}</span>}
- {attachmentsCount > 0 && <span>{c.attachments(attachmentsCount)}</span>}
- {isEditing && (
- <span className="text-[color-mix(in_srgb,var(--dt-composer-ring)_78%,var(--muted-foreground))]">
- {c.editingInComposer}
- </span>
- )}
- </div>
- )}
- </div>
- </StatusRow>
- )
- })}
+ {entries.map(renderRow)}
</StatusSection>
)
}