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:
Ian MacLeod authored and copyberry committed 2026-08-31 21:19:22 +00:00
1 parent 5f79a92e39
commit 17e8101699
10 files changed
+295 -147

No files matched your search

+34 -26
View File
@@ -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;