Skip to content

Commit c03011b

Browse files
committed
feat(tui/commands): refresh popular command messaging
1 parent 8efe472 commit c03011b

2 files changed

Lines changed: 51 additions & 92 deletions

File tree

codex-rs/tui/src/history_cell.rs

Lines changed: 40 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,9 @@ impl HistoryCell for ExploreAggregationCell {
796796
.unwrap_or(0)
797797
}
798798

799-
fn gutter_symbol(&self) -> Option<&'static str> { None }
799+
fn gutter_symbol(&self) -> Option<&'static str> {
800+
None
801+
}
800802
}
801803

802804
// ==================== PlainHistoryCell ====================
@@ -2114,12 +2116,18 @@ impl HistoryCell for MergedExecCell {
21142116

21152117
// Build one header line based on exec kind
21162118
let header_line = match self.kind {
2117-
ExecKind::Read => Some(Line::styled("Read", Style::default().fg(crate::colors::text()))),
2119+
ExecKind::Read => Some(Line::styled(
2120+
"Read",
2121+
Style::default().fg(crate::colors::text()),
2122+
)),
21182123
ExecKind::Search => Some(Line::styled(
21192124
"Searched",
21202125
Style::default().fg(crate::colors::text_dim()),
21212126
)),
2122-
ExecKind::List => Some(Line::styled("List", Style::default().fg(crate::colors::text()))),
2127+
ExecKind::List => Some(Line::styled(
2128+
"List",
2129+
Style::default().fg(crate::colors::text()),
2130+
)),
21232131
ExecKind::Run => None,
21242132
};
21252133

@@ -2428,14 +2436,12 @@ fn exec_render_parts_generic(
24282436
} else {
24292437
String::new()
24302438
};
2431-
pre.push(
2432-
Line::styled(
2433-
format!("Running...{duration_str}"),
2434-
Style::default()
2435-
.fg(crate::colors::info())
2436-
.add_modifier(Modifier::BOLD),
2437-
),
2438-
);
2439+
pre.push(Line::styled(
2440+
format!("Running...{duration_str}"),
2441+
Style::default()
2442+
.fg(crate::colors::info())
2443+
.add_modifier(Modifier::BOLD),
2444+
));
24392445
if let Some(first) = highlighted_cmd.first_mut() {
24402446
if start_time.is_some() {
24412447
let elapsed = start_time.unwrap().elapsed();
@@ -2449,17 +2455,6 @@ fn exec_render_parts_generic(
24492455
}
24502456

24512457
if output.is_some() {
2452-
if let Some(first) = highlighted_cmd.first_mut() {
2453-
first.spans.insert(
2454-
0,
2455-
Span::styled(
2456-
"Ran ",
2457-
Style::default()
2458-
.fg(crate::colors::text_bright())
2459-
.add_modifier(Modifier::BOLD),
2460-
),
2461-
);
2462-
}
24632458
for line in highlighted_cmd.iter_mut() {
24642459
for span in line.spans.iter_mut() {
24652460
span.style = span.style.fg(crate::colors::text_bright());
@@ -2584,7 +2579,6 @@ fn exec_render_parts_parsed(
25842579
let show_stdout = matches!(action, ExecAction::Run);
25852580
let out = output_lines(output, !show_stdout, false);
25862581
let mut any_content_emitted = false;
2587-
let mut added_inline_ran = false;
25882582
// Determine allowed label(s) for this cell's primary action
25892583
let expected_label: Option<&'static str> = match action {
25902584
ExecAction::Read => Some("Read"),
@@ -2725,11 +2719,7 @@ fn exec_render_parts_parsed(
27252719
continue;
27262720
}
27272721
let prefix = if !any_content_emitted {
2728-
if suppress_run_header {
2729-
""
2730-
} else {
2731-
"└ "
2732-
}
2722+
if suppress_run_header { "" } else { "└ " }
27332723
} else if suppress_run_header {
27342724
""
27352725
} else {
@@ -2840,15 +2830,6 @@ fn exec_render_parts_parsed(
28402830
let mut hl =
28412831
crate::syntax_highlight::highlight_code_block(line_text, Some("bash"));
28422832
if let Some(mut first) = hl.pop() {
2843-
if output.is_some() && !added_inline_ran {
2844-
spans.push(Span::styled(
2845-
"Ran ",
2846-
Style::default()
2847-
.fg(crate::colors::text_bright())
2848-
.add_modifier(Modifier::BOLD),
2849-
));
2850-
added_inline_ran = true;
2851-
}
28522833
if output.is_some() {
28532834
for s in first.spans.drain(..) {
28542835
spans.push(Span::styled(
@@ -2860,15 +2841,6 @@ fn exec_render_parts_parsed(
28602841
spans.extend(first.spans.drain(..));
28612842
}
28622843
} else {
2863-
if output.is_some() && !added_inline_ran {
2864-
spans.push(Span::styled(
2865-
"Ran ",
2866-
Style::default()
2867-
.fg(crate::colors::text_bright())
2868-
.add_modifier(Modifier::BOLD),
2869-
));
2870-
added_inline_ran = true;
2871-
}
28722844
spans.push(Span::styled(
28732845
line_text.to_string(),
28742846
Style::default().fg(if output.is_some() {
@@ -5084,6 +5056,20 @@ fn popular_commands_lines() -> Vec<Line<'static>> {
50845056
"Popular commands:",
50855057
Style::default().fg(crate::colors::text_bright()),
50865058
));
5059+
lines.push(Line::from(vec![
5060+
Span::styled("/agents", Style::default().fg(crate::colors::primary())),
5061+
Span::from(" - "),
5062+
Span::from(SlashCommand::Agents.description())
5063+
.style(Style::default().add_modifier(Modifier::DIM)),
5064+
Span::styled(" NEW", Style::default().fg(crate::colors::primary())),
5065+
]));
5066+
lines.push(Line::from(vec![
5067+
Span::styled("/model", Style::default().fg(crate::colors::primary())),
5068+
Span::from(" - "),
5069+
Span::from(SlashCommand::Model.description())
5070+
.style(Style::default().add_modifier(Modifier::DIM)),
5071+
Span::styled(" NEW", Style::default().fg(crate::colors::primary())),
5072+
]));
50875073
lines.push(Line::from(vec![
50885074
Span::styled("/chrome", Style::default().fg(crate::colors::primary())),
50895075
Span::from(" - "),
@@ -5117,12 +5103,6 @@ fn popular_commands_lines() -> Vec<Line<'static>> {
51175103
Span::from(SlashCommand::Code.description())
51185104
.style(Style::default().add_modifier(Modifier::DIM)),
51195105
]));
5120-
lines.push(Line::from(vec![
5121-
Span::styled("/model", Style::default().fg(crate::colors::primary())),
5122-
Span::from(" - "),
5123-
Span::from(SlashCommand::Model.description())
5124-
.style(Style::default().add_modifier(Modifier::DIM)),
5125-
]));
51265106
lines.push(Line::from(vec![
51275107
Span::styled("/resume", Style::default().fg(crate::colors::primary())),
51285108
Span::from(" - "),
@@ -5503,7 +5483,6 @@ fn new_parsed_command(
55035483
// We'll emit only content lines here; the header above already communicates the action.
55045484
// Use a single leading "└ " for the very first content line, then indent subsequent ones.
55055485
let mut any_content_emitted = false;
5506-
let mut added_inline_ran = false;
55075486

55085487
// Restrict displayed entries to the primary action for this cell.
55095488
// For the generic "run" header, allow Run/Test/Lint/Format entries.
@@ -5644,11 +5623,7 @@ fn new_parsed_command(
56445623
continue;
56455624
}
56465625
let prefix = if !any_content_emitted {
5647-
if suppress_run_header {
5648-
""
5649-
} else {
5650-
"└ "
5651-
}
5626+
if suppress_run_header { "" } else { "└ " }
56525627
} else if suppress_run_header {
56535628
""
56545629
} else {
@@ -5769,15 +5744,6 @@ fn new_parsed_command(
57695744
let mut hl =
57705745
crate::syntax_highlight::highlight_code_block(line_text, Some("bash"));
57715746
if let Some(mut first) = hl.pop() {
5772-
if output.is_some() && !added_inline_ran {
5773-
spans.push(Span::styled(
5774-
"Ran ",
5775-
Style::default()
5776-
.fg(crate::colors::text_bright())
5777-
.add_modifier(Modifier::BOLD),
5778-
));
5779-
added_inline_ran = true;
5780-
}
57815747
if output.is_some() {
57825748
for s in first.spans.drain(..) {
57835749
spans.push(Span::styled(
@@ -5789,15 +5755,6 @@ fn new_parsed_command(
57895755
spans.extend(first.spans.drain(..));
57905756
}
57915757
} else {
5792-
if output.is_some() && !added_inline_ran {
5793-
spans.push(Span::styled(
5794-
"Ran ",
5795-
Style::default()
5796-
.fg(crate::colors::text_bright())
5797-
.add_modifier(Modifier::BOLD),
5798-
));
5799-
added_inline_ran = true;
5800-
}
58015758
spans.push(Span::styled(
58025759
line_text.to_string(),
58035760
Style::default().fg(if output.is_some() {
@@ -5867,14 +5824,12 @@ fn new_exec_command_generic(
58675824
} else {
58685825
String::new()
58695826
};
5870-
lines.push(
5871-
Line::styled(
5872-
format!("Running...{duration_str}"),
5873-
Style::default()
5874-
.fg(crate::colors::info())
5875-
.add_modifier(Modifier::BOLD),
5876-
)
5877-
);
5827+
lines.push(Line::styled(
5828+
format!("Running...{duration_str}"),
5829+
Style::default()
5830+
.fg(crate::colors::info())
5831+
.add_modifier(Modifier::BOLD),
5832+
));
58785833
}
58795834

58805835
if let Some(first) = highlighted_cmd.first_mut() {
@@ -5891,9 +5846,7 @@ fn new_exec_command_generic(
58915846
if output.is_some() {
58925847
for line in highlighted_cmd.iter_mut() {
58935848
for span in line.spans.iter_mut() {
5894-
span.style = span
5895-
.style
5896-
.fg(crate::colors::text_bright());
5849+
span.style = span.style.fg(crate::colors::text_bright());
58975850
}
58985851
}
58995852
}

codex-rs/tui/src/slash_command.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ impl SlashCommand {
6666
SlashCommand::Status => "show current session configuration and token usage",
6767
SlashCommand::Theme => "switch between color themes",
6868
SlashCommand::Prompts => "show example prompts",
69-
SlashCommand::Model => "choose what model and reasoning effort to use",
70-
SlashCommand::Agents => "list agents (running and availability)",
69+
SlashCommand::Model => "choose model and reasoning effort",
70+
SlashCommand::Agents => "configure agents",
7171
SlashCommand::Branch => "create a worktree branch and switch (/branch [task])",
7272
SlashCommand::Github => "GitHub Actions watcher (status/on/off)",
7373
SlashCommand::Mcp => "manage MCP servers (status/on/off/add)",
@@ -111,9 +111,15 @@ impl SlashCommand {
111111
// Note: We pass None for agents here as the TUI doesn't have access to the session config
112112
// The actual agents will be determined when the agent tool is invoked
113113
match self {
114-
SlashCommand::Plan => Some(codex_core::slash_commands::format_plan_command(args, None, None)),
115-
SlashCommand::Solve => Some(codex_core::slash_commands::format_solve_command(args, None, None)),
116-
SlashCommand::Code => Some(codex_core::slash_commands::format_code_command(args, None, None)),
114+
SlashCommand::Plan => Some(codex_core::slash_commands::format_plan_command(
115+
args, None, None,
116+
)),
117+
SlashCommand::Solve => Some(codex_core::slash_commands::format_solve_command(
118+
args, None, None,
119+
)),
120+
SlashCommand::Code => Some(codex_core::slash_commands::format_code_command(
121+
args, None, None,
122+
)),
117123
_ => None,
118124
}
119125
}

0 commit comments

Comments
 (0)