fix(tui): queue prompts while the agent is busy#100123
Conversation
573fb89 to
aa3de22
Compare
|
Codex review: stale review; fresh review needed. Summary Next step Review history (3 earlier review cycles)
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 573fb891d9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (context.chatQueuedTurns?.has(clientRunId)) { | ||
| respond(true, { runId: clientRunId, status: "in_flight" as const }, undefined, { |
There was a problem hiding this comment.
Check queued turns before cached chat.send results
When a chat.send ACK is lost and retried after followup/collect queue admission, this new chatQueuedTurns branch is bypassed because the earlier chat:<runId> dedupe cache already returns the queued send as terminal ok while the queued turn is still pending. TUI treats ok as a terminal ACK, clears the optimistic pending state and reloads history, so the user's queued prompt can disappear even though it has not run yet; check the queued-turn map before returning the cached chat result, or avoid caching ok until the queued content is complete.
Useful? React with 👍 / 👎.
aa3de22 to
0a9f304
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0a9f304257
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| queuedFollowupEnqueued = registerQueuedChatTurn({ | ||
| chatQueuedTurns: ensureChatQueuedTurns(context), | ||
| runId: clientRunId, | ||
| controller: activeRunAbort.controller, | ||
| sessionId: backingSessionId ?? clientRunId, |
There was a problem hiding this comment.
Preserve queued BTW turns during session stops
When a /btw prompt is admitted to the followup/collect queue, this queued-turn registration drops the turnKind that was computed for the chat.send. TUI session-scoped stops call chat.abort with preserveSideRuns: true, and the active/pre-registered abort paths skip BTW runs by checking turnKind, but queued turns have no such field so abortAuthorizedQueuedTurnsForSession still aborts them. This means pressing Esc or /stop to stop the main session can cancel an unrelated queued BTW question; carry turnKind into QueuedChatTurnEntry and apply the same preserve-side-runs filter there.
Useful? React with 👍 / 👎.
|
Land-ready proof for
Known proof gaps: none. |
Allow busy TUI sessions to forward prompts into the configured queue while keeping queued-turn admission, cancellation, restart, and transcript ownership consistent across the TUI, Gateway, and followup queue. Co-authored-by: Sebastien Tardif <[email protected]>
0a9f304 to
7b8f573
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7b8f573a38
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const abortsPendingRun = Boolean( | ||
| state.pendingChatRunId && runIds.includes(state.pendingChatRunId), | ||
| ); | ||
| const abortsPendingRun = Boolean(state.pendingChatRunId); |
There was a problem hiding this comment.
Clear pre-ACK pending submits after session abort
When Esc or /stop is pressed after addPendingUser() but before sendChat() has returned, pendingOptimisticUserMessage and pendingSubmitDraft are set while pendingChatRunId is still null. A session-scoped abort can still cancel that pre-registered queued send and return its run id, but this flag stays false, so the row may be dropped while the TUI remains in a pending/busy state until the original chat.send ACK arrives; if that ACK was the transport failure being recovered from, the user is stuck blocked after a successful abort. Treat the current pendingSubmitDraft/returned run ids as a pending abort target, not only pendingChatRunId.
Useful? React with 👍 / 👎.
Allow busy TUI sessions to forward prompts into the configured queue while keeping queued-turn admission, cancellation, restart, and transcript ownership consistent across the TUI, Gateway, and followup queue. Co-authored-by: Sebastien Tardif <[email protected]>
Closes #89059
Closes #90012
Supersedes #89078. The reviewed contributor work is preserved with
Co-authored-by: Sebastien Tardif <[email protected]>.What Problem This Solves
Fixes an issue where TUI users who submitted another prompt while an agent was busy were blocked with an “agent is busy” notice even when their configured queue mode should accept the prompt. Queued prompts could also lose cancellation, restart, or transcript ownership across the TUI and Gateway lifecycle.
Why This Change Was Made
Busy TUI sessions now forward prompts into the configured queue while admission is available. The Gateway tracks queued turns as first-class owners through abort, restart, collection, overflow summarization, and completion; session-wide stop preserves BTW side runs, with a compatibility retry for older Gateways.
User Impact
Users can keep typing in the TUI while a run is active and receive the configured followup or collect behavior. Esc and
/stopcancel the intended queued or active turn without dropping unrelated work, and queued rows are removed when their run terminalizes.Evidence