vtcode_commons/ui_protocol/
selection.rs1use super::style::InlineTone;
4
5#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7pub enum RewindAction {
8 RestoreBoth,
9 RestoreConversation,
10 RestoreCode,
11 SummarizeFromHere,
12 NeverMind,
13}
14
15#[derive(Clone, Copy, Debug, PartialEq, Eq)]
16pub enum OpenAIServiceTierChoice {
17 ProjectDefault,
18 Flex,
19 Priority,
20 Ultrafast,
21}
22
23#[derive(Clone, Debug, PartialEq, Eq)]
29pub enum InlineListSelection {
30 Model(usize),
31 DynamicModel(usize),
32 CustomProvider(usize),
33 RefreshDynamicModels,
34 Reasoning(String),
35 DisableReasoning,
36 OpenAIServiceTier(OpenAIServiceTierChoice),
37 CustomModel,
38 Theme(String),
39 Session(String),
40 SessionForkMode {
41 session_id: String,
42 summarize: bool,
43 },
44 ConfigAction(String),
45 SlashCommand(String),
46 ToolApproval(bool),
47 ToolApprovalDenyOnce,
48 ToolApprovalSession,
49 ToolApprovalPermanent,
50 ToolApprovalEnable,
51 FileConflictReload,
52 FileConflictViewDiff,
53 FileConflictAbort,
54 RewindCheckpoint(usize),
55 RewindAction(RewindAction),
56
57 AskUserChoice {
59 tab_id: String,
60 choice_id: String,
61 text: Option<String>,
62 },
63
64 RequestUserInputAnswer {
66 question_id: String,
67 selected: Vec<String>,
68 other: Option<String>,
69 },
70
71 PlanApprovalExecute,
73 PlanApprovalFreshContext,
75 PlanApprovalEditPlan,
77 PlanApprovalDiscuss,
79 PlanApprovalAutoAccept,
81 PlanApprovalSwitchBuild,
83 PlanApprovalSwitchAuto,
85}
86
87#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
92pub enum InlineItemKind {
93 #[default]
95 Item,
96 Header,
98 Setting,
100 Action,
102 Hint,
104}
105
106#[derive(Clone, Debug, Default)]
108pub struct InlineListItem {
109 pub title: String,
110 pub subtitle: Option<String>,
113 pub badge: Option<String>,
115 pub indent: u8,
116 pub selection: Option<InlineListSelection>,
117 pub search_value: Option<String>,
118 pub value: Option<String>,
120 pub badge_tone: InlineTone,
122 pub kind: InlineItemKind,
124}
125
126impl InlineListItem {
127 #[must_use]
129 pub fn new(title: impl Into<String>, selection: Option<InlineListSelection>) -> Self {
130 Self { title: title.into(), selection, ..Self::default() }
131 }
132
133 #[must_use]
138 pub fn group_header(title: impl Into<String>) -> Self {
139 Self {
140 title: title.into(),
141 kind: InlineItemKind::Header,
142 ..Self::default()
143 }
144 }
145
146 #[must_use]
148 pub fn group_divider() -> Self {
149 Self::default()
151 }
152
153 #[must_use]
154 pub fn with_subtitle(mut self, subtitle: impl Into<String>) -> Self {
155 self.subtitle = Some(subtitle.into());
156 self
157 }
158
159 #[must_use]
160 pub fn with_value(mut self, value: impl Into<String>) -> Self {
161 self.value = Some(value.into());
162 self
163 }
164
165 #[must_use]
166 pub fn with_badge(mut self, label: impl Into<String>, tone: InlineTone) -> Self {
167 self.badge = Some(label.into());
168 self.badge_tone = tone;
169 self
170 }
171
172 #[must_use]
173 pub fn with_kind(mut self, kind: InlineItemKind) -> Self {
174 self.kind = kind;
175 self
176 }
177
178 #[must_use]
179 pub fn with_indent(mut self, indent: u8) -> Self {
180 self.indent = indent;
181 self
182 }
183
184 #[must_use]
185 pub fn with_search_value(mut self, search_value: impl Into<String>) -> Self {
186 self.search_value = Some(search_value.into());
187 self
188 }
189
190 #[must_use]
194 pub fn is_header(&self) -> bool {
195 self.selection.is_none() && self.kind != InlineItemKind::Hint
196 }
197}
198
199#[derive(Clone, Debug)]
201pub struct WizardStep {
202 pub title: String,
204 pub question: String,
206 pub items: Vec<InlineListItem>,
208 pub completed: bool,
210 pub answer: Option<InlineListSelection>,
212
213 pub allow_freeform: bool,
214 pub freeform_label: Option<String>,
215 pub freeform_placeholder: Option<String>,
216 pub freeform_default: Option<String>,
217}