1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
#[allow(clippy::wildcard_imports)]
use super::*;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum FormPickerField {
Labels,
Assignee,
Cycles,
Milestones,
Reviewer,
/// The issue's board column (tix #1508). Single-select, options are the
/// active board's columns plus the field's current value. No inline create:
/// a column the board does not configure renders in the Mismatched column, and
/// inventing one from a form is not something the dropdown should do.
Status,
/// The issue's priority (tix #1508). Single-select, options are the built-in
/// `low`/`medium`/`high` plus every priority the store already uses, plus the
/// current value. Inline `+` create is kept: a custom priority is a preserved
/// concept in the model (`Priority::Other`), so a genuinely new one must
/// remain expressible.
Priority,
/// The new-issue templates configured in `[templates.<name>]`
/// (tui-new-issue-mode). Single-select: choosing one names a record to
/// pre-fill the form from.
Template,
/// The parent issue (WP06 / T026). Single-select, per C-001: one parent,
/// never a list, so this is `DropdownState::single` below and never `multi`.
Parent,
/// The issue's project associations (WP06 T029). **Multi-select**, because the
/// model and the CLI's `--projects` both hold a list, and the options come from
/// the project **service** ([`crate::projects::list_projects`]), not from
/// anything the form constructs. No inline create: a project is a registry
/// record with an identity, and `tix project create` is where one is made.
Project,
/// The issue's epic references (WP06 T031). **Multi-select**, the exact analogue
/// of `Project` for the epic registry (C-003): the model and the CLI's `--epics`
/// both hold a list, and the options come from the epic **service**
/// ([`crate::epics::list_epics`]). No inline create: an epic is a registry record
/// with an identity, and `tix epic create` is where one is made.
Epic,
}
#[derive(Debug, Clone)]
pub(in crate::app) struct FormPicker {
pub(in crate::app) field: FormPickerField,
pub(in crate::app) state: DropdownState,
}
/// The prefix on a stable-ID template's picker option id (`[issue_templates.<id>]`).
///
/// A stable template ID and a legacy `[templates.<name>]` name live in two
/// config tables that are documented never to share a key space, but a single
/// picker presents both — so each option id is namespaced here and decoded on
/// selection. That keeps "a name in one is never mistaken for an ID in the
/// other" true *inside the picker* as well (registry module doc), and it is why
/// the form stores a bare ID/name rather than this opaque token.
pub(in crate::app) const STABLE_TEMPLATE_PREFIX: &str = "stable:";
/// The prefix on a legacy `[templates.<name>]` picker option id. See
/// [`STABLE_TEMPLATE_PREFIX`].
pub(in crate::app) const LEGACY_TEMPLATE_PREFIX: &str = "legacy:";
impl FormPickerField {
/// Whether the picker's `+` inline create is offered on this field.
///
/// Every field but Status keeps the keystroke it had: cycles, milestones and
/// team members become configuration records, labels and priorities are
/// preserved values, and parent/template simply no-op downstream. A board
/// column cannot be created from the form (tix #1508) — a status the board
/// does not configure renders in the Mismatched column, so the dropdown must
/// not pretend to add one.
pub(in crate::app) fn allows_inline_create(self) -> bool {
// A project is a registry record with an identity the service owns, so the
// form may no more invent one than it may invent a board column: `+` here
// would be a project `tix project list` never shows.
!matches!(
self,
FormPickerField::Status | FormPickerField::Project | FormPickerField::Epic
)
}
}
impl App {
pub(in crate::app) fn handle_form_picker_key(&mut self, key: KeyEvent) -> Result<Action> {
if matches!(key.code, KeyCode::Esc | KeyCode::F(2)) {
self.form_picker = None;
return Ok(Action::None);
}
// The Status dropdown refuses inline create (tix #1508): a board column the
// form invents is not a column the board has, and it would render in the
// Mismatched column rather than somewhere real. Swallow the create keys
// before `DropdownState::handle_key` turns them into an InlineCreate prompt.
if let Some(picker) = self.form_picker.as_ref()
&& !picker.field.allows_inline_create()
&& picker.state.mode != PickerMode::InlineCreate
&& matches!(key.code, KeyCode::Char('+') | KeyCode::Insert)
{
return Ok(Action::None);
}
let event = match self.form_picker.as_mut() {
Some(picker) => picker.state.handle_key(key.code),
None => return Ok(Action::None),
};
match event {
PickerEvent::None => {}
PickerEvent::Cancelled => {
self.form_picker = None;
}
PickerEvent::Selected(ids) => {
self.apply_picker_selection(ids);
}
PickerEvent::Created(value) => {
self.apply_picker_created(value)?;
}
}
Ok(Action::None)
}
pub(in crate::app) fn open_form_picker(&mut self) {
let Some(form) = self.form.as_ref() else {
return;
};
let field = match form.focus {
form::FormFocus::Status => FormPickerField::Status,
form::FormFocus::Priority => FormPickerField::Priority,
form::FormFocus::Labels => FormPickerField::Labels,
form::FormFocus::Assignee => FormPickerField::Assignee,
form::FormFocus::Cycles => FormPickerField::Cycles,
form::FormFocus::Milestones => FormPickerField::Milestones,
form::FormFocus::Reviewer => FormPickerField::Reviewer,
form::FormFocus::Parent => FormPickerField::Parent,
form::FormFocus::Projects => FormPickerField::Project,
form::FormFocus::Epics => FormPickerField::Epic,
form::FormFocus::Template => FormPickerField::Template,
_ => return,
};
// The template picker has its own opener (`open_template_picker`), which
// seeds the `(none)` option and refuses when nothing is configured; F2 on
// the row routes there rather than duplicating the fallback here.
if field == FormPickerField::Template {
self.open_template_picker();
return;
}
let options = self.picker_options(field);
let mut state = match field {
FormPickerField::Labels
| FormPickerField::Cycles
| FormPickerField::Milestones
| FormPickerField::Project
| FormPickerField::Epic => DropdownState::multi(options),
FormPickerField::Assignee
| FormPickerField::Reviewer
| FormPickerField::Parent
| FormPickerField::Status
| FormPickerField::Priority
| FormPickerField::Template => DropdownState::single(options),
};
self.seed_picker_selection(field, &mut state);
self.form_picker = Some(FormPicker { field, state });
}
#[allow(clippy::too_many_lines)]
pub(in crate::app) fn picker_options(&self, field: FormPickerField) -> Vec<PickerItem> {
match field {
FormPickerField::Cycles => {
let root = self.project_root();
let planner = Planner::from_config(self.store.config.clone(), root);
planner
.cycle_names()
.into_iter()
.map(|name| PickerItem {
id: name.clone(),
label: name,
})
.collect()
}
FormPickerField::Milestones => {
let root = self.project_root();
let planner = Planner::from_config(self.store.config.clone(), root);
planner
.milestone_names()
.unwrap_or_default()
.into_iter()
.map(|name| PickerItem {
id: name.clone(),
label: name,
})
.collect()
}
FormPickerField::Labels => {
let mut out = std::collections::BTreeSet::new();
for issue in self.store.list().unwrap_or_default() {
for label in issue.labels {
if !label.trim().is_empty() {
out.insert(label);
}
}
}
out.into_iter()
.map(|label| PickerItem {
id: label.clone(),
label,
})
.collect()
}
// The board's columns, in board order, plus the field's current value
// when the board no longer configures it. A status the board has
// dropped must not become unselectable from a form that still holds
// it (tix #1508) — the same "keep the current value" rule the assignee
// and reviewer pickers follow.
FormPickerField::Status => {
let columns = self.active_board_config().columns.clone();
let mut options = crate::ui::triage::status_options(&columns);
if let Some(form) = self.form.as_ref() {
let current = form.status.trim();
if !current.is_empty() && !columns.iter().any(|c| c == current) {
options.push(PickerItem {
id: current.to_string(),
label: current.to_string(),
});
}
}
options
}
// The built-in set first, then every priority the store already uses,
// then the field's current value — the same "defaults plus what the
// project actually uses" rule Labels follows. A custom priority is a
// preserved model value (`Priority::Other`), so it must be listed once
// an issue carries it rather than being re-typed from memory.
FormPickerField::Priority => {
const BUILT_INS: [&str; 3] = ["low", "medium", "high"];
let mut out: Vec<String> = BUILT_INS.iter().map(|p| (*p).to_string()).collect();
for issue in self.store.list().unwrap_or_default() {
let priority = issue.priority.to_string();
if !priority.trim().is_empty() && !out.contains(&priority) {
out.push(priority);
}
}
if let Some(form) = self.form.as_ref() {
let current = form.priority.trim().to_string();
if !current.is_empty() && !out.contains(¤t) {
out.push(current);
}
}
out.into_iter()
.map(|priority| PickerItem {
id: priority.clone(),
label: priority,
})
.collect()
}
FormPickerField::Parent => {
// Every issue in the store is a candidate parent.
//
// T026's note asks for the issue itself to be excluded from the
// list, as "the first line of defense against a self-parent". The
// form is **create-only** — `Mode::Form` has one entry point and it
// always builds a fresh `FormState` — so there is no issue-under-edit
// to exclude: the child does not exist yet and cannot be among its
// own ancestors. The list is therefore unfiltered here, and the
// defense is `hierarchy::validate_new_parent`, which runs at submit.
// (Tracked as tix #1384: once an edit form exists, this arm must
// exclude the edited issue, and `set_parent` becomes the write.)
self.store
.list()
.unwrap_or_default()
.into_iter()
.map(|issue| PickerItem {
id: issue.number.to_string(),
label: format!("#{} {}", issue.number, issue.title),
})
.collect()
}
// Unreachable in practice: `open_form_picker` routes the Template row
// to `open_template_picker`, which owns the `(none)` option. Kept
// exhaustive and honest — the options *are* the configured templates.
FormPickerField::Template => self.template_picker_options(),
// The **service's** project list, in declaration order. The option id is
// the resolved project id (what the model stores and what the filter
// matches), and the label is the shared `name (id)` display form, so the
// picker and `tix project list` cannot spell a project two ways. Nothing
// here constructs or validates a project: a reference the registry does
// not hold never appears, and a stored reference that no longer resolves
// is kept visible by the current-value rule below
// (`seed_picker_selection` seeds it, and `DropdownState` lists a seeded
// value even when no option carries it).
FormPickerField::Project => {
let mut options: Vec<PickerItem> = self
.live_projects()
.into_iter()
.map(|project| PickerItem {
id: project.id.to_string(),
label: crate::projects::project_display(&project.id, &project.name),
})
.collect();
if let Some(form) = self.form.as_ref() {
for current in form.projects.split(',').map(str::trim) {
if !current.is_empty() && !options.iter().any(|o| o.id == current) {
options.push(PickerItem {
id: current.to_string(),
label: format!("{current} (missing project)"),
});
}
}
}
options
}
// The **service's** epic list, in declaration order — the exact analogue
// of the Project arm above. The option id is the resolved epic id (what
// the model stores and what the filter matches), and the label is the
// shared `name (id)` display form, so the picker and `tix epic list`
// cannot spell an epic two ways. Nothing here constructs or validates an
// epic: a reference the registry does not hold never appears, and a stored
// reference that no longer resolves is kept visible by the current-value
// rule below.
//
// No "exclude the issue itself" filter, and the reason is the Parent
// picker's: the form is **create-only** (`Mode::Form` always builds a
// fresh `FormState`), so there is no issue-under-edit to exclude, and an
// issue→epic reference cannot close a cycle in the epic **parent**
// hierarchy anyway — the two are different graphs (contracts/epic-
// service.md §3). A reference the service rejects (an unknown id, or a
// cycle a future edit form introduces) is refused at submit through the
// service's own diagnostic, which is the rule this row must not restate.
FormPickerField::Epic => {
let mut options: Vec<PickerItem> = self
.live_epics()
.into_iter()
.map(|epic| PickerItem {
id: epic.id.to_string(),
label: crate::epics::epic_display(&epic.id, &epic.name),
})
.collect();
if let Some(form) = self.form.as_ref() {
for current in form.epics.split(',').map(str::trim) {
if !current.is_empty() && !options.iter().any(|o| o.id == current) {
options.push(PickerItem {
id: current.to_string(),
label: format!("{current} (missing epic)"),
});
}
}
}
options
}
FormPickerField::Assignee | FormPickerField::Reviewer => {
let mut out = std::collections::BTreeSet::new();
for team in self.store.config.teams.values() {
for member in &team.members {
if !member.trim().is_empty() {
out.insert(member.trim().to_string());
}
}
}
if let Some(id) = git_identity() {
out.insert(id.to_string());
}
if let Some(form) = self.form.as_ref() {
let current = match field {
FormPickerField::Assignee => form.assignee.trim(),
FormPickerField::Reviewer => form.reviewer.trim(),
_ => "",
};
if !current.is_empty() {
out.insert(current.to_string());
}
}
out.into_iter()
.map(|member| PickerItem {
id: member.clone(),
label: member,
})
.collect()
}
}
}
pub(in crate::app) fn seed_picker_selection(
&self,
field: FormPickerField,
picker: &mut DropdownState,
) {
let Some(form) = self.form.as_ref() else {
return;
};
let values: Vec<String> = match field {
FormPickerField::Labels => form
.labels
.split(',')
.map(str::trim)
.filter(|s| !s.is_empty())
.map(str::to_string)
.collect(),
FormPickerField::Cycles => form
.cycles
.split(',')
.map(str::trim)
.filter(|s| !s.is_empty())
.map(str::to_string)
.collect(),
FormPickerField::Milestones => form
.milestones
.split(',')
.map(str::trim)
.filter(|s| !s.is_empty())
.map(str::to_string)
.collect(),
// WP06 T029 step 2: the pre-selected set is the issue's current
// associations, in the same comma-joined shape the submit path parses.
FormPickerField::Project => form
.projects
.split(',')
.map(str::trim)
.filter(|s| !s.is_empty())
.map(str::to_string)
.collect(),
// WP06 T031 step 2: the exact analogue for epic references — the
// pre-selected set is the issue's current references, so an edit cannot
// silently drop the ones the user did not touch.
FormPickerField::Epic => form
.epics
.split(',')
.map(str::trim)
.filter(|s| !s.is_empty())
.map(str::to_string)
.collect(),
FormPickerField::Assignee => form
.assignee
.trim()
.split(',')
.map(str::trim)
.filter(|s| !s.is_empty())
.map(str::to_string)
.take(1)
.collect(),
FormPickerField::Reviewer => form
.reviewer
.trim()
.split(',')
.map(str::trim)
.filter(|s| !s.is_empty())
.map(str::to_string)
.take(1)
.collect(),
// Status and Priority are single values, held whole (a status can
// contain spaces, so splitting on commas would be wrong), and an
// empty field simply starts the dropdown with nothing selected.
FormPickerField::Status => (!form.status.trim().is_empty())
.then(|| form.status.trim().to_string())
.into_iter()
.collect(),
FormPickerField::Priority => (!form.priority.trim().is_empty())
.then(|| form.priority.trim().to_string())
.into_iter()
.collect(),
// Already a resolved number, so no comma-splitting: there is exactly
// one parent, and splitting it would corrupt a value that is legal.
FormPickerField::Parent => (!form.parent.trim().is_empty())
.then(|| form.parent.trim().to_string())
.into_iter()
.collect(),
// Empty is `(none)`, which matches the option's empty id, so the
// picker opens on the current selection rather than at the top. A
// stable-ID selection is namespaced like its option; a legacy one
// likewise. See [`STABLE_TEMPLATE_PREFIX`].
FormPickerField::Template => {
match (form.template_scope.as_deref(), form.template.trim()) {
(Some(_), id) if !id.is_empty() => {
vec![format!("{STABLE_TEMPLATE_PREFIX}{id}")]
}
(None, name) if !name.is_empty() => {
vec![format!("{LEGACY_TEMPLATE_PREFIX}{name}")]
}
_ => Vec::new(),
}
}
};
match &mut picker.selection {
SelectionModel::Single(current) => {
*current = values.first().cloned();
}
SelectionModel::Multi(current) => {
current.clear();
current.extend(values);
}
}
}
pub(in crate::app) fn apply_picker_selection(&mut self, values: Vec<String>) {
let Some(field) = self.form_picker.as_ref().map(|p| p.field) else {
return;
};
// Templates are single-select *and* choosing one ends the interaction: the
// picker closes and the form is pre-filled. The multi-select fields below
// stay open on purpose, so several labels/cycles can be picked in one go.
if field == FormPickerField::Template {
let id = values.first().cloned().unwrap_or_default();
self.form_picker = None;
self.apply_template_choice(&id);
return;
}
let Some(form) = self.form.as_mut() else {
return;
};
match field {
FormPickerField::Labels => form.labels = values.join(","),
FormPickerField::Assignee => {
form.assignee = values.first().cloned().unwrap_or_default()
}
FormPickerField::Cycles => form.cycles = values.join(","),
FormPickerField::Milestones => form.milestones = values.join(","),
// WP06 T029: the multi-selection is the association set, written back in
// the same comma-joined shape every other list field uses. The picker is
// the only way this row changes, and the ids came from the service, so
// the form has constructed nothing.
FormPickerField::Project => form.projects = values.join(","),
// WP06 T031: the multi-selection is the reference set, written back in
// the same comma-joined shape every other list field uses. The picker is
// the only way this row changes, and the ids came from the service, so
// the form has constructed nothing.
FormPickerField::Epic => form.epics = values.join(","),
// Single-select: a Status/Priority dropdown writes the one chosen
// value, and no selection clears the row, which is the same "empty
// means unset" the CLI accepts.
FormPickerField::Status => form.status = values.first().cloned().unwrap_or_default(),
FormPickerField::Priority => {
form.priority = values.first().cloned().unwrap_or_default()
}
FormPickerField::Reviewer => {
form.reviewer = values.first().cloned().unwrap_or_default()
}
// Single-select: at most one value, and no selection clears the field,
// which is the same "empty means none" the CLI's `--parent ""` means.
FormPickerField::Parent => form.parent = values.first().cloned().unwrap_or_default(),
// Handled before the `form` borrow above: choosing a template closes
// the picker and re-fills the form through `apply_template_choice`.
FormPickerField::Template => {}
}
// A picker replaces the value wholesale, so the insertion point belongs
// after it rather than wherever it sat in the text it replaced.
form.cursor_to_end();
}
pub(in crate::app) fn apply_picker_created(&mut self, value: String) -> Result<()> {
let value = value.trim().to_string();
if value.is_empty() {
return Ok(());
}
let Some(field) = self.form_picker.as_ref().map(|p| p.field) else {
return Ok(());
};
match field {
FormPickerField::Cycles => {
let root = self.project_root();
let mut planner = Planner::from_config(self.store.config.clone(), root.clone());
match planner.add_cycle(Some(value.clone())) {
Ok(_) => {
self.reload_config_from(root.as_path())?;
}
Err(e) => {
self.status_msg = Some(e.to_string());
return Ok(());
}
}
}
FormPickerField::Milestones => {
let root = self.project_root();
let planner = Planner::from_config(self.store.config.clone(), root.clone());
match planner.create_milestone_file(&value, None, None) {
Ok(_) => {
self.reload_config_from(root.as_path())?;
}
Err(e) => {
self.status_msg = Some(e.to_string());
return Ok(());
}
}
}
FormPickerField::Assignee | FormPickerField::Reviewer => {
let root = self.project_root();
let mut planner = Planner::from_config(self.store.config.clone(), root.clone());
let team = self
.store
.config
.planning
.default_team
.clone()
.unwrap_or_else(|| "default".to_string());
match planner.add_team_member(&team, &value) {
Ok(()) => {
self.reload_config_from(root.as_path())?;
}
Err(e) => {
self.status_msg = Some(e.to_string());
return Ok(());
}
}
}
// `+` is inline-create: it makes a *new* cycle, milestone, or team
// member, and appends it to the list. A parent is not something you
// make from inside another issue's form — it is an issue that already
// exists — so the keystroke does nothing here, exactly as it does for
// Labels. Creating an empty issue to stand in for a parent would be
// worse than nothing: it would write a file the user never asked for.
// Templates are configuration, not form values: `+` cannot invent one
// any more than it can invent a parent. It is edited in `tix.toml`.
// A priority has no configuration record to write either — the custom
// value *is* the form value, and it is applied through the selection
// below like any picked option. Status never reaches here: its dropdown
// refuses `+`, because a column the board does not configure would
// render in the Mismatched column rather than becoming a choice.
FormPickerField::Labels
| FormPickerField::Parent
| FormPickerField::Template
| FormPickerField::Status
| FormPickerField::Priority
| FormPickerField::Project
| FormPickerField::Epic => {}
}
let next_options = self.picker_options(field);
if let Some(picker) = self.form_picker.as_mut() {
picker.state.options = next_options;
picker.state.filter.clear();
picker.state.cursor = 0;
picker.state.mode = PickerMode::Idle;
picker.state.create_buffer.clear();
match &mut picker.state.selection {
SelectionModel::Single(current) => *current = Some(value.clone()),
SelectionModel::Multi(current) => {
current.insert(value.clone());
}
}
let values = match &picker.state.selection {
SelectionModel::Single(current) => current.iter().cloned().collect(),
SelectionModel::Multi(current) => current.iter().cloned().collect(),
};
self.apply_picker_selection(values);
}
Ok(())
}
/// The picker options for the Template row: the stable-ID registry
/// (`[issue_templates.<id>]`) first, then the legacy `[templates.<name>]`
/// pre-fill names.
///
/// Each option's id is namespaced ([`STABLE_TEMPLATE_PREFIX`] /
/// [`LEGACY_TEMPLATE_PREFIX`]) so the two config key spaces stay distinct
/// inside one picker. A stable label shows the template's **display name and
/// explicit scope** — registry metadata presented for selection, never
/// interpreted (WP05/T023, T026). The stable ID is what a selection records,
/// never the display name (C-002).
pub(in crate::app) fn template_picker_options(&self) -> Vec<PickerItem> {
let mut options: Vec<PickerItem> = self
.store
.config
.issue_templates
.iter()
.map(|(id, template)| PickerItem {
id: format!("{STABLE_TEMPLATE_PREFIX}{id}"),
label: format!(
"{} — {} [{}]",
id,
template.display_name(id),
template.scope
),
})
.collect();
options.extend(self.store.config.templates.keys().map(|name| PickerItem {
id: format!("{LEGACY_TEMPLATE_PREFIX}{name}"),
label: name.clone(),
}));
options
}
}