Files
codex/codex-rs/tui/src/chatwidget/activity_groups.rs
T
Eric Traut ad07f04e47 Show background command launches and late results in the TUI (#64015)
## Why

A background command can outlive the turn that launched it. Its result
could be dropped when no turn was active or appear as a separate
transcript entry if later output had already displaced its running row.

## What changed

- Show background commands as they start, including commands that don't
  match a recognized tool action. Keep tracking their exits after a
  turn ends or is interrupted.
- Update the original transcript row with the exit status and output,
  including when the command finishes in a parked side conversation.
- In rich terminal scrollback, label an unfinished launch `Started`.
  If the launch has already printed, append the result in order.
  Otherwise, replace the queued launch with the completed entry.

## Testing

Cover late exits after turn completion and interruption, completion
during a side conversation handoff, and result ordering behind queued
scrollback.

GitOrigin-RevId: 65f069af28c112078d85613da2c95e5c1c4f29bf
2026-11-25 22:54:56 +00:00

62 lines
2.1 KiB
Rust

//! Keep hidden reasoning and terminal bookkeeping inside compatible activity groups.
//! Detailed output retains the original order while compact activity avoids artificial breaks.
use super::*;
impl ChatWidget {
pub(super) fn absorb_activity_detail(
&mut self,
cell: Box<dyn HistoryCell>,
) -> Result<(), Box<dyn HistoryCell>> {
let hidden_reasoning = cell
.as_any()
.downcast_ref::<history_cell::ReasoningSummaryCell>()
.is_some_and(history_cell::ReasoningSummaryCell::is_transcript_only);
if !hidden_reasoning
&& !cell
.as_any()
.is::<history_cell::UnifiedExecInteractionCell>()
{
return Err(cell);
}
let Some(active) = self.transcript.active_cell.as_mut() else {
return Err(cell);
};
if let Some(computer) = active
.as_any_mut()
.downcast_mut::<history_cell::ComputerActivityCell>()
{
computer.group.push_detail(Arc::from(cell));
self.bump_active_cell_revision();
return Ok(());
}
if let Some(exec) = active.as_any_mut().downcast_mut::<ExecCell>()
&& !exec.should_flush()
{
exec.group.push_detail(Arc::from(cell));
self.bump_active_cell_revision();
return Ok(());
}
Err(cell)
}
/// Hydrate only the validated older portion, leaving current calls and their clocks intact.
pub(crate) fn prepend_active_exploration_history(
&mut self,
older: &dyn HistoryCell,
turns: &[Turn],
) -> Option<(u64, u64)> {
let previous_revision = self.transcript.active_cell_revision;
let active = self
.transcript
.active_cell
.as_mut()?
.as_any_mut()
.downcast_mut::<ExecCell>()?;
let older = crate::thread_transcript::older_exploration_group(older, active, turns)?;
active.prepend(older);
self.bump_active_cell_revision();
Some((previous_revision, self.transcript.active_cell_revision))
}
}