use crate::facets::SessionSyncPayload;
#[derive(Debug, Clone, PartialEq)]
pub struct CommandResult<A> {
pub message: Option<String>,
pub action: Option<A>,
pub is_error: bool,
}
impl<A> CommandResult<A> {
pub fn ok() -> Self {
Self {
message: None,
action: None,
is_error: false,
}
}
pub fn message(msg: impl Into<String>) -> Self {
Self {
message: Some(msg.into()),
action: None,
is_error: false,
}
}
pub fn action(action: A) -> Self {
Self {
message: None,
action: Some(action),
is_error: false,
}
}
pub fn with_message_and_action(msg: impl Into<String>, action: A) -> Self {
Self {
message: Some(msg.into()),
action: Some(action),
is_error: false,
}
}
pub fn error(msg: impl Into<String>) -> Self {
Self {
message: Some(format!("Error: {}", msg.into())),
action: None,
is_error: true,
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum DebugAction {
FetchBalance,
CacheWarmup,
PreviewOutboundRequest {
json: bool,
base_prompt_only: bool,
hypothetical_prompt: Option<String>,
},
OpenTextPager {
title: String,
content: String,
},
OpenDiffPager {
title: String,
diff: String,
},
OpenContextInspector,
SendMessage(String),
SyncSession(SessionSyncPayload),
ConversationUndo {
sync: SessionSyncPayload,
retry_input: Option<String>,
},
}
pub type DebugCommandResult = CommandResult<DebugAction>;
pub type StructcopyCommandResult = CommandResult<std::convert::Infallible>;
#[derive(Debug, Clone, PartialEq)]
pub enum SessionAction {
CompactContext { focus: Option<String> },
PurgeContext,
LoadSession(std::path::PathBuf),
SyncSession(SessionSyncPayload),
SendMessage(String),
RemoteControl(SessionRemoteControlAction),
OpenExternalUrl { url: String, label: String },
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SessionRemoteControlAction {
Start,
Stop,
}
pub type SessionCommandResult = CommandResult<SessionAction>;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ConfigAction {
PermissionRulesChanged,
StartXaiDeviceLogin,
StartClaudeLogin,
StartClaudeRevoke,
StartChatgptPkceLogin,
StartChatgptRevoke,
StartOrcarouterPkceLogin,
StartOrcarouterRevoke,
OpenConfigView,
OpenModePicker,
OpenThemePicker,
OpenStatusPicker,
OpenProviderPicker,
StartPluginLogin {
provider: String,
},
StartPluginLogout {
provider: String,
},
SetScreenMode(crate::types::CommandScreenMode),
SetWorkspaceTrust {
trusted: bool,
save: bool,
},
ModeChanged(crate::types::CommandMode),
ApprovalPolicyChanged {
policy: Option<String>,
},
SwitchProvider {
provider: crate::types::CommandProviderId,
model: Option<String>,
},
CompactionChanged(crate::config::CommandCompactionConfig),
StreamChunkTimeoutChanged(u64),
SubagentRuntimeChanged(crate::config::CommandSubagentRuntimeConfig),
SearchProviderChanged(crate::config::CommandSearchProvider),
PromptSuggestionChanged {
enabled: bool,
},
NotificationChanged(crate::config::CommandNotificationUpdate),
}
pub type ConfigCommandResult = CommandResult<ConfigAction>;
pub type ConfigPolicyAction = ConfigAction;
pub type ConfigPolicyCommandResult = ConfigCommandResult;
pub type ConfigStatusCommandResult = CommandResult<std::convert::Infallible>;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum CoreNavigationAction {
OpenHotbarSetup,
DisableHotbar,
RestoreHotbarDefaults,
OpenLiveTranscript,
OpenTurnInspector,
OpenWorktreeManager,
SwitchWorkspace { workspace: std::path::PathBuf },
VoiceCapture,
}
pub type CoreNavigationCommandResult = CommandResult<CoreNavigationAction>;