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}
76
77/// A selectable item inside a list overlay.
78#[derive(Clone, Debug)]
79pub struct InlineListItem {
80    pub title: String,
81    pub subtitle: Option<String>,
82    pub badge: Option<String>,
83    pub indent: u8,
84    pub selection: Option<InlineListSelection>,
85    pub search_value: Option<String>,
86}
87
88/// A single step in a wizard modal flow.
89#[derive(Clone, Debug)]
90pub struct WizardStep {
91    /// Title displayed in the tab header.
92    pub title: String,
93    /// Question or instruction shown above the list.
94    pub question: String,
95    /// Selectable items for this step.
96    pub items: Vec<InlineListItem>,
97    /// Whether this step has been completed.
98    pub completed: bool,
99    /// The selected answer for this step (if completed).
100    pub answer: Option<InlineListSelection>,
101
102    pub allow_freeform: bool,
103    pub freeform_label: Option<String>,
104    pub freeform_placeholder: Option<String>,
105    pub freeform_default: Option<String>,
106}