1use crate::surfaces::composer::Submission;
2use agent_client_protocol::schema::v2::SessionId;
3use std::path::PathBuf;
4
5#[derive(Default)]
8pub enum ForegroundOperation {
9 #[default]
10 Idle,
11 PreparingPrompt(Submission),
12 CreatingSession { previous_selections: Vec<(String, String)> },
13 ResumingSession { session_id: SessionId, cwd: PathBuf },
14 ListingWorkspaces,
15 PickingWorkspace,
16 MovingWorkspace,
17 LoadingWorkspaceSession { session_id: SessionId, cwd: PathBuf },
18}
19
20impl ForegroundOperation {
21 pub(super) fn is_idle(&self) -> bool {
22 matches!(self, Self::Idle)
23 }
24
25 pub(super) fn drop_prepared_prompt(&mut self) {
27 if matches!(self, Self::PreparingPrompt(_)) {
28 *self = Self::Idle;
29 }
30 }
31
32 pub(super) fn take_prepared_prompt(&mut self) -> Option<Submission> {
33 if !matches!(self, Self::PreparingPrompt(_)) {
34 return None;
35 }
36 let Self::PreparingPrompt(submission) = std::mem::take(self) else { unreachable!() };
37 Some(submission)
38 }
39}