Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

tui: hide '/init' suggestion when AGENTS.md exists (#3038)

Jeremy Rosefcb62a0fa5e8
diff --git a/codex-rs/tui/src/history_cell.rs b/codex-rs/tui/src/history_cell.rs
index 185767be30..db4609ca8f 100644
--- a/codex-rs/tui/src/history_cell.rs
+++ b/codex-rs/tui/src/history_cell.rs
@@ -657,68 +657,40 @@ pub(crate) fn new_session_info(
Some(_) => "~".to_string(),
None => config.cwd.display().to_string(),
};
+ // Discover AGENTS.md files to decide whether to suggest `/init`.
+ let has_agents_md = discover_project_doc_paths(config)
+ .map(|v| !v.is_empty())
+ .unwrap_or(false);
- let lines: Vec<Line<'static>> = vec![
- Line::from(vec![
- Span::raw(">_ ").dim(),
- Span::styled(
- "You are using OpenAI Codex in",
- Style::default().add_modifier(Modifier::BOLD),
- ),
- Span::raw(format!(" {cwd_str}")).dim(),
- ]),
- Line::from("".dim()),
- Line::from(" To get started, describe a task or try one of these commands:".dim()),
- Line::from("".dim()),
- Line::from(vec![
- Span::styled(
- " /init",
- Style::default()
- .add_modifier(Modifier::BOLD)
- .fg(Color::White),
- ),
- Span::styled(
- format!(" - {}", SlashCommand::Init.description()),
- Style::default().dim(),
- ),
- ]),
- Line::from(vec![
- Span::styled(
- " /status",
- Style::default()
- .add_modifier(Modifier::BOLD)
- .fg(Color::White),
- ),
- Span::styled(
- format!(" - {}", SlashCommand::Status.description()),
- Style::default().dim(),
- ),
- ]),
- Line::from(vec![
- Span::styled(
- " /approvals",
- Style::default()
- .add_modifier(Modifier::BOLD)
- .fg(Color::White),
- ),
- Span::styled(
- format!(" - {}", SlashCommand::Approvals.description()),
- Style::default().dim(),
- ),
- ]),
- Line::from(vec![
- Span::styled(
- " /model",
- Style::default()
- .add_modifier(Modifier::BOLD)
- .fg(Color::White),
- ),
- Span::styled(
- format!(" - {}", SlashCommand::Model.description()),
- Style::default().dim(),
- ),
- ]),
- ];
+ let mut lines: Vec<Line<'static>> = Vec::new();
+ lines.push(Line::from(vec![
+ ">_ ".dim(),
+ "You are using OpenAI Codex in".bold(),
+ format!(" {cwd_str}").dim(),
+ ]));
+ lines.push(Line::from("".dim()));
+ lines.push(Line::from(
+ " To get started, describe a task or try one of these commands:".dim(),
+ ));
+ lines.push(Line::from("".dim()));
+ if !has_agents_md {
+ lines.push(Line::from(vec![
+ " /init".bold(),
+ format!(" - {}", SlashCommand::Init.description()).dim(),
+ ]));
+ }
+ lines.push(Line::from(vec![
+ " /status".bold(),
+ format!(" - {}", SlashCommand::Status.description()).dim(),
+ ]));
+ lines.push(Line::from(vec![
+ " /approvals".bold(),
+ format!(" - {}", SlashCommand::Approvals.description()).dim(),
+ ]));
+ lines.push(Line::from(vec![
+ " /model".bold(),
+ format!(" - {}", SlashCommand::Model.description()).dim(),
+ ]));
PlainHistoryCell { lines }
} else if config.model == model {
PlainHistoryCell { lines: Vec::new() }