pi-subagent-manager 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,8 +10,9 @@ import {
10
10
  Container,
11
11
  getKeybindings,
12
12
  Input,
13
+ Key,
14
+ matchesKey,
13
15
  SelectList,
14
- Spacer,
15
16
  stripTerminalSequences,
16
17
  truncateToWidth,
17
18
  Text,
@@ -26,24 +27,17 @@ const MODEL_EDITOR_LAYOUT = {
26
27
  } as const;
27
28
 
28
29
  const PICKER_TITLE = "Preferred models";
30
+ const SELECTED_GROUP = "Selected models · ordered fallback";
31
+ const ACTIONS_GROUP = "Actions";
29
32
 
30
33
  export const MODEL_EDITOR_CANCEL = Symbol("model-editor-cancel");
31
34
 
32
35
  type AvailableModel = Pick<Model<Api>, "provider" | "id" | "name">;
33
36
 
34
37
  interface ModelSelectItem extends SelectItem {
35
- group?: string;
38
+ group: string;
36
39
  }
37
40
 
38
- type ModelEditorMode =
39
- | { kind: "menu" }
40
- | { kind: "actions"; index: number }
41
- | {
42
- kind: "picker";
43
- replaceIndex: number | undefined;
44
- returnTo: "menu" | "actions";
45
- };
46
-
47
41
  interface OrderedModelEditorComponentOptions {
48
42
  tui: { requestRender(force?: boolean): void; terminal?: { rows: number } };
49
43
  theme: Theme;
@@ -81,10 +75,7 @@ function sortModels(models: readonly AvailableModel[]): AvailableModel[] {
81
75
  );
82
76
  }
83
77
 
84
- function describeModel(
85
- model: AvailableModel,
86
- scopedIdentities: ReadonlySet<string>,
87
- ): string {
78
+ function describeModel(model: AvailableModel, scopedIdentities: ReadonlySet<string>): string {
88
79
  const annotation = scopedIdentities.has(modelIdentity(model))
89
80
  ? "scoped in this session"
90
81
  : "portable preference · not scoped in this session";
@@ -105,25 +96,14 @@ export class OrderedModelEditorComponent extends Container {
105
96
  private readonly scopedIdentities: ReadonlySet<string>;
106
97
  private readonly onDone: (models: string[]) => void;
107
98
  private readonly onCancel: () => void;
108
- private readonly body = new Container();
109
99
  private readonly titleText = new Text();
110
100
  private readonly subtitleText = new Text();
111
101
  private readonly footerText = new Text();
102
+ private readonly searchInput = new Input({ placeholder: "Search models" });
112
103
  private draft: string[];
113
- private mode: ModelEditorMode;
114
104
  private pickerQuery = "";
115
- private pickerSelectedValue: string | undefined;
116
105
  private currentItems: ModelSelectItem[] = [];
117
- private selectList = new SelectList(
118
- [],
119
- 1,
120
- getSelectListTheme(),
121
- MODEL_EDITOR_LAYOUT,
122
- );
123
- private searchInput: Input | undefined;
124
- private pickerListChildIndex = -1;
125
- private menuSelectedValue: string | undefined;
126
- private actionSelectedValue: string | undefined;
106
+ private selectList = new SelectList([], 1, getSelectListTheme(), MODEL_EDITOR_LAYOUT);
127
107
  private _focused = false;
128
108
 
129
109
  constructor(options: OrderedModelEditorComponentOptions) {
@@ -142,18 +122,27 @@ export class OrderedModelEditorComponent extends Container {
142
122
  this.suggestedScores = this.searchScores(options.modelSuggestions ?? []);
143
123
  this.onDone = options.onDone;
144
124
  this.onCancel = options.onCancel;
145
- for (const model of this.allModels)
146
- this.modelsByIdentity.set(modelIdentity(model), model);
125
+ for (const model of this.allModels) this.modelsByIdentity.set(modelIdentity(model), model);
147
126
  this.scopedIdentities = new Set(
148
127
  options.scopedModels.map((entry) => modelIdentity(entry.model)),
149
128
  );
150
- this.draft = [...(options.initialModels ?? [])];
151
- this.mode =
152
- this.draft.length === 0
153
- ? { kind: "picker", replaceIndex: undefined, returnTo: "menu" }
154
- : { kind: "menu" };
155
-
156
- this.rebuild();
129
+ this.draft = [...new Set(options.initialModels ?? [])];
130
+ this.titleText.setText(this.theme.fg("accent", PICKER_TITLE));
131
+ this.subtitleText.setText(
132
+ this.theme.fg(
133
+ "muted",
134
+ this.withScopeWarning(
135
+ this.suggestedScores.size
136
+ ? "Selected first; suggested matches scoped first, then other models; the rest A–Z. Type to search."
137
+ : "Selected first. Search by provider/id or model name; other models A–Z.",
138
+ ),
139
+ ),
140
+ );
141
+ this.footerText.setText(
142
+ this.theme.fg("dim", "↑↓ select · Enter toggle · Ctrl+↑↓ reorder · Ctrl+S done · Esc cancel"),
143
+ );
144
+ this.addChild(this.searchInput);
145
+ this.refreshPickerList();
157
146
  }
158
147
 
159
148
  get focused(): boolean {
@@ -162,11 +151,11 @@ export class OrderedModelEditorComponent extends Container {
162
151
 
163
152
  set focused(value: boolean) {
164
153
  this._focused = value;
165
- if (this.searchInput) this.searchInput.focused = value;
154
+ this.searchInput.focused = value;
166
155
  }
167
156
 
168
- getMode(): ModelEditorMode["kind"] {
169
- return this.mode.kind;
157
+ getMode(): "picker" {
158
+ return "picker";
170
159
  }
171
160
 
172
161
  getDraftModels(): readonly string[] {
@@ -181,7 +170,7 @@ export class OrderedModelEditorComponent extends Container {
181
170
  return this.selectList;
182
171
  }
183
172
 
184
- getSearchInput(): Input | undefined {
173
+ getSearchInput(): Input {
185
174
  return this.searchInput;
186
175
  }
187
176
 
@@ -198,15 +187,19 @@ export class OrderedModelEditorComponent extends Container {
198
187
  inner,
199
188
  "",
200
189
  ),
190
+ ...this.searchInput.render(inner),
201
191
  ];
202
- if (this.searchInput) header.push(...this.searchInput.render(inner));
203
192
  const budget = Math.max(1, height - 4 - header.length);
204
193
  const selected = this.selectList.getSelectedItem()?.value;
205
194
  // Headings are visual rows only: keyboard navigation selects models, not groups.
206
195
  const displayRows: (ModelSelectItem | string)[] = [];
207
196
  let previousGroup: string | undefined;
197
+ const hasResults = this.currentItems.some(
198
+ (item) => item.group !== SELECTED_GROUP && item.group !== ACTIONS_GROUP,
199
+ );
208
200
  for (const item of this.currentItems) {
209
- if (item.group && item.group !== previousGroup) {
201
+ if (item.group !== previousGroup) {
202
+ if (item.group === ACTIONS_GROUP && !hasResults) displayRows.push("No matching models");
210
203
  displayRows.push(item.group);
211
204
  }
212
205
  previousGroup = item.group;
@@ -214,21 +207,15 @@ export class OrderedModelEditorComponent extends Container {
214
207
  }
215
208
  const index = Math.max(
216
209
  0,
217
- displayRows.findIndex(
218
- (row) => typeof row !== "string" && row.value === selected,
219
- ),
220
- );
221
- const start = Math.max(
222
- 0,
223
- Math.min(index - budget + 1, displayRows.length - budget),
210
+ displayRows.findIndex((row) => typeof row !== "string" && row.value === selected),
224
211
  );
212
+ const start = Math.max(0, Math.min(index - budget + 1, displayRows.length - budget));
225
213
  // Only format visible rows; a registry can contain thousands of models.
226
214
  const rows = displayRows.slice(start, start + budget).map((row) => {
227
215
  if (typeof row === "string") return this.theme.fg("muted", row);
228
216
  const text = `${row.value === selected ? "›" : " "} ${row.label} ${this.theme.fg("muted", row.description ?? "")}`;
229
217
  return row.value === selected ? this.theme.fg("accent", text) : text;
230
218
  });
231
- if (!rows.length) rows.push(this.theme.fg("muted", "No matching models"));
232
219
  return frameDialog(
233
220
  this.theme,
234
221
  width,
@@ -244,330 +231,116 @@ export class OrderedModelEditorComponent extends Container {
244
231
  }
245
232
 
246
233
  handleInput(keyData: string): void {
247
- if (this.mode.kind === "picker" && this.searchInput) {
248
- const kb = getKeybindings();
249
- const isNav =
250
- kb.matches(keyData, "tui.select.up") ||
251
- kb.matches(keyData, "tui.select.down") ||
252
- kb.matches(keyData, "tui.select.confirm") ||
253
- kb.matches(keyData, "tui.select.cancel");
254
- if (isNav) {
255
- this.selectList.handleInput(keyData);
256
- } else {
257
- this.searchInput.handleInput(keyData);
258
- const nextQuery = this.searchInput.getValue();
259
- if (nextQuery !== this.pickerQuery) {
260
- this.pickerQuery = nextQuery;
261
- this.pickerSelectedValue = undefined;
262
- this.refreshPickerList(this.mode.replaceIndex, this.mode.returnTo);
263
- this.tui.requestRender();
264
- return;
265
- }
234
+ if (matchesKey(keyData, Key.ctrl("s"))) {
235
+ this.onDone([...this.draft]);
236
+ return;
237
+ }
238
+ const earlier = matchesKey(keyData, Key.ctrl("up"));
239
+ const later = matchesKey(keyData, Key.ctrl("down"));
240
+ if (earlier || later) {
241
+ const selected = this.selectList.getSelectedItem()?.value;
242
+ const index = selected === undefined ? -1 : this.draft.indexOf(selected);
243
+ const next = index + (earlier ? -1 : 1);
244
+ // Consume reorder keys even on unselected models or at a list boundary.
245
+ if (index >= 0 && next >= 0 && next < this.draft.length) {
246
+ [this.draft[index], this.draft[next]] = [this.draft[next], this.draft[index]];
247
+ this.refreshPickerList(selected);
248
+ this.tui.requestRender();
266
249
  }
267
- this.tui.requestRender();
268
250
  return;
269
251
  }
270
- this.selectList.handleInput(keyData);
271
- this.tui.requestRender();
272
- }
273
-
274
- private rebuild(): void {
275
- this.body.clear();
276
- this.searchInput = undefined;
277
- this.pickerListChildIndex = -1;
278
- if (this.mode.kind === "menu") {
279
- this.buildMenu();
280
- } else if (this.mode.kind === "actions") {
281
- this.buildActions(this.mode.index);
252
+ const kb = getKeybindings();
253
+ const isNav =
254
+ kb.matches(keyData, "tui.select.up") ||
255
+ kb.matches(keyData, "tui.select.down") ||
256
+ kb.matches(keyData, "tui.select.confirm") ||
257
+ kb.matches(keyData, "tui.select.cancel");
258
+ if (isNav) {
259
+ this.selectList.handleInput(keyData);
282
260
  } else {
283
- this.buildPicker(this.mode.replaceIndex);
261
+ this.searchInput.handleInput(keyData);
262
+ const nextQuery = this.searchInput.getValue();
263
+ if (nextQuery !== this.pickerQuery) {
264
+ this.pickerQuery = nextQuery;
265
+ // Keep selected preferences visible, but focus the first search result
266
+ // so typing a query and pressing Enter still adds the matching model.
267
+ this.refreshPickerList(undefined, true);
268
+ }
284
269
  }
270
+ this.tui.requestRender();
285
271
  }
286
272
 
287
- private buildMenu(): void {
288
- this.titleText.setText(this.theme.fg("accent", PICKER_TITLE));
289
- this.subtitleText.setText(
290
- this.theme.fg(
291
- "muted",
292
- this.withScopeWarning(
293
- this.draft.length
294
- ? "Ordered fallback preferences. Select a numbered entry for actions."
295
- : "No explicit preferences. Add models or done to inherit the default.",
296
- ),
297
- ),
273
+ private refreshPickerList(selectedValue?: string, focusSearchResult = false): void {
274
+ const previousIndex = this.currentItems.findIndex(
275
+ (item) => item.value === this.selectList.getSelectedItem()?.value,
298
276
  );
299
- const items: SelectItem[] = [
277
+ this.currentItems = [
300
278
  ...this.draft.map((identity, index) => ({
301
- value: `entry:${index}`,
302
- label: `${index + 1}. ${renderModelIdentity(identity)}`,
279
+ value: identity,
280
+ label: `[x] ${index + 1}. ${renderModelIdentity(identity)}`,
303
281
  description: this.describeDraftIdentity(identity),
282
+ group: SELECTED_GROUP,
304
283
  })),
284
+ ...this.getPickerItems(),
305
285
  {
306
- value: "action:add",
307
- label: "Add model",
308
- description: "Append another preferred model to the ordered list",
286
+ value: "action:done",
287
+ label: "Done",
288
+ description: "Commit this ordered model preference list",
289
+ group: ACTIONS_GROUP,
309
290
  },
310
291
  {
311
292
  value: "action:clear",
312
293
  label: "Use inherited default",
313
294
  description: "Clear explicit preferences and inherit the default model",
314
- },
315
- {
316
- value: "action:done",
317
- label: "Done",
318
- description: "Commit this ordered model preference list",
295
+ group: ACTIONS_GROUP,
319
296
  },
320
297
  {
321
298
  value: "action:cancel",
322
299
  label: "Cancel",
323
300
  description: "Discard unsaved model preference changes",
301
+ group: ACTIONS_GROUP,
324
302
  },
325
303
  ];
326
- this.currentItems = items;
327
- this.selectList = this.buildSelectList(
328
- items,
329
- this.menuSelectedValue,
330
- (value) => {
331
- if (value.startsWith("entry:")) {
332
- const index = Number(value.slice("entry:".length));
333
- if (!Number.isNaN(index) && this.draft[index] !== undefined) {
334
- this.mode = { kind: "actions", index };
335
- this.actionSelectedValue = "action:replace";
336
- this.rebuildAndRender();
337
- }
338
- return;
339
- }
340
- if (value === "action:add") {
341
- this.openPicker(undefined, "menu");
342
- } else if (value === "action:clear") {
343
- this.draft = [];
344
- this.menuSelectedValue = "action:done";
345
- this.rebuildAndRender();
346
- } else if (value === "action:done") {
347
- this.onDone([...this.draft]);
348
- } else if (value === "action:cancel") {
349
- this.onCancel();
350
- }
351
- },
352
- () => this.onCancel(),
353
- );
354
- this.body.addChild(this.selectList);
355
- this.footerText.setText(
356
- this.theme.fg(
357
- "dim",
358
- "↑↓ select · Enter edit · Esc cancel · Done applies preferences",
359
- ),
360
- );
361
- }
362
-
363
- private buildActions(index: number): void {
364
- const identity = this.draft[index] ?? "";
365
- this.titleText.setText(this.theme.fg("accent", `Model ${index + 1}`));
366
- this.subtitleText.setText(
367
- this.theme.fg(
368
- "muted",
369
- `${index + 1}. ${renderModelIdentity(identity)} · ${this.describeDraftIdentity(identity)}`,
370
- ),
371
- );
372
- const items: SelectItem[] = [
373
- {
374
- value: "action:replace",
375
- label: "Replace",
376
- description: "Choose a different available model for this position",
377
- },
378
- {
379
- value: "action:remove",
380
- label: "Remove",
381
- description: "Delete this preference from the ordered list",
382
- },
383
- ...(index > 0
384
- ? [
385
- {
386
- value: "action:earlier",
387
- label: "Move earlier",
388
- description: "Swap with the previous preference",
389
- },
390
- ]
391
- : []),
392
- ...(index < this.draft.length - 1
393
- ? [
394
- {
395
- value: "action:later",
396
- label: "Move later",
397
- description: "Swap with the next preference",
398
- },
399
- ]
400
- : []),
401
- {
402
- value: "action:back",
403
- label: "Back",
404
- description: "Return to the ordered preference list",
405
- },
406
- ];
407
- this.currentItems = items;
408
- this.selectList = this.buildSelectList(
409
- items,
410
- this.actionSelectedValue,
411
- (value) => {
412
- if (value === "action:replace") {
413
- this.openPicker(index, "actions");
414
- } else if (value === "action:remove") {
415
- this.draft.splice(index, 1);
416
- this.mode = { kind: "menu" };
417
- this.menuSelectedValue = this.draft[index]
418
- ? `entry:${index}`
419
- : "action:add";
420
- this.rebuildAndRender();
421
- } else if (value === "action:earlier" && index > 0) {
422
- [this.draft[index - 1], this.draft[index]] = [
423
- this.draft[index],
424
- this.draft[index - 1],
425
- ];
426
- this.mode = { kind: "menu" };
427
- this.menuSelectedValue = `entry:${index - 1}`;
428
- this.rebuildAndRender();
429
- } else if (value === "action:later" && index < this.draft.length - 1) {
430
- [this.draft[index], this.draft[index + 1]] = [
431
- this.draft[index + 1],
432
- this.draft[index],
433
- ];
434
- this.mode = { kind: "menu" };
435
- this.menuSelectedValue = `entry:${index + 1}`;
436
- this.rebuildAndRender();
437
- } else if (value === "action:back") {
438
- this.mode = { kind: "menu" };
439
- this.menuSelectedValue = `entry:${index}`;
440
- this.rebuildAndRender();
441
- }
442
- },
443
- () => {
444
- this.mode = { kind: "menu" };
445
- this.menuSelectedValue = `entry:${index}`;
446
- this.rebuildAndRender();
447
- },
448
- );
449
- this.body.addChild(this.selectList);
450
- this.footerText.setText(
451
- this.theme.fg("dim", "↑↓ select · Enter choose · Esc back"),
452
- );
453
- }
454
-
455
- private buildPicker(replaceIndex: number | undefined): void {
456
- const isReplace = replaceIndex !== undefined;
457
- this.titleText.setText(
458
- this.theme.fg(
459
- "accent",
460
- isReplace ? `Replace model ${replaceIndex + 1}` : "Add model",
461
- ),
462
- );
463
- this.subtitleText.setText(
464
- this.theme.fg(
465
- "muted",
466
- this.withScopeWarning(
467
- this.suggestedScores.size
468
- ? "Suggested matches: scoped first, then other models; the rest A–Z. Type to search."
469
- : "Search by provider/id or model name. Models A–Z; selected duplicates are hidden.",
470
- ),
471
- ),
472
- );
473
- this.searchInput = new Input({ placeholder: "Search models" });
474
- this.searchInput.setValue(this.pickerQuery);
475
- this.searchInput.focused = this._focused;
476
- this.searchInput.onSubmit = () => {
477
- this.selectList.handleInput("\r");
478
- this.tui.requestRender();
479
- };
480
- this.body.addChild(this.searchInput);
481
- this.body.addChild(new Spacer(1));
482
- const returnTo = this.mode.kind === "picker" ? this.mode.returnTo : "menu";
483
- this.pickerListChildIndex = this.body.children.length;
484
- this.refreshPickerList(replaceIndex, returnTo);
485
- this.footerText.setText(
486
- this.theme.fg("dim", "Type filter · ↑↓ select · Enter choose · Esc back"),
487
- );
488
- }
489
-
490
- private rebuildAndRender(): void {
491
- this.rebuild();
492
- this.tui.requestRender();
493
- }
494
-
495
- private openPicker(
496
- replaceIndex: number | undefined,
497
- returnTo: "menu" | "actions",
498
- ): void {
499
- this.mode = { kind: "picker", replaceIndex, returnTo };
500
- this.pickerQuery = "";
501
- this.pickerSelectedValue = undefined;
502
- this.rebuildAndRender();
503
- }
504
-
505
- private refreshPickerList(
506
- replaceIndex: number | undefined,
507
- returnTo: "menu" | "actions",
508
- ): void {
509
- const items = this.getPickerItems(replaceIndex);
510
- this.currentItems = items;
511
- const list = this.buildSelectList(
512
- items,
513
- this.pickerSelectedValue,
514
- (value) => {
515
- if (replaceIndex === undefined) this.draft.push(value);
516
- else this.draft[replaceIndex] = value;
517
- this.mode = { kind: "menu" };
518
- this.menuSelectedValue = `entry:${replaceIndex === undefined ? this.draft.length - 1 : replaceIndex}`;
519
- this.pickerQuery = "";
520
- this.pickerSelectedValue = undefined;
521
- this.rebuildAndRender();
522
- },
523
- () => {
524
- this.mode =
525
- returnTo === "actions" && replaceIndex !== undefined
526
- ? { kind: "actions", index: replaceIndex }
527
- : { kind: "menu" };
528
- this.pickerQuery = "";
529
- this.pickerSelectedValue = undefined;
530
- this.rebuildAndRender();
531
- },
532
- );
533
- this.selectList = list;
534
- if (this.body.children[this.pickerListChildIndex])
535
- this.body.children[this.pickerListChildIndex] = list;
536
- else this.body.addChild(list);
537
- }
538
-
539
- private buildSelectList(
540
- items: SelectItem[],
541
- selectedValue: string | undefined,
542
- onSelect: (value: string) => void,
543
- onCancel: () => void,
544
- ): SelectList {
545
304
  const list = new SelectList(
546
- items,
547
- Math.min(Math.max(items.length, 1), 10),
305
+ this.currentItems,
306
+ Math.min(this.currentItems.length, 10),
548
307
  getSelectListTheme(),
549
308
  MODEL_EDITOR_LAYOUT,
550
309
  );
551
- const selectedIndex = selectedValue
552
- ? items.findIndex((item) => item.value === selectedValue)
553
- : 0;
554
- if (selectedIndex >= 0) list.setSelectedIndex(selectedIndex);
310
+ const preferredIndex = focusSearchResult
311
+ ? this.currentItems.findIndex(
312
+ (item) => item.group !== SELECTED_GROUP && item.group !== ACTIONS_GROUP,
313
+ )
314
+ : this.currentItems.findIndex((item) => item.value === selectedValue);
315
+ list.setSelectedIndex(
316
+ preferredIndex >= 0
317
+ ? preferredIndex
318
+ : focusSearchResult
319
+ ? 0
320
+ : Math.max(0, Math.min(previousIndex, this.currentItems.length - 1)),
321
+ );
555
322
  list.onSelect = (item) => {
556
- if (this.mode.kind === "menu") this.menuSelectedValue = item.value;
557
- else if (this.mode.kind === "actions")
558
- this.actionSelectedValue = item.value;
559
- else this.pickerSelectedValue = item.value;
560
- onSelect(item.value);
561
- };
562
- list.onSelectionChange = (item) => {
563
- if (this.mode.kind === "menu") this.menuSelectedValue = item.value;
564
- else if (this.mode.kind === "actions")
565
- this.actionSelectedValue = item.value;
566
- else this.pickerSelectedValue = item.value;
323
+ if (this.currentItems.find((row) => row.value === item.value)?.group === ACTIONS_GROUP) {
324
+ if (item.value === "action:done") this.onDone([...this.draft]);
325
+ else if (item.value === "action:cancel") this.onCancel();
326
+ else {
327
+ this.draft = [];
328
+ this.refreshPickerList("action:done");
329
+ this.tui.requestRender();
330
+ }
331
+ return;
332
+ }
333
+ const index = this.draft.indexOf(item.value);
334
+ if (index >= 0) this.draft.splice(index, 1);
335
+ else this.draft.push(item.value);
336
+ this.refreshPickerList(item.value);
567
337
  this.tui.requestRender();
568
338
  };
569
- list.onCancel = onCancel;
570
- return list;
339
+ list.onSelectionChange = () => this.tui.requestRender();
340
+ list.onCancel = () => this.onCancel();
341
+ this.selectList = list;
342
+ if (this.children[1]) this.children[1] = list;
343
+ else this.addChild(list);
571
344
  }
572
345
 
573
346
  private searchScores(queries: readonly string[]): Map<string, number> {
@@ -589,10 +362,8 @@ export class OrderedModelEditorComponent extends Container {
589
362
  return scores;
590
363
  }
591
364
 
592
- private getPickerItems(replaceIndex: number | undefined): ModelSelectItem[] {
593
- const excluded = new Set(
594
- this.draft.filter((_, index) => index !== replaceIndex),
595
- );
365
+ private getPickerItems(): ModelSelectItem[] {
366
+ const excluded = new Set(this.draft);
596
367
  const query = this.pickerQuery.trim();
597
368
  const queryScores = query ? this.searchScores([query]) : undefined;
598
369
  const scoped: AvailableModel[] = [];
@@ -600,8 +371,7 @@ export class OrderedModelEditorComponent extends Container {
600
371
  const remaining: AvailableModel[] = [];
601
372
  for (const model of this.allModels) {
602
373
  const identity = modelIdentity(model);
603
- if (excluded.has(identity) || (queryScores && !queryScores.has(identity)))
604
- continue;
374
+ if (excluded.has(identity) || (queryScores && !queryScores.has(identity))) continue;
605
375
  if (this.suggestedScores.has(identity)) {
606
376
  (this.scopedIdentities.has(identity) ? scoped : other).push(model);
607
377
  } else {
@@ -609,19 +379,15 @@ export class OrderedModelEditorComponent extends Container {
609
379
  }
610
380
  }
611
381
  const bySuggestionScore = (a: AvailableModel, b: AvailableModel) =>
612
- this.suggestedScores.get(modelIdentity(b))! -
613
- this.suggestedScores.get(modelIdentity(a))!;
382
+ this.suggestedScores.get(modelIdentity(b))! - this.suggestedScores.get(modelIdentity(a))!;
614
383
  // Stable score sorting preserves alphabetical order for ties. The last
615
384
  // tier retains the registry's alphabetical order, irrespective of scope.
616
385
  scoped.sort(bySuggestionScore);
617
386
  other.sort(bySuggestionScore);
618
- const items = (
619
- models: AvailableModel[],
620
- group: string,
621
- ): ModelSelectItem[] =>
387
+ const items = (models: AvailableModel[], group: string): ModelSelectItem[] =>
622
388
  models.map((model) => ({
623
389
  value: modelIdentity(model),
624
- label: renderModelIdentity(modelIdentity(model)),
390
+ label: `[ ] ${renderModelIdentity(modelIdentity(model))}`,
625
391
  description: describeModel(model, this.scopedIdentities),
626
392
  group,
627
393
  }));
@@ -630,9 +396,7 @@ export class OrderedModelEditorComponent extends Container {
630
396
  ...items(other, "Suggested matches · other models"),
631
397
  ...items(
632
398
  remaining,
633
- scoped.length || other.length
634
- ? "All other models · A–Z"
635
- : "All models · A–Z",
399
+ scoped.length || other.length ? "All other models · A–Z" : "All models · A–Z",
636
400
  ),
637
401
  ];
638
402
  }