mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
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:
1 parent
935b1c4e3d
commit
1f41cc5d92
18 files changed
+696
-76
No files matched your search
@@ -10,6 +10,7 @@ impl ChatWidget {
|
||||
let Some(wait) = self.unified_exec_wait_streak.take() else {
|
||||
return;
|
||||
};
|
||||
self.flush_completed_command_activity();
|
||||
self.transcript.needs_final_message_separator = true;
|
||||
let cell = history_cell::new_unified_exec_interaction(wait.command_display, String::new());
|
||||
self.app_event_tx
|
||||
@@ -334,6 +335,7 @@ impl ChatWidget {
|
||||
command,
|
||||
process_id: _,
|
||||
source,
|
||||
status,
|
||||
command_actions,
|
||||
aggregated_output,
|
||||
exit_code,
|
||||
@@ -349,13 +351,18 @@ impl ChatWidget {
|
||||
.map(codex_app_server_protocol::CommandAction::into_core)
|
||||
.collect();
|
||||
let duration = Duration::from_millis(duration_ms.unwrap_or_default().max(0) as u64);
|
||||
let exit_code = exit_code.unwrap_or_default();
|
||||
let exit_code = if status == codex_app_server_protocol::CommandExecutionStatus::Completed {
|
||||
exit_code.unwrap_or_default()
|
||||
} else {
|
||||
exit_code.filter(|code| *code != 0).unwrap_or(1)
|
||||
};
|
||||
let aggregated_output = aggregated_output.unwrap_or_default();
|
||||
|
||||
let running = self.running_commands.remove(&id);
|
||||
if self.suppressed_exec_calls.remove(&id) {
|
||||
return;
|
||||
}
|
||||
let was_running = running.is_some();
|
||||
let (command, parsed, source) = match running {
|
||||
Some(rc) => (rc.command, rc.parsed_cmd, rc.source),
|
||||
None => (event_command, event_parsed, source),
|
||||
@@ -364,6 +371,33 @@ impl ChatWidget {
|
||||
let is_unified_exec_interaction =
|
||||
matches!(source, ExecCommandSource::UnifiedExecInteraction);
|
||||
let is_user_shell = source == ExecCommandSource::UserShell;
|
||||
let retain_untracked_unified_exec = !was_running
|
||||
&& source == ExecCommandSource::UnifiedExecStartup
|
||||
&& self.transcript.active_cell.is_none();
|
||||
// Unified exec skips unknown start events, so group their successful completions here.
|
||||
if !was_running
|
||||
&& source == ExecCommandSource::UnifiedExecStartup
|
||||
&& let Some(cell) = self
|
||||
.transcript
|
||||
.active_cell
|
||||
.as_mut()
|
||||
.and_then(|cell| cell.as_any_mut().downcast_mut::<ExecCell>())
|
||||
&& !cell.is_active()
|
||||
&& cell.iter_calls().all(|call| {
|
||||
matches!(
|
||||
call.source,
|
||||
ExecCommandSource::Agent | ExecCommandSource::UnifiedExecStartup
|
||||
)
|
||||
})
|
||||
{
|
||||
cell.add_call(
|
||||
id.clone(),
|
||||
command.clone(),
|
||||
parsed.clone(),
|
||||
source,
|
||||
/*interaction_input*/ None,
|
||||
);
|
||||
}
|
||||
let end_target = match self.transcript.active_cell.as_ref() {
|
||||
Some(cell) => match cell.as_any().downcast_ref::<ExecCell>() {
|
||||
Some(exec_cell) if exec_cell.iter_calls().any(|call| call.call_id == id) => {
|
||||
@@ -372,6 +406,9 @@ impl ChatWidget {
|
||||
Some(exec_cell) if exec_cell.is_active() => {
|
||||
ExecEndTarget::OrphanHistoryWhileActiveExec
|
||||
}
|
||||
None if cell.as_any().is::<McpToolCallCell>() => {
|
||||
ExecEndTarget::OrphanHistoryWhileActiveExec
|
||||
}
|
||||
Some(_) | None => ExecEndTarget::NewCell,
|
||||
},
|
||||
None => ExecEndTarget::NewCell,
|
||||
@@ -387,6 +424,10 @@ impl ChatWidget {
|
||||
|
||||
match end_target {
|
||||
ExecEndTarget::ActiveTracked => {
|
||||
let has_active_hook = self
|
||||
.active_hook_cell
|
||||
.as_ref()
|
||||
.is_some_and(HookCell::has_visible_running_run);
|
||||
if let Some(cell) = self
|
||||
.transcript
|
||||
.active_cell
|
||||
@@ -395,7 +436,7 @@ impl ChatWidget {
|
||||
{
|
||||
let completed = cell.complete_call(&id, output, duration);
|
||||
debug_assert!(completed, "active exec cell should contain {id}");
|
||||
if cell.should_flush() {
|
||||
if cell.should_flush() || (has_active_hook && !cell.is_active()) {
|
||||
self.flush_active_cell();
|
||||
} else {
|
||||
self.bump_active_cell_revision();
|
||||
@@ -431,7 +472,7 @@ impl ChatWidget {
|
||||
);
|
||||
let completed = cell.complete_call(&id, output, duration);
|
||||
debug_assert!(completed, "new exec cell should contain {id}");
|
||||
if cell.should_flush() {
|
||||
if (!was_running && !retain_untracked_unified_exec) || cell.should_flush() {
|
||||
self.add_to_history(cell);
|
||||
} else {
|
||||
self.transcript.active_cell = Some(Box::new(cell));
|
||||
|
||||
Reference in new issue
Block a user