Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

fix: command formatting for user commands (#7002)

jif-oai888c6dd9e765
diff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__user_shell_ls_output.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__user_shell_ls_output.snap
new file mode 100644
index 0000000000..c67cd637d7
--- /dev/null
+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__user_shell_ls_output.snap
@@ -0,0 +1,7 @@
+---
+source: tui/src/chatwidget/tests.rs
+expression: blob
+---
+• You ran ls
+ └ file1
+ file2
diff --git a/codex-rs/tui/src/chatwidget/tests.rs b/codex-rs/tui/src/chatwidget/tests.rs
index 1393e52886..f07d7a51d2 100644
--- a/codex-rs/tui/src/chatwidget/tests.rs
+++ b/codex-rs/tui/src/chatwidget/tests.rs
@@ -1790,6 +1790,28 @@ fn exec_history_extends_previous_when_consecutive() {
assert_snapshot!("exploring_step6_finish_cat_bar", active_blob(&chat));
}
+#[test]
+fn user_shell_command_renders_output_not_exploring() {
+ let (mut chat, mut rx, _op_rx) = make_chatwidget_manual();
+
+ let begin_ls = begin_exec_with_source(
+ &mut chat,
+ "user-shell-ls",
+ "ls",
+ ExecCommandSource::UserShell,
+ );
+ end_exec(&mut chat, begin_ls, "file1\nfile2\n", "", 0);
+
+ let cells = drain_insert_history(&mut rx);
+ assert_eq!(
+ cells.len(),
+ 1,
+ "expected a single history cell for the user command"
+ );
+ let blob = lines_to_single_string(cells.first().unwrap());
+ assert_snapshot!("user_shell_ls_output", blob);
+}
+
#[test]
fn disabled_slash_command_while_task_running_snapshot() {
// Build a chat widget and simulate an active task
diff --git a/codex-rs/tui/src/exec_cell/model.rs b/codex-rs/tui/src/exec_cell/model.rs
index 943fb83654..3fddee1562 100644
--- a/codex-rs/tui/src/exec_cell/model.rs
+++ b/codex-rs/tui/src/exec_cell/model.rs
@@ -117,7 +117,8 @@ impl ExecCell {
}
pub(super) fn is_exploring_call(call: &ExecCall) -> bool {
- !call.parsed.is_empty()
+ !matches!(call.source, ExecCommandSource::UserShell)
+ && !call.parsed.is_empty()
&& call.parsed.iter().all(|p| {
matches!(
p,