Compact successful command activity in the TUI (#38921)

## What changed

- Group consecutive successful agent and unified-exec startup commands into a compact `Ran N commands` entry while preserving their full transcript.
- Flush command groups at interaction boundaries, after failures, and after 32 completed commands. Keep manual shell commands and failed or declined commands visible.
- Apply the same grouping rules when replaying thread history without duplicating command starts or disturbing unrelated active commands.

## Testing

- Add TUI coverage for live and replayed grouping, transcript preservation, failures, overlapping commands, group limits, and interaction boundaries.

GitOrigin-RevId: d6602a20201644012fcff3d6cecf4690024383a9
This commit is contained in:
Eric Traut
2026-08-17 00:32:09 +00:00
committed by copyberry
parent 935b1c4e3d
commit 1f41cc5d92
18 changed files with 696 additions and 76 deletions
+66 -1
View File
@@ -14,6 +14,8 @@ use codex_app_server_protocol::CommandExecutionSource as ExecCommandSource;
use codex_protocol::parse_command::ParsedCommand;
use itertools::Either;
const MAX_GROUPED_COMMANDS: usize = 32;
#[derive(Debug, Default)]
pub(crate) struct CommandOutput {
pub(crate) exit_code: i32,
@@ -104,7 +106,38 @@ impl ExecCell {
duration: None,
interaction_input,
};
if self.is_exploring_cell() && Self::is_exploring_call(&call) {
let has_failed_call = self.calls.iter().any(|existing| {
existing
.output
.as_ref()
.is_some_and(|output| output.exit_code != 0)
});
if (self.calls.len() >= MAX_GROUPED_COMMANDS && !self.is_active())
|| (!Self::is_groupable_source(call.source) && !self.is_active())
|| (has_failed_call && !self.is_active())
{
return false;
}
let continues_exploration = Self::is_exploring_call(&call)
&& (self.is_exploring_cell()
|| self.calls.last().is_some_and(|existing| {
existing.duration.is_none() && Self::is_exploring_call(existing)
}))
&& (self.is_active()
|| self
.calls
.iter()
.all(|existing| Self::is_groupable_source(existing.source)));
let continues_compact_group = self.calls.iter().all(|existing| {
Self::is_groupable_source(existing.source)
&& existing.duration.is_some()
&& existing
.output
.as_ref()
.is_some_and(|output| output.exit_code == 0)
});
if continues_exploration || continues_compact_group {
self.calls.push(call);
true
} else {
@@ -133,6 +166,31 @@ impl ExecCell {
}
pub(crate) fn should_flush(&self) -> bool {
if self.calls.iter().any(|call| {
!Self::is_groupable_source(call.source)
|| call
.output
.as_ref()
.is_some_and(|output| output.exit_code != 0)
}) {
return !self.is_active();
}
if self.calls.len() >= MAX_GROUPED_COMMANDS {
return !self.is_active();
}
if self.calls.iter().all(|call| {
Self::is_groupable_source(call.source)
&& call.duration.is_some()
&& call
.output
.as_ref()
.is_some_and(|output| output.exit_code == 0)
}) {
return false;
}
!self.is_exploring_cell() && self.calls.iter().all(|c| c.duration.is_some())
}
@@ -202,6 +260,13 @@ impl ExecCell {
)
})
}
fn is_groupable_source(source: ExecCommandSource) -> bool {
matches!(
source,
ExecCommandSource::Agent | ExecCommandSource::UnifiedExecStartup
)
}
}
impl ExecCall {