mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Render TUI prompts before submitting user turns (#33373)
## Why Starting a user turn can wait on remote work. Show the submitted prompt immediately instead of leaving the input invisible during that wait. ## What changed - Queue optimistic prompt history before app-event submissions and render a frame before starting the turn. - Preserve the existing submit-failure behavior for direct submissions. ## Testing - Verify that an initial prompt is added to history before its user-turn event is submitted during session replay. GitOrigin-RevId: 57f30c6e0067127e6b082a206f7d154fcfef8d7d
This commit is contained in:
1 parent
2e4f55608b
commit
38b064c31b
3 files changed
+48
-27
No files matched your search
@@ -411,6 +411,15 @@ impl App {
|
||||
return Ok(AppRunControl::Exit(ExitReason::Fatal(message)));
|
||||
}
|
||||
AppEvent::CodexOp(op) => {
|
||||
if matches!(&op, AppCommand::UserTurn { .. }) {
|
||||
self.handle_draw_pre_render(tui)?;
|
||||
if self.transcript_reflow.has_pending_reflow() {
|
||||
self.transcript_reflow.schedule_immediate();
|
||||
self.maybe_run_resize_reflow(tui)?;
|
||||
}
|
||||
self.chat_widget.pre_draw_tick();
|
||||
self.render_chat_widget_frame(tui)?;
|
||||
}
|
||||
self.chat_widget.prepare_local_op_submission(&op);
|
||||
self.submit_active_thread_op(app_server, op).await?;
|
||||
}
|
||||
|
||||
@@ -367,12 +367,14 @@ async fn enqueue_primary_thread_session_replays_turns_before_initial_prompt_subm
|
||||
.await?;
|
||||
|
||||
let mut saw_replayed_answer = false;
|
||||
let mut saw_optimistic_prompt = false;
|
||||
let mut submitted_items = None;
|
||||
while let Ok(event) = app_event_rx.try_recv() {
|
||||
match event {
|
||||
AppEvent::InsertHistoryCell(cell) => {
|
||||
let transcript = lines_to_single_string(&cell.transcript_lines(/*width*/ 80));
|
||||
saw_replayed_answer |= transcript.contains("earlier prompt");
|
||||
saw_optimistic_prompt |= transcript.contains(&initial_prompt);
|
||||
}
|
||||
AppEvent::SubmitThreadOp {
|
||||
thread_id: op_thread_id,
|
||||
@@ -382,6 +384,10 @@ async fn enqueue_primary_thread_session_replays_turns_before_initial_prompt_subm
|
||||
submitted_items = Some(items);
|
||||
}
|
||||
AppEvent::CodexOp(Op::UserTurn { items, .. }) => {
|
||||
assert!(
|
||||
saw_optimistic_prompt,
|
||||
"expected optimistic prompt before turn submission"
|
||||
);
|
||||
submitted_items = Some(items);
|
||||
}
|
||||
_ => {}
|
||||
|
||||
Reference in new issue
Block a user