Add debug-only slash command for rollout path (#5936)
## Summary - add a debug-only `/rollout` slash command that prints the rollout file path or reports when none is known - surface the new command in the slash command metadata and cover it with unit tests <img width="539" height="99" alt="image" src="https://github.com/user-attachments/assets/688e1334-8a06-4576-abb8-ada33b458661" />
This commit is contained in:
@@ -1270,7 +1270,16 @@ impl ChatWidget {
|
|||||||
SlashCommand::Mcp => {
|
SlashCommand::Mcp => {
|
||||||
self.add_mcp_output();
|
self.add_mcp_output();
|
||||||
}
|
}
|
||||||
#[cfg(debug_assertions)]
|
SlashCommand::Rollout => {
|
||||||
|
if let Some(path) = self.rollout_path() {
|
||||||
|
self.add_info_message(
|
||||||
|
format!("Current rollout path: {}", path.display()),
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
self.add_info_message("Rollout path is not available yet.".to_string(), None);
|
||||||
|
}
|
||||||
|
}
|
||||||
SlashCommand::TestApproval => {
|
SlashCommand::TestApproval => {
|
||||||
use codex_core::protocol::EventMsg;
|
use codex_core::protocol::EventMsg;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|||||||
@@ -863,6 +863,42 @@ fn slash_undo_sends_op() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn slash_rollout_displays_current_path() {
|
||||||
|
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual();
|
||||||
|
let rollout_path = PathBuf::from("/tmp/codex-test-rollout.jsonl");
|
||||||
|
chat.current_rollout_path = Some(rollout_path.clone());
|
||||||
|
|
||||||
|
chat.dispatch_command(SlashCommand::Rollout);
|
||||||
|
|
||||||
|
let cells = drain_insert_history(&mut rx);
|
||||||
|
assert_eq!(cells.len(), 1, "expected info message for rollout path");
|
||||||
|
let rendered = lines_to_single_string(&cells[0]);
|
||||||
|
assert!(
|
||||||
|
rendered.contains(&rollout_path.display().to_string()),
|
||||||
|
"expected rollout path to be shown: {rendered}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn slash_rollout_handles_missing_path() {
|
||||||
|
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual();
|
||||||
|
|
||||||
|
chat.dispatch_command(SlashCommand::Rollout);
|
||||||
|
|
||||||
|
let cells = drain_insert_history(&mut rx);
|
||||||
|
assert_eq!(
|
||||||
|
cells.len(),
|
||||||
|
1,
|
||||||
|
"expected info message explaining missing path"
|
||||||
|
);
|
||||||
|
let rendered = lines_to_single_string(&cells[0]);
|
||||||
|
assert!(
|
||||||
|
rendered.contains("not available"),
|
||||||
|
"expected missing rollout path message: {rendered}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn undo_success_events_render_info_messages() {
|
fn undo_success_events_render_info_messages() {
|
||||||
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual();
|
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual();
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ pub enum SlashCommand {
|
|||||||
Logout,
|
Logout,
|
||||||
Quit,
|
Quit,
|
||||||
Feedback,
|
Feedback,
|
||||||
#[cfg(debug_assertions)]
|
Rollout,
|
||||||
TestApproval,
|
TestApproval,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ impl SlashCommand {
|
|||||||
SlashCommand::Approvals => "choose what Codex can do without approval",
|
SlashCommand::Approvals => "choose what Codex can do without approval",
|
||||||
SlashCommand::Mcp => "list configured MCP tools",
|
SlashCommand::Mcp => "list configured MCP tools",
|
||||||
SlashCommand::Logout => "log out of Codex",
|
SlashCommand::Logout => "log out of Codex",
|
||||||
#[cfg(debug_assertions)]
|
SlashCommand::Rollout => "print the rollout file path",
|
||||||
SlashCommand::TestApproval => "test approval request",
|
SlashCommand::TestApproval => "test approval request",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,14 +76,23 @@ impl SlashCommand {
|
|||||||
| SlashCommand::Mcp
|
| SlashCommand::Mcp
|
||||||
| SlashCommand::Feedback
|
| SlashCommand::Feedback
|
||||||
| SlashCommand::Quit => true,
|
| SlashCommand::Quit => true,
|
||||||
|
SlashCommand::Rollout => true,
|
||||||
#[cfg(debug_assertions)]
|
|
||||||
SlashCommand::TestApproval => true,
|
SlashCommand::TestApproval => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_visible(self) -> bool {
|
||||||
|
match self {
|
||||||
|
SlashCommand::Rollout | SlashCommand::TestApproval => cfg!(debug_assertions),
|
||||||
|
_ => true,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return all built-in commands in a Vec paired with their command string.
|
/// Return all built-in commands in a Vec paired with their command string.
|
||||||
pub fn built_in_slash_commands() -> Vec<(&'static str, SlashCommand)> {
|
pub fn built_in_slash_commands() -> Vec<(&'static str, SlashCommand)> {
|
||||||
SlashCommand::iter().map(|c| (c.command(), c)).collect()
|
SlashCommand::iter()
|
||||||
|
.filter(|command| command.is_visible())
|
||||||
|
.map(|c| (c.command(), c))
|
||||||
|
.collect()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user