pi-subagent-manager 0.10.0 → 0.11.1

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
@@ -68,11 +68,13 @@ They inherit your current model until you set preferences. Details: [docs/defaul
68
68
  | ---------------- | ------------------------------------------------------ |
69
69
  | `/agents` | Settings (mode, limits, model picking, tool filtering) |
70
70
  | `/agents types` | Agent-type browser and editor |
71
- | `/agents tree` | Fullscreen tree and read-only live watcher (`/agents status` is an alias) |
71
+ | `/agents tree` | Fullscreen tree and live viewer with manual steering (`/agents status` is an alias) |
72
72
  | `/agents import` | Import agents from other subagent extensions |
73
73
  | `/agents reload` | Reload definitions and settings |
74
74
 
75
- 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** watches an agent, **Escape** returns, and **i** opens existing thread actions. A status strip below the previews shows how many agents are running and **Press ← to open subagent browser**. Press **Left** at the start of the main draft to open it; normal cursor movement is unchanged. See [live navigation](docs/tools-and-ui.md#live-agent-navigation-read-only) for controls and compatibility.
75
+ 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; `/agents tree` still opens the full tree. Press **Left** at the start of the main draft to open it; normal cursor movement is unchanged. See [live navigation](docs/tools-and-ui.md#live-agent-navigation) for controls and compatibility.
76
+
77
+ Experimental features are marked **[labs]** in settings. Enable **[labs] Nerd Font icons** in `/agents` to show role-specific icons beside agent names (off by default; requires a Nerd Font in your terminal). Custom agent types can set an optional `icon` or use **[labs] Icon** in `/agents types`. See [icon setup](docs/settings.md#labs-nerd-font-icons-nerdfonticons).
76
78
 
77
79
  ## Docs
78
80
 
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  name: architect
3
+ icon: '󰠡'
3
4
  description: Design architecture, weigh tradeoffs, and decompose ambiguous work into verifiable plans. Ground external claims in dated primary evidence when retrieval is actually available. Coordinate specialists only when delegation or execution is explicitly authorized.
4
5
  color: mdHeading
5
6
  thinkingLevel: high
package/agents/coder.md CHANGED
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  name: coder
3
+ icon: ''
3
4
  description: Own iterative implementation, refactoring, debugging, and frontend UI through a checked patch. Not for lookup-only questions, review-only passes, or long-form prose.
4
5
  thinkingLevel: high
5
6
  color: mdCode
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  name: researcher
3
+ icon: ''
3
4
  description: Evidence-backed local/remote codebase and internet research; source verification, versioned citations, and decision-ready synthesis
4
5
  modelSuggestions:
5
6
  - gemini-4-argon
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  name: reviewer
3
+ icon: ''
3
4
  description: Non-mutating review of scoped changes or existing code for demonstrable correctness and security defects, with severity, location, impact, and the smallest local repair or removal. Not for implementing fixes, style quotas, or speculative abstractions.
4
5
  thinkingLevel: high
5
6
  color: warning
package/agents/tasker.md CHANGED
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  name: tasker
3
+ icon: ''
3
4
  description: Complete short, bounded jobs with clear acceptance criteria, including diagnostics, extraction, mechanical edits, a few tool steps, or a targeted repository lookup. Not for ambiguous features, sustained implementation, or complex code understanding.
4
5
  thinkingLevel: low
5
6
  color: success
package/agents/writer.md CHANGED
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  name: writer
3
+ icon: ''
3
4
  description: Draft or revise original long-form prose for a stated audience and voice. Not for source changes, code review, or UI design, and not for inventing facts, citations, or testimonials.
4
5
  thinkingLevel: medium
5
6
  color: mdQuote
@@ -22,6 +22,7 @@ These are the only locations read. Other packages' `~/.pi/agent/agents` or `.pi/
22
22
  name: api-scout
23
23
  description: Investigate APIs and find evidence before implementation
24
24
  thinkingLevel: high
25
+ icon: "\uf002"
25
26
  models:
26
27
  - anthropic/claude-sonnet-4-6
27
28
  - openai/gpt-5
@@ -49,11 +50,24 @@ Ask the main model to use it: _"spawn an api-scout at `stripe-webhooks` to check
49
50
  | `thinkingLevel` | no | `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`. Clamped to what the model supports. |
50
51
  | `tools` | no | `allow` / `block` lists of exact tool names. Applied per [Tool Filtering](settings.md#tool-filtering-toolfiltering). |
51
52
  | `color` | no | pi semantic color (`accent`, `success`, `warning`, `error`, `muted`, `dim`) for the type pill and path. Default `accent`. |
53
+ | `icon` | no | Single literal Nerd Font glyph. Displayed only with **[labs] Nerd Font icons** enabled; omit for text-only labels. |
52
54
  | `modelSuggestions` | no | Plain model names (e.g. `sonnet-5.5`) that rank the model picker's search. **Never** select a model at runtime. |
53
55
  | `model` | no | Deprecated single-model alias. Still parsed; saved back as `models`. |
54
56
 
55
57
  The Markdown body is the system prompt.
56
58
 
59
+ ## Icons [labs]
60
+
61
+ The optional `icon` field works for any custom or bundled agent type. Choose a glyph from the [Nerd Fonts cheat sheet](https://www.nerdfonts.com/cheat-sheet) and copy the actual character into quoted YAML, for example:
62
+
63
+ ```yaml
64
+ icon: "\uf002" # nf-fa-search, U+F002
65
+ ```
66
+
67
+ Use one Unicode private-use character, not an icon name (`nf-fa-search`), codepoint text (`U+F002`), emoji, or multiple glyphs. Both BMP and supplementary Nerd Font glyphs are supported. Omit the field to remove an icon; empty `icon:` values are invalid.
68
+
69
+ In `/agents types`, select **[labs] Icon** and paste the glyph, then save the agent. Leave the editor blank to remove it. You can configure icons while the feature is off; enable **[labs] Nerd Font icons** in `/agents` settings to see them. A Nerd Font must also be selected in your terminal. Icons supplement names, never replace them.
70
+
57
71
  ## Tips
58
72
 
59
73
  - **Tools default to none.** With default filtering, an empty or missing `allow` list means the agent gets no tools. List what it needs.
@@ -19,6 +19,21 @@ Use tasker for one symbol or a few facts already in the repository; use research
19
19
 
20
20
  Existing user/project `researcher` overrides still win over the new packaged default. Bundled `worker`, `explorer`, and `designer` remain absent: bounded work routes to tasker, frontend implementation to coder, and source investigation to researcher. Nothing is automatically renamed.
21
21
 
22
+ ## Nerd Font icons
23
+
24
+ The optional **[labs] Nerd Font icons** [setting](settings.md#labs-nerd-font-icons-nerdfonticons) is off by default and requires a Nerd Font in your terminal. Each default has a distinct literal `icon` in its frontmatter:
25
+
26
+ | Role | Nerd Fonts identifier | Codepoint | Why this icon |
27
+ | --- | --- | --- | --- |
28
+ | `architect` | `nf-md-floor_plan` | `U+F0821` | Structure, layout, and architecture planning. |
29
+ | `coder` | `nf-fa-code` | `U+F121` | Implementation and source code. |
30
+ | `researcher` | `nf-fa-search` | `U+F002` | Evidence gathering and investigation. |
31
+ | `reviewer` | `nf-cod-inspect` | `U+EBD1` | Inspecting code for concrete defects. |
32
+ | `tasker` | `nf-oct-checklist` | `U+F45E` | Bounded tasks and checklist-style execution. |
33
+ | `writer` | `nf-fa-pencil` | `U+F040` | Writing and editorial work. |
34
+
35
+ Names and codepoints were checked against the [official Nerd Fonts glyph mapping](https://raw.githubusercontent.com/ryanoasis/nerd-fonts/master/glyphnames.json); the [cheat sheet](https://www.nerdfonts.com/cheat-sheet) offers previews and character copying. These are role-based design choices, not font-detected fallbacks. User/project overrides may choose another icon or omit it entirely. See [custom icons](custom-agents.md#icons-labs).
36
+
22
37
  ## Model suggestions are plain names, not pins
23
38
 
24
39
  Suggestions are chosen by task capability, quality, cost, and speed. API formats, SDK adapter compatibility, provider access, and deployment convenience are not selection criteria; Pi's `pi-ai` SDK abstracts model API differences. Availability/release facts are source metadata, not a reason to downrank a capable model.
package/docs/settings.md CHANGED
@@ -15,6 +15,7 @@ All keys are optional. Defaults:
15
15
  {
16
16
  "subagentMode": "opportunistic",
17
17
  "widgetMode": "full",
18
+ "nerdFontIcons": false,
18
19
  "modelSelection": "pick-first-scoped",
19
20
  "toolFiltering": "allowed",
20
21
  "maxLevels": 3,
@@ -53,6 +54,14 @@ Controls the subagent status display above the input box. Choose **Status Widget
53
54
 
54
55
  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.
55
56
 
57
+ ## [labs] Nerd Font icons (`nerdFontIcons`)
58
+
59
+ Experimental features are tagged **[labs]** in settings. **[labs] Nerd Font icons** is an on/off toggle, **off by default**. Enable it in `/agents` and save with **Ctrl+S**, or set `"nerdFontIcons": true` in your settings file. Configure a [Nerd Font](https://www.nerdfonts.com/) in your terminal first; unsupported fonts may show boxes or incorrect glyphs. The extension does not install or detect fonts.
60
+
61
+ When enabled, an agent type’s optional `icon` appears before its readable name in the full widget, thread browsers, live watcher header, and type picker. Types without icons remain text-only; turning it off restores text-only labels without removing configured icons. The minimal widget remains an aggregate count, with no per-agent icons. Saved settings apply immediately to newly rendered widgets and dialogs.
62
+
63
+ All six bundled agents have [role-specific icons](default-agents.md#nerd-font-icons). Add or change an icon with **[labs] Icon** in `/agents types`, or the optional `icon` frontmatter field in [your own agent](custom-agents.md#icons-labs). Retained threads keep the icon from their saved agent definition.
64
+
56
65
  ## Model Picking (`modelSelection`)
57
66
 
58
67
  Which model an agent gets when its session starts.
@@ -117,3 +126,8 @@ Lower it to keep the tree tidy. Raise it for long sessions with many agents. Whe
117
126
  ## Scope
118
127
 
119
128
  The dialog's scope field picks where to save: **global** or **trusted project**.
129
+ Your selection is remembered across dialog reopenings, projects, and Pi restarts,
130
+ even if you cancel. It is stored separately from manager settings in
131
+ `<agentDir>/subagent-manager/ui-state.json`. Untrusted projects always use Global
132
+ without overwriting your remembered choice. Existing project settings still
133
+ override global defaults; switching scope does not change the values shown.
@@ -56,13 +56,14 @@ Then `agent_wait` or `agent_status` on `/root/controller-security-research`.
56
56
 
57
57
  Refreshes every second and keeps your selection, collapse state and scroll position.
58
58
 
59
- ### Live agent navigation (read-only)
59
+ ### Live agent navigation
60
60
 
61
- The fullscreen watcher shows steer and agent messages in full, including the in-progress assistant reply. Tool calls, results, and other metadata show their name/status and only the first three wrapped lines of each arguments/output preview, followed by `...` when more is hidden. Use **i → Transcript** from the tree for retained tool details. Thinking is initially hidden (**t** toggles it). It never sends a prompt, switches sessions, or changes model/tool/resource ownership. Inherited context is initially collapsed (**c** toggles it). Unsupported/custom content and images use safe text placeholders rather than native rich rendering. Legacy sessions without reliable inherited-prefix metadata show their whole transcript.
61
+ The fullscreen watcher shows steer and agent messages in full, including the in-progress assistant reply. Tool calls, results, and other metadata show their name/status and only the first three wrapped lines of each arguments/output preview, followed by `...` when more is hidden. Use **i → Transcript** from the tree for retained tool details. Thinking is initially hidden (**t** toggles it with transcript controls focused). Inherited context is initially collapsed (**c** toggles it with transcript controls focused). Watching alone never starts a turn, switches sessions, or changes model/tool/resource ownership. Unsupported/custom content and images use safe text placeholders rather than native rich rendering. Legacy sessions without reliable inherited-prefix metadata show their whole transcript.
62
62
 
63
- - **Up/Down, PageUp/PageDown, Home** scroll and pause following.
64
- - **End** or **l** resumes following the live tail. Scroll/follow state is remembered per agent.
65
- - **r** retries an unavailable observation without starting a turn. Starting threads are watchable; stopped/completed threads remain readable.
63
+ - 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.
64
+ - **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.
65
+ - **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.
66
+ - **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.
66
67
  - Frames are sanitized, viewport-bounded and coalesced during bursts. Exit, root replacement and shutdown release observers/timers. Streaming deltas never enter persisted thread events.
67
68
 
68
69
  #### Left-arrow entry
@@ -82,6 +83,8 @@ The widget above the input editor has two display modes, selected with **Status
82
83
  - **Full** (default): the existing compact tree, at most twelve lines.
83
84
  - **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.
84
85
 
86
+ 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` or **Left** at the start of the draft. A new main turn or active subagent restores the configured display mode.
87
+
85
88
  In full mode:
86
89
 
87
90
  - Each row: colored type pill, path, state, task, active time, input `↑` / output `↓` tokens.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-subagent-manager",
3
- "version": "0.10.0",
3
+ "version": "0.11.1",
4
4
  "description": "Hierarchical, steerable subagent threads for pi",
5
5
  "type": "module",
6
6
  "engines": {
package/src/index.ts CHANGED
@@ -48,6 +48,7 @@ export default function piSubagent(pi: ExtensionAPI): void {
48
48
  return loaded.diagnostics;
49
49
  };
50
50
  let generation = 0;
51
+ let rootTurnEnded = false;
51
52
  let navigation = new AgentNavigationController();
52
53
  let navigationEditor: AgentNavigationEditor | undefined;
53
54
  let navigationEditorFactory: Parameters<ExtensionContext["ui"]["setEditorComponent"]>[0];
@@ -81,7 +82,7 @@ export default function piSubagent(pi: ExtensionAPI): void {
81
82
  canOpen: () => manager !== undefined && context?.mode === "tui" &&
82
83
  limits.subagentMode !== "off" && !navigation.isOpen,
83
84
  openTree: () => manager && context
84
- ? navigation.open(context, manager.scope("/root")) : undefined,
85
+ ? navigation.open(context, manager.scope("/root"), undefined, limits.nerdFontIcons) : undefined,
85
86
  onError: (error) => context?.ui.notify(
86
87
  error instanceof Error ? error.message : String(error), "error"),
87
88
  });
@@ -113,12 +114,6 @@ export default function piSubagent(pi: ExtensionAPI): void {
113
114
  importInProgress = false;
114
115
  }
115
116
  };
116
- // A migration can span clarification turns. Reload after each root turn, without converting files.
117
- pi.on("agent_end", async () => {
118
- if (limits.subagentMode === "off" || !migrationRequested) return;
119
- store.reload();
120
- if (store.diagnostics.length) context?.ui.notify(store.diagnostics.join("\n"), "warning");
121
- });
122
117
  const requireManager = () => {
123
118
  if (!manager) throw new Error("Subagent threads are not initialized; start a Pi session first");
124
119
  return manager;
@@ -238,8 +233,20 @@ export default function piSubagent(pi: ExtensionAPI): void {
238
233
  const refreshWidget = (ctx: ExtensionContext) => {
239
234
  if (limits.subagentMode === "off") {
240
235
  if (ctx.hasUI) ctx.ui.setWidget("pi-subagent", undefined);
241
- } else updateWidget(ctx, requireManager().list(), limits.widgetMode);
236
+ } else updateWidget(ctx, requireManager().list(), limits.widgetMode, limits.nerdFontIcons, rootTurnEnded);
242
237
  };
238
+ pi.on("agent_start", async (_event, ctx) => {
239
+ rootTurnEnded = false;
240
+ if (manager) refreshWidget(ctx);
241
+ });
242
+ pi.on("agent_end", async (_event, ctx) => {
243
+ rootTurnEnded = true;
244
+ if (manager) refreshWidget(ctx);
245
+ // A migration can span clarification turns. Reload after each root turn, without converting files.
246
+ if (limits.subagentMode === "off" || !migrationRequested) return;
247
+ store.reload();
248
+ if (store.diagnostics.length) context?.ui.notify(store.diagnostics.join("\n"), "warning");
249
+ });
243
250
  syncTools();
244
251
  pi.on("before_agent_start", async (event, ctx) => {
245
252
  const prompt = subagentPrompt(limits);
@@ -264,6 +271,7 @@ export default function piSubagent(pi: ExtensionAPI): void {
264
271
  if (manager) await manager.shutdown();
265
272
  inheritedTools.reset();
266
273
  context = ctx;
274
+ rootTurnEnded = false;
267
275
  store = new ConfigStore({
268
276
  cwd: ctx.cwd,
269
277
  agentDir: getAgentDir(),
@@ -373,7 +381,7 @@ export default function piSubagent(pi: ExtensionAPI): void {
373
381
  if (command === "import") {
374
382
  await importAgents(ctx, false);
375
383
  } else if (command === "types") {
376
- await editAgentTypes(ctx, store);
384
+ await editAgentTypes(ctx, store, limits.nerdFontIcons);
377
385
  store.reload();
378
386
  } else if (command === "reload") {
379
387
  store.reload();
@@ -403,9 +411,9 @@ export default function piSubagent(pi: ExtensionAPI): void {
403
411
  },
404
412
  });
405
413
  } else if (command === "status") {
406
- await showAgentStatus(ctx, requireManager().scope("/root"));
414
+ await showAgentStatus(ctx, requireManager().scope("/root"), undefined, limits.nerdFontIcons);
407
415
  } else if (command === "tree") {
408
- await navigation.open(ctx, requireManager().scope("/root"), rest.join(" ") || undefined);
416
+ await navigation.open(ctx, requireManager().scope("/root"), rest.join(" ") || undefined, limits.nerdFontIcons);
409
417
  } else
410
418
  ctx.ui.notify(
411
419
  "Usage: /agents [tree [path] | status | settings | types | import | reload]",
@@ -136,6 +136,7 @@ export class ThreadManager {
136
136
  owner: current.owner,
137
137
  type: current.type,
138
138
  color: current.color,
139
+ icon: current.icon,
139
140
  state: current.state,
140
141
  task: current.task,
141
142
  status: current.status,
@@ -177,6 +178,7 @@ export class ThreadManager {
177
178
  const { sessionLeafId, ...storedView } = savedView;
178
179
  const view: ThreadView = {
179
180
  ...storedView,
181
+ icon: storedView.icon ?? item.definition.icon,
180
182
  updatedAt: Date.now(),
181
183
  elapsedMs: storedView.elapsedMs ?? 0,
182
184
  inputTokens: storedView.inputTokens ?? 0,
@@ -263,6 +265,7 @@ export class ThreadManager {
263
265
  owner: parent ?? caller,
264
266
  type: type.name,
265
267
  color: type.color,
268
+ icon: type.icon,
266
269
  state: "starting",
267
270
  task: args.task,
268
271
  status: "Starting",
package/src/orch/tools.ts CHANGED
@@ -45,13 +45,14 @@ export function agentTools(
45
45
  () =>
46
46
  result(
47
47
  getTypes().map(
48
- ({ name, description, thinkingLevel, color, modelSuggestions, ...type }) => ({
48
+ ({ name, description, thinkingLevel, color, icon, modelSuggestions, ...type }) => ({
49
49
  name,
50
50
  description,
51
51
  models: getModelPreferences(type),
52
52
  modelSuggestions: modelSuggestions === undefined ? undefined : [...modelSuggestions],
53
53
  thinkingLevel,
54
54
  color,
55
+ icon,
55
56
  }),
56
57
  ),
57
58
  ),
@@ -78,6 +78,7 @@ const FIELDS = new Set([
78
78
  "modelSuggestions",
79
79
  "thinkingLevel",
80
80
  "color",
81
+ "icon",
81
82
  "tools",
82
83
  ]);
83
84
  const SUBAGENT_MANAGER_DIR = "subagent-manager";
@@ -227,6 +228,11 @@ export function parseAgentType(content: string, filePath?: string): AgentType {
227
228
  );
228
229
  result.color = data.color as string;
229
230
  }
231
+ if (Object.hasOwn(data, "icon")) {
232
+ if (typeof data.icon !== "string" || !/^\p{Co}$/u.test(data.icon))
233
+ throw new Error("icon must be a single literal Nerd Font glyph (Unicode private-use character)");
234
+ result.icon = data.icon;
235
+ }
230
236
  if (Object.hasOwn(data, "tools")) result.tools = toolPolicy(data.tools);
231
237
  if (filePath !== undefined) result.filePath = filePath;
232
238
  return result;
@@ -248,7 +254,7 @@ export function serializeAgentType(type: AgentType): string {
248
254
  if (models !== undefined) data.models = models;
249
255
  if (type.modelSuggestions !== undefined)
250
256
  data.modelSuggestions = modelSuggestionNames(type.modelSuggestions);
251
- for (const key of ["thinkingLevel", "color", "tools"] as const)
257
+ for (const key of ["thinkingLevel", "color", "icon", "tools"] as const)
252
258
  if (type[key] !== undefined) data[key] = type[key];
253
259
  const content = `---\n${stringify(data)}---\n${type.systemPrompt}`;
254
260
  parseAgentType(content);
@@ -33,6 +33,7 @@ export interface ManagerSettings {
33
33
  subagentMode: SubagentMode;
34
34
  toolFiltering: ToolFilteringMode;
35
35
  widgetMode: WidgetMode;
36
+ nerdFontIcons: boolean;
36
37
  maxLevels: number;
37
38
  maxConcurrent: number;
38
39
  maxThreads: number;
@@ -47,10 +48,11 @@ export const DEFAULT_MANAGER_SETTINGS: ManagerSettings = {
47
48
  subagentMode: "opportunistic",
48
49
  toolFiltering: "allowed",
49
50
  widgetMode: "full",
51
+ nerdFontIcons: false,
50
52
  };
51
53
 
52
54
  const KEYS = [
53
- "maxLevels", "maxConcurrent", "maxThreads", "modelSelection", "subagentMode", "toolFiltering", "widgetMode",
55
+ "maxLevels", "maxConcurrent", "maxThreads", "modelSelection", "subagentMode", "toolFiltering", "widgetMode", "nerdFontIcons",
54
56
  ] as const;
55
57
  const MAX_LEVELS = 32;
56
58
 
@@ -88,6 +90,7 @@ function positiveSafeInteger(value: unknown): value is number {
88
90
  }
89
91
 
90
92
  function requirement(key: (typeof KEYS)[number]): string {
93
+ if (key === "nerdFontIcons") return "nerdFontIcons must be a boolean";
91
94
  if (key === "subagentMode") return "subagentMode must be off, opportunistic or orchestration";
92
95
  if (key === "widgetMode") return "widgetMode must be full or minimal";
93
96
  if (key === "toolFiltering") return "toolFiltering must be allowed, all-except-blocked or all";
@@ -122,6 +125,11 @@ function parseSettings(content: string): Partial<ManagerSettings> {
122
125
  for (const key of KEYS) {
123
126
  if (!Object.hasOwn(record, key)) continue;
124
127
  const value = record[key];
128
+ if (key === "nerdFontIcons") {
129
+ if (typeof value !== "boolean") throw new Error(requirement(key));
130
+ layer.nerdFontIcons = value;
131
+ continue;
132
+ }
125
133
  if (key === "subagentMode") {
126
134
  if (!SUBAGENT_MODES.includes(value as SubagentMode)) throw new Error(requirement(key));
127
135
  layer.subagentMode = value as SubagentMode;
@@ -166,7 +174,7 @@ function layer(base: string, segments: string[]): SettingsLayer {
166
174
  return { filePath: join(current, "settings.json"), directories };
167
175
  }
168
176
 
169
- function readLayer(entry: SettingsLayer): Partial<ManagerSettings> | undefined {
177
+ function readLayerContent(entry: SettingsLayer): string | undefined {
170
178
  for (const directory of entry.directories) {
171
179
  const stat = assertNotSymlinkPath(directory);
172
180
  if (!stat) return undefined;
@@ -177,7 +185,47 @@ function readLayer(entry: SettingsLayer): Partial<ManagerSettings> | undefined {
177
185
  if (!stat) return undefined;
178
186
  if (!stat.isFile())
179
187
  throw new Error(`Settings must be a regular file: ${entry.filePath}`);
180
- return parseSettings(readFileSync(entry.filePath, "utf8"));
188
+ return readFileSync(entry.filePath, "utf8");
189
+ }
190
+
191
+ function readLayer(entry: SettingsLayer): Partial<ManagerSettings> | undefined {
192
+ const content = readLayerContent(entry);
193
+ return content === undefined ? undefined : parseSettings(content);
194
+ }
195
+
196
+ export type ManagerSaveScope = "user" | "project";
197
+
198
+ function uiStateLayer(agentDir: string): SettingsLayer {
199
+ const entry = layer(agentDir, ["subagent-manager"]);
200
+ return { ...entry, filePath: join(dirname(entry.filePath), "ui-state.json") };
201
+ }
202
+
203
+ /** UI preference only: never participates in manager-settings precedence. */
204
+ export function loadManagerSaveScope(options: {
205
+ agentDir: string;
206
+ includeProject: boolean;
207
+ }): ManagerSaveScope {
208
+ if (!options.includeProject) return "user";
209
+ try {
210
+ const content = readLayerContent(uiStateLayer(options.agentDir));
211
+ if (content !== undefined) {
212
+ const state: unknown = JSON.parse(content);
213
+ if (
214
+ state && typeof state === "object" && !Array.isArray(state) &&
215
+ "saveScope" in state && state.saveScope === "user"
216
+ ) return "user";
217
+ }
218
+ } catch {
219
+ // Missing, invalid or unsafe UI state must not prevent opening settings.
220
+ }
221
+ return "project";
222
+ }
223
+
224
+ export function saveManagerSaveScope(agentDir: string, scope: ManagerSaveScope): void {
225
+ if (scope !== "user" && scope !== "project") throw new Error("Invalid settings scope");
226
+ const entry = uiStateLayer(agentDir);
227
+ ensureScopeDirectories(entry.directories);
228
+ writeAtomically(entry, `${JSON.stringify({ saveScope: scope }, null, 2)}\n`);
181
229
  }
182
230
 
183
231
  function detail(error: unknown): string {
package/src/types.ts CHANGED
@@ -14,6 +14,8 @@ export interface AgentType {
14
14
  thinkingLevel?: ThinkingLevel;
15
15
  /** Pi semantic token for the type pill background and task path foreground. */
16
16
  color?: string;
17
+ /** Optional literal Nerd Font glyph; displayed only when the labs setting is enabled. */
18
+ icon?: string;
17
19
  tools?: { allow?: string[]; block?: string[] };
18
20
  systemPrompt: string;
19
21
  filePath?: string;
@@ -26,6 +28,7 @@ export interface ThreadView {
26
28
  owner: string;
27
29
  type: string;
28
30
  color?: string;
31
+ icon?: string;
29
32
  state: ThreadState;
30
33
  task: string;
31
34
  status: string;
@@ -118,6 +121,7 @@ export interface SavedThreadView {
118
121
  owner: string;
119
122
  type: string;
120
123
  color?: string;
124
+ icon?: string;
121
125
  state: ThreadState;
122
126
  task: string;
123
127
  status: string;
@@ -1,6 +1,7 @@
1
1
  import type { AgentMessage } from "@earendil-works/pi-agent-core";
2
2
  import { getMarkdownTheme, type Theme } from "@earendil-works/pi-coding-agent";
3
3
  import {
4
+ Input,
4
5
  Key,
5
6
  Markdown,
6
7
  matchesKey,
@@ -12,6 +13,7 @@ import {
12
13
  } from "@earendil-works/pi-tui";
13
14
  import type { ThreadService, TranscriptSnapshot } from "../types.ts";
14
15
  import { dialogText, type DialogHost } from "./dialog.ts";
16
+ import { agentTypeLabel } from "./ui.ts";
15
17
 
16
18
  export interface AgentViewportState {
17
19
  scrollTop: number;
@@ -50,7 +52,7 @@ function json(value: unknown): string {
50
52
  }
51
53
  }
52
54
 
53
- /** Read-only observer. Never invoke watched tools' custom renderers or pass through raw controls. */
55
+ /** Live transcript and manual steering. Never invoke tools' custom renderers or pass through raw controls. */
54
56
  export class LiveAgentView {
55
57
  private snapshot: TranscriptSnapshot | undefined;
56
58
  private error: string | undefined;
@@ -62,6 +64,14 @@ export class LiveAgentView {
62
64
  private scroll: ScrollView;
63
65
  private content: string[] = [];
64
66
  private restoreViewport = true;
67
+ private input = new Input({ prompt: "Steer > " });
68
+ private editing = true;
69
+ private focusedState = true;
70
+ private pasting = false;
71
+ private pasteTail = "";
72
+ private sending = false;
73
+ private steerStatus: string | undefined;
74
+ private steerFailed = false;
65
75
 
66
76
  constructor(
67
77
  private host: DialogHost,
@@ -70,14 +80,63 @@ export class LiveAgentView {
70
80
  readonly path: string,
71
81
  private viewport: AgentViewportState,
72
82
  private done: (result: "back" | "main") => void,
83
+ private nerdFontIcons = false,
73
84
  ) {
74
85
  this.scroll = new ScrollView(
75
86
  { render: () => this.content, invalidate() {} },
76
87
  { follow: "end", overscroll: "contain", scrollbar: "hidden" },
77
88
  );
89
+ this.input.focused = true;
90
+ this.input.onSubmit = (value) => void this.steer(value);
78
91
  void this.attach();
79
92
  }
80
93
 
94
+ get focused(): boolean {
95
+ return this.focusedState;
96
+ }
97
+
98
+ set focused(value: boolean) {
99
+ this.focusedState = value;
100
+ this.input.focused = value && this.editing;
101
+ }
102
+
103
+ private async steer(value: string): Promise<void> {
104
+ const message = dialogText(value);
105
+ if (this.disposed || this.sending || !message.trim()) return;
106
+ this.sending = true;
107
+ this.steerFailed = false;
108
+ this.steerStatus = "Sending steering…";
109
+ this.host.requestRender();
110
+ try {
111
+ // Same root-scoped service as the Actions menu: queues a running turn or resumes a settled one.
112
+ await this.service.steer(this.path, message);
113
+ if (this.disposed) return;
114
+ if (this.input.getValue() === message) this.input.setValue("");
115
+ this.steerStatus = "Steering sent";
116
+ } catch (error) {
117
+ if (this.disposed) return;
118
+ this.steerFailed = true;
119
+ this.steerStatus = `Steering failed: ${error instanceof Error ? error.message : String(error)}`;
120
+ } finally {
121
+ this.sending = false;
122
+ if (!this.disposed) this.host.requestRender();
123
+ }
124
+ }
125
+
126
+ private editInput(data: string): void {
127
+ // Keep paste chunks (including embedded Esc, Tab and Enter) out of navigation shortcuts.
128
+ const pasteData = this.pasteTail + data;
129
+ if (pasteData.includes("\x1b[200~")) this.pasting = true;
130
+ if (pasteData.includes("\x1b[201~")) this.pasting = false;
131
+ this.pasteTail = this.pasting ? pasteData.slice(-5) : "";
132
+ const before = this.input.getValue();
133
+ this.input.handleInput(data);
134
+ const safe = dialogText(this.input.getValue());
135
+ if (safe !== this.input.getValue()) this.input.setValue(safe);
136
+ if (safe !== before && !this.sending) this.steerStatus = undefined;
137
+ this.host.requestRender();
138
+ }
139
+
81
140
  private async attach(): Promise<void> {
82
141
  const attachment = ++this.attachment;
83
142
  this.unsubscribe?.();
@@ -130,6 +189,7 @@ export class LiveAgentView {
130
189
 
131
190
  invalidate(): void {
132
191
  this.cache = new WeakMap();
192
+ this.input.invalidate();
133
193
  }
134
194
 
135
195
  dispose(): void {
@@ -144,28 +204,42 @@ export class LiveAgentView {
144
204
 
145
205
  handleInput(data: string): void {
146
206
  if (this.disposed) return;
207
+ if (this.pasting || (this.editing && data.includes("\x1b[200~"))) {
208
+ this.editInput(data);
209
+ return;
210
+ }
147
211
  if (matchesKey(data, Key.escape)) return this.done("back");
148
212
  if (matchesKey(data, Key.ctrl("q")) || matchesKey(data, Key.ctrl("c")))
149
213
  return this.done("main");
150
- if (data === "r" && this.error) {
214
+ if (matchesKey(data, Key.tab)) {
215
+ this.editing = !this.editing;
216
+ this.input.focused = this.focused && this.editing;
217
+ this.host.requestRender();
218
+ return;
219
+ }
220
+ if (this.error && (matchesKey(data, Key.ctrl("r")) || (!this.editing && data === "r"))) {
151
221
  void this.attach();
152
222
  return;
153
223
  }
154
- if (data === "c") {
155
- this.viewport.showInherited = !this.viewport.showInherited;
156
- this.invalidate();
157
- } else if (data === "t") {
158
- this.viewport.showThinking = !this.viewport.showThinking;
159
- this.invalidate();
160
- } else if (matchesKey(data, Key.up)) this.scroll.scrollBy(-1);
224
+ // Transcript scrolling remains available while composing; Home/End edit the input.
225
+ if (matchesKey(data, Key.up)) this.scroll.scrollBy(-1);
161
226
  else if (matchesKey(data, Key.down)) this.scroll.scrollBy(1);
162
227
  else if (matchesKey(data, Key.pageUp))
163
228
  this.scroll.scrollBy(-Math.max(1, this.scroll.viewportHeight));
164
229
  else if (matchesKey(data, Key.pageDown))
165
230
  this.scroll.scrollBy(Math.max(1, this.scroll.viewportHeight));
166
- else if (matchesKey(data, Key.home)) this.scroll.scrollTo(0, { disableFollow: true });
231
+ else if (this.editing) {
232
+ this.editInput(data);
233
+ return;
234
+ } else if (data === "c") {
235
+ this.viewport.showInherited = !this.viewport.showInherited;
236
+ this.invalidate();
237
+ } else if (data === "t") {
238
+ this.viewport.showThinking = !this.viewport.showThinking;
239
+ this.invalidate();
240
+ } else if (matchesKey(data, Key.home)) this.scroll.scrollTo(0, { disableFollow: true });
167
241
  else if (matchesKey(data, Key.end) || data === "l") this.scroll.scrollToEnd();
168
- else return; // Read-only: text/Enter never routes into either agent's editor.
242
+ else return;
169
243
  this.saveViewport();
170
244
  this.host.requestRender();
171
245
  }
@@ -278,14 +352,14 @@ export class LiveAgentView {
278
352
  const header = this.theme.fg(
279
353
  "accent",
280
354
  dialogText(
281
- `${this.path} · ${thread?.type ?? "agent"} · ${thread?.state ?? "attaching"} — Watching — main continues`,
355
+ `${this.path} · ${agentTypeLabel(thread?.type ?? "agent", thread?.icon, this.nerdFontIcons)} · ${thread?.state ?? "attaching"} — Watching — main continues`,
282
356
  ),
283
357
  );
284
358
  const body: string[] = [];
285
359
  if (this.error)
286
360
  body.push(
287
361
  this.theme.fg("error", dialogText(`Attachment error: ${this.error}`)),
288
- "r Retry · Esc Back · Ctrl+Q Back to main",
362
+ "Ctrl+R Retry · Esc Back · Ctrl+Q Back to main",
289
363
  );
290
364
  if (!snapshot) {
291
365
  if (!this.error) body.push("Attaching to retained live session…");
@@ -333,7 +407,7 @@ export class LiveAgentView {
333
407
  );
334
408
  }
335
409
  this.content = body;
336
- const bodyHeight = Math.max(0, height - 3);
410
+ const bodyHeight = Math.max(0, height - 4);
337
411
  this.scroll.updateLayout(body.length, bodyHeight, () => this.scheduleRender());
338
412
  if (this.restoreViewport) {
339
413
  if (this.viewport.follow) this.scroll.scrollToEnd();
@@ -346,28 +420,28 @@ export class LiveAgentView {
346
420
  while (visible.length < bodyHeight) visible.push("");
347
421
  this.saveViewport();
348
422
  const footer = this.error
349
- ? "r Retry · Esc Back · Ctrl+Q Back to main"
350
- : `Esc tree · Ctrl+Q Back to main · ↑↓/PgUp/PgDn scroll · End latest · c context · t thinking · ${this.viewport.follow ? "following" : "scrolled"}`;
423
+ ? "Ctrl+R Retry · Tab input/transcript · Esc tree · Ctrl+Q main"
424
+ : `${this.editing ? "Enter steer · Tab browse" : "Tab steer · Home/End scroll · c context · t thinking"} · Esc tree · Ctrl+Q main · ↑↓/PgUp/PgDn scroll · ${this.viewport.follow ? "following" : "scrolled"}`;
425
+ const input = this.input.render(columns)[0]!;
426
+ const status = this.theme.fg(
427
+ this.steerStatus ? (this.steerFailed ? "error" : "muted") : this.error ? "error" : "muted",
428
+ dialogText(
429
+ this.steerStatus ??
430
+ (this.error
431
+ ? `Attachment error: ${this.error}`
432
+ : thread
433
+ ? `${thread.task} · ${thread.status}`
434
+ : "Live transcript · Enter to steer"),
435
+ ),
436
+ );
351
437
  const lines =
352
438
  height === 1
353
- ? [header]
439
+ ? [input]
354
440
  : height === 2
355
- ? [header, this.theme.fg("dim", footer)]
356
- : [
357
- header,
358
- this.theme.fg(
359
- this.error ? "error" : "muted",
360
- dialogText(
361
- this.error
362
- ? `Attachment error: ${this.error}`
363
- : thread
364
- ? `${thread.task} · ${thread.status}`
365
- : "Read-only observer",
366
- ),
367
- ),
368
- ...visible,
369
- this.theme.fg("dim", footer),
370
- ];
441
+ ? [header, input]
442
+ : height === 3
443
+ ? [header, this.theme.fg("dim", footer), input]
444
+ : [header, status, ...visible, this.theme.fg("dim", footer), input];
371
445
  return fillViewport(lines, width, height);
372
446
  }
373
447
  }
@@ -8,6 +8,8 @@ import {
8
8
  } from "./dialog.ts";
9
9
  import {
10
10
  DEFAULT_MANAGER_SETTINGS,
11
+ loadManagerSaveScope,
12
+ saveManagerSaveScope,
11
13
  saveManagerSettings,
12
14
  type ManagerSettings,
13
15
  type ModelSelectionMode,
@@ -150,7 +152,10 @@ async function configureAgentsDialog(
150
152
  },
151
153
  ): Promise<void> {
152
154
  let draft = { ...options.settings };
153
- let scope: "user" | "project" = ctx.isProjectTrusted() ? "project" : "user";
155
+ let scope = loadManagerSaveScope({
156
+ agentDir: options.agentDir,
157
+ includeProject: ctx.isProjectTrusted(),
158
+ });
154
159
  let selectedId: string | undefined;
155
160
  while (true) {
156
161
  const dirty = JSON.stringify(draft) !== JSON.stringify(options.settings);
@@ -186,11 +191,17 @@ async function configureAgentsDialog(
186
191
  value: WIDGET_MODE_OPTIONS.find((mode) => mode.id === draft.widgetMode)!.label,
187
192
  help: WIDGET_MODE_HELP,
188
193
  },
194
+ {
195
+ id: "nerdFontIcons",
196
+ label: "[labs] Nerd Font icons",
197
+ value: draft.nerdFontIcons ? "On" : "Off",
198
+ help: "Experimental: display each agent type’s optional icon.\nRequires a Nerd Font configured in your terminal; otherwise glyphs may appear as boxes.\nOff by default. Save and apply to update the widget immediately.",
199
+ },
189
200
  {
190
201
  id: "scope",
191
202
  label: "Save scope",
192
203
  value: scope === "user" ? "Global" : "Current Project",
193
- help: "Global: save all values shown as your defaults for every project. Existing project settings still override them, including here.\nCurrent Project: save all values shown for this project only, overriding your global defaults here. Other projects are unchanged. Requires a trusted project.\nSwitching scope only changes where you save, not the values shown.",
204
+ help: "Global: save all values shown as your defaults for every project. Existing project settings still override them, including here.\nCurrent Project: save all values shown for this project only, overriding your global defaults here. Other projects are unchanged. Requires a trusted project.\nSwitching scope only changes where you save, not the values shown. Your choice is remembered across projects and restarts, even if you cancel.",
194
205
  },
195
206
  {
196
207
  id: "types",
@@ -267,16 +278,22 @@ async function configureAgentsDialog(
267
278
  });
268
279
  if (WIDGET_MODE_OPTIONS.some((option) => option.id === mode))
269
280
  draft.widgetMode = mode as WidgetMode;
281
+ } else if (action === "nerdFontIcons") {
282
+ draft.nerdFontIcons = !draft.nerdFontIcons;
270
283
  } else if (action === "scope") {
271
284
  if (!ctx.isProjectTrusted())
272
285
  ctx.ui.notify(
273
286
  "Project settings require a trusted project; saving globally.",
274
287
  "warning",
275
288
  );
276
- else scope = scope === "user" ? "project" : "user";
289
+ else {
290
+ const nextScope = scope === "user" ? "project" : "user";
291
+ saveManagerSaveScope(options.agentDir, nextScope);
292
+ scope = nextScope;
293
+ }
277
294
  } else if (action === "defaults") draft = { ...DEFAULT_MANAGER_SETTINGS };
278
295
  else if (action === "types") {
279
- await editAgentTypes(ctx, options.store);
296
+ await editAgentTypes(ctx, options.store, draft.nerdFontIcons);
280
297
  options.store.reload();
281
298
  } else if (action === "save") {
282
299
  const file = saveManagerSettings({
@@ -25,7 +25,7 @@ import {
25
25
  } from "./dialog.ts";
26
26
  import type { ThreadService } from "../types.ts";
27
27
  import { buildStatusTree, type StatusRow } from "./thread-tree.ts";
28
- import { agentTypeBadge, showThreads, threadMetrics } from "./ui.ts";
28
+ import { agentTypeBadge, agentTypeLabel, showThreads, threadMetrics } from "./ui.ts";
29
29
  import { LiveAgentView, fillViewport, type AgentViewportState } from "./live-agent-view.ts";
30
30
 
31
31
  export { buildStatusTree, type StatusRow };
@@ -104,6 +104,7 @@ export class StatusDialog {
104
104
  actions(path: string): void;
105
105
  fullscreen?: boolean;
106
106
  },
107
+ private nerdFontIcons = false,
107
108
  ) {
108
109
  this.state = navigation?.state ?? { selectedPath: selected || ROOT, collapsed: new Set() };
109
110
  }
@@ -238,7 +239,7 @@ export class StatusDialog {
238
239
  const status = dialogText(thread.status);
239
240
  return [
240
241
  this.theme.fg(selected ? "accent" : base, head),
241
- this.theme.fg(base, `${dialogText(thread.type)} ${path} `),
242
+ this.theme.fg(base, `${agentTypeLabel(thread.type, thread.icon, this.nerdFontIcons)} ${path} `),
242
243
  this.theme.fg(hint, state),
243
244
  this.theme.fg(base, ` ${status}`),
244
245
  ].join("");
@@ -247,8 +248,8 @@ export class StatusDialog {
247
248
  .map((part) => dialogText(part))
248
249
  .join(" ");
249
250
  if (selected)
250
- return `${this.theme.fg("accent", head)}${agentTypeBadge(thread.type, thread.color, this.theme)} ${this.theme.fg("accent", rest)}`;
251
- return `${head}${agentTypeBadge(thread.type, thread.color, this.theme)} ${rest}`;
251
+ return `${this.theme.fg("accent", head)}${agentTypeBadge(thread.type, thread.color, this.theme, thread.icon, this.nerdFontIcons)} ${this.theme.fg("accent", rest)}`;
252
+ return `${head}${agentTypeBadge(thread.type, thread.color, this.theme, thread.icon, this.nerdFontIcons)} ${rest}`;
252
253
  }
253
254
 
254
255
  private detail(row: StatusRow | undefined): string[] {
@@ -311,6 +312,7 @@ async function showAgentDialog(
311
312
  title?: string;
312
313
  selected?: string;
313
314
  inspect?: (path: string) => Promise<void>;
315
+ nerdFontIcons?: boolean;
314
316
  } = {},
315
317
  ): Promise<void> {
316
318
  const open = options.inspect ?? ((path: string) => showThreads(ctx, service, path));
@@ -321,7 +323,7 @@ async function showAgentDialog(
321
323
  let dialog: StatusDialog | undefined;
322
324
  try {
323
325
  const chosen = await ctx.ui.custom<string | undefined>((host, theme, _keys, done) => {
324
- dialog = new StatusDialog(host, theme, service, done, selected, options.title);
326
+ dialog = new StatusDialog(host, theme, service, done, selected, options.title, undefined, options.nerdFontIcons);
325
327
  dialog.startRefresh();
326
328
  return dialog;
327
329
  }, DIALOG_OPTIONS);
@@ -340,9 +342,10 @@ export async function showAgentStatus(
340
342
  ctx: ExtensionCommandContext,
341
343
  service: ThreadService,
342
344
  inspect?: (path: string) => Promise<void>,
345
+ nerdFontIcons = false,
343
346
  ): Promise<void> {
344
347
  if (!canOpenDialog(ctx)) return;
345
- await showAgentDialog(ctx, service, { inspect });
348
+ await showAgentDialog(ctx, service, { inspect, nerdFontIcons });
346
349
  }
347
350
 
348
351
  /** Root-owned navigation state. Opening and closing never changes the executing session. */
@@ -363,7 +366,7 @@ export class AgentNavigationController {
363
366
  this.session = undefined;
364
367
  }
365
368
 
366
- open(ctx: ExtensionContext, service: ThreadService, selectedPath?: string): Promise<void> {
369
+ open(ctx: ExtensionContext, service: ThreadService, selectedPath?: string, nerdFontIcons = false): Promise<void> {
367
370
  if (this.opening) return this.opening;
368
371
  if (!canOpenDialog(ctx)) return Promise.resolve();
369
372
  if (selectedPath) this.tree.selectedPath = selectedPath;
@@ -443,6 +446,7 @@ export class AgentNavigationController {
443
446
  fullscreen: true,
444
447
  actions: (path) => finish({ kind: "actions", path }),
445
448
  },
449
+ nerdFontIcons,
446
450
  );
447
451
  treeDialog.startRefresh();
448
452
  return treeDialog;
@@ -460,7 +464,7 @@ export class AgentNavigationController {
460
464
  }
461
465
  const result = await session.mount<"back" | "main">(
462
466
  (tui, activeTheme, _keys, finish) =>
463
- new LiveAgentView(tui, activeTheme, service, chosen.path, viewport!, finish),
467
+ new LiveAgentView(tui, activeTheme, service, chosen.path, viewport!, finish, nerdFontIcons),
464
468
  );
465
469
  if (result !== "back") break;
466
470
  }
@@ -505,11 +509,12 @@ export async function showAgentTree(
505
509
  ctx: ExtensionContext,
506
510
  service: ThreadService,
507
511
  selectedPath?: string,
512
+ nerdFontIcons = false,
508
513
  ): Promise<void> {
509
514
  let navigation = navigationByService.get(service);
510
515
  if (!navigation) {
511
516
  navigation = new AgentNavigationController();
512
517
  navigationByService.set(service, navigation);
513
518
  }
514
- await navigation.open(ctx, service, selectedPath);
519
+ await navigation.open(ctx, service, selectedPath, nerdFontIcons);
515
520
  }
package/src/ui/ui.ts CHANGED
@@ -89,12 +89,21 @@ function contrastPill(
89
89
  });
90
90
  }
91
91
 
92
+ /** Invalid/untrusted saved icons never reach the terminal. Names remain readable. */
93
+ export function agentTypeLabel(type: string, icon?: string, nerdFontIcons = false): string {
94
+ const prefix = nerdFontIcons && typeof icon === "string" && /^\p{Co}$/u.test(icon)
95
+ ? `${icon} ` : "";
96
+ return `${prefix}${sanitizeText(type)}`;
97
+ }
98
+
92
99
  export function agentTypeBadge(
93
100
  type: string,
94
101
  color: string | undefined,
95
102
  theme: AgentBadgeTheme,
103
+ icon?: string,
104
+ nerdFontIcons = false,
96
105
  ): string {
97
- return contrastPill(type, color, theme);
106
+ return contrastPill(agentTypeLabel(type, icon, nerdFontIcons), color, theme);
98
107
  }
99
108
 
100
109
  function agentPath(
@@ -170,6 +179,7 @@ export function renderThreads(
170
179
  threads: ThreadView[],
171
180
  width: number,
172
181
  theme: AgentBadgeTheme,
182
+ nerdFontIcons = false,
173
183
  ): string[] {
174
184
  const priority = (thread: ThreadView) =>
175
185
  thread.state === "starting" || thread.state === "running"
@@ -193,7 +203,7 @@ export function renderThreads(
193
203
  : thread.state === "paused"
194
204
  ? "warning"
195
205
  : "accent";
196
- const badge = agentTypeBadge(thread.type, thread.color, theme);
206
+ const badge = agentTypeBadge(thread.type, thread.color, theme, thread.icon, nerdFontIcons);
197
207
  const path = agentPath(thread.path, thread.color, theme);
198
208
  const state = theme.fg(stateColor, `[${sanitizeText(thread.state)}]`);
199
209
  const left = `${badge} ${path} ${state} ${sanitizeText(thread.status || thread.task)}`;
@@ -225,6 +235,7 @@ const AGENT_BROWSER_HINT = "Press ← to open subagent browser";
225
235
  interface AgentWidgetRenderOptions {
226
236
  /** RPC widgets cannot open a terminal browser. */
227
237
  showBrowserHint?: boolean;
238
+ nerdFontIcons?: boolean;
228
239
  }
229
240
 
230
241
  function agentWidgetStatus(
@@ -342,9 +353,10 @@ function agentLine(
342
353
  row: StatusRow,
343
354
  width: number,
344
355
  theme: AgentBadgeTheme,
356
+ nerdFontIcons: boolean,
345
357
  ): string {
346
358
  const thread = row.thread!;
347
- const left = `${row.prefix}${agentTypeBadge(thread.type, thread.color, theme)} ${agentPath(thread.path, thread.color, theme)} ${theme.fg(agentStateColor(thread.state), `[${sanitizeText(thread.state)}]`)} ${sanitizeText(thread.task)}`;
359
+ const left = `${row.prefix}${agentTypeBadge(thread.type, thread.color, theme, thread.icon, nerdFontIcons)} ${agentPath(thread.path, thread.color, theme)} ${theme.fg(agentStateColor(thread.state), `[${sanitizeText(thread.state)}]`)} ${sanitizeText(thread.task)}`;
348
360
  return fitLine(left, theme.fg("muted", threadMetrics(thread)), width);
349
361
  }
350
362
 
@@ -429,7 +441,7 @@ export function renderAgentTree(
429
441
  threads: ThreadView[],
430
442
  width: number,
431
443
  theme: AgentBadgeTheme,
432
- { showBrowserHint = true }: AgentWidgetRenderOptions = {},
444
+ { showBrowserHint = true, nerdFontIcons = false }: AgentWidgetRenderOptions = {},
433
445
  ): string[] {
434
446
  const columns = Math.max(0, width);
435
447
  const rows = buildStatusTree(
@@ -458,7 +470,7 @@ export function renderAgentTree(
458
470
  lines.push(placeholderLine(row, columns, theme));
459
471
  continue;
460
472
  }
461
- lines.push(agentLine(row, columns, theme));
473
+ lines.push(agentLine(row, columns, theme, nerdFontIcons));
462
474
  lines.push(activityLine(row, columns, theme));
463
475
  }
464
476
  lines.push(agentWidgetStatus(live, omitted, columns, theme, showBrowserHint));
@@ -518,18 +530,22 @@ export function updateWidget(
518
530
  ctx: ExtensionContext,
519
531
  threads: ThreadView[],
520
532
  mode: WidgetMode = "full",
533
+ nerdFontIcons = false,
534
+ rootTurnEnded = false,
521
535
  ): void {
522
536
  if (!ctx.hasUI) return;
523
537
  if (!threads.some((thread) => thread.path !== "/root")) {
524
538
  ctx.ui.setWidget("pi-subagent", undefined, AGENT_WIDGET_PLACEMENT);
525
539
  return;
526
540
  }
527
- const render = mode === "minimal" ? renderAgentSummary : renderAgentTree;
541
+ // Retain the tree while either the main turn or any subagent is still active.
542
+ const settled = rootTurnEnded && !threads.some(isLive);
543
+ const render = mode === "minimal" || settled ? renderAgentSummary : renderAgentTree;
528
544
  // RPC hosts accept string widgets only; a component factory is ignored.
529
545
  if (ctx.mode === "rpc") {
530
546
  ctx.ui.setWidget(
531
547
  "pi-subagent",
532
- render(threads, 80, ctx.ui.theme, { showBrowserHint: false }),
548
+ render(threads, 80, ctx.ui.theme, { showBrowserHint: false, nerdFontIcons }),
533
549
  AGENT_WIDGET_PLACEMENT,
534
550
  );
535
551
  return;
@@ -544,7 +560,10 @@ export function updateWidget(
544
560
  timer.unref();
545
561
  }
546
562
  return {
547
- render: (width) => render(snapshot, width, ctx.ui.theme),
563
+ render: (width) => render(snapshot, width, ctx.ui.theme, {
564
+ showBrowserHint: !settled,
565
+ nerdFontIcons,
566
+ }),
548
567
  invalidate: () => {},
549
568
  dispose: () => {
550
569
  if (timer) clearInterval(timer);
@@ -981,6 +1000,7 @@ const EDIT_MENU_ACTIONS = [
981
1000
  "tools.allow",
982
1001
  "tools.block",
983
1002
  "color",
1003
+ "icon",
984
1004
  "systemPrompt",
985
1005
  "Save scope",
986
1006
  "Source",
@@ -1001,6 +1021,7 @@ const EDIT_FIELD_LABELS: Record<EditMenuAction, string> = {
1001
1021
  "tools.allow": "Allowed tools",
1002
1022
  "tools.block": "Blocked tools",
1003
1023
  color: "Color",
1024
+ icon: "[labs] Icon",
1004
1025
  systemPrompt: "System prompt",
1005
1026
  "Save scope": "Save scope",
1006
1027
  Source: "Source (read-only)",
@@ -1022,6 +1043,7 @@ const EDIT_FIELD_HELP: Record<EditMenuAction, string> = {
1022
1043
  "Unset uses default policy; an empty list explicitly allows no tools.",
1023
1044
  "tools.block": "Exact tool names to remove from the allowed set.",
1024
1045
  color: "Thread widget color with live preview.",
1046
+ 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.",
1025
1047
  systemPrompt: "Edit the Markdown prompt body in a multiline dialog.",
1026
1048
  "Save scope":
1027
1049
  "Project definitions override global definitions with the same name.",
@@ -1088,6 +1110,8 @@ function editMenuLabel(action: EditMenuAction, draft: AgentType): string {
1088
1110
  return `tools.block: ${sanitizeText(toolListMenuValue(draft.tools?.block))}`;
1089
1111
  case "color":
1090
1112
  return `color: ${sanitizeText(draft.color ?? "Default (inherit)")}`;
1113
+ case "icon":
1114
+ return `icon: ${draft.icon ? "Configured" : "None"}`;
1091
1115
  case "systemPrompt":
1092
1116
  return `systemPrompt: ${draft.systemPrompt.split("\n").length} lines · ${draft.systemPrompt.length} characters`;
1093
1117
  default:
@@ -1098,14 +1122,16 @@ function editMenuLabel(action: EditMenuAction, draft: AgentType): string {
1098
1122
  export async function editAgentTypes(
1099
1123
  ctx: ExtensionCommandContext,
1100
1124
  store: ConfigStore,
1125
+ nerdFontIcons = false,
1101
1126
  ): Promise<void> {
1102
1127
  if (!canOpenDialog(ctx)) return;
1103
- await withDialogSession(ctx, (scoped) => editAgentTypesDialog(scoped, store));
1128
+ await withDialogSession(ctx, (scoped) => editAgentTypesDialog(scoped, store, nerdFontIcons));
1104
1129
  }
1105
1130
 
1106
1131
  async function editAgentTypesDialog(
1107
1132
  ctx: ExtensionCommandContext,
1108
1133
  store: ConfigStore,
1134
+ nerdFontIcons: boolean,
1109
1135
  ): Promise<void> {
1110
1136
  while (true) {
1111
1137
  const types = store.list();
@@ -1119,7 +1145,7 @@ async function editAgentTypesDialog(
1119
1145
  ...types.map((type) => ({
1120
1146
  id: type.name,
1121
1147
  label: type.name,
1122
- renderLabel: (label: string, theme: Theme) => agentTypeBadge(label, type.color, theme),
1148
+ renderLabel: (label: string, theme: Theme) => agentTypeBadge(label, type.color, theme, type.icon, nerdFontIcons),
1123
1149
  value: type.description,
1124
1150
  help: `${type.source ?? "user"} · ${type.filePath ?? ""}`,
1125
1151
  })),
@@ -1157,9 +1183,11 @@ async function editAgentTypesDialog(
1157
1183
  ? saveScope === "user"
1158
1184
  ? "Global"
1159
1185
  : "Trusted project"
1160
- : separator >= 0
1161
- ? decorated.slice(separator + 2)
1162
- : "",
1186
+ : action === "icon" && nerdFontIcons && draft.icon
1187
+ ? draft.icon
1188
+ : separator >= 0
1189
+ ? decorated.slice(separator + 2)
1190
+ : "",
1163
1191
  help:
1164
1192
  action === "Source"
1165
1193
  ? (original?.filePath ??
@@ -1234,6 +1262,12 @@ async function editAgentTypesDialog(
1234
1262
  value === prefill || value === prefill.trim()
1235
1263
  ? originalValue
1236
1264
  : value;
1265
+ } else if (field === "icon") {
1266
+ const value = await dialogEditor(ctx, "Agent icon (Nerd Font glyph; blank to remove)", candidate.icon ?? "");
1267
+ if (value === undefined) continue;
1268
+ const icon = value.trim();
1269
+ if (!icon) delete candidate.icon;
1270
+ else candidate.icon = icon;
1237
1271
  } else if (field === "models") {
1238
1272
  const value = await editModelPreferences(
1239
1273
  ctx,