mirror of
https://github.com/openai/codex.git
synced 2026-11-26 07:26:11 +00:00
Preserve TUI status timing when the status row is hidden (#41913)
## Why Streaming can temporarily hide the status row, but its elapsed time is still needed when the row returns and when the final `Worked for` duration falls back to the local clock. Approval prompts must also keep that clock paused. ## What changed - Own the pause-aware status timer in the bottom pane independently of the optional status row. - Preserve elapsed time and modal pause state while hiding or restoring the row, and reset the clock for new turns and Windows sandbox setup. - Use the independent timer as the fallback for the final turn duration. ## Testing Add timer unit coverage and TUI tests for hidden rows, outstanding approvals, fallback turn durations, and fresh Windows sandbox setup clocks. GitOrigin-RevId: a77931e465d5aedd4a8cd606a3a3117d1bb37ce7
This commit is contained in:
1 parent
5f79a92e39
commit
17e8101699
10 files changed
+295
-147
No files matched your search
+12
@@ -0,0 +1,12 @@
|
||||
---
|
||||
source: tui/src/chatwidget/tests/permissions.rs
|
||||
assertion_line: 610
|
||||
expression: "setup.replace(&chat.config.cwd.display().to_string(), \"[CWD]\")"
|
||||
---
|
||||
• Setting up sandbox... (0s)
|
||||
└ Hang tight, this may take a few minutes
|
||||
|
||||
|
||||
› Input disabled until setup completes.
|
||||
|
||||
gpt-5.6-sol default · [CWD]
|
||||
@@ -875,35 +875,43 @@ async fn unified_exec_wait_before_streamed_agent_message_snapshot() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn final_worked_for_uses_cumulative_turn_duration_snapshot() {
|
||||
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
handle_turn_started(&mut chat, "turn-1");
|
||||
for duration_ms in [Some(125_000), None] {
|
||||
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
handle_turn_started(&mut chat, "turn-1");
|
||||
|
||||
let exec = begin_exec_with_source(
|
||||
&mut chat,
|
||||
"call-1",
|
||||
"echo preparing",
|
||||
ExecCommandSource::Agent,
|
||||
);
|
||||
end_exec(&mut chat, exec, "preparing\n", "", /*exit_code*/ 0);
|
||||
let exec = begin_exec_with_source(
|
||||
&mut chat,
|
||||
"call-1",
|
||||
"echo preparing",
|
||||
ExecCommandSource::Agent,
|
||||
);
|
||||
end_exec(&mut chat, exec, "preparing\n", "", /*exit_code*/ 0);
|
||||
|
||||
complete_assistant_message(
|
||||
&mut chat,
|
||||
"msg-final",
|
||||
"Final response.",
|
||||
Some(MessagePhase::FinalAnswer),
|
||||
);
|
||||
handle_turn_completed(&mut chat, "turn-1", Some(125_000));
|
||||
chat.bottom_pane
|
||||
.reset_status_timer(Duration::from_secs(/*secs*/ 125));
|
||||
handle_agent_message_delta(&mut chat, "Final response.\n");
|
||||
chat.on_commit_tick();
|
||||
assert!(!chat.bottom_pane.status_indicator_visible());
|
||||
|
||||
let cells = drain_insert_history(&mut rx);
|
||||
let combined = cells
|
||||
.iter()
|
||||
.map(|lines| lines_to_single_string(lines))
|
||||
.collect::<String>();
|
||||
assert!(
|
||||
combined.contains("Worked for 2m 05s"),
|
||||
"expected final separator to use cumulative turn duration, got:\n{combined}"
|
||||
);
|
||||
assert_chatwidget_snapshot!("final_worked_for_uses_cumulative_turn_duration", combined);
|
||||
complete_assistant_message(
|
||||
&mut chat,
|
||||
"msg-final",
|
||||
"Final response.",
|
||||
Some(MessagePhase::FinalAnswer),
|
||||
);
|
||||
handle_turn_completed(&mut chat, "turn-1", duration_ms);
|
||||
|
||||
let cells = drain_insert_history(&mut rx);
|
||||
let combined = cells
|
||||
.iter()
|
||||
.map(|lines| lines_to_single_string(lines))
|
||||
.collect::<String>();
|
||||
assert!(
|
||||
combined.contains("Worked for 2m 05s"),
|
||||
"expected final separator to use cumulative turn duration, got:\n{combined}"
|
||||
);
|
||||
assert_chatwidget_snapshot!("final_worked_for_uses_cumulative_turn_duration", combined);
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
@@ -598,6 +598,28 @@ async fn fragmented_terminal_response_cannot_acknowledge_world_writable_warning(
|
||||
));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn windows_sandbox_setup_starts_a_fresh_status_clock() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.bottom_pane
|
||||
.reset_status_timer(Duration::from_secs(/*secs*/ 125));
|
||||
|
||||
chat.show_windows_sandbox_setup_status();
|
||||
let setup = render_bottom_popup(&chat, /*width*/ 80);
|
||||
assert!(setup.contains("Setting up sandbox"));
|
||||
assert!(setup.contains("(0s"));
|
||||
assert_chatwidget_snapshot!(
|
||||
"windows_sandbox_setup_fresh_clock",
|
||||
setup.replace(&chat.config.cwd.display().to_string(), "[CWD]")
|
||||
);
|
||||
|
||||
chat.clear_windows_sandbox_setup_status();
|
||||
chat.bottom_pane.set_task_running(/*running*/ true);
|
||||
let working = render_bottom_popup(&chat, /*width*/ 80);
|
||||
assert!(working.contains("Working"));
|
||||
assert!(!working.contains("Setting up sandbox"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn required_windows_sandbox_setup_defers_configured_initial_prompt() {
|
||||
let (mut chat, mut rx, mut op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
|
||||
@@ -82,6 +82,7 @@ impl ChatWidget {
|
||||
self.quit_shortcut_expires_at = None;
|
||||
self.quit_shortcut_key = None;
|
||||
self.update_task_running_state();
|
||||
self.bottom_pane.reset_status_timer(Duration::ZERO);
|
||||
self.status_state.retry_status_header = None;
|
||||
self.clear_active_hook_cell();
|
||||
self.status_state.pending_status_indicator_restore = false;
|
||||
@@ -156,8 +157,8 @@ impl ChatWidget {
|
||||
.map(|duration_ms| duration_ms / 1_000)
|
||||
.or_else(|| {
|
||||
self.bottom_pane
|
||||
.status_widget()
|
||||
.map(crate::status_indicator_widget::StatusIndicatorWidget::elapsed_seconds)
|
||||
.status_elapsed()
|
||||
.map(|elapsed| elapsed.as_secs())
|
||||
})
|
||||
} else {
|
||||
None
|
||||
|
||||
@@ -479,7 +479,7 @@ impl ChatWidget {
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
pub(crate) fn maybe_prompt_windows_sandbox_enable(&mut self, _show_now: bool) {}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
#[cfg(any(target_os = "windows", test))]
|
||||
pub(crate) fn show_windows_sandbox_setup_status(&mut self) {
|
||||
// While elevated sandbox setup runs, prevent typing so the user doesn't
|
||||
// accidentally queue messages that will run under an unexpected mode.
|
||||
@@ -487,6 +487,7 @@ impl ChatWidget {
|
||||
/*enabled*/ false,
|
||||
Some("Input disabled until setup completes.".to_string()),
|
||||
);
|
||||
self.bottom_pane.reset_status_timer(Duration::ZERO);
|
||||
self.bottom_pane.ensure_status_indicator();
|
||||
self.bottom_pane
|
||||
.set_interrupt_hint_visible(/*visible*/ false);
|
||||
@@ -499,11 +500,11 @@ impl ChatWidget {
|
||||
self.request_redraw();
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
#[cfg(not(any(target_os = "windows", test)))]
|
||||
#[allow(dead_code)]
|
||||
pub(crate) fn show_windows_sandbox_setup_status(&mut self) {}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
#[cfg(any(target_os = "windows", test))]
|
||||
pub(crate) fn clear_windows_sandbox_setup_status(&mut self) {
|
||||
self.bottom_pane
|
||||
.set_composer_input_enabled(/*enabled*/ true, /*placeholder*/ None);
|
||||
@@ -511,6 +512,6 @@ impl ChatWidget {
|
||||
self.request_redraw();
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
#[cfg(not(any(target_os = "windows", test)))]
|
||||
pub(crate) fn clear_windows_sandbox_setup_status(&mut self) {}
|
||||
}
|
||||
Reference in new issue
Block a user