Skip to main content

objects/object/
action_operation.rs

1// SPDX-License-Identifier: Apache-2.0
2//! Action operation types.
3
4use serde::{Deserialize, Serialize};
5
6use super::ChangeId;
7
8/// Type of operation performed.
9#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
10pub enum Operation {
11    /// Repository initialization.
12    Init,
13    /// Capture worktree as new state.
14    Snapshot,
15    /// Move worktree to a different state.
16    Goto,
17    /// Create a new branch of exploration.
18    Fork,
19    /// Squash multiple states into one.
20    Collapse {
21        /// Source states that were collapsed.
22        sources: Vec<ChangeId>,
23    },
24    /// AI-generated merge/reconciliation.
25    Synthesize {
26        /// Source states that were synthesized.
27        sources: Vec<ChangeId>,
28    },
29    /// Update a thread reference.
30    ThreadUpdate {
31        /// Name of the thread.
32        thread: String,
33    },
34    /// Import from external source.
35    Import {
36        /// Description of the source.
37        source: String,
38    },
39}
40
41impl Operation {
42    /// Get a short description of the operation.
43    pub fn description(&self) -> &'static str {
44        match self {
45            Operation::Init => "initialize repository",
46            Operation::Snapshot => "snapshot",
47            Operation::Goto => "goto",
48            Operation::Fork => "fork",
49            Operation::Collapse { .. } => "collapse",
50            Operation::Synthesize { .. } => "synthesize",
51            Operation::ThreadUpdate { .. } => "update thread",
52            Operation::Import { .. } => "import",
53        }
54    }
55}