pi-subagent-manager 0.25.0 → 0.27.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.
package/README.md CHANGED
@@ -76,7 +76,7 @@ They inherit your current model until you set preferences. Details: [docs/defaul
76
76
  | `/agents reload` | Reload definitions and settings |
77
77
  | `/agents reap` | Confirm the eligible count, then forget completed agents and free retained-thread slots (cannot be resumed); preserves active parents and ancestors of retained threads. Session files remain on disk. |
78
78
 
79
- A live **Agents** widget sits above the input box. Choose **Full** (the existing tree) or **Minimal** (colored status counts and running-agent token totals, plus the browser hint) under **Status Widget** in `/agents` settings. In the fullscreen tree, **Enter** opens an agent's live view. Type in the bottom **Steer** input and press **Enter** to send it a steering message, including nested agents. **Tab** switches between input and transcript controls, **Escape** returns, and **i** in the tree opens existing thread actions. A status strip below the previews shows how many agents are running and **Press ← to open subagent browser**. Once the main turn ends and all subagents are idle, the preview collapses to a single status-count line. A fresh prompt hides previously settled agents from the widget; they reappear only when resumed, and `/agents tree` always keeps them available. While subagents are starting or running, press **Left** at the start of the main draft to open it; otherwise Left stays native. Press **Right** at the end of the draft (or in an empty input) to collapse the widget to one line for this session only, without changing saved settings. `/agents tree` remains available regardless of agent activity. See [live navigation](docs/tools-and-ui.md#live-agent-navigation) for controls and compatibility.
79
+ A live **Agents** widget sits above the input box. Choose **Full** (the existing tree) or **Minimal** (colored status counts and running-agent token totals, plus the browser hint) under **Status Widget** in `/agents` settings. In the fullscreen tree, **Enter** opens an agent's live view. Type in the bottom **Steer** input and press **Enter** to send it a steering message, including nested agents. **Tab** switches between input and transcript controls, **Escape** returns, and **i** in the tree opens existing thread actions. A status strip below the previews shows how many agents are running and **Press ← to open subagent browser**. Once the main turn ends and all subagents are idle, the preview collapses to a single status-count line. A fresh prompt hides previously settled agents from the widget; they reappear only when resumed, and `/agents tree` always keeps them available. Arrow keys walk **tree ← full ← minimal**: press **Right** at the end of the draft (or in an empty input) to collapse the widget to one line for this session only, without changing saved settings, and **Left** at the start of the draft to step back to full and then, while subagents are starting or running, into the tree (otherwise Left stays native). With the Minimal setting the walk is just **tree ← minimal**. In the tree, **Right** on a leaf returns to the widget. `/agents tree` remains available regardless of agent activity. See [live navigation](docs/tools-and-ui.md#live-agent-navigation) for controls and compatibility.
80
80
 
81
81
  **Cost accounting:** Agent rows show estimated USD cost (including cache reads/writes) when reported. Completed, paused, stopped, and failed agents roll up only newly incurred cost. Accounting survives resume, reload, branch navigation, and reaping; nested agents' own costs are counted once. Running-agent costs remain in their rows until settlement. This changes the footer display, not Pi's native session statistics.
82
82
 
package/docs/settings.md CHANGED
@@ -58,7 +58,7 @@ Controls the subagent status display above the input box. Choose **Status Widget
58
58
  | `full` (default) | A compact tree with one row per agent, task/state, metrics and navigation hints. |
59
59
  | `minimal` | One line of theme-colored status counts plus cumulative input `↑` / output `↓` tokens for agents currently starting or running. |
60
60
 
61
- Minimal mode groups starting agents with running agents and excludes the main conversation. Token totals exclude completed, stopped, failed and paused agents. The fullscreen tree remains available via `/agents tree` in either mode. In full mode, press **Right (→)** at the end of the main draft (or in an empty input) to collapse to one line for this session only, without saving preferences. Session startup/switch/reload restores the configured mode. **Left (←)** at the start of the draft still opens the full dialog while agents are active.
61
+ Minimal mode groups starting agents with running agents and excludes the main conversation. Token totals exclude completed, stopped, failed and paused agents. The fullscreen tree remains available via `/agents tree` in either mode. Arrow keys at the draft edge walk a fixed line: **tree ← full ← minimal**. With **Full** configured, all three states are reachable: **Right (→)** at the end of the main draft (or in an empty input) collapses full to the one-line minimal view for this session only, without saving preferences; **Left (←)** at the start of the draft first returns minimal to full, and from full opens the tree (only while agents are starting or running). With **Minimal** configured the line is just **tree ← minimal**: Left opens the tree, and Right does nothing because minimal is already the right edge. In the fullscreen tree, **Right** on a leaf row (after folds and descents are exhausted) closes the tree and returns to the widget (full, or minimal if configured). Session startup/switch/reload restores the configured mode.
62
62
 
63
63
  ## [labs] Nerd Font icons (`nerdFontIcons`)
64
64
 
@@ -186,8 +186,15 @@ Lower it to keep the tree tidy. Raise it for long sessions with many agents. Whe
186
186
 
187
187
  Settings are read in order: **built-in defaults → Global → trusted Current Project**.
188
188
  All keys are optional. The dialog saves only values different from the lower layer,
189
- so unchanged settings continue inheriting future global changes. Restoring defaults
190
- is a draft edit; in Project scope it can explicitly override non-default global values.
189
+ so unchanged settings continue inheriting future global changes.
190
+
191
+ **Restore defaults** asks you to pick **Global** or **Project** (Project only in a
192
+ trusted project). The picker shows the exact `settings.json` path each choice
193
+ deletes. Choosing one deletes that file immediately — nothing is rewritten with
194
+ default or empty values — then reloads settings and discards unsaved edits. A
195
+ missing file is not an error. There is no undo, and Cancel in the outer dialog
196
+ cannot bring the file back. Deleting the Project file returns the save scope to
197
+ Global; Global values still apply beneath any remaining Project file.
191
198
 
192
199
  Colored dots before each setting describe saved changes: an **accent dot** means
193
200
  changed in Global relative to defaults; a **warning dot** means changed in Current
@@ -76,7 +76,7 @@ The fullscreen watcher renders steer and agent messages (including thinking) as
76
76
 
77
77
  - The bottom **Steer** input is focused initially. Type and press **Enter** to send to the inspected agent, including nested descendants, through the same service as `agent_steer`: running agents receive queued input; paused/completed/stopped agents resume their retained session. Empty input is ignored. Sending leaves the viewer open; failures are shown and preserve the draft for retry.
78
78
  - **Tab** switches between steering input and transcript controls. While typing, **c/t/l/r** are ordinary text and **Home/End** move the input cursor. Pasting never submits by itself.
79
- - **Up/Down, PageUp/PageDown** scroll and pause following in either mode. With transcript controls focused, **Home** scrolls to the start; **End** or **l** resumes following the live tail. Scroll/follow state is remembered per agent.
79
+ - **Up/Down, PageUp/PageDown** scroll and pause following in either mode. In pi fullscreen mode (`tuiMode: "fullscreen"`) the **mouse wheel** scrolls the transcript the same way as Up/Down (using pi's `fullscreenWheelScrollLines`; Alt+wheel moves further) when the pointer is over the viewer. With transcript controls focused, **Home** scrolls to the start; **End** or **l** resumes following the live tail. Scroll/follow state is remembered per agent.
80
80
  - **Ctrl+R** (or **r** with transcript controls focused) retries an unavailable observation without starting a turn. Starting threads are watchable; stopped/completed threads remain readable.
81
81
  - Frames are sanitized, viewport-bounded and coalesced during bursts. Exit, root replacement and shutdown release observers/timers. Streaming deltas never enter persisted thread events.
82
82
 
@@ -84,7 +84,7 @@ The fullscreen watcher renders steer and agent messages (including thinking) as
84
84
 
85
85
  While any subagent is **starting or running**, press physical **Left (←)** at the beginning of the main draft (or in an empty input) to open the subagent browser. With no active subagents, or elsewhere in the draft, Left retains normal cursor movement. `/agents tree` remains available regardless of agent activity. Down is always native editing/history navigation. Autocomplete, jumps, paste and configured shortcuts take precedence. Navigating preserves the main draft/cursor and does not require the root to be idle.
86
86
 
87
- Press physical **Right (→)** at the end of the main draft (or in an empty input) to collapse the full widget to a single status line for this session. This does not save settings or change the configured **Status Widget** mode. Refreshes, agent resumes, new main turns and session-tree navigation keep it collapsed; starting, switching or reloading a session restores the configured mode. Left still opens the full dialog while subagents are active, without expanding the widget. Elsewhere in the draft Right retains normal cursor movement; autocomplete, jumps, paste and shortcuts take precedence.
87
+ Press physical **Right (→)** at the end of the main draft (or in an empty input) to collapse the full widget to a single status line for this session. This does not save settings or change the configured **Status Widget** mode. Refreshes, agent resumes, new main turns and session-tree navigation keep it collapsed; starting, switching or reloading a session restores the configured mode. Left from that collapsed line first returns to the full widget; Left again opens the full dialog while subagents are active. In the fullscreen tree, Right on a leaf row closes the tree and returns to the full widget, so the keys always walk **tree ← full ← minimal**. When **Status Widget** is set to Minimal, the walk is **tree ← minimal**: Left opens the tree directly, Right in the tree returns to the minimal line, and Right at the draft does nothing. Elsewhere in the draft Right retains normal cursor movement; autocomplete, jumps, paste and shortcuts take precedence.
88
88
 
89
89
  Arrow-key shortcuts are enabled by default in the TUI; `/agents tree` remains available everywhere. Pi has one custom-editor slot: installation is skipped if another factory owns it or an existing draft is nonempty, since the host cannot transfer cursor/undo/expanded-paste state. Load order can still let a later editor replace ours. Initial startup uses Pi's history hydration; replacement installations seed history once. Session-tree rebuilds keep the existing editor instance.
90
90
 
@@ -99,7 +99,7 @@ The widget above the input editor has two display modes, selected with **Status
99
99
  - **Full** (default): the existing compact tree, at most twelve lines.
100
100
  - **Minimal**: a summary line such as `3 running, 2 stopped, 1 failed, 1 paused ↑12k ↓3k`, with semantic theme colors. Starting agents count as running; completed agents are counted when present. Token totals include only currently starting/running agents, not the main conversation or settled threads. Use `/agents tree` for details.
101
101
 
102
- Once the main turn has ended and no subagents are starting or running, either mode collapses to a single status-count line without the browser hint. The full tree remains available via `/agents tree`; **Left** at the start of the draft opens it only while subagents are starting or running. A fresh main prompt hides agents that were already settled (completed, failed, stopped or paused); they remain in `/agents tree` and reappear in the widget only when resumed. Agents still starting or running remain visible, and new agents appear normally. Automatic Final Recap turns keep the current task's results visible. Visible agents use the configured display mode unless Right has collapsed the widget for this session.
102
+ Once the main turn has ended and no subagents are starting or running, either mode collapses to a single status-count line without the browser hint. The full tree remains available via `/agents tree`; **Left** at the start of the draft opens it only while subagents are starting or running. A fresh main prompt hides agents that were already settled (completed, failed, stopped or paused); they remain in `/agents tree` and reappear in the widget only when resumed. Agents still starting or running remain visible, and new agents appear normally. Automatic Final Recap turns keep the current task's results visible. Visible agents use the configured display mode unless Right has collapsed the widget for this session (Left expands it again).
103
103
 
104
104
  In full mode:
105
105
 
@@ -107,7 +107,7 @@ In full mode:
107
107
  - Activity and lifecycle messages (such as `Completed; session retained`) are omitted to save space; detailed status remains available in `/agents tree` and `agent_status`.
108
108
  - Agents are ordered newest-started first (spawn or resume); a branch ranks by its most recently started agent. The most recently started agents are preferred when previews overflow. Overflow is counted, not listed.
109
109
  - Time freezes while paused and resumes on continue.
110
- - A small status strip below the previews shows the running count (including starting agents) and **Press ← to open subagent browser**, including when agents overflow. The full footer also shows **→ collapse**. Minimal mode keeps **← browser** inline so it stays one line. Browser hints appear only while subagents are starting or running; RPC output omits keyboard hints.
110
+ - A small status strip below the previews shows the running count (including starting agents) and **Press ← to open subagent browser**, including when agents overflow. The full footer also shows **→ collapse**. Minimal mode keeps **← browser** inline so it stays one line (**← expand** when it is a session collapse of full). Browser hints appear only while subagents are starting or running; RPC output omits keyboard hints.
111
111
  - With **[labs] Nerd Font icons** enabled, the selected Circle, Braille, or Hourglass loader appears before the preserved role icon in the widget and fullscreen tree/live-view headers. Each family provides completed, paused, failed, and stopped state icons. The minimal summary uses the same indicators for its status counts. Preview all families and states under **[labs] Loader style**. Animation timers stop on settlement or disposal; RPC output stays static.
112
112
 
113
113
  ### Interrupts and stopping agents
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-subagent-manager",
3
- "version": "0.25.0",
3
+ "version": "0.27.0",
4
4
  "description": "Hierarchical, steerable subagent threads for pi",
5
5
  "type": "module",
6
6
  "engines": {
@@ -39,6 +39,7 @@
39
39
  "check": "tsc --noEmit",
40
40
  "changelog": "tsx .github/scripts/changelog.ts",
41
41
  "test": "tsx --test tests/*.test.ts",
42
+ "test:ttyd": "node .agents/skills/ttyd-testing/scripts/smoke-test.mjs && node .agents/skills/ttyd-testing/scripts/lifecycle-test.mjs",
42
43
  "test:coverage": "mkdir -p coverage && tsx --test --experimental-test-coverage --test-coverage-include='src/**' --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=coverage/lcov.info tests/*.test.ts",
43
44
  "prepublishOnly": "npm run check && npm test",
44
45
  "format": "prettier --write --print-width 100 src tests agents .github docs/default-agents.md README.md",
package/src/index.ts CHANGED
@@ -94,7 +94,13 @@ export default function piSubagent(pi: ExtensionAPI): void {
94
94
  summaryTimer = undefined;
95
95
  summaryRunning = false;
96
96
  };
97
- let navigation = new AgentNavigationController();
97
+ // Right at a tree leaf steps tree → full: leave any session collapse behind.
98
+ const returnToWidget = () => {
99
+ if (!widgetCollapsed) return;
100
+ widgetCollapsed = false;
101
+ if (context) refreshWidget(context);
102
+ };
103
+ let navigation = new AgentNavigationController(returnToWidget);
98
104
  let navigationEditor: AgentNavigationEditor | undefined;
99
105
  let navigationEditorFactory: Parameters<ExtensionContext["ui"]["setEditorComponent"]>[0];
100
106
  let navigationGeneration = 0;
@@ -166,6 +172,19 @@ export default function piSubagent(pi: ExtensionAPI): void {
166
172
  widgetCollapsed = true;
167
173
  if (context) refreshWidget(context);
168
174
  },
175
+ // Left from the session-collapsed one-liner returns to full before the tree.
176
+ canExpand: () =>
177
+ manager !== undefined &&
178
+ context?.mode === "tui" &&
179
+ limits.subagentMode !== "off" &&
180
+ !navigation.isOpen &&
181
+ widgetCollapsed &&
182
+ limits.widgetMode === "full" &&
183
+ widgetThreads().some((thread) => thread.path !== "/root"),
184
+ expandWidget: () => {
185
+ widgetCollapsed = false;
186
+ if (context) refreshWidget(context);
187
+ },
169
188
  onError: (error) =>
170
189
  context?.ui.notify(error instanceof Error ? error.message : String(error), "error"),
171
190
  });
@@ -493,6 +512,7 @@ export default function piSubagent(pi: ExtensionAPI): void {
493
512
  limits.nerdFontIcons,
494
513
  rootTurnEnded,
495
514
  limits.loaderStyle,
515
+ widgetCollapsed && limits.widgetMode === "full",
496
516
  );
497
517
  };
498
518
  pi.on("agent_start", async (_event, ctx) => {
@@ -540,7 +560,7 @@ export default function piSubagent(pi: ExtensionAPI): void {
540
560
  cancelSummary();
541
561
  const token = ++generation;
542
562
  closeNavigation(installEditor);
543
- navigation = new AgentNavigationController();
563
+ navigation = new AgentNavigationController(returnToWidget);
544
564
  // session_start already belongs to the replacement session: never append the old registry here.
545
565
  if (manager) await manager.shutdown();
546
566
  inheritedTools.reset();
@@ -486,3 +486,29 @@ export function setManagerProjectSettings(options: ManagerSettingsOptions & {
486
486
  }
487
487
  return entry.filePath;
488
488
  }
489
+
490
+ /** Resolved settings.json path for a scope; the file may not exist. */
491
+ export function managerSettingsPath(options: ManagerSettingsOptions, scope: ManagerSaveScope): string {
492
+ if (scope === "project") {
493
+ if (!options.includeProject) throw new Error("Project settings are not enabled/trusted");
494
+ return layer(options.cwd, [".pi", "agent", "subagent-manager"]).filePath;
495
+ }
496
+ return layer(options.agentDir, ["subagent-manager"]).filePath;
497
+ }
498
+
499
+ /** Restore a scope's defaults by deleting its settings file (nothing is written). A missing file is not an error. */
500
+ export function deleteManagerSettings(options: ManagerSettingsOptions & { scope: ManagerSaveScope }): {
501
+ filePath: string;
502
+ deleted: boolean;
503
+ } {
504
+ if (options.scope !== "user" && options.scope !== "project")
505
+ throw new Error("Invalid settings scope");
506
+ const filePath = managerSettingsPath(options, options.scope);
507
+ const entry = options.scope === "project"
508
+ ? layer(options.cwd, [".pi", "agent", "subagent-manager"])
509
+ : layer(options.agentDir, ["subagent-manager"]);
510
+ // Malformed JSON is removable; symlinks and non-files are refused by settingsFileExists.
511
+ if (!settingsFileExists(entry)) return { filePath, deleted: false };
512
+ unlinkSync(entry.filePath);
513
+ return { filePath, deleted: true };
514
+ }
@@ -16,9 +16,15 @@ export interface AgentNavigationEditorOptions {
16
16
  /** Must return the whole navigation interaction, so repeated Left cannot reopen it. */
17
17
  openTree(): void | Promise<void>;
18
18
  canOpen(): boolean;
19
- /** Session-local widget collapse; never saves the configured display mode. */
19
+ /** Session-local widget collapse (full → minimal); never saves the configured display mode. */
20
20
  collapseWidget?(): void | Promise<void>;
21
21
  canCollapse?(): boolean;
22
+ /**
23
+ * Session-local widget expansion (minimal → full). While it is available, Left
24
+ * steps toward the full widget before the tree: tree ← full ← minimal.
25
+ */
26
+ expandWidget?(): void | Promise<void>;
27
+ canExpand?(): boolean;
22
28
  /** Root ownership token; changing it invalidates queued transitions. */
23
29
  generation(): unknown;
24
30
  onError?(error: unknown): void;
@@ -169,10 +175,17 @@ export class AgentNavigationEditor extends CustomEditor {
169
175
  generation: unknown,
170
176
  direction: "left" | "right",
171
177
  ): void {
172
- const allowed = () => direction === "left"
173
- ? this.navigation.canOpen()
174
- : !!this.navigation.collapseWidget && (this.navigation.canCollapse?.() ?? false);
175
- if (this.pending || !allowed()) return;
178
+ // Left walks one step toward the tree: minimal → full first, then full → tree.
179
+ // Right walks one step toward minimal. The decision is rechecked in the microtask.
180
+ const action = (): "expand" | "tree" | "collapse" | undefined => {
181
+ if (direction === "right")
182
+ return this.navigation.collapseWidget && (this.navigation.canCollapse?.() ?? false)
183
+ ? "collapse" : undefined;
184
+ if (this.navigation.expandWidget && (this.navigation.canExpand?.() ?? false)) return "expand";
185
+ return this.navigation.canOpen() ? "tree" : undefined;
186
+ };
187
+ const chosen = action();
188
+ if (this.pending || !chosen) return;
176
189
  this.pending = direction;
177
190
  const epoch = this.inputEpoch;
178
191
  queueMicrotask(() => {
@@ -182,7 +195,7 @@ export class AgentNavigationEditor extends CustomEditor {
182
195
  !this.focused ||
183
196
  this.inputEpoch !== epoch ||
184
197
  this.navigation.generation() !== generation ||
185
- !allowed() ||
198
+ action() !== chosen ||
186
199
  this.isShowingAutocomplete() ||
187
200
  this.getText() !== text ||
188
201
  after.line !== cursor.line ||
@@ -194,8 +207,9 @@ export class AgentNavigationEditor extends CustomEditor {
194
207
  try {
195
208
  // Call within the checked microtask: an extra Promise.then would leave
196
209
  // a gap in which root ownership could change after validation.
197
- void Promise.resolve(direction === "left"
198
- ? this.navigation.openTree() : this.navigation.collapseWidget!())
210
+ void Promise.resolve(chosen === "tree" ? this.navigation.openTree()
211
+ : chosen === "expand" ? this.navigation.expandWidget!()
212
+ : this.navigation.collapseWidget!())
199
213
  .catch((error: unknown) => this.navigation.onError?.(error))
200
214
  .finally(() => {
201
215
  this.pending = undefined;
package/src/ui/dialog.ts CHANGED
@@ -17,6 +17,8 @@ import {
17
17
  wrapTextWithAnsi,
18
18
  type Component,
19
19
  type TUI,
20
+ type TuiMouseEvent,
21
+ type TuiMouseEventResult,
20
22
  } from "@earendil-works/pi-tui";
21
23
 
22
24
  export interface DialogHost {
@@ -31,6 +33,8 @@ export interface DialogRow {
31
33
  label: string;
32
34
  /** Trusted formatter receives sanitized text; generated ANSI styling is kept when clipping. */
33
35
  renderLabel?: (label: string, theme: Theme) => string;
36
+ /** Trusted formatter for a fixed three-cell middle column, styled at render time. */
37
+ renderIndicators?: (theme: Theme) => string;
34
38
  value?: string;
35
39
  valueColor?: Parameters<Theme["fg"]>[0];
36
40
  help?: string;
@@ -178,7 +182,7 @@ export function dialogEditor(
178
182
  );
179
183
  }
180
184
 
181
- /** Bounded, two-column menu shared by settings and agent definitions. */
185
+ /** Bounded menu with an optional indicator column, shared by settings and agent definitions. */
182
186
  export class DialogMenu {
183
187
  private selected = 0;
184
188
  private viewport = 1;
@@ -242,11 +246,18 @@ export class DialogMenu {
242
246
  this.rows.length - this.viewport,
243
247
  ),
244
248
  );
245
- const labelWidth = Math.min(28, Math.max(8, Math.floor(inner * 0.35)));
249
+ const hasIndicators = this.rows.some((row) => row.renderIndicators);
250
+ const indicatorWidth = 3;
251
+ const labelWidth = Math.min(
252
+ 28,
253
+ Math.max(8, Math.floor(inner * 0.35)),
254
+ // Reserve prefix, separators, indicators and at least one value cell at narrow widths.
255
+ hasIndicators ? Math.max(0, inner - 2 - 6 - indicatorWidth - 1) : Infinity,
256
+ );
246
257
  const body = [
247
258
  this.theme.fg(
248
259
  "dim",
249
- ` ${this.rows.length ? this.selected + 1 : 0}/${this.rows.length} · Field / Value`,
260
+ ` ${this.rows.length ? this.selected + 1 : 0}/${this.rows.length} · Field / ${hasIndicators ? "Saved / " : ""}Value`,
250
261
  ),
251
262
  ...this.rows.slice(start, start + this.viewport).map((row, i) => {
252
263
  const selected = start + i === this.selected;
@@ -259,10 +270,13 @@ export class DialogMenu {
259
270
  true,
260
271
  );
261
272
  const padding = " ".repeat(Math.max(0, labelWidth - visibleWidth(label)));
273
+ const indicators = truncateToWidth(row.renderIndicators?.(this.theme) ?? "", indicatorWidth, "", true);
274
+ const indicatorPadding = " ".repeat(Math.max(0, indicatorWidth - visibleWidth(indicators)));
262
275
  const value = dialogText(row.value ?? "");
263
276
  return color(`${selected ? "›" : " "} `)
264
277
  + (row.renderLabel ? label : color(label))
265
278
  + color(`${padding} │ `)
279
+ + (hasIndicators ? indicators + color(`${indicatorPadding} │ `) : "")
266
280
  + (row.valueColor ? this.theme.fg(row.valueColor, value) : color(value));
267
281
  }),
268
282
  "",
@@ -512,6 +526,12 @@ export class DialogSession {
512
526
  this.child?.handleInput?.(data);
513
527
  }
514
528
 
529
+ /** Fullscreen mouse events reach the overlay, so forward them to the active child view. */
530
+ handleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined {
531
+ if (this.closed || this.inputLocked) return undefined;
532
+ return this.child?.handleMouse?.(event);
533
+ }
534
+
515
535
  invalidate(): void {
516
536
  this.child?.invalidate();
517
537
  }
@@ -8,6 +8,8 @@ import {
8
8
  ScrollView,
9
9
  stripTerminalSequences,
10
10
  truncateToWidth,
11
+ type TuiMouseEvent,
12
+ type TuiMouseEventResult,
11
13
  visibleWidth,
12
14
  wrapTextWithAnsi,
13
15
  } from "@earendil-works/pi-tui";
@@ -292,6 +294,16 @@ export class LiveAgentView {
292
294
  this.host.requestRender();
293
295
  }
294
296
 
297
+ /** Fullscreen wheel events scroll the transcript like Up/Down, even while composing. */
298
+ handleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined {
299
+ if (this.disposed || event.type !== "wheel") return undefined;
300
+ const lines = Math.trunc(event.wheelDelta ?? 0);
301
+ if (!Number.isFinite(lines) || lines === 0) return undefined;
302
+ this.scroll.scrollBy(lines);
303
+ this.saveViewport();
304
+ return { handled: true, render: true };
305
+ }
306
+
295
307
  private saveViewport(): void {
296
308
  this.viewport.scrollTop = this.scroll.scrollTop;
297
309
  this.viewport.follow = this.scroll.isFollowingEnd;
@@ -15,7 +15,9 @@ import {
15
15
  type CostValue,
16
16
  LOADER_STYLES,
17
17
  type LoaderStyle,
18
+ deleteManagerSettings,
18
19
  loadManagerSettingsLayers,
20
+ managerSettingsPath,
19
21
  saveManagerOverrides,
20
22
  setManagerProjectSettings,
21
23
  type ManagerSettings,
@@ -35,7 +37,7 @@ const LOADER_OPTIONS = LOADER_STYLES.map((id) => {
35
37
  id,
36
38
  label: loader.label,
37
39
  value: `${loader.frames.join(" ")} · ${Object.values(loader.states).join(" ")}`,
38
- help: `Each row: all starting/running frames · completed, paused, failed, stopped.\nStarting/running: ${loader.frames.join(" ")}\nCompleted: ${loader.states.completed} · Paused: ${loader.states.paused}\nFailed: ${loader.states.failed} · Stopped: ${loader.states.stopped}\n${loader.requiresNerdFont ? "Requires [labs] Nerd Font icons On." : id === "braille" ? "Standard Unicode Braille; no Nerd Font needed." : "ASCII only; no special font needed."} The loader appears before the role icon when enabled.`,
40
+ help: `Each row: all starting/running frames · completed, paused, failed, stopped.\nStarting/running: ${loader.frames.join(" ")}\nCompleted: ${loader.states.completed} · Paused: ${loader.states.paused}\nFailed: ${loader.states.failed} · Stopped: ${loader.states.stopped}\n${loader.requiresNerdFont ? "Requires [lab] Nerd Font icons On." : id === "braille" ? "Standard Unicode Braille; no Nerd Font needed." : "ASCII only; no special font needed."} The loader appears before the role icon when enabled.`,
39
41
  };
40
42
  });
41
43
 
@@ -160,9 +162,9 @@ function withProvenance(row: DialogRow, keys: (keyof ManagerSettings)[], layers:
160
162
  layers.project[key] !== (layers.global[key] ?? DEFAULT_MANAGER_SETTINGS[key]));
161
163
  return {
162
164
  ...row,
163
- renderLabel: (label, theme) =>
164
- (globalChanged ? theme.fg("accent", "●") + " " : "") +
165
- (projectChanged ? theme.fg("warning", "●") + " " : "") + label.replace(/^\[labs\] /, ""),
165
+ renderIndicators: (theme) =>
166
+ (globalChanged ? theme.fg("accent", "●") : " ") + " " +
167
+ (projectChanged ? theme.fg("warning", "●") : " "),
166
168
  help: `${row.label}\n${row.help ?? ""}`,
167
169
  };
168
170
  }
@@ -177,7 +179,7 @@ function provenanceLegend(theme: Theme): string {
177
179
  async function configureFooterDisplay(ctx: ExtensionCommandContext, draft: ManagerSettings, layers: SettingsLayers): Promise<void> {
178
180
  let selectedId: string | undefined;
179
181
  while (true) {
180
- const action = await dialogMenu(ctx, "[labs] Footer display", ([
182
+ const action = await dialogMenu(ctx, "[lab] Footer display", ([
181
183
  {
182
184
  id: "location",
183
185
  label: "Location",
@@ -194,7 +196,7 @@ async function configureFooterDisplay(ctx: ExtensionCommandContext, draft: Manag
194
196
  id: "icon",
195
197
  label: "Icon",
196
198
  value: `${costIconGlyph(draft.costIcon, draft.nerdFontIcons)} ${COST_ICON_LABELS[draft.costIcon]}`,
197
- help: `Choose a money-related ${draft.nerdFontIcons ? "Nerd Font" : "emoji"} icon. The family follows [labs] Nerd Font icons.`,
199
+ help: `Choose a money-related ${draft.nerdFontIcons ? "Nerd Font" : "emoji"} icon. The family follows [lab] Nerd Font icons.`,
198
200
  },
199
201
  { id: "back", label: "Back", help: "Return to settings. Save and apply there to commit these changes." },
200
202
  ] as DialogRow[]).map((row) => {
@@ -321,31 +323,31 @@ async function configureAgentsDialog(
321
323
  },
322
324
  {
323
325
  id: "costDisplay",
324
- label: "[labs] Footer display",
326
+ label: "[lab] Footer display",
325
327
  value: COST_DISPLAY_OPTIONS.find((mode) => mode.id === draft.costDisplay)!.label,
326
328
  help: "Configure footer location, displayed cost, and money icon in a submenu. Save and apply to update immediately.",
327
329
  },
328
330
  {
329
331
  id: "nerdFontIcons",
330
- label: "[labs] Nerd Font icons",
332
+ label: "[lab] Nerd Font icons",
331
333
  value: draft.nerdFontIcons ? "On" : "Off",
332
334
  help: "Experimental: display each agent type’s optional Nerd Font icon and unlock Nerd Font loader palettes.\nRequires a Nerd Font configured in your terminal; otherwise glyphs may appear as boxes.\nOff by default. Braille and ASCII loaders work with this Off. Save and apply to update immediately.",
333
335
  },
334
336
  {
335
337
  id: "loaderStyle",
336
- label: "[labs] Loader style",
338
+ label: "[lab] Loader style",
337
339
  value: AGENT_LOADERS[effectiveLoaderStyle(draft.loaderStyle, draft.nerdFontIcons)].label,
338
340
  help: "Preview every animation frame and settled state.\nNerd Fonts Off: Braille (standard Unicode), ASCII, ASCII Star and ASCII Pulse. On: all palettes, including Circle and Hourglass.\nNerd-only saved styles fall back to ASCII while Nerd Fonts are off. Save and apply to update immediately.",
339
341
  },
340
342
  {
341
343
  id: "subagentExtensions",
342
- label: "[labs] Enable subagent extensions",
344
+ label: "[lab] Enable subagent extensions",
343
345
  value: draft.subagentExtensions ? "On" : "Off",
344
346
  help: "Experimental: reload configured user/trusted-project extension hooks in separate subagent sessions (not CLI-only or inline extensions). Bugs and unintended consequences may occur if hooks assume main-session state.\nRead limitations: https://github.com/championswimmer/pi-subagent-manager/blob/main/docs/subagent-extension-limitations.md\nOff by default. Save and apply affects newly opened sessions, not already-open agents.",
345
347
  },
346
348
  {
347
349
  id: "finalRecap",
348
- label: "[labs] Final Recap",
350
+ label: "[lab] Final Recap",
349
351
  value: draft.finalRecap ? "On" : "Off",
350
352
  help: "Experimental: when detached agents finish or fail and the main agent is idle, automatically ask the main agent to summarize their results.\nEnabling this may cause extra model turns and uses more tokens and context.\nOff by default. Subagent Mode Off suppresses automatic summaries.",
351
353
  },
@@ -364,7 +366,7 @@ async function configureAgentsDialog(
364
366
  {
365
367
  id: "defaults",
366
368
  label: "Restore defaults",
367
- help: "Replace all values shown with built-in defaults.\nNothing is saved until you choose Save and apply.",
369
+ help: "Pick Global or Project, then delete that scope's settings.json so its defaults apply again.\nThe file is removed, not rewritten; unsaved edits are discarded. This cannot be undone.",
368
370
  },
369
371
  {
370
372
  id: "save",
@@ -444,7 +446,7 @@ async function configureAgentsDialog(
444
446
  const styles = availableLoaderStyles(draft.nerdFontIcons);
445
447
  const style = await dialogMenu(
446
448
  ctx,
447
- "[labs] Loader style",
449
+ "[lab] Loader style",
448
450
  LOADER_OPTIONS.filter((option) => styles.includes(option.id)),
449
451
  { selectedId: effectiveLoaderStyle(draft.loaderStyle, draft.nerdFontIcons) },
450
452
  );
@@ -489,7 +491,37 @@ async function configureAgentsDialog(
489
491
  options.apply();
490
492
  }
491
493
  }
492
- } else if (action === "defaults") draft = { ...DEFAULT_MANAGER_SETTINGS };
494
+ } else if (action === "defaults") {
495
+ const target = { cwd: ctx.cwd, agentDir: options.agentDir, includeProject: ctx.isProjectTrusted() };
496
+ const globalPath = managerSettingsPath(target, "user");
497
+ const projectPath = target.includeProject ? managerSettingsPath(target, "project") : undefined;
498
+ const explain = (path: string) =>
499
+ `Deletes this file now (nothing is written):\n${path}\nIf it does not exist, nothing happens. Unsaved edits are discarded. No undo.`;
500
+ const rows: DialogRow[] = [
501
+ { id: "user", label: "Global", value: "Restore global defaults", help: explain(globalPath) },
502
+ ...(projectPath
503
+ ? [{ id: "project", label: "Project", value: "Restore project defaults", help: explain(projectPath) }]
504
+ : []),
505
+ { id: "cancel", label: "Cancel", help: "Delete nothing." },
506
+ ];
507
+ const choice = await dialogMenu(ctx, "Restore defaults: delete which settings file?", rows, {
508
+ selectedId: "cancel",
509
+ footer: "↑↓/Tab choose · Enter delete file · Esc cancel",
510
+ });
511
+ if (choice === "user" || choice === "project") {
512
+ const { filePath, deleted } = deleteManagerSettings({ ...target, scope: choice });
513
+ layers = readLayers();
514
+ reportDiagnostics();
515
+ baseline = { ...layers.settings };
516
+ draft = { ...baseline };
517
+ scope = layers.scope;
518
+ options.apply();
519
+ ctx.ui.notify(
520
+ deleted ? `Deleted ${filePath}. Defaults restored.` : `No settings file at ${filePath}; nothing to delete.`,
521
+ "info",
522
+ );
523
+ }
524
+ }
493
525
  else if (action === "types") {
494
526
  await editAgentTypes(ctx, options.store, draft.nerdFontIcons, {
495
527
  getAllTools: options.getAllTools ?? (() => []),
@@ -114,6 +114,8 @@ export class StatusDialog {
114
114
  state: AgentTreeState;
115
115
  actions(path: string): void;
116
116
  fullscreen?: boolean;
117
+ /** Right on a leaf steps tree → widget; called just before the tree closes. */
118
+ returnToWidget?(): void;
117
119
  },
118
120
  private nerdFontIcons = false,
119
121
  private loaderStyle: LoaderStyle = "circle",
@@ -242,6 +244,12 @@ export class StatusDialog {
242
244
  else {
243
245
  const child = row?.hasChildren ? firstChild(rows, index) : undefined;
244
246
  if (child) this.selectedPath = child.path;
247
+ else if (this.navigation?.fullscreen) {
248
+ // Nothing left to fold or descend into: the next step right is the widget.
249
+ this.navigation.returnToWidget?.();
250
+ this.done(undefined);
251
+ return;
252
+ }
245
253
  }
246
254
  } else {
247
255
  let next = index;
@@ -355,7 +363,7 @@ export class StatusDialog {
355
363
  height,
356
364
  this.heading(rows, start, treeCount),
357
365
  body,
358
- this.navigation ? "Esc main · ↑↓ select · ←→ fold · i Actions · Ctrl+C stop all" : FOOTER,
366
+ this.navigation ? "Esc main · ↑↓ select · ←→ fold · → widget · i Actions · Ctrl+C stop all" : FOOTER,
359
367
  );
360
368
  }
361
369
 
@@ -433,6 +441,8 @@ export class AgentNavigationController {
433
441
  private opening: Promise<void> | undefined;
434
442
  private generation = 0;
435
443
 
444
+ constructor(private returnToWidget?: () => void) {}
445
+
436
446
  get isOpen(): boolean {
437
447
  return this.opening !== undefined;
438
448
  }
@@ -527,6 +537,7 @@ export class AgentNavigationController {
527
537
  {
528
538
  state: this.tree,
529
539
  fullscreen: true,
540
+ returnToWidget: this.returnToWidget,
530
541
  actions: (path) => finish({ kind: "actions", path }),
531
542
  },
532
543
  nerdFontIcons,
package/src/ui/ui.ts CHANGED
@@ -226,6 +226,8 @@ interface AgentWidgetRenderOptions {
226
226
  loaderStyle?: LoaderStyle;
227
227
  /** RPC snapshots use a static running frame and never start an animation. */
228
228
  animate?: boolean;
229
+ /** Minimal line is a session collapse of full: Left steps back to full, not the browser. */
230
+ expandHint?: boolean;
229
231
  }
230
232
 
231
233
  function agentWidgetStatus(
@@ -377,6 +379,7 @@ export function renderAgentSummary(
377
379
  nerdFontIcons = false,
378
380
  animate = true,
379
381
  loaderStyle = "circle",
382
+ expandHint = false,
380
383
  }: AgentWidgetRenderOptions = {},
381
384
  ): string[] {
382
385
  const agents = new Map<string, ThreadView>();
@@ -420,7 +423,7 @@ export function renderAgentSummary(
420
423
  return theme.fg(color, `${progress ? `${progress} ` : ""}${counts[state]} ${state}`);
421
424
  })
422
425
  .join(theme.fg("muted", ", ")) +
423
- (showBrowserHint && counts.running > 0 ? theme.fg("muted", " · ← browser") : "");
426
+ (showBrowserHint && counts.running > 0 ? theme.fg("muted", expandHint ? " · ← expand" : " · ← browser") : "");
424
427
  const right = theme.fg("muted", `↑${formatCount(input)} ↓${formatCount(output)}`);
425
428
  return [fitLine(left, right, Math.max(0, width))];
426
429
  }
@@ -432,6 +435,8 @@ export function updateWidget(
432
435
  nerdFontIcons = false,
433
436
  rootTurnEnded = false,
434
437
  loaderStyle: LoaderStyle = "circle",
438
+ /** True while a configured-full widget is session-collapsed to the minimal line. */
439
+ sessionCollapsed = false,
435
440
  ): void {
436
441
  if (!ctx.hasUI) return;
437
442
  if (!threads.some((thread) => thread.path !== "/root")) {
@@ -470,6 +475,7 @@ export function updateWidget(
470
475
  showBrowserHint: !settled,
471
476
  nerdFontIcons,
472
477
  loaderStyle,
478
+ expandHint: sessionCollapsed,
473
479
  }),
474
480
  invalidate: () => {},
475
481
  dispose: () => {
@@ -882,7 +888,7 @@ const EDIT_FIELD_LABELS: Record<EditMenuAction, string> = {
882
888
  "tools.allow": "Allowed tools",
883
889
  "tools.block": "Blocked tools",
884
890
  color: "Color",
885
- icon: "[labs] Icon",
891
+ icon: "[lab] Icon",
886
892
  systemPrompt: "System prompt",
887
893
  "Save scope": "Save scope",
888
894
  Source: "Source (read-only)",
@@ -908,7 +914,7 @@ const EDIT_FIELD_HELP: Record<EditMenuAction, string> = {
908
914
  "tools.block":
909
915
  "Pick session tools to block. Blocked tools take precedence when the policy uses this list.",
910
916
  color: "Thread widget color with live preview.",
911
- icon: "Paste a single Nerd Font glyph from nerdfonts.com/cheat-sheet (not its name or codepoint).\nLeave blank to remove. Display requires [labs] Nerd Font icons in settings and a Nerd Font in your terminal.",
917
+ icon: "Paste a single Nerd Font glyph from nerdfonts.com/cheat-sheet (not its name or codepoint).\nLeave blank to remove. Display requires [lab] Nerd Font icons in settings and a Nerd Font in your terminal.",
912
918
  systemPrompt: "Edit the Markdown prompt body in a multiline dialog.",
913
919
  "Save scope": "Project definitions override global definitions with the same name.",
914
920
  Source: "Read-only source. Bundled definitions are copied, never overwritten.",