mirror of
https://github.com/openai/codex.git
synced 2026-11-24 23:20:47 +00:00
Restore the TUI Working indicator when a Stop hook continues a turn (#63736)
## Why A final answer hides the Working indicator. If a Stop hook then asks Codex to continue, the TUI can look idle while the turn is still running. ## What changed Restore the indicator when a completed `HookPrompt` belongs to the current running turn, both during live updates and when replaying a thread snapshot. ## Testing Add a regression test that snapshots the restored Working row during a live retry, checks that snapshot replay also restores it, and verifies that replaying the prompt after turn completion leaves it hidden. GitOrigin-RevId: 67909c92b628ff5389ea9b417e7e5133a9acdeec
This commit is contained in:
@@ -488,7 +488,14 @@ impl ChatWidget {
|
||||
));
|
||||
}
|
||||
}
|
||||
ThreadItemPayload::HookPrompt { .. } => {}
|
||||
ThreadItemPayload::HookPrompt { .. } => {
|
||||
// A Stop hook continued the turn after the final answer hid the status row.
|
||||
if self.turn_lifecycle.agent_turn_running
|
||||
&& self.last_turn_id() == Some(turn_id.as_str())
|
||||
{
|
||||
self.bottom_pane.ensure_status_indicator();
|
||||
}
|
||||
}
|
||||
ThreadItemPayload::CollabAgentToolCall {
|
||||
id,
|
||||
tool,
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
---
|
||||
source: tui/src/chatwidget/tests/status_and_layout.rs
|
||||
expression: "hook_status_frame(&chat, 60)"
|
||||
---
|
||||
" "
|
||||
"• Working (0s • esc to interrupt) "
|
||||
" "
|
||||
" "
|
||||
"› Ask Codex to do anything "
|
||||
" "
|
||||
" GPT-5.6-Sol default · /tmp/project "
|
||||
" ? for shortcuts "
|
||||
@@ -2681,6 +2681,44 @@ async fn idle_commit_ticks_do_not_restore_status_without_commentary_completion()
|
||||
assert_eq!(chat.bottom_pane.status_indicator_visible(), false);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn stop_hook_retry_restores_working_after_final_answer() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
handle_turn_started(&mut chat, "turn-1");
|
||||
complete_assistant_message(&mut chat, "msg-1", "Done.", Some(MessagePhase::FinalAnswer));
|
||||
|
||||
let prompt = ServerNotification::ItemCompleted(ItemCompletedNotification::new(
|
||||
String::new(),
|
||||
"turn-1".into(),
|
||||
AppServerThreadItemPayload::HookPrompt {
|
||||
id: "prompt-1".into(),
|
||||
fragments: vec![codex_app_server_protocol::HookPromptFragment {
|
||||
text: "Include test results.".into(),
|
||||
hook_run_id: "stop-1".into(),
|
||||
}],
|
||||
},
|
||||
/*started_at_ms*/ None,
|
||||
/*completed_at_ms*/ 0,
|
||||
));
|
||||
chat.handle_server_notification(prompt.clone(), /*replay_kind*/ None);
|
||||
assert_chatwidget_snapshot!(
|
||||
"stop_hook_retry_working",
|
||||
hook_status_frame(&chat, /*width*/ 60)
|
||||
);
|
||||
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
let replay = ReplayKind::ThreadSnapshot;
|
||||
replay_turn_started(&mut chat, replay);
|
||||
replay_agent_message(&mut chat, "msg-1", "Done.", replay);
|
||||
assert!(!chat.bottom_pane.status_indicator_visible());
|
||||
chat.handle_server_notification(prompt.clone(), Some(replay));
|
||||
assert!(chat.bottom_pane.status_indicator_visible());
|
||||
|
||||
handle_turn_completed(&mut chat, "turn-1", /*duration_ms*/ None);
|
||||
chat.handle_server_notification(prompt, Some(replay));
|
||||
assert!(!chat.bottom_pane.status_indicator_visible());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn final_answer_completion_restores_status_indicator_for_pending_steer() {
|
||||
let (mut chat, mut rx, mut op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
|
||||
Reference in New Issue
Block a user