Preserve queued TUI input semantics (#39604)

## Why

Paste placeholders and deferred slash-command parsing can hide the meaning of an input until it is expanded or a session is configured. Draining such input as an ordinary message can accidentally treat pasted text beginning with `!` as a shell command or lose `/plan` behavior.

## What changed

- Track paste-expanded inputs that begin with `!` as literal model input through history, queue editing, retries, and startup queues.
- Defer `/plan` parsing when session or model state is unavailable, then submit it in plan mode with shell escapes disabled.
- Drain queued input only after session configuration, and keep later queued prompts pending when an initial prompt cannot be submitted.
- Suppress queue auto-send before applying a replayed thread session so input from the outgoing thread is not submitted during restoration.

## Testing

Add coverage for direct, recalled, edited, interrupted, rejected, startup-queued, and plan-mode paste flows, including placeholder collisions and rejected initial images.

GitOrigin-RevId: d482220d8df21754f166fea5b54e9945f622a978
This commit is contained in:
Eric Traut authored and copyberry committed 2026-08-20 05:49:49 +00:00
1 parent 8e7f646974
commit 3434c2545b
10 files changed
+519 -36

No files matched your search

+21
View File
@@ -917,6 +917,27 @@ async fn replay_thread_snapshot_restores_draft_and_queued_input() {
let (chat_widget, _app_event_tx, _rx, mut new_op_rx) =
make_chatwidget_manual_with_sender().await;
app.chat_widget = chat_widget;
let outgoing_thread_id = ThreadId::new();
app.chat_widget.handle_thread_session(test_thread_session(
outgoing_thread_id,
test_path_buf("/tmp/outgoing-project"),
));
app.chat_widget.handle_server_notification(
turn_started_notification(outgoing_thread_id, "outgoing-turn"),
/*replay_kind*/ None,
);
app.chat_widget
.apply_external_edit("outgoing queued input".to_string());
app.chat_widget
.handle_key_event(KeyEvent::new(KeyCode::Tab, KeyModifiers::NONE));
app.chat_widget
.set_queue_autosend_suppressed(/*suppressed*/ true);
app.chat_widget.handle_server_notification(
turn_completed_notification(outgoing_thread_id, "outgoing-turn", TurnStatus::Completed),
/*replay_kind*/ None,
);
app.chat_widget
.set_queue_autosend_suppressed(/*suppressed*/ false);
app.replay_thread_snapshot(snapshot, /*resume_restored_queue*/ true);