@draht/coding-agent 2026.10.4 → 2026.10.8
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/CHANGELOG.md +13 -0
- package/README.md +32 -6
- package/dist/bundle/chunks/anthropic.js +1 -1
- package/dist/bundle/chunks/{chunk-DPE4ALPU.js → chunk-2VAF4XJI.js} +1 -1
- package/dist/bundle/chunks/chunk-6APPDDHH.js +65 -0
- package/dist/bundle/chunks/{chunk-LDAOC5RB.js → chunk-JFDPOIUH.js} +1 -1
- package/dist/bundle/chunks/{chunk-COF5JT7R.js → chunk-KU5HAKZL.js} +1 -1
- package/dist/bundle/chunks/{chunk-Z2INEV2J.js → chunk-MIUVNYYW.js} +292 -153
- package/dist/bundle/chunks/{chunk-5VZWYVZB.js → chunk-NHTOADU6.js} +2 -2
- package/dist/bundle/chunks/{chunk-H6FT43VC.js → chunk-OWGSPJPZ.js} +4 -4
- package/dist/bundle/chunks/chunk-PGJAHC3R.js +107 -0
- package/dist/bundle/chunks/chunk-QVFELZW2.js +312 -0
- package/dist/bundle/chunks/{chunk-XKDTJ4YR.js → chunk-TJ3AW62W.js} +1 -1
- package/dist/bundle/chunks/{cli-SR5QBZH4.js → cli-U7Y4VNNI.js} +1 -1
- package/dist/bundle/chunks/execute-ZWB4PIQQ.js +18 -0
- package/dist/bundle/chunks/google-antigravity.js +1 -1
- package/dist/bundle/chunks/google-gemini-cli.js +1 -1
- package/dist/bundle/chunks/openai-chatgpt.js +1 -1
- package/dist/bundle/chunks/openai-codex.js +1 -1
- package/dist/bundle/chunks/openrouter.js +1 -1
- package/dist/bundle/chunks/radius.js +1 -1
- package/dist/bundle/chunks/runtime-363BOYEO.js +3 -0
- package/dist/bundle/chunks/{runtime-6YJPGSP7.js → runtime-PXJK4L7Y.js} +1 -1
- package/dist/bundle/chunks/{settings-manager-D2EG7WDO.js → settings-manager-GEOZJXFQ.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-BEJ4ZJ3D.js +2 -0
- package/dist/bundle/chunks/xai.js +1 -1
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/args.js +3 -3
- package/dist/cli/args.js.map +1 -1
- package/dist/core/builtins/duet.d.ts +5 -2
- package/dist/core/builtins/duet.d.ts.map +1 -1
- package/dist/core/builtins/duet.js +65 -27
- package/dist/core/builtins/duet.js.map +1 -1
- package/dist/core/builtins/index.d.ts.map +1 -1
- package/dist/core/builtins/index.js +2 -0
- package/dist/core/builtins/index.js.map +1 -1
- package/dist/core/builtins/polyphase.d.ts +15 -0
- package/dist/core/builtins/polyphase.d.ts.map +1 -0
- package/dist/core/builtins/polyphase.js +196 -0
- package/dist/core/builtins/polyphase.js.map +1 -0
- package/dist/core/builtins/subagent.d.ts +44 -34
- package/dist/core/builtins/subagent.d.ts.map +1 -1
- package/dist/core/builtins/subagent.js +827 -560
- package/dist/core/builtins/subagent.js.map +1 -1
- package/dist/core/extensions/types.d.ts +17 -2
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/keybindings.d.ts +30 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +24 -0
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-resolver.js +4 -4
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/multi-agent/permission-gate.d.ts.map +1 -1
- package/dist/core/multi-agent/permission-gate.js +4 -1
- package/dist/core/multi-agent/permission-gate.js.map +1 -1
- package/dist/core/polyphase/approval.d.ts +35 -0
- package/dist/core/polyphase/approval.d.ts.map +1 -0
- package/dist/core/polyphase/approval.js +184 -0
- package/dist/core/polyphase/approval.js.map +1 -0
- package/dist/core/polyphase/child-events.d.ts +107 -0
- package/dist/core/polyphase/child-events.d.ts.map +1 -0
- package/dist/core/polyphase/child-events.js +862 -0
- package/dist/core/polyphase/child-events.js.map +1 -0
- package/dist/core/polyphase/child-process.d.ts +65 -0
- package/dist/core/polyphase/child-process.d.ts.map +1 -0
- package/dist/core/polyphase/child-process.js +361 -0
- package/dist/core/polyphase/child-process.js.map +1 -0
- package/dist/core/polyphase/commands.d.ts +44 -0
- package/dist/core/polyphase/commands.d.ts.map +1 -0
- package/dist/core/polyphase/commands.js +244 -0
- package/dist/core/polyphase/commands.js.map +1 -0
- package/dist/core/polyphase/details.d.ts +40 -0
- package/dist/core/polyphase/details.d.ts.map +1 -0
- package/dist/core/polyphase/details.js +538 -0
- package/dist/core/polyphase/details.js.map +1 -0
- package/dist/core/polyphase/emitter.d.ts +20 -0
- package/dist/core/polyphase/emitter.d.ts.map +1 -0
- package/dist/core/polyphase/emitter.js +90 -0
- package/dist/core/polyphase/emitter.js.map +1 -0
- package/dist/core/polyphase/jsonl-reader.d.ts +31 -0
- package/dist/core/polyphase/jsonl-reader.d.ts.map +1 -0
- package/dist/core/polyphase/jsonl-reader.js +161 -0
- package/dist/core/polyphase/jsonl-reader.js.map +1 -0
- package/dist/core/polyphase/keyword.d.ts +27 -0
- package/dist/core/polyphase/keyword.d.ts.map +1 -0
- package/dist/core/polyphase/keyword.js +97 -0
- package/dist/core/polyphase/keyword.js.map +1 -0
- package/dist/core/polyphase/limiter.d.ts +38 -0
- package/dist/core/polyphase/limiter.d.ts.map +1 -0
- package/dist/core/polyphase/limiter.js +129 -0
- package/dist/core/polyphase/limiter.js.map +1 -0
- package/dist/core/polyphase/model-selection.d.ts +35 -0
- package/dist/core/polyphase/model-selection.d.ts.map +1 -0
- package/dist/core/polyphase/model-selection.js +72 -0
- package/dist/core/polyphase/model-selection.js.map +1 -0
- package/dist/core/polyphase/render/format.d.ts +52 -0
- package/dist/core/polyphase/render/format.d.ts.map +1 -0
- package/dist/core/polyphase/render/format.js +169 -0
- package/dist/core/polyphase/render/format.js.map +1 -0
- package/dist/core/polyphase/render/renderers.d.ts +63 -0
- package/dist/core/polyphase/render/renderers.d.ts.map +1 -0
- package/dist/core/polyphase/render/renderers.js +277 -0
- package/dist/core/polyphase/render/renderers.js.map +1 -0
- package/dist/core/polyphase/render/run-block.d.ts +45 -0
- package/dist/core/polyphase/render/run-block.d.ts.map +1 -0
- package/dist/core/polyphase/render/run-block.js +843 -0
- package/dist/core/polyphase/render/run-block.js.map +1 -0
- package/dist/core/polyphase/render/snapshot.d.ts +106 -0
- package/dist/core/polyphase/render/snapshot.d.ts.map +1 -0
- package/dist/core/polyphase/render/snapshot.js +292 -0
- package/dist/core/polyphase/render/snapshot.js.map +1 -0
- package/dist/core/polyphase/result-text.d.ts +41 -0
- package/dist/core/polyphase/result-text.d.ts.map +1 -0
- package/dist/core/polyphase/result-text.js +326 -0
- package/dist/core/polyphase/result-text.js.map +1 -0
- package/dist/core/polyphase/session.d.ts +33 -0
- package/dist/core/polyphase/session.d.ts.map +1 -0
- package/dist/core/polyphase/session.js +106 -0
- package/dist/core/polyphase/session.js.map +1 -0
- package/dist/core/polyphase/settings.d.ts +18 -0
- package/dist/core/polyphase/settings.d.ts.map +1 -0
- package/dist/core/polyphase/settings.js +93 -0
- package/dist/core/polyphase/settings.js.map +1 -0
- package/dist/core/polyphase/store.d.ts +197 -0
- package/dist/core/polyphase/store.d.ts.map +1 -0
- package/dist/core/polyphase/store.js +558 -0
- package/dist/core/polyphase/store.js.map +1 -0
- package/dist/core/polyphase/types.d.ts +371 -0
- package/dist/core/polyphase/types.d.ts.map +1 -0
- package/dist/core/polyphase/types.js +36 -0
- package/dist/core/polyphase/types.js.map +1 -0
- package/dist/core/polyphase/ui/controller.d.ts +28 -0
- package/dist/core/polyphase/ui/controller.d.ts.map +1 -0
- package/dist/core/polyphase/ui/controller.js +150 -0
- package/dist/core/polyphase/ui/controller.js.map +1 -0
- package/dist/core/polyphase/ui/dock.d.ts +27 -0
- package/dist/core/polyphase/ui/dock.d.ts.map +1 -0
- package/dist/core/polyphase/ui/dock.js +121 -0
- package/dist/core/polyphase/ui/dock.js.map +1 -0
- package/dist/core/polyphase/ui/inspector.d.ts +117 -0
- package/dist/core/polyphase/ui/inspector.d.ts.map +1 -0
- package/dist/core/polyphase/ui/inspector.js +1016 -0
- package/dist/core/polyphase/ui/inspector.js.map +1 -0
- package/dist/core/polyphase/ui/transcript-layout.d.ts +55 -0
- package/dist/core/polyphase/ui/transcript-layout.d.ts.map +1 -0
- package/dist/core/polyphase/ui/transcript-layout.js +210 -0
- package/dist/core/polyphase/ui/transcript-layout.js.map +1 -0
- package/dist/core/polyphase/update-pump.d.ts +18 -0
- package/dist/core/polyphase/update-pump.d.ts.map +1 -0
- package/dist/core/polyphase/update-pump.js +132 -0
- package/dist/core/polyphase/update-pump.js.map +1 -0
- package/dist/core/polyphase/workflow/agent-host.d.ts +26 -0
- package/dist/core/polyphase/workflow/agent-host.d.ts.map +1 -0
- package/dist/core/polyphase/workflow/agent-host.js +187 -0
- package/dist/core/polyphase/workflow/agent-host.js.map +1 -0
- package/dist/core/polyphase/workflow/guidance.d.ts +19 -0
- package/dist/core/polyphase/workflow/guidance.d.ts.map +1 -0
- package/dist/core/polyphase/workflow/guidance.js +119 -0
- package/dist/core/polyphase/workflow/guidance.js.map +1 -0
- package/dist/core/polyphase/workflow/launch.d.ts +41 -0
- package/dist/core/polyphase/workflow/launch.d.ts.map +1 -0
- package/dist/core/polyphase/workflow/launch.js +173 -0
- package/dist/core/polyphase/workflow/launch.js.map +1 -0
- package/dist/core/polyphase/workflow/meta.d.ts +43 -0
- package/dist/core/polyphase/workflow/meta.d.ts.map +1 -0
- package/dist/core/polyphase/workflow/meta.js +529 -0
- package/dist/core/polyphase/workflow/meta.js.map +1 -0
- package/dist/core/polyphase/workflow/prelude.d.ts +24 -0
- package/dist/core/polyphase/workflow/prelude.d.ts.map +1 -0
- package/dist/core/polyphase/workflow/prelude.js +93 -0
- package/dist/core/polyphase/workflow/prelude.js.map +1 -0
- package/dist/core/polyphase/workflow/runtime.d.ts +79 -0
- package/dist/core/polyphase/workflow/runtime.d.ts.map +1 -0
- package/dist/core/polyphase/workflow/runtime.js +217 -0
- package/dist/core/polyphase/workflow/runtime.js.map +1 -0
- package/dist/core/polyphase/workflow/runtime.lazy.d.ts +3 -0
- package/dist/core/polyphase/workflow/runtime.lazy.d.ts.map +1 -0
- package/dist/core/polyphase/workflow/runtime.lazy.js +3 -0
- package/dist/core/polyphase/workflow/runtime.lazy.js.map +1 -0
- package/dist/core/polyphase/workflow/saved.d.ts +55 -0
- package/dist/core/polyphase/workflow/saved.d.ts.map +1 -0
- package/dist/core/polyphase/workflow/saved.js +299 -0
- package/dist/core/polyphase/workflow/saved.js.map +1 -0
- package/dist/core/polyphase/workflow/structured-output.d.ts +22 -0
- package/dist/core/polyphase/workflow/structured-output.d.ts.map +1 -0
- package/dist/core/polyphase/workflow/structured-output.js +66 -0
- package/dist/core/polyphase/workflow/structured-output.js.map +1 -0
- package/dist/core/polyphase/workflow/tool.d.ts +24 -0
- package/dist/core/polyphase/workflow/tool.d.ts.map +1 -0
- package/dist/core/polyphase/workflow/tool.js +139 -0
- package/dist/core/polyphase/workflow/tool.js.map +1 -0
- package/dist/core/sdk.d.ts +1 -1
- package/dist/core/sdk.js +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-manager.d.ts +27 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/socket-server/permission-relay.js +4 -0
- package/dist/core/socket-server/permission-relay.js.map +1 -1
- package/dist/core/trust-manager.d.ts +3 -2
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +5 -2
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/experimental/micro/runtime.js +1 -1
- package/dist/experimental/micro/runtime.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts +7 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js +18 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +11 -2
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +9 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/prompts/commands/orchestrate.md +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +7 -1
- package/dist/utils/shell.js.map +1 -1
- package/docs/docs.json +4 -0
- package/docs/duet.md +3 -3
- package/docs/environment-variables.md +11 -0
- package/docs/json.md +7 -0
- package/docs/keybindings.md +20 -0
- package/docs/polyphase.md +391 -0
- package/docs/rpc-commands.md +9 -9
- package/docs/settings.md +12 -0
- package/docs/virtual-models.md +3 -3
- package/examples/extensions/preset.ts +3 -3
- package/examples/extensions/subagent/README.md +1 -1
- package/examples/extensions/subagent/agents/planner.md +1 -1
- package/examples/extensions/subagent/agents/reviewer.md +1 -1
- package/examples/extensions/subagent/agents/scout.md +1 -1
- package/examples/extensions/subagent/agents/worker.md +1 -1
- package/examples/extensions/summarize.ts +3 -3
- package/examples/sdk/02-custom-model.ts +1 -1
- package/examples/sdk/12-full-control.ts +1 -1
- package/examples/sdk/README.md +1 -1
- package/package.json +10 -10
- package/prompts/commands/orchestrate.md +1 -1
- package/dist/bundle/chunks/chunk-CEJJ5XF2.js +0 -170
- package/dist/bundle/chunks/execute-VCYDHEYA.js +0 -328
- package/dist/bundle/chunks/virtual-modules-JTCGDL2Z.js +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspector.js","sourceRoot":"","sources":["../../../../src/core/polyphase/ui/inspector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,2DAA2D,CAAC;AAGrG,OAAO,EAEN,OA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AO,CAAC,sBAAsB,EAAE,QAAQ,CAAC,CAAC,CAAC;YAChE,OAAO,CAAC,qBAAqB,EAAE,UAAU,CAAC;YAC1C,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,2BAA2B,EAAE,QAAQ,CAAC,CAAC,CAAC;YACrE,OAAO,CAAC,mBAAmB,EAAE,MAAM,CAAC;SACpC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;CACD","sourcesContent":["/**\n * `PolyphaseInspector`: the `alt+a` popup overlay listing runs and following an agent's live\n * transcript. See DESIGN.md §12.1-12.6, §12.8.\n */\n\nimport type { Component, Focusable, KeybindingsManager, TUI } from \"@draht/tui\";\nimport { visibleWidth, wrapTextWithAnsi } from \"@draht/tui\";\nimport { combinedKeyHint, keyHint } from \"../../../modes/interactive/components/keybinding-hints.ts\";\nimport type { Theme } from \"../../../modes/interactive/theme/theme.ts\";\nimport type { ArchivedRun } from \"../details.ts\";\nimport {\n\ttype ColumnCell,\n\tcolumns,\n\tfitLine,\n\tformatCost,\n\tformatDuration,\n\tformatModelLabel,\n\tformatTokens,\n\toneLine,\n\tpadToWidth,\n\tstatusGlyph,\n} from \"../render/format.ts\";\nimport { sanitizeChildText, sanitizeSnapshot } from \"../render/run-block.ts\";\nimport { type AgentSnapshotRow, type RunSnapshot, snapshotFromDetails, snapshotFromRun } from \"../render/snapshot.ts\";\nimport type { PolyphaseSession } from \"../session.ts\";\nimport type { AgentStatus, TranscriptItem } from \"../types.ts\";\nimport type { SavedWorkflowSummary } from \"../workflow/saved.ts\";\nimport {\n\tsanitizeForDisplay,\n\tTranscriptLineCache,\n\ttype TranscriptLineRange,\n\ttailWindowOf,\n} from \"./transcript-layout.ts\";\n\nexport type InspectorInitialView =\n\t| { view: \"auto\" }\n\t| { view: \"runs\" }\n\t| { view: \"run\"; runId: string }\n\t| { view: \"agent\"; runId: string; agentIndex: number };\n\nexport interface InspectorDeps {\n\tsession: PolyphaseSession;\n\ttui: TUI;\n\ttheme: Theme;\n\tkeybindings: KeybindingsManager;\n\tgetArchivedRuns(): readonly ArchivedRun[];\n\tgetSavedWorkflows(): readonly SavedWorkflowSummary[];\n\tinitial: InspectorInitialView;\n\tshowThinking: boolean;\n\tclose(): void;\n\tinsertCommand(text: string): void;\n}\n\nconst PAGE_SIZE = 10;\nconst SPLIT_MIN_WIDTH = 120;\nconst SPLIT_LEFT_WIDTH = 40;\n\ntype ViewMode = \"runs\" | \"run\" | \"agent\";\n\ninterface RunsRow {\n\tkind: \"live\" | \"earlier\" | \"saved\";\n\trunId?: string;\n\tsnapshot?: RunSnapshot;\n\tsaved?: SavedWorkflowSummary;\n}\n\ninterface CancelTarget {\n\trunId: string;\n\tagentIndex?: number;\n\tlabel: string;\n\tfinished: boolean;\n}\n\nfunction clamp(n: number, min: number, max: number): number {\n\treturn Math.min(max, Math.max(min, n));\n}\n\n/** Slices `lines` to `height` rows centred on `pivot`, replacing the first/last visible row with\n * a muted \"N more\" marker when the window hides rows above/below. The window is always centred on\n * `pivot` (clamped only at the list's edges), so `pivot` lands on an edge row of the window only\n * when that edge has nothing hidden past it — the marker never overwrites the selected row. */\nfunction windowAround(lines: readonly string[], height: number, pivot: number, theme: Theme): readonly string[] {\n\tif (lines.length <= height) return lines;\n\tconst start = Math.max(0, Math.min(pivot - Math.floor(height / 2), lines.length - height));\n\tconst end = start + height;\n\tconst windowed = lines.slice(start, end);\n\tif (height < 2) return windowed;\n\tconst pivotOffset = pivot - start;\n\tconst marked = windowed.slice();\n\tif (start > 0 && pivotOffset !== 0) {\n\t\tmarked[0] = theme.fg(\"muted\", `↑ ${start} more`);\n\t}\n\tif (end < lines.length && pivotOffset !== marked.length - 1) {\n\t\tmarked[marked.length - 1] = theme.fg(\"muted\", `↓ ${lines.length - end} more`);\n\t}\n\treturn marked;\n}\n\nfunction padLines(lines: readonly string[], height: number): string[] {\n\tif (lines.length >= height) return lines.slice(0, height);\n\treturn [...lines, ...Array.from({ length: height - lines.length }, () => \"\")];\n}\n\ninterface PauseAnchor {\n\tseq: number;\n\tlineInItem: number;\n}\n\n/** Resolves a pause anchor back to an absolute window-end line (exclusive), against the item line\n * ranges from the most recent render. If the anchored item was evicted, clamps to just past the\n * first still-kept item instead of drifting the view forward by the wrong amount. */\nfunction resolvePauseEndLine(anchor: PauseAnchor, ranges: readonly TranscriptLineRange[], totalLines: number): number {\n\tconst range = ranges.find((r) => r.seq === anchor.seq);\n\tif (range) return clamp(range.start + anchor.lineInItem + 1, 0, totalLines);\n\tconst first = ranges[0];\n\treturn first ? clamp(first.start + 1, 0, totalLines) : 0;\n}\n\n/** Converts an absolute window-end line (exclusive) into a pause anchor on whichever item renders\n * that line, so the anchor survives evictions that shift line numbers. */\nfunction anchorAtEndLine(endLine: number, ranges: readonly TranscriptLineRange[]): PauseAnchor | undefined {\n\tconst lastVisibleLine = endLine - 1;\n\tfor (const range of ranges) {\n\t\tif (lastVisibleLine >= range.start && lastVisibleLine < range.end) {\n\t\t\treturn { seq: range.seq, lineInItem: lastVisibleLine - range.start };\n\t\t}\n\t}\n\tconst last = ranges[ranges.length - 1];\n\treturn last ? { seq: last.seq, lineInItem: Math.max(0, last.end - last.start - 1) } : undefined;\n}\n\n/** Truncates the title (never the right segment or the closing corner) so the border always stays\n * closed, instead of handing the whole assembled string to `fitLine` and letting it cut off\n * whichever happens to sit at the end. */\nfunction borderTop(title: string, right: string, width: number): string {\n\tconst inner = Math.max(0, width - 2);\n\tlet rightSeg = right ? ` ${right} ` : \"\";\n\tlet rightWidth = visibleWidth(rightSeg);\n\tif (rightWidth > inner) {\n\t\trightSeg = \"\";\n\t\trightWidth = 0;\n\t}\n\tconst minDashes = 1;\n\tconst titleBudget = Math.max(0, inner - rightWidth - minDashes);\n\tconst titleSeg = fitLine(` ${title} `, titleBudget);\n\tconst dashes = Math.max(0, inner - visibleWidth(titleSeg) - rightWidth);\n\treturn `┌${titleSeg}${\"─\".repeat(dashes)}${rightSeg}┐`;\n}\n\nfunction borderBottom(width: number): string {\n\treturn fitLine(`└${\"─\".repeat(Math.max(0, width - 2))}┘`, width);\n}\n\nfunction sideLine(content: string, width: number): string {\n\tconst inner = Math.max(0, width - 4);\n\treturn fitLine(`│ ${padToWidth(content, inner)} │`, width);\n}\n\nfunction runsRowKey(row: RunsRow): string {\n\tif (row.kind === \"saved\") return `saved:${row.saved?.name ?? \"\"}`;\n\treturn `run:${row.runId ?? \"\"}`;\n}\n\nfunction groupLabel(kind: RunsRow[\"kind\"]): string {\n\tswitch (kind) {\n\t\tcase \"live\":\n\t\t\treturn \"Live\";\n\t\tcase \"earlier\":\n\t\t\treturn \"Earlier in this session\";\n\t\tcase \"saved\":\n\t\t\treturn \"Saved workflows\";\n\t}\n}\n\n/** Drops a trailing agent-count suffix (e.g. \"subagent parallel · 2 agents\"): `runSubtitleText`\n * is the single place that shows the count, so the title must not repeat it. */\nconst TRAILING_AGENT_COUNT = / · \\d+ agents?$/;\n\n/** The phase marker is only meaningful while the run is still progressing through phases; a\n * finished or cancelled run has no \"current\" phase left, so showing one would misread as still\n * running. */\nfunction isCurrentlyPhased(status: RunSnapshot[\"status\"]): boolean {\n\treturn status === \"running\";\n}\n\nfunction runTitleText(snapshot: RunSnapshot): string {\n\tif (snapshot.kind === \"workflow\") return `workflow ${snapshot.workflow?.name ?? snapshot.title}`;\n\tif (snapshot.kind === \"duet\") return `duet · ${snapshot.title}`;\n\treturn snapshot.title.replace(TRAILING_AGENT_COUNT, \"\");\n}\n\nfunction runSubtitleText(snapshot: RunSnapshot): string {\n\tif (snapshot.kind === \"workflow\") {\n\t\tconst phase =\n\t\t\tisCurrentlyPhased(snapshot.status) && snapshot.currentPhase !== undefined\n\t\t\t\t? snapshot.phases[snapshot.currentPhase]\n\t\t\t\t: undefined;\n\t\tif (phase) return `▸ ${phase.title}`;\n\t\tconst n = snapshot.phases.length;\n\t\treturn n > 0 ? `${n} phase${n === 1 ? \"\" : \"s\"}` : \"\";\n\t}\n\tconst n = snapshot.agents.length;\n\treturn `${n} agent${n === 1 ? \"\" : \"s\"}`;\n}\n\n/** `› ` (or ` `) + glyph, always a fixed-width cell outside the title's flex cell: the cursor and\n * status glyph must stay visible even when nothing else does. `columns()`'s own 1-column gap\n * supplies the separator space before the title, matching `› ● label` elsewhere in this file. */\nconst RUNS_ROW_CURSOR_WIDTH = 3;\n\nfunction savedWorkflowSourceLabel(source: SavedWorkflowSummary[\"source\"]): string {\n\treturn source === \"project\" ? \"proj\" : \"user\";\n}\n\n/** Drops or shrinks the runs-view row's optional columns as `width` decreases, in order of least\n * useful first (tokens, then cost, then the subtitle, then counts and duration), so the title (the\n * flex cell) keeps a usable share of the row instead of being squeezed to nothing by fixed columns\n * that no longer fit. */\nfunction runsRowOptionalWidths(width: number): {\n\tsubtitle: number;\n\tcounts: number;\n\tduration: number;\n\ttokens: number;\n\tcost: number;\n} {\n\treturn {\n\t\tsubtitle: width >= 80 ? 16 : width >= 60 ? 10 : 0,\n\t\tcounts: width >= 56 ? 10 : 0,\n\t\tduration: width >= 50 ? 7 : 0,\n\t\ttokens: width >= 70 ? 6 : 0,\n\t\tcost: width >= 60 ? 7 : 0,\n\t};\n}\n\n/** The agent detail header's right side (§12.2: `◐ thinking 0:41`) shows only the current activity\n * keyword, not `row.now`'s full content: `row.now` for a thinking/writing agent is `\"thinking · <the\n * actual text>\"`, and showing that verbatim in the border would leak hidden-thinking content past the\n * `app.thinking.toggle` gate that otherwise hides it in the transcript below. */\nfunction headerActivityText(row: AgentSnapshotRow): string {\n\tconst now = row.now ? oneLine(sanitizeForDisplay(row.now)) : undefined;\n\tif (!now) return row.status;\n\tconst separator = now.indexOf(\" · \");\n\treturn separator === -1 ? now : now.slice(0, separator);\n}\n\n/** Mirrors `headerActivityText`'s thinking-keyword cut: the run view's agent list and the split\n * view's left pane must not leak hidden thinking content into the \"now\" column either (§12.2 shows\n * just `thinking` there), even though the same column shows the activity in full once thinking is\n * visible. */\nfunction agentRowRightText(row: AgentSnapshotRow, showThinking: boolean): string {\n\tif (row.now) {\n\t\tconst now = oneLine(sanitizeForDisplay(row.now));\n\t\t// \"thinking\" is the only `computeNowLine()` activity word that can be followed by child-written\n\t\t// text; checking the prefix (not the full `\"thinking · \"` separator) also catches the edge case\n\t\t// where the thinking block is still empty and `oneLine()` has trimmed the trailing separator.\n\t\tif (!showThinking && now.startsWith(\"thinking\")) return \"thinking\";\n\t\treturn now;\n\t}\n\tif (row.statusLine) return oneLine(sanitizeForDisplay(row.statusLine));\n\tif (row.error) return oneLine(sanitizeForDisplay(row.error));\n\tswitch (row.status) {\n\t\tcase \"queued\":\n\t\t\treturn \"queued\";\n\t\tcase \"pending\":\n\t\t\treturn row.step !== undefined && row.step > 1 ? `waits for step ${row.step - 1}` : \"not run\";\n\t\tcase \"skipped\":\n\t\t\treturn \"not run\";\n\t\tcase \"cancelled\":\n\t\t\treturn \"cancelled\";\n\t\tcase \"done\":\n\t\t\t// A finished agent with no `now` and no `STATUS:` line still has output worth showing\n\t\t\t// (§11.3's tool-row fallback does the same): the first line beats a blank column.\n\t\t\treturn row.output ? oneLine(sanitizeForDisplay(row.output)) : \"\";\n\t\tdefault:\n\t\t\treturn \"\";\n\t}\n}\n\nconst COUNT_ORDER: readonly AgentStatus[] = [\"running\", \"done\", \"failed\", \"cancelled\", \"queued\", \"pending\", \"skipped\"];\n\nfunction formatCounts(theme: Theme, now: number, counts: Record<AgentStatus, number>): string {\n\tconst parts: string[] = [];\n\tfor (const status of COUNT_ORDER) {\n\t\tconst n = counts[status];\n\t\tif (n > 0) parts.push(`${statusGlyph(status, theme, { now, animate: false })}${n}`);\n\t}\n\treturn parts.join(\" \");\n}\n\nfunction isFinishedAgentStatus(status: AgentStatus): boolean {\n\treturn status === \"done\" || status === \"failed\" || status === \"cancelled\" || status === \"skipped\";\n}\n\n/**\n * The `alt+a` popup. `render()` recomputes the live runs-view list, the current run's agent list\n * and the selected agent's transcript window on every call, since those come straight from the\n * live store; nothing here owns a timer. Dirtiness (when to re-render at all) is the caller's job,\n * driven by `session.store`'s flush notifications.\n */\nexport class PolyphaseInspector implements Component, Focusable {\n\tfocused = false;\n\n\tprivate readonly deps: InspectorDeps;\n\tprivate readonly transcriptCache: TranscriptLineCache;\n\tprivate readonly unsubscribe: () => void;\n\n\tprivate mode: ViewMode = \"runs\";\n\tprivate currentRunId: string | undefined;\n\tprivate currentAgentIndex: number | undefined;\n\tprivate runsRows: RunsRow[] = [];\n\tprivate runsSelection = 0;\n\tprivate runsSelectionKey: string | undefined;\n\tprivate runSelection = 0;\n\tprivate following = true;\n\t/** Anchors the paused window to an item (`seq`) and a line within it, not an absolute line index:\n\t * the transcript keeps at most `maxItems`, so a paused run that keeps producing output evicts\n\t * older items and shifts every absolute line index after them. Resolved back to an absolute line\n\t * on each render via `resolvePauseEndLine`. See `renderAgentDetailBody`. */\n\tprivate pauseAnchor: PauseAnchor | undefined;\n\tprivate lastTranscriptTotalLines: number | undefined;\n\tprivate lastTranscriptRanges: readonly TranscriptLineRange[] = [];\n\tprivate lastDetailBodyHeight: number | undefined;\n\tprivate lastRenderWidth = 0;\n\tprivate showThinking: boolean;\n\tprivate showToolPreviews = false;\n\tprivate armed: { action: \"cancelAgent\" | \"cancelRun\"; runId: string; agentIndex?: number } | undefined;\n\tprivate footerNotice: string | undefined;\n\n\tconstructor(deps: InspectorDeps) {\n\t\tthis.deps = deps;\n\t\tthis.showThinking = deps.showThinking;\n\t\tthis.transcriptCache = new TranscriptLineCache(deps.theme);\n\t\tthis.resolveInitialView();\n\t\tthis.unsubscribe = deps.session.store.subscribe((change) => {\n\t\t\tif (change.type === \"disposed\") {\n\t\t\t\tthis.deps.close();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.deps.tui.requestRender();\n\t\t});\n\t}\n\n\thandleInput(data: string): void {\n\t\tif (this.mode === \"runs\") {\n\t\t\tthis.runsRows = this.buildRunsRows();\n\t\t\tthis.runsSelection = this.resolveRunsSelectionIndex(this.runsRows);\n\t\t}\n\t\tconst kb = this.deps.keybindings;\n\n\t\tif (kb.matches(data, \"app.polyphase.inspector\")) {\n\t\t\tthis.deps.close();\n\t\t\treturn;\n\t\t}\n\t\tif (kb.matches(data, \"app.polyphase.cancelAgent\")) {\n\t\t\tthis.handleCancelKey(\"cancelAgent\");\n\t\t\treturn;\n\t\t}\n\t\tif (kb.matches(data, \"app.polyphase.cancelRun\")) {\n\t\t\tthis.handleCancelKey(\"cancelRun\");\n\t\t\treturn;\n\t\t}\n\n\t\tthis.armed = undefined;\n\t\tthis.footerNotice = undefined;\n\n\t\tif (kb.matches(data, \"tui.select.cancel\")) {\n\t\t\tthis.goBack();\n\t\t} else if (kb.matches(data, \"app.thinking.toggle\")) {\n\t\t\tthis.showThinking = !this.showThinking;\n\t\t} else if (kb.matches(data, \"app.tools.expand\")) {\n\t\t\tthis.showToolPreviews = !this.showToolPreviews;\n\t\t} else if (kb.matches(data, \"app.polyphase.follow\")) {\n\t\t\tthis.toggleFollow();\n\t\t} else if (kb.matches(data, \"app.polyphase.nextAgent\")) {\n\t\t\tthis.cycleAgent(1);\n\t\t} else if (kb.matches(data, \"app.polyphase.previousAgent\")) {\n\t\t\tthis.cycleAgent(-1);\n\t\t} else if (kb.matches(data, \"tui.select.up\")) {\n\t\t\tthis.moveSelection(-1);\n\t\t} else if (kb.matches(data, \"tui.select.down\")) {\n\t\t\tthis.moveSelection(1);\n\t\t} else if (kb.matches(data, \"tui.select.pageUp\")) {\n\t\t\tthis.handlePage(-1);\n\t\t} else if (kb.matches(data, \"tui.select.pageDown\")) {\n\t\t\tthis.handlePage(1);\n\t\t} else if (kb.matches(data, \"tui.select.confirm\")) {\n\t\t\tthis.confirmSelection();\n\t\t}\n\t}\n\n\trender(width: number): string[] {\n\t\tthis.lastRenderWidth = width;\n\t\tconst terminal = this.deps.tui.terminal;\n\t\tif (width < 40 || terminal.rows < 10) {\n\t\t\treturn [fitLine(\"terminal too small for the agent inspector\", width)];\n\t\t}\n\t\tconst height = Math.max(8, terminal.rows - 2);\n\t\tconst bodyHeight = Math.max(1, height - 2);\n\t\tconst innerWidth = Math.max(1, width - 4);\n\n\t\tlet topTitle: string;\n\t\tlet topRight: string;\n\t\tlet bodyLines: string[];\n\n\t\tif (this.mode === \"runs\") {\n\t\t\tthis.runsRows = this.buildRunsRows();\n\t\t\tthis.runsSelection = this.resolveRunsSelectionIndex(this.runsRows);\n\t\t\t// Tracks the selection by identity from the very first render, not only once the user has\n\t\t\t// pressed an arrow key, so a live run inserted above the selection between renders cannot\n\t\t\t// change what a subsequent `enter` opens.\n\t\t\tif (this.runsSelectionKey === undefined) {\n\t\t\t\tconst row = this.runsRows[this.runsSelection];\n\t\t\t\tthis.runsSelectionKey = row ? runsRowKey(row) : undefined;\n\t\t\t}\n\t\t\tconst liveCount = this.runsRows.filter((row) => row.kind === \"live\").length;\n\t\t\tconst earlierCount = this.runsRows.filter((row) => row.kind === \"earlier\").length;\n\t\t\tconst limiter = this.deps.session.limiter.stats();\n\t\t\ttopTitle = `polyphase · ${liveCount} live · ${earlierCount} earlier · slots ${limiter.active}/${limiter.capacity}`;\n\t\t\ttopRight = keyHint(\"app.polyphase.inspector\", \"close\");\n\t\t\tbodyLines = this.renderRunsBody(innerWidth, bodyHeight);\n\t\t} else if (this.mode === \"run\") {\n\t\t\t// Built once here and threaded through, instead of each of the header and the body methods\n\t\t\t// calling `currentRunSnapshot()`/`currentRunAgents()` again: `snapshotFromRun` runs a regex\n\t\t\t// over every agent's output and hashes the whole details object, so repeating it several\n\t\t\t// times per render on every pump flush is wasted work.\n\t\t\tconst snapshot = this.currentRunSnapshot();\n\t\t\tconst rows = this.sortedAgentsOf(snapshot);\n\t\t\ttopTitle = snapshot ? this.runTitleForHeader(snapshot) : \"run\";\n\t\t\ttopRight = snapshot ? this.runHeaderRight(snapshot) : \"\";\n\t\t\tbodyLines =\n\t\t\t\twidth >= SPLIT_MIN_WIDTH\n\t\t\t\t\t? this.renderSplitBody(innerWidth, bodyHeight, rows)\n\t\t\t\t\t: this.renderRunBody(innerWidth, bodyHeight, snapshot, rows);\n\t\t} else {\n\t\t\tconst snapshot = this.currentRunSnapshot();\n\t\t\tconst rows = this.sortedAgentsOf(snapshot);\n\t\t\tconst row = rows.find((r) => r.i === this.currentAgentIndex);\n\t\t\tconst phaseTitle = row?.phase !== undefined ? snapshot?.phases[row.phase]?.title : undefined;\n\t\t\ttopTitle = row ? `${row.label} · ${row.agentType}${phaseTitle ? ` · ${phaseTitle}` : \"\"}` : \"agent\";\n\t\t\ttopRight = row\n\t\t\t\t? `${statusGlyph(row.status, this.deps.theme, { now: this.now(), animate: false })} ${headerActivityText(row)}${\n\t\t\t\t\t\trow.elapsedMs === undefined ? \"\" : ` ${formatDuration(row.elapsedMs)}`\n\t\t\t\t\t}`\n\t\t\t\t: \"\";\n\t\t\tbodyLines = this.renderAgentDetailBody(this.currentAgentIndex, innerWidth, bodyHeight, rows);\n\t\t}\n\n\t\tconst padded = padLines(bodyLines, bodyHeight);\n\t\treturn [\n\t\t\tborderTop(topTitle, topRight, width),\n\t\t\t...padded.map((line) => sideLine(line, width)),\n\t\t\tborderBottom(width),\n\t\t];\n\t}\n\n\tinvalidate(): void {}\n\n\tdispose(): void {\n\t\tthis.unsubscribe();\n\t}\n\n\tprivate now(): number {\n\t\treturn Date.now();\n\t}\n\n\t// ── Navigation ──────────────────────────────────────────────────────────\n\n\tprivate resolveInitialView(): void {\n\t\tconst initial = this.deps.initial;\n\t\tif (initial.view === \"runs\") {\n\t\t\tthis.mode = \"runs\";\n\t\t\treturn;\n\t\t}\n\t\tif (initial.view === \"run\") {\n\t\t\tthis.mode = \"run\";\n\t\t\tthis.currentRunId = initial.runId;\n\t\t\tthis.selectFirstActiveAgentForCurrentRun();\n\t\t\treturn;\n\t\t}\n\t\tif (initial.view === \"agent\") {\n\t\t\tthis.mode = \"agent\";\n\t\t\tthis.currentRunId = initial.runId;\n\t\t\tthis.currentAgentIndex = initial.agentIndex;\n\t\t\treturn;\n\t\t}\n\t\tconst liveRuns = this.deps.session.store.runs().filter((run) => run.status === \"running\");\n\t\tif (liveRuns.length === 1) {\n\t\t\tthis.mode = \"run\";\n\t\t\tthis.currentRunId = liveRuns[0]?.id;\n\t\t\tthis.selectFirstActiveAgentForCurrentRun();\n\t\t} else {\n\t\t\tthis.mode = \"runs\";\n\t\t}\n\t}\n\n\tprivate selectFirstActiveAgentForCurrentRun(): void {\n\t\tconst rows = this.currentRunAgents();\n\t\tconst idx = rows.findIndex((row) => row.status === \"running\" || row.status === \"starting\");\n\t\tthis.runSelection = idx === -1 ? 0 : idx;\n\t}\n\n\t/** Resolves the runs-view selection by the identity of the previously selected row (its runId or\n\t * saved-workflow name), not its index, so a live update that reorders rows between a render and the\n\t * next key press does not silently select a different run. Falls back to a clamped index when the\n\t * previous row is gone (e.g. an archived run was pruned). */\n\tprivate resolveRunsSelectionIndex(rows: readonly RunsRow[]): number {\n\t\tif (this.runsSelectionKey !== undefined) {\n\t\t\tconst idx = rows.findIndex((row) => runsRowKey(row) === this.runsSelectionKey);\n\t\t\tif (idx !== -1) return idx;\n\t\t}\n\t\treturn clamp(this.runsSelection, 0, Math.max(0, rows.length - 1));\n\t}\n\n\tprivate resetFollowing(): void {\n\t\tthis.following = true;\n\t\tthis.pauseAnchor = undefined;\n\t}\n\n\tprivate isSplitActive(): boolean {\n\t\treturn this.lastRenderWidth >= SPLIT_MIN_WIDTH;\n\t}\n\n\tprivate goBack(): void {\n\t\tif (this.mode === \"agent\") {\n\t\t\tconst rows = this.currentRunAgents();\n\t\t\tconst idx = rows.findIndex((row) => row.i === this.currentAgentIndex);\n\t\t\tif (idx !== -1) this.runSelection = idx;\n\t\t\tthis.mode = \"run\";\n\t\t\tthis.resetFollowing();\n\t\t\treturn;\n\t\t}\n\t\tif (this.mode === \"run\") {\n\t\t\t// Reselects the run the user came from, so the runs view does not fall back to the index it\n\t\t\t// had before drilling in (which may now point at a different row).\n\t\t\tif (this.currentRunId) this.runsSelectionKey = `run:${this.currentRunId}`;\n\t\t\tthis.mode = \"runs\";\n\t\t\tthis.currentRunId = undefined;\n\t\t\treturn;\n\t\t}\n\t\tthis.deps.close();\n\t}\n\n\tprivate confirmSelection(): void {\n\t\tif (this.mode === \"runs\") {\n\t\t\tconst row = this.runsRows[this.runsSelection];\n\t\t\tif (!row) return;\n\t\t\tif (row.kind === \"saved\") {\n\t\t\t\tconst saved = row.saved;\n\t\t\t\tif (!saved) return;\n\t\t\t\tif (!saved.valid) {\n\t\t\t\t\tthis.footerNotice = `/${saved.name} is invalid`;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst command = saved.command ? `/${saved.command.replace(/^\\//, \"\")} ` : `/workflow ${saved.name} `;\n\t\t\t\tthis.deps.insertCommand(command);\n\t\t\t\tthis.deps.close();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (row.runId) {\n\t\t\t\tthis.currentRunId = row.runId;\n\t\t\t\tthis.mode = \"run\";\n\t\t\t\tthis.selectFirstActiveAgentForCurrentRun();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (this.mode === \"run\") {\n\t\t\tconst rows = this.currentRunAgents();\n\t\t\tconst row = rows[this.runSelection];\n\t\t\tif (!row) return;\n\t\t\tthis.currentAgentIndex = row.i;\n\t\t\tthis.mode = \"agent\";\n\t\t\tthis.resetFollowing();\n\t\t}\n\t}\n\n\tprivate moveSelection(delta: number): void {\n\t\tif (this.mode === \"runs\") {\n\t\t\tif (this.runsRows.length === 0) return;\n\t\t\tthis.runsSelection = clamp(this.runsSelection + delta, 0, this.runsRows.length - 1);\n\t\t\tconst row = this.runsRows[this.runsSelection];\n\t\t\tthis.runsSelectionKey = row ? runsRowKey(row) : undefined;\n\t\t\treturn;\n\t\t}\n\t\tif (this.mode === \"run\") {\n\t\t\tconst rows = this.currentRunAgents();\n\t\t\tif (rows.length === 0) return;\n\t\t\tconst next = clamp(this.runSelection + delta, 0, rows.length - 1);\n\t\t\tif (next !== this.runSelection) {\n\t\t\t\tthis.runSelection = next;\n\t\t\t\tthis.resetFollowing();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tthis.scrollTranscript(delta);\n\t}\n\n\t/** Shared by the agent detail view and, in split view, by page keys on the run view: both drive\n\t * the same `following`/`pauseAnchor` pair against whichever agent is currently shown on the\n\t * right. */\n\tprivate scrollTranscript(delta: number): void {\n\t\tconst total = this.lastTranscriptTotalLines ?? 0;\n\t\tconst ranges = this.lastTranscriptRanges;\n\t\tconst visible = Math.max(1, this.lastDetailBodyHeight ?? 1);\n\t\tconst currentEnd = this.pauseAnchor ? resolvePauseEndLine(this.pauseAnchor, ranges, total) : total;\n\t\tif (delta < 0) {\n\t\t\tif (total <= visible) return;\n\t\t\tconst minEnd = Math.min(total, visible);\n\t\t\tthis.pauseAnchor = anchorAtEndLine(Math.max(minEnd, currentEnd + delta), ranges);\n\t\t\tthis.following = false;\n\t\t} else if (delta > 0 && this.pauseAnchor !== undefined) {\n\t\t\tconst next = Math.min(total, currentEnd + delta);\n\t\t\tif (next >= total) {\n\t\t\t\tthis.pauseAnchor = undefined;\n\t\t\t\tthis.following = true;\n\t\t\t} else {\n\t\t\t\tthis.pauseAnchor = anchorAtEndLine(next, ranges);\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Page keys scroll the right pane in split view (§12.2) instead of moving the left selection by\n\t * a page. Up/down always move the left selection; only page keys are redirected. */\n\tprivate handlePage(direction: 1 | -1): void {\n\t\tif (this.mode === \"run\" && this.isSplitActive()) {\n\t\t\tthis.scrollTranscript(direction * PAGE_SIZE);\n\t\t\treturn;\n\t\t}\n\t\tthis.moveSelection(direction * PAGE_SIZE);\n\t}\n\n\tprivate cycleAgent(direction: 1 | -1): void {\n\t\tif (this.mode === \"run\") {\n\t\t\tconst rows = this.currentRunAgents();\n\t\t\tif (rows.length === 0) return;\n\t\t\tthis.runSelection = (this.runSelection + direction + rows.length) % rows.length;\n\t\t\tthis.resetFollowing();\n\t\t\treturn;\n\t\t}\n\t\tif (this.mode === \"agent\") {\n\t\t\tconst rows = this.currentRunAgents();\n\t\t\tif (rows.length === 0) return;\n\t\t\tconst curIdx = rows.findIndex((row) => row.i === this.currentAgentIndex);\n\t\t\tconst nextIdx = ((curIdx === -1 ? 0 : curIdx) + direction + rows.length) % rows.length;\n\t\t\tthis.currentAgentIndex = rows[nextIdx]?.i;\n\t\t\tthis.resetFollowing();\n\t\t}\n\t}\n\n\tprivate toggleFollow(): void {\n\t\tif (this.mode !== \"agent\" && !(this.mode === \"run\" && this.isSplitActive())) return;\n\t\tif (this.following) {\n\t\t\tconst anchor = anchorAtEndLine(this.lastTranscriptTotalLines ?? 0, this.lastTranscriptRanges);\n\t\t\t// An empty transcript (no ranges yet, or the archived/retention-dropped summary body, which\n\t\t\t// never sets any ranges) has nothing to anchor a pause to. Pressing `f` must stay a no-op\n\t\t\t// then, not flip into a paused state the view can never escape: `scrollTranscript` only\n\t\t\t// resumes following once `pauseAnchor` advances to the end, which it can never do without an\n\t\t\t// anchor.\n\t\t\tif (anchor === undefined) return;\n\t\t\tthis.pauseAnchor = anchor;\n\t\t\tthis.following = false;\n\t\t} else {\n\t\t\tthis.resetFollowing();\n\t\t}\n\t}\n\n\t// ── Two-press cancel (§12.4) ────────────────────────────────────────────\n\n\tprivate handleCancelKey(action: \"cancelAgent\" | \"cancelRun\"): void {\n\t\tconst target = this.cancelTarget(action);\n\t\tif (!target) {\n\t\t\tthis.armed = undefined;\n\t\t\tthis.footerNotice = undefined;\n\t\t\treturn;\n\t\t}\n\t\tconst sameTarget =\n\t\t\tthis.armed?.action === action &&\n\t\t\tthis.armed.runId === target.runId &&\n\t\t\tthis.armed.agentIndex === target.agentIndex;\n\t\tif (sameTarget) {\n\t\t\tthis.armed = undefined;\n\t\t\tthis.footerNotice = undefined;\n\t\t\tif (action === \"cancelAgent\" && target.agentIndex !== undefined) {\n\t\t\t\tthis.deps.session.store.cancelAgent(target.runId, target.agentIndex);\n\t\t\t} else {\n\t\t\t\tthis.deps.session.store.cancelRun(target.runId);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (target.finished) {\n\t\t\tthis.armed = undefined;\n\t\t\tthis.footerNotice = \"already finished\";\n\t\t\treturn;\n\t\t}\n\t\tthis.armed = { action, runId: target.runId, agentIndex: target.agentIndex };\n\t\tthis.footerNotice =\n\t\t\taction === \"cancelAgent\" ? `press x again to cancel ${target.label}` : \"press X again to cancel the run\";\n\t}\n\n\tprivate cancelTarget(action: \"cancelAgent\" | \"cancelRun\"): CancelTarget | undefined {\n\t\tif (action === \"cancelAgent\") {\n\t\t\tif (this.mode === \"run\") {\n\t\t\t\tconst row = this.currentRunAgents()[this.runSelection];\n\t\t\t\tif (!row || !this.currentRunId) return undefined;\n\t\t\t\treturn {\n\t\t\t\t\trunId: this.currentRunId,\n\t\t\t\t\tagentIndex: row.i,\n\t\t\t\t\tlabel: row.label,\n\t\t\t\t\tfinished: isFinishedAgentStatus(row.status),\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (this.mode === \"agent\") {\n\t\t\t\tconst row = this.currentAgentRow();\n\t\t\t\tif (!row || !this.currentRunId) return undefined;\n\t\t\t\treturn {\n\t\t\t\t\trunId: this.currentRunId,\n\t\t\t\t\tagentIndex: row.i,\n\t\t\t\t\tlabel: row.label,\n\t\t\t\t\tfinished: isFinishedAgentStatus(row.status),\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t\tif (this.mode === \"runs\") {\n\t\t\tconst row = this.runsRows[this.runsSelection];\n\t\t\tif (!row || row.kind === \"saved\" || !row.runId || !row.snapshot) return undefined;\n\t\t\treturn { runId: row.runId, label: row.snapshot.title, finished: row.snapshot.status !== \"running\" };\n\t\t}\n\t\tconst snapshot = this.currentRunSnapshot();\n\t\tif (!snapshot || !this.currentRunId) return undefined;\n\t\treturn { runId: this.currentRunId, label: snapshot.title, finished: snapshot.status !== \"running\" };\n\t}\n\n\t// ── Data access ─────────────────────────────────────────────────────────\n\n\tprivate buildRunsRows(): RunsRow[] {\n\t\tconst store = this.deps.session.store;\n\t\tconst allRuns = store.runs();\n\t\tconst liveRuns = allRuns.filter((run) => run.status === \"running\");\n\t\tconst finishedLive = allRuns.filter((run) => run.status !== \"running\");\n\t\tconst knownIds = new Set([...liveRuns, ...finishedLive].map((run) => run.id));\n\t\tconst archived = this.deps.getArchivedRuns().filter((entry) => !knownIds.has(entry.runId));\n\n\t\tconst rows: RunsRow[] = [];\n\t\tfor (const run of liveRuns) {\n\t\t\trows.push({\n\t\t\t\tkind: \"live\",\n\t\t\t\trunId: run.id,\n\t\t\t\tsnapshot: sanitizeSnapshot(\n\t\t\t\t\tsnapshotFromRun(run, { now: this.now(), tailItems: 0, limiter: this.deps.session.limiter.stats() }),\n\t\t\t\t),\n\t\t\t});\n\t\t}\n\t\tfor (const run of finishedLive) {\n\t\t\trows.push({\n\t\t\t\tkind: \"earlier\",\n\t\t\t\trunId: run.id,\n\t\t\t\tsnapshot: sanitizeSnapshot(snapshotFromRun(run, { now: this.now(), tailItems: 0 })),\n\t\t\t});\n\t\t}\n\t\tfor (const entry of archived) {\n\t\t\trows.push({\n\t\t\t\tkind: \"earlier\",\n\t\t\t\trunId: entry.runId,\n\t\t\t\tsnapshot: sanitizeSnapshot(snapshotFromDetails(entry.details, { now: this.now() })),\n\t\t\t});\n\t\t}\n\t\tfor (const saved of this.deps.getSavedWorkflows()) {\n\t\t\trows.push({ kind: \"saved\", saved });\n\t\t}\n\t\treturn rows;\n\t}\n\n\tprivate currentRunSnapshot(): RunSnapshot | undefined {\n\t\tif (!this.currentRunId) return undefined;\n\t\tconst liveRun = this.deps.session.store.getRun(this.currentRunId);\n\t\tif (liveRun) {\n\t\t\treturn sanitizeSnapshot(\n\t\t\t\tsnapshotFromRun(liveRun, { now: this.now(), tailItems: 0, limiter: this.deps.session.limiter.stats() }),\n\t\t\t);\n\t\t}\n\t\tconst archived = this.deps.getArchivedRuns().find((entry) => entry.runId === this.currentRunId);\n\t\treturn archived ? sanitizeSnapshot(snapshotFromDetails(archived.details, { now: this.now() })) : undefined;\n\t}\n\n\tprivate sortedAgentsOf(snapshot: RunSnapshot | undefined): AgentSnapshotRow[] {\n\t\tif (!snapshot) return [];\n\t\treturn [...snapshot.agents].sort((a, b) => a.i - b.i);\n\t}\n\n\tprivate currentRunAgents(): AgentSnapshotRow[] {\n\t\treturn this.sortedAgentsOf(this.currentRunSnapshot());\n\t}\n\n\tprivate currentAgentRow(): AgentSnapshotRow | undefined {\n\t\tif (this.currentAgentIndex === undefined) return undefined;\n\t\treturn this.currentRunAgents().find((row) => row.i === this.currentAgentIndex);\n\t}\n\n\tprivate currentAgentTranscriptFor(\n\t\tagentIndex: number,\n\t): { items: readonly TranscriptItem[]; dropped: number } | undefined {\n\t\tif (!this.currentRunId) return undefined;\n\t\tconst run = this.deps.session.store.getRun(this.currentRunId);\n\t\tconst agent = run?.agents[agentIndex];\n\t\t// Retention drops every agent's transcript on a finished run once it falls past\n\t\t// `keepTranscriptRuns`; `undefined` here sends the caller to the archived-style summary body\n\t\t// (status, output, error, the \"only kept while in memory\" note) instead of an empty transcript.\n\t\tif (!run || !agent || run.transcriptsDropped) return undefined;\n\t\treturn { items: agent.state.transcript, dropped: agent.state.droppedItems };\n\t}\n\n\t// ── Rendering ───────────────────────────────────────────────────────────\n\n\tprivate formatRunsRow(row: RunsRow, width: number, selected: boolean): string {\n\t\tconst cursor = selected ? \"› \" : \" \";\n\t\tif (row.kind === \"saved\" && row.saved) {\n\t\t\tconst saved = row.saved;\n\t\t\t// `name`/`description` come from the saved script's own meta block (`workflow/meta.ts`), the\n\t\t\t// same kind of script-supplied text `sanitizeSnapshot` cleans for live/archived runs.\n\t\t\tconst nameText = `${cursor}/${sanitizeChildText(saved.name)}`;\n\t\t\treturn columns(\n\t\t\t\t[\n\t\t\t\t\t{ text: saved.valid ? nameText : this.deps.theme.fg(\"error\", `${nameText} invalid`), width: 18 },\n\t\t\t\t\t{ text: sanitizeChildText(saved.description), width: \"flex\" },\n\t\t\t\t\t{ text: savedWorkflowSourceLabel(saved.source), width: 4, align: \"right\" },\n\t\t\t\t],\n\t\t\t\twidth,\n\t\t\t);\n\t\t}\n\t\tconst snapshot = row.snapshot;\n\t\tif (!snapshot) return fitLine(`${cursor}?`, width);\n\t\tconst glyph = statusGlyph(snapshot.status, this.deps.theme, { now: this.now(), animate: false });\n\t\tconst optional = runsRowOptionalWidths(width);\n\t\t// The cursor, glyph and title are fixed/flex cells ahead of every optional column, so they\n\t\t// always render, even at widths where every optional column below has been dropped.\n\t\tconst cells: ColumnCell[] = [\n\t\t\t{ text: `${cursor}${glyph}`, width: RUNS_ROW_CURSOR_WIDTH },\n\t\t\t{ text: runTitleText(snapshot), width: \"flex\" },\n\t\t];\n\t\tif (optional.subtitle > 0) cells.push({ text: runSubtitleText(snapshot), width: optional.subtitle });\n\t\tif (optional.counts > 0) {\n\t\t\tcells.push({ text: formatCounts(this.deps.theme, this.now(), snapshot.counts), width: optional.counts });\n\t\t}\n\t\tif (optional.duration > 0) {\n\t\t\tcells.push({ text: formatDuration(snapshot.elapsedMs), width: optional.duration, align: \"right\" });\n\t\t}\n\t\tif (optional.tokens > 0) {\n\t\t\tcells.push({\n\t\t\t\ttext: snapshot.tokens > 0 ? formatTokens(snapshot.tokens) : \"\",\n\t\t\t\twidth: optional.tokens,\n\t\t\t\talign: \"right\",\n\t\t\t});\n\t\t}\n\t\tif (optional.cost > 0) cells.push({ text: formatCost(snapshot.cost), width: optional.cost, align: \"right\" });\n\t\treturn columns(cells, width);\n\t}\n\n\tprivate renderRunsBody(width: number, height: number): string[] {\n\t\tconst rows = this.runsRows;\n\t\tconst lines: string[] = [];\n\t\tconst lineForRow: number[] = [];\n\t\tlet lastKind: RunsRow[\"kind\"] | undefined;\n\t\trows.forEach((row, idx) => {\n\t\t\tif (row.kind !== lastKind) {\n\t\t\t\tlines.push(this.deps.theme.bold(groupLabel(row.kind)));\n\t\t\t\tlastKind = row.kind;\n\t\t\t}\n\t\t\tlineForRow[idx] = lines.length;\n\t\t\tlines.push(this.formatRunsRow(row, width, idx === this.runsSelection));\n\t\t});\n\t\tif (rows.length === 0) {\n\t\t\tlines.push('No agents yet. Put \"polyphase\" in a prompt or run /workflow <name>.');\n\t\t}\n\t\tconst pivot = lineForRow[this.runsSelection] ?? 0;\n\t\tconst contentHeight = Math.max(1, height - 1);\n\t\tconst windowed = padLines(windowAround(lines, contentHeight, pivot, this.deps.theme), contentHeight);\n\t\treturn [...windowed, this.footerLine(this.runsHintLine(), width)];\n\t}\n\n\tprivate formatAgentRow(row: AgentSnapshotRow, width: number, selected: boolean): string {\n\t\tconst cursor = selected ? \"› \" : \" \";\n\t\tconst glyph = statusGlyph(row.status, this.deps.theme, { now: this.now(), animate: false });\n\t\tconst model = formatModelLabel(row, { withProvider: false });\n\t\tconst cells: ColumnCell[] = [\n\t\t\t{ text: `${cursor}${glyph} ${row.label}`, width: 18 },\n\t\t\t{ text: model, width: 20 },\n\t\t];\n\t\t// Dropped below 60 columns, the same threshold `layoutRun` uses for its elapsed column: at\n\t\t// the 40-column split-pane width there is no room for a 5th fixed cell ahead of the flex one.\n\t\tif (width >= 60) {\n\t\t\tcells.push({\n\t\t\t\ttext: row.elapsedMs === undefined ? \"\" : formatDuration(row.elapsedMs),\n\t\t\t\twidth: 5,\n\t\t\t\talign: \"right\",\n\t\t\t});\n\t\t}\n\t\tcells.push({ text: agentRowRightText(row, this.showThinking), width: \"flex\" });\n\t\treturn columns(cells, width);\n\t}\n\n\tprivate runTitleForHeader(snapshot: RunSnapshot): string {\n\t\tconst base = runTitleText(snapshot);\n\t\tif (snapshot.kind === \"workflow\" && isCurrentlyPhased(snapshot.status) && snapshot.currentPhase !== undefined) {\n\t\t\tconst phase = snapshot.phases[snapshot.currentPhase];\n\t\t\tif (phase) return `${base} ▸ ${phase.title}`;\n\t\t}\n\t\treturn base;\n\t}\n\n\tprivate runHeaderRight(snapshot: RunSnapshot): string {\n\t\tconst parts = [formatCounts(this.deps.theme, this.now(), snapshot.counts), formatDuration(snapshot.elapsedMs)];\n\t\tif (snapshot.tokens > 0) parts.push(formatTokens(snapshot.tokens));\n\t\tconst cost = formatCost(snapshot.cost);\n\t\tif (cost) parts.push(cost);\n\t\treturn parts.filter((part) => part.length > 0).join(\" \");\n\t}\n\n\tprivate renderRunBody(\n\t\twidth: number,\n\t\theight: number,\n\t\tsnapshot: RunSnapshot | undefined,\n\t\trows: AgentSnapshotRow[],\n\t): string[] {\n\t\tif (!snapshot) return [this.deps.theme.fg(\"muted\", \"run not found\")];\n\t\tthis.runSelection = clamp(this.runSelection, 0, Math.max(0, rows.length - 1));\n\n\t\tconst lines: string[] = [];\n\t\tconst lineForAgent: number[] = [];\n\t\tif (snapshot.phases.length > 0) {\n\t\t\t// Agents spawned before any phase()/agent({phase}) call (§13.3) carry no phase index; they\n\t\t\t// are still selectable, so they get an ungrouped block ahead of the phase list instead of\n\t\t\t// being silently dropped from the view.\n\t\t\trows.forEach((row, idx) => {\n\t\t\t\tif (row.phase !== undefined) return;\n\t\t\t\tlineForAgent[idx] = lines.length;\n\t\t\t\tlines.push(this.formatAgentRow(row, width, idx === this.runSelection));\n\t\t\t});\n\t\t\tfor (const phase of snapshot.phases) {\n\t\t\t\tlines.push(\n\t\t\t\t\tcolumns(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttext: `${statusGlyph(phase.status, this.deps.theme, { now: this.now(), animate: false })} ${phase.index + 1} ${phase.title}`,\n\t\t\t\t\t\t\t\twidth: \"flex\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ text: `${phase.done}/${phase.total}`, width: 7, align: \"right\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttext: phase.elapsedMs === undefined ? \"\" : formatDuration(phase.elapsedMs),\n\t\t\t\t\t\t\t\twidth: 7,\n\t\t\t\t\t\t\t\talign: \"right\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\twidth,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\trows.forEach((row, idx) => {\n\t\t\t\t\tif (row.phase !== phase.index) return;\n\t\t\t\t\tlineForAgent[idx] = lines.length;\n\t\t\t\t\tlines.push(` ${this.formatAgentRow(row, Math.max(1, width - 4), idx === this.runSelection)}`);\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\trows.forEach((row, idx) => {\n\t\t\t\tlineForAgent[idx] = lines.length;\n\t\t\t\tconst prefix = row.step !== undefined ? `${row.step} ` : \"\";\n\t\t\t\tlines.push(\n\t\t\t\t\t`${prefix}${this.formatAgentRow(row, Math.max(1, width - prefix.length), idx === this.runSelection)}`,\n\t\t\t\t);\n\t\t\t});\n\t\t}\n\t\tif (snapshot.log.length > 0) {\n\t\t\tlines.push(`» ${oneLine(sanitizeForDisplay(snapshot.log[snapshot.log.length - 1] ?? \"\"))}`);\n\t\t} else if (snapshot.resultPreview && snapshot.status !== \"running\") {\n\t\t\tlines.push(`→ ${oneLine(sanitizeForDisplay(snapshot.resultPreview))}`);\n\t\t}\n\n\t\tconst pivot = lineForAgent[this.runSelection] ?? 0;\n\t\tconst contentHeight = Math.max(1, height - 1);\n\t\tconst windowed = padLines(windowAround(lines, contentHeight, pivot, this.deps.theme), contentHeight);\n\t\treturn [...windowed, this.footerLine(this.runHintLine(), width)];\n\t}\n\n\tprivate renderSplitBody(width: number, height: number, rows: AgentSnapshotRow[]): string[] {\n\t\tconst rightWidth = Math.max(1, width - SPLIT_LEFT_WIDTH - 1);\n\t\tthis.runSelection = clamp(this.runSelection, 0, Math.max(0, rows.length - 1));\n\t\tconst leftLines = rows.map((row, idx) =>\n\t\t\tfitLine(this.formatAgentRow(row, SPLIT_LEFT_WIDTH, idx === this.runSelection), SPLIT_LEFT_WIDTH),\n\t\t);\n\t\tconst selectedAgentIndex = rows[this.runSelection]?.i;\n\t\tconst rightLines = this.renderAgentDetailBody(selectedAgentIndex, rightWidth, height, rows);\n\t\t// Windowed the same way `renderRunBody` windows the flat agent list, so a run with more agents\n\t\t// than the pane has rows keeps the `›` cursor on screen instead of scrolling it off the top.\n\t\tconst paddedLeft = padLines(windowAround(leftLines, height, this.runSelection, this.deps.theme), height);\n\t\tconst paddedRight = padLines(rightLines, height);\n\t\treturn paddedLeft.map((line, idx) => `${padToWidth(line, SPLIT_LEFT_WIDTH)}│${paddedRight[idx] ?? \"\"}`);\n\t}\n\n\tprivate renderAgentDetailBody(\n\t\tagentIndex: number | undefined,\n\t\twidth: number,\n\t\theight: number,\n\t\trows: AgentSnapshotRow[],\n\t): string[] {\n\t\tconst footerFallback = this.agentHintLine();\n\t\tconst contentHeight = Math.max(1, height - 1);\n\t\tif (agentIndex === undefined) {\n\t\t\treturn [\n\t\t\t\t...padLines([this.deps.theme.fg(\"muted\", \"no agent selected\")], contentHeight),\n\t\t\t\tthis.footerLine(footerFallback, width),\n\t\t\t];\n\t\t}\n\t\tconst row = rows.find((r) => r.i === agentIndex);\n\t\tif (!row) {\n\t\t\treturn [\n\t\t\t\t...padLines([this.deps.theme.fg(\"muted\", \"agent not found\")], contentHeight),\n\t\t\t\tthis.footerLine(footerFallback, width),\n\t\t\t];\n\t\t}\n\n\t\tconst header: string[] = [];\n\t\tconst modelLabel = formatModelLabel(row, { withProvider: true, withSource: true });\n\t\tconst confirmText = row.modelConfirmed ? \"confirmed\" : \"unconfirmed\";\n\t\tconst tokensText = row.tokens > 0 ? ` · ${formatTokens(row.tokens)} tok` : \"\";\n\t\tconst costText = row.cost > 0 ? ` · ${formatCost(row.cost)}` : \"\";\n\t\tconst turnsText = `${row.turns} turn${row.turns === 1 ? \"\" : \"s\"}`;\n\t\tconst toolsText = `${row.toolCalls} tool${row.toolCalls === 1 ? \"\" : \"s\"}`;\n\t\theader.push(oneLine(`${modelLabel} · ${confirmText} · ${turnsText} · ${toolsText}${tokensText}${costText}`));\n\t\theader.push(`task ${oneLine(row.task)}`);\n\t\theader.push(\"─\".repeat(Math.max(0, width)));\n\n\t\tconst footer = this.footerLine(this.agentHintLine(row.status), width);\n\t\tconst transcript = this.currentAgentTranscriptFor(agentIndex);\n\t\tif (!transcript) {\n\t\t\tconst OUTPUT_PREVIEW_MAX_LINES = 8;\n\t\t\tlet statusLines = row.statusLine ? 1 : 0;\n\t\t\tlet errorLines = row.error ? 1 : 0;\n\t\t\tconst noteLines = 1;\n\t\t\t// The note explains why the transcript is gone, so it must survive trimming even at the\n\t\t\t// smallest supported height: reserve header + note first, then drop error, then status,\n\t\t\t// before giving any remaining budget to the output preview. `padLines` below only pads or\n\t\t\t// truncates from the end, so whatever we build here must already fit `contentHeight`.\n\t\t\tif (header.length + statusLines + errorLines + noteLines > contentHeight && errorLines > 0) {\n\t\t\t\terrorLines = 0;\n\t\t\t}\n\t\t\tif (header.length + statusLines + errorLines + noteLines > contentHeight && statusLines > 0) {\n\t\t\t\tstatusLines = 0;\n\t\t\t}\n\t\t\tconst outputBudget = row.output\n\t\t\t\t? Math.max(0, contentHeight - header.length - statusLines - errorLines - noteLines - 1)\n\t\t\t\t: 0;\n\t\t\tconst body = [...header];\n\t\t\tif (statusLines > 0 && row.statusLine) {\n\t\t\t\tbody.push(fitLine(`status ${oneLine(sanitizeForDisplay(row.statusLine))}`, width));\n\t\t\t}\n\t\t\tif (row.output && outputBudget > 0) {\n\t\t\t\tbody.push(\"output\");\n\t\t\t\tbody.push(\n\t\t\t\t\t...wrapTextWithAnsi(sanitizeForDisplay(row.output), Math.max(1, width - 2))\n\t\t\t\t\t\t.slice(0, Math.min(OUTPUT_PREVIEW_MAX_LINES, outputBudget))\n\t\t\t\t\t\t.map((line) => fitLine(` ${line}`, width)),\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (errorLines > 0 && row.error) body.push(fitLine(`error ${oneLine(sanitizeForDisplay(row.error))}`, width));\n\t\t\tbody.push(this.deps.theme.fg(\"muted\", \"Live transcript is only kept while the run is in memory.\"));\n\t\t\tthis.lastTranscriptTotalLines = undefined;\n\t\t\tthis.lastTranscriptRanges = [];\n\t\t\tthis.lastDetailBodyHeight = undefined;\n\t\t\treturn [...padLines(body, contentHeight), footer];\n\t\t}\n\n\t\tconst owner = `${this.currentRunId}:${agentIndex}`;\n\t\tconst transcriptLines = this.transcriptCache.linesFor(owner, transcript.items, transcript.dropped, {\n\t\t\twidth,\n\t\t\tshowThinking: this.showThinking,\n\t\t\tshowToolPreviews: this.showToolPreviews,\n\t\t\tnow: this.now(),\n\t\t});\n\t\tconst tail = tailWindowOf(transcriptLines);\n\t\tthis.lastTranscriptTotalLines = tail.totalLines;\n\t\tthis.lastTranscriptRanges = this.transcriptCache.lineRanges();\n\t\t// A finished or cancelled agent has nothing left to follow or pause: the indicator row only\n\t\t// makes sense while the agent could still produce more output.\n\t\tconst showFollowLine = !isFinishedAgentStatus(row.status);\n\t\tconst transcriptRows = Math.max(1, contentHeight - header.length - (showFollowLine ? 1 : 0));\n\t\tthis.lastDetailBodyHeight = transcriptRows;\n\t\tconst pinnedEndLine = this.pauseAnchor\n\t\t\t? resolvePauseEndLine(this.pauseAnchor, this.lastTranscriptRanges, tail.totalLines)\n\t\t\t: undefined;\n\t\tconst offsetFromEnd = this.following ? 0 : Math.max(0, tail.totalLines - (pinnedEndLine ?? tail.totalLines));\n\t\tconst windowLines = padLines(tail.window(transcriptRows, offsetFromEnd), transcriptRows);\n\t\tconst followLine = showFollowLine\n\t\t\t? [fitLine(this.following ? \"◆ following\" : \"‖ paused · f to follow\", width)]\n\t\t\t: [];\n\t\tconst body = [...header, ...windowLines, ...followLine];\n\t\treturn [...padLines(body, contentHeight), footer];\n\t}\n\n\t/** `width` is the same inner width the caller laid its body out to, so a hint line that does not\n\t * fit is ellipsised like every other row instead of being hard-cut by `sideLine`'s padding,\n\t * which carries no ellipsis of its own. */\n\tprivate footerLine(hint: string, width: number): string {\n\t\treturn fitLine(this.footerNotice ? this.deps.theme.fg(\"warning\", this.footerNotice) : hint, width);\n\t}\n\n\tprivate runsHintLine(): string {\n\t\treturn [\n\t\t\tcombinedKeyHint([\"tui.select.up\", \"tui.select.down\"], \"select\"),\n\t\t\tkeyHint(\"tui.select.confirm\", \"open\"),\n\t\t\tkeyHint(\"app.polyphase.cancelRun\", \"cancel run\"),\n\t\t\tkeyHint(\"tui.select.cancel\", \"close\"),\n\t\t].join(\" \");\n\t}\n\n\tprivate runHintLine(): string {\n\t\treturn [\n\t\t\tcombinedKeyHint([\"tui.select.up\", \"tui.select.down\"], \"select\"),\n\t\t\tkeyHint(\"tui.select.confirm\", \"follow\"),\n\t\t\tkeyHint(\"app.polyphase.cancelAgent\", \"cancel agent\"),\n\t\t\tkeyHint(\"app.polyphase.cancelRun\", \"cancel run\"),\n\t\t\tkeyHint(\"tui.select.cancel\", \"back\"),\n\t\t].join(\" \");\n\t}\n\n\tprivate agentHintLine(status?: AgentStatus): string {\n\t\tconst finished = status !== undefined && isFinishedAgentStatus(status);\n\t\treturn [\n\t\t\tkeyHint(\"app.polyphase.nextAgent\", \"next agent\"),\n\t\t\t...(finished ? [] : [keyHint(\"app.polyphase.follow\", \"follow\")]),\n\t\t\tkeyHint(\"app.thinking.toggle\", \"thinking\"),\n\t\t\t...(finished ? [] : [keyHint(\"app.polyphase.cancelAgent\", \"cancel\")]),\n\t\t\tkeyHint(\"tui.select.cancel\", \"back\"),\n\t\t].join(\" \");\n\t}\n}\n"]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrapped-line cache and tail-window math for one agent's live transcript, shared by the agent
|
|
3
|
+
* detail view (`ui/inspector.ts`). See DESIGN.md §12.5.
|
|
4
|
+
*/
|
|
5
|
+
import type { Theme } from "../../../modes/interactive/theme/theme.ts";
|
|
6
|
+
import type { TranscriptItem } from "../types.ts";
|
|
7
|
+
export interface TranscriptRenderOptions {
|
|
8
|
+
width: number;
|
|
9
|
+
showThinking: boolean;
|
|
10
|
+
showToolPreviews: boolean;
|
|
11
|
+
now: number;
|
|
12
|
+
}
|
|
13
|
+
export interface TranscriptTailWindow {
|
|
14
|
+
readonly totalLines: number;
|
|
15
|
+
/** `[totalLines - height - offsetFromEnd, totalLines - offsetFromEnd)`, clamped. */
|
|
16
|
+
window(height: number, offsetFromEnd: number): string[];
|
|
17
|
+
}
|
|
18
|
+
export declare function tailWindowOf(lines: readonly string[]): TranscriptTailWindow;
|
|
19
|
+
/** Child-sourced text (thinking/text content, tool summaries, result previews, blocked reasons,
|
|
20
|
+
* notice text) may contain cursor/erase CSI sequences, OSC title sequences, tabs and bare CRs.
|
|
21
|
+
* Stripped (or, for CR, normalised to a newline) before wrapping, so the parent terminal never
|
|
22
|
+
* executes them and a progress-style `\r` can never move the cursor back to column 0 and overwrite
|
|
23
|
+
* already-drawn output. `wrapTextWithAnsi` already splits on `\r` like a newline, so normalising it
|
|
24
|
+
* here does not change multi-line rendering. Exported for `ui/inspector.ts`, which draws other
|
|
25
|
+
* child-sourced fields (status lines, output previews, errors) outside the transcript; those
|
|
26
|
+
* single-line call sites must also run the result through `oneLine()` so the newline this
|
|
27
|
+
* introduces does not split one logical row into two terminal lines. */
|
|
28
|
+
export declare function sanitizeForDisplay(text: string): string;
|
|
29
|
+
/** The line span `[start, end)` one transcript item occupies in the last `linesFor()` result, so a
|
|
30
|
+
* caller can re-locate an item (e.g. a pinned pause anchor) after the surrounding lines shift. */
|
|
31
|
+
export interface TranscriptLineRange {
|
|
32
|
+
seq: number;
|
|
33
|
+
start: number;
|
|
34
|
+
end: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Caches one transcript item's wrapped lines by `(seq, rev, width, showThinking, showToolPreviews,
|
|
38
|
+
* open)`, so an unchanged item is not re-wrapped on every render. The last item is re-wrapped from
|
|
39
|
+
* its last 16 KiB only while it is still open (streaming), so a growing thinking/text block does not
|
|
40
|
+
* make every render O(item length). Entries are scoped to one `owner` (one agent's transcript):
|
|
41
|
+
* `seq` is a per-agent counter that restarts at 0 for every agent, so entries from a previously
|
|
42
|
+
* shown agent are discarded whenever the owner changes, instead of being served to the next one.
|
|
43
|
+
*/
|
|
44
|
+
export declare class TranscriptLineCache {
|
|
45
|
+
private readonly theme;
|
|
46
|
+
private owner;
|
|
47
|
+
private entries;
|
|
48
|
+
private ranges;
|
|
49
|
+
constructor(theme: Theme);
|
|
50
|
+
linesFor(owner: string, items: readonly TranscriptItem[], droppedItems: number, options: TranscriptRenderOptions): string[];
|
|
51
|
+
/** The item line ranges computed by the most recent `linesFor()` call. */
|
|
52
|
+
lineRanges(): readonly TranscriptLineRange[];
|
|
53
|
+
private renderItem;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=transcript-layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcript-layout.d.ts","sourceRoot":"","sources":["../../../../src/core/polyphase/ui/transcript-layout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2CAA2C,CAAC;AAKvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAOlD,MAAM,WAAW,uBAAuB;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,OAAO,CAAC;IACtB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,oFAAoF;IACpF,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACxD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,oBAAoB,CAc3E;AAMD;;;;;;;;wEAQwE;AACxE,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvD;AA8HD;kGACkG;AAClG,MAAM,WAAW,mBAAmB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACZ;AAED;;;;;;;GAOG;AACH,qBAAa,mBAAmB;IAC/B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,MAAM,CAAsC;IAEpD,YAAY,KAAK,EAAE,KAAK,EAEvB;IAED,QAAQ,CACP,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,uBAAuB,GAC9B,MAAM,EAAE,CAkCV;IAED,0EAA0E;IAC1E,UAAU,IAAI,SAAS,mBAAmB,EAAE,CAE3C;IAED,OAAO,CAAC,UAAU;CAYlB"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrapped-line cache and tail-window math for one agent's live transcript, shared by the agent
|
|
3
|
+
* detail view (`ui/inspector.ts`). See DESIGN.md §12.5.
|
|
4
|
+
*/
|
|
5
|
+
import { visibleWidth, wrapTextWithAnsi } from "@draht/tui";
|
|
6
|
+
import { keyText } from "../../../modes/interactive/components/keybinding-hints.js";
|
|
7
|
+
import { stripAnsi } from "../../../utils/ansi.js";
|
|
8
|
+
import { sanitizeBinaryOutput } from "../../../utils/shell.js";
|
|
9
|
+
import { replaceTabs } from "../../tools/render-utils.js";
|
|
10
|
+
import { columns, fitLine, formatDuration, oneLine } from "../render/format.js";
|
|
11
|
+
/** Only the last 16 KiB of an open (not-yet-done) item's text is re-wrapped on every delta, so
|
|
12
|
+
* rendering cost stays bounded while the item streams in. */
|
|
13
|
+
const STREAM_TAIL_CHARS = 16 * 1024;
|
|
14
|
+
const TOOL_PREVIEW_MAX_LINES = 6;
|
|
15
|
+
export function tailWindowOf(lines) {
|
|
16
|
+
return {
|
|
17
|
+
get totalLines() {
|
|
18
|
+
return lines.length;
|
|
19
|
+
},
|
|
20
|
+
window(height, offsetFromEnd) {
|
|
21
|
+
const total = lines.length;
|
|
22
|
+
const h = Math.max(0, Math.floor(height));
|
|
23
|
+
const offset = Math.min(total, Math.max(0, Math.floor(offsetFromEnd)));
|
|
24
|
+
const end = total - offset;
|
|
25
|
+
const start = Math.max(0, end - h);
|
|
26
|
+
return lines.slice(start, end);
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function isOpenItem(item) {
|
|
31
|
+
return (item.kind === "thinking" || item.kind === "text") && !item.done;
|
|
32
|
+
}
|
|
33
|
+
/** Child-sourced text (thinking/text content, tool summaries, result previews, blocked reasons,
|
|
34
|
+
* notice text) may contain cursor/erase CSI sequences, OSC title sequences, tabs and bare CRs.
|
|
35
|
+
* Stripped (or, for CR, normalised to a newline) before wrapping, so the parent terminal never
|
|
36
|
+
* executes them and a progress-style `\r` can never move the cursor back to column 0 and overwrite
|
|
37
|
+
* already-drawn output. `wrapTextWithAnsi` already splits on `\r` like a newline, so normalising it
|
|
38
|
+
* here does not change multi-line rendering. Exported for `ui/inspector.ts`, which draws other
|
|
39
|
+
* child-sourced fields (status lines, output previews, errors) outside the transcript; those
|
|
40
|
+
* single-line call sites must also run the result through `oneLine()` so the newline this
|
|
41
|
+
* introduces does not split one logical row into two terminal lines. */
|
|
42
|
+
export function sanitizeForDisplay(text) {
|
|
43
|
+
return replaceTabs(sanitizeBinaryOutput(stripAnsi(text))).replace(/\r\n?/g, "\n");
|
|
44
|
+
}
|
|
45
|
+
/** A 16 KiB tail cut can land inside a UTF-16 surrogate pair, leaving an orphan low surrogate at
|
|
46
|
+
* the start; `String.prototype.slice` does not know about pairs. Dropped before sanitizing so it
|
|
47
|
+
* never reaches the terminal as a replacement-character glyph. */
|
|
48
|
+
function trimLeadingLoneSurrogate(text) {
|
|
49
|
+
const code = text.charCodeAt(0);
|
|
50
|
+
return code >= 0xdc00 && code <= 0xdfff ? text.slice(1) : text;
|
|
51
|
+
}
|
|
52
|
+
function appendCursor(lines) {
|
|
53
|
+
if (lines.length === 0)
|
|
54
|
+
return ["▌"];
|
|
55
|
+
const last = lines[lines.length - 1] ?? "";
|
|
56
|
+
return [...lines.slice(0, -1), `${last}▌`];
|
|
57
|
+
}
|
|
58
|
+
function renderTextLikeItem(theme, kind, text, done, redacted, options, open) {
|
|
59
|
+
const header = theme.fg("muted", `▸ ${kind}`);
|
|
60
|
+
if (kind === "thinking" && !options.showThinking) {
|
|
61
|
+
const hidden = redacted
|
|
62
|
+
? "▸ thinking (redacted, hidden)"
|
|
63
|
+
: `▸ thinking (hidden — ${keyText("app.thinking.toggle")} to show)`;
|
|
64
|
+
return [fitLine(theme.fg("muted", hidden), options.width)];
|
|
65
|
+
}
|
|
66
|
+
const indent = " ";
|
|
67
|
+
const bodyWidth = Math.max(1, options.width - indent.length - (done ? 0 : 1));
|
|
68
|
+
// Sliced before sanitizing, not after: sanitizing the open item's full text on every delta would
|
|
69
|
+
// cost up to `maxItemChars` instead of the intended 16 KiB bound. A partial escape sequence left
|
|
70
|
+
// at the cut point becomes harmless literal text once `stripAnsi` sees it.
|
|
71
|
+
const source = sanitizeForDisplay(open ? trimLeadingLoneSurrogate(text.slice(-STREAM_TAIL_CHARS)) : text);
|
|
72
|
+
const wrapped = wrapTextWithAnsi(source, bodyWidth);
|
|
73
|
+
const withCursor = done ? wrapped : appendCursor(wrapped);
|
|
74
|
+
return [fitLine(header, options.width), ...withCursor.map((line) => fitLine(`${indent}${line}`, options.width))];
|
|
75
|
+
}
|
|
76
|
+
function formatToolElapsed(ms) {
|
|
77
|
+
if (ms < 1000)
|
|
78
|
+
return `${Math.max(0, ms / 1000).toFixed(1)}s`;
|
|
79
|
+
return formatDuration(ms);
|
|
80
|
+
}
|
|
81
|
+
function toolStatusRight(item, theme, now) {
|
|
82
|
+
switch (item.status) {
|
|
83
|
+
case "ok": {
|
|
84
|
+
const elapsed = item.startedAt === undefined ? undefined : (item.endedAt ?? now) - item.startedAt;
|
|
85
|
+
return `${theme.fg("success", "✓")}${elapsed === undefined ? "" : ` ${formatToolElapsed(elapsed)}`}`;
|
|
86
|
+
}
|
|
87
|
+
case "error": {
|
|
88
|
+
const elapsed = item.startedAt === undefined ? undefined : (item.endedAt ?? now) - item.startedAt;
|
|
89
|
+
return `${theme.fg("error", "✗")}${elapsed === undefined ? "" : ` ${formatToolElapsed(elapsed)}`}`;
|
|
90
|
+
}
|
|
91
|
+
case "blocked":
|
|
92
|
+
return `${theme.fg("warning", "⚠")} blocked: needs approval`;
|
|
93
|
+
case "running": {
|
|
94
|
+
// A static glyph, not an animated spinner: only the focused row animates (§20.4), and this
|
|
95
|
+
// item may be rendered outside the cache on every flush, so an animated frame here would
|
|
96
|
+
// just be redundant churn.
|
|
97
|
+
const elapsed = item.startedAt === undefined ? undefined : now - item.startedAt;
|
|
98
|
+
return `${theme.fg("accent", "◐")}${elapsed === undefined ? "" : ` ${formatToolElapsed(elapsed)}`}`;
|
|
99
|
+
}
|
|
100
|
+
case "pending":
|
|
101
|
+
return theme.fg("dim", "·");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function renderToolItem(theme, item, options) {
|
|
105
|
+
const summary = sanitizeForDisplay(item.summary);
|
|
106
|
+
const left = oneLine(`● ${item.name} ${summary}`.trim());
|
|
107
|
+
const right = toolStatusRight(item, theme, options.now);
|
|
108
|
+
const line = columns([
|
|
109
|
+
{ text: left, width: "flex" },
|
|
110
|
+
{ text: right, width: visibleWidth(right) },
|
|
111
|
+
], options.width, 1);
|
|
112
|
+
const lines = [fitLine(line, options.width)];
|
|
113
|
+
if (item.status === "blocked" && item.blockedReason) {
|
|
114
|
+
const indent = " ";
|
|
115
|
+
const reason = sanitizeForDisplay(item.blockedReason);
|
|
116
|
+
lines.push(...wrapTextWithAnsi(reason, Math.max(1, options.width - indent.length)).map((l) => fitLine(`${indent}${l}`, options.width)));
|
|
117
|
+
}
|
|
118
|
+
if (options.showToolPreviews && item.resultPreview) {
|
|
119
|
+
const indent = " │ ";
|
|
120
|
+
const preview = sanitizeForDisplay(item.resultPreview);
|
|
121
|
+
const previewWidth = Math.max(1, options.width - indent.length);
|
|
122
|
+
lines.push(...wrapTextWithAnsi(preview, previewWidth)
|
|
123
|
+
.slice(0, TOOL_PREVIEW_MAX_LINES)
|
|
124
|
+
.map((l) => fitLine(`${indent}${l}`, options.width)));
|
|
125
|
+
}
|
|
126
|
+
return lines;
|
|
127
|
+
}
|
|
128
|
+
function renderNoticeItem(theme, item, width) {
|
|
129
|
+
const color = item.level === "error" ? "error" : item.level === "warning" ? "warning" : "muted";
|
|
130
|
+
const text = sanitizeForDisplay(item.text);
|
|
131
|
+
return wrapTextWithAnsi(theme.fg(color, `! ${text}`), width).map((line) => fitLine(line, width));
|
|
132
|
+
}
|
|
133
|
+
/** A running tool item's status column (elapsed time) must keep advancing on every render, but
|
|
134
|
+
* `rev` only changes on mutation, so it is never cached. */
|
|
135
|
+
function isLiveTimed(item) {
|
|
136
|
+
return item.kind === "tool" && item.status === "running";
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Caches one transcript item's wrapped lines by `(seq, rev, width, showThinking, showToolPreviews,
|
|
140
|
+
* open)`, so an unchanged item is not re-wrapped on every render. The last item is re-wrapped from
|
|
141
|
+
* its last 16 KiB only while it is still open (streaming), so a growing thinking/text block does not
|
|
142
|
+
* make every render O(item length). Entries are scoped to one `owner` (one agent's transcript):
|
|
143
|
+
* `seq` is a per-agent counter that restarts at 0 for every agent, so entries from a previously
|
|
144
|
+
* shown agent are discarded whenever the owner changes, instead of being served to the next one.
|
|
145
|
+
*/
|
|
146
|
+
export class TranscriptLineCache {
|
|
147
|
+
theme;
|
|
148
|
+
owner;
|
|
149
|
+
entries = new Map();
|
|
150
|
+
ranges = [];
|
|
151
|
+
constructor(theme) {
|
|
152
|
+
this.theme = theme;
|
|
153
|
+
}
|
|
154
|
+
linesFor(owner, items, droppedItems, options) {
|
|
155
|
+
if (owner !== this.owner) {
|
|
156
|
+
this.entries.clear();
|
|
157
|
+
this.owner = owner;
|
|
158
|
+
}
|
|
159
|
+
const lines = [];
|
|
160
|
+
const ranges = [];
|
|
161
|
+
if (droppedItems > 0) {
|
|
162
|
+
lines.push(fitLine(this.theme.fg("muted", `… ${droppedItems} earlier items not kept`), options.width));
|
|
163
|
+
}
|
|
164
|
+
const lastIndex = items.length - 1;
|
|
165
|
+
const liveSeqs = new Set();
|
|
166
|
+
for (let i = 0; i <= lastIndex; i++) {
|
|
167
|
+
const item = items[i];
|
|
168
|
+
if (!item)
|
|
169
|
+
continue;
|
|
170
|
+
liveSeqs.add(item.seq);
|
|
171
|
+
const open = i === lastIndex && isOpenItem(item);
|
|
172
|
+
const start = lines.length;
|
|
173
|
+
if (isLiveTimed(item)) {
|
|
174
|
+
lines.push(...this.renderItem(item, options, open));
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
const key = `${item.rev}|${options.width}|${options.showThinking}|${options.showToolPreviews}|${open}`;
|
|
178
|
+
const cached = this.entries.get(item.seq);
|
|
179
|
+
const itemLines = cached && cached.key === key ? cached.lines : this.renderItem(item, options, open);
|
|
180
|
+
if (!cached || cached.key !== key)
|
|
181
|
+
this.entries.set(item.seq, { key, lines: itemLines });
|
|
182
|
+
lines.push(...itemLines);
|
|
183
|
+
}
|
|
184
|
+
ranges.push({ seq: item.seq, start, end: lines.length });
|
|
185
|
+
}
|
|
186
|
+
for (const seq of this.entries.keys()) {
|
|
187
|
+
if (!liveSeqs.has(seq))
|
|
188
|
+
this.entries.delete(seq);
|
|
189
|
+
}
|
|
190
|
+
this.ranges = ranges;
|
|
191
|
+
return lines;
|
|
192
|
+
}
|
|
193
|
+
/** The item line ranges computed by the most recent `linesFor()` call. */
|
|
194
|
+
lineRanges() {
|
|
195
|
+
return this.ranges;
|
|
196
|
+
}
|
|
197
|
+
renderItem(item, options, open) {
|
|
198
|
+
switch (item.kind) {
|
|
199
|
+
case "thinking":
|
|
200
|
+
return renderTextLikeItem(this.theme, "thinking", item.text, item.done, item.redacted, options, open);
|
|
201
|
+
case "text":
|
|
202
|
+
return renderTextLikeItem(this.theme, "text", item.text, item.done, false, options, open);
|
|
203
|
+
case "tool":
|
|
204
|
+
return renderToolItem(this.theme, item, options);
|
|
205
|
+
case "notice":
|
|
206
|
+
return renderNoticeItem(this.theme, item, options.width);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=transcript-layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcript-layout.js","sourceRoot":"","sources":["../../../../src/core/polyphase/ui/transcript-layout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,2DAA2D,CAAC;AAEpF,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAGhF;6DAC6D;AAC7D,MAAM,iBAAiB,GAAG,EAAE,GAAG,IAAI,CAAC;AACpC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAejC,MAAM,UAAU,YAAY,CAAC,KAAwB;IACpD,OAAO;QACN,IAAI,UAAU;YACb,OAAO,KAAK,CAAC,MAAM,CAAC;QACrB,CAAC;QACD,MAAM,CAAC,MAAc,EAAE,aAAqB;YAC3C,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC;YAC3B,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;YAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAA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AAQ;gBACZ,OAAO,gBAAgB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QAC3D,CAAC;IACF,CAAC;CACD","sourcesContent":["/**\n * Wrapped-line cache and tail-window math for one agent's live transcript, shared by the agent\n * detail view (`ui/inspector.ts`). See DESIGN.md §12.5.\n */\n\nimport { visibleWidth, wrapTextWithAnsi } from \"@draht/tui\";\nimport { keyText } from \"../../../modes/interactive/components/keybinding-hints.ts\";\nimport type { Theme } from \"../../../modes/interactive/theme/theme.ts\";\nimport { stripAnsi } from \"../../../utils/ansi.ts\";\nimport { sanitizeBinaryOutput } from \"../../../utils/shell.ts\";\nimport { replaceTabs } from \"../../tools/render-utils.ts\";\nimport { columns, fitLine, formatDuration, oneLine } from \"../render/format.ts\";\nimport type { TranscriptItem } from \"../types.ts\";\n\n/** Only the last 16 KiB of an open (not-yet-done) item's text is re-wrapped on every delta, so\n * rendering cost stays bounded while the item streams in. */\nconst STREAM_TAIL_CHARS = 16 * 1024;\nconst TOOL_PREVIEW_MAX_LINES = 6;\n\nexport interface TranscriptRenderOptions {\n\twidth: number;\n\tshowThinking: boolean;\n\tshowToolPreviews: boolean;\n\tnow: number;\n}\n\nexport interface TranscriptTailWindow {\n\treadonly totalLines: number;\n\t/** `[totalLines - height - offsetFromEnd, totalLines - offsetFromEnd)`, clamped. */\n\twindow(height: number, offsetFromEnd: number): string[];\n}\n\nexport function tailWindowOf(lines: readonly string[]): TranscriptTailWindow {\n\treturn {\n\t\tget totalLines(): number {\n\t\t\treturn lines.length;\n\t\t},\n\t\twindow(height: number, offsetFromEnd: number): string[] {\n\t\t\tconst total = lines.length;\n\t\t\tconst h = Math.max(0, Math.floor(height));\n\t\t\tconst offset = Math.min(total, Math.max(0, Math.floor(offsetFromEnd)));\n\t\t\tconst end = total - offset;\n\t\t\tconst start = Math.max(0, end - h);\n\t\t\treturn lines.slice(start, end);\n\t\t},\n\t};\n}\n\nfunction isOpenItem(item: TranscriptItem): boolean {\n\treturn (item.kind === \"thinking\" || item.kind === \"text\") && !item.done;\n}\n\n/** Child-sourced text (thinking/text content, tool summaries, result previews, blocked reasons,\n * notice text) may contain cursor/erase CSI sequences, OSC title sequences, tabs and bare CRs.\n * Stripped (or, for CR, normalised to a newline) before wrapping, so the parent terminal never\n * executes them and a progress-style `\\r` can never move the cursor back to column 0 and overwrite\n * already-drawn output. `wrapTextWithAnsi` already splits on `\\r` like a newline, so normalising it\n * here does not change multi-line rendering. Exported for `ui/inspector.ts`, which draws other\n * child-sourced fields (status lines, output previews, errors) outside the transcript; those\n * single-line call sites must also run the result through `oneLine()` so the newline this\n * introduces does not split one logical row into two terminal lines. */\nexport function sanitizeForDisplay(text: string): string {\n\treturn replaceTabs(sanitizeBinaryOutput(stripAnsi(text))).replace(/\\r\\n?/g, \"\\n\");\n}\n\n/** A 16 KiB tail cut can land inside a UTF-16 surrogate pair, leaving an orphan low surrogate at\n * the start; `String.prototype.slice` does not know about pairs. Dropped before sanitizing so it\n * never reaches the terminal as a replacement-character glyph. */\nfunction trimLeadingLoneSurrogate(text: string): string {\n\tconst code = text.charCodeAt(0);\n\treturn code >= 0xdc00 && code <= 0xdfff ? text.slice(1) : text;\n}\n\nfunction appendCursor(lines: string[]): string[] {\n\tif (lines.length === 0) return [\"▌\"];\n\tconst last = lines[lines.length - 1] ?? \"\";\n\treturn [...lines.slice(0, -1), `${last}▌`];\n}\n\nfunction renderTextLikeItem(\n\ttheme: Theme,\n\tkind: \"thinking\" | \"text\",\n\ttext: string,\n\tdone: boolean,\n\tredacted: boolean,\n\toptions: TranscriptRenderOptions,\n\topen: boolean,\n): string[] {\n\tconst header = theme.fg(\"muted\", `▸ ${kind}`);\n\tif (kind === \"thinking\" && !options.showThinking) {\n\t\tconst hidden = redacted\n\t\t\t? \"▸ thinking (redacted, hidden)\"\n\t\t\t: `▸ thinking (hidden — ${keyText(\"app.thinking.toggle\")} to show)`;\n\t\treturn [fitLine(theme.fg(\"muted\", hidden), options.width)];\n\t}\n\tconst indent = \" \";\n\tconst bodyWidth = Math.max(1, options.width - indent.length - (done ? 0 : 1));\n\t// Sliced before sanitizing, not after: sanitizing the open item's full text on every delta would\n\t// cost up to `maxItemChars` instead of the intended 16 KiB bound. A partial escape sequence left\n\t// at the cut point becomes harmless literal text once `stripAnsi` sees it.\n\tconst source = sanitizeForDisplay(open ? trimLeadingLoneSurrogate(text.slice(-STREAM_TAIL_CHARS)) : text);\n\tconst wrapped = wrapTextWithAnsi(source, bodyWidth);\n\tconst withCursor = done ? wrapped : appendCursor(wrapped);\n\treturn [fitLine(header, options.width), ...withCursor.map((line) => fitLine(`${indent}${line}`, options.width))];\n}\n\nfunction formatToolElapsed(ms: number): string {\n\tif (ms < 1000) return `${Math.max(0, ms / 1000).toFixed(1)}s`;\n\treturn formatDuration(ms);\n}\n\ntype ToolItem = Extract<TranscriptItem, { kind: \"tool\" }>;\n\nfunction toolStatusRight(item: ToolItem, theme: Theme, now: number): string {\n\tswitch (item.status) {\n\t\tcase \"ok\": {\n\t\t\tconst elapsed = item.startedAt === undefined ? undefined : (item.endedAt ?? now) - item.startedAt;\n\t\t\treturn `${theme.fg(\"success\", \"✓\")}${elapsed === undefined ? \"\" : ` ${formatToolElapsed(elapsed)}`}`;\n\t\t}\n\t\tcase \"error\": {\n\t\t\tconst elapsed = item.startedAt === undefined ? undefined : (item.endedAt ?? now) - item.startedAt;\n\t\t\treturn `${theme.fg(\"error\", \"✗\")}${elapsed === undefined ? \"\" : ` ${formatToolElapsed(elapsed)}`}`;\n\t\t}\n\t\tcase \"blocked\":\n\t\t\treturn `${theme.fg(\"warning\", \"⚠\")} blocked: needs approval`;\n\t\tcase \"running\": {\n\t\t\t// A static glyph, not an animated spinner: only the focused row animates (§20.4), and this\n\t\t\t// item may be rendered outside the cache on every flush, so an animated frame here would\n\t\t\t// just be redundant churn.\n\t\t\tconst elapsed = item.startedAt === undefined ? undefined : now - item.startedAt;\n\t\t\treturn `${theme.fg(\"accent\", \"◐\")}${elapsed === undefined ? \"\" : ` ${formatToolElapsed(elapsed)}`}`;\n\t\t}\n\t\tcase \"pending\":\n\t\t\treturn theme.fg(\"dim\", \"·\");\n\t}\n}\n\nfunction renderToolItem(theme: Theme, item: ToolItem, options: TranscriptRenderOptions): string[] {\n\tconst summary = sanitizeForDisplay(item.summary);\n\tconst left = oneLine(`● ${item.name} ${summary}`.trim());\n\tconst right = toolStatusRight(item, theme, options.now);\n\tconst line = columns(\n\t\t[\n\t\t\t{ text: left, width: \"flex\" },\n\t\t\t{ text: right, width: visibleWidth(right) },\n\t\t],\n\t\toptions.width,\n\t\t1,\n\t);\n\tconst lines = [fitLine(line, options.width)];\n\tif (item.status === \"blocked\" && item.blockedReason) {\n\t\tconst indent = \" \";\n\t\tconst reason = sanitizeForDisplay(item.blockedReason);\n\t\tlines.push(\n\t\t\t...wrapTextWithAnsi(reason, Math.max(1, options.width - indent.length)).map((l) =>\n\t\t\t\tfitLine(`${indent}${l}`, options.width),\n\t\t\t),\n\t\t);\n\t}\n\tif (options.showToolPreviews && item.resultPreview) {\n\t\tconst indent = \" │ \";\n\t\tconst preview = sanitizeForDisplay(item.resultPreview);\n\t\tconst previewWidth = Math.max(1, options.width - indent.length);\n\t\tlines.push(\n\t\t\t...wrapTextWithAnsi(preview, previewWidth)\n\t\t\t\t.slice(0, TOOL_PREVIEW_MAX_LINES)\n\t\t\t\t.map((l) => fitLine(`${indent}${l}`, options.width)),\n\t\t);\n\t}\n\treturn lines;\n}\n\nfunction renderNoticeItem(theme: Theme, item: Extract<TranscriptItem, { kind: \"notice\" }>, width: number): string[] {\n\tconst color = item.level === \"error\" ? \"error\" : item.level === \"warning\" ? \"warning\" : \"muted\";\n\tconst text = sanitizeForDisplay(item.text);\n\treturn wrapTextWithAnsi(theme.fg(color, `! ${text}`), width).map((line) => fitLine(line, width));\n}\n\n/** A running tool item's status column (elapsed time) must keep advancing on every render, but\n * `rev` only changes on mutation, so it is never cached. */\nfunction isLiveTimed(item: TranscriptItem): boolean {\n\treturn item.kind === \"tool\" && item.status === \"running\";\n}\n\ninterface CacheEntry {\n\tkey: string;\n\tlines: readonly string[];\n}\n\n/** The line span `[start, end)` one transcript item occupies in the last `linesFor()` result, so a\n * caller can re-locate an item (e.g. a pinned pause anchor) after the surrounding lines shift. */\nexport interface TranscriptLineRange {\n\tseq: number;\n\tstart: number;\n\tend: number;\n}\n\n/**\n * Caches one transcript item's wrapped lines by `(seq, rev, width, showThinking, showToolPreviews,\n * open)`, so an unchanged item is not re-wrapped on every render. The last item is re-wrapped from\n * its last 16 KiB only while it is still open (streaming), so a growing thinking/text block does not\n * make every render O(item length). Entries are scoped to one `owner` (one agent's transcript):\n * `seq` is a per-agent counter that restarts at 0 for every agent, so entries from a previously\n * shown agent are discarded whenever the owner changes, instead of being served to the next one.\n */\nexport class TranscriptLineCache {\n\tprivate readonly theme: Theme;\n\tprivate owner: string | undefined;\n\tprivate entries = new Map<number, CacheEntry>();\n\tprivate ranges: readonly TranscriptLineRange[] = [];\n\n\tconstructor(theme: Theme) {\n\t\tthis.theme = theme;\n\t}\n\n\tlinesFor(\n\t\towner: string,\n\t\titems: readonly TranscriptItem[],\n\t\tdroppedItems: number,\n\t\toptions: TranscriptRenderOptions,\n\t): string[] {\n\t\tif (owner !== this.owner) {\n\t\t\tthis.entries.clear();\n\t\t\tthis.owner = owner;\n\t\t}\n\t\tconst lines: string[] = [];\n\t\tconst ranges: TranscriptLineRange[] = [];\n\t\tif (droppedItems > 0) {\n\t\t\tlines.push(fitLine(this.theme.fg(\"muted\", `… ${droppedItems} earlier items not kept`), options.width));\n\t\t}\n\t\tconst lastIndex = items.length - 1;\n\t\tconst liveSeqs = new Set<number>();\n\t\tfor (let i = 0; i <= lastIndex; i++) {\n\t\t\tconst item = items[i];\n\t\t\tif (!item) continue;\n\t\t\tliveSeqs.add(item.seq);\n\t\t\tconst open = i === lastIndex && isOpenItem(item);\n\t\t\tconst start = lines.length;\n\t\t\tif (isLiveTimed(item)) {\n\t\t\t\tlines.push(...this.renderItem(item, options, open));\n\t\t\t} else {\n\t\t\t\tconst key = `${item.rev}|${options.width}|${options.showThinking}|${options.showToolPreviews}|${open}`;\n\t\t\t\tconst cached = this.entries.get(item.seq);\n\t\t\t\tconst itemLines = cached && cached.key === key ? cached.lines : this.renderItem(item, options, open);\n\t\t\t\tif (!cached || cached.key !== key) this.entries.set(item.seq, { key, lines: itemLines });\n\t\t\t\tlines.push(...itemLines);\n\t\t\t}\n\t\t\tranges.push({ seq: item.seq, start, end: lines.length });\n\t\t}\n\t\tfor (const seq of this.entries.keys()) {\n\t\t\tif (!liveSeqs.has(seq)) this.entries.delete(seq);\n\t\t}\n\t\tthis.ranges = ranges;\n\t\treturn lines;\n\t}\n\n\t/** The item line ranges computed by the most recent `linesFor()` call. */\n\tlineRanges(): readonly TranscriptLineRange[] {\n\t\treturn this.ranges;\n\t}\n\n\tprivate renderItem(item: TranscriptItem, options: TranscriptRenderOptions, open: boolean): readonly string[] {\n\t\tswitch (item.kind) {\n\t\t\tcase \"thinking\":\n\t\t\t\treturn renderTextLikeItem(this.theme, \"thinking\", item.text, item.done, item.redacted, options, open);\n\t\t\tcase \"text\":\n\t\t\t\treturn renderTextLikeItem(this.theme, \"text\", item.text, item.done, false, options, open);\n\t\t\tcase \"tool\":\n\t\t\t\treturn renderToolItem(this.theme, item, options);\n\t\t\tcase \"notice\":\n\t\t\t\treturn renderNoticeItem(this.theme, item, options.width);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface UpdatePump {
|
|
2
|
+
schedule(runId: string, change: "fine" | "coarse"): void;
|
|
3
|
+
setIntervalMs(ms: number): void;
|
|
4
|
+
setFlushHandler(handler: (dirty: ReadonlyMap<string, boolean>) => void): void;
|
|
5
|
+
/** Schedules a "fine" change for runId every heartbeatMs. */
|
|
6
|
+
startHeartbeat(runId: string): void;
|
|
7
|
+
stopHeartbeat(runId: string): void;
|
|
8
|
+
flushNow(): void;
|
|
9
|
+
dispose(): void;
|
|
10
|
+
readonly activeTimers: number;
|
|
11
|
+
}
|
|
12
|
+
export interface UpdatePumpOptions {
|
|
13
|
+
intervalMs: number;
|
|
14
|
+
heartbeatMs?: number;
|
|
15
|
+
coarseDelayMs?: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function createUpdatePump(options: UpdatePumpOptions): UpdatePump;
|
|
18
|
+
//# sourceMappingURL=update-pump.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-pump.d.ts","sourceRoot":"","sources":["../../../src/core/polyphase/update-pump.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAAC;IACzD,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,eAAe,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,GAAG,IAAI,CAAC;IAC9E,6DAA6D;IAC7D,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,QAAQ,IAAI,IAAI,CAAC;IACjB,OAAO,IAAI,IAAI,CAAC;IAChB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,iBAAiB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,UAAU,CAEvE"}
|