Skip to main content

oxicode_vtui_compat/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    /// `/models` catalog browser — index into
36    /// `RenderState::overlay_catalog_models`.
37    CatalogModel(usize),
38    /// `/providers` list — index into `RenderState::overlay_providers`.
39    ProviderRow(usize),
40    Theme(String),
41    Session(String),
42    SessionForkMode {
43        session_id: String,
44        summarize: bool,
45    },
46    ConfigAction(String),
47    SlashCommand(String),
48    ToolApproval(bool),
49    ToolApprovalDenyOnce,
50    ToolApprovalSession,
51    ToolApprovalPermanent,
52    ToolApprovalEnable,
53    FileConflictReload,
54    FileConflictViewDiff,
55    FileConflictAbort,
56    SessionLimitIncrease(usize),
57    RewindCheckpoint(usize),
58    RewindAction(RewindAction),
59
60    /// Selection shape used by legacy tabbed HITL flows.
61    AskUserChoice {
62        tab_id: String,
63        choice_id: String,
64        text: Option<String>,
65    },
66
67    /// Selection returned from the `request_user_input` HITL tool.
68    RequestUserInputAnswer {
69        question_id: String,
70        selected: Vec<String>,
71        other: Option<String>,
72    },
73
74    /// Plan confirmation dialog result (human-in-the-loop flow).
75    PlanApprovalExecute,
76    /// Return to planning to edit the plan file.
77    PlanApprovalEditPlan,
78    /// Return to planning to discuss and revise the plan in chat.
79    PlanApprovalDiscuss,
80    /// Auto-accept all future plans in this session.
81    PlanApprovalAutoAccept,
82    /// Hand off to the build primary agent and execute the plan.
83    PlanApprovalSwitchBuild,
84    /// Hand off to the auto primary agent (auto-execute with per-step HITL).
85    PlanApprovalSwitchAuto,
86}
87
88/// A selectable item inside a list overlay.
89#[derive(Clone, Debug)]
90pub struct InlineListItem {
91    pub title: String,
92    pub subtitle: Option<String>,
93    pub badge: Option<String>,
94    pub indent: u8,
95    pub selection: Option<InlineListSelection>,
96    pub search_value: Option<String>,
97}
98
99/// A single step in a wizard modal flow.
100#[derive(Clone, Debug)]
101pub struct WizardStep {
102    /// Title displayed in the tab header.
103    pub title: String,
104    /// Question or instruction shown above the list.
105    pub question: String,
106    /// Selectable items for this step.
107    pub items: Vec<InlineListItem>,
108    /// Whether this step has been completed.
109    pub completed: bool,
110    /// The selected answer for this step (if completed).
111    pub answer: Option<InlineListSelection>,
112
113    pub allow_freeform: bool,
114    pub freeform_label: Option<String>,
115    pub freeform_placeholder: Option<String>,
116    pub freeform_default: Option<String>,
117}