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