pi-fabric 0.88.0 → 0.88.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../src/ui/conversation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAS,GAAG,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAenH,OAAO,EAAwC,KAAK,2CAA2C,EAAE,MAAM,0BAA0B,CAAC;AAClI,OAAO,EAAsB,KAAK,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AACjG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAKpF,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAIvE,MAAM,MAAM,0BAA0B,GAAG,OAAO,GAAG,UAAU,CAAC;AAE9D,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,UAAU,CAAC;IACn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AAO,CAAC,kBAAkB;IAO1B,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,QAAQ;IA8BhB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,UAAU;IAclB,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,aAAa;IAyCrB,OAAO,CAAC,mBAAmB;IAK3B,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,YAAY;IAcpB,OAAO,CAAC,iBAAiB;IA0BzB,OAAO,CAAC,QAAQ;IAOhB,OAAO,CAAC,cAAc;IA4BtB,OAAO,CAAC,mBAAmB;IAQ3B,OAAO,CAAC,SAAS;IAqBjB,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,YAAY;IA4BpB,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,cAAc;IAgBtB,OAAO,CAAC,UAAU;IA0BlB,OAAO,CAAC,WAAW;CAyCpB"}
|
package/dist/ui/conversation.js
CHANGED
|
@@ -2464,6 +2464,7 @@ var FabricConversationView = class {
|
|
|
2464
2464
|
const maxScroll = Math.max(0, this.lastBodyLength - this.lastBodyBudget);
|
|
2465
2465
|
const position = entry.following ? maxScroll : entry.scroll;
|
|
2466
2466
|
if (entry.pageAnchor === "end") entry.pageAnchor = void 0;
|
|
2467
|
+
if (entry.following && delta > 0) return;
|
|
2467
2468
|
const next = position + Math.trunc(delta);
|
|
2468
2469
|
entry.following = false;
|
|
2469
2470
|
if (next < 0 && !this.textSelection.dragging && this.options.loadOlder(this.currentId)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ui/conversation.ts", "../../src/ui/conversation-render.ts", "../../src/ui/conversation-selection.ts", "../../src/ui/conversation-history.ts", "../../src/ui/conversation-commands.ts", "../../src/ui/conversation-queue-store.ts", "../../src/ui/conversation-queue.ts"],
|
|
4
|
-
"sourcesContent": ["import { copyToClipboard } from \"@earendil-works/pi-coding-agent\";\nimport type { KeybindingsManager, Theme } from \"@earendil-works/pi-coding-agent\";\nimport type { Component, Focusable, KeyId, TUI, TuiMouseEvent, TuiMouseEventResult } from \"@earendil-works/pi-tui\";\nimport {\n CURSOR_MARKER,\n Editor,\n fuzzyFilter,\n getKeybindings,\n Input,\n Key,\n Loader,\n Text,\n matchesKey,\n truncateToWidth,\n visibleWidth,\n type EditorTheme,\n} from \"@earendil-works/pi-tui\";\nimport { FabricConversationTranscriptRenderer, type FabricConversationTranscriptRendererOptions } from \"./conversation-render.js\";\nimport { conversationFooter, type FabricConversationAppearance } from \"./conversation-chrome.js\";\nimport type { AgentUsage } from \"../agents/types.js\";\nimport { safeText } from \"./format.js\";\nimport type { CodePreviewSettings } from \"./code-preview.js\";\nimport type { NativeConversationTranscript } from \"./conversation-native-reader.js\";\nimport { defaultConversationTarget } from \"./conversation-targets.js\";\nimport { ConversationTextSelection } from \"./conversation-selection.js\";\nimport { appendConversationPrompt, conversationPromptHistory } from \"./conversation-history.js\";\nimport { conversationAssistantText, conversationCommandCompletion, CONVERSATION_COMMAND_HELP } from \"./conversation-commands.js\";\nimport { ConversationQueueStore } from \"./conversation-queue-store.js\";\nimport type { ConversationQueue } from \"./conversation-queue.js\";\nimport { isActiveStatus } from \"./types.js\";\n\nexport type FabricConversationDelivery = \"steer\" | \"followUp\";\n\nexport interface FabricConversationTarget {\n id: string;\n name: string;\n kind: \"main\" | \"peer\" | \"agent\" | \"actor\";\n parentId?: string;\n status: string;\n runner?: string;\n model?: string;\n thinking?: string;\n cwd?: string;\n branch?: string;\n usage?: AgentUsage;\n contextWindow?: number;\n canSteer: boolean;\n canFollowUp: boolean;\n canStop: boolean;\n readOnlyReason?: string;\n stale?: boolean;\n /** Latest activity timestamp; enables an unread marker in the target picker. */\n updatedAt?: number;\n}\n\nexport interface FabricConversationStateEntry {\n draft: string;\n following: boolean;\n scroll: number;\n pageAnchor: \"start\" | \"end\" | \"prepend\" | undefined;\n anchorLength?: number | undefined;\n toolsExpanded: boolean;\n hideThinking?: boolean;\n lastSeenUpdatedAt: number;\n /** Session-local composer history, oldest first; lazily seeded, like Pi. */\n promptHistory?: string[];\n}\n\nconst STATE_ENTRY_LIMIT = 128;\n\n/** Session-owned in-flight send; survives view close/reopen, cleared on clear(). */\nexport interface FabricConversationPendingSend {\n id: string;\n message: string;\n delivery: FabricConversationDelivery;\n}\n\n/**\n * Per-target view state owned by the parent controller. Created once and\n * reused across overlay opens so drafts, scroll/following, and the selected\n * target survive close/reopen; clear() on session shutdown (and bumps epoch\n * so in-flight sends from a previous session never mutate new state).\n */\nexport class FabricConversationState {\n readonly queues = new ConversationQueueStore();\n selectedId: string | undefined;\n private epochCounter = 0;\n private readonly entries = new Map<string, FabricConversationStateEntry>();\n private readonly pendingSends = new Set<FabricConversationPendingSend>();\n\n get epoch(): number {\n return this.epochCounter;\n }\n\n hasPendingSend(id: string, message: string): boolean {\n for (const pending of this.pendingSends) {\n if (pending.id === id && pending.message === message) return true;\n }\n return false;\n }\n\n addPendingSend(pending: FabricConversationPendingSend): void {\n this.pendingSends.add(pending);\n }\n\n /** Acknowledged: drop the pending marker and clear only the exact accepted draft. */\n resolvePendingSend(id: string, message: string): void {\n for (const pending of this.pendingSends) {\n if (pending.id !== id || pending.message !== message) continue;\n this.pendingSends.delete(pending);\n const entry = this.entries.get(id);\n if (entry && entry.draft === message) entry.draft = \"\";\n return;\n }\n }\n\n /** Rejected: drop the pending marker; the raw draft stays untouched. */\n failPendingSend(id: string, message: string): void {\n for (const pending of this.pendingSends) {\n if (pending.id !== id || pending.message !== message) continue;\n this.pendingSends.delete(pending);\n return;\n }\n }\n\n /** Live view state for a target; creates (and may evict empty) entries. */\n view(id: string): FabricConversationStateEntry {\n const existing = this.entries.get(id);\n if (existing) {\n this.entries.delete(id);\n this.entries.set(id, existing);\n return existing;\n }\n const created: FabricConversationStateEntry = {\n draft: \"\",\n following: true,\n scroll: 0,\n pageAnchor: undefined,\n toolsExpanded: false,\n lastSeenUpdatedAt: 0,\n };\n this.entries.set(id, created);\n this.enforceLimit();\n return created;\n }\n\n /** Non-mutating lookup; unread checks must never create or evict drafts. */\n peek(id: string): FabricConversationStateEntry | undefined {\n return this.entries.get(id);\n }\n\n clear(): void {\n this.queues.clear();\n this.entries.clear();\n this.pendingSends.clear();\n this.selectedId = undefined;\n this.epochCounter++;\n }\n\n private enforceLimit(): void {\n while (this.entries.size > STATE_ENTRY_LIMIT) {\n let evicted = false;\n for (const key of this.entries.keys()) {\n if (key === this.selectedId) continue;\n const entry = this.entries.get(key);\n // Only discard untouched lightweight navigation state. Pinned scroll,\n // loaded-page anchors, queues and in-flight sends outlive reader suspension.\n if (entry && entry.draft === \"\" && entry.following && !entry.pageAnchor &&\n !entry.toolsExpanded && entry.hideThinking === undefined &&\n !this.queues.get(key) && ![...this.pendingSends].some((pending) => pending.id === key)) {\n this.entries.delete(key);\n evicted = true;\n break;\n }\n }\n if (!evicted) break;\n }\n }\n}\n\nexport interface FabricConversationOptions {\n targets: () => FabricConversationTarget[];\n initialTargetId?: string;\n state: FabricConversationState;\n transcript: (id: string, followLatest: boolean) => NativeConversationTranscript;\n loadOlder: (id: string) => boolean;\n loadNewer: (id: string) => boolean;\n loadLatest: (id: string) => boolean;\n send: (id: string, message: string, delivery: FabricConversationDelivery) => Promise<unknown>;\n stop: (id: string) => Promise<unknown>;\n close: () => void;\n copyToClipboard?: (text: string) => Promise<void>;\n onTargetChange?: (id: string) => void;\n keybindings?: Pick<KeybindingsManager, \"matches\" | \"getKeys\">;\n codePreviewSettings?: CodePreviewSettings;\n appearance?: FabricConversationAppearance;\n rendererOptions?: FabricConversationTranscriptRendererOptions | undefined;\n queueEvents?: { emit(channel: string, data: unknown): void } | undefined;\n}\n\ninterface Feedback {\n text: string;\n kind: \"info\" | \"error\";\n at: number;\n}\n\nconst FEEDBACK_TTL_MS = 8_000;\nconst FOLLOW_UP_FALLBACK: KeyId[] = [\"alt+enter\", \"ctrl+q\"];\nconst TOOLS_EXPAND_FALLBACK: KeyId[] = [\"ctrl+o\"];\n\nconst conversationEditorTheme = (theme: Theme, thinking: () => string | undefined): EditorTheme => ({\n borderColor: (value: string) => {\n const level = thinking();\n const color = level === \"minimal\" ? \"thinkingMinimal\" : level === \"low\" ? \"thinkingLow\"\n : level === \"medium\" ? \"thinkingMedium\" : level === \"high\" ? \"thinkingHigh\"\n : level === \"xhigh\" ? \"thinkingXhigh\" : level === \"max\" ? \"thinkingMax\" : \"borderMuted\";\n return theme.fg(color, value);\n },\n selectList: {\n selectedPrefix: (text: string) => theme.fg(\"accent\", text),\n selectedText: (text: string) => theme.fg(\"accent\", text),\n description: (text: string) => theme.fg(\"muted\", text),\n scrollInfo: (text: string) => theme.fg(\"muted\", text),\n noMatch: (text: string) => theme.fg(\"muted\", text),\n },\n});\n\nconst errorText = (error: unknown): string => {\n if (error instanceof Error) return error.message;\n return String(error ?? \"\");\n};\n\nconst isMainTarget = (target: FabricConversationTarget | undefined): boolean =>\n target?.kind === \"main\";\n\ninterface PickerRow {\n target: FabricConversationTarget;\n depth: number;\n}\n\nexport class FabricConversationView implements Component, Focusable {\n private focusState = true;\n private readonly tui: TUI;\n private readonly theme: Theme;\n private readonly options: FabricConversationOptions;\n private readonly state: FabricConversationState;\n private readonly renderer: FabricConversationTranscriptRenderer;\n private editor: Editor | undefined;\n private suspendedEditor: Editor | undefined;\n private editorEpoch = -1;\n private pickerInput: Input | undefined;\n private pickerRows: PickerRow[] = [];\n private pickerSelectedId: string | undefined;\n private mode: \"conversation\" | \"picker\" = \"conversation\";\n private currentId: string | undefined;\n private feedback: Feedback | undefined;\n private commandNotification: { component: Text; epoch: number; pendingResult?: Text } | undefined;\n private notificationScope = 0;\n private stopConfirmId: string | undefined;\n private disposed = false;\n private lastBodyLength = 0;\n private lastBody: string[] = [];\n private lastBodyBudget = 1;\n private editorTop = 0;\n private editorHeight = 0;\n private ownsMouseMode = false;\n private targets: FabricConversationTarget[] = [];\n private targetsKey = \"\";\n private readonly targetsById = new Map<string, FabricConversationTarget>();\n private nonMain: FabricConversationTarget[] = [];\n private main: FabricConversationTarget | undefined;\n private observationKey = \"\";\n private observedTranscript: NativeConversationTranscript | undefined;\n private pickerKey = \"\";\n private working: Loader | undefined;\n private workingTargetId: string | undefined;\n private readonly textSelection = new ConversationTextSelection();\n private selectionWidth = 0;\n private selectionWasFollowing = false;\n private bodyTop = 0;\n private bodyHeight = 0;\n private copyVersion = 0;\n private copyTask: Promise<void> = Promise.resolve();\n\n constructor(\n tui: TUI,\n theme: Theme,\n options: FabricConversationOptions,\n ) {\n this.tui = tui;\n this.theme = theme;\n this.options = options;\n this.state = options.state;\n this.updateTargets();\n this.renderer = new FabricConversationTranscriptRenderer(tui, theme, {\n ...options.rendererOptions,\n imageWidthCells: options.appearance?.imageWidthCells,\n });\n this.editor = this.createEditor();\n this.editorEpoch = this.state.epoch;\n // An explicit initialTargetId must win over state.selectedId so reissuing\n // \"/fabric chat B\" focuses B instead of reopening the previously selected A.\n const nonMain = this.nonMainTargets();\n const requested = options.initialTargetId ?? defaultConversationTarget(nonMain, options.state.selectedId)?.id;\n const requestedTarget = requested\n ? this.targetById(requested)\n : undefined;\n const resolved =\n requested && requestedTarget && !isMainTarget(requestedTarget)\n ? requested\n : nonMain[0]?.id;\n if (resolved) this.applySelection(resolved, false);\n if (!this.currentId) this.currentId = nonMain[0]?.id;\n // Regular Pi leaves mouse input to terminal scrollback. This preview owns\n // a separate viewport; capture wheel and drag input and restore on close.\n if (tui.mode === \"regular\") {\n tui.terminal.write(\"\\x1b[?1000h\\x1b[?1002h\\x1b[?1006h\");\n this.ownsMouseMode = true;\n }\n }\n\n private createEditor(withHistory = true): Editor {\n // Own method only: assignment through Pi's live proxy would mutate Main.\n const editorTui = Object.create(this.tui, { requestRender: { value: () => {\n if (!this.disposed && this.editor === editor) this.tui.requestRender();\n } } }) as TUI;\n const editor = new Editor(editorTui, conversationEditorTheme(this.theme, () => this.currentTarget()?.thinking), {\n paddingX: this.options.appearance?.editorPaddingX ?? 0,\n });\n editor.focused = this.focusState && this.mode === \"conversation\";\n if (!withHistory) return editor;\n editor.setAutocompleteProvider(conversationCommandCompletion(() =>\n !this.disposed && this.editor === editor && this.mode === \"conversation\" && !this.state.queues.get(this.currentId ?? \"\")?.editingActive));\n editor.onSubmit = (text) => {\n if (this.disposed || this.editor !== editor) return;\n // Native completion submits after clearing the editor; restore for routing.\n editor.setText(text);\n this.submit(\"steer\");\n };\n editor.onChange = (text) => {\n if (this.editor === editor && this.currentId && !this.state.queues.get(this.currentId)?.editingActive) this.state.view(this.currentId).draft = text;\n };\n for (const text of this.currentId ? this.state.peek(this.currentId)?.promptHistory ?? [] : []) editor.addToHistory(text);\n return editor;\n }\n\n private releaseEditor(editor: Editor | undefined): void {\n if (!editor) return;\n editor.setAutocompleteProvider(conversationCommandCompletion(() => false));\n editor.focused = false;\n delete editor.onSubmit;\n delete editor.onChange;\n }\n\n private resetEditor(): void {\n this.releaseEditor(this.editor);\n this.releaseEditor(this.suspendedEditor);\n this.suspendedEditor = undefined;\n this.editor = this.createEditor();\n this.editorEpoch = this.state.epoch;\n }\n\n private ensureEditorEpoch(): void {\n if (this.editorEpoch === this.state.epoch) return;\n this.observedTranscript = undefined;\n this.observationKey = \"\";\n this.resetEditor();\n if (this.currentId) this.editor?.setText(this.state.view(this.currentId).draft);\n }\n\n private initializePromptHistory(): void {\n if (!this.currentId || !this.editor || this.suspendedEditor) return;\n const entry = this.state.view(this.currentId);\n if (entry.promptHistory !== undefined) return;\n const transcript = this.observedTranscript ?? this.options.transcript(this.currentId, entry.following);\n // A worker may not have written its initial transcript yet; retry later.\n if (transcript.unavailable) return;\n entry.promptHistory = conversationPromptHistory(transcript);\n for (const text of entry.promptHistory) this.editor.addToHistory(text);\n }\n\n private rememberPrompt(text: string): void {\n if (!this.currentId) return;\n this.initializePromptHistory();\n const entry = this.state.view(this.currentId);\n appendConversationPrompt(entry.promptHistory ??= [], text);\n this.editor?.addToHistory(text);\n }\n\n private setQueueEditorText(text: string): void {\n let restoredText = text;\n const editing = this.currentId && this.state.queues.get(this.currentId)?.editingActive;\n if (editing && !this.suspendedEditor) {\n // Preserve the composer's native history/draft; queued rows never browse it.\n this.suspendedEditor = this.editor;\n if (this.suspendedEditor) this.suspendedEditor.focused = false;\n this.editor = this.createEditor(false);\n } else if (!editing && this.suspendedEditor) {\n this.releaseEditor(this.editor);\n this.editor = this.suspendedEditor;\n this.suspendedEditor = undefined;\n this.editor.focused = this.focusState && this.mode === \"conversation\";\n // An acknowledgement may have cleared the composer while a row was open.\n restoredText = this.currentId ? this.state.view(this.currentId).draft : text;\n }\n this.editor?.setText(restoredText);\n }\n\n get focused(): boolean {\n return this.focusState;\n }\n\n set focused(value: boolean) {\n this.focusState = value;\n if (this.mode === \"picker\") {\n if (this.pickerInput) this.pickerInput.focused = value;\n if (this.editor) this.editor.focused = false;\n return;\n }\n if (this.editor) this.editor.focused = value;\n }\n\n /** Re-focus a target while the view is open; selecting Main closes to the native session. */\n selectTarget(id: string): void {\n this.updateTargets();\n this.applySelection(id, true);\n }\n\n handleInput(data: string): void {\n if (this.disposed) return;\n this.ensureEditorEpoch();\n this.updateTargets();\n // Fullscreen Pi dispatches normalized events; regular mode forwards SGR.\n const mouse = /^\\x1b\\[<(\\d+);(\\d+);(\\d+)([Mm])$/.exec(data);\n if (mouse) {\n const button = Number(mouse[1]);\n const wheel = (button & 64) !== 0;\n const release = mouse[4] === \"m\" || (!wheel && (button & 3) === 3 && !(button & 32));\n this.handleMouse({ type: wheel ? \"wheel\" : release ? \"release\" : (button & 32) ? \"drag\" : \"press\",\n button: wheel ? \"none\" : (button & 3) === 0 ? \"left\" : (button & 3) === 1 ? \"middle\" : (button & 3) === 2 ? \"right\" : \"none\",\n ...(wheel ? { wheelDelta: (button & 1) === 0 ? -3 : 3 } : {}),\n x: Number(mouse[2]) - 1, y: Number(mouse[3]) - 1, screenX: Number(mouse[2]) - 1, screenY: Number(mouse[3]) - 1,\n width: this.tui.terminal.columns, height: this.terminalRows(), shift: !!(button & 4), alt: !!(button & 8), ctrl: !!(button & 16) });\n return;\n }\n if (this.mode === \"picker\") {\n this.handlePickerInput(data);\n this.tui.requestRender();\n return;\n }\n this.handleConversationInput(data);\n this.tui.requestRender();\n }\n\n handleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined {\n if (this.disposed) return undefined;\n this.ensureEditorEpoch();\n this.updateTargets();\n if (event.type === \"wheel\") {\n if (this.mode === \"picker\") this.movePickerSelection((event.wheelDelta ?? 0) < 0 ? -1 : 1);\n else this.scrollBy(event.wheelDelta ?? 0);\n this.tui.requestRender();\n return { handled: true };\n }\n if (this.mode !== \"conversation\" || !this.currentId) return { handled: true };\n const entry = this.state.view(this.currentId);\n const inBody = event.y >= this.bodyTop && event.y < this.bodyTop + this.bodyHeight;\n const row = entry.scroll + Math.max(0, Math.min(this.bodyHeight - 1, event.y - this.bodyTop));\n if (event.type === \"press\" && event.button === \"left\" && inBody) {\n this.selectionWasFollowing = entry.following;\n entry.following = false;\n this.textSelection.start(this.lastBody, row, event.x);\n this.tui.requestRender();\n return { handled: true, capture: true };\n }\n if (this.textSelection.dragging && (event.type === \"drag\" || event.type === \"release\")) {\n if (event.type === \"drag\") this.textSelection.move(row, event.x);\n else {\n this.textSelection.finish(row, event.x);\n if (!this.textSelection.active && this.selectionWasFollowing) entry.following = true;\n if (this.textSelection.active && (this.options.appearance?.copyOnSelect ?? true)) this.copySelection();\n }\n this.tui.requestRender();\n return { handled: true, render: true };\n }\n if (event.type === \"press\") this.textSelection.clear();\n if (event.y >= this.editorTop && event.y < this.editorTop + this.editorHeight) {\n return this.editor?.handleMouse({ ...event, y: event.y - this.editorTop, height: this.editorHeight }) ?? { handled: true };\n }\n // Never fall back to the host's selection or paste handlers behind an overlay.\n return { handled: true };\n }\n\n render(width: number): string[] {\n if (this.disposed || width <= 0) return [];\n this.updateTargets();\n if (width !== this.selectionWidth) {\n this.textSelection.clear();\n this.selectionWidth = width;\n }\n const rows = Math.max(1, this.terminalRows());\n this.markCurrentTargetSeen();\n this.reconcileEditor();\n const target = this.currentTarget();\n const queue = this.mode === \"conversation\" ? this.currentQueue() : undefined;\n this.observe();\n const liveTranscriptLines = this.mode === \"conversation\" ? this.transcriptLines(width) : [];\n const transcriptLines = this.textSelection.source ?? liveTranscriptLines;\n let queueLines = queue?.render(width) ?? [];\n // Native components own their interior padding. Giving them the full width\n // keeps user backgrounds and editor rules flush with both terminal edges.\n let editorLines = this.mode === \"conversation\" && !(queue?.editingActive && queue.mode === \"extension\") ? this.renderEditorLines(width) : [];\n const editorBudget = Math.min(editorLines.length, Math.max(1, rows - (rows >= 6 ? 3 : 0)));\n if (editorLines.length > editorBudget) {\n const cursor = Math.max(0, editorLines.findIndex((line) => line.includes(CURSOR_MARKER)));\n const start = Math.max(0, Math.min(cursor - Math.floor(editorBudget / 2), editorLines.length - editorBudget));\n editorLines = editorLines.slice(start, start + editorBudget);\n }\n let remaining = rows - editorLines.length;\n const footer = this.mode === \"conversation\"\n ? conversationFooter(target, this.theme, width).slice(0, Math.max(0, remaining - 1))\n : [];\n remaining -= footer.length;\n const head: string[] = [];\n if (remaining > 0) {\n head.push(this.breadcrumbLine(width));\n remaining--;\n }\n const feedback = this.currentFeedbackLine(width);\n if (feedback !== undefined && remaining > 1) {\n head.push(feedback);\n remaining--;\n }\n const hints = this.mode === \"conversation\" && remaining > 2 ? [this.hintsLine(width)] : [];\n remaining -= hints.length;\n const queueBudget = Math.max(0, remaining - 1);\n if (queueLines.length > queueBudget) {\n const cursor = queueLines.findIndex((line) => line.includes(CURSOR_MARKER));\n const start = Math.max(0, Math.min(cursor < 0 ? 0 : cursor - Math.floor(queueBudget / 2), queueLines.length - queueBudget));\n queueLines = queueLines.slice(start, start + queueBudget);\n }\n remaining -= queueLines.length;\n this.editorTop = rows - editorLines.length - footer.length - hints.length;\n this.editorHeight = editorLines.length;\n const body = remaining <= 0 ? [] : this.mode === \"picker\"\n ? this.pickerLines(width, remaining)\n : this.windowBody(transcriptLines, remaining, this.transcriptTail(width, remaining));\n this.bodyTop = head.length;\n const scroll = this.currentId ? this.state.view(this.currentId).scroll : 0;\n this.bodyHeight = this.mode === \"conversation\" ? Math.max(0, Math.min(remaining, this.lastBody.length - scroll)) : 0;\n if (this.textSelection.active) {\n for (let row = 0; row < this.bodyHeight; row++) body[row] = this.textSelection.highlight(body[row]!, scroll + row, this.theme);\n }\n while (body.length < remaining) body.push(\"\");\n return [...head, ...body.slice(0, remaining), ...queueLines, ...editorLines, ...footer, ...hints]\n .slice(0, rows)\n .map((line) => visibleWidth(line) <= width ? line : truncateToWidth(line, width, \"\"));\n }\n\n /** Observe files without rendering native history; true means a visible change\n * or a live animation still needs the normal TUI render path. */\n refresh(): boolean {\n if (this.disposed) return false;\n this.updateTargets();\n const changed = this.observe();\n return changed || (this.mode === \"conversation\" && this.selectedTargetIsWorking());\n }\n\n private observe(): boolean {\n const entry = this.currentId ? this.state.view(this.currentId) : undefined;\n const transcript = this.mode === \"conversation\" && this.currentTarget() && this.currentId && entry\n ? this.options.transcript(this.currentId, entry.following) : undefined;\n if (transcript && this.currentId) this.state.queues.sync(this.currentId, transcript);\n const key = JSON.stringify([this.targetsKey, this.currentId, this.mode, entry?.draft,\n this.feedback && Date.now() - this.feedback.at <= FEEDBACK_TTL_MS ? this.feedback : undefined,\n transcript && [transcript.sourceId, transcript.sessionId, transcript.sessionFile, transcript.eventsFile,\n transcript.revision, transcript.status, transcript.leafId, transcript.historyComplete, transcript.hasMore,\n transcript.hasNewer, transcript.unavailable, transcript.error, transcript.pendingMessages]]);\n const previous = this.observedTranscript;\n const changed = key !== this.observationKey || previous?.messages !== transcript?.messages ||\n previous?.entries !== transcript?.entries || previous?.streaming !== transcript?.streaming;\n this.observationKey = key;\n this.observedTranscript = transcript;\n this.syncWorkingIndicator();\n return changed;\n }\n\n private selectedTargetIsWorking(): boolean {\n const target = this.currentTarget();\n if (!target || target.stale) return false;\n // A killed worker can leave a partial message/tool in its log forever.\n // That retained tail must not override terminal or unavailable ownership.\n return isActiveStatus(target.status);\n }\n\n private syncWorkingIndicator(): void {\n const active = !this.disposed && this.mode === \"conversation\" && this.currentId && this.selectedTargetIsWorking();\n if (!active) {\n this.stopWorkingIndicator();\n return;\n }\n if (this.working && this.workingTargetId === this.currentId) return;\n this.stopWorkingIndicator();\n const id = this.currentId;\n this.workingTargetId = id;\n // Pi's standalone WorkingStatusIndicator delegates to this public Loader.\n this.working = new Loader({ requestRender: () => {\n if (!this.disposed && this.mode === \"conversation\" && this.currentId === id) this.tui.requestRender();\n } } as TUI, (text) => this.theme.fg(\"accent\", text), (text) => this.theme.fg(\"muted\", text), \"Working\");\n }\n\n private stopWorkingIndicator(): void {\n this.working?.stop();\n this.working = undefined;\n this.workingTargetId = undefined;\n }\n\n invalidate(): void {\n this.working?.invalidate();\n this.commandNotification?.component.invalidate();\n this.commandNotification?.pendingResult?.invalidate();\n this.renderer.invalidate();\n this.editor?.invalidate();\n this.pickerInput?.invalidate();\n }\n\n dispose(): void {\n if (this.currentId) this.state.queues.detach(this.currentId);\n this.disposed = true;\n this.clearCommandNotification();\n this.copyVersion++;\n this.textSelection.clear();\n this.stopWorkingIndicator();\n this.releaseEditor(this.editor);\n this.releaseEditor(this.suspendedEditor);\n this.suspendedEditor = undefined;\n this.editor = undefined;\n this.pickerInput = undefined;\n this.observedTranscript = undefined;\n this.lastBody = [];\n this.renderer.dispose();\n if (this.ownsMouseMode) {\n this.ownsMouseMode = false;\n this.tui.terminal.write(\"\\x1b[?1002l\\x1b[?1000l\\x1b[?1006l\");\n }\n }\n\n /** Keep the editor in sync with the shared session draft (e.g. after an ack\n * that landed while a previous view instance was disposed). */\n private reconcileEditor(): void {\n this.ensureEditorEpoch();\n if (this.mode !== \"conversation\" || !this.editor || !this.currentId) return;\n if (this.state.queues.get(this.currentId)?.editingActive) return;\n if (this.state.hasPendingSend(this.currentId, this.editor.getText())) return;\n const draft = this.state.view(this.currentId).draft;\n if (this.editor.getText() !== draft) this.editor.setText(draft);\n }\n\n private applySelection(id: string, requestRender: boolean): void {\n if (this.currentId && this.currentId !== id) this.state.queues.detach(this.currentId);\n const target = this.targetById(id);\n if (!target) {\n this.feedback = {\n text: `Unknown target ${safeText(id)}`,\n kind: \"error\",\n at: Date.now(),\n };\n if (requestRender) this.tui.requestRender();\n return;\n }\n if (isMainTarget(target)) {\n this.options.close();\n return;\n }\n const changed = this.currentId !== id;\n if (changed) {\n this.clearCommandNotification();\n this.copyVersion++;\n this.textSelection.clear();\n this.stopWorkingIndicator();\n this.observedTranscript = undefined;\n this.observationKey = \"\";\n this.lastBody = [];\n this.lastBodyLength = 0;\n this.renderer.invalidate();\n this.options.onTargetChange?.(id);\n }\n this.currentId = id;\n this.state.selectedId = id;\n if (changed) this.resetEditor();\n const entry = this.state.view(id);\n entry.lastSeenUpdatedAt = target.updatedAt ?? Date.now();\n this.stopConfirmId = undefined;\n this.closePicker();\n this.feedback = undefined;\n this.editor?.setText(entry.draft);\n if (requestRender) this.tui.requestRender();\n }\n\n private markCurrentTargetSeen(): void {\n if (!this.currentId) return;\n const target = this.targetById(this.currentId);\n if (!target?.updatedAt) return;\n const entry = this.state.view(this.currentId);\n if (entry.lastSeenUpdatedAt < target.updatedAt) entry.lastSeenUpdatedAt = target.updatedAt;\n }\n\n private updateTargets(): void {\n // One provider observation per frame/input, including providers that mutate\n // their roster in place. The fingerprint contains metadata, never history.\n const targets = this.options.targets();\n const key = JSON.stringify(targets);\n if (key === this.targetsKey) return;\n this.targetsKey = key;\n this.targets = targets;\n this.targetsById.clear();\n for (const target of targets) {\n if (!this.targetsById.has(target.id)) this.targetsById.set(target.id, target);\n }\n this.nonMain = targets.filter((target) => !isMainTarget(target));\n this.main = targets.find(isMainTarget);\n }\n\n private currentTargets(): FabricConversationTarget[] {\n return this.targets;\n }\n\n private nonMainTargets(): FabricConversationTarget[] {\n return this.nonMain;\n }\n\n private currentTarget(): FabricConversationTarget | undefined {\n return this.currentId ? this.targetById(this.currentId) : undefined;\n }\n\n private mainTarget(): FabricConversationTarget | undefined {\n return this.main;\n }\n\n private targetById(id: string): FabricConversationTarget | undefined {\n return this.targetsById.get(id);\n }\n\n private terminalRows(): number {\n return this.tui.terminal?.rows ?? process.stdout.rows ?? 28;\n }\n\n /**\n * Respects a configured binding; when an injected manager reports no keys\n * the binding is unbound (never falls back), and only the default global\n * manager (no injection) falls back to hard-coded keys.\n */\n private bindingMatches(\n data: string,\n binding: \"app.message.followUp\" | \"app.message.copy\" | \"app.tools.expand\" | \"app.thinking.toggle\",\n fallbackKeys: KeyId[],\n ): boolean {\n if (this.options.keybindings) {\n const keys = this.options.keybindings.getKeys(binding);\n return keys.length > 0 && this.options.keybindings.matches(data, binding);\n }\n const global = getKeybindings();\n const keys = global.getKeys(binding);\n if (keys.length > 0) return global.matches(data, binding);\n return fallbackKeys.some((key) => matchesKey(data, key));\n }\n\n private bindingHint(\n binding: \"app.message.followUp\" | \"app.message.copy\" | \"app.tools.expand\" | \"app.thinking.toggle\",\n fallbackLabel: string,\n ): string {\n const manager = this.options.keybindings ?? getKeybindings();\n const keys = manager.getKeys(binding);\n if (keys.length > 0) return keys.join(\"/\");\n return this.options.keybindings ? \"unbound\" : fallbackLabel;\n }\n\n private handleConversationInput(data: string): void {\n const editor = this.editor;\n if (!editor) return;\n this.feedback = undefined;\n if (this.stopConfirmId === undefined && this.bindingMatches(data, \"app.message.copy\", [\"ctrl+shift+c\"])) {\n this.copyResponse(undefined, true);\n return;\n }\n if (this.stopConfirmId === undefined && this.textSelection.active && matchesKey(data, Key.ctrl(\"c\"))) {\n this.copySelection();\n return;\n }\n if (this.stopConfirmId === undefined && this.textSelection.source && matchesKey(data, Key.escape)) {\n this.textSelection.clear();\n return;\n }\n const queue = this.currentQueue();\n if (this.stopConfirmId === undefined && !queue?.editingActive && editor.isShowingAutocomplete() &&\n [Key.enter, Key.tab, Key.up, Key.down, Key.escape].some((key) => matchesKey(data, key))) {\n editor.handleInput(data);\n return;\n }\n if (this.stopConfirmId === undefined && queue?.handleInput(data)) return;\n\n if (this.stopConfirmId !== undefined) {\n if (matchesKey(data, Key.enter)) {\n const target = this.targetById(this.stopConfirmId);\n this.stopConfirmId = undefined;\n if (target) this.dispatchStop(target);\n return;\n }\n if (matchesKey(data, Key.escape)) {\n this.stopConfirmId = undefined;\n this.notifyCommand(\"Stop cancelled\");\n return;\n }\n this.stopConfirmId = undefined;\n this.notifyCommand(\"Stop cancelled\");\n }\n\n if (this.bindingMatches(data, \"app.message.followUp\", FOLLOW_UP_FALLBACK)) {\n this.submit(\"followUp\");\n return;\n }\n if (matchesKey(data, Key.enter)) {\n this.submit(\"steer\");\n return;\n }\n if (matchesKey(data, Key.ctrl(\"c\"))) {\n if (editor.getText().length > 0) editor.setText(\"\");\n return;\n }\n if (matchesKey(data, Key.escape)) {\n this.options.close();\n return;\n }\n if (matchesKey(data, Key.ctrl(\"n\"))) {\n this.openPicker();\n return;\n }\n if (matchesKey(data, \"ctrl+tab\")) {\n this.cycleTarget(1);\n return;\n }\n if (matchesKey(data, \"shift+ctrl+tab\")) {\n this.cycleTarget(-1);\n return;\n }\n if (matchesKey(data, \"ctrl+shift+left\")) {\n this.navigateParent();\n return;\n }\n if (matchesKey(data, \"ctrl+shift+right\")) {\n this.navigateFirstChild();\n return;\n }\n if (matchesKey(data, \"alt+left\") && editor.getText().length === 0) {\n this.navigateParent();\n return;\n }\n if (matchesKey(data, \"alt+right\") && editor.getText().length === 0) {\n this.navigateFirstChild();\n return;\n }\n const viewportKeys = getKeybindings();\n if (viewportKeys.matches(data, \"tui.altScreen.previousPrompt\")) { this.scrollPrompt(-1); return; }\n if (viewportKeys.matches(data, \"tui.altScreen.nextPrompt\")) { this.scrollPrompt(1); return; }\n if (viewportKeys.matches(data, \"tui.altScreen.lineUp\")) { this.scrollBy(-1); return; }\n if (viewportKeys.matches(data, \"tui.altScreen.lineDown\")) { this.scrollBy(1); return; }\n if (viewportKeys.matches(data, \"tui.altScreen.pageUp\")) { this.scrollBy(-Math.max(1, this.lastBodyBudget - 2)); return; }\n if (viewportKeys.matches(data, \"tui.altScreen.pageDown\")) { this.scrollBy(Math.max(1, this.lastBodyBudget - 2)); return; }\n if (viewportKeys.matches(data, \"tui.altScreen.halfPageUp\")) { this.scrollBy(-Math.max(1, Math.floor(this.lastBodyBudget / 2))); return; }\n if (viewportKeys.matches(data, \"tui.altScreen.halfPageDown\")) { this.scrollBy(Math.max(1, Math.floor(this.lastBodyBudget / 2))); return; }\n if (viewportKeys.matches(data, \"tui.altScreen.top\")) { this.scrollToTop(); return; }\n if (viewportKeys.matches(data, \"tui.altScreen.bottom\")) { this.followLatest(); return; }\n if (this.bindingMatches(data, \"app.thinking.toggle\", [\"ctrl+t\"])) {\n this.textSelection.clear();\n if (this.currentId) {\n const entry = this.state.view(this.currentId);\n entry.hideThinking = !(entry.hideThinking ?? this.options.appearance?.hideThinkingBlock ?? false);\n }\n return;\n }\n if (this.bindingMatches(data, \"app.tools.expand\", TOOLS_EXPAND_FALLBACK)) {\n this.textSelection.clear();\n if (this.currentId) {\n const entry = this.state.view(this.currentId);\n entry.toolsExpanded = !entry.toolsExpanded;\n }\n return;\n }\n if (viewportKeys.matches(data, \"tui.editor.cursorUp\") || viewportKeys.matches(data, \"tui.editor.cursorDown\") ||\n viewportKeys.matches(data, \"tui.editor.historyPrevious\") || viewportKeys.matches(data, \"tui.editor.historyNext\")) this.initializePromptHistory();\n editor.handleInput(data);\n }\n\n private clearCommandNotification(): void {\n this.commandNotification = undefined;\n this.notificationScope++;\n }\n\n private notifyCommand(message: string, kind: Feedback[\"kind\"] = \"info\",\n options: { reserve?: string; reveal?: boolean } = {}): void {\n if (this.disposed || this.mode !== \"conversation\" || !this.currentId || !this.currentTarget()) return;\n this.feedback = undefined;\n // Pi showStatus/showError use Spacer(1) + Text, not the input/status dock.\n // Retain one local result, rather than implement a full notification history.\n const text = safeText(message).slice(0, 4096);\n this.commandNotification = {\n component: new Text(this.theme.fg(kind === \"error\" ? \"error\" : \"dim\", kind === \"error\" ? `Error: ${text}` : text),\n kind === \"error\" ? this.options.appearance?.outputPad ?? 1 : 1, 0),\n epoch: this.state.epoch,\n ...(options.reserve !== undefined ? { pendingResult: new Text(this.theme.fg(\"dim\", safeText(options.reserve).slice(0, 4096)), 1, 0) } : {}),\n };\n // Reveal the result in the loaded window; do not fetch newer history or\n // change following/selection when the user is inspecting an older page.\n if (options.reveal !== false) {\n const entry = this.state.view(this.currentId);\n entry.pageAnchor = entry.following ? undefined : \"end\";\n entry.anchorLength = undefined;\n }\n this.tui.requestRender();\n }\n\n private copyFeedback(text: string, kind: Feedback[\"kind\"], command?: string, reveal = true): void {\n if (command !== undefined) this.notifyCommand(text, kind, { reveal });\n else {\n // A shortcut superseding a slash copy must not leave a pending result.\n if (this.commandNotification?.pendingResult) this.clearCommandNotification();\n this.feedback = { text: safeText(text), kind, at: Date.now() };\n }\n }\n\n private copySelection(command?: string): void {\n const text = this.textSelection.text();\n if (!text) {\n this.copyFeedback(\"No transcript text selected. Drag to select first.\", \"error\", command);\n return;\n }\n this.copyText(text, \"Copied selected transcript text\", command);\n }\n\n private copyResponse(command?: string, preferSelection = false): void {\n if (preferSelection && this.textSelection.active) { this.copySelection(command); return; }\n if (!this.currentId) return;\n const transcript = this.options.transcript(this.currentId, false);\n if (transcript.hasNewer) {\n this.copyFeedback(\"Use /latest before /copy to load the latest response.\", \"error\", command);\n return;\n }\n const text = conversationAssistantText(transcript);\n if (!text) {\n this.copyFeedback(\"No assistant response to copy yet.\", \"error\", command);\n return;\n }\n this.copyText(text, \"Copied last assistant response\", command);\n }\n\n private copyText(text: string, message: string, command?: string): void {\n const id = this.currentId;\n const epoch = this.state.epoch;\n const version = ++this.copyVersion;\n const editor = this.editor;\n // Completion removes the suggestion rows synchronously. Reserve the final\n // result now, so clipboard latency cannot produce a blank, shifting frame.\n if (command !== undefined) this.notifyCommand(\"Copying\u2026\", \"info\", { reserve: message });\n const notification = this.commandNotification;\n const current = (): boolean => !this.disposed && this.currentId === id && this.state.epoch === epoch && this.copyVersion === version;\n // A newer command owns the notification, but does not cancel the copy itself.\n const currentResult = (): boolean => current() && (command === undefined || this.commandNotification === notification);\n // Serialize writes so a slower older copy cannot overwrite a newer one.\n this.copyTask = this.copyTask.then(() => {\n if (current()) return (this.options.copyToClipboard ?? copyToClipboard)(text);\n }).then(() => {\n if (!currentResult()) return;\n if (command !== undefined && id) {\n if (this.state.peek(id)?.draft === command) this.state.view(id).draft = \"\";\n if (editor?.getText() === command) editor.setText(\"\");\n }\n this.copyFeedback(message, \"info\", command, false);\n this.tui.requestRender();\n }, (error: unknown) => {\n if (!currentResult()) return;\n this.copyFeedback(`Copy failed: ${errorText(error)}`, \"error\", command, false);\n this.tui.requestRender();\n });\n }\n\n private submit(delivery: FabricConversationDelivery): void {\n const editor = this.editor;\n const target = this.currentTarget();\n if (!editor || !target || isMainTarget(target)) return;\n const raw = editor.getText();\n const message = editor.getExpandedText();\n if (!message.trim()) return;\n const command = message.trim().replace(/[\\t ]+/g, \" \");\n // Commands belong only to this target's in-memory editor history, including\n // failed attempts. Remember before navigation/validation, never via send.\n if (command.startsWith(\"/\")) this.rememberPrompt(message);\n if (command === \"/copy\") { this.copyResponse(raw); return; }\n if (command === \"/copy selection\") { this.copySelection(raw); return; }\n if (command === \"/help\") {\n editor.setText(\"\");\n this.notifyCommand(CONVERSATION_COMMAND_HELP);\n return;\n }\n if (command === \"/latest\") {\n editor.setText(\"\");\n this.followLatest();\n this.notifyCommand(\"Following latest output\");\n return;\n }\n\n if (command === \"/back\") {\n this.options.close();\n return;\n }\n if (command === \"/agents\") {\n this.openPicker();\n return;\n }\n if (command === \"/stop\") {\n if (!target.canStop) {\n this.notifyCommand(`Stop unavailable for ${target.name}: the selected target cannot be stopped from here.`, \"error\");\n return;\n }\n this.stopConfirmId = target.id;\n this.notifyCommand(`Press enter again to stop ${target.name} \u00B7 esc cancels`);\n return;\n }\n if (message.trim().startsWith(\"/\") || message.trim().startsWith(\"!\")) {\n this.notifyCommand(`Unsupported command \"${message.trim()}\" is not forwarded from this view. Use /help for preview commands.`, \"error\");\n return;\n }\n if (target.readOnlyReason) {\n this.feedback = {\n text: safeText(`${target.name} is read-only: ${target.readOnlyReason}`),\n kind: \"error\",\n at: Date.now(),\n };\n return;\n }\n if (delivery === \"steer\" && !target.canSteer) {\n this.feedback = {\n text: safeText(`${target.name} does not accept steering messages right now.`),\n kind: \"error\",\n at: Date.now(),\n };\n return;\n }\n if (delivery === \"followUp\" && !target.canFollowUp) {\n this.feedback = {\n text: safeText(`${target.name} does not accept follow-up messages right now.`),\n kind: \"error\",\n at: Date.now(),\n };\n return;\n }\n const queue = this.currentQueue();\n if (!queue) return;\n this.textSelection.clear();\n this.state.queues.sync(target.id, this.options.transcript(target.id, true));\n if (queue.mode === \"extension\" && delivery === \"followUp\" && !isActiveStatus(target.status)) {\n const parked = queue.park(message, delivery);\n if (parked.ok) { this.rememberPrompt(message); this.state.view(target.id).draft = \"\"; editor.setText(\"\"); }\n return;\n }\n // Session-owned pending marker: blocks duplicate submission of the same\n // raw draft for the same target across view close/reopen.\n if (this.state.hasPendingSend(target.id, raw)) return;\n this.rememberPrompt(message);\n const pending: FabricConversationPendingSend = { id: target.id, message: raw, delivery };\n this.state.addPendingSend(pending);\n const epoch = this.state.epoch;\n this.feedback = {\n text: safeText(`Sending ${delivery} \u2192 ${target.name}\u2026`),\n kind: \"info\",\n at: Date.now(),\n };\n void Promise.resolve()\n .then(() => queue.dispatch(message, delivery))\n .then(() => {\n // Same-session acks mutate shared state even if this view was closed;\n // only a session clear (epoch change) invalidates the result.\n if (this.state.epoch !== epoch) return;\n this.state.resolvePendingSend(target.id, raw);\n if (this.disposed) return;\n if (this.currentId === target.id && this.editor === editor && editor.getText() === raw) {\n editor.setText(\"\");\n }\n this.feedback = {\n text: safeText(`Queued ${delivery} \u2192 ${target.name}`),\n kind: \"info\",\n at: Date.now(),\n };\n this.tui.requestRender();\n })\n .catch((error: unknown) => {\n if (this.state.epoch !== epoch) return;\n this.state.failPendingSend(target.id, raw);\n if (this.disposed) return;\n // Keep the raw draft including whitespace and any newer editing; never merge.\n this.feedback = {\n text: safeText(\n `Send failed for ${target.name} (${delivery}): ${errorText(error)}`,\n ),\n kind: \"error\",\n at: Date.now(),\n };\n this.tui.requestRender();\n });\n }\n\n private dispatchStop(target: FabricConversationTarget): void {\n const epoch = this.state.epoch;\n const scope = this.notificationScope;\n const current = (): boolean => !this.disposed && epoch === this.state.epoch &&\n scope === this.notificationScope && this.currentId === target.id;\n this.notifyCommand(`Stopping ${target.name}\u2026`);\n void Promise.resolve()\n .then(() => this.options.stop(target.id))\n .then(() => {\n if (current()) this.notifyCommand(`Stop requested for ${target.name}`);\n })\n .catch((error: unknown) => {\n if (current()) this.notifyCommand(`Stop failed for ${target.name}: ${errorText(error)}`, \"error\");\n });\n }\n\n private navigateParent(): void {\n const target = this.currentTarget();\n if (!target) return;\n const parent = target.parentId ? this.targetById(target.parentId) : undefined;\n if (parent && !isMainTarget(parent)) {\n this.applySelection(parent.id, true);\n return;\n }\n this.options.close();\n }\n\n private navigateFirstChild(): void {\n const target = this.currentTarget();\n if (!target) return;\n const child = this.currentTargets().find((candidate) => candidate.parentId === target.id);\n if (child && !isMainTarget(child)) this.applySelection(child.id, true);\n }\n\n private cycleTarget(direction: 1 | -1): void {\n const targets = this.nonMainTargets();\n if (targets.length === 0) return;\n const index = targets.findIndex((target) => target.id === this.currentId);\n const nextIndex = index < 0\n ? 0\n : (index + direction + targets.length) % targets.length;\n const next = targets[nextIndex];\n if (next) this.applySelection(next.id, true);\n }\n\n private scrollBy(delta: number): void {\n if (!this.currentId || !Number.isFinite(delta) || delta === 0) return;\n if (!this.textSelection.dragging) this.textSelection.clear();\n const entry = this.state.view(this.currentId);\n const maxScroll = Math.max(0, this.lastBodyLength - this.lastBodyBudget);\n const position = entry.following ? maxScroll : entry.scroll;\n // A wheel/key gesture wins over an unpainted command-result reveal.\n if (entry.pageAnchor === \"end\") entry.pageAnchor = undefined;\n const next = position + Math.trunc(delta);\n entry.following = false;\n if (next < 0 && !this.textSelection.dragging && this.options.loadOlder(this.currentId)) {\n // Native history pages prepend records instead of replacing the tail.\n // Preserve the old viewport anchor, then apply the requested movement.\n entry.pageAnchor = \"prepend\";\n entry.anchorLength = this.lastBody.length;\n entry.scroll = next;\n return;\n }\n if (next > maxScroll && !this.textSelection.dragging && this.options.loadNewer(this.currentId)) {\n entry.scroll = next;\n return;\n }\n entry.scroll = Math.max(0, Math.min(next, maxScroll));\n if (delta > 0 && entry.scroll === maxScroll) entry.following = true;\n }\n\n private scrollPrompt(direction: -1 | 1): void {\n if (!this.currentId) return;\n const entry = this.state.view(this.currentId);\n const position = entry.following ? Math.max(0, this.lastBodyLength - this.lastBodyBudget) : entry.scroll;\n const prompts = this.lastBody.flatMap((line, index) => line.includes(\"\\x1b]133;A\") ? [index] : []);\n const target = direction < 0 ? prompts.filter((row) => row < position).at(-1) : prompts.find((row) => row > position);\n this.scrollBy(target === undefined ? direction * Math.max(1, this.lastBodyBudget) : target - position);\n }\n\n private scrollToTop(): void {\n if (!this.currentId) return;\n this.textSelection.clear();\n const entry = this.state.view(this.currentId);\n entry.following = false;\n entry.scroll = 0;\n if (this.options.loadOlder(this.currentId)) entry.pageAnchor = \"start\";\n }\n\n private followLatest(): void {\n this.textSelection.clear();\n if (!this.currentId) return;\n this.options.loadLatest(this.currentId);\n const entry = this.state.view(this.currentId);\n entry.following = true;\n entry.pageAnchor = undefined;\n entry.anchorLength = undefined;\n }\n\n private openPicker(): void {\n this.clearCommandNotification();\n this.copyVersion++;\n this.textSelection.clear();\n this.stopWorkingIndicator();\n this.mode = \"picker\";\n this.pickerInput = new Input({ prompt: \"search targets: \" });\n this.pickerInput.focused = this.focusState;\n this.pickerInput.onSubmit = () => this.pickSelected();\n if (this.editor) this.editor.focused = false;\n this.pickerSelectedId = this.currentId ?? this.nonMainTargets()[0]?.id;\n this.refreshPicker();\n }\n\n private closePicker(): void {\n this.mode = \"conversation\";\n this.pickerInput = undefined;\n this.pickerRows = [];\n this.pickerKey = \"\";\n this.pickerSelectedId = undefined;\n if (this.editor) this.editor.focused = this.focusState;\n }\n\n private refreshPicker(): void {\n const search = this.pickerInput?.getValue() ?? \"\";\n const key = JSON.stringify([this.targetsKey, search]);\n if (key === this.pickerKey) return;\n this.pickerKey = key;\n const rows: PickerRow[] = [];\n const targets = this.currentTargets();\n const children = new Map<string, FabricConversationTarget[]>();\n for (const target of targets) {\n if (!target.parentId) continue;\n const siblings = children.get(target.parentId) ?? [];\n siblings.push(target);\n children.set(target.parentId, siblings);\n }\n const roots = targets.filter(\n (target) => !target.parentId || !this.targetsById.has(target.parentId),\n );\n roots.sort((left, right) =>\n Number(isMainTarget(right)) - Number(isMainTarget(left)),\n );\n const visited = new Set<string>();\n const pushTree = (target: FabricConversationTarget, depth: number): void => {\n if (visited.has(target.id)) return;\n visited.add(target.id);\n rows.push({ target, depth });\n for (const child of children.get(target.id) ?? []) pushTree(child, depth + 1);\n };\n for (const root of roots) pushTree(root, 0);\n for (const orphan of targets) {\n if (!visited.has(orphan.id)) rows.push({ target: orphan, depth: 0 });\n }\n const filtered = search.trim()\n ? fuzzyFilter(rows, search, (row) => `${row.target.kind} ${row.target.name} ${row.target.id}`)\n : rows;\n this.pickerRows = filtered;\n // Selection identity is the target id, stable across roster updates.\n if (!filtered.some((row) => row.target.id === this.pickerSelectedId)) {\n this.pickerSelectedId = filtered[0]?.target.id;\n }\n }\n\n private pickerSelectedIndex(): number {\n const index = this.pickerRows.findIndex((row) => row.target.id === this.pickerSelectedId);\n return index >= 0 ? index : 0;\n }\n\n private movePickerSelection(direction: 1 | -1): void {\n if (this.pickerRows.length === 0) return;\n const index = this.pickerSelectedIndex();\n const next = (index + direction + this.pickerRows.length) % this.pickerRows.length;\n this.pickerSelectedId = this.pickerRows[next]?.target.id;\n }\n\n private pickSelected(): void {\n const row = this.pickerRows.find((candidate) => candidate.target.id === this.pickerSelectedId) ??\n this.pickerRows[0];\n if (!row) {\n this.closePicker();\n return;\n }\n if (isMainTarget(row.target)) {\n this.options.close();\n return;\n }\n this.applySelection(row.target.id, true);\n }\n\n private handlePickerInput(data: string): void {\n const input = this.pickerInput;\n if (!input) {\n this.closePicker();\n return;\n }\n if (matchesKey(data, Key.escape)) {\n this.closePicker();\n return;\n }\n if (matchesKey(data, Key.up)) {\n this.movePickerSelection(-1);\n return;\n }\n if (matchesKey(data, Key.down)) {\n this.movePickerSelection(1);\n return;\n }\n if (matchesKey(data, Key.enter)) {\n this.pickSelected();\n return;\n }\n input.handleInput(data);\n this.refreshPicker();\n }\n\n private isUnread(target: FabricConversationTarget): boolean {\n if (target.updatedAt === undefined || target.id === this.currentId) return false;\n // peek() only: listing targets must never create or evict drafts.\n const seen = this.state.peek(target.id)?.lastSeenUpdatedAt ?? 0;\n return target.updatedAt > seen;\n }\n\n private breadcrumbLine(width: number): string {\n const chain: FabricConversationTarget[] = [];\n let cursor = this.currentTarget();\n const guard = new Set<string>();\n while (cursor && !guard.has(cursor.id)) {\n guard.add(cursor.id);\n chain.unshift(cursor);\n cursor = cursor.parentId ? this.targetById(cursor.parentId) : undefined;\n }\n if (chain.length === 0) {\n const main = this.mainTarget();\n if (main) chain.push(main);\n }\n if (chain.length === 0) return truncateToWidth(this.theme.fg(\"dim\", \"Fabric\"), width, \"\");\n const last = chain[chain.length - 1];\n const parts = chain.map((target, index) => {\n const isCurrent = target.id === this.currentId;\n const name = isMainTarget(target) ? \"Main\" : safeText(target.name) || target.id;\n const styled = isCurrent\n ? this.theme.fg(\"accent\", name)\n : this.theme.fg(\"muted\", name);\n return last && index === chain.length - 1 && this.isUnread(last)\n ? `${styled} \u25CF`\n : styled;\n });\n return truncateToWidth(parts.join(this.theme.fg(\"dim\", \" > \")), width, \"\");\n }\n\n private currentFeedbackLine(width: number): string | undefined {\n if (this.mode === \"picker\") return undefined;\n if (!this.feedback) return undefined;\n if (Date.now() - this.feedback.at > FEEDBACK_TTL_MS) return undefined;\n const color = this.feedback.kind === \"error\" ? \"error\" : \"accent\";\n return truncateToWidth(this.theme.fg(color, this.feedback.text), width, \"\");\n }\n\n private hintsLine(width: number): string {\n const followUpKeys = this.bindingHint(\"app.message.followUp\", \"alt+enter\");\n const toolsKeys = this.bindingHint(\"app.tools.expand\", \"ctrl+o\");\n const hints = this.stopConfirmId !== undefined\n ? [this.theme.fg(\"warning\", safeText(\"enter confirms stop \u00B7 esc cancels\"))]\n : [\n this.theme.fg(\"dim\", \"enter\"),\n \"steer\",\n this.theme.fg(\"dim\", followUpKeys),\n \"follow-up\",\n this.theme.fg(\"dim\", \"ctrl+n\"),\n \"targets\",\n this.theme.fg(\"dim\", \"pgup/pgdn\"),\n \"scroll \u00B7 drag select \u00B7 /help\",\n this.theme.fg(\"dim\", \"esc\"),\n \"close\",\n ];\n const full = [...hints, this.theme.fg(\"dim\", toolsKeys), \"tools\"].join(\" \");\n return truncateToWidth(full, width, \"\");\n }\n\n private renderEditorLines(innerWidth: number): string[] {\n const editor = this.editor;\n if (!editor) return [];\n return editor.render(innerWidth);\n }\n\n private currentQueue(): ConversationQueue | undefined {\n const target = this.currentTarget();\n if (!target || target.kind === \"main\" || !this.editor || this.disposed) return undefined;\n return this.state.queues.attach({\n targetId: target.id, targetName: target.name,\n piEvents: this.options.queueEvents ?? { emit() {} }, theme: this.theme,\n send: (message, delivery) => {\n if (message.trimStart().startsWith(\"/\") || message.trimStart().startsWith(\"!\")) {\n return Promise.reject(new Error(\"Commands cannot be sent from queued edits; use the preview composer.\"));\n }\n return this.options.send(target.id, message, delivery);\n },\n editor: {\n getText: () => this.editor?.getText() ?? \"\",\n setText: (text) => this.setQueueEditorText(text),\n handleInput: (data) => this.editor?.handleInput(data),\n render: (width) => this.editor?.render(width) ?? [],\n paddingX: this.options.appearance?.editorPaddingX ?? 0,\n },\n ...(this.options.keybindings ? { keybindings: this.options.keybindings } : {}),\n isIdle: () => !isActiveStatus(this.targetById(target.id)?.status ?? \"stopped\"),\n onNotify: (text, kind) => {\n if (kind === \"error\" && !this.disposed && this.currentId === target.id) this.feedback = { text: safeText(text), kind, at: Date.now() };\n },\n requestRender: () => { if (!this.disposed && this.currentId === target.id) this.tui.requestRender(); },\n });\n }\n\n private transcriptLines(innerWidth: number): string[] {\n const target = this.currentTarget();\n if (!target || !this.currentId) return [this.theme.fg(\"dim\", \"No target selected.\")];\n const entry = this.state.view(this.currentId);\n const transcript = this.observedTranscript ?? this.options.transcript(this.currentId, entry.following);\n return this.renderer.render(transcript, innerWidth, {\n target,\n toolsExpanded: entry.toolsExpanded,\n hideThinking: entry.hideThinking ?? this.options.appearance?.hideThinkingBlock ?? false,\n showImages: this.options.appearance?.showImages ?? true,\n outputPad: this.options.appearance?.outputPad ?? 1,\n ...(this.options.appearance?.codeBlockIndent !== undefined ? { codeBlockIndent: this.options.appearance.codeBlockIndent } : {}),\n codePreviewSettings: this.options.codePreviewSettings,\n });\n }\n\n private transcriptTail(width: number, budget: number): string[] {\n if (this.commandNotification && this.commandNotification.epoch !== this.state.epoch) this.clearCommandNotification();\n const notification = this.commandNotification;\n if (this.observedTranscript?.hasNewer && !notification) return [];\n // These rows belong to the end of history, never to the fixed input dock.\n const tail = notification ? [\"\", ...notification.component.render(width)] : [];\n // Reserve wrapped success geometry too, including after a resize.\n if (notification?.pendingResult) {\n const reserved = 1 + notification.pendingResult.render(width).length;\n while (tail.length < reserved) tail.push(\"\");\n }\n if (!this.observedTranscript?.hasNewer) tail.push(...this.working?.render(width) ?? []);\n if (budget > 1) tail.push(\"\");\n return tail;\n }\n\n private windowBody(body: string[], budget: number, tail: string[]): string[] {\n this.lastBodyLength = body.length + tail.length;\n this.lastBody = body;\n this.lastBodyBudget = budget;\n const entry = this.currentId ? this.state.view(this.currentId) : undefined;\n const maxScroll = Math.max(0, this.lastBodyLength - budget);\n if (entry) {\n if (entry.following) {\n entry.scroll = maxScroll;\n } else if (entry.pageAnchor) {\n entry.scroll = entry.pageAnchor === \"prepend\"\n ? entry.scroll + Math.max(0, body.length - (entry.anchorLength ?? body.length))\n : entry.pageAnchor === \"end\" ? maxScroll : 0;\n entry.pageAnchor = undefined;\n entry.anchorLength = undefined;\n }\n entry.scroll = Math.max(0, Math.min(entry.scroll, maxScroll));\n }\n // Slice the virtual body + tail without copying retained history per frame.\n const start = entry?.scroll ?? 0;\n const end = start + budget;\n const lines = body.slice(start, end);\n if (end > body.length) lines.push(...tail.slice(Math.max(0, start - body.length), end - body.length));\n return lines;\n }\n\n private pickerLines(innerWidth: number, budget: number): string[] {\n // Independent viewport: the picker never reads or writes the selected\n // target's transcript scroll/follow state.\n this.refreshPicker();\n const lines = [this.theme.fg(\"accent\", \"Targets \u00B7 enter select \u00B7 esc cancel\")];\n const input = this.pickerInput;\n if (input) {\n for (const line of input.render(innerWidth)) lines.push(line);\n }\n const rows = this.pickerRows;\n const selectedIndex = this.pickerSelectedIndex();\n const listBudget = Math.max(1, budget - lines.length - 1);\n const startIndex = Math.max(\n 0,\n Math.min(selectedIndex - Math.floor(listBudget / 2), rows.length - listBudget),\n );\n const endIndex = Math.min(startIndex + listBudget, rows.length);\n if (rows.length === 0) lines.push(this.theme.fg(\"muted\", \" no matching targets\"));\n for (let i = startIndex; i < endIndex; i++) {\n const row = rows[i];\n if (!row) continue;\n const selected = row.target.id === this.pickerSelectedId;\n const indent = \" \".repeat(row.depth + 1);\n const marker = selected ? this.theme.fg(\"accent\", \"\u2192 \") : \" \";\n const unread = this.isUnread(row.target) ? this.theme.fg(\"accent\", \" \u25CF\") : \"\";\n const label = isMainTarget(row.target)\n ? \"Main (native session)\"\n : `${safeText(row.target.name)} ${this.theme.fg(\"muted\", `(${row.target.kind} \u00B7 ${row.target.status})`)}`;\n lines.push(\n truncateToWidth(\n `${indent}${marker}${selected ? this.theme.fg(\"accent\", label) : label}${unread}`,\n innerWidth,\n \"\",\n ),\n );\n }\n if (rows.length > listBudget) {\n lines.push(this.theme.fg(\"muted\", ` (${selectedIndex + 1}/${rows.length})`));\n }\n return lines.slice(0, budget);\n }\n}\n", "import {\n AssistantMessageComponent,\n BashExecutionComponent,\n BranchSummaryMessageComponent,\n CompactionSummaryMessageComponent,\n CustomMessageComponent,\n parseSkillBlock,\n SkillInvocationMessageComponent,\n ToolExecutionComponent,\n UserMessageComponent,\n type MarkdownTransformer,\n type MessageRenderer,\n type Theme,\n type TruncationResult,\n} from \"@earendil-works/pi-coding-agent\";\nimport type { MarkdownTheme, TUI } from \"@earendil-works/pi-tui\";\nimport { wrapTextWithAnsi } from \"@earendil-works/pi-tui\";\nimport type { CodePreviewSettings } from \"./code-preview.js\";\nimport { highlightCode } from \"./highlight.js\";\nimport { terminalSafe } from \"./transcript-sanitization.js\";\nimport type { FabricConversationTarget } from \"./conversation.js\";\nimport { unwrapActorEnvelopeText } from \"./conversation-transcript.js\";\nimport type {\n NativeAgentMessage,\n NativeConversationTranscript,\n NativeToolExecution,\n} from \"./conversation-native-reader.js\";\n\nexport type {\n NativeAgentMessage,\n NativeConversationTranscript,\n NativeToolExecution,\n} from \"./conversation-native-reader.js\";\n\ntype UserAgentMessage = Extract<NativeAgentMessage, { role: \"user\" }>;\ntype ToolResultAgentMessage = Extract<NativeAgentMessage, { role: \"toolResult\" }>;\ntype BashExecutionAgentMessage = Extract<NativeAgentMessage, { role: \"bashExecution\" }>;\ntype CustomAgentMessage = Extract<NativeAgentMessage, { role: \"custom\" }>;\ntype CompactionSummaryAgentMessage = Extract<NativeAgentMessage, { role: \"compactionSummary\" }>;\ntype BranchSummaryAgentMessage = Extract<NativeAgentMessage, { role: \"branchSummary\" }>;\n\n/** Exactly what ToolExecutionComponent accepts as its tool definition. */\nexport type FabricToolDefinitionLike = ConstructorParameters<typeof ToolExecutionComponent>[4];\nexport type FabricGetToolDefinition = (toolName: string) => FabricToolDefinitionLike;\n\nexport interface FabricConversationTranscriptRendererOptions {\n /**\n * Registered tool definitions (Main wires the actual fabricTool and\n * capturedTools.get(name).definition). Undefined falls back to the native\n * generic tool card, exactly like interactive-mode getRegisteredToolDefinition.\n */\n getToolDefinition?: FabricGetToolDefinition | undefined;\n /** Extension message renderers (capturedTools.runner.getMessageRenderer). */\n getMessageRenderer?: ((customType: string) => MessageRenderer | undefined) | undefined;\n /** Native markdown transformers (capturedTools.runner.getMarkdownTransformers). */\n markdownTransformers?: readonly MarkdownTransformer[] | undefined;\n hiddenThinkingLabel?: string | undefined;\n imageWidthCells?: number | undefined;\n}\n\nexport interface FabricConversationTranscriptRenderOptions {\n target: FabricConversationTarget;\n toolsExpanded: boolean;\n outputPad?: 0 | 1;\n codeBlockIndent?: string;\n codePreviewSettings?: CodePreviewSettings | undefined;\n hideThinking?: boolean;\n showImages?: boolean;\n}\n\ntype NativeToolResultContent = { type: string; text?: string; data?: string; mimeType?: string };\n\nconst DEFAULT_IMAGE_WIDTH_CELLS = 60;\n\nconst stableKey = (value: unknown): string => {\n if (value === undefined) return \"undefined\";\n try {\n return JSON.stringify(value) ?? \"undefined\";\n } catch {\n return `unserializable:${String(value)}`;\n }\n};\n\ninterface RenderedRow {\n render: (width: number) => string[];\n lines?: string[] | undefined;\n spacer: boolean;\n dynamic: boolean;\n partial?: boolean;\n input?: readonly unknown[];\n}\n\ninterface ToolCacheRecord {\n component: ToolExecutionComponent;\n name: string;\n dynamicRenderer: boolean;\n started: boolean;\n argsComplete: boolean;\n args: unknown;\n argsKey: string;\n result: unknown;\n resultKey: string | undefined;\n partialKey: string | undefined;\n imageKey: string;\n isPartial: boolean;\n isError: boolean;\n error: string | undefined;\n}\n\ninterface MessageCacheRecord {\n component: BashExecutionComponent | CustomMessageComponent | CompactionSummaryMessageComponent\n | BranchSummaryMessageComponent | SkillInvocationMessageComponent;\n}\n\ninterface AssistantCacheRecord {\n hideThinking: boolean;\n message?: NativeAgentMessage;\n streaming?: boolean;\n component: AssistantMessageComponent;\n}\n\n/**\n * Renders a conversation-native transcript with the exact registered Pi\n * components (UserMessageComponent, AssistantMessageComponent,\n * ToolExecutionComponent, BashExecutionComponent, compaction/branch/custom\n * summaries), dispatched the way interactive-mode addMessageToChat and\n * renderSessionItems do. Native component rows are preserved verbatim \u2014 no\n * dashboard normalization, no per-line re-truncation, no extra background or\n * glyph decoration \u2014 so full-width backgrounds and native spacing survive.\n */\nexport class FabricConversationTranscriptRenderer {\n private readonly toolComponents = new Map<string, ToolCacheRecord>();\n private readonly messageComponents = new Map<string, MessageCacheRecord>();\n private readonly assistantComponents = new Map<string, AssistantCacheRecord>();\n private readonly markdownThemeCache = new Map<string, MarkdownTheme>();\n private readonly highlightInvalidate: () => void;\n private disposed = false;\n private currentTargetId = \"\";\n private readonly rendererStates = new Map<string, Set<Record<string, unknown>>>();\n private readonly liveStates = new WeakSet<object>();\n private readonly messageRows = new Map<NativeAgentMessage, RenderedRow>();\n private readonly toolRows = new Map<string, RenderedRow>();\n private readonly toolTokens = new Map<string, object>();\n private readonly messageIds = new WeakMap<NativeAgentMessage, number>();\n private nextMessageId = 0;\n private rows: RenderedRow[] = [];\n private lastMessages: NativeAgentMessage[] = [];\n private lastTools: NativeToolExecution[] = [];\n private lastPartial: NativeConversationTranscript[\"streaming\"][\"partialAssistant\"];\n private lastVersion: number | undefined;\n private sourceKey = \"\";\n private optionsKey = \"\";\n private lastRendererHooks: unknown[] = [];\n private lastWidth = 0;\n private frameLines: string[] | undefined;\n private frameFlags = \"\";\n private planDirty = true;\n\n constructor(\n private readonly tui: TUI,\n private readonly theme: Theme,\n private readonly rendererOptions: FabricConversationTranscriptRendererOptions = {},\n ) {\n this.highlightInvalidate = (): void => {\n if (this.disposed) return;\n this.invalidate();\n this.tui.requestRender();\n };\n }\n\n /** Drop cached components; stray renderer timers/invalidations become no-ops. */\n invalidate(): void {\n this.toolTokens.clear();\n for (const key of this.rendererStates.keys()) this.releaseRendererStates(key);\n this.toolComponents.clear();\n this.messageComponents.clear();\n this.assistantComponents.clear();\n this.markdownThemeCache.clear();\n this.messageRows.clear();\n this.toolRows.clear();\n this.rows = [];\n this.lastMessages = [];\n this.lastTools = [];\n this.lastPartial = undefined;\n this.frameLines = undefined;\n this.planDirty = true;\n }\n\n /** Finalize: live spinner/timing intervals may still fire once; guarded. */\n dispose(): void {\n this.disposed = true;\n this.invalidate();\n }\n\n render(\n transcript: NativeConversationTranscript,\n width: number,\n options: FabricConversationTranscriptRenderOptions,\n ): string[] {\n if (this.disposed || width <= 0) return [];\n width = Math.max(1, width);\n // Revisions are reader-local, and a participant can roll to a new activation.\n const sourceKey = stableKey([options.target.id, options.target.cwd ?? process.cwd(), transcript.sourceId,\n transcript.sessionId, transcript.sessionFile, transcript.eventsFile]);\n const optionsKey = stableKey([options.toolsExpanded, options.outputPad, options.codeBlockIndent,\n options.hideThinking, options.showImages, options.codePreviewSettings,\n this.rendererOptions.hiddenThinkingLabel, this.rendererOptions.imageWidthCells]);\n const hooks = [this.rendererOptions.getToolDefinition, this.rendererOptions.getMessageRenderer,\n ...(this.rendererOptions.markdownTransformers ?? [])];\n if (sourceKey !== this.sourceKey || optionsKey !== this.optionsKey || !sameItems(hooks, this.lastRendererHooks)) {\n this.invalidate();\n this.sourceKey = sourceKey;\n this.optionsKey = optionsKey;\n this.lastRendererHooks = hooks;\n }\n this.currentTargetId = options.target.id;\n const version = (transcript as NativeConversationTranscript & { contentVersion?: number }).contentVersion\n ?? transcript.revision;\n const streaming = transcript.streaming;\n // Compare identities, not content keys: fixtures may replace a message without\n // bumping revision, while reader metadata can change without replacing content.\n if (this.planDirty || version !== this.lastVersion ||\n !sameItems(transcript.messages, this.lastMessages) ||\n !sameItems(streaming.tools, this.lastTools) || streaming.partialAssistant !== this.lastPartial) {\n this.reconcileRows(transcript, options);\n this.lastVersion = version;\n }\n if (width !== this.lastWidth) {\n this.lastWidth = width;\n for (const row of this.rows) row.lines = undefined;\n this.frameLines = undefined;\n }\n for (const row of this.rows) {\n if (row.lines && !row.dynamic) continue;\n row.lines = row.render(width);\n this.frameLines = undefined;\n }\n const flags = `${transcript.hasMore}:${transcript.hasNewer}`;\n if (!this.frameLines || flags !== this.frameFlags) {\n const lines: string[] = [];\n if (!transcript.messages.length && !streaming.partialAssistant && !streaming.tools.length) {\n lines.push(this.theme.fg(\"dim\", \"No retained transcript yet; new agent activity will appear here.\"));\n } else {\n if (transcript.hasMore) {\n lines.push(this.theme.fg(\"dim\", \"\u2191 older activity available \u00B7 ctrl+\u2191 past the top to load\"));\n }\n for (const row of this.rows) {\n if (!row.lines?.length) continue;\n if (row.spacer && lines.length) lines.push(\"\");\n for (const line of row.lines) lines.push(line);\n }\n if (transcript.hasNewer) {\n lines.push(this.theme.fg(\"dim\", \"\u2193 newer activity available \u00B7 ctrl+\u2193 past the bottom to load\"));\n }\n }\n this.frameLines = lines;\n this.frameFlags = flags;\n }\n // The public result is mutable; callers must not be able to corrupt cached rows.\n return this.frameLines.slice();\n }\n\n private reconcileRows(\n transcript: NativeConversationTranscript,\n options: FabricConversationTranscriptRenderOptions,\n ): void {\n const rows: RenderedRow[] = [];\n const messages = new Set<NativeAgentMessage>();\n const keys = new Set<string>();\n const tools = new Set<string>();\n const results = new Map<string, ToolResultAgentMessage>();\n const streaming = new Map(transcript.streaming.tools.map((tool) => [tool.toolCallId, tool]));\n for (const message of transcript.messages) {\n if (message.role === \"toolResult\") results.set(message.toolCallId, message);\n }\n const addTool = (id: string, name: string, args: Record<string, unknown> | undefined, error?: string): void => {\n if (tools.has(id)) return;\n tools.add(id);\n rows.push(this.reconcileTool(id, name, args, results.get(id), streaming.get(id), error, options));\n };\n const addMessage = (message: NativeAgentMessage, partial = false): void => {\n if (message.role === \"toolResult\") return;\n messages.add(message);\n const key = partial ? \":streaming\" : this.messageKey(message);\n keys.add(key);\n let row = this.messageRows.get(message);\n const input = shallowInput(message);\n if (!row || row.partial !== partial || !sameItems(row.input ?? [], input)) {\n if (row) {\n this.assistantComponents.delete(key);\n this.messageComponents.delete(key);\n }\n row = {\n input,\n partial,\n spacer: message.role !== \"assistant\",\n // A custom component can read time or external state in render(width).\n dynamic: message.role === \"custom\" && message.display,\n render: (width) => {\n const lines: string[] = [];\n if (partial && message.role === \"assistant\") {\n this.renderAssistantContent(message, key, true, width, options, lines);\n } else {\n this.renderMessage(message, width, options, lines);\n }\n return lines;\n },\n };\n this.messageRows.set(message, row);\n }\n rows.push(row);\n if (message.role === \"assistant\") {\n const error = message.stopReason === \"error\" || message.stopReason === \"aborted\"\n ? message.errorMessage || \"Error\" : undefined;\n for (const call of message.content) {\n if (call.type === \"toolCall\") addTool(call.id, call.name, call.arguments, error);\n }\n }\n };\n for (const message of transcript.messages) addMessage(message);\n if (transcript.streaming.partialAssistant) addMessage(transcript.streaming.partialAssistant, true);\n for (const tool of transcript.streaming.tools) addTool(tool.toolCallId, tool.toolName, tool.args);\n // Retain the loaded window, not an undersized FIFO that thrashes on each scan.\n for (const message of this.messageRows.keys()) if (!messages.has(message)) this.messageRows.delete(message);\n for (const cache of [this.messageComponents, this.assistantComponents]) {\n for (const key of cache.keys()) if (!keys.has(key)) cache.delete(key);\n }\n for (const key of this.toolComponents.keys()) {\n const id = key.slice(this.currentTargetId.length + 1);\n if (!tools.has(id)) this.releaseTool(key);\n }\n this.rows = rows;\n this.lastMessages = transcript.messages.slice();\n this.lastTools = transcript.streaming.tools.slice();\n this.lastPartial = transcript.streaming.partialAssistant;\n this.planDirty = false;\n this.frameLines = undefined;\n }\n\n private messageKey(message: NativeAgentMessage): string {\n let id = this.messageIds.get(message);\n if (id === undefined) { id = ++this.nextMessageId; this.messageIds.set(message, id); }\n return `${this.currentTargetId}\\u0000${id}`;\n }\n\n private markdownTheme(options: FabricConversationTranscriptRenderOptions): MarkdownTheme {\n const key = options.codeBlockIndent ?? \"\";\n let markdownTheme = this.markdownThemeCache.get(key);\n if (!markdownTheme) {\n markdownTheme = {\n ...(options.codeBlockIndent !== undefined ? { codeBlockIndent: options.codeBlockIndent } : {}),\n heading: (text) => this.theme.fg(\"mdHeading\", text),\n link: (text) => this.theme.fg(\"mdLink\", text),\n linkUrl: (text) => this.theme.fg(\"mdLinkUrl\", text),\n code: (text) => this.theme.fg(\"mdCode\", text),\n codeBlock: (text) => this.theme.fg(\"mdCodeBlock\", text),\n codeBlockBorder: (text) => this.theme.fg(\"mdCodeBlockBorder\", text),\n quote: (text) => this.theme.fg(\"mdQuote\", text),\n quoteBorder: (text) => this.theme.fg(\"mdQuoteBorder\", text),\n hr: (text) => this.theme.fg(\"mdHr\", text),\n listBullet: (text) => this.theme.fg(\"mdListBullet\", text),\n bold: (text) => this.theme.bold(text),\n italic: (text) => this.theme.italic(text),\n underline: (text) => this.theme.underline(text),\n strikethrough: (text) => this.theme.strikethrough(text),\n highlightCode: (code, lang) =>\n highlightCode(code, lang ?? \"\", this.highlightInvalidate) ??\n code.split(\"\\n\").map((line) => this.theme.fg(\"mdCodeBlock\", line)),\n };\n this.markdownThemeCache.set(key, markdownTheme);\n }\n return markdownTheme;\n }\n\n private renderMessage(\n message: NativeAgentMessage,\n width: number,\n options: FabricConversationTranscriptRenderOptions,\n lines: string[],\n ): void {\n switch (message.role) {\n case \"user\":\n this.renderUserMessage(message, width, options, lines);\n return;\n case \"assistant\":\n this.renderAssistantContent(message, this.messageKey(message), false, width, options, lines);\n return;\n case \"toolResult\":\n return;\n case \"bashExecution\":\n this.pushSpacer(lines);\n this.renderBashExecution(message, width, options, lines);\n return;\n case \"custom\":\n if (!message.display) return;\n this.pushSpacer(lines);\n this.renderCustomMessage(message, width, options, lines);\n return;\n case \"compactionSummary\":\n this.pushSpacer(lines);\n this.renderBoxedMessage(this.messageKey(message), message, CompactionSummaryMessageComponent, width, options, lines);\n return;\n case \"branchSummary\":\n this.pushSpacer(lines);\n this.renderBoxedMessage(this.messageKey(message), message, BranchSummaryMessageComponent, width, options, lines);\n return;\n default:\n return;\n }\n }\n\n private renderUserMessage(\n message: UserAgentMessage,\n width: number,\n options: FabricConversationTranscriptRenderOptions,\n lines: string[],\n ): void {\n const text = userMessageText(message);\n if (!text) return;\n this.pushSpacer(lines);\n const skillBlock = parseSkillBlock(text);\n if (skillBlock) {\n const record = this.messageRecord(this.messageKey(message), () =>\n new SkillInvocationMessageComponent(skillBlock, this.markdownTheme(options)));\n record.component.setExpanded(options.toolsExpanded);\n lines.push(...safeRender(record.component, width, () => this.plainTextFallback(text, width)));\n if (skillBlock.userMessage) {\n this.pushSpacer(lines);\n lines.push(...this.userComponentLines(skillBlock.userMessage, width, options));\n }\n return;\n }\n lines.push(...this.userComponentLines(text, width, options));\n }\n\n private userComponentLines(\n text: string,\n width: number,\n options: FabricConversationTranscriptRenderOptions,\n ): string[] {\n const component = new UserMessageComponent(\n terminalSafe(text, false),\n this.markdownTheme(options),\n options.outputPad ?? 1,\n this.rendererOptions.markdownTransformers,\n );\n return safeRender(component, width, () => this.plainTextFallback(text, width));\n }\n\n private renderAssistantContent(\n message: Extract<NativeAgentMessage, { role: \"assistant\" }>,\n key: string,\n streaming: boolean,\n width: number,\n options: FabricConversationTranscriptRenderOptions,\n lines: string[],\n ): void {\n const record = this.assistantRecord(key, options);\n if (record.message !== message || record.streaming !== streaming) {\n record.component.updateContent(message, streaming);\n record.message = message;\n record.streaming = streaming;\n }\n lines.push(...safeRender(record.component, width, () => this.plainTextFallback(assistantText(message), width)));\n }\n\n private reconcileTool(\n id: string,\n name: string,\n callArgs: Record<string, unknown> | undefined,\n result: ToolResultAgentMessage | undefined,\n tool: NativeToolExecution | undefined,\n error: string | undefined,\n options: FabricConversationTranscriptRenderOptions,\n ): RenderedRow {\n const key = `${this.currentTargetId}\\u0000${id}`;\n const args = tool?.args ?? callArgs;\n const value = result ?? tool?.result ?? tool?.partial;\n const isPartial = !result && !tool?.result && !error;\n const isError = result?.isError ?? tool?.isError ?? !!error;\n const started = tool ? tool.executionStarted ?? true : false;\n const argsComplete = !!result || !!tool?.result || !!tool?.argsComplete;\n let record = this.toolComponents.get(key);\n // Native converted-image caches are indexed by position, not image identity.\n const images = record?.result === value ? undefined : value?.content?.filter(\n (block): block is NativeToolResultContent => !!block && typeof block === \"object\" &&\n (block as NativeToolResultContent).type === \"image\",\n );\n const imageKey = record && record.result === value ? record.imageKey : stableKey(images?.length ? images : undefined);\n if (record && (record.name !== name || record.imageKey !== imageKey ||\n (!record.isPartial && isPartial) || (record.argsComplete && !argsComplete) ||\n (record.started && !started && !result))) {\n this.releaseTool(key);\n record = undefined;\n }\n let row = this.toolRows.get(key);\n if (!record) {\n const token = {};\n this.toolTokens.set(key, token);\n const definition = this.definitionFor(name, key, token);\n // Pi's live TUI proxy forwards inherited assignments to the real host.\n // Define an own callback so delegation cannot overwrite requestRender.\n const ui = Object.create(this.tui, {\n requestRender: {\n configurable: true, enumerable: true, writable: true,\n value: (): void => {\n if (this.disposed || this.toolTokens.get(key) !== token) return;\n const current = this.toolRows.get(key);\n if (current) current.lines = undefined;\n this.frameLines = undefined;\n this.tui.requestRender();\n },\n },\n }) as TUI;\n const component = new ToolExecutionComponent(name, id, args,\n { showImages: options.showImages ?? true, imageWidthCells: this.imageWidthCells() },\n definition, ui, options.target.cwd ?? process.cwd());\n if (options.toolsExpanded) component.setExpanded(true);\n record = { component, name, dynamicRenderer: !!definition?.renderCall || !!definition?.renderResult, started: false, argsComplete: false, args, argsKey: \"0\",\n result: undefined, resultKey: undefined, partialKey: undefined, imageKey,\n isPartial: true, isError: false, error: undefined };\n this.toolComponents.set(key, record);\n row = {\n spacer: false,\n dynamic: !!definition?.renderCall || !!definition?.renderResult || isPartial || imageKey !== \"undefined\",\n render: (width) => safeRender(component, width, () => this.plainTextFallback(name, width)),\n };\n this.toolRows.set(key, row);\n }\n const { component } = record;\n let changed = false;\n if (record.args !== args) {\n component.updateArgs(args);\n changed = true;\n record.args = args;\n record.argsKey = String(Number(record.argsKey) + 1);\n }\n if (started && !record.started) {\n record.started = true;\n component.markExecutionStarted();\n changed = true;\n }\n if (argsComplete && !record.argsComplete) {\n record.argsComplete = true;\n component.setArgsComplete();\n changed = true;\n }\n if (record.result !== value || record.isPartial !== isPartial || record.isError !== isError || record.error !== error) {\n // Details can contain opaque extension state; serialization is not an equality test.\n const resultKey = String(Number(record.resultKey ?? 0) + 1);\n if (value !== undefined || error !== undefined) {\n component.updateResult({\n content: error && !value ? [{ type: \"text\", text: error }] : (value?.content ?? []) as NativeToolResultContent[],\n ...(value?.details !== undefined ? { details: value.details } : {}),\n isError,\n }, isPartial);\n changed = true;\n }\n record.result = value;\n record.resultKey = resultKey;\n record.partialKey = isPartial ? resultKey : undefined;\n record.isPartial = isPartial;\n record.isError = isError;\n record.error = error;\n }\n row!.dynamic = record.dynamicRenderer || isPartial || imageKey !== \"undefined\";\n if (changed) row!.lines = undefined;\n return row!;\n }\n\n private releaseTool(key: string): void {\n this.toolTokens.delete(key);\n this.releaseRendererStates(key);\n this.toolComponents.delete(key);\n this.toolRows.delete(key);\n }\n\n private renderBashExecution(\n message: BashExecutionAgentMessage,\n width: number,\n options: FabricConversationTranscriptRenderOptions,\n lines: string[],\n ): void {\n const key = this.messageKey(message);\n const record = this.messageRecord(key, () => {\n const component = new BashExecutionComponent(message.command, this.tui, message.excludeFromContext);\n component.appendOutput(terminalSafe(message.output ?? \"\", false));\n // Mirrors interactive-mode: only the truncated flag is known at this point.\n const truncation = message.truncated ? ({ truncated: true } as TruncationResult) : undefined;\n component.setComplete(message.exitCode, message.cancelled, truncation, message.fullOutputPath);\n return component;\n });\n record.component.setExpanded(options.toolsExpanded);\n lines.push(...safeRender(record.component, width, () => this.plainTextFallback(message.command, width)));\n }\n\n private renderCustomMessage(\n message: CustomAgentMessage,\n width: number,\n options: FabricConversationTranscriptRenderOptions,\n lines: string[],\n ): void {\n const record = this.messageRecord(this.messageKey(message), () =>\n new CustomMessageComponent(\n message,\n this.rendererOptions.getMessageRenderer?.(message.customType),\n this.markdownTheme(options),\n options.outputPad ?? 1,\n ));\n record.component.setExpanded(options.toolsExpanded);\n lines.push(...safeRender(record.component, width, () => this.plainTextFallback(customText(message), width)));\n }\n\n private renderBoxedMessage<M extends CompactionSummaryAgentMessage | BranchSummaryAgentMessage>(\n key: string,\n message: M,\n create: new (message: M, markdownTheme?: MarkdownTheme) => MessageCacheRecord[\"component\"],\n width: number,\n options: FabricConversationTranscriptRenderOptions,\n lines: string[],\n ): void {\n const record = this.messageRecord(key, () => new create(message, this.markdownTheme(options)));\n record.component.setExpanded(options.toolsExpanded);\n lines.push(...safeRender(record.component, width, () => this.plainTextFallback(message.summary, width)));\n }\n\n /**\n * Registered definition with wrapped renderer callbacks: the render context\n * invalidate becomes a no-op once disposed, so a live spinner/timing timer\n * firing after dispose cannot touch the TUI. ToolExecutionComponent has no\n * dispose; this finalizes its renderer subscriptions instead.\n */\n private definitionFor(toolName: string, key: string, token: object): FabricToolDefinitionLike {\n const definition = this.rendererOptions.getToolDefinition?.(toolName);\n if (!definition) return definition;\n const live = (): boolean => !this.disposed && this.toolTokens.get(key) === token;\n const guard = <T extends { invalidate: () => void; state: Record<string, unknown> }>(context: T): T => {\n const states = this.rendererStates.get(key) ?? new Set<Record<string, unknown>>();\n states.add(context.state);\n this.rendererStates.set(key, states);\n this.liveStates.add(context.state);\n return {\n ...context,\n invalidate: (): void => {\n if (!live() || !this.liveStates.has(context.state)) return;\n context.invalidate();\n },\n };\n };\n // An old native image conversion can call updateDisplay after eviction.\n const empty = { render: () => [], invalidate: () => {} };\n return {\n ...definition,\n ...(definition.renderCall\n ? { renderCall: (args: any, theme: Theme, context: any) =>\n live() ? definition.renderCall!(args, theme, guard(context)) : empty }\n : {}),\n ...(definition.renderResult\n ? { renderResult: (result: any, options: any, theme: Theme, context: any) =>\n live() ? definition.renderResult!(result, options, theme, guard(context)) : empty }\n : {}),\n };\n }\n\n private assistantRecord(\n key: string,\n options: FabricConversationTranscriptRenderOptions,\n ): AssistantCacheRecord {\n const cacheKey = key;\n const hideThinking = options.hideThinking ?? false;\n let record = this.assistantComponents.get(cacheKey);\n if (!record || record.hideThinking !== hideThinking) {\n record = {\n hideThinking,\n component: new AssistantMessageComponent(\n undefined,\n hideThinking,\n this.markdownTheme(options),\n this.rendererOptions.hiddenThinkingLabel,\n options.outputPad ?? 1,\n this.rendererOptions.markdownTransformers,\n ),\n };\n this.assistantComponents.set(cacheKey, record);\n }\n return record;\n }\n\n private messageRecord(\n key: string,\n create: () => MessageCacheRecord[\"component\"],\n ): MessageCacheRecord {\n const cacheKey = key;\n let record = this.messageComponents.get(cacheKey);\n if (!record) {\n record = { component: create() };\n this.messageComponents.set(cacheKey, record);\n }\n return record;\n }\n\n private releaseRendererStates(key: string): void {\n for (const state of this.rendererStates.get(key) ?? []) {\n this.liveStates.delete(state);\n if (state.codePreviewTimingInterval) {\n clearInterval(state.codePreviewTimingInterval as ReturnType<typeof setInterval>);\n delete state.codePreviewTimingInterval;\n }\n const spinner = state.fabricSpinner as { timer?: ReturnType<typeof setTimeout> } | undefined;\n if (spinner?.timer) { clearTimeout(spinner.timer); delete spinner.timer; }\n }\n this.rendererStates.delete(key);\n }\n\n private imageWidthCells(): number {\n return Math.max(1, Math.floor(this.rendererOptions.imageWidthCells ?? DEFAULT_IMAGE_WIDTH_CELLS));\n }\n\n private plainTextFallback(text: string, width: number): string[] {\n const safe = terminalSafe(text, false);\n return safe.split(\"\\n\").flatMap((paragraph) =>\n wrapTextWithAnsi(paragraph, Math.max(1, width)).map((line) => this.theme.fg(\"text\", line)),\n );\n }\n\n private pushSpacer(lines: string[]): void {\n if (lines.length > 0) lines.push(\"\");\n }\n}\n\n// Snapshot shallow fields on projection changes, including optional producer-side\n// content versions. Immutable nested payloads never need hashing on warm frames.\nconst shallowInput = (value: object): unknown[] => [...Object.keys(value), ...Object.values(value)];\n\nconst sameItems = <T>(a: readonly T[], b: readonly T[]): boolean =>\n a.length === b.length && a.every((item, index) => item === b[index]);\n\nconst userMessageText = (message: UserAgentMessage): string => {\n const blocks = typeof message.content === \"string\"\n ? [{ type: \"text\", text: message.content }]\n : message.content.filter((block): block is { type: \"text\"; text: string } => block.type === \"text\");\n const text = blocks.map((block) => block.text).join(\"\");\n return unwrapActorEnvelopeText(text) ?? text;\n};\n\nconst assistantText = (message: { content: unknown }): string =>\n Array.isArray(message.content)\n ? message.content\n .filter((block): block is { type: \"text\"; text: string } =>\n typeof block === \"object\" && block !== null && (block as { type?: unknown }).type === \"text\")\n .map((block) => block.text)\n .join(\"\\n\")\n : \"\";\n\nconst customText = (message: CustomAgentMessage): string =>\n typeof message.content === \"string\"\n ? message.content\n : message.content\n .filter((block): block is { type: \"text\"; text: string } => block.type === \"text\")\n .map((block) => block.text)\n .join(\"\\n\");\n\nconst safeRender = (\n component: { render(width: number): string[] },\n width: number,\n fallback: () => string[],\n): string[] => {\n try {\n // Native rows are preserved verbatim: components already wrap and pad to\n // width, so re-truncating would clip the trailing background cell.\n return component.render(width);\n } catch {\n return fallback();\n }\n};\n", "import type { Theme } from \"@earendil-works/pi-coding-agent\";\nimport { sliceByColumn, stripTerminalSequences, visibleWidth } from \"@earendil-works/pi-tui\";\n\ninterface Point { row: number; col: number }\nconst graphemes = new Intl.Segmenter(undefined, { granularity: \"grapheme\" });\n\n/** One immutable rendered-history reference; no history-sized copy on drag. */\nexport class ConversationTextSelection {\n source: string[] | undefined;\n private anchor: Point | undefined;\n private focus: Point | undefined;\n dragging = false;\n\n clear(): void {\n this.source = undefined;\n this.anchor = this.focus = undefined;\n this.dragging = false;\n }\n\n start(source: string[], row: number, col: number): void {\n this.source = source;\n this.anchor = this.point(row, col);\n this.focus = this.anchor;\n this.dragging = true;\n }\n\n move(row: number, col: number): void {\n if (this.dragging) this.focus = this.point(row, col);\n }\n\n finish(row: number, col: number): void {\n this.move(row, col);\n this.dragging = false;\n if (!this.bounds()) this.clear();\n }\n\n get active(): boolean { return this.bounds() !== undefined; }\n\n private point(row: number, col: number): Point {\n row = Math.max(0, Math.min(this.source!.length - 1, row));\n let boundary = 0;\n for (const { segment } of graphemes.segment(stripTerminalSequences(this.source![row] ?? \"\"))) {\n const next = boundary + visibleWidth(segment);\n if (next > col) break;\n boundary = next;\n }\n return { row, col: boundary };\n }\n\n private bounds(): { start: Point; end: Point } | undefined {\n const a = this.anchor;\n const b = this.focus;\n if (!a || !b || (a.row === b.row && a.col === b.col)) return undefined;\n return a.row < b.row || (a.row === b.row && a.col < b.col) ? { start: a, end: b } : { start: b, end: a };\n }\n\n text(): string | undefined {\n const bounds = this.bounds();\n if (!bounds || !this.source) return undefined;\n const lines: string[] = [];\n for (let row = bounds.start.row; row <= bounds.end.row; row++) {\n const line = this.source[row] ?? \"\";\n const start = row === bounds.start.row ? bounds.start.col : 0;\n const end = row === bounds.end.row ? bounds.end.col : visibleWidth(line);\n lines.push(stripTerminalSequences(sliceByColumn(line, start, end - start, true)).trimEnd());\n }\n return lines.join(\"\\n\") || undefined;\n }\n\n highlight(line: string, row: number, theme: Theme): string {\n const bounds = this.bounds();\n if (!bounds || row < bounds.start.row || row > bounds.end.row) return line;\n // Never slice/re-emit image control payloads while painting a selection.\n if (/\\x1b(?:_G|\\]1337;File=|P)/.test(line)) return line;\n const width = visibleWidth(line);\n const start = row === bounds.start.row ? bounds.start.col : 0;\n const end = row === bounds.end.row ? bounds.end.col : width;\n if (end <= start) return line;\n const selected = stripTerminalSequences(sliceByColumn(line, start, end - start, true));\n return sliceByColumn(line, 0, start, true) + theme.bg(\"selectedBg\", theme.fg(\"text\", selected)) +\n sliceByColumn(line, end, Math.max(0, width - end), true);\n }\n}\n", "import type { NativeConversationTranscript } from \"./conversation-native-reader.js\";\nimport { unwrapActorEnvelopeText } from \"./conversation-transcript.js\";\n\nconst PROMPT_HISTORY_LIMIT = 100;\n\n/** Pi keeps the newest 100 trimmed prompts, suppressing consecutive duplicates. */\nexport function appendConversationPrompt(history: string[], text: string): void {\n const prompt = text.trim();\n if (!prompt || history.at(-1) === prompt) return;\n history.push(prompt);\n if (history.length > PROMPT_HISTORY_LIMIT) history.shift();\n}\n\n/** Seed once on history use, without retaining transcript objects or reading more pages. */\nexport function conversationPromptHistory(transcript: NativeConversationTranscript): string[] {\n const newest: string[] = [];\n for (let index = transcript.messages.length - 1; index >= 0 && newest.length < PROMPT_HISTORY_LIMIT; index--) {\n const message = transcript.messages[index]!;\n if (message.role !== \"user\") continue;\n const raw = typeof message.content === \"string\" ? message.content\n : message.content.filter((part) => part.type === \"text\").map((part) => part.text).join(\"\");\n const text = (unwrapActorEnvelopeText(raw) ?? raw).trim();\n if (text && newest.at(-1) !== text) newest.push(text);\n }\n return newest.reverse();\n}\n", "import type { AutocompleteItem, AutocompleteProvider } from \"@earendil-works/pi-tui\";\nimport type { NativeConversationTranscript } from \"./conversation-native-reader.js\";\n\nexport const CONVERSATION_COMMANDS = [\n { value: \"/copy\", label: \"/copy\", description: \"Copy the last assistant response\" },\n { value: \"/copy selection\", label: \"/copy selection\", description: \"Copy selected transcript text\" },\n { value: \"/latest\", label: \"/latest\", description: \"Clear selection and follow latest output\" },\n { value: \"/agents\", label: \"/agents\", description: \"Choose a conversation\" },\n { value: \"/back\", label: \"/back\", description: \"Return to Main\" },\n { value: \"/stop\", label: \"/stop\", description: \"Confirm stopping this participant\" },\n { value: \"/help\", label: \"/help\", description: \"Show preview commands\" },\n] satisfies AutocompleteItem[];\n\nexport const CONVERSATION_COMMAND_HELP = \"Commands: /copy [selection] \u00B7 /latest \u00B7 /agents \u00B7 /back \u00B7 /stop \u00B7 /help\";\n\nexport function conversationCommandCompletion(enabled: () => boolean): AutocompleteProvider {\n return {\n triggerCharacters: [\"/\"],\n async getSuggestions(lines, row, col, options) {\n if (!enabled() || options.signal.aborted || row !== 0 || lines.length !== 1) return null;\n const prefix = lines[0]!.slice(0, col);\n if (col !== lines[0]!.length || !/^\\/[a-z]*(?: +[a-z]*)?$/.test(prefix)) return null;\n const items = CONVERSATION_COMMANDS.filter((item) => item.value.startsWith(prefix));\n return items.length ? { items, prefix } : null;\n },\n applyCompletion(lines, row, _col, item) {\n const next = [...lines];\n next[row] = `${item.value} `;\n return { lines: next, cursorLine: row, cursorCol: next[row]!.length };\n },\n };\n}\n\n/** Match Pi's /copy semantics: text from the last non-empty-aborted assistant. */\nexport function conversationAssistantText(transcript: NativeConversationTranscript): string | undefined {\n for (let index = transcript.messages.length - 1; index >= 0; index--) {\n const message = transcript.messages[index]!;\n if (message.role !== \"assistant\" || (message.stopReason === \"aborted\" && message.content.length === 0)) continue;\n const text = message.content.filter((block) => block.type === \"text\").map((block) => block.text).join(\"\").trim();\n return text || undefined;\n }\n return undefined;\n}\n", "import { createHash } from \"node:crypto\";\nimport { createConversationQueue, type ConversationQueue, type ConversationQueueOptions, type ConversationSnapshotEntry } from \"./conversation-queue.js\";\nimport type { NativeConversationTranscript } from \"./conversation-native-reader.js\";\nimport { unwrapActorEnvelopeText } from \"./conversation-transcript.js\";\n\ninterface QueueSlot {\n queue: ConversationQueue;\n attached: ConversationQueueOptions | undefined;\n initialized: boolean;\n frontier: number;\n projection?: QueueProjection | undefined;\n}\n\ninterface QueueProjection {\n messages: NativeConversationTranscript[\"messages\"];\n messageCount: number;\n revision: number;\n sourceId: string;\n sessionFile: string | undefined;\n eventsFile: string | undefined;\n leafId: string | null;\n entries: ConversationSnapshotEntry[];\n}\n\ninterface UserIdentity {\n content: string;\n timestamp: number;\n id: string;\n text: string;\n}\n\n/** Session-owned queues; replacing a view never strands an acknowledgement or editor. */\nexport class ConversationQueueStore {\n private readonly slots = new Map<string, QueueSlot>();\n private readonly userIdentities = new WeakMap<object, UserIdentity>();\n\n attach(options: ConversationQueueOptions): ConversationQueue {\n const existing = this.slots.get(options.targetId);\n if (existing) { existing.attached = options; return existing.queue; }\n const slot: QueueSlot = { queue: undefined as unknown as ConversationQueue, attached: options, initialized: false, frontier: 0 };\n const attached = () => slot.attached;\n slot.queue = createConversationQueue({\n ...options,\n send: (text, lane) => {\n const current = attached();\n if (!current) return Promise.reject(new Error(\"Open this conversation to send its queued messages\"));\n return current.send(text, lane);\n },\n editor: {\n getText: () => attached()?.editor?.getText() ?? \"\",\n setText: (text) => attached()?.editor?.setText(text),\n handleInput: (data) => attached()?.editor?.handleInput?.(data),\n render: (width) => attached()?.editor?.render?.(width) ?? [],\n get paddingX() { return attached()?.editor?.paddingX ?? 0; },\n },\n isIdle: () => attached()?.isIdle?.() ?? true,\n onNotify: (text, kind) => attached()?.onNotify?.(text, kind),\n requestRender: () => attached()?.requestRender?.(),\n });\n this.slots.set(options.targetId, slot);\n return slot.queue;\n }\n\n get(id: string): ConversationQueue | undefined { return this.slots.get(id)?.queue; }\n\n detach(id: string): void {\n const slot = this.slots.get(id);\n if (!slot) return;\n slot.queue.cancelEditing();\n slot.attached = undefined;\n slot.projection = undefined;\n }\n\n sync(id: string, transcript: NativeConversationTranscript): void {\n const slot = this.slots.get(id);\n if (!slot) return;\n let projection = slot.projection;\n const changed = !projection || projection.messages !== transcript.messages ||\n projection.messageCount !== transcript.messages.length || projection.revision !== transcript.revision ||\n projection.sourceId !== transcript.sourceId || projection.sessionFile !== transcript.sessionFile ||\n projection.eventsFile !== transcript.eventsFile || projection.leafId !== transcript.leafId;\n if (changed) {\n let frontier = slot.frontier;\n const occurrences = new Map<string, number>();\n const entries: ConversationSnapshotEntry[] = [];\n for (const message of transcript.messages) {\n if (Number.isFinite(message.timestamp)) frontier = Math.max(frontier, message.timestamp);\n if (message.role !== \"user\") continue;\n const { id: identity, text } = this.userIdentity(message);\n const occurrence = occurrences.get(identity) ?? 0;\n occurrences.set(identity, occurrence + 1);\n entries.push({ id: occurrence === 0 ? identity : `${identity}:${occurrence}`, text,\n historical: !slot.initialized || message.timestamp < slot.frontier });\n }\n projection = {\n messages: transcript.messages, messageCount: transcript.messages.length, revision: transcript.revision,\n sourceId: transcript.sourceId, sessionFile: transcript.sessionFile, eventsFile: transcript.eventsFile,\n leafId: transcript.leafId, entries,\n };\n // Inactive queues keep delivery frontiers, not a strong reference to the\n // reader's entire transcript. Its identity cache uses weak keys too.\n slot.projection = slot.attached ? projection : undefined;\n slot.frontier = frontier;\n slot.initialized = true;\n }\n // A routing acknowledgement can arrive after its native entry, without a\n // transcript change. Pending sends must still check cached delivery ids.\n if (projection && (changed || slot.queue.pendingCount() > 0)) slot.queue.syncSnapshot(projection.entries);\n slot.queue.syncPending(transcript.pendingMessages);\n }\n\n private userIdentity(message: Extract<NativeConversationTranscript[\"messages\"][number], { role: \"user\" }>): Pick<UserIdentity, \"id\" | \"text\"> {\n const cached = this.userIdentities.get(message);\n if (cached && cached.content === message.content && cached.timestamp === message.timestamp) return cached;\n const raw = typeof message.content === \"string\" ? message.content : message.content.filter((part) => part.type === \"text\").map((part) => part.text).join(\"\");\n const text = unwrapActorEnvelopeText(raw) ?? raw;\n let id: string | undefined;\n if (text !== raw) {\n try {\n const envelope = JSON.parse(raw.trim().slice(\"Fabric actor message from direct:\".length));\n if (typeof envelope.id === \"string\") id = envelope.id;\n } catch { /* Only a validated actor envelope can provide a delivery id. */ }\n }\n id ||= createHash(\"sha256\").update(JSON.stringify([message.timestamp, message.content])).digest(\"hex\");\n const identity = { id, text };\n // Array blocks can be mutated in place; recheck them on changed projections\n // rather than trusting their container identity for delivery matching.\n if (typeof message.content === \"string\") {\n this.userIdentities.set(message, { ...identity, content: message.content, timestamp: message.timestamp });\n }\n return identity;\n }\n\n clear(): void {\n for (const slot of this.slots.values()) { slot.queue.cancelEditing(); slot.attached = undefined; slot.projection = undefined; slot.queue.dispose(); }\n this.slots.clear();\n }\n}\n", "import type { KeybindingsManager, Theme, ThemeColor } from \"@earendil-works/pi-coding-agent\";\nimport {\n Key,\n getKeybindings,\n matchesKey,\n truncateToWidth,\n type KeyId,\n} from \"@earendil-works/pi-tui\";\n\n/**\n * Target-scoped conversation queue for the focused conversation view.\n *\n * When pi-queue-steer is installed and loaded, a versioned pi.events\n * request/capability handshake hands this adapter a bridge over the\n * extension's actual queue-state machinery (DeliveryQueue / QueueEditSession)\n * AND its actual shared execution-outline renderer (QueueTimelineWidget plus\n * the real inline-editor line extractor) \u2014 no imitation, no hard dependency:\n * the extension is discovered only through the shared bus. With no compatible\n * listener, the adapter falls back to Pi's native queue display labels and\n * colors (\"Steering:\" / \"Follow-up:\", dim) and never claims extension parity.\n *\n * Delivery ownership rules:\n * - every queue is bound to one targetId; rows and edits never leak to Main\n * or to another target (dispatch goes only through the injected per-target\n * `send` route);\n * - `submit` acknowledges route acceptance only: a resolved send marks the\n * row `dispatched` \u2014 immutable, no longer editable (there is no remote\n * retract API) \u2014 and still visible until native delivery is confirmed;\n * - rows retire through `syncSnapshot`, reconciled against the native\n * reader agent's complete-message snapshot (read-only messages/streaming/\n * tools source). Retirement keys on stable native message identities plus\n * a pre-dispatch baseline and live-append frontier, with duplicate\n * counting \u2014 trimmed text alone is NOT identity: identical text already in\n * history, or historical pages loaded later, can never fake consumption;\n * - a failed send restores the exact remaining rows to the timeline head in\n * order;\n * - Main-only control actions (/ commands, ! bash) are rejected at stage\n * time \u2014 they are not queueable from a focused conversation;\n * - a run ending (settled, aborted, errored) is NOT a retirement event:\n * follow-ups exist precisely to start the next run, and a route ack cannot\n * prove consumption, so only `retireAll` (target removed/unreachable) or\n * an identity match retires rows;\n * - `dispose({ retain })` gives Main explicit cleanup/retention semantics on\n * target switches: retention parks the rows (the extension bridge retains\n * them per targetId for re-adoption), the default clears them and releases\n * the extension's retained state.\n */\n\nexport const QUEUE_STEER_CONVERSATION_QUEUE_REQUEST_EVENT = \"queue-steer:conversation-queue:request:v1\";\n\ntype ConversationQueueLane = \"steer\" | \"followUp\";\ntype ConversationQueueRowState = \"queued\" | \"dispatched\";\n\ninterface ConversationQueueRow {\n id: string;\n lane: ConversationQueueLane;\n text: string;\n state: ConversationQueueRowState;\n paused: boolean;\n /** Current row-editing selection (rendered live through the shared editor). */\n selected: boolean;\n /** Marked for removal inside the active editing session; save deletes it. */\n removed: boolean;\n}\n\n/** Structural shape of the extension's real `DeliveryQueue` rows. */\ninterface ConversationQueueBridgeRow {\n id: string;\n lane: ConversationQueueLane;\n text: string;\n images: unknown[];\n sequence: number;\n paused?: boolean;\n}\n\n/** Structural subset of the extension's real `DeliveryQueue`. */\ninterface ConversationQueueBridgeQueue {\n enqueue(lane: ConversationQueueLane, text: string, images?: readonly unknown[]): ConversationQueueBridgeRow;\n snapshot(): ConversationQueueBridgeRow[];\n peek(): ConversationQueueBridgeRow | undefined;\n get(id: string): ConversationQueueBridgeRow | undefined;\n remove(id: string): ConversationQueueBridgeRow | undefined;\n prepend(item: ConversationQueueBridgeRow): void;\n prependMany(items: readonly ConversationQueueBridgeRow[]): void;\n update(id: string, text: string): boolean;\n setLane(id: string, lane: ConversationQueueLane): boolean;\n setPaused(id: string, paused: boolean): boolean;\n clear(): void;\n readonly length: number;\n}\n\n/** Structural subset of the extension's real `QueueEditSession`. */\ninterface ConversationQueueBridgeEditSession {\n readonly selectedId: string;\n readonly composerDraft: string;\n capture(text: string): void;\n select(item: ConversationQueueBridgeRow, currentText: string): string;\n toggleRemoved(id: string): boolean | undefined;\n togglePaused(id: string): boolean | undefined;\n setLane(id: string, lane: ConversationQueueLane): ConversationQueueLane | undefined;\n commit(queue: ConversationQueueBridgeQueue, currentText: string): {\n updated: number;\n removed: number;\n moved: number;\n held: number;\n released: number;\n };\n rollbackPositions(queue: ConversationQueueBridgeQueue): void;\n /** Draft decoration readers; present on the extension's real session. */\n laneFor?(id: string): ConversationQueueLane | undefined;\n textFor?(id: string): string | undefined;\n pausedFor?(id: string): boolean | undefined;\n isRemoved?(id: string): boolean;\n}\n\n/**\n * Version 1 interop bridge served by a loaded pi-queue-steer over the\n * `QUEUE_STEER_CONVERSATION_QUEUE_REQUEST_EVENT` handshake. The renderer\n * members are optional so an older installed extension degrades gracefully\n * to the native fallback rendering instead of an imitation outline.\n */\nexport interface ConversationQueueBridgeV1 {\n version: 1;\n targetId: string;\n createQueue(): ConversationQueueBridgeQueue;\n createEditSession(item: ConversationQueueBridgeRow, composerDraft: string): ConversationQueueBridgeEditSession;\n isQueueableSubmission(text: string): boolean;\n laneLabel(lane: ConversationQueueLane): string;\n laneColor(lane: ConversationQueueLane): string;\n buildTimelineItems?(\n queue: ConversationQueueBridgeQueue,\n editSession: ConversationQueueBridgeEditSession | undefined,\n modes?: { steer: \"all\" | \"one-at-a-time\"; followUp: \"all\" | \"one-at-a-time\" },\n ): readonly unknown[];\n createTimelineWidget?(\n options: {\n items: readonly unknown[];\n editingId?: string;\n paused?: boolean;\n idle?: boolean;\n renderInlineEditor?: (width: number) => string[];\n },\n theme: Theme,\n ): { render(width: number): string[]; invalidate(): void };\n extractInlineEditorLines?(lines: readonly string[], paddingX?: number): string[];\n}\n\n/**\n * One entry of the native reader agent's complete-message snapshot. `id` is\n * a stable native identity (session entry id, reader event identity, or the\n * actor envelope/message id); `historical` marks baseline/history entries \u2014\n * including older transcript pages loaded later \u2014 which establish identity\n * but can never retire a queued row.\n */\nexport interface ConversationSnapshotEntry {\n id: string;\n text: string;\n historical?: boolean;\n}\n\nexport interface ConversationQueueOptions {\n /** Shared pi.events bus (emit only; the handshake is synchronous claim/respond). */\n piEvents: { emit(channel: string, data: unknown): void };\n targetId: string;\n targetName?: string;\n /**\n * Per-target dispatch route owned by Main; rejection restores the rows. A\n * resolved value may carry `messageId`/`id` (e.g. an actor envelope id) \u2014\n * it becomes the row's expected native delivery identity.\n */\n send: (message: string, delivery: ConversationQueueLane) => Promise<unknown>;\n theme: Theme;\n /** Shared focused-view editor; row editing renders live through it. */\n editor?: {\n getText(): string;\n setText(text: string): void;\n handleInput?(data: string): void;\n /** Full renderer, used for real inline row editing via the bridge. */\n render?(width: number): string[];\n /** Editor interior padding, forwarded to the inline line extractor. */\n paddingX?: number;\n };\n keybindings?: Pick<KeybindingsManager, \"matches\" | \"getKeys\">;\n /** Target run state for the shared widget's stage label; default idle=false. */\n isIdle?: () => boolean;\n onNotify?: (text: string, kind: \"info\" | \"error\") => void;\n requestRender?: () => void;\n}\n\ninterface StageResult {\n ok: boolean;\n id?: string;\n error?: string;\n}\n\nexport interface ConversationQueue {\n readonly targetId: string;\n /** \"extension\" when a real pi-queue-steer bridge was claimed, \"native\" otherwise. */\n readonly mode: \"extension\" | \"native\";\n readonly active: boolean;\n /** True while a row-editing session holds the shared editor. */\n readonly editingActive: boolean;\n /** Stage text as a queue row for this target. Control input is rejected. */\n stage(text: string, lane: ConversationQueueLane): StageResult;\n /**\n * Dispatch the contiguous same-lane unpauseed head batch through `send`.\n * Resolves true only when every row was accepted by the route; a failure\n * restores the unsent rows to the timeline head in order. Acceptance is\n * not consumption: accepted rows become immutable and stay visible until\n * `syncSnapshot` confirms native delivery identity.\n */\n submit(lane: ConversationQueueLane): Promise<boolean>;\n dispatch(text: string, lane: ConversationQueueLane): Promise<void>;\n park(text: string, lane: ConversationQueueLane): StageResult;\n cancelEditing(): void;\n syncPending(pending: { steering: string[]; followUp: string[] } | undefined): void;\n /** Decorated rows in timeline order (dispatched rows first, then queued). */\n rows(): ConversationQueueRow[];\n /** Queue list lines rendered above the editor; empty when nothing is held. */\n render(width: number): string[];\n /**\n * Row-editing input handling. Consumes keys only while an editing session\n * is active or when the dequeue binding starts one; everything else passes\n * back to Main (`false`).\n */\n handleInput(data: string): boolean;\n /**\n * Reconcile against the native reader snapshot (read-only). Main feeds the\n * initial pre-dispatch snapshot as `historical` entries before the first\n * submit, then subsequent live snapshots. Retirement matches, first, a\n * dispatched row's expected native message identity (actor envelope id) or,\n * failing that, one live-append entry beyond the historical baseline with\n * the row's text \u2014 duplicate rows each consume their own frontier entry.\n * Historical entries and older pages never retire anything.\n */\n syncSnapshot(entries: readonly ConversationSnapshotEntry[]): number;\n /**\n * The target is being removed/unreachable: retire every held row. This is\n * the only blanket retirement, and it must NOT be called merely because a\n * run ended or the target stopped \u2014 follow-ups are for the next run, and a\n * route ack cannot prove consumption.\n */\n retireAll(reason?: string): number;\n /** Number of rows still held (queued + dispatched-but-unconfirmed). */\n pendingCount(): number;\n dispose(options?: { retain?: boolean }): void;\n}\n\ninterface RequestResult {\n ok: boolean;\n bridge?: ConversationQueueBridgeV1;\n error?: string;\n}\n\ninterface HandshakeRequest {\n version: 1;\n action: \"acquire\" | \"release\";\n targetId: string;\n claim(): boolean;\n respond(result: RequestResult): void;\n}\n\ninterface DispatchedRow {\n id: string;\n lane: ConversationQueueLane;\n text: string;\n /** Expected stable native identity, when the route reported one. */\n expectedId?: string;\n}\n\nconst DEQUEUE_FALLBACK: KeyId = \"alt+up\";\nconst REMOVE_ROW_KEY = \"alt+x\";\nconst PAUSE_ROW_KEY = \"alt+p\";\nconst INDENT_ROW_KEY: KeyId = \"alt+right\";\nconst OUTDENT_ROW_KEY: KeyId = \"alt+left\";\nconst TOGGLE_LANE_KEY = \"alt+t\";\n\n/** Native Pi pending-messages labels (interactive-mode ground truth). */\nconst NATIVE_LANE_LABEL: Record<ConversationQueueLane, string> = {\n steer: \"Steering\",\n followUp: \"Follow-up\",\n};\n\n/**\n * Native fallback timeline implementing the same structural contract as the\n * extension bridge, so the adapter logic is single-path for both modes.\n */\nclass NativeQueueState implements ConversationQueueBridgeQueue {\n private items: ConversationQueueBridgeRow[] = [];\n private nextIdNumber = 1;\n private nextSequence = 1;\n\n enqueue(lane: ConversationQueueLane, text: string, images: readonly unknown[] = []): ConversationQueueBridgeRow {\n const prefix = lane === \"steer\" ? \"steer\" : \"follow-up\";\n const item: ConversationQueueBridgeRow = {\n id: `${prefix}-${this.nextIdNumber++}`,\n lane,\n text,\n images: [...images],\n sequence: this.nextSequence++,\n paused: false,\n };\n this.items.push(item);\n return { ...item, images: [...item.images] };\n }\n\n snapshot(): ConversationQueueBridgeRow[] {\n return this.items.map((item) => ({ ...item, images: [...item.images] }));\n }\n\n peek(): ConversationQueueBridgeRow | undefined {\n const item = this.items[0];\n return item ? { ...item, images: [...item.images] } : undefined;\n }\n\n get(id: string): ConversationQueueBridgeRow | undefined {\n const item = this.items.find((candidate) => candidate.id === id);\n return item ? { ...item, images: [...item.images] } : undefined;\n }\n\n remove(id: string): ConversationQueueBridgeRow | undefined {\n const index = this.items.findIndex((candidate) => candidate.id === id);\n if (index === -1) return undefined;\n const [item] = this.items.splice(index, 1);\n return item ? { ...item, images: [...item.images] } : undefined;\n }\n\n prepend(item: ConversationQueueBridgeRow): void {\n this.items.unshift({ ...item, images: [...item.images] });\n }\n\n prependMany(items: readonly ConversationQueueBridgeRow[]): void {\n for (let index = items.length - 1; index >= 0; index -= 1) {\n const item = items[index];\n if (item) this.items.unshift({ ...item, images: [...item.images] });\n }\n }\n\n update(id: string, text: string): boolean {\n const item = this.items.find((candidate) => candidate.id === id);\n if (!item) return false;\n item.text = text;\n return true;\n }\n\n setLane(id: string, lane: ConversationQueueLane): boolean {\n const item = this.items.find((candidate) => candidate.id === id);\n if (!item || item.lane === lane) return false;\n item.lane = lane;\n return true;\n }\n\n setPaused(id: string, paused: boolean): boolean {\n const item = this.items.find((candidate) => candidate.id === id);\n if (!item || (item.paused ?? false) === paused) return false;\n item.paused = paused;\n return true;\n }\n\n clear(): void {\n this.items = [];\n }\n\n get length(): number {\n return this.items.length;\n }\n}\n\n/** Rollback-safe snapshot editing for the native fallback queue. */\nclass NativeEditSession implements ConversationQueueBridgeEditSession {\n readonly composerDraft: string;\n private currentId: string;\n private readonly drafts = new Map<string, { text: string; lane: ConversationQueueLane; removed: boolean; paused: boolean }>();\n\n constructor(item: ConversationQueueBridgeRow, composerDraft: string) {\n this.currentId = item.id;\n this.composerDraft = composerDraft;\n this.drafts.set(item.id, {\n text: item.text,\n lane: item.lane,\n removed: false,\n paused: item.paused ?? false,\n });\n }\n\n get selectedId(): string {\n return this.currentId;\n }\n\n capture(text: string): void {\n const draft = this.drafts.get(this.currentId);\n if (draft) draft.text = text;\n }\n\n select(item: ConversationQueueBridgeRow, currentText: string): string {\n this.capture(currentText);\n if (!this.drafts.has(item.id)) {\n this.drafts.set(item.id, {\n text: item.text,\n lane: item.lane,\n removed: false,\n paused: item.paused ?? false,\n });\n }\n this.currentId = item.id;\n return this.drafts.get(item.id)?.text ?? item.text;\n }\n\n toggleRemoved(id: string): boolean | undefined {\n const draft = this.drafts.get(id);\n if (!draft) return undefined;\n draft.removed = !draft.removed;\n return draft.removed;\n }\n\n togglePaused(id: string): boolean | undefined {\n const draft = this.drafts.get(id);\n if (!draft) return undefined;\n draft.paused = !draft.paused;\n return draft.paused;\n }\n\n setLane(id: string, lane: ConversationQueueLane): ConversationQueueLane | undefined {\n const draft = this.drafts.get(id);\n if (!draft) return undefined;\n draft.lane = lane;\n return draft.lane;\n }\n\n commit(queue: ConversationQueueBridgeQueue, currentText: string): {\n updated: number;\n removed: number;\n moved: number;\n held: number;\n released: number;\n } {\n this.capture(currentText);\n let updated = 0;\n let removed = 0;\n let moved = 0;\n let held = 0;\n let released = 0;\n for (const [id, draft] of this.drafts.entries()) {\n if (draft.removed || !draft.text.trim()) {\n if (queue.remove(id)) removed += 1;\n continue;\n }\n if (queue.update(id, draft.text)) updated += 1;\n if (queue.setLane(id, draft.lane)) moved += 1;\n if (queue.setPaused(id, draft.paused)) {\n if (draft.paused) held += 1;\n else released += 1;\n }\n }\n return { updated, removed, moved, held, released };\n }\n\n rollbackPositions(): void {}\n\n laneFor(id: string): ConversationQueueLane | undefined {\n return this.drafts.get(id)?.lane;\n }\n\n textFor(id: string): string | undefined {\n return this.drafts.get(id)?.text;\n }\n\n pausedFor(id: string): boolean | undefined {\n return this.drafts.get(id)?.paused;\n }\n\n isRemoved(id: string): boolean {\n return this.drafts.get(id)?.removed ?? false;\n }\n}\n\nconst errorText = (error: unknown): string =>\n error instanceof Error ? error.message : String(error ?? \"\");\n\nconst controlInputRe = /^[/!]/;\n\n/**\n * Create one target-scoped conversation queue. Attempts the pi-queue-steer\n * interop handshake first (mode \"extension\"); with no claiming listener the\n * adapter serves Pi's native queue labels and colors (mode \"native\").\n */\nexport function createConversationQueue(options: ConversationQueueOptions): ConversationQueue {\n const { piEvents, targetId, theme } = options;\n const notify = (text: string, kind: \"info\" | \"error\" = \"info\") => {\n options.onNotify?.(text, kind);\n };\n const requestRender = () => options.requestRender?.();\n const targetLabel = options.targetName ?? targetId;\n\n let bridge: ConversationQueueBridgeV1 | undefined;\n let queue: ConversationQueueBridgeQueue;\n let mode: \"extension\" | \"native\" = \"native\";\n let disposed = false;\n /** Route-accepted rows awaiting native delivery identity confirmation. */\n const dispatched: DispatchedRow[] = [];\n let externalPending: DispatchedRow[] = [];\n let lastSendError: unknown;\n let editSession: ConversationQueueBridgeEditSession | undefined;\n\n // Snapshot reconciliation state: every fed identity is seen exactly once;\n // historical entries (initial baseline, older pages) can never retire;\n // live-append frontier counts per trimmed text drive text-based retirement\n // with duplicate counting; consumed ids make each entry retire at most one row.\n const seenIds = new Set<string>();\n const consumedIds = new Set<string>();\n const liveTextCounts = new Map<string, number>();\n\n const emitHandshake = (action: \"acquire\" | \"release\"): { claimed: boolean; result?: RequestResult | undefined } => {\n let claimed = false;\n let settled = false;\n let result: RequestResult | undefined;\n const request: HandshakeRequest = {\n version: 1,\n action,\n targetId,\n claim: () => {\n if (claimed) return false;\n claimed = true;\n return true;\n },\n respond: (response) => {\n // The bridge contract is a synchronous respond during emit; late\n // responses are ignored so the adapter mode never flips mid-render.\n if (settled) return;\n settled = true;\n result = response;\n },\n };\n piEvents.emit(QUEUE_STEER_CONVERSATION_QUEUE_REQUEST_EVENT, request);\n return { claimed, result };\n };\n\n const acquisition = emitHandshake(\"acquire\");\n if (\n acquisition.claimed\n && acquisition.result?.ok\n && acquisition.result.bridge?.version === 1\n && acquisition.result.bridge.targetId === targetId\n ) {\n bridge = acquisition.result.bridge;\n mode = \"extension\";\n } else if (acquisition.claimed && acquisition.result && !acquisition.result.ok) {\n notify(`pi-queue-steer refused the conversation queue for ${targetLabel}: ${acquisition.result.error ?? \"unknown error\"}`, \"error\");\n }\n queue = bridge ? bridge.createQueue() : new NativeQueueState();\n\n const laneLabel = (lane: ConversationQueueLane): string =>\n bridge ? bridge.laneLabel(lane) : lane === \"steer\" ? \"steer\" : \"follow-up\";\n\n const isQueueable = (text: string): boolean =>\n bridge ? bridge.isQueueableSubmission(text) : !controlInputRe.test(text.trim()) && text.trim() !== \"\";\n\n const decoratedRow = (item: ConversationQueueBridgeRow): ConversationQueueRow => ({\n id: item.id,\n lane: editSession?.laneFor?.(item.id) ?? item.lane,\n text: editSession?.textFor?.(item.id) ?? item.text,\n state: \"queued\",\n paused: editSession?.pausedFor?.(item.id) ?? (item.paused ?? false),\n selected: editSession?.selectedId === item.id,\n removed: editSession?.isRemoved?.(item.id) ?? false,\n });\n\n const orderedRows = (): ConversationQueueRow[] => {\n const held = queue.snapshot().map(decoratedRow);\n // Accepted rows are immutable: outside the editing queue, never selectable.\n const inFlight: ConversationQueueRow[] = [...dispatched, ...externalPending].map((row) => ({\n id: row.id,\n lane: row.lane,\n text: row.text,\n state: \"dispatched\" as const,\n paused: false,\n selected: false,\n removed: false,\n }));\n return [...inFlight, ...held];\n };\n\n /**\n * Contiguous same-lane head batch; a paused head row is a dispatch barrier\n * and rows behind it never jump ahead.\n */\n const headBatch = (lane: ConversationQueueLane): ConversationQueueBridgeRow[] => {\n const items = queue.snapshot();\n const head = items[0];\n if (!head || head.lane !== lane) return [];\n const batch: ConversationQueueBridgeRow[] = [];\n for (const item of items) {\n if (item.lane !== lane) break;\n if (item.paused) break;\n batch.push(item);\n }\n return batch;\n };\n\n const dequeueKeys = (): readonly string[] => {\n const manager = options.keybindings ?? getKeybindings();\n const keys = manager.getKeys(\"app.message.dequeue\");\n return keys.filter((key: string) => /up$/i.test(key)).map((key: string) =>\n key.endsWith(\"Up\") ? `${key.slice(0, -2)}Down` : `${key.slice(0, -2)}down`\n );\n };\n\n const actionMatches = (\n data: string,\n action: \"app.message.dequeue\" | \"app.interrupt\" | \"tui.input.submit\" | \"app.message.followUp\",\n fallback: (data: string) => boolean,\n ): boolean => {\n const manager = options.keybindings;\n if (manager) {\n const keys = manager.getKeys(action);\n if (keys.length === 0) return false;\n return manager.matches(data, action);\n }\n const global = getKeybindings();\n if (global.getKeys(action).length > 0) return global.matches(data, action);\n return fallback(data);\n };\n\n const startEditing = (): boolean => {\n if (!options.editor) {\n notify(\"Editing queued rows requires the shared editor\", \"error\");\n return false;\n }\n const items = queue.snapshot();\n if (items.length === 0) {\n notify(\"No queued messages to edit\", \"info\");\n return false;\n }\n // Enter at the most recently queued row, like the extension's dequeue.\n const mostRecent = items.reduce((newest, item) => (item.sequence > newest.sequence ? item : newest), items[0]!);\n editSession = bridge\n ? bridge.createEditSession(mostRecent, options.editor.getText())\n : new NativeEditSession(mostRecent, options.editor.getText());\n options.editor.setText(mostRecent.text);\n notify(`Editing queued ${laneLabel(mostRecent.lane)} row \u00B7 enter saves, escape rolls back`, \"info\");\n requestRender();\n return true;\n };\n\n const finishEditing = (save: boolean): boolean => {\n const session = editSession;\n const editor = options.editor;\n if (!session || !editor) return false;\n const currentText = editor.getText();\n editSession = undefined;\n if (save) {\n const result = session.commit(queue, currentText);\n if (result.removed > 0) notify(`Removed ${result.removed} queued row${result.removed === 1 ? \"\" : \"s\"}`, \"info\");\n if (result.moved > 0) notify(`Changed delivery depth for ${result.moved} row${result.moved === 1 ? \"\" : \"s\"}`, \"info\");\n if (result.held > 0) notify(`Paused ${result.held} row${result.held === 1 ? \"\" : \"s\"} \u2014 dispatch stops there until resumed`, \"info\");\n if (result.released > 0) notify(`Resumed ${result.released} row${result.released === 1 ? \"\" : \"s\"}`, \"info\");\n } else {\n // Escape rolls the whole editing session back, including lane and\n // pause drafts; row edits live only in the discarded drafts.\n notify(\"Row edits rolled back\", \"info\");\n }\n editor.setText(session.composerDraft);\n requestRender();\n return true;\n };\n\n const matchesOptionArrow = (data: string, direction: \"left\" | \"right\"): boolean => {\n const arrow = direction === \"left\" ? OUTDENT_ROW_KEY : INDENT_ROW_KEY;\n const wordAlias: KeyId = direction === \"left\" ? \"alt+b\" : \"alt+f\";\n // Preserve the word-navigation aliases some terminals send for Option+Arrow.\n return matchesKey(data, arrow) && !matchesKey(data, wordAlias);\n };\n\n const inlineEditorRenderer = (): ((width: number) => string[]) | undefined => {\n const editor = options.editor;\n if (!editor?.render) return undefined;\n return (width: number) => {\n const lines = editor.render!(width);\n if (bridge?.extractInlineEditorLines) {\n return bridge.extractInlineEditorLines(lines, editor.paddingX ?? 0);\n }\n return [...lines];\n };\n };\n\n return {\n targetId,\n get mode() {\n return mode;\n },\n get active() {\n return !disposed && (queue.length > 0 || dispatched.length > 0);\n },\n get editingActive() {\n return editSession !== undefined;\n },\n\n stage(text, lane) {\n if (disposed) return { ok: false, error: \"Queue is disposed\" };\n const trimmed = text.trim();\n if (!trimmed) return { ok: false, error: \"Nothing to queue\" };\n if (!isQueueable(trimmed) || controlInputRe.test(trimmed)) {\n return {\n ok: false,\n error: \"Control input (/ commands, ! bash) is Main-only and is not queued from a focused conversation\",\n };\n }\n const row = queue.enqueue(lane, text);\n notify(`Queued ${laneLabel(lane)} \u2192 ${targetLabel}`, \"info\");\n requestRender();\n return { ok: true, id: row.id };\n },\n\n async submit(lane) {\n if (disposed) return false;\n if (editSession) {\n notify(\"Finish or cancel row editing before dispatching the queue\", \"info\");\n return false;\n }\n const batch = headBatch(lane);\n if (batch.length === 0) {\n const head = queue.peek();\n if (head?.paused) notify(`The next ${laneLabel(lane)} row is paused \u2014 dispatch holds there`, \"info\");\n else notify(`No dispatchable queued ${laneLabel(lane)} rows at the timeline head`, \"info\");\n return false;\n }\n let sent = 0;\n lastSendError = undefined;\n for (const item of batch) {\n if (disposed) return false;\n queue.remove(item.id);\n const pending: DispatchedRow = { id: item.id, lane, text: item.text };\n dispatched.push(pending);\n requestRender();\n let expectedId: string | undefined;\n try {\n const result = await options.send(item.text, lane);\n // Actor routes can report the original envelope/message id; a\n // one-shot native route may resolve void \u2014 identity then falls\n // back to the live-append text frontier.\n const candidate = result as { messageId?: unknown; id?: unknown } | undefined;\n const reported = candidate?.messageId ?? candidate?.id;\n if (typeof reported === \"string\" && reported !== \"\") expectedId = reported;\n } catch (error) {\n lastSendError = error;\n const pendingIndex = dispatched.indexOf(pending);\n if (pendingIndex < 0 || disposed) return !disposed;\n dispatched.splice(pendingIndex, 1);\n // Exact failed-send restoration: only the failed row is prepended\n // \u2014 rows behind it were never removed from the queue, so they are\n // still in their original positions after it.\n queue.prepend({ ...item });\n notify(`Send failed for ${targetLabel} (${laneLabel(lane)}); row restored to the queue head: ${errorText(error)}`, \"error\");\n requestRender();\n return false;\n }\n if (expectedId) pending.expectedId = expectedId;\n sent += 1;\n }\n notify(`Accepted ${sent} queued ${laneLabel(lane)} row${sent === 1 ? \"\" : \"s\"} \u2192 ${targetLabel} \u00B7 awaiting delivery`, \"info\");\n requestRender();\n return true;\n },\n\n async dispatch(text, lane) {\n const row = this.stage(text, lane);\n if (!row.ok || !row.id) throw new Error(row.error ?? \"Unable to queue input\");\n if (!await this.submit(lane)) {\n queue.remove(row.id);\n throw lastSendError ?? new Error(\"The queue head is paused or held; edit or resume it before sending\");\n }\n },\n\n park(text, lane) {\n const result = this.stage(text, lane);\n if (result.id) queue.setPaused(result.id, true);\n return result;\n },\n\n cancelEditing() { if (editSession) finishEditing(false); },\n\n syncPending(pending) {\n externalPending = [];\n if (!pending) return;\n const own = [...queue.snapshot(), ...dispatched];\n for (const [lane, messages] of [[\"steer\", pending.steering], [\"followUp\", pending.followUp]] as const) {\n const remaining = own.filter((row) => row.lane === lane).map((row) => row.text);\n messages.forEach((text, index) => {\n const match = remaining.indexOf(text);\n if (match >= 0) remaining.splice(match, 1);\n else externalPending.push({ id: `native:${lane}:${index}`, lane, text });\n });\n }\n },\n\n rows: orderedRows,\n\n render(width) {\n if (disposed || width <= 0) return [];\n const rows = orderedRows();\n if (rows.length === 0) return [];\n // Extension mode with a bridge that serves the real renderer: render\n // the actual shared execution-outline widget. The caption keeps the\n // execution model honest \u2014 Fabric dispatches on submit; retirement is\n // delivery-confirmed, not implied by the outline.\n if (bridge?.createTimelineWidget && bridge.buildTimelineItems) {\n const visibleRows: ConversationQueueBridgeRow[] = [\n ...[...dispatched, ...externalPending].map((row, index) => ({ id: row.id, lane: row.lane, text: row.text, images: [], sequence: index - dispatched.length })),\n ...queue.snapshot(),\n ];\n const displayQueue = new Proxy(queue, { get(target, key) {\n if (key === \"snapshot\") return () => visibleRows;\n const value: unknown = Reflect.get(target, key, target);\n return typeof value === \"function\" ? value.bind(target) : value;\n } });\n const items = bridge.buildTimelineItems(displayQueue, editSession);\n const inline = editSession ? inlineEditorRenderer() : undefined;\n const editingId = editSession?.selectedId;\n const widget = bridge.createTimelineWidget(\n {\n items,\n ...(editingId !== undefined ? { editingId } : {}),\n paused: false,\n idle: options.isIdle?.() ?? false,\n ...(inline ? { renderInlineEditor: inline } : {}),\n },\n theme,\n );\n const lines = widget.render(width);\n if (dispatched.length > 0) lines.push(theme.fg(\"dim\", truncateToWidth(\"Sent rows await child delivery; they cannot be edited locally.\", width, \"\")));\n return lines;\n }\n // Native Pi pending-messages display (ground-truth labels/colors) or\n // an older bridge without the renderer members.\n const lines: string[] = [\"\"];\n const innerWidth = Math.max(0, width - 2);\n const dequeueHint = (options.keybindings ?? getKeybindings()).getKeys(\"app.message.dequeue\").join(\"/\") || DEQUEUE_FALLBACK;\n for (const row of rows) {\n const label = bridge ? bridge.laneLabel(row.lane) : NATIVE_LANE_LABEL[row.lane];\n const marker = row.selected ? \"\u203A \" : row.paused ? \"\u23F8 \" : \"\";\n const note = row.removed\n ? \" \u00B7 removed on save\"\n : row.paused\n ? \" \u00B7 paused\"\n : \"\";\n const color: ThemeColor = row.state === \"dispatched\"\n ? \"dim\"\n : bridge ? bridge.laneColor(row.lane) as ThemeColor : \"dim\";\n lines.push(\n ` ${theme.fg(color, truncateToWidth(`${marker}${label}: ${row.text.replace(/\\n/g, \" \")}${note}`, innerWidth, \"\u2026\"))} `,\n );\n }\n const hint = queue.length > 0 ? `\u21B3 ${dequeueHint} to edit queued messages` : \"\u21B3 Waiting for child delivery\";\n lines.push(` ${theme.fg(\"dim\", truncateToWidth(hint, innerWidth, \"\u2026\"))} `);\n return lines;\n },\n\n handleInput(data) {\n if (disposed) return false;\n if (!editSession) {\n if (queue.length === 0) return false;\n if (!options.editor?.getText().trim() && matchesKey(data, Key.enter)) {\n const head = queue.peek();\n if (head) { queue.setPaused(head.id, false); void this.submit(head.lane); }\n return true;\n }\n if (actionMatches(data, \"app.message.dequeue\", (input) => matchesKey(input, DEQUEUE_FALLBACK))) {\n return startEditing();\n }\n return false;\n }\n const session = editSession;\n const editor = options.editor;\n // Navigation mirrors the extension: configured dequeue action moves to\n // the previous row, its mirrored twin moves to the next.\n if (actionMatches(data, \"app.message.dequeue\", (input) => matchesKey(input, DEQUEUE_FALLBACK)) && editor) {\n const ordered = queue.snapshot();\n const index = ordered.findIndex((item) => item.id === session.selectedId);\n const target = index <= 0 ? ordered.at(-1) : ordered[index - 1];\n if (target) editor.setText(session.select(target, editor.getText()));\n requestRender();\n return true;\n }\n const nextKeys = dequeueKeys();\n if (nextKeys.length > 0 && nextKeys.some((key) => matchesKey(data, key as KeyId)) && editor) {\n const ordered = queue.snapshot();\n const index = ordered.findIndex((item) => item.id === session.selectedId);\n const target = index === -1 || index === ordered.length - 1 ? ordered[0] : ordered[index + 1];\n if (target) editor.setText(session.select(target, editor.getText()));\n requestRender();\n return true;\n }\n if (matchesKey(data, REMOVE_ROW_KEY)) {\n session.toggleRemoved(session.selectedId);\n requestRender();\n return true;\n }\n if (matchesKey(data, PAUSE_ROW_KEY)) {\n session.togglePaused(session.selectedId);\n requestRender();\n return true;\n }\n if (matchesOptionArrow(data, \"left\")) {\n session.setLane(session.selectedId, \"followUp\");\n requestRender();\n return true;\n }\n if (matchesOptionArrow(data, \"right\")) {\n session.setLane(session.selectedId, \"steer\");\n requestRender();\n return true;\n }\n if (matchesKey(data, TOGGLE_LANE_KEY)) {\n const current = queue.get(session.selectedId)?.lane;\n if (current) session.setLane(session.selectedId, current === \"steer\" ? \"followUp\" : \"steer\");\n requestRender();\n return true;\n }\n if (\n actionMatches(data, \"tui.input.submit\", (input) => matchesKey(input, Key.enter))\n || actionMatches(data, \"app.message.followUp\", () => false)\n ) {\n return finishEditing(true);\n }\n if (actionMatches(data, \"app.interrupt\", (input) => matchesKey(input, Key.escape))) {\n return finishEditing(false);\n }\n editor?.handleInput?.(data);\n return true;\n },\n\n syncSnapshot(entries) {\n if (disposed || dispatched.length === 0) {\n // Still record identities so a pre-dispatch baseline exists even\n // before anything is queued.\n for (const entry of entries) {\n if (!seenIds.has(entry.id)) seenIds.add(entry.id);\n }\n return 0;\n }\n // Fold the snapshot in first: historical entries (initial baseline,\n // older transcript pages) register identity without creating frontier;\n // live unseen entries extend the per-text live-append frontier.\n for (const entry of entries) {\n if (seenIds.has(entry.id)) continue;\n seenIds.add(entry.id);\n if (entry.historical) continue;\n const key = entry.text.trim();\n liveTextCounts.set(key, (liveTextCounts.get(key) ?? 0) + 1);\n }\n let retired = 0;\n const consume = (entry: ConversationSnapshotEntry) => {\n consumedIds.add(entry.id);\n if (!entry.historical) {\n const key = entry.text.trim();\n const remaining = (liveTextCounts.get(key) ?? 0) - 1;\n if (remaining > 0) liveTextCounts.set(key, remaining);\n else liveTextCounts.delete(key);\n }\n };\n const frontierEntry = (row: DispatchedRow): ConversationSnapshotEntry | undefined => {\n // 1. Expected stable native identity (actor envelope/message id):\n // any entry carrying it confirms delivery outright.\n if (row.expectedId) {\n const match = entries.find((entry) => entry.id === row.expectedId && !consumedIds.has(entry.id));\n if (match) return match;\n }\n // 2. Live-append frontier beyond the historical baseline: only\n // entries that arrived live after dispatch, counted per text so\n // duplicate rows retire one-for-one. History and older pages\n // never qualify.\n for (const entry of entries) {\n if (entry.historical || consumedIds.has(entry.id)) continue;\n if (entry.text.trim() === row.text.trim() && (liveTextCounts.get(entry.text.trim()) ?? 0) > 0) {\n return { id: entry.id, text: entry.text.trim() };\n }\n }\n return undefined;\n };\n for (let index = dispatched.length - 1; index >= 0; index -= 1) {\n const row = dispatched[index];\n if (!row) continue;\n const confirmed = frontierEntry(row);\n if (!confirmed) continue;\n consume(confirmed);\n dispatched.splice(index, 1);\n retired += 1;\n }\n if (retired > 0) {\n notify(`${retired} queued row${retired === 1 ? \"\" : \"s\"} confirmed delivered \u2192 ${targetLabel}`, \"info\");\n requestRender();\n }\n return retired;\n },\n\n retireAll(reason) {\n if (disposed) return 0;\n const count = queue.length + dispatched.length;\n queue.clear();\n dispatched.length = 0;\n editSession = undefined;\n if (count > 0) {\n const suffix = reason ? ` (${reason})` : \"\";\n notify(`Retired ${count} queued row${count === 1 ? \"\" : \"s\"} for ${targetLabel}${suffix}`, \"info\");\n requestRender();\n }\n return count;\n },\n\n pendingCount() {\n if (disposed) return 0;\n return queue.length + dispatched.length;\n },\n\n dispose({ retain = false } = {}) {\n if (disposed) return;\n disposed = true;\n editSession = undefined;\n if (retain) {\n // Rows stay parked: in extension mode the bridge retains them per\n // targetId for re-adoption when the target is focused again.\n return;\n }\n queue.clear();\n dispatched.length = 0;\n if (bridge) emitHandshake(\"release\");\n },\n };\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,uBAAuB;AAGhC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAAA;AAAA,EACA;AAAA,EACA,OAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,gBAAAC;AAAA,OAEK;;;AChBP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AAEP,SAAS,wBAAwB;AAwDjC,IAAM,4BAA4B;AAElC,IAAM,YAAY,CAAC,UAA2B;AAC5C,MAAI,UAAU,OAAW,QAAO;AAChC,MAAI;AACF,WAAO,KAAK,UAAU,KAAK,KAAK;AAAA,EAClC,QAAQ;AACN,WAAO,kBAAkB,OAAO,KAAK,CAAC;AAAA,EACxC;AACF;AAiDO,IAAM,uCAAN,MAA2C;AAAA,EA4BhD,YACmB,KACA,OACA,kBAA+D,CAAC,GACjF;AAHiB;AACA;AACA;AAEjB,SAAK,sBAAsB,MAAY;AACrC,UAAI,KAAK,SAAU;AACnB,WAAK,WAAW;AAChB,WAAK,IAAI,cAAc;AAAA,IACzB;AAAA,EACF;AAAA,EArCiB,iBAAiB,oBAAI,IAA6B;AAAA,EAClD,oBAAoB,oBAAI,IAAgC;AAAA,E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ager, Theme } from \"@earendil-works/pi-coding-agent\";\nimport type { Component, Focusable, KeyId, TUI, TuiMouseEvent, TuiMouseEventResult } from \"@earendil-works/pi-tui\";\nimport {\n CURSOR_MARKER,\n Editor,\n fuzzyFilter,\n getKeybindings,\n Input,\n Key,\n Loader,\n Text,\n matchesKey,\n truncateToWidth,\n visibleWidth,\n type EditorTheme,\n} from \"@earendil-works/pi-tui\";\nimport { FabricConversationTranscriptRenderer, type FabricConversationTranscriptRendererOptions } from \"./conversation-render.js\";\nimport { conversationFooter, type FabricConversationAppearance } from \"./conversation-chrome.js\";\nimport type { AgentUsage } from \"../agents/types.js\";\nimport { safeText } from \"./format.js\";\nimport type { CodePreviewSettings } from \"./code-preview.js\";\nimport type { NativeConversationTranscript } from \"./conversation-native-reader.js\";\nimport { defaultConversationTarget } from \"./conversation-targets.js\";\nimport { ConversationTextSelection } from \"./conversation-selection.js\";\nimport { appendConversationPrompt, conversationPromptHistory } from \"./conversation-history.js\";\nimport { conversationAssistantText, conversationCommandCompletion, CONVERSATION_COMMAND_HELP } from \"./conversation-commands.js\";\nimport { ConversationQueueStore } from \"./conversation-queue-store.js\";\nimport type { ConversationQueue } from \"./conversation-queue.js\";\nimport { isActiveStatus } from \"./types.js\";\n\nexport type FabricConversationDelivery = \"steer\" | \"followUp\";\n\nexport interface FabricConversationTarget {\n id: string;\n name: string;\n kind: \"main\" | \"peer\" | \"agent\" | \"actor\";\n parentId?: string;\n status: string;\n runner?: string;\n model?: string;\n thinking?: string;\n cwd?: string;\n branch?: string;\n usage?: AgentUsage;\n contextWindow?: number;\n canSteer: boolean;\n canFollowUp: boolean;\n canStop: boolean;\n readOnlyReason?: string;\n stale?: boolean;\n /** Latest activity timestamp; enables an unread marker in the target picker. */\n updatedAt?: number;\n}\n\nexport interface FabricConversationStateEntry {\n draft: string;\n following: boolean;\n scroll: number;\n pageAnchor: \"start\" | \"end\" | \"prepend\" | undefined;\n anchorLength?: number | undefined;\n toolsExpanded: boolean;\n hideThinking?: boolean;\n lastSeenUpdatedAt: number;\n /** Session-local composer history, oldest first; lazily seeded, like Pi. */\n promptHistory?: string[];\n}\n\nconst STATE_ENTRY_LIMIT = 128;\n\n/** Session-owned in-flight send; survives view close/reopen, cleared on clear(). */\nexport interface FabricConversationPendingSend {\n id: string;\n message: string;\n delivery: FabricConversationDelivery;\n}\n\n/**\n * Per-target view state owned by the parent controller. Created once and\n * reused across overlay opens so drafts, scroll/following, and the selected\n * target survive close/reopen; clear() on session shutdown (and bumps epoch\n * so in-flight sends from a previous session never mutate new state).\n */\nexport class FabricConversationState {\n readonly queues = new ConversationQueueStore();\n selectedId: string | undefined;\n private epochCounter = 0;\n private readonly entries = new Map<string, FabricConversationStateEntry>();\n private readonly pendingSends = new Set<FabricConversationPendingSend>();\n\n get epoch(): number {\n return this.epochCounter;\n }\n\n hasPendingSend(id: string, message: string): boolean {\n for (const pending of this.pendingSends) {\n if (pending.id === id && pending.message === message) return true;\n }\n return false;\n }\n\n addPendingSend(pending: FabricConversationPendingSend): void {\n this.pendingSends.add(pending);\n }\n\n /** Acknowledged: drop the pending marker and clear only the exact accepted draft. */\n resolvePendingSend(id: string, message: string): void {\n for (const pending of this.pendingSends) {\n if (pending.id !== id || pending.message !== message) continue;\n this.pendingSends.delete(pending);\n const entry = this.entries.get(id);\n if (entry && entry.draft === message) entry.draft = \"\";\n return;\n }\n }\n\n /** Rejected: drop the pending marker; the raw draft stays untouched. */\n failPendingSend(id: string, message: string): void {\n for (const pending of this.pendingSends) {\n if (pending.id !== id || pending.message !== message) continue;\n this.pendingSends.delete(pending);\n return;\n }\n }\n\n /** Live view state for a target; creates (and may evict empty) entries. */\n view(id: string): FabricConversationStateEntry {\n const existing = this.entries.get(id);\n if (existing) {\n this.entries.delete(id);\n this.entries.set(id, existing);\n return existing;\n }\n const created: FabricConversationStateEntry = {\n draft: \"\",\n following: true,\n scroll: 0,\n pageAnchor: undefined,\n toolsExpanded: false,\n lastSeenUpdatedAt: 0,\n };\n this.entries.set(id, created);\n this.enforceLimit();\n return created;\n }\n\n /** Non-mutating lookup; unread checks must never create or evict drafts. */\n peek(id: string): FabricConversationStateEntry | undefined {\n return this.entries.get(id);\n }\n\n clear(): void {\n this.queues.clear();\n this.entries.clear();\n this.pendingSends.clear();\n this.selectedId = undefined;\n this.epochCounter++;\n }\n\n private enforceLimit(): void {\n while (this.entries.size > STATE_ENTRY_LIMIT) {\n let evicted = false;\n for (const key of this.entries.keys()) {\n if (key === this.selectedId) continue;\n const entry = this.entries.get(key);\n // Only discard untouched lightweight navigation state. Pinned scroll,\n // loaded-page anchors, queues and in-flight sends outlive reader suspension.\n if (entry && entry.draft === \"\" && entry.following && !entry.pageAnchor &&\n !entry.toolsExpanded && entry.hideThinking === undefined &&\n !this.queues.get(key) && ![...this.pendingSends].some((pending) => pending.id === key)) {\n this.entries.delete(key);\n evicted = true;\n break;\n }\n }\n if (!evicted) break;\n }\n }\n}\n\nexport interface FabricConversationOptions {\n targets: () => FabricConversationTarget[];\n initialTargetId?: string;\n state: FabricConversationState;\n transcript: (id: string, followLatest: boolean) => NativeConversationTranscript;\n loadOlder: (id: string) => boolean;\n loadNewer: (id: string) => boolean;\n loadLatest: (id: string) => boolean;\n send: (id: string, message: string, delivery: FabricConversationDelivery) => Promise<unknown>;\n stop: (id: string) => Promise<unknown>;\n close: () => void;\n copyToClipboard?: (text: string) => Promise<void>;\n onTargetChange?: (id: string) => void;\n keybindings?: Pick<KeybindingsManager, \"matches\" | \"getKeys\">;\n codePreviewSettings?: CodePreviewSettings;\n appearance?: FabricConversationAppearance;\n rendererOptions?: FabricConversationTranscriptRendererOptions | undefined;\n queueEvents?: { emit(channel: string, data: unknown): void } | undefined;\n}\n\ninterface Feedback {\n text: string;\n kind: \"info\" | \"error\";\n at: number;\n}\n\nconst FEEDBACK_TTL_MS = 8_000;\nconst FOLLOW_UP_FALLBACK: KeyId[] = [\"alt+enter\", \"ctrl+q\"];\nconst TOOLS_EXPAND_FALLBACK: KeyId[] = [\"ctrl+o\"];\n\nconst conversationEditorTheme = (theme: Theme, thinking: () => string | undefined): EditorTheme => ({\n borderColor: (value: string) => {\n const level = thinking();\n const color = level === \"minimal\" ? \"thinkingMinimal\" : level === \"low\" ? \"thinkingLow\"\n : level === \"medium\" ? \"thinkingMedium\" : level === \"high\" ? \"thinkingHigh\"\n : level === \"xhigh\" ? \"thinkingXhigh\" : level === \"max\" ? \"thinkingMax\" : \"borderMuted\";\n return theme.fg(color, value);\n },\n selectList: {\n selectedPrefix: (text: string) => theme.fg(\"accent\", text),\n selectedText: (text: string) => theme.fg(\"accent\", text),\n description: (text: string) => theme.fg(\"muted\", text),\n scrollInfo: (text: string) => theme.fg(\"muted\", text),\n noMatch: (text: string) => theme.fg(\"muted\", text),\n },\n});\n\nconst errorText = (error: unknown): string => {\n if (error instanceof Error) return error.message;\n return String(error ?? \"\");\n};\n\nconst isMainTarget = (target: FabricConversationTarget | undefined): boolean =>\n target?.kind === \"main\";\n\ninterface PickerRow {\n target: FabricConversationTarget;\n depth: number;\n}\n\nexport class FabricConversationView implements Component, Focusable {\n private focusState = true;\n private readonly tui: TUI;\n private readonly theme: Theme;\n private readonly options: FabricConversationOptions;\n private readonly state: FabricConversationState;\n private readonly renderer: FabricConversationTranscriptRenderer;\n private editor: Editor | undefined;\n private suspendedEditor: Editor | undefined;\n private editorEpoch = -1;\n private pickerInput: Input | undefined;\n private pickerRows: PickerRow[] = [];\n private pickerSelectedId: string | undefined;\n private mode: \"conversation\" | \"picker\" = \"conversation\";\n private currentId: string | undefined;\n private feedback: Feedback | undefined;\n private commandNotification: { component: Text; epoch: number; pendingResult?: Text } | undefined;\n private notificationScope = 0;\n private stopConfirmId: string | undefined;\n private disposed = false;\n private lastBodyLength = 0;\n private lastBody: string[] = [];\n private lastBodyBudget = 1;\n private editorTop = 0;\n private editorHeight = 0;\n private ownsMouseMode = false;\n private targets: FabricConversationTarget[] = [];\n private targetsKey = \"\";\n private readonly targetsById = new Map<string, FabricConversationTarget>();\n private nonMain: FabricConversationTarget[] = [];\n private main: FabricConversationTarget | undefined;\n private observationKey = \"\";\n private observedTranscript: NativeConversationTranscript | undefined;\n private pickerKey = \"\";\n private working: Loader | undefined;\n private workingTargetId: string | undefined;\n private readonly textSelection = new ConversationTextSelection();\n private selectionWidth = 0;\n private selectionWasFollowing = false;\n private bodyTop = 0;\n private bodyHeight = 0;\n private copyVersion = 0;\n private copyTask: Promise<void> = Promise.resolve();\n\n constructor(\n tui: TUI,\n theme: Theme,\n options: FabricConversationOptions,\n ) {\n this.tui = tui;\n this.theme = theme;\n this.options = options;\n this.state = options.state;\n this.updateTargets();\n this.renderer = new FabricConversationTranscriptRenderer(tui, theme, {\n ...options.rendererOptions,\n imageWidthCells: options.appearance?.imageWidthCells,\n });\n this.editor = this.createEditor();\n this.editorEpoch = this.state.epoch;\n // An explicit initialTargetId must win over state.selectedId so reissuing\n // \"/fabric chat B\" focuses B instead of reopening the previously selected A.\n const nonMain = this.nonMainTargets();\n const requested = options.initialTargetId ?? defaultConversationTarget(nonMain, options.state.selectedId)?.id;\n const requestedTarget = requested\n ? this.targetById(requested)\n : undefined;\n const resolved =\n requested && requestedTarget && !isMainTarget(requestedTarget)\n ? requested\n : nonMain[0]?.id;\n if (resolved) this.applySelection(resolved, false);\n if (!this.currentId) this.currentId = nonMain[0]?.id;\n // Regular Pi leaves mouse input to terminal scrollback. This preview owns\n // a separate viewport; capture wheel and drag input and restore on close.\n if (tui.mode === \"regular\") {\n tui.terminal.write(\"\\x1b[?1000h\\x1b[?1002h\\x1b[?1006h\");\n this.ownsMouseMode = true;\n }\n }\n\n private createEditor(withHistory = true): Editor {\n // Own method only: assignment through Pi's live proxy would mutate Main.\n const editorTui = Object.create(this.tui, { requestRender: { value: () => {\n if (!this.disposed && this.editor === editor) this.tui.requestRender();\n } } }) as TUI;\n const editor = new Editor(editorTui, conversationEditorTheme(this.theme, () => this.currentTarget()?.thinking), {\n paddingX: this.options.appearance?.editorPaddingX ?? 0,\n });\n editor.focused = this.focusState && this.mode === \"conversation\";\n if (!withHistory) return editor;\n editor.setAutocompleteProvider(conversationCommandCompletion(() =>\n !this.disposed && this.editor === editor && this.mode === \"conversation\" && !this.state.queues.get(this.currentId ?? \"\")?.editingActive));\n editor.onSubmit = (text) => {\n if (this.disposed || this.editor !== editor) return;\n // Native completion submits after clearing the editor; restore for routing.\n editor.setText(text);\n this.submit(\"steer\");\n };\n editor.onChange = (text) => {\n if (this.editor === editor && this.currentId && !this.state.queues.get(this.currentId)?.editingActive) this.state.view(this.currentId).draft = text;\n };\n for (const text of this.currentId ? this.state.peek(this.currentId)?.promptHistory ?? [] : []) editor.addToHistory(text);\n return editor;\n }\n\n private releaseEditor(editor: Editor | undefined): void {\n if (!editor) return;\n editor.setAutocompleteProvider(conversationCommandCompletion(() => false));\n editor.focused = false;\n delete editor.onSubmit;\n delete editor.onChange;\n }\n\n private resetEditor(): void {\n this.releaseEditor(this.editor);\n this.releaseEditor(this.suspendedEditor);\n this.suspendedEditor = undefined;\n this.editor = this.createEditor();\n this.editorEpoch = this.state.epoch;\n }\n\n private ensureEditorEpoch(): void {\n if (this.editorEpoch === this.state.epoch) return;\n this.observedTranscript = undefined;\n this.observationKey = \"\";\n this.resetEditor();\n if (this.currentId) this.editor?.setText(this.state.view(this.currentId).draft);\n }\n\n private initializePromptHistory(): void {\n if (!this.currentId || !this.editor || this.suspendedEditor) return;\n const entry = this.state.view(this.currentId);\n if (entry.promptHistory !== undefined) return;\n const transcript = this.observedTranscript ?? this.options.transcript(this.currentId, entry.following);\n // A worker may not have written its initial transcript yet; retry later.\n if (transcript.unavailable) return;\n entry.promptHistory = conversationPromptHistory(transcript);\n for (const text of entry.promptHistory) this.editor.addToHistory(text);\n }\n\n private rememberPrompt(text: string): void {\n if (!this.currentId) return;\n this.initializePromptHistory();\n const entry = this.state.view(this.currentId);\n appendConversationPrompt(entry.promptHistory ??= [], text);\n this.editor?.addToHistory(text);\n }\n\n private setQueueEditorText(text: string): void {\n let restoredText = text;\n const editing = this.currentId && this.state.queues.get(this.currentId)?.editingActive;\n if (editing && !this.suspendedEditor) {\n // Preserve the composer's native history/draft; queued rows never browse it.\n this.suspendedEditor = this.editor;\n if (this.suspendedEditor) this.suspendedEditor.focused = false;\n this.editor = this.createEditor(false);\n } else if (!editing && this.suspendedEditor) {\n this.releaseEditor(this.editor);\n this.editor = this.suspendedEditor;\n this.suspendedEditor = undefined;\n this.editor.focused = this.focusState && this.mode === \"conversation\";\n // An acknowledgement may have cleared the composer while a row was open.\n restoredText = this.currentId ? this.state.view(this.currentId).draft : text;\n }\n this.editor?.setText(restoredText);\n }\n\n get focused(): boolean {\n return this.focusState;\n }\n\n set focused(value: boolean) {\n this.focusState = value;\n if (this.mode === \"picker\") {\n if (this.pickerInput) this.pickerInput.focused = value;\n if (this.editor) this.editor.focused = false;\n return;\n }\n if (this.editor) this.editor.focused = value;\n }\n\n /** Re-focus a target while the view is open; selecting Main closes to the native session. */\n selectTarget(id: string): void {\n this.updateTargets();\n this.applySelection(id, true);\n }\n\n handleInput(data: string): void {\n if (this.disposed) return;\n this.ensureEditorEpoch();\n this.updateTargets();\n // Fullscreen Pi dispatches normalized events; regular mode forwards SGR.\n const mouse = /^\\x1b\\[<(\\d+);(\\d+);(\\d+)([Mm])$/.exec(data);\n if (mouse) {\n const button = Number(mouse[1]);\n const wheel = (button & 64) !== 0;\n const release = mouse[4] === \"m\" || (!wheel && (button & 3) === 3 && !(button & 32));\n this.handleMouse({ type: wheel ? \"wheel\" : release ? \"release\" : (button & 32) ? \"drag\" : \"press\",\n button: wheel ? \"none\" : (button & 3) === 0 ? \"left\" : (button & 3) === 1 ? \"middle\" : (button & 3) === 2 ? \"right\" : \"none\",\n ...(wheel ? { wheelDelta: (button & 1) === 0 ? -3 : 3 } : {}),\n x: Number(mouse[2]) - 1, y: Number(mouse[3]) - 1, screenX: Number(mouse[2]) - 1, screenY: Number(mouse[3]) - 1,\n width: this.tui.terminal.columns, height: this.terminalRows(), shift: !!(button & 4), alt: !!(button & 8), ctrl: !!(button & 16) });\n return;\n }\n if (this.mode === \"picker\") {\n this.handlePickerInput(data);\n this.tui.requestRender();\n return;\n }\n this.handleConversationInput(data);\n this.tui.requestRender();\n }\n\n handleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined {\n if (this.disposed) return undefined;\n this.ensureEditorEpoch();\n this.updateTargets();\n if (event.type === \"wheel\") {\n if (this.mode === \"picker\") this.movePickerSelection((event.wheelDelta ?? 0) < 0 ? -1 : 1);\n else this.scrollBy(event.wheelDelta ?? 0);\n this.tui.requestRender();\n return { handled: true };\n }\n if (this.mode !== \"conversation\" || !this.currentId) return { handled: true };\n const entry = this.state.view(this.currentId);\n const inBody = event.y >= this.bodyTop && event.y < this.bodyTop + this.bodyHeight;\n const row = entry.scroll + Math.max(0, Math.min(this.bodyHeight - 1, event.y - this.bodyTop));\n if (event.type === \"press\" && event.button === \"left\" && inBody) {\n this.selectionWasFollowing = entry.following;\n entry.following = false;\n this.textSelection.start(this.lastBody, row, event.x);\n this.tui.requestRender();\n return { handled: true, capture: true };\n }\n if (this.textSelection.dragging && (event.type === \"drag\" || event.type === \"release\")) {\n if (event.type === \"drag\") this.textSelection.move(row, event.x);\n else {\n this.textSelection.finish(row, event.x);\n if (!this.textSelection.active && this.selectionWasFollowing) entry.following = true;\n if (this.textSelection.active && (this.options.appearance?.copyOnSelect ?? true)) this.copySelection();\n }\n this.tui.requestRender();\n return { handled: true, render: true };\n }\n if (event.type === \"press\") this.textSelection.clear();\n if (event.y >= this.editorTop && event.y < this.editorTop + this.editorHeight) {\n return this.editor?.handleMouse({ ...event, y: event.y - this.editorTop, height: this.editorHeight }) ?? { handled: true };\n }\n // Never fall back to the host's selection or paste handlers behind an overlay.\n return { handled: true };\n }\n\n render(width: number): string[] {\n if (this.disposed || width <= 0) return [];\n this.updateTargets();\n if (width !== this.selectionWidth) {\n this.textSelection.clear();\n this.selectionWidth = width;\n }\n const rows = Math.max(1, this.terminalRows());\n this.markCurrentTargetSeen();\n this.reconcileEditor();\n const target = this.currentTarget();\n const queue = this.mode === \"conversation\" ? this.currentQueue() : undefined;\n this.observe();\n const liveTranscriptLines = this.mode === \"conversation\" ? this.transcriptLines(width) : [];\n const transcriptLines = this.textSelection.source ?? liveTranscriptLines;\n let queueLines = queue?.render(width) ?? [];\n // Native components own their interior padding. Giving them the full width\n // keeps user backgrounds and editor rules flush with both terminal edges.\n let editorLines = this.mode === \"conversation\" && !(queue?.editingActive && queue.mode === \"extension\") ? this.renderEditorLines(width) : [];\n const editorBudget = Math.min(editorLines.length, Math.max(1, rows - (rows >= 6 ? 3 : 0)));\n if (editorLines.length > editorBudget) {\n const cursor = Math.max(0, editorLines.findIndex((line) => line.includes(CURSOR_MARKER)));\n const start = Math.max(0, Math.min(cursor - Math.floor(editorBudget / 2), editorLines.length - editorBudget));\n editorLines = editorLines.slice(start, start + editorBudget);\n }\n let remaining = rows - editorLines.length;\n const footer = this.mode === \"conversation\"\n ? conversationFooter(target, this.theme, width).slice(0, Math.max(0, remaining - 1))\n : [];\n remaining -= footer.length;\n const head: string[] = [];\n if (remaining > 0) {\n head.push(this.breadcrumbLine(width));\n remaining--;\n }\n const feedback = this.currentFeedbackLine(width);\n if (feedback !== undefined && remaining > 1) {\n head.push(feedback);\n remaining--;\n }\n const hints = this.mode === \"conversation\" && remaining > 2 ? [this.hintsLine(width)] : [];\n remaining -= hints.length;\n const queueBudget = Math.max(0, remaining - 1);\n if (queueLines.length > queueBudget) {\n const cursor = queueLines.findIndex((line) => line.includes(CURSOR_MARKER));\n const start = Math.max(0, Math.min(cursor < 0 ? 0 : cursor - Math.floor(queueBudget / 2), queueLines.length - queueBudget));\n queueLines = queueLines.slice(start, start + queueBudget);\n }\n remaining -= queueLines.length;\n this.editorTop = rows - editorLines.length - footer.length - hints.length;\n this.editorHeight = editorLines.length;\n const body = remaining <= 0 ? [] : this.mode === \"picker\"\n ? this.pickerLines(width, remaining)\n : this.windowBody(transcriptLines, remaining, this.transcriptTail(width, remaining));\n this.bodyTop = head.length;\n const scroll = this.currentId ? this.state.view(this.currentId).scroll : 0;\n this.bodyHeight = this.mode === \"conversation\" ? Math.max(0, Math.min(remaining, this.lastBody.length - scroll)) : 0;\n if (this.textSelection.active) {\n for (let row = 0; row < this.bodyHeight; row++) body[row] = this.textSelection.highlight(body[row]!, scroll + row, this.theme);\n }\n while (body.length < remaining) body.push(\"\");\n return [...head, ...body.slice(0, remaining), ...queueLines, ...editorLines, ...footer, ...hints]\n .slice(0, rows)\n .map((line) => visibleWidth(line) <= width ? line : truncateToWidth(line, width, \"\"));\n }\n\n /** Observe files without rendering native history; true means a visible change\n * or a live animation still needs the normal TUI render path. */\n refresh(): boolean {\n if (this.disposed) return false;\n this.updateTargets();\n const changed = this.observe();\n return changed || (this.mode === \"conversation\" && this.selectedTargetIsWorking());\n }\n\n private observe(): boolean {\n const entry = this.currentId ? this.state.view(this.currentId) : undefined;\n const transcript = this.mode === \"conversation\" && this.currentTarget() && this.currentId && entry\n ? this.options.transcript(this.currentId, entry.following) : undefined;\n if (transcript && this.currentId) this.state.queues.sync(this.currentId, transcript);\n const key = JSON.stringify([this.targetsKey, this.currentId, this.mode, entry?.draft,\n this.feedback && Date.now() - this.feedback.at <= FEEDBACK_TTL_MS ? this.feedback : undefined,\n transcript && [transcript.sourceId, transcript.sessionId, transcript.sessionFile, transcript.eventsFile,\n transcript.revision, transcript.status, transcript.leafId, transcript.historyComplete, transcript.hasMore,\n transcript.hasNewer, transcript.unavailable, transcript.error, transcript.pendingMessages]]);\n const previous = this.observedTranscript;\n const changed = key !== this.observationKey || previous?.messages !== transcript?.messages ||\n previous?.entries !== transcript?.entries || previous?.streaming !== transcript?.streaming;\n this.observationKey = key;\n this.observedTranscript = transcript;\n this.syncWorkingIndicator();\n return changed;\n }\n\n private selectedTargetIsWorking(): boolean {\n const target = this.currentTarget();\n if (!target || target.stale) return false;\n // A killed worker can leave a partial message/tool in its log forever.\n // That retained tail must not override terminal or unavailable ownership.\n return isActiveStatus(target.status);\n }\n\n private syncWorkingIndicator(): void {\n const active = !this.disposed && this.mode === \"conversation\" && this.currentId && this.selectedTargetIsWorking();\n if (!active) {\n this.stopWorkingIndicator();\n return;\n }\n if (this.working && this.workingTargetId === this.currentId) return;\n this.stopWorkingIndicator();\n const id = this.currentId;\n this.workingTargetId = id;\n // Pi's standalone WorkingStatusIndicator delegates to this public Loader.\n this.working = new Loader({ requestRender: () => {\n if (!this.disposed && this.mode === \"conversation\" && this.currentId === id) this.tui.requestRender();\n } } as TUI, (text) => this.theme.fg(\"accent\", text), (text) => this.theme.fg(\"muted\", text), \"Working\");\n }\n\n private stopWorkingIndicator(): void {\n this.working?.stop();\n this.working = undefined;\n this.workingTargetId = undefined;\n }\n\n invalidate(): void {\n this.working?.invalidate();\n this.commandNotification?.component.invalidate();\n this.commandNotification?.pendingResult?.invalidate();\n this.renderer.invalidate();\n this.editor?.invalidate();\n this.pickerInput?.invalidate();\n }\n\n dispose(): void {\n if (this.currentId) this.state.queues.detach(this.currentId);\n this.disposed = true;\n this.clearCommandNotification();\n this.copyVersion++;\n this.textSelection.clear();\n this.stopWorkingIndicator();\n this.releaseEditor(this.editor);\n this.releaseEditor(this.suspendedEditor);\n this.suspendedEditor = undefined;\n this.editor = undefined;\n this.pickerInput = undefined;\n this.observedTranscript = undefined;\n this.lastBody = [];\n this.renderer.dispose();\n if (this.ownsMouseMode) {\n this.ownsMouseMode = false;\n this.tui.terminal.write(\"\\x1b[?1002l\\x1b[?1000l\\x1b[?1006l\");\n }\n }\n\n /** Keep the editor in sync with the shared session draft (e.g. after an ack\n * that landed while a previous view instance was disposed). */\n private reconcileEditor(): void {\n this.ensureEditorEpoch();\n if (this.mode !== \"conversation\" || !this.editor || !this.currentId) return;\n if (this.state.queues.get(this.currentId)?.editingActive) return;\n if (this.state.hasPendingSend(this.currentId, this.editor.getText())) return;\n const draft = this.state.view(this.currentId).draft;\n if (this.editor.getText() !== draft) this.editor.setText(draft);\n }\n\n private applySelection(id: string, requestRender: boolean): void {\n if (this.currentId && this.currentId !== id) this.state.queues.detach(this.currentId);\n const target = this.targetById(id);\n if (!target) {\n this.feedback = {\n text: `Unknown target ${safeText(id)}`,\n kind: \"error\",\n at: Date.now(),\n };\n if (requestRender) this.tui.requestRender();\n return;\n }\n if (isMainTarget(target)) {\n this.options.close();\n return;\n }\n const changed = this.currentId !== id;\n if (changed) {\n this.clearCommandNotification();\n this.copyVersion++;\n this.textSelection.clear();\n this.stopWorkingIndicator();\n this.observedTranscript = undefined;\n this.observationKey = \"\";\n this.lastBody = [];\n this.lastBodyLength = 0;\n this.renderer.invalidate();\n this.options.onTargetChange?.(id);\n }\n this.currentId = id;\n this.state.selectedId = id;\n if (changed) this.resetEditor();\n const entry = this.state.view(id);\n entry.lastSeenUpdatedAt = target.updatedAt ?? Date.now();\n this.stopConfirmId = undefined;\n this.closePicker();\n this.feedback = undefined;\n this.editor?.setText(entry.draft);\n if (requestRender) this.tui.requestRender();\n }\n\n private markCurrentTargetSeen(): void {\n if (!this.currentId) return;\n const target = this.targetById(this.currentId);\n if (!target?.updatedAt) return;\n const entry = this.state.view(this.currentId);\n if (entry.lastSeenUpdatedAt < target.updatedAt) entry.lastSeenUpdatedAt = target.updatedAt;\n }\n\n private updateTargets(): void {\n // One provider observation per frame/input, including providers that mutate\n // their roster in place. The fingerprint contains metadata, never history.\n const targets = this.options.targets();\n const key = JSON.stringify(targets);\n if (key === this.targetsKey) return;\n this.targetsKey = key;\n this.targets = targets;\n this.targetsById.clear();\n for (const target of targets) {\n if (!this.targetsById.has(target.id)) this.targetsById.set(target.id, target);\n }\n this.nonMain = targets.filter((target) => !isMainTarget(target));\n this.main = targets.find(isMainTarget);\n }\n\n private currentTargets(): FabricConversationTarget[] {\n return this.targets;\n }\n\n private nonMainTargets(): FabricConversationTarget[] {\n return this.nonMain;\n }\n\n private currentTarget(): FabricConversationTarget | undefined {\n return this.currentId ? this.targetById(this.currentId) : undefined;\n }\n\n private mainTarget(): FabricConversationTarget | undefined {\n return this.main;\n }\n\n private targetById(id: string): FabricConversationTarget | undefined {\n return this.targetsById.get(id);\n }\n\n private terminalRows(): number {\n return this.tui.terminal?.rows ?? process.stdout.rows ?? 28;\n }\n\n /**\n * Respects a configured binding; when an injected manager reports no keys\n * the binding is unbound (never falls back), and only the default global\n * manager (no injection) falls back to hard-coded keys.\n */\n private bindingMatches(\n data: string,\n binding: \"app.message.followUp\" | \"app.message.copy\" | \"app.tools.expand\" | \"app.thinking.toggle\",\n fallbackKeys: KeyId[],\n ): boolean {\n if (this.options.keybindings) {\n const keys = this.options.keybindings.getKeys(binding);\n return keys.length > 0 && this.options.keybindings.matches(data, binding);\n }\n const global = getKeybindings();\n const keys = global.getKeys(binding);\n if (keys.length > 0) return global.matches(data, binding);\n return fallbackKeys.some((key) => matchesKey(data, key));\n }\n\n private bindingHint(\n binding: \"app.message.followUp\" | \"app.message.copy\" | \"app.tools.expand\" | \"app.thinking.toggle\",\n fallbackLabel: string,\n ): string {\n const manager = this.options.keybindings ?? getKeybindings();\n const keys = manager.getKeys(binding);\n if (keys.length > 0) return keys.join(\"/\");\n return this.options.keybindings ? \"unbound\" : fallbackLabel;\n }\n\n private handleConversationInput(data: string): void {\n const editor = this.editor;\n if (!editor) return;\n this.feedback = undefined;\n if (this.stopConfirmId === undefined && this.bindingMatches(data, \"app.message.copy\", [\"ctrl+shift+c\"])) {\n this.copyResponse(undefined, true);\n return;\n }\n if (this.stopConfirmId === undefined && this.textSelection.active && matchesKey(data, Key.ctrl(\"c\"))) {\n this.copySelection();\n return;\n }\n if (this.stopConfirmId === undefined && this.textSelection.source && matchesKey(data, Key.escape)) {\n this.textSelection.clear();\n return;\n }\n const queue = this.currentQueue();\n if (this.stopConfirmId === undefined && !queue?.editingActive && editor.isShowingAutocomplete() &&\n [Key.enter, Key.tab, Key.up, Key.down, Key.escape].some((key) => matchesKey(data, key))) {\n editor.handleInput(data);\n return;\n }\n if (this.stopConfirmId === undefined && queue?.handleInput(data)) return;\n\n if (this.stopConfirmId !== undefined) {\n if (matchesKey(data, Key.enter)) {\n const target = this.targetById(this.stopConfirmId);\n this.stopConfirmId = undefined;\n if (target) this.dispatchStop(target);\n return;\n }\n if (matchesKey(data, Key.escape)) {\n this.stopConfirmId = undefined;\n this.notifyCommand(\"Stop cancelled\");\n return;\n }\n this.stopConfirmId = undefined;\n this.notifyCommand(\"Stop cancelled\");\n }\n\n if (this.bindingMatches(data, \"app.message.followUp\", FOLLOW_UP_FALLBACK)) {\n this.submit(\"followUp\");\n return;\n }\n if (matchesKey(data, Key.enter)) {\n this.submit(\"steer\");\n return;\n }\n if (matchesKey(data, Key.ctrl(\"c\"))) {\n if (editor.getText().length > 0) editor.setText(\"\");\n return;\n }\n if (matchesKey(data, Key.escape)) {\n this.options.close();\n return;\n }\n if (matchesKey(data, Key.ctrl(\"n\"))) {\n this.openPicker();\n return;\n }\n if (matchesKey(data, \"ctrl+tab\")) {\n this.cycleTarget(1);\n return;\n }\n if (matchesKey(data, \"shift+ctrl+tab\")) {\n this.cycleTarget(-1);\n return;\n }\n if (matchesKey(data, \"ctrl+shift+left\")) {\n this.navigateParent();\n return;\n }\n if (matchesKey(data, \"ctrl+shift+right\")) {\n this.navigateFirstChild();\n return;\n }\n if (matchesKey(data, \"alt+left\") && editor.getText().length === 0) {\n this.navigateParent();\n return;\n }\n if (matchesKey(data, \"alt+right\") && editor.getText().length === 0) {\n this.navigateFirstChild();\n return;\n }\n const viewportKeys = getKeybindings();\n if (viewportKeys.matches(data, \"tui.altScreen.previousPrompt\")) { this.scrollPrompt(-1); return; }\n if (viewportKeys.matches(data, \"tui.altScreen.nextPrompt\")) { this.scrollPrompt(1); return; }\n if (viewportKeys.matches(data, \"tui.altScreen.lineUp\")) { this.scrollBy(-1); return; }\n if (viewportKeys.matches(data, \"tui.altScreen.lineDown\")) { this.scrollBy(1); return; }\n if (viewportKeys.matches(data, \"tui.altScreen.pageUp\")) { this.scrollBy(-Math.max(1, this.lastBodyBudget - 2)); return; }\n if (viewportKeys.matches(data, \"tui.altScreen.pageDown\")) { this.scrollBy(Math.max(1, this.lastBodyBudget - 2)); return; }\n if (viewportKeys.matches(data, \"tui.altScreen.halfPageUp\")) { this.scrollBy(-Math.max(1, Math.floor(this.lastBodyBudget / 2))); return; }\n if (viewportKeys.matches(data, \"tui.altScreen.halfPageDown\")) { this.scrollBy(Math.max(1, Math.floor(this.lastBodyBudget / 2))); return; }\n if (viewportKeys.matches(data, \"tui.altScreen.top\")) { this.scrollToTop(); return; }\n if (viewportKeys.matches(data, \"tui.altScreen.bottom\")) { this.followLatest(); return; }\n if (this.bindingMatches(data, \"app.thinking.toggle\", [\"ctrl+t\"])) {\n this.textSelection.clear();\n if (this.currentId) {\n const entry = this.state.view(this.currentId);\n entry.hideThinking = !(entry.hideThinking ?? this.options.appearance?.hideThinkingBlock ?? false);\n }\n return;\n }\n if (this.bindingMatches(data, \"app.tools.expand\", TOOLS_EXPAND_FALLBACK)) {\n this.textSelection.clear();\n if (this.currentId) {\n const entry = this.state.view(this.currentId);\n entry.toolsExpanded = !entry.toolsExpanded;\n }\n return;\n }\n if (viewportKeys.matches(data, \"tui.editor.cursorUp\") || viewportKeys.matches(data, \"tui.editor.cursorDown\") ||\n viewportKeys.matches(data, \"tui.editor.historyPrevious\") || viewportKeys.matches(data, \"tui.editor.historyNext\")) this.initializePromptHistory();\n editor.handleInput(data);\n }\n\n private clearCommandNotification(): void {\n this.commandNotification = undefined;\n this.notificationScope++;\n }\n\n private notifyCommand(message: string, kind: Feedback[\"kind\"] = \"info\",\n options: { reserve?: string; reveal?: boolean } = {}): void {\n if (this.disposed || this.mode !== \"conversation\" || !this.currentId || !this.currentTarget()) return;\n this.feedback = undefined;\n // Pi showStatus/showError use Spacer(1) + Text, not the input/status dock.\n // Retain one local result, rather than implement a full notification history.\n const text = safeText(message).slice(0, 4096);\n this.commandNotification = {\n component: new Text(this.theme.fg(kind === \"error\" ? \"error\" : \"dim\", kind === \"error\" ? `Error: ${text}` : text),\n kind === \"error\" ? this.options.appearance?.outputPad ?? 1 : 1, 0),\n epoch: this.state.epoch,\n ...(options.reserve !== undefined ? { pendingResult: new Text(this.theme.fg(\"dim\", safeText(options.reserve).slice(0, 4096)), 1, 0) } : {}),\n };\n // Reveal the result in the loaded window; do not fetch newer history or\n // change following/selection when the user is inspecting an older page.\n if (options.reveal !== false) {\n const entry = this.state.view(this.currentId);\n entry.pageAnchor = entry.following ? undefined : \"end\";\n entry.anchorLength = undefined;\n }\n this.tui.requestRender();\n }\n\n private copyFeedback(text: string, kind: Feedback[\"kind\"], command?: string, reveal = true): void {\n if (command !== undefined) this.notifyCommand(text, kind, { reveal });\n else {\n // A shortcut superseding a slash copy must not leave a pending result.\n if (this.commandNotification?.pendingResult) this.clearCommandNotification();\n this.feedback = { text: safeText(text), kind, at: Date.now() };\n }\n }\n\n private copySelection(command?: string): void {\n const text = this.textSelection.text();\n if (!text) {\n this.copyFeedback(\"No transcript text selected. Drag to select first.\", \"error\", command);\n return;\n }\n this.copyText(text, \"Copied selected transcript text\", command);\n }\n\n private copyResponse(command?: string, preferSelection = false): void {\n if (preferSelection && this.textSelection.active) { this.copySelection(command); return; }\n if (!this.currentId) return;\n const transcript = this.options.transcript(this.currentId, false);\n if (transcript.hasNewer) {\n this.copyFeedback(\"Use /latest before /copy to load the latest response.\", \"error\", command);\n return;\n }\n const text = conversationAssistantText(transcript);\n if (!text) {\n this.copyFeedback(\"No assistant response to copy yet.\", \"error\", command);\n return;\n }\n this.copyText(text, \"Copied last assistant response\", command);\n }\n\n private copyText(text: string, message: string, command?: string): void {\n const id = this.currentId;\n const epoch = this.state.epoch;\n const version = ++this.copyVersion;\n const editor = this.editor;\n // Completion removes the suggestion rows synchronously. Reserve the final\n // result now, so clipboard latency cannot produce a blank, shifting frame.\n if (command !== undefined) this.notifyCommand(\"Copying\u2026\", \"info\", { reserve: message });\n const notification = this.commandNotification;\n const current = (): boolean => !this.disposed && this.currentId === id && this.state.epoch === epoch && this.copyVersion === version;\n // A newer command owns the notification, but does not cancel the copy itself.\n const currentResult = (): boolean => current() && (command === undefined || this.commandNotification === notification);\n // Serialize writes so a slower older copy cannot overwrite a newer one.\n this.copyTask = this.copyTask.then(() => {\n if (current()) return (this.options.copyToClipboard ?? copyToClipboard)(text);\n }).then(() => {\n if (!currentResult()) return;\n if (command !== undefined && id) {\n if (this.state.peek(id)?.draft === command) this.state.view(id).draft = \"\";\n if (editor?.getText() === command) editor.setText(\"\");\n }\n this.copyFeedback(message, \"info\", command, false);\n this.tui.requestRender();\n }, (error: unknown) => {\n if (!currentResult()) return;\n this.copyFeedback(`Copy failed: ${errorText(error)}`, \"error\", command, false);\n this.tui.requestRender();\n });\n }\n\n private submit(delivery: FabricConversationDelivery): void {\n const editor = this.editor;\n const target = this.currentTarget();\n if (!editor || !target || isMainTarget(target)) return;\n const raw = editor.getText();\n const message = editor.getExpandedText();\n if (!message.trim()) return;\n const command = message.trim().replace(/[\\t ]+/g, \" \");\n // Commands belong only to this target's in-memory editor history, including\n // failed attempts. Remember before navigation/validation, never via send.\n if (command.startsWith(\"/\")) this.rememberPrompt(message);\n if (command === \"/copy\") { this.copyResponse(raw); return; }\n if (command === \"/copy selection\") { this.copySelection(raw); return; }\n if (command === \"/help\") {\n editor.setText(\"\");\n this.notifyCommand(CONVERSATION_COMMAND_HELP);\n return;\n }\n if (command === \"/latest\") {\n editor.setText(\"\");\n this.followLatest();\n this.notifyCommand(\"Following latest output\");\n return;\n }\n\n if (command === \"/back\") {\n this.options.close();\n return;\n }\n if (command === \"/agents\") {\n this.openPicker();\n return;\n }\n if (command === \"/stop\") {\n if (!target.canStop) {\n this.notifyCommand(`Stop unavailable for ${target.name}: the selected target cannot be stopped from here.`, \"error\");\n return;\n }\n this.stopConfirmId = target.id;\n this.notifyCommand(`Press enter again to stop ${target.name} \u00B7 esc cancels`);\n return;\n }\n if (message.trim().startsWith(\"/\") || message.trim().startsWith(\"!\")) {\n this.notifyCommand(`Unsupported command \"${message.trim()}\" is not forwarded from this view. Use /help for preview commands.`, \"error\");\n return;\n }\n if (target.readOnlyReason) {\n this.feedback = {\n text: safeText(`${target.name} is read-only: ${target.readOnlyReason}`),\n kind: \"error\",\n at: Date.now(),\n };\n return;\n }\n if (delivery === \"steer\" && !target.canSteer) {\n this.feedback = {\n text: safeText(`${target.name} does not accept steering messages right now.`),\n kind: \"error\",\n at: Date.now(),\n };\n return;\n }\n if (delivery === \"followUp\" && !target.canFollowUp) {\n this.feedback = {\n text: safeText(`${target.name} does not accept follow-up messages right now.`),\n kind: \"error\",\n at: Date.now(),\n };\n return;\n }\n const queue = this.currentQueue();\n if (!queue) return;\n this.textSelection.clear();\n this.state.queues.sync(target.id, this.options.transcript(target.id, true));\n if (queue.mode === \"extension\" && delivery === \"followUp\" && !isActiveStatus(target.status)) {\n const parked = queue.park(message, delivery);\n if (parked.ok) { this.rememberPrompt(message); this.state.view(target.id).draft = \"\"; editor.setText(\"\"); }\n return;\n }\n // Session-owned pending marker: blocks duplicate submission of the same\n // raw draft for the same target across view close/reopen.\n if (this.state.hasPendingSend(target.id, raw)) return;\n this.rememberPrompt(message);\n const pending: FabricConversationPendingSend = { id: target.id, message: raw, delivery };\n this.state.addPendingSend(pending);\n const epoch = this.state.epoch;\n this.feedback = {\n text: safeText(`Sending ${delivery} \u2192 ${target.name}\u2026`),\n kind: \"info\",\n at: Date.now(),\n };\n void Promise.resolve()\n .then(() => queue.dispatch(message, delivery))\n .then(() => {\n // Same-session acks mutate shared state even if this view was closed;\n // only a session clear (epoch change) invalidates the result.\n if (this.state.epoch !== epoch) return;\n this.state.resolvePendingSend(target.id, raw);\n if (this.disposed) return;\n if (this.currentId === target.id && this.editor === editor && editor.getText() === raw) {\n editor.setText(\"\");\n }\n this.feedback = {\n text: safeText(`Queued ${delivery} \u2192 ${target.name}`),\n kind: \"info\",\n at: Date.now(),\n };\n this.tui.requestRender();\n })\n .catch((error: unknown) => {\n if (this.state.epoch !== epoch) return;\n this.state.failPendingSend(target.id, raw);\n if (this.disposed) return;\n // Keep the raw draft including whitespace and any newer editing; never merge.\n this.feedback = {\n text: safeText(\n `Send failed for ${target.name} (${delivery}): ${errorText(error)}`,\n ),\n kind: \"error\",\n at: Date.now(),\n };\n this.tui.requestRender();\n });\n }\n\n private dispatchStop(target: FabricConversationTarget): void {\n const epoch = this.state.epoch;\n const scope = this.notificationScope;\n const current = (): boolean => !this.disposed && epoch === this.state.epoch &&\n scope === this.notificationScope && this.currentId === target.id;\n this.notifyCommand(`Stopping ${target.name}\u2026`);\n void Promise.resolve()\n .then(() => this.options.stop(target.id))\n .then(() => {\n if (current()) this.notifyCommand(`Stop requested for ${target.name}`);\n })\n .catch((error: unknown) => {\n if (current()) this.notifyCommand(`Stop failed for ${target.name}: ${errorText(error)}`, \"error\");\n });\n }\n\n private navigateParent(): void {\n const target = this.currentTarget();\n if (!target) return;\n const parent = target.parentId ? this.targetById(target.parentId) : undefined;\n if (parent && !isMainTarget(parent)) {\n this.applySelection(parent.id, true);\n return;\n }\n this.options.close();\n }\n\n private navigateFirstChild(): void {\n const target = this.currentTarget();\n if (!target) return;\n const child = this.currentTargets().find((candidate) => candidate.parentId === target.id);\n if (child && !isMainTarget(child)) this.applySelection(child.id, true);\n }\n\n private cycleTarget(direction: 1 | -1): void {\n const targets = this.nonMainTargets();\n if (targets.length === 0) return;\n const index = targets.findIndex((target) => target.id === this.currentId);\n const nextIndex = index < 0\n ? 0\n : (index + direction + targets.length) % targets.length;\n const next = targets[nextIndex];\n if (next) this.applySelection(next.id, true);\n }\n\n private scrollBy(delta: number): void {\n if (!this.currentId || !Number.isFinite(delta) || delta === 0) return;\n if (!this.textSelection.dragging) this.textSelection.clear();\n const entry = this.state.view(this.currentId);\n const maxScroll = Math.max(0, this.lastBodyLength - this.lastBodyBudget);\n const position = entry.following ? maxScroll : entry.scroll;\n // A wheel/key gesture wins over an unpainted command-result reveal.\n if (entry.pageAnchor === \"end\") entry.pageAnchor = undefined;\n // Downward overscroll at the live tail is still follow mode. Paging here\n // can succeed on fresh activity and leave the view pinned between frames,\n // alternating the Working row with the newer-activity notice.\n if (entry.following && delta > 0) return;\n const next = position + Math.trunc(delta);\n entry.following = false;\n if (next < 0 && !this.textSelection.dragging && this.options.loadOlder(this.currentId)) {\n // Native history pages prepend records instead of replacing the tail.\n // Preserve the old viewport anchor, then apply the requested movement.\n entry.pageAnchor = \"prepend\";\n entry.anchorLength = this.lastBody.length;\n entry.scroll = next;\n return;\n }\n if (next > maxScroll && !this.textSelection.dragging && this.options.loadNewer(this.currentId)) {\n entry.scroll = next;\n return;\n }\n entry.scroll = Math.max(0, Math.min(next, maxScroll));\n if (delta > 0 && entry.scroll === maxScroll) entry.following = true;\n }\n\n private scrollPrompt(direction: -1 | 1): void {\n if (!this.currentId) return;\n const entry = this.state.view(this.currentId);\n const position = entry.following ? Math.max(0, this.lastBodyLength - this.lastBodyBudget) : entry.scroll;\n const prompts = this.lastBody.flatMap((line, index) => line.includes(\"\\x1b]133;A\") ? [index] : []);\n const target = direction < 0 ? prompts.filter((row) => row < position).at(-1) : prompts.find((row) => row > position);\n this.scrollBy(target === undefined ? direction * Math.max(1, this.lastBodyBudget) : target - position);\n }\n\n private scrollToTop(): void {\n if (!this.currentId) return;\n this.textSelection.clear();\n const entry = this.state.view(this.currentId);\n entry.following = false;\n entry.scroll = 0;\n if (this.options.loadOlder(this.currentId)) entry.pageAnchor = \"start\";\n }\n\n private followLatest(): void {\n this.textSelection.clear();\n if (!this.currentId) return;\n this.options.loadLatest(this.currentId);\n const entry = this.state.view(this.currentId);\n entry.following = true;\n entry.pageAnchor = undefined;\n entry.anchorLength = undefined;\n }\n\n private openPicker(): void {\n this.clearCommandNotification();\n this.copyVersion++;\n this.textSelection.clear();\n this.stopWorkingIndicator();\n this.mode = \"picker\";\n this.pickerInput = new Input({ prompt: \"search targets: \" });\n this.pickerInput.focused = this.focusState;\n this.pickerInput.onSubmit = () => this.pickSelected();\n if (this.editor) this.editor.focused = false;\n this.pickerSelectedId = this.currentId ?? this.nonMainTargets()[0]?.id;\n this.refreshPicker();\n }\n\n private closePicker(): void {\n this.mode = \"conversation\";\n this.pickerInput = undefined;\n this.pickerRows = [];\n this.pickerKey = \"\";\n this.pickerSelectedId = undefined;\n if (this.editor) this.editor.focused = this.focusState;\n }\n\n private refreshPicker(): void {\n const search = this.pickerInput?.getValue() ?? \"\";\n const key = JSON.stringify([this.targetsKey, search]);\n if (key === this.pickerKey) return;\n this.pickerKey = key;\n const rows: PickerRow[] = [];\n const targets = this.currentTargets();\n const children = new Map<string, FabricConversationTarget[]>();\n for (const target of targets) {\n if (!target.parentId) continue;\n const siblings = children.get(target.parentId) ?? [];\n siblings.push(target);\n children.set(target.parentId, siblings);\n }\n const roots = targets.filter(\n (target) => !target.parentId || !this.targetsById.has(target.parentId),\n );\n roots.sort((left, right) =>\n Number(isMainTarget(right)) - Number(isMainTarget(left)),\n );\n const visited = new Set<string>();\n const pushTree = (target: FabricConversationTarget, depth: number): void => {\n if (visited.has(target.id)) return;\n visited.add(target.id);\n rows.push({ target, depth });\n for (const child of children.get(target.id) ?? []) pushTree(child, depth + 1);\n };\n for (const root of roots) pushTree(root, 0);\n for (const orphan of targets) {\n if (!visited.has(orphan.id)) rows.push({ target: orphan, depth: 0 });\n }\n const filtered = search.trim()\n ? fuzzyFilter(rows, search, (row) => `${row.target.kind} ${row.target.name} ${row.target.id}`)\n : rows;\n this.pickerRows = filtered;\n // Selection identity is the target id, stable across roster updates.\n if (!filtered.some((row) => row.target.id === this.pickerSelectedId)) {\n this.pickerSelectedId = filtered[0]?.target.id;\n }\n }\n\n private pickerSelectedIndex(): number {\n const index = this.pickerRows.findIndex((row) => row.target.id === this.pickerSelectedId);\n return index >= 0 ? index : 0;\n }\n\n private movePickerSelection(direction: 1 | -1): void {\n if (this.pickerRows.length === 0) return;\n const index = this.pickerSelectedIndex();\n const next = (index + direction + this.pickerRows.length) % this.pickerRows.length;\n this.pickerSelectedId = this.pickerRows[next]?.target.id;\n }\n\n private pickSelected(): void {\n const row = this.pickerRows.find((candidate) => candidate.target.id === this.pickerSelectedId) ??\n this.pickerRows[0];\n if (!row) {\n this.closePicker();\n return;\n }\n if (isMainTarget(row.target)) {\n this.options.close();\n return;\n }\n this.applySelection(row.target.id, true);\n }\n\n private handlePickerInput(data: string): void {\n const input = this.pickerInput;\n if (!input) {\n this.closePicker();\n return;\n }\n if (matchesKey(data, Key.escape)) {\n this.closePicker();\n return;\n }\n if (matchesKey(data, Key.up)) {\n this.movePickerSelection(-1);\n return;\n }\n if (matchesKey(data, Key.down)) {\n this.movePickerSelection(1);\n return;\n }\n if (matchesKey(data, Key.enter)) {\n this.pickSelected();\n return;\n }\n input.handleInput(data);\n this.refreshPicker();\n }\n\n private isUnread(target: FabricConversationTarget): boolean {\n if (target.updatedAt === undefined || target.id === this.currentId) return false;\n // peek() only: listing targets must never create or evict drafts.\n const seen = this.state.peek(target.id)?.lastSeenUpdatedAt ?? 0;\n return target.updatedAt > seen;\n }\n\n private breadcrumbLine(width: number): string {\n const chain: FabricConversationTarget[] = [];\n let cursor = this.currentTarget();\n const guard = new Set<string>();\n while (cursor && !guard.has(cursor.id)) {\n guard.add(cursor.id);\n chain.unshift(cursor);\n cursor = cursor.parentId ? this.targetById(cursor.parentId) : undefined;\n }\n if (chain.length === 0) {\n const main = this.mainTarget();\n if (main) chain.push(main);\n }\n if (chain.length === 0) return truncateToWidth(this.theme.fg(\"dim\", \"Fabric\"), width, \"\");\n const last = chain[chain.length - 1];\n const parts = chain.map((target, index) => {\n const isCurrent = target.id === this.currentId;\n const name = isMainTarget(target) ? \"Main\" : safeText(target.name) || target.id;\n const styled = isCurrent\n ? this.theme.fg(\"accent\", name)\n : this.theme.fg(\"muted\", name);\n return last && index === chain.length - 1 && this.isUnread(last)\n ? `${styled} \u25CF`\n : styled;\n });\n return truncateToWidth(parts.join(this.theme.fg(\"dim\", \" > \")), width, \"\");\n }\n\n private currentFeedbackLine(width: number): string | undefined {\n if (this.mode === \"picker\") return undefined;\n if (!this.feedback) return undefined;\n if (Date.now() - this.feedback.at > FEEDBACK_TTL_MS) return undefined;\n const color = this.feedback.kind === \"error\" ? \"error\" : \"accent\";\n return truncateToWidth(this.theme.fg(color, this.feedback.text), width, \"\");\n }\n\n private hintsLine(width: number): string {\n const followUpKeys = this.bindingHint(\"app.message.followUp\", \"alt+enter\");\n const toolsKeys = this.bindingHint(\"app.tools.expand\", \"ctrl+o\");\n const hints = this.stopConfirmId !== undefined\n ? [this.theme.fg(\"warning\", safeText(\"enter confirms stop \u00B7 esc cancels\"))]\n : [\n this.theme.fg(\"dim\", \"enter\"),\n \"steer\",\n this.theme.fg(\"dim\", followUpKeys),\n \"follow-up\",\n this.theme.fg(\"dim\", \"ctrl+n\"),\n \"targets\",\n this.theme.fg(\"dim\", \"pgup/pgdn\"),\n \"scroll \u00B7 drag select \u00B7 /help\",\n this.theme.fg(\"dim\", \"esc\"),\n \"close\",\n ];\n const full = [...hints, this.theme.fg(\"dim\", toolsKeys), \"tools\"].join(\" \");\n return truncateToWidth(full, width, \"\");\n }\n\n private renderEditorLines(innerWidth: number): string[] {\n const editor = this.editor;\n if (!editor) return [];\n return editor.render(innerWidth);\n }\n\n private currentQueue(): ConversationQueue | undefined {\n const target = this.currentTarget();\n if (!target || target.kind === \"main\" || !this.editor || this.disposed) return undefined;\n return this.state.queues.attach({\n targetId: target.id, targetName: target.name,\n piEvents: this.options.queueEvents ?? { emit() {} }, theme: this.theme,\n send: (message, delivery) => {\n if (message.trimStart().startsWith(\"/\") || message.trimStart().startsWith(\"!\")) {\n return Promise.reject(new Error(\"Commands cannot be sent from queued edits; use the preview composer.\"));\n }\n return this.options.send(target.id, message, delivery);\n },\n editor: {\n getText: () => this.editor?.getText() ?? \"\",\n setText: (text) => this.setQueueEditorText(text),\n handleInput: (data) => this.editor?.handleInput(data),\n render: (width) => this.editor?.render(width) ?? [],\n paddingX: this.options.appearance?.editorPaddingX ?? 0,\n },\n ...(this.options.keybindings ? { keybindings: this.options.keybindings } : {}),\n isIdle: () => !isActiveStatus(this.targetById(target.id)?.status ?? \"stopped\"),\n onNotify: (text, kind) => {\n if (kind === \"error\" && !this.disposed && this.currentId === target.id) this.feedback = { text: safeText(text), kind, at: Date.now() };\n },\n requestRender: () => { if (!this.disposed && this.currentId === target.id) this.tui.requestRender(); },\n });\n }\n\n private transcriptLines(innerWidth: number): string[] {\n const target = this.currentTarget();\n if (!target || !this.currentId) return [this.theme.fg(\"dim\", \"No target selected.\")];\n const entry = this.state.view(this.currentId);\n const transcript = this.observedTranscript ?? this.options.transcript(this.currentId, entry.following);\n return this.renderer.render(transcript, innerWidth, {\n target,\n toolsExpanded: entry.toolsExpanded,\n hideThinking: entry.hideThinking ?? this.options.appearance?.hideThinkingBlock ?? false,\n showImages: this.options.appearance?.showImages ?? true,\n outputPad: this.options.appearance?.outputPad ?? 1,\n ...(this.options.appearance?.codeBlockIndent !== undefined ? { codeBlockIndent: this.options.appearance.codeBlockIndent } : {}),\n codePreviewSettings: this.options.codePreviewSettings,\n });\n }\n\n private transcriptTail(width: number, budget: number): string[] {\n if (this.commandNotification && this.commandNotification.epoch !== this.state.epoch) this.clearCommandNotification();\n const notification = this.commandNotification;\n if (this.observedTranscript?.hasNewer && !notification) return [];\n // These rows belong to the end of history, never to the fixed input dock.\n const tail = notification ? [\"\", ...notification.component.render(width)] : [];\n // Reserve wrapped success geometry too, including after a resize.\n if (notification?.pendingResult) {\n const reserved = 1 + notification.pendingResult.render(width).length;\n while (tail.length < reserved) tail.push(\"\");\n }\n if (!this.observedTranscript?.hasNewer) tail.push(...this.working?.render(width) ?? []);\n if (budget > 1) tail.push(\"\");\n return tail;\n }\n\n private windowBody(body: string[], budget: number, tail: string[]): string[] {\n this.lastBodyLength = body.length + tail.length;\n this.lastBody = body;\n this.lastBodyBudget = budget;\n const entry = this.currentId ? this.state.view(this.currentId) : undefined;\n const maxScroll = Math.max(0, this.lastBodyLength - budget);\n if (entry) {\n if (entry.following) {\n entry.scroll = maxScroll;\n } else if (entry.pageAnchor) {\n entry.scroll = entry.pageAnchor === \"prepend\"\n ? entry.scroll + Math.max(0, body.length - (entry.anchorLength ?? body.length))\n : entry.pageAnchor === \"end\" ? maxScroll : 0;\n entry.pageAnchor = undefined;\n entry.anchorLength = undefined;\n }\n entry.scroll = Math.max(0, Math.min(entry.scroll, maxScroll));\n }\n // Slice the virtual body + tail without copying retained history per frame.\n const start = entry?.scroll ?? 0;\n const end = start + budget;\n const lines = body.slice(start, end);\n if (end > body.length) lines.push(...tail.slice(Math.max(0, start - body.length), end - body.length));\n return lines;\n }\n\n private pickerLines(innerWidth: number, budget: number): string[] {\n // Independent viewport: the picker never reads or writes the selected\n // target's transcript scroll/follow state.\n this.refreshPicker();\n const lines = [this.theme.fg(\"accent\", \"Targets \u00B7 enter select \u00B7 esc cancel\")];\n const input = this.pickerInput;\n if (input) {\n for (const line of input.render(innerWidth)) lines.push(line);\n }\n const rows = this.pickerRows;\n const selectedIndex = this.pickerSelectedIndex();\n const listBudget = Math.max(1, budget - lines.length - 1);\n const startIndex = Math.max(\n 0,\n Math.min(selectedIndex - Math.floor(listBudget / 2), rows.length - listBudget),\n );\n const endIndex = Math.min(startIndex + listBudget, rows.length);\n if (rows.length === 0) lines.push(this.theme.fg(\"muted\", \" no matching targets\"));\n for (let i = startIndex; i < endIndex; i++) {\n const row = rows[i];\n if (!row) continue;\n const selected = row.target.id === this.pickerSelectedId;\n const indent = \" \".repeat(row.depth + 1);\n const marker = selected ? this.theme.fg(\"accent\", \"\u2192 \") : \" \";\n const unread = this.isUnread(row.target) ? this.theme.fg(\"accent\", \" \u25CF\") : \"\";\n const label = isMainTarget(row.target)\n ? \"Main (native session)\"\n : `${safeText(row.target.name)} ${this.theme.fg(\"muted\", `(${row.target.kind} \u00B7 ${row.target.status})`)}`;\n lines.push(\n truncateToWidth(\n `${indent}${marker}${selected ? this.theme.fg(\"accent\", label) : label}${unread}`,\n innerWidth,\n \"\",\n ),\n );\n }\n if (rows.length > listBudget) {\n lines.push(this.theme.fg(\"muted\", ` (${selectedIndex + 1}/${rows.length})`));\n }\n return lines.slice(0, budget);\n }\n}\n", "import {\n AssistantMessageComponent,\n BashExecutionComponent,\n BranchSummaryMessageComponent,\n CompactionSummaryMessageComponent,\n CustomMessageComponent,\n parseSkillBlock,\n SkillInvocationMessageComponent,\n ToolExecutionComponent,\n UserMessageComponent,\n type MarkdownTransformer,\n type MessageRenderer,\n type Theme,\n type TruncationResult,\n} from \"@earendil-works/pi-coding-agent\";\nimport type { MarkdownTheme, TUI } from \"@earendil-works/pi-tui\";\nimport { wrapTextWithAnsi } from \"@earendil-works/pi-tui\";\nimport type { CodePreviewSettings } from \"./code-preview.js\";\nimport { highlightCode } from \"./highlight.js\";\nimport { terminalSafe } from \"./transcript-sanitization.js\";\nimport type { FabricConversationTarget } from \"./conversation.js\";\nimport { unwrapActorEnvelopeText } from \"./conversation-transcript.js\";\nimport type {\n NativeAgentMessage,\n NativeConversationTranscript,\n NativeToolExecution,\n} from \"./conversation-native-reader.js\";\n\nexport type {\n NativeAgentMessage,\n NativeConversationTranscript,\n NativeToolExecution,\n} from \"./conversation-native-reader.js\";\n\ntype UserAgentMessage = Extract<NativeAgentMessage, { role: \"user\" }>;\ntype ToolResultAgentMessage = Extract<NativeAgentMessage, { role: \"toolResult\" }>;\ntype BashExecutionAgentMessage = Extract<NativeAgentMessage, { role: \"bashExecution\" }>;\ntype CustomAgentMessage = Extract<NativeAgentMessage, { role: \"custom\" }>;\ntype CompactionSummaryAgentMessage = Extract<NativeAgentMessage, { role: \"compactionSummary\" }>;\ntype BranchSummaryAgentMessage = Extract<NativeAgentMessage, { role: \"branchSummary\" }>;\n\n/** Exactly what ToolExecutionComponent accepts as its tool definition. */\nexport type FabricToolDefinitionLike = ConstructorParameters<typeof ToolExecutionComponent>[4];\nexport type FabricGetToolDefinition = (toolName: string) => FabricToolDefinitionLike;\n\nexport interface FabricConversationTranscriptRendererOptions {\n /**\n * Registered tool definitions (Main wires the actual fabricTool and\n * capturedTools.get(name).definition). Undefined falls back to the native\n * generic tool card, exactly like interactive-mode getRegisteredToolDefinition.\n */\n getToolDefinition?: FabricGetToolDefinition | undefined;\n /** Extension message renderers (capturedTools.runner.getMessageRenderer). */\n getMessageRenderer?: ((customType: string) => MessageRenderer | undefined) | undefined;\n /** Native markdown transformers (capturedTools.runner.getMarkdownTransformers). */\n markdownTransformers?: readonly MarkdownTransformer[] | undefined;\n hiddenThinkingLabel?: string | undefined;\n imageWidthCells?: number | undefined;\n}\n\nexport interface FabricConversationTranscriptRenderOptions {\n target: FabricConversationTarget;\n toolsExpanded: boolean;\n outputPad?: 0 | 1;\n codeBlockIndent?: string;\n codePreviewSettings?: CodePreviewSettings | undefined;\n hideThinking?: boolean;\n showImages?: boolean;\n}\n\ntype NativeToolResultContent = { type: string; text?: string; data?: string; mimeType?: string };\n\nconst DEFAULT_IMAGE_WIDTH_CELLS = 60;\n\nconst stableKey = (value: unknown): string => {\n if (value === undefined) return \"undefined\";\n try {\n return JSON.stringify(value) ?? \"undefined\";\n } catch {\n return `unserializable:${String(value)}`;\n }\n};\n\ninterface RenderedRow {\n render: (width: number) => string[];\n lines?: string[] | undefined;\n spacer: boolean;\n dynamic: boolean;\n partial?: boolean;\n input?: readonly unknown[];\n}\n\ninterface ToolCacheRecord {\n component: ToolExecutionComponent;\n name: string;\n dynamicRenderer: boolean;\n started: boolean;\n argsComplete: boolean;\n args: unknown;\n argsKey: string;\n result: unknown;\n resultKey: string | undefined;\n partialKey: string | undefined;\n imageKey: string;\n isPartial: boolean;\n isError: boolean;\n error: string | undefined;\n}\n\ninterface MessageCacheRecord {\n component: BashExecutionComponent | CustomMessageComponent | CompactionSummaryMessageComponent\n | BranchSummaryMessageComponent | SkillInvocationMessageComponent;\n}\n\ninterface AssistantCacheRecord {\n hideThinking: boolean;\n message?: NativeAgentMessage;\n streaming?: boolean;\n component: AssistantMessageComponent;\n}\n\n/**\n * Renders a conversation-native transcript with the exact registered Pi\n * components (UserMessageComponent, AssistantMessageComponent,\n * ToolExecutionComponent, BashExecutionComponent, compaction/branch/custom\n * summaries), dispatched the way interactive-mode addMessageToChat and\n * renderSessionItems do. Native component rows are preserved verbatim \u2014 no\n * dashboard normalization, no per-line re-truncation, no extra background or\n * glyph decoration \u2014 so full-width backgrounds and native spacing survive.\n */\nexport class FabricConversationTranscriptRenderer {\n private readonly toolComponents = new Map<string, ToolCacheRecord>();\n private readonly messageComponents = new Map<string, MessageCacheRecord>();\n private readonly assistantComponents = new Map<string, AssistantCacheRecord>();\n private readonly markdownThemeCache = new Map<string, MarkdownTheme>();\n private readonly highlightInvalidate: () => void;\n private disposed = false;\n private currentTargetId = \"\";\n private readonly rendererStates = new Map<string, Set<Record<string, unknown>>>();\n private readonly liveStates = new WeakSet<object>();\n private readonly messageRows = new Map<NativeAgentMessage, RenderedRow>();\n private readonly toolRows = new Map<string, RenderedRow>();\n private readonly toolTokens = new Map<string, object>();\n private readonly messageIds = new WeakMap<NativeAgentMessage, number>();\n private nextMessageId = 0;\n private rows: RenderedRow[] = [];\n private lastMessages: NativeAgentMessage[] = [];\n private lastTools: NativeToolExecution[] = [];\n private lastPartial: NativeConversationTranscript[\"streaming\"][\"partialAssistant\"];\n private lastVersion: number | undefined;\n private sourceKey = \"\";\n private optionsKey = \"\";\n private lastRendererHooks: unknown[] = [];\n private lastWidth = 0;\n private frameLines: string[] | undefined;\n private frameFlags = \"\";\n private planDirty = true;\n\n constructor(\n private readonly tui: TUI,\n private readonly theme: Theme,\n private readonly rendererOptions: FabricConversationTranscriptRendererOptions = {},\n ) {\n this.highlightInvalidate = (): void => {\n if (this.disposed) return;\n this.invalidate();\n this.tui.requestRender();\n };\n }\n\n /** Drop cached components; stray renderer timers/invalidations become no-ops. */\n invalidate(): void {\n this.toolTokens.clear();\n for (const key of this.rendererStates.keys()) this.releaseRendererStates(key);\n this.toolComponents.clear();\n this.messageComponents.clear();\n this.assistantComponents.clear();\n this.markdownThemeCache.clear();\n this.messageRows.clear();\n this.toolRows.clear();\n this.rows = [];\n this.lastMessages = [];\n this.lastTools = [];\n this.lastPartial = undefined;\n this.frameLines = undefined;\n this.planDirty = true;\n }\n\n /** Finalize: live spinner/timing intervals may still fire once; guarded. */\n dispose(): void {\n this.disposed = true;\n this.invalidate();\n }\n\n render(\n transcript: NativeConversationTranscript,\n width: number,\n options: FabricConversationTranscriptRenderOptions,\n ): string[] {\n if (this.disposed || width <= 0) return [];\n width = Math.max(1, width);\n // Revisions are reader-local, and a participant can roll to a new activation.\n const sourceKey = stableKey([options.target.id, options.target.cwd ?? process.cwd(), transcript.sourceId,\n transcript.sessionId, transcript.sessionFile, transcript.eventsFile]);\n const optionsKey = stableKey([options.toolsExpanded, options.outputPad, options.codeBlockIndent,\n options.hideThinking, options.showImages, options.codePreviewSettings,\n this.rendererOptions.hiddenThinkingLabel, this.rendererOptions.imageWidthCells]);\n const hooks = [this.rendererOptions.getToolDefinition, this.rendererOptions.getMessageRenderer,\n ...(this.rendererOptions.markdownTransformers ?? [])];\n if (sourceKey !== this.sourceKey || optionsKey !== this.optionsKey || !sameItems(hooks, this.lastRendererHooks)) {\n this.invalidate();\n this.sourceKey = sourceKey;\n this.optionsKey = optionsKey;\n this.lastRendererHooks = hooks;\n }\n this.currentTargetId = options.target.id;\n const version = (transcript as NativeConversationTranscript & { contentVersion?: number }).contentVersion\n ?? transcript.revision;\n const streaming = transcript.streaming;\n // Compare identities, not content keys: fixtures may replace a message without\n // bumping revision, while reader metadata can change without replacing content.\n if (this.planDirty || version !== this.lastVersion ||\n !sameItems(transcript.messages, this.lastMessages) ||\n !sameItems(streaming.tools, this.lastTools) || streaming.partialAssistant !== this.lastPartial) {\n this.reconcileRows(transcript, options);\n this.lastVersion = version;\n }\n if (width !== this.lastWidth) {\n this.lastWidth = width;\n for (const row of this.rows) row.lines = undefined;\n this.frameLines = undefined;\n }\n for (const row of this.rows) {\n if (row.lines && !row.dynamic) continue;\n row.lines = row.render(width);\n this.frameLines = undefined;\n }\n const flags = `${transcript.hasMore}:${transcript.hasNewer}`;\n if (!this.frameLines || flags !== this.frameFlags) {\n const lines: string[] = [];\n if (!transcript.messages.length && !streaming.partialAssistant && !streaming.tools.length) {\n lines.push(this.theme.fg(\"dim\", \"No retained transcript yet; new agent activity will appear here.\"));\n } else {\n if (transcript.hasMore) {\n lines.push(this.theme.fg(\"dim\", \"\u2191 older activity available \u00B7 ctrl+\u2191 past the top to load\"));\n }\n for (const row of this.rows) {\n if (!row.lines?.length) continue;\n if (row.spacer && lines.length) lines.push(\"\");\n for (const line of row.lines) lines.push(line);\n }\n if (transcript.hasNewer) {\n lines.push(this.theme.fg(\"dim\", \"\u2193 newer activity available \u00B7 ctrl+\u2193 past the bottom to load\"));\n }\n }\n this.frameLines = lines;\n this.frameFlags = flags;\n }\n // The public result is mutable; callers must not be able to corrupt cached rows.\n return this.frameLines.slice();\n }\n\n private reconcileRows(\n transcript: NativeConversationTranscript,\n options: FabricConversationTranscriptRenderOptions,\n ): void {\n const rows: RenderedRow[] = [];\n const messages = new Set<NativeAgentMessage>();\n const keys = new Set<string>();\n const tools = new Set<string>();\n const results = new Map<string, ToolResultAgentMessage>();\n const streaming = new Map(transcript.streaming.tools.map((tool) => [tool.toolCallId, tool]));\n for (const message of transcript.messages) {\n if (message.role === \"toolResult\") results.set(message.toolCallId, message);\n }\n const addTool = (id: string, name: string, args: Record<string, unknown> | undefined, error?: string): void => {\n if (tools.has(id)) return;\n tools.add(id);\n rows.push(this.reconcileTool(id, name, args, results.get(id), streaming.get(id), error, options));\n };\n const addMessage = (message: NativeAgentMessage, partial = false): void => {\n if (message.role === \"toolResult\") return;\n messages.add(message);\n const key = partial ? \":streaming\" : this.messageKey(message);\n keys.add(key);\n let row = this.messageRows.get(message);\n const input = shallowInput(message);\n if (!row || row.partial !== partial || !sameItems(row.input ?? [], input)) {\n if (row) {\n this.assistantComponents.delete(key);\n this.messageComponents.delete(key);\n }\n row = {\n input,\n partial,\n spacer: message.role !== \"assistant\",\n // A custom component can read time or external state in render(width).\n dynamic: message.role === \"custom\" && message.display,\n render: (width) => {\n const lines: string[] = [];\n if (partial && message.role === \"assistant\") {\n this.renderAssistantContent(message, key, true, width, options, lines);\n } else {\n this.renderMessage(message, width, options, lines);\n }\n return lines;\n },\n };\n this.messageRows.set(message, row);\n }\n rows.push(row);\n if (message.role === \"assistant\") {\n const error = message.stopReason === \"error\" || message.stopReason === \"aborted\"\n ? message.errorMessage || \"Error\" : undefined;\n for (const call of message.content) {\n if (call.type === \"toolCall\") addTool(call.id, call.name, call.arguments, error);\n }\n }\n };\n for (const message of transcript.messages) addMessage(message);\n if (transcript.streaming.partialAssistant) addMessage(transcript.streaming.partialAssistant, true);\n for (const tool of transcript.streaming.tools) addTool(tool.toolCallId, tool.toolName, tool.args);\n // Retain the loaded window, not an undersized FIFO that thrashes on each scan.\n for (const message of this.messageRows.keys()) if (!messages.has(message)) this.messageRows.delete(message);\n for (const cache of [this.messageComponents, this.assistantComponents]) {\n for (const key of cache.keys()) if (!keys.has(key)) cache.delete(key);\n }\n for (const key of this.toolComponents.keys()) {\n const id = key.slice(this.currentTargetId.length + 1);\n if (!tools.has(id)) this.releaseTool(key);\n }\n this.rows = rows;\n this.lastMessages = transcript.messages.slice();\n this.lastTools = transcript.streaming.tools.slice();\n this.lastPartial = transcript.streaming.partialAssistant;\n this.planDirty = false;\n this.frameLines = undefined;\n }\n\n private messageKey(message: NativeAgentMessage): string {\n let id = this.messageIds.get(message);\n if (id === undefined) { id = ++this.nextMessageId; this.messageIds.set(message, id); }\n return `${this.currentTargetId}\\u0000${id}`;\n }\n\n private markdownTheme(options: FabricConversationTranscriptRenderOptions): MarkdownTheme {\n const key = options.codeBlockIndent ?? \"\";\n let markdownTheme = this.markdownThemeCache.get(key);\n if (!markdownTheme) {\n markdownTheme = {\n ...(options.codeBlockIndent !== undefined ? { codeBlockIndent: options.codeBlockIndent } : {}),\n heading: (text) => this.theme.fg(\"mdHeading\", text),\n link: (text) => this.theme.fg(\"mdLink\", text),\n linkUrl: (text) => this.theme.fg(\"mdLinkUrl\", text),\n code: (text) => this.theme.fg(\"mdCode\", text),\n codeBlock: (text) => this.theme.fg(\"mdCodeBlock\", text),\n codeBlockBorder: (text) => this.theme.fg(\"mdCodeBlockBorder\", text),\n quote: (text) => this.theme.fg(\"mdQuote\", text),\n quoteBorder: (text) => this.theme.fg(\"mdQuoteBorder\", text),\n hr: (text) => this.theme.fg(\"mdHr\", text),\n listBullet: (text) => this.theme.fg(\"mdListBullet\", text),\n bold: (text) => this.theme.bold(text),\n italic: (text) => this.theme.italic(text),\n underline: (text) => this.theme.underline(text),\n strikethrough: (text) => this.theme.strikethrough(text),\n highlightCode: (code, lang) =>\n highlightCode(code, lang ?? \"\", this.highlightInvalidate) ??\n code.split(\"\\n\").map((line) => this.theme.fg(\"mdCodeBlock\", line)),\n };\n this.markdownThemeCache.set(key, markdownTheme);\n }\n return markdownTheme;\n }\n\n private renderMessage(\n message: NativeAgentMessage,\n width: number,\n options: FabricConversationTranscriptRenderOptions,\n lines: string[],\n ): void {\n switch (message.role) {\n case \"user\":\n this.renderUserMessage(message, width, options, lines);\n return;\n case \"assistant\":\n this.renderAssistantContent(message, this.messageKey(message), false, width, options, lines);\n return;\n case \"toolResult\":\n return;\n case \"bashExecution\":\n this.pushSpacer(lines);\n this.renderBashExecution(message, width, options, lines);\n return;\n case \"custom\":\n if (!message.display) return;\n this.pushSpacer(lines);\n this.renderCustomMessage(message, width, options, lines);\n return;\n case \"compactionSummary\":\n this.pushSpacer(lines);\n this.renderBoxedMessage(this.messageKey(message), message, CompactionSummaryMessageComponent, width, options, lines);\n return;\n case \"branchSummary\":\n this.pushSpacer(lines);\n this.renderBoxedMessage(this.messageKey(message), message, BranchSummaryMessageComponent, width, options, lines);\n return;\n default:\n return;\n }\n }\n\n private renderUserMessage(\n message: UserAgentMessage,\n width: number,\n options: FabricConversationTranscriptRenderOptions,\n lines: string[],\n ): void {\n const text = userMessageText(message);\n if (!text) return;\n this.pushSpacer(lines);\n const skillBlock = parseSkillBlock(text);\n if (skillBlock) {\n const record = this.messageRecord(this.messageKey(message), () =>\n new SkillInvocationMessageComponent(skillBlock, this.markdownTheme(options)));\n record.component.setExpanded(options.toolsExpanded);\n lines.push(...safeRender(record.component, width, () => this.plainTextFallback(text, width)));\n if (skillBlock.userMessage) {\n this.pushSpacer(lines);\n lines.push(...this.userComponentLines(skillBlock.userMessage, width, options));\n }\n return;\n }\n lines.push(...this.userComponentLines(text, width, options));\n }\n\n private userComponentLines(\n text: string,\n width: number,\n options: FabricConversationTranscriptRenderOptions,\n ): string[] {\n const component = new UserMessageComponent(\n terminalSafe(text, false),\n this.markdownTheme(options),\n options.outputPad ?? 1,\n this.rendererOptions.markdownTransformers,\n );\n return safeRender(component, width, () => this.plainTextFallback(text, width));\n }\n\n private renderAssistantContent(\n message: Extract<NativeAgentMessage, { role: \"assistant\" }>,\n key: string,\n streaming: boolean,\n width: number,\n options: FabricConversationTranscriptRenderOptions,\n lines: string[],\n ): void {\n const record = this.assistantRecord(key, options);\n if (record.message !== message || record.streaming !== streaming) {\n record.component.updateContent(message, streaming);\n record.message = message;\n record.streaming = streaming;\n }\n lines.push(...safeRender(record.component, width, () => this.plainTextFallback(assistantText(message), width)));\n }\n\n private reconcileTool(\n id: string,\n name: string,\n callArgs: Record<string, unknown> | undefined,\n result: ToolResultAgentMessage | undefined,\n tool: NativeToolExecution | undefined,\n error: string | undefined,\n options: FabricConversationTranscriptRenderOptions,\n ): RenderedRow {\n const key = `${this.currentTargetId}\\u0000${id}`;\n const args = tool?.args ?? callArgs;\n const value = result ?? tool?.result ?? tool?.partial;\n const isPartial = !result && !tool?.result && !error;\n const isError = result?.isError ?? tool?.isError ?? !!error;\n const started = tool ? tool.executionStarted ?? true : false;\n const argsComplete = !!result || !!tool?.result || !!tool?.argsComplete;\n let record = this.toolComponents.get(key);\n // Native converted-image caches are indexed by position, not image identity.\n const images = record?.result === value ? undefined : value?.content?.filter(\n (block): block is NativeToolResultContent => !!block && typeof block === \"object\" &&\n (block as NativeToolResultContent).type === \"image\",\n );\n const imageKey = record && record.result === value ? record.imageKey : stableKey(images?.length ? images : undefined);\n if (record && (record.name !== name || record.imageKey !== imageKey ||\n (!record.isPartial && isPartial) || (record.argsComplete && !argsComplete) ||\n (record.started && !started && !result))) {\n this.releaseTool(key);\n record = undefined;\n }\n let row = this.toolRows.get(key);\n if (!record) {\n const token = {};\n this.toolTokens.set(key, token);\n const definition = this.definitionFor(name, key, token);\n // Pi's live TUI proxy forwards inherited assignments to the real host.\n // Define an own callback so delegation cannot overwrite requestRender.\n const ui = Object.create(this.tui, {\n requestRender: {\n configurable: true, enumerable: true, writable: true,\n value: (): void => {\n if (this.disposed || this.toolTokens.get(key) !== token) return;\n const current = this.toolRows.get(key);\n if (current) current.lines = undefined;\n this.frameLines = undefined;\n this.tui.requestRender();\n },\n },\n }) as TUI;\n const component = new ToolExecutionComponent(name, id, args,\n { showImages: options.showImages ?? true, imageWidthCells: this.imageWidthCells() },\n definition, ui, options.target.cwd ?? process.cwd());\n if (options.toolsExpanded) component.setExpanded(true);\n record = { component, name, dynamicRenderer: !!definition?.renderCall || !!definition?.renderResult, started: false, argsComplete: false, args, argsKey: \"0\",\n result: undefined, resultKey: undefined, partialKey: undefined, imageKey,\n isPartial: true, isError: false, error: undefined };\n this.toolComponents.set(key, record);\n row = {\n spacer: false,\n dynamic: !!definition?.renderCall || !!definition?.renderResult || isPartial || imageKey !== \"undefined\",\n render: (width) => safeRender(component, width, () => this.plainTextFallback(name, width)),\n };\n this.toolRows.set(key, row);\n }\n const { component } = record;\n let changed = false;\n if (record.args !== args) {\n component.updateArgs(args);\n changed = true;\n record.args = args;\n record.argsKey = String(Number(record.argsKey) + 1);\n }\n if (started && !record.started) {\n record.started = true;\n component.markExecutionStarted();\n changed = true;\n }\n if (argsComplete && !record.argsComplete) {\n record.argsComplete = true;\n component.setArgsComplete();\n changed = true;\n }\n if (record.result !== value || record.isPartial !== isPartial || record.isError !== isError || record.error !== error) {\n // Details can contain opaque extension state; serialization is not an equality test.\n const resultKey = String(Number(record.resultKey ?? 0) + 1);\n if (value !== undefined || error !== undefined) {\n component.updateResult({\n content: error && !value ? [{ type: \"text\", text: error }] : (value?.content ?? []) as NativeToolResultContent[],\n ...(value?.details !== undefined ? { details: value.details } : {}),\n isError,\n }, isPartial);\n changed = true;\n }\n record.result = value;\n record.resultKey = resultKey;\n record.partialKey = isPartial ? resultKey : undefined;\n record.isPartial = isPartial;\n record.isError = isError;\n record.error = error;\n }\n row!.dynamic = record.dynamicRenderer || isPartial || imageKey !== \"undefined\";\n if (changed) row!.lines = undefined;\n return row!;\n }\n\n private releaseTool(key: string): void {\n this.toolTokens.delete(key);\n this.releaseRendererStates(key);\n this.toolComponents.delete(key);\n this.toolRows.delete(key);\n }\n\n private renderBashExecution(\n message: BashExecutionAgentMessage,\n width: number,\n options: FabricConversationTranscriptRenderOptions,\n lines: string[],\n ): void {\n const key = this.messageKey(message);\n const record = this.messageRecord(key, () => {\n const component = new BashExecutionComponent(message.command, this.tui, message.excludeFromContext);\n component.appendOutput(terminalSafe(message.output ?? \"\", false));\n // Mirrors interactive-mode: only the truncated flag is known at this point.\n const truncation = message.truncated ? ({ truncated: true } as TruncationResult) : undefined;\n component.setComplete(message.exitCode, message.cancelled, truncation, message.fullOutputPath);\n return component;\n });\n record.component.setExpanded(options.toolsExpanded);\n lines.push(...safeRender(record.component, width, () => this.plainTextFallback(message.command, width)));\n }\n\n private renderCustomMessage(\n message: CustomAgentMessage,\n width: number,\n options: FabricConversationTranscriptRenderOptions,\n lines: string[],\n ): void {\n const record = this.messageRecord(this.messageKey(message), () =>\n new CustomMessageComponent(\n message,\n this.rendererOptions.getMessageRenderer?.(message.customType),\n this.markdownTheme(options),\n options.outputPad ?? 1,\n ));\n record.component.setExpanded(options.toolsExpanded);\n lines.push(...safeRender(record.component, width, () => this.plainTextFallback(customText(message), width)));\n }\n\n private renderBoxedMessage<M extends CompactionSummaryAgentMessage | BranchSummaryAgentMessage>(\n key: string,\n message: M,\n create: new (message: M, markdownTheme?: MarkdownTheme) => MessageCacheRecord[\"component\"],\n width: number,\n options: FabricConversationTranscriptRenderOptions,\n lines: string[],\n ): void {\n const record = this.messageRecord(key, () => new create(message, this.markdownTheme(options)));\n record.component.setExpanded(options.toolsExpanded);\n lines.push(...safeRender(record.component, width, () => this.plainTextFallback(message.summary, width)));\n }\n\n /**\n * Registered definition with wrapped renderer callbacks: the render context\n * invalidate becomes a no-op once disposed, so a live spinner/timing timer\n * firing after dispose cannot touch the TUI. ToolExecutionComponent has no\n * dispose; this finalizes its renderer subscriptions instead.\n */\n private definitionFor(toolName: string, key: string, token: object): FabricToolDefinitionLike {\n const definition = this.rendererOptions.getToolDefinition?.(toolName);\n if (!definition) return definition;\n const live = (): boolean => !this.disposed && this.toolTokens.get(key) === token;\n const guard = <T extends { invalidate: () => void; state: Record<string, unknown> }>(context: T): T => {\n const states = this.rendererStates.get(key) ?? new Set<Record<string, unknown>>();\n states.add(context.state);\n this.rendererStates.set(key, states);\n this.liveStates.add(context.state);\n return {\n ...context,\n invalidate: (): void => {\n if (!live() || !this.liveStates.has(context.state)) return;\n context.invalidate();\n },\n };\n };\n // An old native image conversion can call updateDisplay after eviction.\n const empty = { render: () => [], invalidate: () => {} };\n return {\n ...definition,\n ...(definition.renderCall\n ? { renderCall: (args: any, theme: Theme, context: any) =>\n live() ? definition.renderCall!(args, theme, guard(context)) : empty }\n : {}),\n ...(definition.renderResult\n ? { renderResult: (result: any, options: any, theme: Theme, context: any) =>\n live() ? definition.renderResult!(result, options, theme, guard(context)) : empty }\n : {}),\n };\n }\n\n private assistantRecord(\n key: string,\n options: FabricConversationTranscriptRenderOptions,\n ): AssistantCacheRecord {\n const cacheKey = key;\n const hideThinking = options.hideThinking ?? false;\n let record = this.assistantComponents.get(cacheKey);\n if (!record || record.hideThinking !== hideThinking) {\n record = {\n hideThinking,\n component: new AssistantMessageComponent(\n undefined,\n hideThinking,\n this.markdownTheme(options),\n this.rendererOptions.hiddenThinkingLabel,\n options.outputPad ?? 1,\n this.rendererOptions.markdownTransformers,\n ),\n };\n this.assistantComponents.set(cacheKey, record);\n }\n return record;\n }\n\n private messageRecord(\n key: string,\n create: () => MessageCacheRecord[\"component\"],\n ): MessageCacheRecord {\n const cacheKey = key;\n let record = this.messageComponents.get(cacheKey);\n if (!record) {\n record = { component: create() };\n this.messageComponents.set(cacheKey, record);\n }\n return record;\n }\n\n private releaseRendererStates(key: string): void {\n for (const state of this.rendererStates.get(key) ?? []) {\n this.liveStates.delete(state);\n if (state.codePreviewTimingInterval) {\n clearInterval(state.codePreviewTimingInterval as ReturnType<typeof setInterval>);\n delete state.codePreviewTimingInterval;\n }\n const spinner = state.fabricSpinner as { timer?: ReturnType<typeof setTimeout> } | undefined;\n if (spinner?.timer) { clearTimeout(spinner.timer); delete spinner.timer; }\n }\n this.rendererStates.delete(key);\n }\n\n private imageWidthCells(): number {\n return Math.max(1, Math.floor(this.rendererOptions.imageWidthCells ?? DEFAULT_IMAGE_WIDTH_CELLS));\n }\n\n private plainTextFallback(text: string, width: number): string[] {\n const safe = terminalSafe(text, false);\n return safe.split(\"\\n\").flatMap((paragraph) =>\n wrapTextWithAnsi(paragraph, Math.max(1, width)).map((line) => this.theme.fg(\"text\", line)),\n );\n }\n\n private pushSpacer(lines: string[]): void {\n if (lines.length > 0) lines.push(\"\");\n }\n}\n\n// Snapshot shallow fields on projection changes, including optional producer-side\n// content versions. Immutable nested payloads never need hashing on warm frames.\nconst shallowInput = (value: object): unknown[] => [...Object.keys(value), ...Object.values(value)];\n\nconst sameItems = <T>(a: readonly T[], b: readonly T[]): boolean =>\n a.length === b.length && a.every((item, index) => item === b[index]);\n\nconst userMessageText = (message: UserAgentMessage): string => {\n const blocks = typeof message.content === \"string\"\n ? [{ type: \"text\", text: message.content }]\n : message.content.filter((block): block is { type: \"text\"; text: string } => block.type === \"text\");\n const text = blocks.map((block) => block.text).join(\"\");\n return unwrapActorEnvelopeText(text) ?? text;\n};\n\nconst assistantText = (message: { content: unknown }): string =>\n Array.isArray(message.content)\n ? message.content\n .filter((block): block is { type: \"text\"; text: string } =>\n typeof block === \"object\" && block !== null && (block as { type?: unknown }).type === \"text\")\n .map((block) => block.text)\n .join(\"\\n\")\n : \"\";\n\nconst customText = (message: CustomAgentMessage): string =>\n typeof message.content === \"string\"\n ? message.content\n : message.content\n .filter((block): block is { type: \"text\"; text: string } => block.type === \"text\")\n .map((block) => block.text)\n .join(\"\\n\");\n\nconst safeRender = (\n component: { render(width: number): string[] },\n width: number,\n fallback: () => string[],\n): string[] => {\n try {\n // Native rows are preserved verbatim: components already wrap and pad to\n // width, so re-truncating would clip the trailing background cell.\n return component.render(width);\n } catch {\n return fallback();\n }\n};\n", "import type { Theme } from \"@earendil-works/pi-coding-agent\";\nimport { sliceByColumn, stripTerminalSequences, visibleWidth } from \"@earendil-works/pi-tui\";\n\ninterface Point { row: number; col: number }\nconst graphemes = new Intl.Segmenter(undefined, { granularity: \"grapheme\" });\n\n/** One immutable rendered-history reference; no history-sized copy on drag. */\nexport class ConversationTextSelection {\n source: string[] | undefined;\n private anchor: Point | undefined;\n private focus: Point | undefined;\n dragging = false;\n\n clear(): void {\n this.source = undefined;\n this.anchor = this.focus = undefined;\n this.dragging = false;\n }\n\n start(source: string[], row: number, col: number): void {\n this.source = source;\n this.anchor = this.point(row, col);\n this.focus = this.anchor;\n this.dragging = true;\n }\n\n move(row: number, col: number): void {\n if (this.dragging) this.focus = this.point(row, col);\n }\n\n finish(row: number, col: number): void {\n this.move(row, col);\n this.dragging = false;\n if (!this.bounds()) this.clear();\n }\n\n get active(): boolean { return this.bounds() !== undefined; }\n\n private point(row: number, col: number): Point {\n row = Math.max(0, Math.min(this.source!.length - 1, row));\n let boundary = 0;\n for (const { segment } of graphemes.segment(stripTerminalSequences(this.source![row] ?? \"\"))) {\n const next = boundary + visibleWidth(segment);\n if (next > col) break;\n boundary = next;\n }\n return { row, col: boundary };\n }\n\n private bounds(): { start: Point; end: Point } | undefined {\n const a = this.anchor;\n const b = this.focus;\n if (!a || !b || (a.row === b.row && a.col === b.col)) return undefined;\n return a.row < b.row || (a.row === b.row && a.col < b.col) ? { start: a, end: b } : { start: b, end: a };\n }\n\n text(): string | undefined {\n const bounds = this.bounds();\n if (!bounds || !this.source) return undefined;\n const lines: string[] = [];\n for (let row = bounds.start.row; row <= bounds.end.row; row++) {\n const line = this.source[row] ?? \"\";\n const start = row === bounds.start.row ? bounds.start.col : 0;\n const end = row === bounds.end.row ? bounds.end.col : visibleWidth(line);\n lines.push(stripTerminalSequences(sliceByColumn(line, start, end - start, true)).trimEnd());\n }\n return lines.join(\"\\n\") || undefined;\n }\n\n highlight(line: string, row: number, theme: Theme): string {\n const bounds = this.bounds();\n if (!bounds || row < bounds.start.row || row > bounds.end.row) return line;\n // Never slice/re-emit image control payloads while painting a selection.\n if (/\\x1b(?:_G|\\]1337;File=|P)/.test(line)) return line;\n const width = visibleWidth(line);\n const start = row === bounds.start.row ? bounds.start.col : 0;\n const end = row === bounds.end.row ? bounds.end.col : width;\n if (end <= start) return line;\n const selected = stripTerminalSequences(sliceByColumn(line, start, end - start, true));\n return sliceByColumn(line, 0, start, true) + theme.bg(\"selectedBg\", theme.fg(\"text\", selected)) +\n sliceByColumn(line, end, Math.max(0, width - end), true);\n }\n}\n", "import type { NativeConversationTranscript } from \"./conversation-native-reader.js\";\nimport { unwrapActorEnvelopeText } from \"./conversation-transcript.js\";\n\nconst PROMPT_HISTORY_LIMIT = 100;\n\n/** Pi keeps the newest 100 trimmed prompts, suppressing consecutive duplicates. */\nexport function appendConversationPrompt(history: string[], text: string): void {\n const prompt = text.trim();\n if (!prompt || history.at(-1) === prompt) return;\n history.push(prompt);\n if (history.length > PROMPT_HISTORY_LIMIT) history.shift();\n}\n\n/** Seed once on history use, without retaining transcript objects or reading more pages. */\nexport function conversationPromptHistory(transcript: NativeConversationTranscript): string[] {\n const newest: string[] = [];\n for (let index = transcript.messages.length - 1; index >= 0 && newest.length < PROMPT_HISTORY_LIMIT; index--) {\n const message = transcript.messages[index]!;\n if (message.role !== \"user\") continue;\n const raw = typeof message.content === \"string\" ? message.content\n : message.content.filter((part) => part.type === \"text\").map((part) => part.text).join(\"\");\n const text = (unwrapActorEnvelopeText(raw) ?? raw).trim();\n if (text && newest.at(-1) !== text) newest.push(text);\n }\n return newest.reverse();\n}\n", "import type { AutocompleteItem, AutocompleteProvider } from \"@earendil-works/pi-tui\";\nimport type { NativeConversationTranscript } from \"./conversation-native-reader.js\";\n\nexport const CONVERSATION_COMMANDS = [\n { value: \"/copy\", label: \"/copy\", description: \"Copy the last assistant response\" },\n { value: \"/copy selection\", label: \"/copy selection\", description: \"Copy selected transcript text\" },\n { value: \"/latest\", label: \"/latest\", description: \"Clear selection and follow latest output\" },\n { value: \"/agents\", label: \"/agents\", description: \"Choose a conversation\" },\n { value: \"/back\", label: \"/back\", description: \"Return to Main\" },\n { value: \"/stop\", label: \"/stop\", description: \"Confirm stopping this participant\" },\n { value: \"/help\", label: \"/help\", description: \"Show preview commands\" },\n] satisfies AutocompleteItem[];\n\nexport const CONVERSATION_COMMAND_HELP = \"Commands: /copy [selection] \u00B7 /latest \u00B7 /agents \u00B7 /back \u00B7 /stop \u00B7 /help\";\n\nexport function conversationCommandCompletion(enabled: () => boolean): AutocompleteProvider {\n return {\n triggerCharacters: [\"/\"],\n async getSuggestions(lines, row, col, options) {\n if (!enabled() || options.signal.aborted || row !== 0 || lines.length !== 1) return null;\n const prefix = lines[0]!.slice(0, col);\n if (col !== lines[0]!.length || !/^\\/[a-z]*(?: +[a-z]*)?$/.test(prefix)) return null;\n const items = CONVERSATION_COMMANDS.filter((item) => item.value.startsWith(prefix));\n return items.length ? { items, prefix } : null;\n },\n applyCompletion(lines, row, _col, item) {\n const next = [...lines];\n next[row] = `${item.value} `;\n return { lines: next, cursorLine: row, cursorCol: next[row]!.length };\n },\n };\n}\n\n/** Match Pi's /copy semantics: text from the last non-empty-aborted assistant. */\nexport function conversationAssistantText(transcript: NativeConversationTranscript): string | undefined {\n for (let index = transcript.messages.length - 1; index >= 0; index--) {\n const message = transcript.messages[index]!;\n if (message.role !== \"assistant\" || (message.stopReason === \"aborted\" && message.content.length === 0)) continue;\n const text = message.content.filter((block) => block.type === \"text\").map((block) => block.text).join(\"\").trim();\n return text || undefined;\n }\n return undefined;\n}\n", "import { createHash } from \"node:crypto\";\nimport { createConversationQueue, type ConversationQueue, type ConversationQueueOptions, type ConversationSnapshotEntry } from \"./conversation-queue.js\";\nimport type { NativeConversationTranscript } from \"./conversation-native-reader.js\";\nimport { unwrapActorEnvelopeText } from \"./conversation-transcript.js\";\n\ninterface QueueSlot {\n queue: ConversationQueue;\n attached: ConversationQueueOptions | undefined;\n initialized: boolean;\n frontier: number;\n projection?: QueueProjection | undefined;\n}\n\ninterface QueueProjection {\n messages: NativeConversationTranscript[\"messages\"];\n messageCount: number;\n revision: number;\n sourceId: string;\n sessionFile: string | undefined;\n eventsFile: string | undefined;\n leafId: string | null;\n entries: ConversationSnapshotEntry[];\n}\n\ninterface UserIdentity {\n content: string;\n timestamp: number;\n id: string;\n text: string;\n}\n\n/** Session-owned queues; replacing a view never strands an acknowledgement or editor. */\nexport class ConversationQueueStore {\n private readonly slots = new Map<string, QueueSlot>();\n private readonly userIdentities = new WeakMap<object, UserIdentity>();\n\n attach(options: ConversationQueueOptions): ConversationQueue {\n const existing = this.slots.get(options.targetId);\n if (existing) { existing.attached = options; return existing.queue; }\n const slot: QueueSlot = { queue: undefined as unknown as ConversationQueue, attached: options, initialized: false, frontier: 0 };\n const attached = () => slot.attached;\n slot.queue = createConversationQueue({\n ...options,\n send: (text, lane) => {\n const current = attached();\n if (!current) return Promise.reject(new Error(\"Open this conversation to send its queued messages\"));\n return current.send(text, lane);\n },\n editor: {\n getText: () => attached()?.editor?.getText() ?? \"\",\n setText: (text) => attached()?.editor?.setText(text),\n handleInput: (data) => attached()?.editor?.handleInput?.(data),\n render: (width) => attached()?.editor?.render?.(width) ?? [],\n get paddingX() { return attached()?.editor?.paddingX ?? 0; },\n },\n isIdle: () => attached()?.isIdle?.() ?? true,\n onNotify: (text, kind) => attached()?.onNotify?.(text, kind),\n requestRender: () => attached()?.requestRender?.(),\n });\n this.slots.set(options.targetId, slot);\n return slot.queue;\n }\n\n get(id: string): ConversationQueue | undefined { return this.slots.get(id)?.queue; }\n\n detach(id: string): void {\n const slot = this.slots.get(id);\n if (!slot) return;\n slot.queue.cancelEditing();\n slot.attached = undefined;\n slot.projection = undefined;\n }\n\n sync(id: string, transcript: NativeConversationTranscript): void {\n const slot = this.slots.get(id);\n if (!slot) return;\n let projection = slot.projection;\n const changed = !projection || projection.messages !== transcript.messages ||\n projection.messageCount !== transcript.messages.length || projection.revision !== transcript.revision ||\n projection.sourceId !== transcript.sourceId || projection.sessionFile !== transcript.sessionFile ||\n projection.eventsFile !== transcript.eventsFile || projection.leafId !== transcript.leafId;\n if (changed) {\n let frontier = slot.frontier;\n const occurrences = new Map<string, number>();\n const entries: ConversationSnapshotEntry[] = [];\n for (const message of transcript.messages) {\n if (Number.isFinite(message.timestamp)) frontier = Math.max(frontier, message.timestamp);\n if (message.role !== \"user\") continue;\n const { id: identity, text } = this.userIdentity(message);\n const occurrence = occurrences.get(identity) ?? 0;\n occurrences.set(identity, occurrence + 1);\n entries.push({ id: occurrence === 0 ? identity : `${identity}:${occurrence}`, text,\n historical: !slot.initialized || message.timestamp < slot.frontier });\n }\n projection = {\n messages: transcript.messages, messageCount: transcript.messages.length, revision: transcript.revision,\n sourceId: transcript.sourceId, sessionFile: transcript.sessionFile, eventsFile: transcript.eventsFile,\n leafId: transcript.leafId, entries,\n };\n // Inactive queues keep delivery frontiers, not a strong reference to the\n // reader's entire transcript. Its identity cache uses weak keys too.\n slot.projection = slot.attached ? projection : undefined;\n slot.frontier = frontier;\n slot.initialized = true;\n }\n // A routing acknowledgement can arrive after its native entry, without a\n // transcript change. Pending sends must still check cached delivery ids.\n if (projection && (changed || slot.queue.pendingCount() > 0)) slot.queue.syncSnapshot(projection.entries);\n slot.queue.syncPending(transcript.pendingMessages);\n }\n\n private userIdentity(message: Extract<NativeConversationTranscript[\"messages\"][number], { role: \"user\" }>): Pick<UserIdentity, \"id\" | \"text\"> {\n const cached = this.userIdentities.get(message);\n if (cached && cached.content === message.content && cached.timestamp === message.timestamp) return cached;\n const raw = typeof message.content === \"string\" ? message.content : message.content.filter((part) => part.type === \"text\").map((part) => part.text).join(\"\");\n const text = unwrapActorEnvelopeText(raw) ?? raw;\n let id: string | undefined;\n if (text !== raw) {\n try {\n const envelope = JSON.parse(raw.trim().slice(\"Fabric actor message from direct:\".length));\n if (typeof envelope.id === \"string\") id = envelope.id;\n } catch { /* Only a validated actor envelope can provide a delivery id. */ }\n }\n id ||= createHash(\"sha256\").update(JSON.stringify([message.timestamp, message.content])).digest(\"hex\");\n const identity = { id, text };\n // Array blocks can be mutated in place; recheck them on changed projections\n // rather than trusting their container identity for delivery matching.\n if (typeof message.content === \"string\") {\n this.userIdentities.set(message, { ...identity, content: message.content, timestamp: message.timestamp });\n }\n return identity;\n }\n\n clear(): void {\n for (const slot of this.slots.values()) { slot.queue.cancelEditing(); slot.attached = undefined; slot.projection = undefined; slot.queue.dispose(); }\n this.slots.clear();\n }\n}\n", "import type { KeybindingsManager, Theme, ThemeColor } from \"@earendil-works/pi-coding-agent\";\nimport {\n Key,\n getKeybindings,\n matchesKey,\n truncateToWidth,\n type KeyId,\n} from \"@earendil-works/pi-tui\";\n\n/**\n * Target-scoped conversation queue for the focused conversation view.\n *\n * When pi-queue-steer is installed and loaded, a versioned pi.events\n * request/capability handshake hands this adapter a bridge over the\n * extension's actual queue-state machinery (DeliveryQueue / QueueEditSession)\n * AND its actual shared execution-outline renderer (QueueTimelineWidget plus\n * the real inline-editor line extractor) \u2014 no imitation, no hard dependency:\n * the extension is discovered only through the shared bus. With no compatible\n * listener, the adapter falls back to Pi's native queue display labels and\n * colors (\"Steering:\" / \"Follow-up:\", dim) and never claims extension parity.\n *\n * Delivery ownership rules:\n * - every queue is bound to one targetId; rows and edits never leak to Main\n * or to another target (dispatch goes only through the injected per-target\n * `send` route);\n * - `submit` acknowledges route acceptance only: a resolved send marks the\n * row `dispatched` \u2014 immutable, no longer editable (there is no remote\n * retract API) \u2014 and still visible until native delivery is confirmed;\n * - rows retire through `syncSnapshot`, reconciled against the native\n * reader agent's complete-message snapshot (read-only messages/streaming/\n * tools source). Retirement keys on stable native message identities plus\n * a pre-dispatch baseline and live-append frontier, with duplicate\n * counting \u2014 trimmed text alone is NOT identity: identical text already in\n * history, or historical pages loaded later, can never fake consumption;\n * - a failed send restores the exact remaining rows to the timeline head in\n * order;\n * - Main-only control actions (/ commands, ! bash) are rejected at stage\n * time \u2014 they are not queueable from a focused conversation;\n * - a run ending (settled, aborted, errored) is NOT a retirement event:\n * follow-ups exist precisely to start the next run, and a route ack cannot\n * prove consumption, so only `retireAll` (target removed/unreachable) or\n * an identity match retires rows;\n * - `dispose({ retain })` gives Main explicit cleanup/retention semantics on\n * target switches: retention parks the rows (the extension bridge retains\n * them per targetId for re-adoption), the default clears them and releases\n * the extension's retained state.\n */\n\nexport const QUEUE_STEER_CONVERSATION_QUEUE_REQUEST_EVENT = \"queue-steer:conversation-queue:request:v1\";\n\ntype ConversationQueueLane = \"steer\" | \"followUp\";\ntype ConversationQueueRowState = \"queued\" | \"dispatched\";\n\ninterface ConversationQueueRow {\n id: string;\n lane: ConversationQueueLane;\n text: string;\n state: ConversationQueueRowState;\n paused: boolean;\n /** Current row-editing selection (rendered live through the shared editor). */\n selected: boolean;\n /** Marked for removal inside the active editing session; save deletes it. */\n removed: boolean;\n}\n\n/** Structural shape of the extension's real `DeliveryQueue` rows. */\ninterface ConversationQueueBridgeRow {\n id: string;\n lane: ConversationQueueLane;\n text: string;\n images: unknown[];\n sequence: number;\n paused?: boolean;\n}\n\n/** Structural subset of the extension's real `DeliveryQueue`. */\ninterface ConversationQueueBridgeQueue {\n enqueue(lane: ConversationQueueLane, text: string, images?: readonly unknown[]): ConversationQueueBridgeRow;\n snapshot(): ConversationQueueBridgeRow[];\n peek(): ConversationQueueBridgeRow | undefined;\n get(id: string): ConversationQueueBridgeRow | undefined;\n remove(id: string): ConversationQueueBridgeRow | undefined;\n prepend(item: ConversationQueueBridgeRow): void;\n prependMany(items: readonly ConversationQueueBridgeRow[]): void;\n update(id: string, text: string): boolean;\n setLane(id: string, lane: ConversationQueueLane): boolean;\n setPaused(id: string, paused: boolean): boolean;\n clear(): void;\n readonly length: number;\n}\n\n/** Structural subset of the extension's real `QueueEditSession`. */\ninterface ConversationQueueBridgeEditSession {\n readonly selectedId: string;\n readonly composerDraft: string;\n capture(text: string): void;\n select(item: ConversationQueueBridgeRow, currentText: string): string;\n toggleRemoved(id: string): boolean | undefined;\n togglePaused(id: string): boolean | undefined;\n setLane(id: string, lane: ConversationQueueLane): ConversationQueueLane | undefined;\n commit(queue: ConversationQueueBridgeQueue, currentText: string): {\n updated: number;\n removed: number;\n moved: number;\n held: number;\n released: number;\n };\n rollbackPositions(queue: ConversationQueueBridgeQueue): void;\n /** Draft decoration readers; present on the extension's real session. */\n laneFor?(id: string): ConversationQueueLane | undefined;\n textFor?(id: string): string | undefined;\n pausedFor?(id: string): boolean | undefined;\n isRemoved?(id: string): boolean;\n}\n\n/**\n * Version 1 interop bridge served by a loaded pi-queue-steer over the\n * `QUEUE_STEER_CONVERSATION_QUEUE_REQUEST_EVENT` handshake. The renderer\n * members are optional so an older installed extension degrades gracefully\n * to the native fallback rendering instead of an imitation outline.\n */\nexport interface ConversationQueueBridgeV1 {\n version: 1;\n targetId: string;\n createQueue(): ConversationQueueBridgeQueue;\n createEditSession(item: ConversationQueueBridgeRow, composerDraft: string): ConversationQueueBridgeEditSession;\n isQueueableSubmission(text: string): boolean;\n laneLabel(lane: ConversationQueueLane): string;\n laneColor(lane: ConversationQueueLane): string;\n buildTimelineItems?(\n queue: ConversationQueueBridgeQueue,\n editSession: ConversationQueueBridgeEditSession | undefined,\n modes?: { steer: \"all\" | \"one-at-a-time\"; followUp: \"all\" | \"one-at-a-time\" },\n ): readonly unknown[];\n createTimelineWidget?(\n options: {\n items: readonly unknown[];\n editingId?: string;\n paused?: boolean;\n idle?: boolean;\n renderInlineEditor?: (width: number) => string[];\n },\n theme: Theme,\n ): { render(width: number): string[]; invalidate(): void };\n extractInlineEditorLines?(lines: readonly string[], paddingX?: number): string[];\n}\n\n/**\n * One entry of the native reader agent's complete-message snapshot. `id` is\n * a stable native identity (session entry id, reader event identity, or the\n * actor envelope/message id); `historical` marks baseline/history entries \u2014\n * including older transcript pages loaded later \u2014 which establish identity\n * but can never retire a queued row.\n */\nexport interface ConversationSnapshotEntry {\n id: string;\n text: string;\n historical?: boolean;\n}\n\nexport interface ConversationQueueOptions {\n /** Shared pi.events bus (emit only; the handshake is synchronous claim/respond). */\n piEvents: { emit(channel: string, data: unknown): void };\n targetId: string;\n targetName?: string;\n /**\n * Per-target dispatch route owned by Main; rejection restores the rows. A\n * resolved value may carry `messageId`/`id` (e.g. an actor envelope id) \u2014\n * it becomes the row's expected native delivery identity.\n */\n send: (message: string, delivery: ConversationQueueLane) => Promise<unknown>;\n theme: Theme;\n /** Shared focused-view editor; row editing renders live through it. */\n editor?: {\n getText(): string;\n setText(text: string): void;\n handleInput?(data: string): void;\n /** Full renderer, used for real inline row editing via the bridge. */\n render?(width: number): string[];\n /** Editor interior padding, forwarded to the inline line extractor. */\n paddingX?: number;\n };\n keybindings?: Pick<KeybindingsManager, \"matches\" | \"getKeys\">;\n /** Target run state for the shared widget's stage label; default idle=false. */\n isIdle?: () => boolean;\n onNotify?: (text: string, kind: \"info\" | \"error\") => void;\n requestRender?: () => void;\n}\n\ninterface StageResult {\n ok: boolean;\n id?: string;\n error?: string;\n}\n\nexport interface ConversationQueue {\n readonly targetId: string;\n /** \"extension\" when a real pi-queue-steer bridge was claimed, \"native\" otherwise. */\n readonly mode: \"extension\" | \"native\";\n readonly active: boolean;\n /** True while a row-editing session holds the shared editor. */\n readonly editingActive: boolean;\n /** Stage text as a queue row for this target. Control input is rejected. */\n stage(text: string, lane: ConversationQueueLane): StageResult;\n /**\n * Dispatch the contiguous same-lane unpauseed head batch through `send`.\n * Resolves true only when every row was accepted by the route; a failure\n * restores the unsent rows to the timeline head in order. Acceptance is\n * not consumption: accepted rows become immutable and stay visible until\n * `syncSnapshot` confirms native delivery identity.\n */\n submit(lane: ConversationQueueLane): Promise<boolean>;\n dispatch(text: string, lane: ConversationQueueLane): Promise<void>;\n park(text: string, lane: ConversationQueueLane): StageResult;\n cancelEditing(): void;\n syncPending(pending: { steering: string[]; followUp: string[] } | undefined): void;\n /** Decorated rows in timeline order (dispatched rows first, then queued). */\n rows(): ConversationQueueRow[];\n /** Queue list lines rendered above the editor; empty when nothing is held. */\n render(width: number): string[];\n /**\n * Row-editing input handling. Consumes keys only while an editing session\n * is active or when the dequeue binding starts one; everything else passes\n * back to Main (`false`).\n */\n handleInput(data: string): boolean;\n /**\n * Reconcile against the native reader snapshot (read-only). Main feeds the\n * initial pre-dispatch snapshot as `historical` entries before the first\n * submit, then subsequent live snapshots. Retirement matches, first, a\n * dispatched row's expected native message identity (actor envelope id) or,\n * failing that, one live-append entry beyond the historical baseline with\n * the row's text \u2014 duplicate rows each consume their own frontier entry.\n * Historical entries and older pages never retire anything.\n */\n syncSnapshot(entries: readonly ConversationSnapshotEntry[]): number;\n /**\n * The target is being removed/unreachable: retire every held row. This is\n * the only blanket retirement, and it must NOT be called merely because a\n * run ended or the target stopped \u2014 follow-ups are for the next run, and a\n * route ack cannot prove consumption.\n */\n retireAll(reason?: string): number;\n /** Number of rows still held (queued + dispatched-but-unconfirmed). */\n pendingCount(): number;\n dispose(options?: { retain?: boolean }): void;\n}\n\ninterface RequestResult {\n ok: boolean;\n bridge?: ConversationQueueBridgeV1;\n error?: string;\n}\n\ninterface HandshakeRequest {\n version: 1;\n action: \"acquire\" | \"release\";\n targetId: string;\n claim(): boolean;\n respond(result: RequestResult): void;\n}\n\ninterface DispatchedRow {\n id: string;\n lane: ConversationQueueLane;\n text: string;\n /** Expected stable native identity, when the route reported one. */\n expectedId?: string;\n}\n\nconst DEQUEUE_FALLBACK: KeyId = \"alt+up\";\nconst REMOVE_ROW_KEY = \"alt+x\";\nconst PAUSE_ROW_KEY = \"alt+p\";\nconst INDENT_ROW_KEY: KeyId = \"alt+right\";\nconst OUTDENT_ROW_KEY: KeyId = \"alt+left\";\nconst TOGGLE_LANE_KEY = \"alt+t\";\n\n/** Native Pi pending-messages labels (interactive-mode ground truth). */\nconst NATIVE_LANE_LABEL: Record<ConversationQueueLane, string> = {\n steer: \"Steering\",\n followUp: \"Follow-up\",\n};\n\n/**\n * Native fallback timeline implementing the same structural contract as the\n * extension bridge, so the adapter logic is single-path for both modes.\n */\nclass NativeQueueState implements ConversationQueueBridgeQueue {\n private items: ConversationQueueBridgeRow[] = [];\n private nextIdNumber = 1;\n private nextSequence = 1;\n\n enqueue(lane: ConversationQueueLane, text: string, images: readonly unknown[] = []): ConversationQueueBridgeRow {\n const prefix = lane === \"steer\" ? \"steer\" : \"follow-up\";\n const item: ConversationQueueBridgeRow = {\n id: `${prefix}-${this.nextIdNumber++}`,\n lane,\n text,\n images: [...images],\n sequence: this.nextSequence++,\n paused: false,\n };\n this.items.push(item);\n return { ...item, images: [...item.images] };\n }\n\n snapshot(): ConversationQueueBridgeRow[] {\n return this.items.map((item) => ({ ...item, images: [...item.images] }));\n }\n\n peek(): ConversationQueueBridgeRow | undefined {\n const item = this.items[0];\n return item ? { ...item, images: [...item.images] } : undefined;\n }\n\n get(id: string): ConversationQueueBridgeRow | undefined {\n const item = this.items.find((candidate) => candidate.id === id);\n return item ? { ...item, images: [...item.images] } : undefined;\n }\n\n remove(id: string): ConversationQueueBridgeRow | undefined {\n const index = this.items.findIndex((candidate) => candidate.id === id);\n if (index === -1) return undefined;\n const [item] = this.items.splice(index, 1);\n return item ? { ...item, images: [...item.images] } : undefined;\n }\n\n prepend(item: ConversationQueueBridgeRow): void {\n this.items.unshift({ ...item, images: [...item.images] });\n }\n\n prependMany(items: readonly ConversationQueueBridgeRow[]): void {\n for (let index = items.length - 1; index >= 0; index -= 1) {\n const item = items[index];\n if (item) this.items.unshift({ ...item, images: [...item.images] });\n }\n }\n\n update(id: string, text: string): boolean {\n const item = this.items.find((candidate) => candidate.id === id);\n if (!item) return false;\n item.text = text;\n return true;\n }\n\n setLane(id: string, lane: ConversationQueueLane): boolean {\n const item = this.items.find((candidate) => candidate.id === id);\n if (!item || item.lane === lane) return false;\n item.lane = lane;\n return true;\n }\n\n setPaused(id: string, paused: boolean): boolean {\n const item = this.items.find((candidate) => candidate.id === id);\n if (!item || (item.paused ?? false) === paused) return false;\n item.paused = paused;\n return true;\n }\n\n clear(): void {\n this.items = [];\n }\n\n get length(): number {\n return this.items.length;\n }\n}\n\n/** Rollback-safe snapshot editing for the native fallback queue. */\nclass NativeEditSession implements ConversationQueueBridgeEditSession {\n readonly composerDraft: string;\n private currentId: string;\n private readonly drafts = new Map<string, { text: string; lane: ConversationQueueLane; removed: boolean; paused: boolean }>();\n\n constructor(item: ConversationQueueBridgeRow, composerDraft: string) {\n this.currentId = item.id;\n this.composerDraft = composerDraft;\n this.drafts.set(item.id, {\n text: item.text,\n lane: item.lane,\n removed: false,\n paused: item.paused ?? false,\n });\n }\n\n get selectedId(): string {\n return this.currentId;\n }\n\n capture(text: string): void {\n const draft = this.drafts.get(this.currentId);\n if (draft) draft.text = text;\n }\n\n select(item: ConversationQueueBridgeRow, currentText: string): string {\n this.capture(currentText);\n if (!this.drafts.has(item.id)) {\n this.drafts.set(item.id, {\n text: item.text,\n lane: item.lane,\n removed: false,\n paused: item.paused ?? false,\n });\n }\n this.currentId = item.id;\n return this.drafts.get(item.id)?.text ?? item.text;\n }\n\n toggleRemoved(id: string): boolean | undefined {\n const draft = this.drafts.get(id);\n if (!draft) return undefined;\n draft.removed = !draft.removed;\n return draft.removed;\n }\n\n togglePaused(id: string): boolean | undefined {\n const draft = this.drafts.get(id);\n if (!draft) return undefined;\n draft.paused = !draft.paused;\n return draft.paused;\n }\n\n setLane(id: string, lane: ConversationQueueLane): ConversationQueueLane | undefined {\n const draft = this.drafts.get(id);\n if (!draft) return undefined;\n draft.lane = lane;\n return draft.lane;\n }\n\n commit(queue: ConversationQueueBridgeQueue, currentText: string): {\n updated: number;\n removed: number;\n moved: number;\n held: number;\n released: number;\n } {\n this.capture(currentText);\n let updated = 0;\n let removed = 0;\n let moved = 0;\n let held = 0;\n let released = 0;\n for (const [id, draft] of this.drafts.entries()) {\n if (draft.removed || !draft.text.trim()) {\n if (queue.remove(id)) removed += 1;\n continue;\n }\n if (queue.update(id, draft.text)) updated += 1;\n if (queue.setLane(id, draft.lane)) moved += 1;\n if (queue.setPaused(id, draft.paused)) {\n if (draft.paused) held += 1;\n else released += 1;\n }\n }\n return { updated, removed, moved, held, released };\n }\n\n rollbackPositions(): void {}\n\n laneFor(id: string): ConversationQueueLane | undefined {\n return this.drafts.get(id)?.lane;\n }\n\n textFor(id: string): string | undefined {\n return this.drafts.get(id)?.text;\n }\n\n pausedFor(id: string): boolean | undefined {\n return this.drafts.get(id)?.paused;\n }\n\n isRemoved(id: string): boolean {\n return this.drafts.get(id)?.removed ?? false;\n }\n}\n\nconst errorText = (error: unknown): string =>\n error instanceof Error ? error.message : String(error ?? \"\");\n\nconst controlInputRe = /^[/!]/;\n\n/**\n * Create one target-scoped conversation queue. Attempts the pi-queue-steer\n * interop handshake first (mode \"extension\"); with no claiming listener the\n * adapter serves Pi's native queue labels and colors (mode \"native\").\n */\nexport function createConversationQueue(options: ConversationQueueOptions): ConversationQueue {\n const { piEvents, targetId, theme } = options;\n const notify = (text: string, kind: \"info\" | \"error\" = \"info\") => {\n options.onNotify?.(text, kind);\n };\n const requestRender = () => options.requestRender?.();\n const targetLabel = options.targetName ?? targetId;\n\n let bridge: ConversationQueueBridgeV1 | undefined;\n let queue: ConversationQueueBridgeQueue;\n let mode: \"extension\" | \"native\" = \"native\";\n let disposed = false;\n /** Route-accepted rows awaiting native delivery identity confirmation. */\n const dispatched: DispatchedRow[] = [];\n let externalPending: DispatchedRow[] = [];\n let lastSendError: unknown;\n let editSession: ConversationQueueBridgeEditSession | undefined;\n\n // Snapshot reconciliation state: every fed identity is seen exactly once;\n // historical entries (initial baseline, older pages) can never retire;\n // live-append frontier counts per trimmed text drive text-based retirement\n // with duplicate counting; consumed ids make each entry retire at most one row.\n const seenIds = new Set<string>();\n const consumedIds = new Set<string>();\n const liveTextCounts = new Map<string, number>();\n\n const emitHandshake = (action: \"acquire\" | \"release\"): { claimed: boolean; result?: RequestResult | undefined } => {\n let claimed = false;\n let settled = false;\n let result: RequestResult | undefined;\n const request: HandshakeRequest = {\n version: 1,\n action,\n targetId,\n claim: () => {\n if (claimed) return false;\n claimed = true;\n return true;\n },\n respond: (response) => {\n // The bridge contract is a synchronous respond during emit; late\n // responses are ignored so the adapter mode never flips mid-render.\n if (settled) return;\n settled = true;\n result = response;\n },\n };\n piEvents.emit(QUEUE_STEER_CONVERSATION_QUEUE_REQUEST_EVENT, request);\n return { claimed, result };\n };\n\n const acquisition = emitHandshake(\"acquire\");\n if (\n acquisition.claimed\n && acquisition.result?.ok\n && acquisition.result.bridge?.version === 1\n && acquisition.result.bridge.targetId === targetId\n ) {\n bridge = acquisition.result.bridge;\n mode = \"extension\";\n } else if (acquisition.claimed && acquisition.result && !acquisition.result.ok) {\n notify(`pi-queue-steer refused the conversation queue for ${targetLabel}: ${acquisition.result.error ?? \"unknown error\"}`, \"error\");\n }\n queue = bridge ? bridge.createQueue() : new NativeQueueState();\n\n const laneLabel = (lane: ConversationQueueLane): string =>\n bridge ? bridge.laneLabel(lane) : lane === \"steer\" ? \"steer\" : \"follow-up\";\n\n const isQueueable = (text: string): boolean =>\n bridge ? bridge.isQueueableSubmission(text) : !controlInputRe.test(text.trim()) && text.trim() !== \"\";\n\n const decoratedRow = (item: ConversationQueueBridgeRow): ConversationQueueRow => ({\n id: item.id,\n lane: editSession?.laneFor?.(item.id) ?? item.lane,\n text: editSession?.textFor?.(item.id) ?? item.text,\n state: \"queued\",\n paused: editSession?.pausedFor?.(item.id) ?? (item.paused ?? false),\n selected: editSession?.selectedId === item.id,\n removed: editSession?.isRemoved?.(item.id) ?? false,\n });\n\n const orderedRows = (): ConversationQueueRow[] => {\n const held = queue.snapshot().map(decoratedRow);\n // Accepted rows are immutable: outside the editing queue, never selectable.\n const inFlight: ConversationQueueRow[] = [...dispatched, ...externalPending].map((row) => ({\n id: row.id,\n lane: row.lane,\n text: row.text,\n state: \"dispatched\" as const,\n paused: false,\n selected: false,\n removed: false,\n }));\n return [...inFlight, ...held];\n };\n\n /**\n * Contiguous same-lane head batch; a paused head row is a dispatch barrier\n * and rows behind it never jump ahead.\n */\n const headBatch = (lane: ConversationQueueLane): ConversationQueueBridgeRow[] => {\n const items = queue.snapshot();\n const head = items[0];\n if (!head || head.lane !== lane) return [];\n const batch: ConversationQueueBridgeRow[] = [];\n for (const item of items) {\n if (item.lane !== lane) break;\n if (item.paused) break;\n batch.push(item);\n }\n return batch;\n };\n\n const dequeueKeys = (): readonly string[] => {\n const manager = options.keybindings ?? getKeybindings();\n const keys = manager.getKeys(\"app.message.dequeue\");\n return keys.filter((key: string) => /up$/i.test(key)).map((key: string) =>\n key.endsWith(\"Up\") ? `${key.slice(0, -2)}Down` : `${key.slice(0, -2)}down`\n );\n };\n\n const actionMatches = (\n data: string,\n action: \"app.message.dequeue\" | \"app.interrupt\" | \"tui.input.submit\" | \"app.message.followUp\",\n fallback: (data: string) => boolean,\n ): boolean => {\n const manager = options.keybindings;\n if (manager) {\n const keys = manager.getKeys(action);\n if (keys.length === 0) return false;\n return manager.matches(data, action);\n }\n const global = getKeybindings();\n if (global.getKeys(action).length > 0) return global.matches(data, action);\n return fallback(data);\n };\n\n const startEditing = (): boolean => {\n if (!options.editor) {\n notify(\"Editing queued rows requires the shared editor\", \"error\");\n return false;\n }\n const items = queue.snapshot();\n if (items.length === 0) {\n notify(\"No queued messages to edit\", \"info\");\n return false;\n }\n // Enter at the most recently queued row, like the extension's dequeue.\n const mostRecent = items.reduce((newest, item) => (item.sequence > newest.sequence ? item : newest), items[0]!);\n editSession = bridge\n ? bridge.createEditSession(mostRecent, options.editor.getText())\n : new NativeEditSession(mostRecent, options.editor.getText());\n options.editor.setText(mostRecent.text);\n notify(`Editing queued ${laneLabel(mostRecent.lane)} row \u00B7 enter saves, escape rolls back`, \"info\");\n requestRender();\n return true;\n };\n\n const finishEditing = (save: boolean): boolean => {\n const session = editSession;\n const editor = options.editor;\n if (!session || !editor) return false;\n const currentText = editor.getText();\n editSession = undefined;\n if (save) {\n const result = session.commit(queue, currentText);\n if (result.removed > 0) notify(`Removed ${result.removed} queued row${result.removed === 1 ? \"\" : \"s\"}`, \"info\");\n if (result.moved > 0) notify(`Changed delivery depth for ${result.moved} row${result.moved === 1 ? \"\" : \"s\"}`, \"info\");\n if (result.held > 0) notify(`Paused ${result.held} row${result.held === 1 ? \"\" : \"s\"} \u2014 dispatch stops there until resumed`, \"info\");\n if (result.released > 0) notify(`Resumed ${result.released} row${result.released === 1 ? \"\" : \"s\"}`, \"info\");\n } else {\n // Escape rolls the whole editing session back, including lane and\n // pause drafts; row edits live only in the discarded drafts.\n notify(\"Row edits rolled back\", \"info\");\n }\n editor.setText(session.composerDraft);\n requestRender();\n return true;\n };\n\n const matchesOptionArrow = (data: string, direction: \"left\" | \"right\"): boolean => {\n const arrow = direction === \"left\" ? OUTDENT_ROW_KEY : INDENT_ROW_KEY;\n const wordAlias: KeyId = direction === \"left\" ? \"alt+b\" : \"alt+f\";\n // Preserve the word-navigation aliases some terminals send for Option+Arrow.\n return matchesKey(data, arrow) && !matchesKey(data, wordAlias);\n };\n\n const inlineEditorRenderer = (): ((width: number) => string[]) | undefined => {\n const editor = options.editor;\n if (!editor?.render) return undefined;\n return (width: number) => {\n const lines = editor.render!(width);\n if (bridge?.extractInlineEditorLines) {\n return bridge.extractInlineEditorLines(lines, editor.paddingX ?? 0);\n }\n return [...lines];\n };\n };\n\n return {\n targetId,\n get mode() {\n return mode;\n },\n get active() {\n return !disposed && (queue.length > 0 || dispatched.length > 0);\n },\n get editingActive() {\n return editSession !== undefined;\n },\n\n stage(text, lane) {\n if (disposed) return { ok: false, error: \"Queue is disposed\" };\n const trimmed = text.trim();\n if (!trimmed) return { ok: false, error: \"Nothing to queue\" };\n if (!isQueueable(trimmed) || controlInputRe.test(trimmed)) {\n return {\n ok: false,\n error: \"Control input (/ commands, ! bash) is Main-only and is not queued from a focused conversation\",\n };\n }\n const row = queue.enqueue(lane, text);\n notify(`Queued ${laneLabel(lane)} \u2192 ${targetLabel}`, \"info\");\n requestRender();\n return { ok: true, id: row.id };\n },\n\n async submit(lane) {\n if (disposed) return false;\n if (editSession) {\n notify(\"Finish or cancel row editing before dispatching the queue\", \"info\");\n return false;\n }\n const batch = headBatch(lane);\n if (batch.length === 0) {\n const head = queue.peek();\n if (head?.paused) notify(`The next ${laneLabel(lane)} row is paused \u2014 dispatch holds there`, \"info\");\n else notify(`No dispatchable queued ${laneLabel(lane)} rows at the timeline head`, \"info\");\n return false;\n }\n let sent = 0;\n lastSendError = undefined;\n for (const item of batch) {\n if (disposed) return false;\n queue.remove(item.id);\n const pending: DispatchedRow = { id: item.id, lane, text: item.text };\n dispatched.push(pending);\n requestRender();\n let expectedId: string | undefined;\n try {\n const result = await options.send(item.text, lane);\n // Actor routes can report the original envelope/message id; a\n // one-shot native route may resolve void \u2014 identity then falls\n // back to the live-append text frontier.\n const candidate = result as { messageId?: unknown; id?: unknown } | undefined;\n const reported = candidate?.messageId ?? candidate?.id;\n if (typeof reported === \"string\" && reported !== \"\") expectedId = reported;\n } catch (error) {\n lastSendError = error;\n const pendingIndex = dispatched.indexOf(pending);\n if (pendingIndex < 0 || disposed) return !disposed;\n dispatched.splice(pendingIndex, 1);\n // Exact failed-send restoration: only the failed row is prepended\n // \u2014 rows behind it were never removed from the queue, so they are\n // still in their original positions after it.\n queue.prepend({ ...item });\n notify(`Send failed for ${targetLabel} (${laneLabel(lane)}); row restored to the queue head: ${errorText(error)}`, \"error\");\n requestRender();\n return false;\n }\n if (expectedId) pending.expectedId = expectedId;\n sent += 1;\n }\n notify(`Accepted ${sent} queued ${laneLabel(lane)} row${sent === 1 ? \"\" : \"s\"} \u2192 ${targetLabel} \u00B7 awaiting delivery`, \"info\");\n requestRender();\n return true;\n },\n\n async dispatch(text, lane) {\n const row = this.stage(text, lane);\n if (!row.ok || !row.id) throw new Error(row.error ?? \"Unable to queue input\");\n if (!await this.submit(lane)) {\n queue.remove(row.id);\n throw lastSendError ?? new Error(\"The queue head is paused or held; edit or resume it before sending\");\n }\n },\n\n park(text, lane) {\n const result = this.stage(text, lane);\n if (result.id) queue.setPaused(result.id, true);\n return result;\n },\n\n cancelEditing() { if (editSession) finishEditing(false); },\n\n syncPending(pending) {\n externalPending = [];\n if (!pending) return;\n const own = [...queue.snapshot(), ...dispatched];\n for (const [lane, messages] of [[\"steer\", pending.steering], [\"followUp\", pending.followUp]] as const) {\n const remaining = own.filter((row) => row.lane === lane).map((row) => row.text);\n messages.forEach((text, index) => {\n const match = remaining.indexOf(text);\n if (match >= 0) remaining.splice(match, 1);\n else externalPending.push({ id: `native:${lane}:${index}`, lane, text });\n });\n }\n },\n\n rows: orderedRows,\n\n render(width) {\n if (disposed || width <= 0) return [];\n const rows = orderedRows();\n if (rows.length === 0) return [];\n // Extension mode with a bridge that serves the real renderer: render\n // the actual shared execution-outline widget. The caption keeps the\n // execution model honest \u2014 Fabric dispatches on submit; retirement is\n // delivery-confirmed, not implied by the outline.\n if (bridge?.createTimelineWidget && bridge.buildTimelineItems) {\n const visibleRows: ConversationQueueBridgeRow[] = [\n ...[...dispatched, ...externalPending].map((row, index) => ({ id: row.id, lane: row.lane, text: row.text, images: [], sequence: index - dispatched.length })),\n ...queue.snapshot(),\n ];\n const displayQueue = new Proxy(queue, { get(target, key) {\n if (key === \"snapshot\") return () => visibleRows;\n const value: unknown = Reflect.get(target, key, target);\n return typeof value === \"function\" ? value.bind(target) : value;\n } });\n const items = bridge.buildTimelineItems(displayQueue, editSession);\n const inline = editSession ? inlineEditorRenderer() : undefined;\n const editingId = editSession?.selectedId;\n const widget = bridge.createTimelineWidget(\n {\n items,\n ...(editingId !== undefined ? { editingId } : {}),\n paused: false,\n idle: options.isIdle?.() ?? false,\n ...(inline ? { renderInlineEditor: inline } : {}),\n },\n theme,\n );\n const lines = widget.render(width);\n if (dispatched.length > 0) lines.push(theme.fg(\"dim\", truncateToWidth(\"Sent rows await child delivery; they cannot be edited locally.\", width, \"\")));\n return lines;\n }\n // Native Pi pending-messages display (ground-truth labels/colors) or\n // an older bridge without the renderer members.\n const lines: string[] = [\"\"];\n const innerWidth = Math.max(0, width - 2);\n const dequeueHint = (options.keybindings ?? getKeybindings()).getKeys(\"app.message.dequeue\").join(\"/\") || DEQUEUE_FALLBACK;\n for (const row of rows) {\n const label = bridge ? bridge.laneLabel(row.lane) : NATIVE_LANE_LABEL[row.lane];\n const marker = row.selected ? \"\u203A \" : row.paused ? \"\u23F8 \" : \"\";\n const note = row.removed\n ? \" \u00B7 removed on save\"\n : row.paused\n ? \" \u00B7 paused\"\n : \"\";\n const color: ThemeColor = row.state === \"dispatched\"\n ? \"dim\"\n : bridge ? bridge.laneColor(row.lane) as ThemeColor : \"dim\";\n lines.push(\n ` ${theme.fg(color, truncateToWidth(`${marker}${label}: ${row.text.replace(/\\n/g, \" \")}${note}`, innerWidth, \"\u2026\"))} `,\n );\n }\n const hint = queue.length > 0 ? `\u21B3 ${dequeueHint} to edit queued messages` : \"\u21B3 Waiting for child delivery\";\n lines.push(` ${theme.fg(\"dim\", truncateToWidth(hint, innerWidth, \"\u2026\"))} `);\n return lines;\n },\n\n handleInput(data) {\n if (disposed) return false;\n if (!editSession) {\n if (queue.length === 0) return false;\n if (!options.editor?.getText().trim() && matchesKey(data, Key.enter)) {\n const head = queue.peek();\n if (head) { queue.setPaused(head.id, false); void this.submit(head.lane); }\n return true;\n }\n if (actionMatches(data, \"app.message.dequeue\", (input) => matchesKey(input, DEQUEUE_FALLBACK))) {\n return startEditing();\n }\n return false;\n }\n const session = editSession;\n const editor = options.editor;\n // Navigation mirrors the extension: configured dequeue action moves to\n // the previous row, its mirrored twin moves to the next.\n if (actionMatches(data, \"app.message.dequeue\", (input) => matchesKey(input, DEQUEUE_FALLBACK)) && editor) {\n const ordered = queue.snapshot();\n const index = ordered.findIndex((item) => item.id === session.selectedId);\n const target = index <= 0 ? ordered.at(-1) : ordered[index - 1];\n if (target) editor.setText(session.select(target, editor.getText()));\n requestRender();\n return true;\n }\n const nextKeys = dequeueKeys();\n if (nextKeys.length > 0 && nextKeys.some((key) => matchesKey(data, key as KeyId)) && editor) {\n const ordered = queue.snapshot();\n const index = ordered.findIndex((item) => item.id === session.selectedId);\n const target = index === -1 || index === ordered.length - 1 ? ordered[0] : ordered[index + 1];\n if (target) editor.setText(session.select(target, editor.getText()));\n requestRender();\n return true;\n }\n if (matchesKey(data, REMOVE_ROW_KEY)) {\n session.toggleRemoved(session.selectedId);\n requestRender();\n return true;\n }\n if (matchesKey(data, PAUSE_ROW_KEY)) {\n session.togglePaused(session.selectedId);\n requestRender();\n return true;\n }\n if (matchesOptionArrow(data, \"left\")) {\n session.setLane(session.selectedId, \"followUp\");\n requestRender();\n return true;\n }\n if (matchesOptionArrow(data, \"right\")) {\n session.setLane(session.selectedId, \"steer\");\n requestRender();\n return true;\n }\n if (matchesKey(data, TOGGLE_LANE_KEY)) {\n const current = queue.get(session.selectedId)?.lane;\n if (current) session.setLane(session.selectedId, current === \"steer\" ? \"followUp\" : \"steer\");\n requestRender();\n return true;\n }\n if (\n actionMatches(data, \"tui.input.submit\", (input) => matchesKey(input, Key.enter))\n || actionMatches(data, \"app.message.followUp\", () => false)\n ) {\n return finishEditing(true);\n }\n if (actionMatches(data, \"app.interrupt\", (input) => matchesKey(input, Key.escape))) {\n return finishEditing(false);\n }\n editor?.handleInput?.(data);\n return true;\n },\n\n syncSnapshot(entries) {\n if (disposed || dispatched.length === 0) {\n // Still record identities so a pre-dispatch baseline exists even\n // before anything is queued.\n for (const entry of entries) {\n if (!seenIds.has(entry.id)) seenIds.add(entry.id);\n }\n return 0;\n }\n // Fold the snapshot in first: historical entries (initial baseline,\n // older transcript pages) register identity without creating frontier;\n // live unseen entries extend the per-text live-append frontier.\n for (const entry of entries) {\n if (seenIds.has(entry.id)) continue;\n seenIds.add(entry.id);\n if (entry.historical) continue;\n const key = entry.text.trim();\n liveTextCounts.set(key, (liveTextCounts.get(key) ?? 0) + 1);\n }\n let retired = 0;\n const consume = (entry: ConversationSnapshotEntry) => {\n consumedIds.add(entry.id);\n if (!entry.historical) {\n const key = entry.text.trim();\n const remaining = (liveTextCounts.get(key) ?? 0) - 1;\n if (remaining > 0) liveTextCounts.set(key, remaining);\n else liveTextCounts.delete(key);\n }\n };\n const frontierEntry = (row: DispatchedRow): ConversationSnapshotEntry | undefined => {\n // 1. Expected stable native identity (actor envelope/message id):\n // any entry carrying it confirms delivery outright.\n if (row.expectedId) {\n const match = entries.find((entry) => entry.id === row.expectedId && !consumedIds.has(entry.id));\n if (match) return match;\n }\n // 2. Live-append frontier beyond the historical baseline: only\n // entries that arrived live after dispatch, counted per text so\n // duplicate rows retire one-for-one. History and older pages\n // never qualify.\n for (const entry of entries) {\n if (entry.historical || consumedIds.has(entry.id)) continue;\n if (entry.text.trim() === row.text.trim() && (liveTextCounts.get(entry.text.trim()) ?? 0) > 0) {\n return { id: entry.id, text: entry.text.trim() };\n }\n }\n return undefined;\n };\n for (let index = dispatched.length - 1; index >= 0; index -= 1) {\n const row = dispatched[index];\n if (!row) continue;\n const confirmed = frontierEntry(row);\n if (!confirmed) continue;\n consume(confirmed);\n dispatched.splice(index, 1);\n retired += 1;\n }\n if (retired > 0) {\n notify(`${retired} queued row${retired === 1 ? \"\" : \"s\"} confirmed delivered \u2192 ${targetLabel}`, \"info\");\n requestRender();\n }\n return retired;\n },\n\n retireAll(reason) {\n if (disposed) return 0;\n const count = queue.length + dispatched.length;\n queue.clear();\n dispatched.length = 0;\n editSession = undefined;\n if (count > 0) {\n const suffix = reason ? ` (${reason})` : \"\";\n notify(`Retired ${count} queued row${count === 1 ? \"\" : \"s\"} for ${targetLabel}${suffix}`, \"info\");\n requestRender();\n }\n return count;\n },\n\n pendingCount() {\n if (disposed) return 0;\n return queue.length + dispatched.length;\n },\n\n dispose({ retain = false } = {}) {\n if (disposed) return;\n disposed = true;\n editSession = undefined;\n if (retain) {\n // Rows stay parked: in extension mode the bridge retains them per\n // targetId for re-adoption when the target is focused again.\n return;\n }\n queue.clear();\n dispatched.length = 0;\n if (bridge) emitHandshake(\"release\");\n },\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,uBAAuB;AAGhC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAAA;AAAA,EACA;AAAA,EACA,OAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,gBAAAC;AAAA,OAEK;;;AChBP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AAEP,SAAS,wBAAwB;AAwDjC,IAAM,4BAA4B;AAElC,IAAM,YAAY,CAAC,UAA2B;AAC5C,MAAI,UAAU,OAAW,QAAO;AAChC,MAAI;AACF,WAAO,KAAK,UAAU,KAAK,KAAK;AAAA,EAClC,QAAQ;AACN,WAAO,kBAAkB,OAAO,KAAK,CAAC;AAAA,EACxC;AACF;AAiDO,IAAM,uCAAN,MAA2C;AAAA,EA4BhD,YACmB,KACA,OACA,kBAA+D,CAAC,GACjF;AAHiB;AACA;AACA;AAEjB,SAAK,sBAAsB,MAAY;AACrC,UAAI,KAAK,SAAU;AACnB,WAAK,WAAW;AAChB,WAAK,IAAI,cAAc;AAAA,IACzB;AAAA,EACF;AAAA,EArCiB,iBAAiB,o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A,EAC9B;AACF;",
|
|
6
6
|
"names": ["getKeybindings", "Key", "matchesKey", "truncateToWidth", "visibleWidth", "component", "lines", "errorText", "visibleWidth", "truncateToWidth", "keys", "getKeybindings", "matchesKey", "Key"]
|
|
7
7
|
}
|