pi-subagent-manager 0.21.1 → 0.23.0

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.
@@ -3,6 +3,7 @@ import {
3
3
  closeSync,
4
4
  constants,
5
5
  fchmodSync,
6
+ linkSync,
6
7
  lstatSync,
7
8
  mkdirSync,
8
9
  openSync,
@@ -28,7 +29,7 @@ export type CostValue = (typeof COST_VALUES)[number];
28
29
  export const COST_ICONS = ["money", "coins", "wallet"] as const;
29
30
  export type CostIcon = (typeof COST_ICONS)[number];
30
31
 
31
- export const LOADER_STYLES = ["circle", "braille", "hourglass"] as const;
32
+ export const LOADER_STYLES = ["circle", "braille", "hourglass", "ascii", "ascii-star", "ascii-pulse"] as const;
32
33
  export type LoaderStyle = (typeof LOADER_STYLES)[number];
33
34
 
34
35
  export const TOOL_FILTERING_MODES = ["allowed", "all-except-blocked", "all"] as const;
@@ -51,6 +52,7 @@ export interface ManagerSettings {
51
52
  nerdFontIcons: boolean;
52
53
  loaderStyle: LoaderStyle;
53
54
  finalRecap: boolean;
55
+ subagentExtensions: boolean;
54
56
  maxLevels: number;
55
57
  maxConcurrent: number;
56
58
  maxThreads: number;
@@ -71,10 +73,11 @@ export const DEFAULT_MANAGER_SETTINGS: ManagerSettings = {
71
73
  nerdFontIcons: false,
72
74
  loaderStyle: "circle",
73
75
  finalRecap: false,
76
+ subagentExtensions: false,
74
77
  };
75
78
 
76
79
  const KEYS = [
77
- "maxLevels", "maxConcurrent", "maxThreads", "modelSelection", "subagentMode", "toolFiltering", "widgetMode", "costDisplay", "costValue", "costIcon", "nerdFontIcons", "loaderStyle", "finalRecap",
80
+ "maxLevels", "maxConcurrent", "maxThreads", "modelSelection", "subagentMode", "toolFiltering", "widgetMode", "costDisplay", "costValue", "costIcon", "nerdFontIcons", "loaderStyle", "finalRecap", "subagentExtensions",
78
81
  ] as const;
79
82
  const MAX_LEVELS = 32;
80
83
 
@@ -112,13 +115,13 @@ function positiveSafeInteger(value: unknown): value is number {
112
115
  }
113
116
 
114
117
  function requirement(key: (typeof KEYS)[number]): string {
115
- if (key === "nerdFontIcons" || key === "finalRecap") return `${key} must be a boolean`;
118
+ if (key === "nerdFontIcons" || key === "finalRecap" || key === "subagentExtensions") return `${key} must be a boolean`;
116
119
  if (key === "subagentMode") return "subagentMode must be off, opportunistic or orchestration";
117
120
  if (key === "widgetMode") return "widgetMode must be full or minimal";
118
121
  if (key === "costDisplay") return "costDisplay must be pi-footer-event, pi-footer-status or pi-status";
119
122
  if (key === "costValue") return "costValue must be subagents or total";
120
123
  if (key === "costIcon") return "costIcon must be money, coins or wallet";
121
- if (key === "loaderStyle") return "loaderStyle must be circle, braille or hourglass";
124
+ if (key === "loaderStyle") return `loaderStyle must be one of: ${LOADER_STYLES.join(", ")}`;
122
125
  if (key === "toolFiltering") return "toolFiltering must be allowed, all-except-blocked or all";
123
126
  if (key === "modelSelection")
124
127
  return "modelSelection must be pick-first-available, pick-first-scoped or use-current";
@@ -151,7 +154,7 @@ function parseSettings(content: string): Partial<ManagerSettings> {
151
154
  for (const key of KEYS) {
152
155
  if (!Object.hasOwn(record, key)) continue;
153
156
  const value = record[key];
154
- if (key === "nerdFontIcons" || key === "finalRecap") {
157
+ if (key === "nerdFontIcons" || key === "finalRecap" || key === "subagentExtensions") {
155
158
  if (typeof value !== "boolean") throw new Error(requirement(key));
156
159
  layer[key] = value;
157
160
  continue;
@@ -220,82 +223,74 @@ function layer(base: string, segments: string[]): SettingsLayer {
220
223
  return { filePath: join(current, "settings.json"), directories };
221
224
  }
222
225
 
223
- function readLayerContent(entry: SettingsLayer): string | undefined {
226
+ function settingsFileExists(entry: SettingsLayer): boolean {
224
227
  for (const directory of entry.directories) {
225
228
  const stat = assertNotSymlinkPath(directory);
226
- if (!stat) return undefined;
229
+ if (!stat) return false;
227
230
  if (!stat.isDirectory())
228
231
  throw new Error(`Settings directory must be a directory: ${directory}`);
229
232
  }
230
233
  const stat = assertNotSymlinkPath(entry.filePath);
231
- if (!stat) return undefined;
234
+ if (!stat) return false;
232
235
  if (!stat.isFile())
233
236
  throw new Error(`Settings must be a regular file: ${entry.filePath}`);
234
- return readFileSync(entry.filePath, "utf8");
235
- }
236
-
237
- function readLayer(entry: SettingsLayer): Partial<ManagerSettings> | undefined {
238
- const content = readLayerContent(entry);
239
- return content === undefined ? undefined : parseSettings(content);
237
+ return true;
240
238
  }
241
239
 
242
240
  export type ManagerSaveScope = "user" | "project";
243
241
 
244
- function uiStateLayer(agentDir: string): SettingsLayer {
245
- const entry = layer(agentDir, ["subagent-manager"]);
246
- return { ...entry, filePath: join(dirname(entry.filePath), "ui-state.json") };
242
+ function detail(error: unknown): string {
243
+ return error instanceof Error ? error.message : String(error);
247
244
  }
248
245
 
249
- /** UI preference only: never participates in manager-settings precedence. */
250
- export function loadManagerSaveScope(options: {
246
+ export interface ManagerSettingsOptions {
247
+ cwd: string;
251
248
  agentDir: string;
252
249
  includeProject: boolean;
253
- }): ManagerSaveScope {
254
- if (!options.includeProject) return "user";
255
- try {
256
- const content = readLayerContent(uiStateLayer(options.agentDir));
257
- if (content !== undefined) {
258
- const state: unknown = JSON.parse(content);
259
- if (
260
- state && typeof state === "object" && !Array.isArray(state) &&
261
- "saveScope" in state && state.saveScope === "user"
262
- ) return "user";
263
- }
264
- } catch {
265
- // Missing, invalid or unsafe UI state must not prevent opening settings.
266
- }
267
- return "project";
268
- }
269
-
270
- export function saveManagerSaveScope(agentDir: string, scope: ManagerSaveScope): void {
271
- if (scope !== "user" && scope !== "project") throw new Error("Invalid settings scope");
272
- const entry = uiStateLayer(agentDir);
273
- ensureScopeDirectories(entry.directories);
274
- writeAtomically(entry, `${JSON.stringify({ saveScope: scope }, null, 2)}\n`);
275
250
  }
276
251
 
277
- function detail(error: unknown): string {
278
- return error instanceof Error ? error.message : String(error);
252
+ export interface ManagerSettingsLayers {
253
+ settings: ManagerSettings;
254
+ diagnostics: string[];
255
+ global: Partial<ManagerSettings>;
256
+ project: Partial<ManagerSettings>;
257
+ scope: ManagerSaveScope;
279
258
  }
280
259
 
281
- export function loadManagerSettings(options: {
282
- cwd: string;
283
- agentDir: string;
284
- includeProject: boolean;
285
- }): { settings: ManagerSettings; diagnostics: string[] } {
286
- const diagnostics: string[] = [];
287
- const settings: ManagerSettings = { ...DEFAULT_MANAGER_SETTINGS };
288
- const layers = [layer(options.agentDir, ["subagent-manager"])];
260
+ /** Validated layers retain provenance; save scope belongs to the current project. */
261
+ export function loadManagerSettingsLayers(options: ManagerSettingsOptions): ManagerSettingsLayers {
262
+ const result: ManagerSettingsLayers = {
263
+ settings: { ...DEFAULT_MANAGER_SETTINGS },
264
+ diagnostics: [],
265
+ global: {},
266
+ project: {},
267
+ scope: "user",
268
+ };
269
+ const layers: ["global" | "project", SettingsLayer][] = [
270
+ ["global", layer(options.agentDir, ["subagent-manager"])],
271
+ ];
289
272
  if (options.includeProject)
290
- layers.push(layer(options.cwd, [".pi", "agent", "subagent-manager"]));
291
- for (const entry of layers) {
273
+ layers.push(["project", layer(options.cwd, [".pi", "agent", "subagent-manager"])]);
274
+ for (const [scope, entry] of layers) {
292
275
  try {
293
- const parsed = readLayer(entry);
294
- if (parsed !== undefined) Object.assign(settings, parsed);
276
+ if (!settingsFileExists(entry)) continue;
277
+ // Malformed/unreadable regular project files still represent a save destination.
278
+ if (scope === "project") result.scope = "project";
279
+ const parsed = parseSettings(readFileSync(entry.filePath, "utf8"));
280
+ result[scope] = parsed;
281
+ Object.assign(result.settings, parsed);
295
282
  } catch (error) {
296
- diagnostics.push(`${entry.filePath}: ${detail(error)}`);
283
+ result.diagnostics.push(`${entry.filePath}: ${detail(error)}`);
297
284
  }
298
285
  }
286
+ return result;
287
+ }
288
+
289
+ export function loadManagerSettings(options: ManagerSettingsOptions): {
290
+ settings: ManagerSettings;
291
+ diagnostics: string[];
292
+ } {
293
+ const { settings, diagnostics } = loadManagerSettingsLayers(options);
299
294
  return { settings, diagnostics };
300
295
  }
301
296
 
@@ -358,7 +353,7 @@ function exclusiveCreateFlags(): number {
358
353
  return constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | (constants.O_NOFOLLOW || 0);
359
354
  }
360
355
 
361
- function writeAtomically(entry: SettingsLayer, content: string): void {
356
+ function writeAtomically(entry: SettingsLayer, content: string, overwrite = true): void {
362
357
  const filePath = entry.filePath;
363
358
  const temporary = join(dirname(filePath), `.settings.${randomUUID()}.tmp`);
364
359
  let created = false;
@@ -378,7 +373,17 @@ function writeAtomically(entry: SettingsLayer, content: string): void {
378
373
  const tempStat = assertNotSymlinkPath(temporary);
379
374
  if (!tempStat?.isFile())
380
375
  throw new Error(`Settings must be a regular file: ${temporary}`);
381
- renameSync(temporary, filePath);
376
+ if (overwrite) renameSync(temporary, filePath);
377
+ else {
378
+ try {
379
+ // Linking a completed temporary file creates the destination without clobbering
380
+ // a settings file that appeared after the initial absence check.
381
+ linkSync(temporary, filePath);
382
+ } catch (error) {
383
+ if (errorCode(error) !== "EEXIST") throw error;
384
+ assertRegularFileOrAbsent(filePath);
385
+ }
386
+ }
382
387
  } finally {
383
388
  if (created) {
384
389
  try {
@@ -412,3 +417,72 @@ export function saveManagerSettings(options: {
412
417
  writeAtomically(entry, content);
413
418
  return entry.filePath;
414
419
  }
420
+
421
+ function assertExpectedLayers(current: ManagerSettingsLayers, expected: ManagerSettingsLayers): void {
422
+ if (
423
+ current.scope !== expected.scope ||
424
+ KEYS.some((key) => current.global[key] !== expected.global[key] ||
425
+ current.project[key] !== expected.project[key]) ||
426
+ current.diagnostics.length !== expected.diagnostics.length ||
427
+ current.diagnostics.some((diagnostic, index) => diagnostic !== expected.diagnostics[index])
428
+ ) {
429
+ throw new Error("Settings changed on disk. Reopen settings before saving or switching scope to avoid stale inherited values.");
430
+ }
431
+ }
432
+
433
+ /** Persist only values that change the selected scope's inherited settings. */
434
+ export function saveManagerOverrides(options: ManagerSettingsOptions & {
435
+ scope: ManagerSaveScope;
436
+ settings: ManagerSettings;
437
+ expectedLayers?: ManagerSettingsLayers;
438
+ }): string {
439
+ if (options.scope !== "user" && options.scope !== "project")
440
+ throw new Error("Invalid settings scope");
441
+ if (options.scope === "project" && !options.includeProject)
442
+ throw new Error("Project settings are not enabled/trusted");
443
+ // Validate the complete draft before creating directories or modifying files.
444
+ const parsed = parseSettings(serializedSettings(options.settings));
445
+ const current = loadManagerSettingsLayers(options);
446
+ if (options.expectedLayers) assertExpectedLayers(current, options.expectedLayers);
447
+ if (options.scope === "project") {
448
+ const globalPath = layer(options.agentDir, ["subagent-manager"]).filePath;
449
+ const globalDiagnostics = current.diagnostics.filter((diagnostic) => diagnostic.startsWith(`${globalPath}:`));
450
+ if (globalDiagnostics.length > 0)
451
+ throw new Error(`Cannot save project overrides while global settings are invalid. Fix global settings and reopen settings. ${globalDiagnostics.join("; ")}`);
452
+ }
453
+ const inherited = options.scope === "user"
454
+ ? DEFAULT_MANAGER_SETTINGS
455
+ : { ...DEFAULT_MANAGER_SETTINGS, ...current.global };
456
+ const overrides = Object.fromEntries(
457
+ KEYS.filter((key) => parsed[key] !== inherited[key]).map((key) => [key, parsed[key]]),
458
+ );
459
+ const entry = options.scope === "user"
460
+ ? layer(options.agentDir, ["subagent-manager"])
461
+ : layer(options.cwd, [".pi", "agent", "subagent-manager"]);
462
+ ensureScopeDirectories(entry.directories);
463
+ writeAtomically(entry, `${JSON.stringify(overrides, null, 2)}\n`);
464
+ return entry.filePath;
465
+ }
466
+
467
+ /** Confirmed scope transition: create an empty project layer or remove only its file. */
468
+ export function setManagerProjectSettings(options: ManagerSettingsOptions & {
469
+ enabled: boolean;
470
+ expectedLayers?: ManagerSettingsLayers;
471
+ }): string {
472
+ if (!options.includeProject) throw new Error("Project settings are not enabled/trusted");
473
+ if (typeof options.enabled !== "boolean") throw new Error("Invalid project settings state");
474
+ if (options.expectedLayers)
475
+ assertExpectedLayers(loadManagerSettingsLayers(options), options.expectedLayers);
476
+ const entry = layer(options.cwd, [".pi", "agent", "subagent-manager"]);
477
+ const present = settingsFileExists(entry);
478
+ if (options.enabled) {
479
+ if (!present) {
480
+ ensureScopeDirectories(entry.directories);
481
+ writeAtomically(entry, "{}\n", false);
482
+ }
483
+ } else if (present) {
484
+ // Recheck owned paths immediately before deletion; malformed JSON is removable.
485
+ if (settingsFileExists(entry)) unlinkSync(entry.filePath);
486
+ }
487
+ return entry.filePath;
488
+ }
package/src/types.ts CHANGED
@@ -128,7 +128,7 @@ export interface AgentDriver {
128
128
  observeTranscript?(listener: TranscriptListener): TranscriptObservation;
129
129
  output(): string;
130
130
  abort(): Promise<void>;
131
- dispose(): void;
131
+ dispose(): void | Promise<void>;
132
132
  sendUpdate(content: string): Promise<void> | void;
133
133
  sessionFile?: string;
134
134
  sessionLeafId?: string | null;
@@ -1,4 +1,4 @@
1
- import type { LoaderStyle } from "../prefs/settings.ts";
1
+ import { LOADER_STYLES, type LoaderStyle } from "../prefs/settings.ts";
2
2
  import type { ThreadView } from "../types.ts";
3
3
 
4
4
  export const AGENT_PROGRESS_INTERVAL = 180;
@@ -10,12 +10,14 @@ export const AGENT_LOADERS: Record<
10
10
  LoaderStyle,
11
11
  {
12
12
  label: string;
13
+ requiresNerdFont: boolean;
13
14
  frames: readonly string[];
14
15
  states: Record<SettledState, string>;
15
16
  }
16
17
  > = {
17
18
  circle: {
18
19
  label: "Circle",
20
+ requiresNerdFont: true,
19
21
  // Nerd Fonts md-circle-slice-1..8, check-circle, pause-circle, close-circle, stop-circle.
20
22
  frames: Array.from({ length: 8 }, (_, index) => String.fromCodePoint(0xf0a9e + index)),
21
23
  states: {
@@ -27,17 +29,49 @@ export const AGENT_LOADERS: Record<
27
29
  },
28
30
  braille: {
29
31
  label: "Braille",
32
+ requiresNerdFont: false,
30
33
  frames: Array.from("⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏"),
31
34
  states: { completed: "✓", paused: "Ⅱ", failed: "×", stopped: "■" },
32
35
  },
33
36
  hourglass: {
34
37
  label: "Hourglass",
38
+ requiresNerdFont: true,
35
39
  // Nerd Fonts fa-hourglass-start/half/end, check-square, pause, times-circle, stop.
36
40
  frames: ["\uf251", "\uf252", "\uf253"],
37
41
  states: { completed: "\uf14a", paused: "\uf04c", failed: "\uf057", stopped: "\uf04d" },
38
42
  },
43
+ // Compact ASCII palettes inspired by cli-spinners line, star2 and toggle13.
44
+ // https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json
45
+ ascii: {
46
+ label: "ASCII",
47
+ requiresNerdFont: false,
48
+ frames: ["|", "/", "-", "\\"],
49
+ states: { completed: "+", paused: "=", failed: "!", stopped: "#" },
50
+ },
51
+ "ascii-star": {
52
+ label: "ASCII Star",
53
+ requiresNerdFont: false,
54
+ frames: ["+", "x", "*"],
55
+ states: { completed: "+", paused: "=", failed: "!", stopped: "#" },
56
+ },
57
+ "ascii-pulse": {
58
+ label: "ASCII Pulse",
59
+ requiresNerdFont: false,
60
+ frames: ["=", "*", "-"],
61
+ states: { completed: "+", paused: "=", failed: "!", stopped: "#" },
62
+ },
39
63
  };
40
64
 
65
+ /** Filter the picker without exposing private-use glyphs to ordinary fonts. */
66
+ export function availableLoaderStyles(nerdFontIcons: boolean): LoaderStyle[] {
67
+ return LOADER_STYLES.filter((style) => nerdFontIcons || !AGENT_LOADERS[style].requiresNerdFont);
68
+ }
69
+
70
+ /** Preserve saved preferences, but render a portable fallback when Nerd Fonts are off. */
71
+ export function effectiveLoaderStyle(style: LoaderStyle, nerdFontIcons: boolean): LoaderStyle {
72
+ return !nerdFontIcons && AGENT_LOADERS[style].requiresNerdFont ? "ascii" : style;
73
+ }
74
+
41
75
  /** RPC/non-animated hosts use the first running frame and all settled indicators. */
42
76
  export function agentProgressIcon(
43
77
  thread: Pick<ThreadView, "state">,
@@ -46,8 +80,7 @@ export function agentProgressIcon(
46
80
  animate = true,
47
81
  loaderStyle: LoaderStyle = "circle",
48
82
  ): string | undefined {
49
- if (!nerdFontIcons) return undefined;
50
- const loader = AGENT_LOADERS[loaderStyle];
83
+ const loader = AGENT_LOADERS[effectiveLoaderStyle(loaderStyle, nerdFontIcons)];
51
84
  if (thread.state === "starting" || thread.state === "running") {
52
85
  const index = animate ? Math.floor(Math.max(0, now) / AGENT_PROGRESS_INTERVAL) : 0;
53
86
  return loader.frames[index % loader.frames.length];
@@ -56,8 +89,10 @@ export function agentProgressIcon(
56
89
  }
57
90
 
58
91
  /** Restrict the separate label prefix to trusted, single built-in loader glyphs. */
59
- export function isAgentLoaderGlyph(glyph: string): boolean {
92
+ export function isAgentLoaderGlyph(glyph: string, nerdFontIcons = true): boolean {
60
93
  return Object.values(AGENT_LOADERS).some(
61
- (loader) => loader.frames.includes(glyph) || Object.values(loader.states).includes(glyph),
94
+ (loader) =>
95
+ (nerdFontIcons || !loader.requiresNerdFont) &&
96
+ (loader.frames.includes(glyph) || Object.values(loader.states).includes(glyph)),
62
97
  );
63
98
  }
@@ -30,13 +30,13 @@ export function footerUsage(entries: readonly SessionEntry[]) {
30
30
  }
31
31
  export const COST_WIDGET_ID = "subagent_cost";
32
32
  export const COST_WIDGET_EVENT = "pi-footer:update-widget";
33
- export const COST_ICON = "\uf0d6";
33
+ export const COST_ICON = "\uf0d6"; // nf-fa-money_bill
34
34
 
35
35
  export function costIconGlyph(icon: CostIcon, nerdFontIcons: boolean): string {
36
36
  const glyphs = {
37
37
  money: { emoji: "💵", nerd: COST_ICON },
38
- coins: { emoji: "🪙", nerd: "\u{f0512}" },
39
- wallet: { emoji: "👛", nerd: "\u{f055d}" },
38
+ coins: { emoji: "🪙", nerd: "\uede8" }, // nf-fa-coins
39
+ wallet: { emoji: "👛", nerd: "\uee1e" }, // nf-fa-wallet
40
40
  };
41
41
  return glyphs[icon][nerdFontIcons ? "nerd" : "emoji"];
42
42
  }
@@ -210,11 +210,7 @@ export class LiveAgentView {
210
210
 
211
211
  private syncProgress(): void {
212
212
  const state = this.snapshot?.thread?.state;
213
- const active =
214
- this.nerdFontIcons &&
215
- !this.disposed &&
216
- !this.error &&
217
- (state === "starting" || state === "running");
213
+ const active = !this.disposed && !this.error && (state === "starting" || state === "running");
218
214
  if (!active) {
219
215
  if (this.progressTimer !== undefined) clearInterval(this.progressTimer);
220
216
  this.progressTimer = undefined;
@@ -102,6 +102,7 @@ export class OrderedModelEditorComponent extends Container {
102
102
  private readonly searchInput = new Input({ placeholder: "Search models" });
103
103
  private draft: string[];
104
104
  private pickerQuery = "";
105
+ private searching = false;
105
106
  private currentItems: ModelSelectItem[] = [];
106
107
  private selectList = new SelectList([], 1, getSelectListTheme(), MODEL_EDITOR_LAYOUT);
107
108
  private _focused = false;
@@ -133,14 +134,12 @@ export class OrderedModelEditorComponent extends Container {
133
134
  "muted",
134
135
  this.withScopeWarning(
135
136
  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.",
137
+ ? "Selected first; suggested matches scoped first, then other models; the rest A–Z. / to search."
138
+ : "Selected first. / to search by provider/id or model name; other models A–Z.",
138
139
  ),
139
140
  ),
140
141
  );
141
- this.footerText.setText(
142
- this.theme.fg("dim", "↑↓ select · Enter toggle · Ctrl+↑↓ reorder · Ctrl+S done · Esc cancel"),
143
- );
142
+ this.updateFooter();
144
143
  this.addChild(this.searchInput);
145
144
  this.refreshPickerList();
146
145
  }
@@ -151,7 +150,7 @@ export class OrderedModelEditorComponent extends Container {
151
150
 
152
151
  set focused(value: boolean) {
153
152
  this._focused = value;
154
- this.searchInput.focused = value;
153
+ this.searchInput.focused = value && this.searching;
155
154
  }
156
155
 
157
156
  getMode(): "picker" {
@@ -235,8 +234,13 @@ export class OrderedModelEditorComponent extends Container {
235
234
  this.onDone([...this.draft]);
236
235
  return;
237
236
  }
238
- const earlier = matchesKey(keyData, Key.ctrl("up"));
239
- const later = matchesKey(keyData, Key.ctrl("down"));
237
+ if (matchesKey(keyData, Key.tab) || (!this.searching && keyData === "/")) {
238
+ this.setSearching(!this.searching);
239
+ this.tui.requestRender();
240
+ return;
241
+ }
242
+ const earlier = !this.searching && keyData === "w";
243
+ const later = !this.searching && keyData === "s";
240
244
  if (earlier || later) {
241
245
  const selected = this.selectList.getSelectedItem()?.value;
242
246
  const index = selected === undefined ? -1 : this.draft.indexOf(selected);
@@ -261,6 +265,7 @@ export class OrderedModelEditorComponent extends Container {
261
265
  this.searchInput.handleInput(keyData);
262
266
  const nextQuery = this.searchInput.getValue();
263
267
  if (nextQuery !== this.pickerQuery) {
268
+ this.setSearching(true);
264
269
  this.pickerQuery = nextQuery;
265
270
  // Keep selected preferences visible, but focus the first search result
266
271
  // so typing a query and pressing Enter still adds the matching model.
@@ -270,6 +275,23 @@ export class OrderedModelEditorComponent extends Container {
270
275
  this.tui.requestRender();
271
276
  }
272
277
 
278
+ private setSearching(value: boolean): void {
279
+ this.searching = value;
280
+ this.searchInput.focused = this._focused && value;
281
+ this.updateFooter();
282
+ }
283
+
284
+ private updateFooter(): void {
285
+ this.footerText.setText(
286
+ this.theme.fg(
287
+ "dim",
288
+ this.searching
289
+ ? "↑↓ select · Enter toggle · Tab browse · Ctrl+S done · Esc cancel"
290
+ : "↑↓ select · Enter toggle · w/s reorder · / search · Ctrl+S done · Esc cancel",
291
+ ),
292
+ );
293
+ }
294
+
273
295
  private refreshPickerList(selectedValue?: string, focusSearchResult = false): void {
274
296
  const previousIndex = this.currentItems.findIndex(
275
297
  (item) => item.value === this.selectList.getSelectedItem()?.value,