grok-build-upstream-mirror/crates/codegen/xai-grok-pager/src/slash/commands/help.rs
grokkybara[bot] c68e39f604 Publish harness and TUI open-source
initial sync from the monorepo
2026-07-16 06:46:02 +01:00

64 lines
1.8 KiB
Rust

//! `/help` -- open the command palette (the command + shortcut browser).
//!
//! In minimal mode there's no always-visible footer of hints, so `/help` is the
//! discoverable entry point (advertised in the status line). It opens the same
//! command palette as Ctrl+P, hosted inline by the overlay app-modal host.
use crate::app::actions::Action;
use crate::slash::command::{CommandExecCtx, CommandResult, SlashCommand};
/// Open the command palette.
pub struct HelpCommand;
impl SlashCommand for HelpCommand {
fn name(&self) -> &str {
"help"
}
fn description(&self) -> &str {
"Browse commands and keyboard shortcuts"
}
fn usage(&self) -> &str {
"/help"
}
fn run(&self, _ctx: &mut CommandExecCtx, _args: &str) -> CommandResult {
CommandResult::Action(Action::OpenCommandPalette)
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::acp::model_state::ModelState;
use crate::app::bundle::BundleState;
use crate::settings::PagerLocalSnapshot;
static DEFAULT_BUNDLE_STATE: BundleState = BundleState {
has_cache: false,
version: String::new(),
personas: Vec::new(),
roles: Vec::new(),
agents: Vec::new(),
skills: Vec::new(),
persona_details: Vec::new(),
role_details: Vec::new(),
};
#[test]
fn dispatches_open_command_palette() {
let models = ModelState::default();
let mut ctx = CommandExecCtx {
models: &models,
session_id: None,
bundle_state: &DEFAULT_BUNDLE_STATE,
screen_mode: crate::app::ScreenMode::Minimal,
pager_state: PagerLocalSnapshot::default(),
};
assert!(matches!(
HelpCommand.run(&mut ctx, ""),
CommandResult::Action(Action::OpenCommandPalette)
));
}
}