Skip to main content

vtcode_commons/ui_protocol/
selection.rs

1//! List selection and wizard step types.
2
3/// Rewind action choices for the rewind overlay.
4#[derive(Clone, Copy, Debug, PartialEq, Eq)]
5pub enum RewindAction {
6    RestoreBoth,
7    RestoreConversation,
8    RestoreCode,
9    SummarizeFromHere,
10    NeverMind,
11}
12
13#[derive(Clone, Copy, Debug, PartialEq, Eq)]
14pub enum OpenAIServiceTierChoice {
15    ProjectDefault,
16    Flex,
17    Priority,
18}
19
20/// Selection value returned from a list or wizard overlay.
21///
22/// The `Reasoning` variant carries a `String` reasoning-effort level rather
23/// than a typed enum so that this type stays free of config-crate dependencies.
24/// Callers convert to/from their local `ReasoningEffortLevel` as needed.
25#[derive(Clone, Debug, PartialEq, Eq)]
26pub enum InlineListSelection {
27    Model(usize),
28    DynamicModel(usize),
29    CustomProvider(usize),
30    RefreshDynamicModels,
31    Reasoning(String),
32    DisableReasoning,
33    OpenAIServiceTier(OpenAIServiceTierChoice),
34    CustomModel,
35    Theme(String),
36    Session(String),
37    SessionForkMode {
38        session_id: String,
39        summarize: bool,
40    },
41    ConfigAction(String),
42    SlashCommand(String),
43    ToolApproval(bool),
44    ToolApprovalDenyOnce,
45    ToolApprovalSession,
46    ToolApprovalPermanent,
47    ToolApprovalEnable,
48    FileConflictReload,
49    FileConflictViewDiff,
50    FileConflictAbort,
51    SessionLimitIncrease(usize),
52    RewindCheckpoint(usize),
53    RewindAction(RewindAction),
54
55    /// Selection shape used by legacy tabbed HITL flows.
56    AskUserChoice {
57        tab_id: String,
58        choice_id: String,
59        text: Option<String>,
60    },
61
62    /// Selection returned from the `request_user_input` HITL tool.
63    RequestUserInputAnswer {
64        question_id: String,
65        selected: Vec<String>,
66        other: Option<String>,
67    },
68
69    /// Plan confirmation dialog result (human-in-the-loop flow).
70    PlanApprovalExecute,
71    /// Return to planning to edit the plan.
72    PlanApprovalEditPlan,
73    /// Auto-accept all future plans in this session.
74    PlanApprovalAutoAccept,
75    /// Hand off to the build primary agent and execute the plan.
76    PlanApprovalSwitchBuild,
77    /// Hand off to the auto primary agent (auto-execute with per-step HITL).
78    PlanApprovalSwitchAuto,
79}
80
81/// A selectable item inside a list overlay.
82#[derive(Clone, Debug)]
83pub struct InlineListItem {
84    pub title: String,
85    pub subtitle: Option<String>,
86    pub badge: Option<String>,
87    pub indent: u8,
88    pub selection: Option<InlineListSelection>,
89    pub search_value: Option<String>,
90}
91
92/// A single step in a wizard modal flow.
93#[derive(Clone, Debug)]
94pub struct WizardStep {
95    /// Title displayed in the tab header.
96    pub title: String,
97    /// Question or instruction shown above the list.
98    pub question: String,
99    /// Selectable items for this step.
100    pub items: Vec<InlineListItem>,
101    /// Whether this step has been completed.
102    pub completed: bool,
103    /// The selected answer for this step (if completed).
104    pub answer: Option<InlineListSelection>,
105
106    pub allow_freeform: bool,
107    pub freeform_label: Option<String>,
108    pub freeform_placeholder: Option<String>,
109    pub freeform_default: Option<String>,
110}