@maheidem/pi-delegate 0.8.0 → 0.10.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.
@@ -2,7 +2,11 @@
2
2
  * delegate — child process + RPC lifecycle for one foreground run.
3
3
  *
4
4
  * Owns exactly one child `pi` process per run (FR-007, POL-007): owned,
5
- * tracked, killable; never detached or unref'd. The task travels over RPC
5
+ * tracked, killable; never detached. Safety timers (hard, inactivity,
6
+ * handoffSettle, killEscalate, handoffGrace, handoffEnforce) are NOT unref'd
7
+ * so they can always fire before exit; only the progress heartbeat
8
+ * (background runs) is unref'd — it is the sole detached timer and may never
9
+ * keep the process alive on its own. The task travels over RPC
6
10
  * stdin, never argv (POL-004). The full stdout capture and stderr stay on
7
11
  * disk; only a bounded handoff + diagnostics return to the caller
8
12
  * (FR-013/FR-014).
@@ -12,11 +16,13 @@ import * as childProcess from "node:child_process";
12
16
  import * as fs from "node:fs";
13
17
  import * as path from "node:path";
14
18
  import type {
19
+ ChildLiveState,
15
20
  DelegateDisplayItem,
16
21
  DelegateError,
17
22
  DelegateErrorCode,
18
23
  DelegateRole,
19
24
  DelegateUsage,
25
+ ResolvedChildConfig,
20
26
  RunState,
21
27
  RunTerminalState,
22
28
  RunHooks,
@@ -140,6 +146,37 @@ export interface RunnerSpawnRequest {
140
146
  /** R17: ask budget (env to the child; 0/undefined disables ask_parent). */
141
147
  askTimeoutMs?: number;
142
148
  askMaxQuestions?: number;
149
+ /** Resolved child configuration (project overlay + per-invocation + parent). */
150
+ childConfig?: ResolvedChildConfig;
151
+ }
152
+
153
+ /**
154
+ * Explicit env allowlist for the untrusted child: only PATH, HOME, TMPDIR,
155
+ * LANG/LC_*, TERM, USER (plus XDG_*) and the PI_DELEGATE_* contract vars.
156
+ * Everything else the parent has (API keys, tokens, cloud creds) is dropped.
157
+ */
158
+ export function buildChildEnv(req: RunnerSpawnRequest, askEnabled: boolean): NodeJS.ProcessEnv {
159
+ const env: NodeJS.ProcessEnv = {};
160
+ for (const [key, value] of Object.entries(process.env)) {
161
+ if (value === undefined) continue;
162
+ if (
163
+ key === "PATH" || key === "HOME" || key === "TMPDIR" || key === "TERM" || key === "USER" ||
164
+ key === "LANG" || key.startsWith("LC_") || key.startsWith("XDG_")
165
+ ) {
166
+ env[key] = value;
167
+ }
168
+ }
169
+ env.PATH = env.PATH ?? "/usr/local/bin:/usr/bin:/bin";
170
+ env.PI_DELEGATE_CHILD = "1";
171
+ env.PI_DELEGATE_RUN_ID = req.runId;
172
+ env.PI_DELEGATE_PARENT_PID = String(process.pid);
173
+ if (askEnabled) {
174
+ env.PI_DELEGATE_BACKGROUND = "1";
175
+ env.PI_DELEGATE_ASK_DIR = req.askDir;
176
+ env.PI_DELEGATE_ASK_TIMEOUT_MS = String(req.askTimeoutMs);
177
+ env.PI_DELEGATE_ASK_MAX = String(req.askMaxQuestions ?? 5);
178
+ }
179
+ return env;
143
180
  }
144
181
 
145
182
  export function buildChildArgs(
@@ -150,7 +187,15 @@ export function buildChildArgs(
150
187
  // ceiling; the delegate extension registers it in child mode. Background
151
188
  // children (R17/R18) also get ask_parent when the ask channel is enabled.
152
189
  const askEnabled = Boolean(req.background && req.askDir && req.askTimeoutMs && req.askTimeoutMs > 0);
153
- const toolList = [...role.tools, "handoff", ...(askEnabled ? ["ask_parent"] : [])].join(",");
190
+ const child = req.childConfig;
191
+ // Resolved configuration: per-invocation > project overlay > parent.
192
+ const model = child?.model?.trim() || req.parentModel;
193
+ const thinking = child?.thinking?.trim() || req.thinkingLevel;
194
+ // Tool ceiling: the project's child.tools allowlist (intersected with the
195
+ // registered parent tools by the resolver) replaces the role's tools;
196
+ // otherwise the role ceiling applies. handoff is always mandatory.
197
+ const roleTools = child?.tools !== undefined ? [...child.tools] : [...role.tools];
198
+ const toolList = [...new Set([...roleTools, "handoff", ...(askEnabled ? ["ask_parent"] : [])])].join(",");
154
199
  // R3: the child's session is DURABLE. New runs persist it under the run
155
200
  // store (--session-dir); resumed runs re-enter the prior session file
156
201
  // directly (--session <file>) so a killed run can be continued in the
@@ -161,27 +206,19 @@ export function buildChildArgs(
161
206
  const args: string[] = [
162
207
  "--mode", "rpc",
163
208
  ...sessionArgs,
164
- "--model", req.parentModel,
209
+ "--model", model,
165
210
  ];
166
- if (req.thinkingLevel) args.push("--thinking", req.thinkingLevel);
211
+ if (thinking) args.push("--thinking", thinking);
167
212
  args.push("--tools", toolList);
168
- args.push("--no-skills", "--no-prompt-templates", "--no-themes");
213
+ // standard context (the default) keeps the child's skills, prompt
214
+ // templates and themes — only an explicit child.context: "minimal" disables them.
215
+ if ((child?.context ?? "standard") === "minimal") {
216
+ args.push("--no-skills", "--no-prompt-templates", "--no-themes");
217
+ }
169
218
  args.push("--append-system-prompt", role.promptPath);
170
- args.push(req.projectTrusted ? "--approve" : "--no-approve");
171
- const env: NodeJS.ProcessEnv = {
172
- ...process.env,
173
- PI_DELEGATE_CHILD: "1",
174
- PI_DELEGATE_RUN_ID: req.runId,
175
- PI_DELEGATE_PARENT_PID: String(process.pid),
176
- ...(askEnabled
177
- ? {
178
- PI_DELEGATE_BACKGROUND: "1",
179
- PI_DELEGATE_ASK_DIR: req.askDir,
180
- PI_DELEGATE_ASK_TIMEOUT_MS: String(req.askTimeoutMs),
181
- PI_DELEGATE_ASK_MAX: String(req.askMaxQuestions ?? 5),
182
- }
183
- : {}),
184
- };
219
+ const trust = child?.trustProject ?? req.projectTrusted;
220
+ args.push(trust ? "--approve" : "--no-approve");
221
+ const env = buildChildEnv(req, askEnabled);
185
222
  return { args, env, promptId: `delegate:${req.runId}:prompt` };
186
223
  }
187
224
 
@@ -351,6 +388,12 @@ export class DelegateRunner {
351
388
  private readonly promptId: string;
352
389
  /** R16: steering sequence (follow_up record ids). */
353
390
  private steerSeq = 0;
391
+ /** get_state request sequence (state record ids). */
392
+ private stateSeq = 0;
393
+ /** get_state ids we sent and are waiting on (stale ids are ignored). */
394
+ private pendingStateIds = new Set<string>();
395
+ /** Cached live child state from the last answered get_state (best-effort). */
396
+ private liveChildState: ChildLiveState | undefined;
354
397
  /** R23: progress-report throttle state + heartbeat timer. */
355
398
  private progressState: ProgressThrottleState = { reportsSent: 0, lastReportAt: 0, startedMs: 0 };
356
399
  private progressTimer: NodeJS.Timeout | null = null;
@@ -376,6 +419,32 @@ export class DelegateRunner {
376
419
  return this.child?.pid;
377
420
  }
378
421
 
422
+ /**
423
+ * Host/TUI hook: ask the live child for its current state (get_state RPC).
424
+ * Best-effort: no child, a finished run, or a failed write simply no-ops.
425
+ * The answer is correlated by id and cached; stale ids are ignored.
426
+ */
427
+ requestChildState(): void {
428
+ if (this.finalizing || this.cancelRequested || this.settled) return;
429
+ const child = this.child;
430
+ if (!child || child.killed || child.exitCode !== null) return;
431
+ this.stateSeq += 1;
432
+ const id = `delegate:${this.runId}:state:${this.stateSeq}`;
433
+ if (this.pendingStateIds.size >= 20) this.pendingStateIds.clear();
434
+ this.pendingStateIds.add(id);
435
+ try {
436
+ child.stdin?.write(`${JSON.stringify({ id, type: "get_state" })}\n`);
437
+ this.noteActivity();
438
+ } catch {
439
+ this.pendingStateIds.delete(id);
440
+ }
441
+ }
442
+
443
+ /** Cached live child state from the last answered get_state (undefined until answered). */
444
+ getChildState(): ChildLiveState | undefined {
445
+ return this.liveChildState;
446
+ }
447
+
379
448
  /** Spawn and drive the run to a terminal state. */
380
449
  async run(): Promise<RunnerOutcome> {
381
450
  const { metadata, paths, stdout, stderr } = this.opened;
@@ -475,7 +544,6 @@ export class DelegateRunner {
475
544
  // Timers: inactivity (reset by activity) + hard (from spawn).
476
545
  this.armInactivity();
477
546
  this.hardTimer = setTimeout(() => this.cancel("timed_out_hard"), this.cfg.hardTimeoutMs);
478
- this.hardTimer.unref();
479
547
 
480
548
  // R23: progress-report heartbeat (background runs only — the hook is
481
549
  // wired solely by the background spawn path).
@@ -546,7 +614,6 @@ export class DelegateRunner {
546
614
  ? this.cfg.stuckToolTimeoutMs ?? this.cfg.hardTimeoutMs
547
615
  : this.cfg.inactivityTimeoutMs;
548
616
  this.inactivityTimer = setTimeout(() => this.cancel("timed_out_idle"), budget);
549
- this.inactivityTimer.unref();
550
617
  }
551
618
 
552
619
  private handleRecord(record: RpcRecord): void {
@@ -581,6 +648,13 @@ export class DelegateRunner {
581
648
  }
582
649
  const cls = classifyRpcRecord(record);
583
650
  switch (cls.kind) {
651
+ case "state_response":
652
+ // get_state answer — correlated by id; stale/unknown ids ignored.
653
+ if (cls.id && this.pendingStateIds.has(cls.id)) {
654
+ this.pendingStateIds.delete(cls.id);
655
+ if (cls.ok) this.liveChildState = cls.state;
656
+ }
657
+ break;
584
658
  case "prompt_response":
585
659
  if (cls.id === this.promptId || cls.id === "") {
586
660
  if (cls.ok) {
@@ -855,7 +929,6 @@ export class DelegateRunner {
855
929
  this.handoffPhase = "none";
856
930
  this.startKillEscalation(0);
857
931
  }, stepMs);
858
- this.handoffSettleTimer.unref();
859
932
  }
860
933
 
861
934
  /** SIGTERM → killGrace → SIGKILL escalation (one shared implementation). */
@@ -877,7 +950,6 @@ export class DelegateRunner {
877
950
  }
878
951
  }, this.cfg.killGraceMs);
879
952
  }, delayMs);
880
- this.killEscalateTimer.unref();
881
953
  }
882
954
 
883
955
  /** R2: the child settled after our abort — offer it the handoff prompt. */
@@ -902,7 +974,6 @@ export class DelegateRunner {
902
974
  if (this.cancelRequested) this.finish(this.cancelRequested, undefined, this.partialHandoffExtra());
903
975
  }
904
976
  }, grace);
905
- this.handoffGraceTimer.unref();
906
977
  }
907
978
 
908
979
  /** R2: build the partial-handoff `extra`. The structured submission
@@ -1008,8 +1079,7 @@ export class DelegateRunner {
1008
1079
  this.handoffPhase = "none";
1009
1080
  this.finalizeFreeTextFallback();
1010
1081
  }, this.cfg.handoffEnforceTimeoutMs ?? 60_000);
1011
- this.handoffEnforceTimer.unref();
1012
- return; // wait for the enforcement turn to settle
1082
+ return; // wait for the enforcement turn to settle
1013
1083
  }
1014
1084
  }
1015
1085
  if (!final || !final.text.trim()) {
@@ -1133,6 +1203,8 @@ export class DelegateRunner {
1133
1203
  private finish(state: RunTerminalState, error?: DelegateError, extra?: { handoff?: string; truncated?: boolean; stopReason?: string; usage?: DelegateUsage; partialHandoff?: string }): void {
1134
1204
  if (this.finalizing) return;
1135
1205
  this.finalizing = true;
1206
+ // A terminal run can never answer get_state — drop the pending ids.
1207
+ this.pendingStateIds.clear();
1136
1208
  const finishedAt = new Date().toISOString();
1137
1209
  const durationMs = this.startedAtMs ? Date.now() - this.startedAtMs : 0;
1138
1210
  // P3: timeout/cancel terminal states are reached without an explicit
@@ -1326,7 +1398,10 @@ export class DelegateRunner {
1326
1398
  runId: this.runId,
1327
1399
  role: this.req.role.name,
1328
1400
  phase,
1329
- model: this.req.parentModel,
1401
+ // The RESOLVED child model (per-invocation > project > parent), so
1402
+ // the head/status rows can never show the parent's model for a
1403
+ // pinned child. The receipt's `model` stays the parent model.
1404
+ model: this.req.childConfig?.model?.trim() || this.req.parentModel,
1330
1405
  openTools: this.openToolNames(),
1331
1406
  elapsedMs: this.startedAtMs ? now - this.startedAtMs : 0,
1332
1407
  lastActions: this.lastActions.slice(-5),
@@ -97,6 +97,49 @@ export const EMPTY_USAGE: DelegateUsage = {
97
97
  turns: 0,
98
98
  };
99
99
 
100
+ /**
101
+ * Child configuration keys accepted by the project overlay
102
+ * (`<projectRoot>/.pi/delegate/config.json`). Validated field-by-field
103
+ * in config.ts; unknown keys are diagnosed and dropped.
104
+ */
105
+ export interface ChildConfig {
106
+ /** Resolved child model ("provider/model-id"). */
107
+ model?: string;
108
+ /** Child thinking level (e.g. "high"). Inherits the parent when absent. */
109
+ thinking?: string;
110
+ /** Tool allowlist (restricted to registered parent tools at resolution time). */
111
+ tools?: string[];
112
+ /** Approve the project trust prompt (default: inherit the parent's trust). */
113
+ trustProject?: boolean;
114
+ /** Execution context tier. "standard" (default) keeps skills/templates/themes. */
115
+ context?: "standard" | "minimal";
116
+ }
117
+
118
+ /**
119
+ * The child config as resolved for one run: every value the runner needs,
120
+ * plus where the model came from and any field-level diagnostics.
121
+ * Recorded in the receipt metadata so the resolved shape is inspectable
122
+ * after the fact.
123
+ */
124
+ export interface ResolvedChildConfig extends ChildConfig {
125
+ /** Where the resolved child model came from. */
126
+ modelSource?: "per-invocation" | "project" | "parent";
127
+ /** Execution context tier (defaults to "standard"). */
128
+ context: "standard" | "minimal";
129
+ /** Field-level diagnostics from validation/resolution (unknown tool names, dropped values). */
130
+ diagnostics?: string[];
131
+ }
132
+
133
+ /** Live child state observed from the child's `get_state` RPC response. */
134
+ export interface ChildLiveState {
135
+ /** Live child model as "provider/id" (null when the child reports no model). */
136
+ model?: string;
137
+ /** Live child thinking level (from get_state, tolerating effort aliases). */
138
+ thinking?: string;
139
+ /** Live child streaming flag. */
140
+ isStreaming?: boolean;
141
+ }
142
+
100
143
  export type RunSource = "tool" | "command";
101
144
 
102
145
  /** Project-wide config path: `<projectRoot>/.pi/delegate/config.json`. */
@@ -121,6 +164,8 @@ export interface DelegateRequest {
121
164
  projectRoot?: string;
122
165
  /** R3: resume a prior run's child session (its session file is re-entered). */
123
166
  resumeFrom?: string;
167
+ /** Resolved child config (project overlay + per-invocation + parent), filled by the adapter. */
168
+ childConfig?: ResolvedChildConfig;
124
169
  /** R8: run as a background delegation (non-blocking tool call). */
125
170
  background?: boolean;
126
171
  /** R8: 3–6-word purpose summary, required when background. */
@@ -152,6 +197,8 @@ sessionPath?: string;
152
197
  /** R22: validated 3–6-word purpose summary (required for every delegation;
153
198
  * returned inline in the foreground result header). */
154
199
  description?: string;
200
+ /** Resolved child configuration the run was launched with (receipt copy). */
201
+ childConfig?: ResolvedChildConfig;
155
202
  transcriptPath: string;
156
203
  stderrPath: string;
157
204
  displayItems: DelegateDisplayItem[];
@@ -241,6 +288,8 @@ export interface RunMetadataV1 {
241
288
  background?: boolean;
242
289
  /** R8: validated 3–6-word purpose summary (background runs). */
243
290
  description?: string;
291
+ /** Resolved child configuration this run was launched with. */
292
+ childConfig?: ResolvedChildConfig;
244
293
  }
245
294
 
246
295
  export interface TranscriptRecordV1 {
@@ -496,6 +545,12 @@ export interface DelegateApplication {
496
545
  * the terminal state. */
497
546
  runBackground(request: DelegateRequest): { error: DelegateRunResult } | { handle: BackgroundRunHandle };
498
547
  cancel(runId?: string): Promise<CancelResult>;
548
+ /** Host/TUI hooks: live-child steering + state (get_state) — all best-effort. */
549
+ requestChildState(): void;
550
+ activeRunChildState(): ChildLiveState | undefined;
551
+ steerActiveRun(message: string): { ok: true } | { ok: false; error: string };
552
+ /** The session's active foreground run id (for peek/view wiring). */
553
+ activeRunId(): string | null;
499
554
  inspect(runId?: string, includeTranscript?: boolean): RunInspection;
500
555
  doctor(): DoctorReport;
501
556
  getStatus(activeTools: string[] | "degraded", projectRoot?: string): DelegateStatus;
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Event-card — the shared "event card" block for middle-of-run informational
3
+ * messages (background progress lines, the blocked-waiting question block,
4
+ * delegate start/terminal messages). Every one of them used to render as
5
+ * bare gray text; they now get the same styled treatment as the panels:
6
+ * a rounded box on the custom-message background, a bold accent label on
7
+ * the header band, dimmed body lines. The words are unchanged — only the
8
+ * layout changes; no new text is added or removed.
9
+ *
10
+ * Pure layout (theme-driven): the pure lines function is unit-testable
11
+ * without a Pi session, and the component wrapper is the only Pi-facing
12
+ * piece. Headless fallbacks return plain text — output never disappears.
13
+ */
14
+
15
+ import { truncateToWidth, visibleWidth, type Component } from "@earendil-works/pi-tui";
16
+ import type { Theme } from "@earendil-works/pi-coding-agent";
17
+
18
+ export interface EventCardSpec {
19
+ /** Bold header line (e.g. `? background del_abc…: asks (topic)`). */
20
+ label: string;
21
+ /** Body lines, one per row, verbatim (blank lines kept as blank rows). */
22
+ bodyLines: string[];
23
+ }
24
+
25
+ /**
26
+ * Render the card body rows for `width` (never wider than `width`).
27
+ * `theme` may be undefined — headless renderers then get plain text.
28
+ * Returns `[topBorder, ...bodyRows, bottomBorder]` (or just the label when
29
+ * the width is degenerate).
30
+ */
31
+ export function eventCardLines(theme: Theme | undefined, width: number, spec: EventCardSpec): string[] {
32
+ const w = Math.max(1, Math.floor(width));
33
+ if (!theme?.fg) return [spec.label, ...spec.bodyLines];
34
+ if (w <= 2) return [truncateToWidth(spec.label, w)];
35
+
36
+ const inner = Math.max(1, w - 4); // │ + space on each side
37
+ const bgLine = (line: string): string => {
38
+ const visLen = visibleWidth(line);
39
+ const padded = visLen < w ? line + " ".repeat(w - visLen) : line;
40
+ if (theme.bg) return theme.bg("customMessageBg", truncateToWidth(padded, w));
41
+ return truncateToWidth(padded, w);
42
+ };
43
+ const borderColor = (s: string) => theme.fg("border", s);
44
+
45
+ // Header band: rounded corner + bold accent label + tail + rounded corner.
46
+ // The space between the corners is `w - 2` (not `inner`): the label lives
47
+ // on the top border line itself, not inside a side-bar row.
48
+ const label = theme.bold(theme.fg("accent", ` ${spec.label} `));
49
+ const clippedLabel = truncateToWidth(label, Math.max(1, w - 2), "", false);
50
+ const tail = "─".repeat(Math.max(0, w - 2 - visibleWidth(clippedLabel)));
51
+ const top = borderColor("╭") + clippedLabel + borderColor(tail + "╮");
52
+ const bottom = borderColor(`╰${"─".repeat(Math.max(0, w - 2))}╯`);
53
+
54
+ const rows: string[] = [bgLine(top)];
55
+ for (const line of spec.bodyLines) {
56
+ const body = theme.fg("dim", truncateToWidth(line, inner - 2));
57
+ const visLen = visibleWidth(body);
58
+ const padded = body + " ".repeat(Math.max(0, inner - visLen));
59
+ rows.push(bgLine(borderColor("│") + " " + padded + " " + borderColor("│")));
60
+ }
61
+ rows.push(bgLine(bottom));
62
+ return rows;
63
+ }
64
+
65
+ /**
66
+ * Custom-message component wrapper for the event card. Stateless; `render`
67
+ * is pure so it can be called with any width.
68
+ */
69
+ export class EventCard implements Component {
70
+ private readonly theme: Theme | undefined;
71
+ private readonly spec: EventCardSpec;
72
+
73
+ constructor(theme: Theme | undefined, spec: EventCardSpec) {
74
+ this.theme = theme;
75
+ this.spec = spec;
76
+ }
77
+
78
+ invalidate(): void {}
79
+
80
+ render(width: number): string[] {
81
+ return eventCardLines(this.theme, width, this.spec);
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Split a message's text into (label, bodyLines) — the label is the first
87
+ * line, the body is every line after it (blank separator lines kept; the
88
+ * card drops nothing). Returns undefined label/body for empty text.
89
+ */
90
+ export function eventCardSpec(text: string): EventCardSpec | undefined {
91
+ const lines = text.split("\n");
92
+ if (lines.length === 0 || lines.every((l) => l.length === 0)) return undefined;
93
+ const label = lines[0] ?? "";
94
+ const bodyLines = lines.slice(1);
95
+ return { label, bodyLines };
96
+ }
@@ -9,6 +9,7 @@ import { truncateToWidth, visibleWidth, matchesKey, type Component } from "@eare
9
9
  import type { Theme, KeybindingsManager, ThemeColor } from "@earendil-works/pi-coding-agent";
10
10
  import { frameHeight, padToFrame } from "@maheidem/pi-panel-kit";
11
11
  import type { PanelSnapshot } from "@maheidem/pi-panel-kit";
12
+ import type { ChildLiveState, ResolvedChildConfig } from "../types.ts";
12
13
 
13
14
  export interface PeekViewState {
14
15
  /** Header: run id + state/model. */
@@ -19,6 +20,10 @@ export interface PeekViewState {
19
20
  lines: string[];
20
21
  /** True while the run is still active (enables follow). */
21
22
  live: boolean;
23
+ /** Live child state from the last answered get_state (best-effort). */
24
+ childLive?: ChildLiveState;
25
+ /** The resolved pin this run was launched with (receipt copy). */
26
+ childPinned?: ResolvedChildConfig;
22
27
  }
23
28
 
24
29
  export interface PeekViewHost {
@@ -112,9 +117,26 @@ export class PeekView implements Component {
112
117
  const content = [...Array<string>(Math.max(0, CONTENT_ROWS - window.length)).fill(""), ...window];
113
118
 
114
119
  const counts = [start > 0 ? `↑${start}` : "", end < total ? `↓${total - end}` : ""].filter(Boolean).join(" ");
120
+ const childLine = ((): string => {
121
+ const live = s.childLive;
122
+ const pinned = s.childPinned;
123
+ if (live?.model) {
124
+ const parts = [`child: ${live.model}`, "(live)"];
125
+ if (live.thinking) parts.push(`thinking ${live.thinking}`);
126
+ if (live.isStreaming) parts.push("streaming");
127
+ return parts.join(" · ");
128
+ }
129
+ if (pinned?.model) {
130
+ const parts = [`child: ${pinned.model}`];
131
+ parts.push(pinned.modelSource === "per-invocation" || pinned.modelSource === "project" ? "(pinned)" : "(inherited)");
132
+ if (pinned.thinking) parts.push(`thinking ${pinned.thinking}`);
133
+ return parts.join(" · ");
134
+ }
135
+ return "";
136
+ })();
115
137
  const status = s.live
116
- ? `● live — following · j/k scroll · f re-follow · q close${counts ? ` · ${counts}` : ""}`
117
- : `final — ${total} event(s) · j/k scroll · q close${counts ? ` · ${counts}` : ""}`;
138
+ ? `● live — ${childLine ? `${childLine} · ` : ""}following · j/k scroll · f re-follow · q close${counts ? ` · ${counts}` : ""}`
139
+ : `final — ${total} event(s)${childLine ? ` · ${childLine}` : ""}${counts ? ` · ${counts}` : ""} · j/k scroll · q close`;
118
140
 
119
141
  // Frame arithmetic through the canonical helper: the window is the
120
142
  // grammar's detail block; the summary row occupies the grammar's