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]
137 pub fn group_header(title: impl Into<String>) -> Self {
138 Self {
139 title: title.into(),
140 kind: InlineItemKind::Header,
141 ..Self::default()
142 }
143 }
144
145 #[must_use]
147 pub fn group_divider() -> Self {
148 Self::default()
150 }
151
152 #[must_use]
153 pub fn with_subtitle(mut self, subtitle: impl Into<String>) -> Self {
154 self.subtitle = Some(subtitle.into());
155 self
156 }
157
158 #[must_use]
159 pub fn with_value(mut self, value: impl Into<String>) -> Self {
160 self.value = Some(value.into());
161 self
162 }
163
164 #[must_use]
165 pub fn with_badge(mut self, label: impl Into<String>, tone: InlineTone) -> Self {
166 self.badge = Some(label.into());
167 self.badge_tone = tone;
168 self
169 }
170
171 #[must_use]
172 pub fn with_kind(mut self, kind: InlineItemKind) -> Self {
173 self.kind = kind;
174 self
175 }
176
177 #[must_use]
178 pub fn with_indent(mut self, indent: u8) -> Self {
179 self.indent = indent;
180 self
181 }
182
183 #[must_use]
184 pub fn with_search_value(mut self, search_value: impl Into<String>) -> Self {
185 self.search_value = Some(search_value.into());
186 self
187 }
188
189 #[must_use]
193 pub fn is_header(&self) -> bool {
194 self.selection.is_none() && self.kind != InlineItemKind::Hint
195 }
196}
197
198#[derive(Clone, Debug)]
200pub struct WizardStep {
201 pub title: String,
203 pub question: String,
205 pub items: Vec<InlineListItem>,
207 pub completed: bool,
209 pub answer: Option<InlineListSelection>,
211
212 pub allow_freeform: bool,
213 pub freeform_label: Option<String>,
214 pub freeform_placeholder: Option<String>,
215 pub freeform_default: Option<String>,
216}