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 SessionLimitIncrease(usize),
55 RewindCheckpoint(usize),
56 RewindAction(RewindAction),
57
58 AskUserChoice {
60 tab_id: String,
61 choice_id: String,
62 text: Option<String>,
63 },
64
65 RequestUserInputAnswer {
67 question_id: String,
68 selected: Vec<String>,
69 other: Option<String>,
70 },
71
72 PlanApprovalExecute,
74 PlanApprovalFreshContext,
76 PlanApprovalEditPlan,
78 PlanApprovalDiscuss,
80 PlanApprovalAutoAccept,
82 PlanApprovalSwitchBuild,
84 PlanApprovalSwitchAuto,
86}
87
88#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
93pub enum InlineItemKind {
94 #[default]
96 Item,
97 Header,
99 Setting,
101 Action,
103 Hint,
105}
106
107#[derive(Clone, Debug, Default)]
109pub struct InlineListItem {
110 pub title: String,
111 pub subtitle: Option<String>,
114 pub badge: Option<String>,
116 pub indent: u8,
117 pub selection: Option<InlineListSelection>,
118 pub search_value: Option<String>,
119 pub value: Option<String>,
121 pub badge_tone: InlineTone,
123 pub kind: InlineItemKind,
125}
126
127impl InlineListItem {
128 #[must_use]
130 pub fn new(title: impl Into<String>, selection: Option<InlineListSelection>) -> Self {
131 Self { title: title.into(), selection, ..Self::default() }
132 }
133
134 #[must_use]
139 pub fn group_header(title: impl Into<String>) -> Self {
140 Self {
141 title: title.into(),
142 kind: InlineItemKind::Header,
143 ..Self::default()
144 }
145 }
146
147 #[must_use]
149 pub fn group_divider() -> Self {
150 Self::default()
152 }
153
154 #[must_use]
155 pub fn with_subtitle(mut self, subtitle: impl Into<String>) -> Self {
156 self.subtitle = Some(subtitle.into());
157 self
158 }
159
160 #[must_use]
161 pub fn with_value(mut self, value: impl Into<String>) -> Self {
162 self.value = Some(value.into());
163 self
164 }
165
166 #[must_use]
167 pub fn with_badge(mut self, label: impl Into<String>, tone: InlineTone) -> Self {
168 self.badge = Some(label.into());
169 self.badge_tone = tone;
170 self
171 }
172
173 #[must_use]
174 pub fn with_kind(mut self, kind: InlineItemKind) -> Self {
175 self.kind = kind;
176 self
177 }
178
179 #[must_use]
180 pub fn with_indent(mut self, indent: u8) -> Self {
181 self.indent = indent;
182 self
183 }
184
185 #[must_use]
186 pub fn with_search_value(mut self, search_value: impl Into<String>) -> Self {
187 self.search_value = Some(search_value.into());
188 self
189 }
190
191 #[must_use]
195 pub fn is_header(&self) -> bool {
196 self.selection.is_none() && self.kind != InlineItemKind::Hint
197 }
198}
199
200#[derive(Clone, Debug)]
202pub struct WizardStep {
203 pub title: String,
205 pub question: String,
207 pub items: Vec<InlineListItem>,
209 pub completed: bool,
211 pub answer: Option<InlineListSelection>,
213
214 pub allow_freeform: bool,
215 pub freeform_label: Option<String>,
216 pub freeform_placeholder: Option<String>,
217 pub freeform_default: Option<String>,
218}