Skip to content

Persist the mid-run follow-up queue on the thread record - #218

Merged
currentbits merged 1 commit into
mainfrom
coder/queued-follow-up-messages-live-only-in-r-80ec03
Aug 17, 2026
Merged

currentbits merged 1 commit into
mainfrom
coder/queued-follow-up-messages-live-only-in-r-80ec03

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Fixes #137.

Problem

The type-ahead queue for a running thread lived only in renderer memory (useCoder's queued state + queuedRef) — the code carried its own admission of this in a ponytail: comment. Two consequences:

  • A reload or crash mid-run silently dropped whatever the user had typed.
  • App.tsx rendered the queued strip only for the selected thread, so a queue pending elsewhere was invisible.

Change

  • ThreadInfo.queued: { prompt, attachments? } | null — the queue now lives on the thread record, normalized in electron/store.js (absent → null, same shape as the other late-added fields).
  • New threads:setQueued endpoint, plumbed exactly where setPinned is (services / ipc / preload / wireClient / shared ipc types / devCoder / fakeCoder). prompt: null clears; a non-null prompt appends to any existing queue. The append moved from the renderer into the service on purpose: the old code did a synchronous read-modify-write on a ref, and once that hop is asynchronous, two quick follow-ups could race-replace each other. It never bumps updatedAt — queueing is not activity, same rule as setPinned.
  • useCoder derives queued from the thread records via useMemo; the local state, the ref and applyQueued are gone. Persistence gives reactivity for free, since threads already stream in over threads:changed / thread:updated.
  • Leftover queues flush after the initial load for any thread that is not working. Without this, a queue that outlived a crash would never fire, because the settle transition that normally flushes it already happened.
  • Sidebar hint: a small data-queued-dot on the thread card, with the queued text as its title, alongside the existing unread and wait badges.

Flush-on-settle behaviour is unchanged — the queue still delivers at the run's terminal, including stopped.

Tests

  • electron/test/services.test.js: setQueued appends on a second call, clears on prompt: null, leaves updatedAt alone, and throws naming an unknown thread.
  • test/queuedFollowup.test.tsx: the queue round-trips through the API and survives a remount (and shows the sidebar dot); a leftover queue on a non-working thread flushes after load and clears the persisted copy before starting the run.
  • electron/test/ipc-seam.test.js gained setQueued in its endpoint enumeration.

Verification

tsc --noEmit clean. Renderer suite 718/718 pass. Electron suite 803 pass / 11 fail — all 11 reproduce unchanged at the base commit (10 orch-server tests that cannot bind a port in this environment, 1 webBridge socket reconnect test), confirmed 3/3 runs in a scratch worktree at 6b19285. No delta from this change.

  • PR created by the Claude Code agent

The type-ahead queue lived only in renderer memory, so a reload
dropped it and other threads could not show a pending hint.

Store it on ThreadInfo.queued, append or clear via threads:setQueued
(no updatedAt bump), derive the renderer queue from thread records,
flush leftover queues on load, and hint pending queues in the sidebar.

Fixes #137
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@currentbits
currentbits merged commit 5da67a1 into main Aug 17, 2026
1 check failed
@currentbits
currentbits deleted the coder/queued-follow-up-messages-live-only-in-r-80ec03 branch October 3, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Queued follow-up messages live only in renderer memory; lost on reload, invisible from other threads

1 participant