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, 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    FileConflictReload,
48    FileConflictViewDiff,
49    FileConflictAbort,
50    SessionLimitIncrease(usize),
51    RewindCheckpoint(usize),
52    RewindAction(RewindAction),
53
54    /// Selection shape used by legacy tabbed HITL flows.
55    AskUserChoice {
56        tab_id: String,
57        choice_id: String,
58        text: Option<String>,
59    },
60
61    /// Selection returned from the `request_user_input` HITL tool.
62    RequestUserInputAnswer {
63        question_id: String,
64        selected: Vec<String>,
65        other: Option<String>,
66    },
67
68    /// Plan confirmation dialog result (human-in-the-loop flow).
69    PlanApprovalExecute,
70    /// Return to planning to edit the plan.
71    PlanApprovalEditPlan,
72    /// Auto-accept all future plans in this session.
73    PlanApprovalAutoAccept,
74}
75
76/// A selectable item inside a list overlay.
77#[derive(Clone, Debug)]
78pub struct InlineListItem {
79    pub title: String,
80    pub subtitle: Option<String>,
81    pub badge: Option<String>,
82    pub indent: u8,
83    pub selection: Option<InlineListSelection>,
84    pub search_value: Option<String>,
85}
86
87/// A single step in a wizard modal flow.
88#[derive(Clone, Debug)]
89pub struct WizardStep {
90    /// Title displayed in the tab header.
91    pub title: String,
92    /// Question or instruction shown above the list.
93    pub question: String,
94    /// Selectable items for this step.
95    pub items: Vec<InlineListItem>,
96    /// Whether this step has been completed.
97    pub completed: bool,
98    /// The selected answer for this step (if completed).
99    pub answer: Option<InlineListSelection>,
100
101    pub allow_freeform: bool,
102    pub freeform_label: Option<String>,
103    pub freeform_placeholder: Option<String>,
104    pub freeform_default: Option<String>,
105}