Crate renames: - zesdex-entities::seaorm → domain (misleading name, no SeaORM used) - zesdex-dto → merged into zesdex-entities (100% re-exports) - zesdex-libs → zesdex-infra (vague name) Module renames: - app/harness → guard (misleading: safety gatekeeper, not test harness) - runtime/commands → action_dispatch (name clashed with controller/command) - resources → prompts (embedded prompt text, not general resources) - tool/seqthink → sequential_think (unreadable abbreviation) - msglog/query → insert (module only inserts, never queries) Dead code removal: - app/mode/help.rs (orphaned — not declared in mod.rs) - app/mode/loading.rs (orphaned — not declared in mod.rs) File splitting (71 new files, avg ~115 lines/file): - app/runtime/actions/: 1→8 files (was 2030 lines) - view/overlays/: 1→16 files (was 1167 lines) - tool/lsp/: 1→8 per-tool files (was 909 lines) - main.rs: 1→5 files (session, daemon, attach, event_loop) - workflow/engine + hive_mind: 2→10 files - subagent/engine + auto: 2→9 files - lsp/provisioner: 1→5 files - review/: 1→6 files - guard/: 1→2 files (extracted patterns) - state/misc: 1→3 files (input, scroll) - mcp/: 1→3 files (transport, adapter) - stream/json_repair extracted from turn.rs DRY: - Pattern constants (STUB_PATTERNS etc) in guard/patterns shared with subagent - 3 near-identical background spawners → 1 generic + thin wrappers - Shared spawn_subagent_with_drain() extracted - Shared create_session() in main - write_osc52 deduplicated Bug fixes: - archive_message(): sess.db → db (wrong variable name) - execute_one_tool(): wrong parameter name - check_credential_read() function was missing (restored from test expectations)
78 lines
2.6 KiB
Rust
78 lines
2.6 KiB
Rust
//! Maps parsed `/` slash commands into one or more `Action` variants
|
|
//! that `apply_action` can process.
|
|
use crate::app::runtime::actions::Action;
|
|
use crate::app::state::types::Overlay;
|
|
use crate::controller::command::Command;
|
|
|
|
/// Convert a parsed `Command` into the corresponding sequence of `Action`s.
|
|
///
|
|
/// Flow: match each `Command` variant to its handler — most produce a
|
|
/// single `Action` (open an overlay, dispatch an OAuth flow, open the
|
|
/// editor, etc.); some produce an `Action::SystemNote` for errors or
|
|
/// informational responses.
|
|
///
|
|
/// Return: a `Vec<Action>` (always non-empty) to be applied sequentially
|
|
/// by `apply_action`.
|
|
pub fn apply_command(command: Command) -> Vec<Action> {
|
|
match command {
|
|
Command::Help => {
|
|
vec![Action::OpenOverlay(Overlay::Help)]
|
|
}
|
|
Command::Quit => {
|
|
vec![Action::QuitConfirm]
|
|
}
|
|
Command::McpOpen => {
|
|
vec![Action::OpenOverlay(Overlay::Mcp)]
|
|
}
|
|
Command::ClearConfirm => {
|
|
vec![Action::OpenOverlay(Overlay::ClearConfirm)]
|
|
}
|
|
Command::Clear => {
|
|
vec![Action::SystemNote {
|
|
kind: "clear".to_string(),
|
|
message: "transcript cleared".to_string(),
|
|
}]
|
|
}
|
|
Command::Login { provider } if provider.is_empty() => {
|
|
vec![Action::SystemNote {
|
|
kind: "error".to_string(),
|
|
message: "Usage: /login <provider>".to_string(),
|
|
}]
|
|
}
|
|
Command::Login { provider } => {
|
|
vec![Action::StartOAuth { provider }]
|
|
}
|
|
Command::Edit(path) if path == "." || path.is_empty() => {
|
|
vec![Action::SystemNote {
|
|
kind: "info".to_string(),
|
|
message: "Usage: /edit <path>\nOpens a file for inline editing.\nExample: /edit src/main.rs".to_string(),
|
|
}]
|
|
}
|
|
Command::Edit(path) => {
|
|
vec![Action::OpenEditor { path }]
|
|
}
|
|
Command::McpAdd { name, command } => {
|
|
vec![Action::McpAdd { name, command }]
|
|
}
|
|
Command::ModelList => {
|
|
vec![Action::ModelList]
|
|
}
|
|
Command::Compact => {
|
|
vec![Action::Compact]
|
|
}
|
|
|
|
Command::TodoOpen => {
|
|
vec![Action::OpenOverlay(Overlay::Todo)]
|
|
}
|
|
Command::UsageOpen => {
|
|
vec![Action::OpenOverlay(Overlay::Usage)]
|
|
}
|
|
Command::Unknown(cmd) => {
|
|
vec![Action::SystemNote {
|
|
kind: "error".to_string(),
|
|
message: format!("unknown command: {cmd}"),
|
|
}]
|
|
}
|
|
}
|
|
}
|