Preserve thread input across TUI session resumes (#61216)

## Why

Resuming another session must keep drafts, queued follow-ups, and interrupted steer retries with their original thread. Submitted input whose delivery is still uncertain must wait for matching receipts before the queue can advance.

## What changed

- Pause submissions while draining outgoing events, then capture input before switching threads or backends.
- Restore saved input through a shared resume path, reconcile receipts from resumed history and buffered events, preserve active-turn state, and dispatch eligible queued input when the resumed thread is idle.
- Preserve whether a draft's leading `!` is literal text or a shell command.
- Reject `!` shell commands in Cloud conversations with an error and clear the pending submission so the next prompt can proceed.

## Testing

Add regression coverage for session round trips with buffered completion and interruption events, receipt reconciliation across read-only and writable resumes, draft shell mode, and submitting a prompt after a rejected Cloud shell command.

GitOrigin-RevId: 9a823a398a371e689b8ae743de494323ae95ef57
This commit is contained in:
Benjamin Carlsson
2026-11-13 00:52:53 +00:00
committed by copyberry
parent 006911a313
commit 5183e1dcb2
20 changed files with 841 additions and 133 deletions
+5 -1
View File
@@ -50,6 +50,8 @@ pub(super) struct InputQueueState {
/// fresh user turn instead of restoring them into the composer.
pub(super) submit_pending_steers_after_interrupt: bool,
pub(super) suppress_queue_autosend: bool,
/// Independent of settings suppression, which a drained event can set.
pub(super) resume_handoff: std::sync::Weak<()>,
pub(super) transcript_copy: std::sync::Weak<crate::copy_input_guard::CopyInputGuard>,
/// Hold submissions while a usage failure or backend-directed model fallback is resolved.
pub(super) rate_limit_recovery_pending: bool,
@@ -67,7 +69,9 @@ impl InputQueueState {
}
pub(super) fn submissions_paused(&self) -> bool {
self.suppress_queue_autosend || self.transcript_copy.strong_count() > 0
self.suppress_queue_autosend
|| self.transcript_copy.strong_count() > 0
|| self.resume_handoff.strong_count() > 0
}
pub(super) fn has_unconfirmed_messages(&self) -> bool {