Skip to main content

wisp/
command.rs

1use crate::attachment::{AttachmentOutcome, PromptAttachment};
2use crate::file_index::FileEntry;
3use crate::conversation::ConversationId;
4use crate::git_review::{DiffScope, GitDiffEvent, GitWatchEvent};
5use crate::request::RequestId;
6use crate::session::workspace_status::WorkspaceStatus;
7use crate::settings::UiSettings;
8use crate::theme::{Theme, ThemeApplicationError};
9use acp_utils::notifications::{
10    PromptSearchParams, PromptSearchResponse, SessionPreviewResponse, WorkspaceListResponse, WorkspaceMoveResponse,
11    WorkspaceMoveTarget,
12};
13use agent_client_protocol::schema::v2::{
14    ContentBlock, ListSessionsResponse, LoginAuthResponse, NewSessionResponse, PromptResponse,
15    ResumeSessionResponse, SetSessionConfigOptionResponse, SessionConfigOptionValue, SessionId,
16};
17use clankerdiff_ratatui::diff::RepositoryAction;
18use std::path::PathBuf;
19
20#[derive(Debug, Clone)]
21pub enum Command {
22    Agent(AgentCommand),
23    Filesystem(FilesystemCommand),
24    Git(GitCommand),
25    GitWatch(GitWatchCommand),
26    ResolveWorkspace { cwd: PathBuf },
27    Terminal(TerminalCommand),
28}
29
30#[derive(Debug, Clone)]
31pub enum AgentCommand {
32    Prompt { session_id: SessionId, text: String, content: Option<Vec<ContentBlock>> },
33    Cancel { session_id: SessionId },
34    SetConfigOption { conversation_id: ConversationId, session_id: SessionId, config_id: String, value: SessionConfigOptionValue },
35    AuthenticateMcpServer { session_id: SessionId, server_name: String },
36    Authenticate { method_id: String },
37    ListSessions,
38    ResumeSession { session_id: SessionId, cwd: PathBuf },
39    NewSession { cwd: PathBuf },
40    SearchPrompts(PromptSearchParams),
41    SessionPreview { session_id: String },
42    ListWorkspaces { session_id: String },
43    MoveWorkspace { session_id: String, target: WorkspaceMoveTarget },
44}
45
46#[derive(Debug, Clone)]
47pub enum FilesystemCommand {
48    IndexFiles { request_id: RequestId, root: PathBuf },
49    PrepareSubmission { attachments: Vec<PromptAttachment> },
50    ListThemes,
51    ListReviewThemes,
52    ApplyTheme { settings: Box<UiSettings> },
53}
54
55#[derive(Debug, Clone)]
56pub enum GitCommand {
57    Apply { review_id: RequestId, action: RepositoryAction },
58}
59
60#[derive(Debug, Clone)]
61pub enum GitWatchCommand {
62    Open { review_id: RequestId, working_dir: PathBuf, scope: DiffScope },
63    Refresh { review_id: RequestId, scope: DiffScope },
64    Close { review_id: RequestId },
65}
66
67#[derive(Debug, Clone)]
68pub enum TerminalCommand {
69    RingBell,
70}
71
72pub enum CommandResult {
73    Prompt(Result<PromptResponse, String>),
74    Cancel(Result<(), String>),
75    AuthenticateMcp(Result<(), String>),
76    ConfigOptionsUpdated { conversation_id: ConversationId, result: Result<SetSessionConfigOptionResponse, String> },
77    AuthenticationCompleted { method_id: String, result: Result<LoginAuthResponse, String> },
78    NewSession(Result<NewSessionResponse, String>),
79    ResumeSession { session_id: SessionId, result: Result<ResumeSessionResponse, String> },
80    SessionsListed(Result<ListSessionsResponse, String>),
81    PromptSearchResults { query: String, result: Result<PromptSearchResponse, String> },
82    SessionPreviewLoaded { session_id: String, result: Result<SessionPreviewResponse, String> },
83    WorkspacesListed(Result<WorkspaceListResponse, String>),
84    WorkspaceMoved(Result<WorkspaceMoveResponse, String>),
85    FilesIndexed { request_id: RequestId, files: Vec<FileEntry> },
86    GitDiff(GitDiffEvent),
87    GitWatch(GitWatchEvent),
88    GitWatchStarted {
89        review_id: RequestId,
90        result: Result<Box<(clankerdiff_git::GitRepository, clankerdiff_watch::RepositoryWatcher)>, clankerdiff_watch::WatchError>,
91    },
92    SubmissionPrepared(AttachmentOutcome),
93    ThemesListed(Vec<String>),
94    ReviewThemesListed(Vec<clankerdiff_ratatui::ThemeChoice>),
95    ThemeApplied(Result<(Box<UiSettings>, Theme), ThemeApplicationError>),
96    WorkspaceResolved { cwd: PathBuf, status: WorkspaceStatus },
97    BackgroundFailed(String),
98    TerminalFailed(String),
99}