1use crate::attachment::{AttachmentOutcome, PromptAttachment};
2use crate::file_index::FileEntry;
3use crate::git_review::{ClientState, DiffReviewEvent, ServerMessage};
4use crate::request::RequestId;
5use crate::session::workspace_status::WorkspaceStatus;
6use crate::settings::UiSettings;
7use crate::theme::{Theme, ThemeApplicationError};
8use acp_utils::conversation::ConversationId;
9use acp_utils::notifications::{
10 PromptSearchParams, PromptSearchResponse, SessionPreviewResponse, WorkspaceListResponse, WorkspaceMoveResponse,
11 WorkspaceMoveTarget,
12};
13use agent_client_protocol::schema::v2::{
14 ContentBlock, ListSessionsResponse, LoginAuthResponse, NewSessionResponse, ResumeSessionResponse,
15 SessionConfigOptionValue, SessionId, SetSessionConfigOptionResponse,
16};
17use std::path::PathBuf;
18use std::sync::Arc;
19
20#[derive(Debug, Clone)]
21pub enum Command {
22 Agent(AgentCommand),
23 GitReview(GitReviewCommand),
24 Filesystem(FilesystemCommand),
25 Terminal(TerminalCommand),
26}
27
28#[derive(Debug, Clone)]
29pub enum AgentCommand {
30 Prompt {
31 request_id: RequestId,
32 session_id: SessionId,
33 text: String,
34 content: Option<Vec<ContentBlock>>,
35 },
36 Cancel {
37 session_id: SessionId,
38 },
39 SetConfigOption {
40 conversation_id: ConversationId,
41 session_id: SessionId,
42 config_id: String,
43 value: SessionConfigOptionValue,
44 },
45 AuthenticateMcpServer {
46 session_id: SessionId,
47 server_name: String,
48 },
49 Authenticate {
50 method_id: String,
51 },
52 ListSessions,
53 ResumeSession {
54 session_id: SessionId,
55 cwd: PathBuf,
56 },
57 NewSession {
58 cwd: PathBuf,
59 },
60 SearchPrompts(PromptSearchParams),
61 SessionPreview {
62 session_id: String,
63 },
64 ListWorkspaces {
65 session_id: String,
66 },
67 MoveWorkspace {
68 session_id: String,
69 target: WorkspaceMoveTarget,
70 },
71 FetchWorkspaceStatus {
72 session_id: String,
73 cwd: PathBuf,
74 },
75}
76
77#[derive(Debug, Clone)]
78pub enum GitReviewCommand {
79 Open { session_id: String },
81 Event(DiffReviewEvent),
83 Forward(ServerMessage),
85 Close,
87}
88
89#[derive(Debug, Clone)]
90pub enum FilesystemCommand {
91 IndexFiles { request_id: RequestId, root: PathBuf },
92 PrepareSubmission { attachments: Vec<PromptAttachment> },
93 ListThemes,
94 ListReviewThemes,
95 ApplyTheme { settings: Box<UiSettings> },
96}
97
98#[derive(Debug, Clone)]
99pub enum TerminalCommand {
100 RingBell,
101}
102
103#[derive(Debug, Clone, PartialEq, Eq)]
104pub enum PromptRejection {
105 Cancelled,
106 Failed(String),
107}
108
109pub enum CommandResult {
110 Prompt { request_id: RequestId, result: Result<(), PromptRejection> },
111 Cancel(Result<(), String>),
112 AuthenticateMcp(Result<(), String>),
113 ConfigOptionsUpdated { conversation_id: ConversationId, result: Result<SetSessionConfigOptionResponse, String> },
114 AuthenticationCompleted { method_id: String, result: Result<LoginAuthResponse, String> },
115 NewSession(Result<NewSessionResponse, String>),
116 ResumeSession { session_id: SessionId, result: Result<ResumeSessionResponse, String> },
117 SessionsListed(Result<ListSessionsResponse, String>),
118 PromptSearchResults { query: String, result: Result<PromptSearchResponse, String> },
119 SessionPreviewLoaded { session_id: String, result: Result<SessionPreviewResponse, String> },
120 WorkspacesListed(Result<WorkspaceListResponse, String>),
121 WorkspaceMoved(Result<WorkspaceMoveResponse, String>),
122 FilesIndexed { request_id: RequestId, files: Vec<FileEntry> },
123 GitReview(Arc<ClientState>),
124 GitReviewAction(Result<(), String>),
125 SubmissionPrepared(AttachmentOutcome),
126 ThemesListed(Vec<String>),
127 ReviewThemesListed(Vec<clankerdiff_ratatui::ThemeChoice>),
128 ThemeApplied(Result<(Box<UiSettings>, Theme), ThemeApplicationError>),
129 WorkspaceResolved { cwd: PathBuf, status: WorkspaceStatus },
130 BackgroundFailed(String),
131 TerminalFailed(String),
132}