use agent_client_protocol::schema::v2::SessionId;
use std::path::PathBuf;
#[derive(Default)]
pub enum ForegroundOperation {
#[default]
Idle,
PreparingPrompt(String),
CreatingSession { previous_selections: Vec<(String, String)> },
ResumingSession { session_id: SessionId, cwd: PathBuf },
ListingWorkspaces,
PickingWorkspace,
MovingWorkspace,
LoadingWorkspaceSession { session_id: SessionId, cwd: PathBuf },
}
impl ForegroundOperation {
pub(super) fn is_idle(&self) -> bool {
matches!(self, Self::Idle)
}
pub(super) fn drop_prepared_prompt(&mut self) {
if matches!(self, Self::PreparingPrompt(_)) {
*self = Self::Idle;
}
}
pub(super) fn take_prepared_prompt(&mut self) -> Option<String> {
if !matches!(self, Self::PreparingPrompt(_)) {
return None;
}
let Self::PreparingPrompt(text) = std::mem::take(self) else { unreachable!() };
Some(text)
}
}