@kolisachint/hoocode-agent 0.5.37 → 0.5.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.5.38] - 2026-08-27
4
+
5
+ ### Fixed
6
+
7
+ - A radar run no longer lands hard against the turn that introduced it. The
8
+ rows of a run stack without gaps on purpose — one line each, they only read
9
+ as a map when nothing separates them — but the same rule left the *first*
10
+ row with nothing above it either, so the prose and the run below it ran
11
+ together as one paragraph. The gap belongs to the run rather than to its
12
+ rows: one blank line at the top of the chain, and the rows go on stacking
13
+ underneath it. Radar only, and only where the blocks are not already drawing
14
+ a spacer of their own, so an opened run and every other view are unchanged.
15
+
16
+ - The cut-out themes' paper shadow reads as one edge again. Two defects made it
17
+ read as debris instead. The shadow's right-hand column followed the cut edge
18
+ in front of it, stepping in a column on roughly one row in five — and since
19
+ `▌` paints half a cell, a one-column step leaves *no* overlap between one
20
+ row's mark and the next, so what should have been an edge broke into a dashed
21
+ staircase. It was the loudest thing on the block, too: the sheet's own edge is
22
+ a quiet colour against the page, so the only part of the cut anyone could see
23
+ was the shadow coming apart. The cut now moves the sheet and never the shadow,
24
+ and a nicked row shows its cut as a column of page between the two, which is
25
+ what a nick looks like.
26
+
27
+ The bottom run also stopped a cell short of that column, leaving the corner
28
+ open where the two shadows should have met. It now ends underneath it. A theme
29
+ with `paperShadow` but no gutter is unchanged — there is no column there to
30
+ meet, and a run reaching past the last cell would wrap.
31
+
3
32
  ## [0.5.37] - 2026-08-25
4
33
 
5
34
  ### Fixed
@@ -24,7 +24,11 @@ export declare class ToolChainComponent extends Container {
24
24
  /** The newest run in the transcript; radar marks it. */
25
25
  private latest;
26
26
  private memo?;
27
+ /** Lead-in memo, keyed on the rows it wraps, so the array stays stable. */
28
+ private leadIn?;
27
29
  constructor(view: ToolOutputView);
30
+ /** Every cache this chain keeps. The two go stale for the same reasons. */
31
+ private forget;
28
32
  add(block: ToolExecutionComponent): void;
29
33
  /** True until the agent speaks or the turn settles. */
30
34
  get isOpen(): boolean;
@@ -68,7 +72,22 @@ export declare class ToolChainComponent extends Container {
68
72
  * one, so this is the common case, not an edge.
69
73
  */
70
74
  private isCollapsed;
75
+ /**
76
+ * The blank row that holds a run off whatever came before it.
77
+ *
78
+ * Radar's rows stack without gaps on purpose, and that is right *between*
79
+ * rows — but it left the first row of a run pressed against the prose that
80
+ * introduced it, with the turn above and the run below reading as one
81
+ * paragraph. The gap belongs to the run rather than to its rows: one blank
82
+ * line at the top of the chain, and the rows go on stacking underneath it.
83
+ *
84
+ * Only radar needs it. Every other view gives each block a leading spacer of
85
+ * its own, and so does a radar block that has been opened, so asking the
86
+ * first block whether it draws one keeps the two from doubling up.
87
+ */
88
+ private needsLeadIn;
71
89
  render(width: number): string[];
90
+ private rows;
72
91
  /**
73
92
  * Each failed call's reason, indented under the chain line.
74
93
  *
@@ -1 +1 @@
1
- {"version":3,"file":"tool-chain.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-chain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAiC,MAAM,0BAA0B,CAAC;AACpG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAGxE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE;;;;;;;;;;;;;GAaG;AACH,qBAAa,kBAAmB,SAAQ,SAAS;IAChD,OAAO,CAAC,MAAM,CAAgC;IAC9C,OAAO,CAAC,IAAI,CAAiB;IAC7B,OAAO,CAAC,KAAK,CAAyB;IACtC,8DAA8D;IAC9D,OAAO,CAAC,MAAM,CAAS;IACvB,wDAAwD;IACxD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,IAAI,CAAC,CAAmC;IAEhD,YAAY,IAAI,EAAE,cAAc,EAG/B;IAED,GAAG,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI,CAIvC;IAED,uDAAuD;IACvD,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,8EAA8E;IAC9E,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,IAAI,UAAU,IAAI,SAAS,sBAAsB,EAAE,CAElD;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAG3C;IAED,OAAO,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAIlC;IAED,2EAA2E;IAC3E,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAInC;IAED,iFAAiF;IACjF,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAG/B;IAED;;;;;;;OAOG;IACH,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAI/B;IAEQ,UAAU,IAAI,IAAI,CAG1B;IAED;;;;;;;;;OASG;IACH,OAAO,CAAC,WAAW;IAIV,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAgDvC;IAED;;;;;;OAMG;IACH,OAAO,CAAC,YAAY;CAcpB;AAED,4CAA4C;AAC5C,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,GAAG,KAAK,IAAI,kBAAkB,CAEzE","sourcesContent":["import { type Component, Container, truncateToWidth, visibleWidth } from \"@kolisachint/hoocode-tui\";\nimport type { ToolOutputView } from \"../../../core/tool-output-view.js\";\nimport { theme } from \"../theme/theme.js\";\nimport { type ChainState, chainPhrase, chainSegments, chainStats } from \"./tool-chain-summary.js\";\nimport type { ToolExecutionComponent } from \"./tool-execution.js\";\n\n/**\n * A run of consecutive tool calls, rendered as one line in the radar view.\n *\n * The chain owns its blocks rather than sitting beside them, so there is one\n * place that decides whether you are looking at a summary or at the calls. In\n * every view but a collapsed radar it is a plain pass-through container and the\n * blocks render exactly as they always did.\n *\n * A chain closes when the agent next speaks, or when the turn settles. Closing\n * early matters more than it looks: rewriting a line that has scrolled above\n * the viewport forces the TUI into a full redraw, which clears the terminal's\n * scrollback. Chains that close while they are still the bottom of the screen\n * flip for the price of one line.\n */\nexport class ToolChainComponent extends Container {\n\tprivate blocks: ToolExecutionComponent[] = [];\n\tprivate view: ToolOutputView;\n\tprivate state: ChainState = \"running\";\n\t/** Opened into its per-call rows by `app.tools.unfoldOne`. */\n\tprivate opened = false;\n\t/** The newest run in the transcript; radar marks it. */\n\tprivate latest = false;\n\tprivate memo?: { width: number; out: string[] };\n\n\tconstructor(view: ToolOutputView) {\n\t\tsuper();\n\t\tthis.view = view;\n\t}\n\n\tadd(block: ToolExecutionComponent): void {\n\t\tthis.blocks.push(block);\n\t\tthis.addChild(block);\n\t\tthis.memo = undefined;\n\t}\n\n\t/** True until the agent speaks or the turn settles. */\n\tget isOpen(): boolean {\n\t\treturn this.state === \"running\";\n\t}\n\n\tget isOpened(): boolean {\n\t\treturn this.opened;\n\t}\n\n\t/** Whether a summary line is standing in for this chain's calls right now. */\n\tget isSummarised(): boolean {\n\t\treturn this.isCollapsed();\n\t}\n\n\tget isEmpty(): boolean {\n\t\treturn this.blocks.length === 0;\n\t}\n\n\tget toolBlocks(): readonly ToolExecutionComponent[] {\n\t\treturn this.blocks;\n\t}\n\n\t/**\n\t * Settle the chain.\n\t *\n\t * `interrupted` keeps the running rendering, because the settled phrase is a\n\t * claim about what the run amounted to and a run cut off partway through has\n\t * no such claim to make — the same reason an aborted turn's plan items settle\n\t * to cancelled rather than done.\n\t */\n\tclose(outcome: \"done\" | \"interrupted\"): void {\n\t\tthis.state = outcome;\n\t\tthis.memo = undefined;\n\t}\n\n\tsetView(view: ToolOutputView): void {\n\t\tthis.view = view;\n\t\tthis.memo = undefined;\n\t\tfor (const block of this.blocks) block.setView(view);\n\t}\n\n\t/** The global expand key opens every block, which also opens the chain. */\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.opened = expanded;\n\t\tthis.memo = undefined;\n\t\tfor (const block of this.blocks) block.setExpanded(expanded);\n\t}\n\n\t/** `alt+u` in radar: open this chain into its per-call rows, or fold it back. */\n\tsetOpened(opened: boolean): void {\n\t\tthis.opened = opened;\n\t\tthis.memo = undefined;\n\t}\n\n\t/**\n\t * Mark this run as the newest in the transcript, or no longer it.\n\t *\n\t * The per-call rows carry the same mark, but they are not what radar usually\n\t * shows: a run of more than one call folds to this single line, so without\n\t * marking the line too the stroke would be invisible in the view it was\n\t * built for.\n\t */\n\tsetLatest(latest: boolean): void {\n\t\tif (this.latest === latest) return;\n\t\tthis.latest = latest;\n\t\tthis.memo = undefined;\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.memo = undefined;\n\t}\n\n\t/**\n\t * Whether this chain is currently drawn as a single summary line.\n\t *\n\t * A chain of one is not summarised. Its phrase would be `Ran npm run check`,\n\t * which is strictly less than the radar row it replaced: the row names the\n\t * tool and how much came back, and the phrase drops both to say the same\n\t * thing in prose. Summarising is only worth a lossy rewrite when there is\n\t * more than one call to fold — and by measurement most chains have exactly\n\t * one, so this is the common case, not an edge.\n\t */\n\tprivate isCollapsed(): boolean {\n\t\treturn this.view === \"radar\" && !this.opened && this.blocks.length > 1;\n\t}\n\n\toverride render(width: number): string[] {\n\t\tif (!this.isCollapsed()) return super.render(width);\n\t\tif (this.memo && this.memo.width === width) return this.memo.out;\n\n\t\tconst entries = this.blocks.map((block) => block.chainEntry());\n\t\tconst running = this.state === \"running\";\n\t\tconst glyph = running ? \"◐\" : \"●\";\n\t\tconst glyphTone = entries.some((e) => e.isError) ? \"error\" : running ? \"warning\" : \"success\";\n\n\t\t// While it runs the chain shows its shape in order; once it is over, what\n\t\t// it amounted to. See tool-chain-summary.ts for why they differ.\n\t\tlet leftPlain: string;\n\t\tlet leftStyled: string;\n\t\tif (this.state === \"done\") {\n\t\t\tconst phrase = chainPhrase(entries);\n\t\t\tleftPlain = phrase;\n\t\t\tleftStyled = theme.fg(\"toolTitle\", phrase);\n\t\t} else {\n\t\t\tconst segments = chainSegments(entries);\n\t\t\tconst sep = \" › \";\n\t\t\tleftPlain = segments.map((s) => s.label).join(sep) + (running ? \"…\" : \"\");\n\t\t\tleftStyled =\n\t\t\t\tsegments\n\t\t\t\t\t.map((s) =>\n\t\t\t\t\t\ttheme.fg(s.tone === \"error\" ? \"error\" : s.tone === \"running\" ? \"warning\" : \"toolTitle\", s.label),\n\t\t\t\t\t)\n\t\t\t\t\t.join(theme.fg(\"dim\", sep)) + (running ? theme.fg(\"dim\", \"…\") : \"\");\n\t\t}\n\n\t\tconst stats = chainStats(entries, this.state);\n\t\t// The marker stroke runs over what you read and stops before the stats,\n\t\t// the same shape it takes on a per-call row.\n\t\tconst stroke = this.latest && theme.hasBg(\"activeToolBg\");\n\t\tconst mark = (text: string) => (stroke ? theme.bg(\"activeToolBg\", text) : text);\n\t\t// \" ● \" + left, then stats flush right when there is room for both.\n\t\tconst prefix = `${glyph} `;\n\t\tconst budget = Math.max(0, width - 1 - visibleWidth(prefix));\n\t\tlet line: string;\n\t\tif (visibleWidth(leftPlain) + 2 + visibleWidth(stats) <= budget) {\n\t\t\tconst pad = \" \".repeat(budget - visibleWidth(leftPlain) - visibleWidth(stats));\n\t\t\tline = ` ${theme.fg(glyphTone, prefix)}${mark(leftStyled)}${pad}${theme.fg(\"muted\", stats)}`;\n\t\t} else {\n\t\t\tline = ` ${theme.fg(glyphTone, prefix)}${mark(truncateToWidth(leftStyled, budget))}`;\n\t\t}\n\n\t\tconst out = [line, ...this.failureLines(width)];\n\t\tthis.memo = { width, out };\n\t\treturn out;\n\t}\n\n\t/**\n\t * Each failed call's reason, indented under the chain line.\n\t *\n\t * A collapsed chain hides its blocks, so without this a failure would be a\n\t * count in the stats and nothing else. Whatever else these views fold away,\n\t * they never fold away why something broke.\n\t */\n\tprivate failureLines(width: number): string[] {\n\t\tconst lines: string[] = [];\n\t\tfor (const block of this.blocks) {\n\t\t\tconst entry = block.chainEntry();\n\t\t\tif (!entry.isError) continue;\n\t\t\tconst header = ` ${theme.fg(\"error\", \"✗\")} ${theme.fg(\"toolTitle\", entry.tool)} ${theme.fg(\"toolOutput\", entry.subject)}`;\n\t\t\tlines.push(truncateToWidth(header, width));\n\t\t\tfor (const raw of block.errorText().split(\"\\n\")) {\n\t\t\t\tif (!raw.trim()) continue;\n\t\t\t\tlines.push(truncateToWidth(` ${theme.fg(\"toolOutput\", raw)}`, width));\n\t\t\t}\n\t\t}\n\t\treturn lines;\n\t}\n}\n\n/** Narrow a transcript child to a chain. */\nexport function isToolChain(child: Component): child is ToolChainComponent {\n\treturn child instanceof ToolChainComponent;\n}\n"]}
1
+ {"version":3,"file":"tool-chain.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-chain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAiC,MAAM,0BAA0B,CAAC;AACpG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAGxE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE;;;;;;;;;;;;;GAaG;AACH,qBAAa,kBAAmB,SAAQ,SAAS;IAChD,OAAO,CAAC,MAAM,CAAgC;IAC9C,OAAO,CAAC,IAAI,CAAiB;IAC7B,OAAO,CAAC,KAAK,CAAyB;IACtC,8DAA8D;IAC9D,OAAO,CAAC,MAAM,CAAS;IACvB,wDAAwD;IACxD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,IAAI,CAAC,CAAmC;IAChD,2EAA2E;IAC3E,OAAO,CAAC,MAAM,CAAC,CAAmC;IAElD,YAAY,IAAI,EAAE,cAAc,EAG/B;IAED,2EAA2E;IAC3E,OAAO,CAAC,MAAM;IAKd,GAAG,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI,CAIvC;IAED,uDAAuD;IACvD,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,8EAA8E;IAC9E,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,IAAI,UAAU,IAAI,SAAS,sBAAsB,EAAE,CAElD;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAG3C;IAED,OAAO,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAIlC;IAED,2EAA2E;IAC3E,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAInC;IAED,iFAAiF;IACjF,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAG/B;IAED;;;;;;;OAOG;IACH,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAI/B;IAEQ,UAAU,IAAI,IAAI,CAG1B;IAED;;;;;;;;;OASG;IACH,OAAO,CAAC,WAAW;IAInB;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,WAAW;IAMV,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CASvC;IAED,OAAO,CAAC,IAAI;IAkDZ;;;;;;OAMG;IACH,OAAO,CAAC,YAAY;CAcpB;AAED,4CAA4C;AAC5C,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,GAAG,KAAK,IAAI,kBAAkB,CAEzE","sourcesContent":["import { type Component, Container, truncateToWidth, visibleWidth } from \"@kolisachint/hoocode-tui\";\nimport type { ToolOutputView } from \"../../../core/tool-output-view.js\";\nimport { theme } from \"../theme/theme.js\";\nimport { type ChainState, chainPhrase, chainSegments, chainStats } from \"./tool-chain-summary.js\";\nimport type { ToolExecutionComponent } from \"./tool-execution.js\";\n\n/**\n * A run of consecutive tool calls, rendered as one line in the radar view.\n *\n * The chain owns its blocks rather than sitting beside them, so there is one\n * place that decides whether you are looking at a summary or at the calls. In\n * every view but a collapsed radar it is a plain pass-through container and the\n * blocks render exactly as they always did.\n *\n * A chain closes when the agent next speaks, or when the turn settles. Closing\n * early matters more than it looks: rewriting a line that has scrolled above\n * the viewport forces the TUI into a full redraw, which clears the terminal's\n * scrollback. Chains that close while they are still the bottom of the screen\n * flip for the price of one line.\n */\nexport class ToolChainComponent extends Container {\n\tprivate blocks: ToolExecutionComponent[] = [];\n\tprivate view: ToolOutputView;\n\tprivate state: ChainState = \"running\";\n\t/** Opened into its per-call rows by `app.tools.unfoldOne`. */\n\tprivate opened = false;\n\t/** The newest run in the transcript; radar marks it. */\n\tprivate latest = false;\n\tprivate memo?: { width: number; out: string[] };\n\t/** Lead-in memo, keyed on the rows it wraps, so the array stays stable. */\n\tprivate leadIn?: { src: string[]; out: string[] };\n\n\tconstructor(view: ToolOutputView) {\n\t\tsuper();\n\t\tthis.view = view;\n\t}\n\n\t/** Every cache this chain keeps. The two go stale for the same reasons. */\n\tprivate forget(): void {\n\t\tthis.memo = undefined;\n\t\tthis.leadIn = undefined;\n\t}\n\n\tadd(block: ToolExecutionComponent): void {\n\t\tthis.blocks.push(block);\n\t\tthis.addChild(block);\n\t\tthis.forget();\n\t}\n\n\t/** True until the agent speaks or the turn settles. */\n\tget isOpen(): boolean {\n\t\treturn this.state === \"running\";\n\t}\n\n\tget isOpened(): boolean {\n\t\treturn this.opened;\n\t}\n\n\t/** Whether a summary line is standing in for this chain's calls right now. */\n\tget isSummarised(): boolean {\n\t\treturn this.isCollapsed();\n\t}\n\n\tget isEmpty(): boolean {\n\t\treturn this.blocks.length === 0;\n\t}\n\n\tget toolBlocks(): readonly ToolExecutionComponent[] {\n\t\treturn this.blocks;\n\t}\n\n\t/**\n\t * Settle the chain.\n\t *\n\t * `interrupted` keeps the running rendering, because the settled phrase is a\n\t * claim about what the run amounted to and a run cut off partway through has\n\t * no such claim to make — the same reason an aborted turn's plan items settle\n\t * to cancelled rather than done.\n\t */\n\tclose(outcome: \"done\" | \"interrupted\"): void {\n\t\tthis.state = outcome;\n\t\tthis.forget();\n\t}\n\n\tsetView(view: ToolOutputView): void {\n\t\tthis.view = view;\n\t\tthis.forget();\n\t\tfor (const block of this.blocks) block.setView(view);\n\t}\n\n\t/** The global expand key opens every block, which also opens the chain. */\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.opened = expanded;\n\t\tthis.forget();\n\t\tfor (const block of this.blocks) block.setExpanded(expanded);\n\t}\n\n\t/** `alt+u` in radar: open this chain into its per-call rows, or fold it back. */\n\tsetOpened(opened: boolean): void {\n\t\tthis.opened = opened;\n\t\tthis.forget();\n\t}\n\n\t/**\n\t * Mark this run as the newest in the transcript, or no longer it.\n\t *\n\t * The per-call rows carry the same mark, but they are not what radar usually\n\t * shows: a run of more than one call folds to this single line, so without\n\t * marking the line too the stroke would be invisible in the view it was\n\t * built for.\n\t */\n\tsetLatest(latest: boolean): void {\n\t\tif (this.latest === latest) return;\n\t\tthis.latest = latest;\n\t\tthis.forget();\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.forget();\n\t}\n\n\t/**\n\t * Whether this chain is currently drawn as a single summary line.\n\t *\n\t * A chain of one is not summarised. Its phrase would be `Ran npm run check`,\n\t * which is strictly less than the radar row it replaced: the row names the\n\t * tool and how much came back, and the phrase drops both to say the same\n\t * thing in prose. Summarising is only worth a lossy rewrite when there is\n\t * more than one call to fold — and by measurement most chains have exactly\n\t * one, so this is the common case, not an edge.\n\t */\n\tprivate isCollapsed(): boolean {\n\t\treturn this.view === \"radar\" && !this.opened && this.blocks.length > 1;\n\t}\n\n\t/**\n\t * The blank row that holds a run off whatever came before it.\n\t *\n\t * Radar's rows stack without gaps on purpose, and that is right *between*\n\t * rows — but it left the first row of a run pressed against the prose that\n\t * introduced it, with the turn above and the run below reading as one\n\t * paragraph. The gap belongs to the run rather than to its rows: one blank\n\t * line at the top of the chain, and the rows go on stacking underneath it.\n\t *\n\t * Only radar needs it. Every other view gives each block a leading spacer of\n\t * its own, and so does a radar block that has been opened, so asking the\n\t * first block whether it draws one keeps the two from doubling up.\n\t */\n\tprivate needsLeadIn(): boolean {\n\t\tif (this.view !== \"radar\") return false;\n\t\tif (this.isCollapsed()) return true;\n\t\treturn this.blocks[0]?.drawsLeadingGap() === false;\n\t}\n\n\toverride render(width: number): string[] {\n\t\tconst rows = this.rows(width);\n\t\tif (rows.length === 0 || !this.needsLeadIn()) return rows;\n\t\t// Keep the wrapped array reference-stable: the TUI diffs whole subtrees\n\t\t// by identity, and a fresh array every frame would defeat that.\n\t\tif (this.leadIn?.src === rows) return this.leadIn.out;\n\t\tconst out = [\"\", ...rows];\n\t\tthis.leadIn = { src: rows, out };\n\t\treturn out;\n\t}\n\n\tprivate rows(width: number): string[] {\n\t\tif (!this.isCollapsed()) return super.render(width);\n\t\tif (this.memo && this.memo.width === width) return this.memo.out;\n\n\t\tconst entries = this.blocks.map((block) => block.chainEntry());\n\t\tconst running = this.state === \"running\";\n\t\tconst glyph = running ? \"◐\" : \"●\";\n\t\tconst glyphTone = entries.some((e) => e.isError) ? \"error\" : running ? \"warning\" : \"success\";\n\n\t\t// While it runs the chain shows its shape in order; once it is over, what\n\t\t// it amounted to. See tool-chain-summary.ts for why they differ.\n\t\tlet leftPlain: string;\n\t\tlet leftStyled: string;\n\t\tif (this.state === \"done\") {\n\t\t\tconst phrase = chainPhrase(entries);\n\t\t\tleftPlain = phrase;\n\t\t\tleftStyled = theme.fg(\"toolTitle\", phrase);\n\t\t} else {\n\t\t\tconst segments = chainSegments(entries);\n\t\t\tconst sep = \" › \";\n\t\t\tleftPlain = segments.map((s) => s.label).join(sep) + (running ? \"…\" : \"\");\n\t\t\tleftStyled =\n\t\t\t\tsegments\n\t\t\t\t\t.map((s) =>\n\t\t\t\t\t\ttheme.fg(s.tone === \"error\" ? \"error\" : s.tone === \"running\" ? \"warning\" : \"toolTitle\", s.label),\n\t\t\t\t\t)\n\t\t\t\t\t.join(theme.fg(\"dim\", sep)) + (running ? theme.fg(\"dim\", \"…\") : \"\");\n\t\t}\n\n\t\tconst stats = chainStats(entries, this.state);\n\t\t// The marker stroke runs over what you read and stops before the stats,\n\t\t// the same shape it takes on a per-call row.\n\t\tconst stroke = this.latest && theme.hasBg(\"activeToolBg\");\n\t\tconst mark = (text: string) => (stroke ? theme.bg(\"activeToolBg\", text) : text);\n\t\t// \" ● \" + left, then stats flush right when there is room for both.\n\t\tconst prefix = `${glyph} `;\n\t\tconst budget = Math.max(0, width - 1 - visibleWidth(prefix));\n\t\tlet line: string;\n\t\tif (visibleWidth(leftPlain) + 2 + visibleWidth(stats) <= budget) {\n\t\t\tconst pad = \" \".repeat(budget - visibleWidth(leftPlain) - visibleWidth(stats));\n\t\t\tline = ` ${theme.fg(glyphTone, prefix)}${mark(leftStyled)}${pad}${theme.fg(\"muted\", stats)}`;\n\t\t} else {\n\t\t\tline = ` ${theme.fg(glyphTone, prefix)}${mark(truncateToWidth(leftStyled, budget))}`;\n\t\t}\n\n\t\tconst out = [line, ...this.failureLines(width)];\n\t\tthis.memo = { width, out };\n\t\treturn out;\n\t}\n\n\t/**\n\t * Each failed call's reason, indented under the chain line.\n\t *\n\t * A collapsed chain hides its blocks, so without this a failure would be a\n\t * count in the stats and nothing else. Whatever else these views fold away,\n\t * they never fold away why something broke.\n\t */\n\tprivate failureLines(width: number): string[] {\n\t\tconst lines: string[] = [];\n\t\tfor (const block of this.blocks) {\n\t\t\tconst entry = block.chainEntry();\n\t\t\tif (!entry.isError) continue;\n\t\t\tconst header = ` ${theme.fg(\"error\", \"✗\")} ${theme.fg(\"toolTitle\", entry.tool)} ${theme.fg(\"toolOutput\", entry.subject)}`;\n\t\t\tlines.push(truncateToWidth(header, width));\n\t\t\tfor (const raw of block.errorText().split(\"\\n\")) {\n\t\t\t\tif (!raw.trim()) continue;\n\t\t\t\tlines.push(truncateToWidth(` ${theme.fg(\"toolOutput\", raw)}`, width));\n\t\t\t}\n\t\t}\n\t\treturn lines;\n\t}\n}\n\n/** Narrow a transcript child to a chain. */\nexport function isToolChain(child: Component): child is ToolChainComponent {\n\treturn child instanceof ToolChainComponent;\n}\n"]}
@@ -24,14 +24,21 @@ export class ToolChainComponent extends Container {
24
24
  /** The newest run in the transcript; radar marks it. */
25
25
  latest = false;
26
26
  memo;
27
+ /** Lead-in memo, keyed on the rows it wraps, so the array stays stable. */
28
+ leadIn;
27
29
  constructor(view) {
28
30
  super();
29
31
  this.view = view;
30
32
  }
33
+ /** Every cache this chain keeps. The two go stale for the same reasons. */
34
+ forget() {
35
+ this.memo = undefined;
36
+ this.leadIn = undefined;
37
+ }
31
38
  add(block) {
32
39
  this.blocks.push(block);
33
40
  this.addChild(block);
34
- this.memo = undefined;
41
+ this.forget();
35
42
  }
36
43
  /** True until the agent speaks or the turn settles. */
37
44
  get isOpen() {
@@ -60,25 +67,25 @@ export class ToolChainComponent extends Container {
60
67
  */
61
68
  close(outcome) {
62
69
  this.state = outcome;
63
- this.memo = undefined;
70
+ this.forget();
64
71
  }
65
72
  setView(view) {
66
73
  this.view = view;
67
- this.memo = undefined;
74
+ this.forget();
68
75
  for (const block of this.blocks)
69
76
  block.setView(view);
70
77
  }
71
78
  /** The global expand key opens every block, which also opens the chain. */
72
79
  setExpanded(expanded) {
73
80
  this.opened = expanded;
74
- this.memo = undefined;
81
+ this.forget();
75
82
  for (const block of this.blocks)
76
83
  block.setExpanded(expanded);
77
84
  }
78
85
  /** `alt+u` in radar: open this chain into its per-call rows, or fold it back. */
79
86
  setOpened(opened) {
80
87
  this.opened = opened;
81
- this.memo = undefined;
88
+ this.forget();
82
89
  }
83
90
  /**
84
91
  * Mark this run as the newest in the transcript, or no longer it.
@@ -92,11 +99,11 @@ export class ToolChainComponent extends Container {
92
99
  if (this.latest === latest)
93
100
  return;
94
101
  this.latest = latest;
95
- this.memo = undefined;
102
+ this.forget();
96
103
  }
97
104
  invalidate() {
98
105
  super.invalidate();
99
- this.memo = undefined;
106
+ this.forget();
100
107
  }
101
108
  /**
102
109
  * Whether this chain is currently drawn as a single summary line.
@@ -111,7 +118,39 @@ export class ToolChainComponent extends Container {
111
118
  isCollapsed() {
112
119
  return this.view === "radar" && !this.opened && this.blocks.length > 1;
113
120
  }
121
+ /**
122
+ * The blank row that holds a run off whatever came before it.
123
+ *
124
+ * Radar's rows stack without gaps on purpose, and that is right *between*
125
+ * rows — but it left the first row of a run pressed against the prose that
126
+ * introduced it, with the turn above and the run below reading as one
127
+ * paragraph. The gap belongs to the run rather than to its rows: one blank
128
+ * line at the top of the chain, and the rows go on stacking underneath it.
129
+ *
130
+ * Only radar needs it. Every other view gives each block a leading spacer of
131
+ * its own, and so does a radar block that has been opened, so asking the
132
+ * first block whether it draws one keeps the two from doubling up.
133
+ */
134
+ needsLeadIn() {
135
+ if (this.view !== "radar")
136
+ return false;
137
+ if (this.isCollapsed())
138
+ return true;
139
+ return this.blocks[0]?.drawsLeadingGap() === false;
140
+ }
114
141
  render(width) {
142
+ const rows = this.rows(width);
143
+ if (rows.length === 0 || !this.needsLeadIn())
144
+ return rows;
145
+ // Keep the wrapped array reference-stable: the TUI diffs whole subtrees
146
+ // by identity, and a fresh array every frame would defeat that.
147
+ if (this.leadIn?.src === rows)
148
+ return this.leadIn.out;
149
+ const out = ["", ...rows];
150
+ this.leadIn = { src: rows, out };
151
+ return out;
152
+ }
153
+ rows(width) {
115
154
  if (!this.isCollapsed())
116
155
  return super.render(width);
117
156
  if (this.memo && this.memo.width === width)
@@ -1 +1 @@
1
- {"version":3,"file":"tool-chain.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-chain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEpG,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAmB,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGlG;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IACxC,MAAM,GAA6B,EA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AAC,CAAC,CAAC;YAC3E,CAAC;QACF,CAAC;QACD,OAAO,KAAK,CAAC;IAAA,CACb;CACD;AAED,4CAA4C;AAC5C,MAAM,UAAU,WAAW,CAAC,KAAgB,EAA+B;IAC1E,OAAO,KAAK,YAAY,kBAAkB,CAAC;AAAA,CAC3C","sourcesContent":["import { type Component, Container, truncateToWidth, visibleWidth } from \"@kolisachint/hoocode-tui\";\nimport type { ToolOutputView } from \"../../../core/tool-output-view.js\";\nimport { theme } from \"../theme/theme.js\";\nimport { type ChainState, chainPhrase, chainSegments, chainStats } from \"./tool-chain-summary.js\";\nimport type { ToolExecutionComponent } from \"./tool-execution.js\";\n\n/**\n * A run of consecutive tool calls, rendered as one line in the radar view.\n *\n * The chain owns its blocks rather than sitting beside them, so there is one\n * place that decides whether you are looking at a summary or at the calls. In\n * every view but a collapsed radar it is a plain pass-through container and the\n * blocks render exactly as they always did.\n *\n * A chain closes when the agent next speaks, or when the turn settles. Closing\n * early matters more than it looks: rewriting a line that has scrolled above\n * the viewport forces the TUI into a full redraw, which clears the terminal's\n * scrollback. Chains that close while they are still the bottom of the screen\n * flip for the price of one line.\n */\nexport class ToolChainComponent extends Container {\n\tprivate blocks: ToolExecutionComponent[] = [];\n\tprivate view: ToolOutputView;\n\tprivate state: ChainState = \"running\";\n\t/** Opened into its per-call rows by `app.tools.unfoldOne`. */\n\tprivate opened = false;\n\t/** The newest run in the transcript; radar marks it. */\n\tprivate latest = false;\n\tprivate memo?: { width: number; out: string[] };\n\n\tconstructor(view: ToolOutputView) {\n\t\tsuper();\n\t\tthis.view = view;\n\t}\n\n\tadd(block: ToolExecutionComponent): void {\n\t\tthis.blocks.push(block);\n\t\tthis.addChild(block);\n\t\tthis.memo = undefined;\n\t}\n\n\t/** True until the agent speaks or the turn settles. */\n\tget isOpen(): boolean {\n\t\treturn this.state === \"running\";\n\t}\n\n\tget isOpened(): boolean {\n\t\treturn this.opened;\n\t}\n\n\t/** Whether a summary line is standing in for this chain's calls right now. */\n\tget isSummarised(): boolean {\n\t\treturn this.isCollapsed();\n\t}\n\n\tget isEmpty(): boolean {\n\t\treturn this.blocks.length === 0;\n\t}\n\n\tget toolBlocks(): readonly ToolExecutionComponent[] {\n\t\treturn this.blocks;\n\t}\n\n\t/**\n\t * Settle the chain.\n\t *\n\t * `interrupted` keeps the running rendering, because the settled phrase is a\n\t * claim about what the run amounted to and a run cut off partway through has\n\t * no such claim to make — the same reason an aborted turn's plan items settle\n\t * to cancelled rather than done.\n\t */\n\tclose(outcome: \"done\" | \"interrupted\"): void {\n\t\tthis.state = outcome;\n\t\tthis.memo = undefined;\n\t}\n\n\tsetView(view: ToolOutputView): void {\n\t\tthis.view = view;\n\t\tthis.memo = undefined;\n\t\tfor (const block of this.blocks) block.setView(view);\n\t}\n\n\t/** The global expand key opens every block, which also opens the chain. */\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.opened = expanded;\n\t\tthis.memo = undefined;\n\t\tfor (const block of this.blocks) block.setExpanded(expanded);\n\t}\n\n\t/** `alt+u` in radar: open this chain into its per-call rows, or fold it back. */\n\tsetOpened(opened: boolean): void {\n\t\tthis.opened = opened;\n\t\tthis.memo = undefined;\n\t}\n\n\t/**\n\t * Mark this run as the newest in the transcript, or no longer it.\n\t *\n\t * The per-call rows carry the same mark, but they are not what radar usually\n\t * shows: a run of more than one call folds to this single line, so without\n\t * marking the line too the stroke would be invisible in the view it was\n\t * built for.\n\t */\n\tsetLatest(latest: boolean): void {\n\t\tif (this.latest === latest) return;\n\t\tthis.latest = latest;\n\t\tthis.memo = undefined;\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.memo = undefined;\n\t}\n\n\t/**\n\t * Whether this chain is currently drawn as a single summary line.\n\t *\n\t * A chain of one is not summarised. Its phrase would be `Ran npm run check`,\n\t * which is strictly less than the radar row it replaced: the row names the\n\t * tool and how much came back, and the phrase drops both to say the same\n\t * thing in prose. Summarising is only worth a lossy rewrite when there is\n\t * more than one call to fold — and by measurement most chains have exactly\n\t * one, so this is the common case, not an edge.\n\t */\n\tprivate isCollapsed(): boolean {\n\t\treturn this.view === \"radar\" && !this.opened && this.blocks.length > 1;\n\t}\n\n\toverride render(width: number): string[] {\n\t\tif (!this.isCollapsed()) return super.render(width);\n\t\tif (this.memo && this.memo.width === width) return this.memo.out;\n\n\t\tconst entries = this.blocks.map((block) => block.chainEntry());\n\t\tconst running = this.state === \"running\";\n\t\tconst glyph = running ? \"◐\" : \"●\";\n\t\tconst glyphTone = entries.some((e) => e.isError) ? \"error\" : running ? \"warning\" : \"success\";\n\n\t\t// While it runs the chain shows its shape in order; once it is over, what\n\t\t// it amounted to. See tool-chain-summary.ts for why they differ.\n\t\tlet leftPlain: string;\n\t\tlet leftStyled: string;\n\t\tif (this.state === \"done\") {\n\t\t\tconst phrase = chainPhrase(entries);\n\t\t\tleftPlain = phrase;\n\t\t\tleftStyled = theme.fg(\"toolTitle\", phrase);\n\t\t} else {\n\t\t\tconst segments = chainSegments(entries);\n\t\t\tconst sep = \" › \";\n\t\t\tleftPlain = segments.map((s) => s.label).join(sep) + (running ? \"…\" : \"\");\n\t\t\tleftStyled =\n\t\t\t\tsegments\n\t\t\t\t\t.map((s) =>\n\t\t\t\t\t\ttheme.fg(s.tone === \"error\" ? \"error\" : s.tone === \"running\" ? \"warning\" : \"toolTitle\", s.label),\n\t\t\t\t\t)\n\t\t\t\t\t.join(theme.fg(\"dim\", sep)) + (running ? theme.fg(\"dim\", \"…\") : \"\");\n\t\t}\n\n\t\tconst stats = chainStats(entries, this.state);\n\t\t// The marker stroke runs over what you read and stops before the stats,\n\t\t// the same shape it takes on a per-call row.\n\t\tconst stroke = this.latest && theme.hasBg(\"activeToolBg\");\n\t\tconst mark = (text: string) => (stroke ? theme.bg(\"activeToolBg\", text) : text);\n\t\t// \" ● \" + left, then stats flush right when there is room for both.\n\t\tconst prefix = `${glyph} `;\n\t\tconst budget = Math.max(0, width - 1 - visibleWidth(prefix));\n\t\tlet line: string;\n\t\tif (visibleWidth(leftPlain) + 2 + visibleWidth(stats) <= budget) {\n\t\t\tconst pad = \" \".repeat(budget - visibleWidth(leftPlain) - visibleWidth(stats));\n\t\t\tline = ` ${theme.fg(glyphTone, prefix)}${mark(leftStyled)}${pad}${theme.fg(\"muted\", stats)}`;\n\t\t} else {\n\t\t\tline = ` ${theme.fg(glyphTone, prefix)}${mark(truncateToWidth(leftStyled, budget))}`;\n\t\t}\n\n\t\tconst out = [line, ...this.failureLines(width)];\n\t\tthis.memo = { width, out };\n\t\treturn out;\n\t}\n\n\t/**\n\t * Each failed call's reason, indented under the chain line.\n\t *\n\t * A collapsed chain hides its blocks, so without this a failure would be a\n\t * count in the stats and nothing else. Whatever else these views fold away,\n\t * they never fold away why something broke.\n\t */\n\tprivate failureLines(width: number): string[] {\n\t\tconst lines: string[] = [];\n\t\tfor (const block of this.blocks) {\n\t\t\tconst entry = block.chainEntry();\n\t\t\tif (!entry.isError) continue;\n\t\t\tconst header = ` ${theme.fg(\"error\", \"✗\")} ${theme.fg(\"toolTitle\", entry.tool)} ${theme.fg(\"toolOutput\", entry.subject)}`;\n\t\t\tlines.push(truncateToWidth(header, width));\n\t\t\tfor (const raw of block.errorText().split(\"\\n\")) {\n\t\t\t\tif (!raw.trim()) continue;\n\t\t\t\tlines.push(truncateToWidth(` ${theme.fg(\"toolOutput\", raw)}`, width));\n\t\t\t}\n\t\t}\n\t\treturn lines;\n\t}\n}\n\n/** Narrow a transcript child to a chain. */\nexport function isToolChain(child: Component): child is ToolChainComponent {\n\treturn child instanceof ToolChainComponent;\n}\n"]}
1
+ {"version":3,"file":"tool-chain.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-chain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEpG,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAmB,WAAW,EAAE,aAAa,EA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visibleWidth } from \"@kolisachint/hoocode-tui\";\nimport type { ToolOutputView } from \"../../../core/tool-output-view.js\";\nimport { theme } from \"../theme/theme.js\";\nimport { type ChainState, chainPhrase, chainSegments, chainStats } from \"./tool-chain-summary.js\";\nimport type { ToolExecutionComponent } from \"./tool-execution.js\";\n\n/**\n * A run of consecutive tool calls, rendered as one line in the radar view.\n *\n * The chain owns its blocks rather than sitting beside them, so there is one\n * place that decides whether you are looking at a summary or at the calls. In\n * every view but a collapsed radar it is a plain pass-through container and the\n * blocks render exactly as they always did.\n *\n * A chain closes when the agent next speaks, or when the turn settles. Closing\n * early matters more than it looks: rewriting a line that has scrolled above\n * the viewport forces the TUI into a full redraw, which clears the terminal's\n * scrollback. Chains that close while they are still the bottom of the screen\n * flip for the price of one line.\n */\nexport class ToolChainComponent extends Container {\n\tprivate blocks: ToolExecutionComponent[] = [];\n\tprivate view: ToolOutputView;\n\tprivate state: ChainState = \"running\";\n\t/** Opened into its per-call rows by `app.tools.unfoldOne`. */\n\tprivate opened = false;\n\t/** The newest run in the transcript; radar marks it. */\n\tprivate latest = false;\n\tprivate memo?: { width: number; out: string[] };\n\t/** Lead-in memo, keyed on the rows it wraps, so the array stays stable. */\n\tprivate leadIn?: { src: string[]; out: string[] };\n\n\tconstructor(view: ToolOutputView) {\n\t\tsuper();\n\t\tthis.view = view;\n\t}\n\n\t/** Every cache this chain keeps. The two go stale for the same reasons. */\n\tprivate forget(): void {\n\t\tthis.memo = undefined;\n\t\tthis.leadIn = undefined;\n\t}\n\n\tadd(block: ToolExecutionComponent): void {\n\t\tthis.blocks.push(block);\n\t\tthis.addChild(block);\n\t\tthis.forget();\n\t}\n\n\t/** True until the agent speaks or the turn settles. */\n\tget isOpen(): boolean {\n\t\treturn this.state === \"running\";\n\t}\n\n\tget isOpened(): boolean {\n\t\treturn this.opened;\n\t}\n\n\t/** Whether a summary line is standing in for this chain's calls right now. */\n\tget isSummarised(): boolean {\n\t\treturn this.isCollapsed();\n\t}\n\n\tget isEmpty(): boolean {\n\t\treturn this.blocks.length === 0;\n\t}\n\n\tget toolBlocks(): readonly ToolExecutionComponent[] {\n\t\treturn this.blocks;\n\t}\n\n\t/**\n\t * Settle the chain.\n\t *\n\t * `interrupted` keeps the running rendering, because the settled phrase is a\n\t * claim about what the run amounted to and a run cut off partway through has\n\t * no such claim to make — the same reason an aborted turn's plan items settle\n\t * to cancelled rather than done.\n\t */\n\tclose(outcome: \"done\" | \"interrupted\"): void {\n\t\tthis.state = outcome;\n\t\tthis.forget();\n\t}\n\n\tsetView(view: ToolOutputView): void {\n\t\tthis.view = view;\n\t\tthis.forget();\n\t\tfor (const block of this.blocks) block.setView(view);\n\t}\n\n\t/** The global expand key opens every block, which also opens the chain. */\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.opened = expanded;\n\t\tthis.forget();\n\t\tfor (const block of this.blocks) block.setExpanded(expanded);\n\t}\n\n\t/** `alt+u` in radar: open this chain into its per-call rows, or fold it back. */\n\tsetOpened(opened: boolean): void {\n\t\tthis.opened = opened;\n\t\tthis.forget();\n\t}\n\n\t/**\n\t * Mark this run as the newest in the transcript, or no longer it.\n\t *\n\t * The per-call rows carry the same mark, but they are not what radar usually\n\t * shows: a run of more than one call folds to this single line, so without\n\t * marking the line too the stroke would be invisible in the view it was\n\t * built for.\n\t */\n\tsetLatest(latest: boolean): void {\n\t\tif (this.latest === latest) return;\n\t\tthis.latest = latest;\n\t\tthis.forget();\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.forget();\n\t}\n\n\t/**\n\t * Whether this chain is currently drawn as a single summary line.\n\t *\n\t * A chain of one is not summarised. Its phrase would be `Ran npm run check`,\n\t * which is strictly less than the radar row it replaced: the row names the\n\t * tool and how much came back, and the phrase drops both to say the same\n\t * thing in prose. Summarising is only worth a lossy rewrite when there is\n\t * more than one call to fold — and by measurement most chains have exactly\n\t * one, so this is the common case, not an edge.\n\t */\n\tprivate isCollapsed(): boolean {\n\t\treturn this.view === \"radar\" && !this.opened && this.blocks.length > 1;\n\t}\n\n\t/**\n\t * The blank row that holds a run off whatever came before it.\n\t *\n\t * Radar's rows stack without gaps on purpose, and that is right *between*\n\t * rows — but it left the first row of a run pressed against the prose that\n\t * introduced it, with the turn above and the run below reading as one\n\t * paragraph. The gap belongs to the run rather than to its rows: one blank\n\t * line at the top of the chain, and the rows go on stacking underneath it.\n\t *\n\t * Only radar needs it. Every other view gives each block a leading spacer of\n\t * its own, and so does a radar block that has been opened, so asking the\n\t * first block whether it draws one keeps the two from doubling up.\n\t */\n\tprivate needsLeadIn(): boolean {\n\t\tif (this.view !== \"radar\") return false;\n\t\tif (this.isCollapsed()) return true;\n\t\treturn this.blocks[0]?.drawsLeadingGap() === false;\n\t}\n\n\toverride render(width: number): string[] {\n\t\tconst rows = this.rows(width);\n\t\tif (rows.length === 0 || !this.needsLeadIn()) return rows;\n\t\t// Keep the wrapped array reference-stable: the TUI diffs whole subtrees\n\t\t// by identity, and a fresh array every frame would defeat that.\n\t\tif (this.leadIn?.src === rows) return this.leadIn.out;\n\t\tconst out = [\"\", ...rows];\n\t\tthis.leadIn = { src: rows, out };\n\t\treturn out;\n\t}\n\n\tprivate rows(width: number): string[] {\n\t\tif (!this.isCollapsed()) return super.render(width);\n\t\tif (this.memo && this.memo.width === width) return this.memo.out;\n\n\t\tconst entries = this.blocks.map((block) => block.chainEntry());\n\t\tconst running = this.state === \"running\";\n\t\tconst glyph = running ? \"◐\" : \"●\";\n\t\tconst glyphTone = entries.some((e) => e.isError) ? \"error\" : running ? \"warning\" : \"success\";\n\n\t\t// While it runs the chain shows its shape in order; once it is over, what\n\t\t// it amounted to. See tool-chain-summary.ts for why they differ.\n\t\tlet leftPlain: string;\n\t\tlet leftStyled: string;\n\t\tif (this.state === \"done\") {\n\t\t\tconst phrase = chainPhrase(entries);\n\t\t\tleftPlain = phrase;\n\t\t\tleftStyled = theme.fg(\"toolTitle\", phrase);\n\t\t} else {\n\t\t\tconst segments = chainSegments(entries);\n\t\t\tconst sep = \" › \";\n\t\t\tleftPlain = segments.map((s) => s.label).join(sep) + (running ? \"…\" : \"\");\n\t\t\tleftStyled =\n\t\t\t\tsegments\n\t\t\t\t\t.map((s) =>\n\t\t\t\t\t\ttheme.fg(s.tone === \"error\" ? \"error\" : s.tone === \"running\" ? \"warning\" : \"toolTitle\", s.label),\n\t\t\t\t\t)\n\t\t\t\t\t.join(theme.fg(\"dim\", sep)) + (running ? theme.fg(\"dim\", \"…\") : \"\");\n\t\t}\n\n\t\tconst stats = chainStats(entries, this.state);\n\t\t// The marker stroke runs over what you read and stops before the stats,\n\t\t// the same shape it takes on a per-call row.\n\t\tconst stroke = this.latest && theme.hasBg(\"activeToolBg\");\n\t\tconst mark = (text: string) => (stroke ? theme.bg(\"activeToolBg\", text) : text);\n\t\t// \" ● \" + left, then stats flush right when there is room for both.\n\t\tconst prefix = `${glyph} `;\n\t\tconst budget = Math.max(0, width - 1 - visibleWidth(prefix));\n\t\tlet line: string;\n\t\tif (visibleWidth(leftPlain) + 2 + visibleWidth(stats) <= budget) {\n\t\t\tconst pad = \" \".repeat(budget - visibleWidth(leftPlain) - visibleWidth(stats));\n\t\t\tline = ` ${theme.fg(glyphTone, prefix)}${mark(leftStyled)}${pad}${theme.fg(\"muted\", stats)}`;\n\t\t} else {\n\t\t\tline = ` ${theme.fg(glyphTone, prefix)}${mark(truncateToWidth(leftStyled, budget))}`;\n\t\t}\n\n\t\tconst out = [line, ...this.failureLines(width)];\n\t\tthis.memo = { width, out };\n\t\treturn out;\n\t}\n\n\t/**\n\t * Each failed call's reason, indented under the chain line.\n\t *\n\t * A collapsed chain hides its blocks, so without this a failure would be a\n\t * count in the stats and nothing else. Whatever else these views fold away,\n\t * they never fold away why something broke.\n\t */\n\tprivate failureLines(width: number): string[] {\n\t\tconst lines: string[] = [];\n\t\tfor (const block of this.blocks) {\n\t\t\tconst entry = block.chainEntry();\n\t\t\tif (!entry.isError) continue;\n\t\t\tconst header = ` ${theme.fg(\"error\", \"✗\")} ${theme.fg(\"toolTitle\", entry.tool)} ${theme.fg(\"toolOutput\", entry.subject)}`;\n\t\t\tlines.push(truncateToWidth(header, width));\n\t\t\tfor (const raw of block.errorText().split(\"\\n\")) {\n\t\t\t\tif (!raw.trim()) continue;\n\t\t\t\tlines.push(truncateToWidth(` ${theme.fg(\"toolOutput\", raw)}`, width));\n\t\t\t}\n\t\t}\n\t\treturn lines;\n\t}\n}\n\n/** Narrow a transcript child to a chain. */\nexport function isToolChain(child: Component): child is ToolChainComponent {\n\treturn child instanceof ToolChainComponent;\n}\n"]}
@@ -99,6 +99,17 @@ export declare class ToolExecutionComponent extends Container {
99
99
  */
100
100
  private isLatest;
101
101
  private shouldShowSignalLine;
102
+ /**
103
+ * Whether this block draws its own blank row above itself.
104
+ *
105
+ * Radar rows do not — rows that are one line each only read as a map when
106
+ * they stack without gaps — which leaves the first row of a run with nothing
107
+ * between it and whatever introduced it. `ToolChainComponent` asks this so
108
+ * the run can draw that one gap itself without doubling a gap the block was
109
+ * already drawing, which is what happens in every other view and for a radar
110
+ * block that has been opened.
111
+ */
112
+ drawsLeadingGap(): boolean;
102
113
  /**
103
114
  * A failure's body under a radar row hangs off the row; anywhere else it sits
104
115
  * directly under its own call line and needs no extra indent.
@@ -1 +1 @@
1
- {"version":3,"file":"tool-execution.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,SAAS,EAMT,KAAK,GAAG,EAGR,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,mCAAmC,CAAC;AAC3F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAKxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAG1D;;;GAGG;AACH,YAAY,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAExE,MAAM,WAAW,oBAAoB;IACpC,UAAU,CAAC,E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;OAGG;IACH,OAAO,CAAC,oBAAoB;IAI5B;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAKjC;IAED,OAAO,CAAC,kBAAkB;IAkB1B,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAGjC;IAED,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAGtC;IAEQ,UAAU,IAAI,IAAI,CAM1B;IAED;;;;OAIG;IACH,WAAW,IAAI,OAAO,CAErB;IAED;uEACmE;IACnE,MAAM,IAAI,IAAI,CAEb;IAED,OAAO,CAAC,iBAAiB;IAahB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAuBvC;IAED;;;;;;;;;;OAUG;IACH,OAAO,CAAC,WAAW;IAKnB,uEAAuE;IACvE,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,aAAa;IA6HrB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,mBAAmB;CAuB3B","sourcesContent":["import {\n\tBox,\n\ttype Component,\n\tContainer,\n\tgetCapabilities,\n\tImage,\n\tisImageLine,\n\tSpacer,\n\tText,\n\ttype TUI,\n\ttruncateToWidth,\n\tvisibleWidth,\n} from \"@kolisachint/hoocode-tui\";\nimport type { ToolDefinition, ToolRenderContext } from \"../../../core/extensions/types.js\";\nimport type { ToolOutputView } from \"../../../core/tool-output-view.js\";\nimport { createAllToolDefinitions, type ToolName } from \"../../../core/tools/index.js\";\nimport { getTextOutput as getRenderedTextOutput } from \"../../../core/tools/render-utils.js\";\nimport { convertToPng } from \"../../../utils/image-convert.js\";\nimport { theme } from \"../theme/theme.js\";\nimport type { ChainEntry } from \"./tool-chain-summary.js\";\nimport { ToolSignalComponent, toolSubject } from \"./tool-signal.js\";\n\n/**\n * Re-exported so tool-block callers keep a single import site for the view\n * dial; the type itself lives in core (the settings manager persists it).\n */\nexport type { ToolOutputView } from \"../../../core/tool-output-view.js\";\n\nexport interface ToolExecutionOptions {\n\tshowImages?: boolean;\n\timageWidthCells?: number;\n\tview?: ToolOutputView;\n}\n\n/**\n * Renders a child component and prepends a prefix (e.g. a status dot) to its\n * first line, indenting continuation lines so they align under the content.\n *\n * This keeps the dot inline with the first line instead of stacking it on its\n * own line (which happens when a Container holds the dot as a separate child).\n */\nclass PrefixFirstLine implements Component {\n\tprivate prefix: string;\n\tprivate child: Component;\n\tprivate indentWidth: number;\n\t// Keyed on the child's returned array identity so an unchanged child keeps\n\t// this wrapper reference-stable too (parents memoize flattening by ref).\n\tprivate memo?: { src: string[]; width: number; out: string[] };\n\n\tconstructor(prefix: string, child: Component) {\n\t\tthis.prefix = prefix;\n\t\tthis.child = child;\n\t\tthis.indentWidth = visibleWidth(prefix);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.child.invalidate?.();\n\t\tthis.memo = undefined;\n\t}\n\n\trender(width: number): string[] {\n\t\t// Reserve room for the prefix so the child wraps within the remaining width.\n\t\tconst childWidth = Math.max(1, width - this.indentWidth);\n\t\tconst lines = this.child.render(childWidth);\n\t\tif (this.memo && this.memo.src === lines && this.memo.width === width) {\n\t\t\treturn this.memo.out;\n\t\t}\n\t\tconst indent = \" \".repeat(this.indentWidth);\n\t\tconst out =\n\t\t\tlines.length === 0 ? [this.prefix] : lines.map((line, i) => (i === 0 ? this.prefix + line : indent + line));\n\t\tthis.memo = { src: lines, width, out };\n\t\treturn out;\n\t}\n}\n\n/**\n * Indents every line of a child, unlike PrefixFirstLine which only offsets the\n * first. Used for a failure's body under a radar row, so the reason reads as\n * hanging off the row rather than starting a new column.\n */\nclass IndentAll implements Component {\n\tprivate child: Component;\n\tprivate indent: string;\n\tprivate memo?: { src: string[]; width: number; out: string[] };\n\n\tconstructor(child: Component, width: number) {\n\t\tthis.child = child;\n\t\tthis.indent = \" \".repeat(width);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.child.invalidate?.();\n\t\tthis.memo = undefined;\n\t}\n\n\trender(width: number): string[] {\n\t\tconst lines = this.child.render(Math.max(1, width - this.indent.length));\n\t\tif (this.memo && this.memo.src === lines && this.memo.width === width) return this.memo.out;\n\t\tconst out = lines.map((line) => (line.trim() === \"\" ? line : this.indent + line));\n\t\tthis.memo = { src: lines, width, out };\n\t\treturn out;\n\t}\n}\n\nexport class ToolExecutionComponent extends Container {\n\tprivate contentBox: Box;\n\tprivate contentText: Text;\n\tprivate selfRenderContainer: Container;\n\tprivate callRendererComponent?: Component;\n\tprivate resultRendererComponent?: Component;\n\tprivate rendererState: any = {};\n\tprivate imageComponents: Image[] = [];\n\tprivate imageSpacers: Spacer[] = [];\n\tprivate toolName: string;\n\tprivate toolCallId: string;\n\tprivate args: any;\n\tprivate expanded = false;\n\t// Persisted view (radar/glance/full). Controls how the call line is drawn and\n\t// whether the result body renders at all; `revealed` is the per-block override\n\t// the global expand key flips for radar/glance blocks.\n\tprivate view: ToolOutputView;\n\tprivate revealed = false;\n\tprivate signalComponent?: ToolSignalComponent;\n\tprivate leadingSpacer: Spacer;\n\tprivate showImages: boolean;\n\tprivate imageWidthCells: number;\n\tprivate isPartial = true;\n\tprivate toolDefinition?: ToolDefinition<any, any>;\n\tprivate builtInToolDefinition?: ToolDefinition<any, any>;\n\tprivate ui: TUI;\n\tprivate cwd: string;\n\tprivate executionStarted = false;\n\tprivate argsComplete = false;\n\tprivate result?: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tisError: boolean;\n\t\tdetails?: any;\n\t};\n\tprivate convertedImages: Map<number, { data: string; mimeType: string }> = new Map();\n\tprivate hideComponent = false;\n\t// Once a finished tool block has scrolled far out of view the interactive mode\n\t// freezes it (see freeze()): its already-rendered lines are captured and the\n\t// heavy source payloads (full tool result, base64 image copies, per-renderer\n\t// state, child component caches) are released. A frozen block is immutable and\n\t// no longer reflows on resize — old off-screen scrollback keeps its wrapping,\n\t// which self-heals on any full rebuild (theme toggle / session reload, both of\n\t// which reconstruct components from the intact session data).\n\tprivate frozen = false;\n\tprivate frozenLines?: string[];\n\t/** Width the frozen snapshot was captured at; a wider terminal is safe as-is,\n\t * a narrower one needs re-truncation to avoid the TUI's over-width crash guard. */\n\tprivate frozenWidth = 0;\n\tprivate frozenTruncated?: string[];\n\tprivate frozenTruncatedWidth = -1;\n\n\tconstructor(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: any,\n\t\toptions: ToolExecutionOptions = {},\n\t\ttoolDefinition: ToolDefinition<any, any> | undefined,\n\t\tui: TUI,\n\t\tcwd: string,\n\t) {\n\t\tsuper();\n\t\tthis.toolName = toolName;\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.args = args;\n\t\tthis.toolDefinition = toolDefinition;\n\t\tthis.builtInToolDefinition = createAllToolDefinitions(cwd)[toolName as ToolName];\n\t\tthis.showImages = options.showImages ?? true;\n\t\tthis.imageWidthCells = options.imageWidthCells ?? 60;\n\t\tthis.view = options.view ?? \"glance\";\n\t\tthis.ui = ui;\n\t\tthis.cwd = cwd;\n\n\t\t// The separator between consecutive tool blocks. Radar drops it: rows that\n\t\t// are one line each only read as a map when they stack without gaps.\n\t\tthis.leadingSpacer = new Spacer(1);\n\t\tthis.addChild(this.leadingSpacer);\n\n\t\t// Always create all shell variants. contentBox is used for default renderer-based composition.\n\t\t// selfRenderContainer is used when the tool renders its own framing.\n\t\t// contentText is reserved for generic fallback rendering when no tool definition exists.\n\t\t// Boxless: no filled background — hierarchy comes from status dots + indent.\n\t\t// paddingY is 0: the single leading Spacer(1) is the only separator between\n\t\t// tool blocks, so consecutive commands don't stack 3 blank lines between them.\n\t\tthis.contentBox = new Box(1, 0);\n\t\tthis.contentText = new Text(\"\", 1, 0);\n\t\tthis.selfRenderContainer = new Container();\n\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tthis.addChild(this.activeShell());\n\t\t} else {\n\t\t\tthis.addChild(this.contentText);\n\t\t}\n\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate getCallRenderer(): ToolDefinition<any, any>[\"renderCall\"] | undefined {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderCall;\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderCall;\n\t\t}\n\t\treturn this.toolDefinition.renderCall ?? this.builtInToolDefinition.renderCall;\n\t}\n\n\tprivate getResultRenderer(): ToolDefinition<any, any>[\"renderResult\"] | undefined {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderResult;\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderResult;\n\t\t}\n\t\treturn this.toolDefinition.renderResult ?? this.builtInToolDefinition.renderResult;\n\t}\n\n\tprivate hasRendererDefinition(): boolean {\n\t\treturn this.builtInToolDefinition !== undefined || this.toolDefinition !== undefined;\n\t}\n\n\tprivate getRenderShell(): \"default\" | \"self\" {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderShell ?? \"default\";\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderShell ?? \"default\";\n\t\t}\n\t\treturn this.toolDefinition.renderShell ?? this.builtInToolDefinition.renderShell ?? \"default\";\n\t}\n\n\tprivate getRenderContext(lastComponent: Component | undefined): ToolRenderContext {\n\t\treturn {\n\t\t\targs: this.args,\n\t\t\ttoolCallId: this.toolCallId,\n\t\t\tinvalidate: () => {\n\t\t\t\tthis.invalidate();\n\t\t\t\tthis.ui.requestRender();\n\t\t\t},\n\t\t\tlastComponent,\n\t\t\tstate: this.rendererState,\n\t\t\tcwd: this.cwd,\n\t\t\texecutionStarted: this.executionStarted,\n\t\t\targsComplete: this.argsComplete,\n\t\t\tisPartial: this.isPartial,\n\t\t\texpanded: this.expanded,\n\t\t\tshowImages: this.showImages,\n\t\t\tisError: this.result?.isError ?? false,\n\t\t};\n\t}\n\n\tprivate createCallFallback(): Component {\n\t\treturn new Text(theme.fg(\"toolTitle\", theme.bold(this.toolName)), 0, 0);\n\t}\n\n\tprivate createResultFallback(): Component | undefined {\n\t\tconst output = this.getTextOutput();\n\t\tif (!output) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn new Text(theme.fg(\"toolOutput\", output), 0, 0);\n\t}\n\n\tupdateArgs(args: any): void {\n\t\tthis.args = args;\n\t\tthis.updateDisplay();\n\t}\n\n\tmarkExecutionStarted(): void {\n\t\tthis.executionStarted = true;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tsetArgsComplete(): void {\n\t\tthis.argsComplete = true;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tupdateResult(\n\t\tresult: {\n\t\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\t\tdetails?: any;\n\t\t\tisError: boolean;\n\t\t},\n\t\tisPartial = false,\n\t): void {\n\t\tthis.result = result;\n\t\tthis.isPartial = isPartial;\n\t\tthis.updateDisplay();\n\t\tthis.maybeConvertImagesForKitty();\n\t}\n\n\tprivate maybeConvertImagesForKitty(): void {\n\t\tconst caps = getCapabilities();\n\t\tif (caps.images !== \"kitty\") return;\n\t\tif (!this.result) return;\n\n\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\tconst img = imageBlocks[i];\n\t\t\tif (!img.data || !img.mimeType) continue;\n\t\t\tif (img.mimeType === \"image/png\") continue;\n\t\t\tif (this.convertedImages.has(i)) continue;\n\n\t\t\tconst index = i;\n\t\t\tconvertToPng(img.data, img.mimeType).then((converted) => {\n\t\t\t\tif (this.frozen) return;\n\t\t\t\tif (converted) {\n\t\t\t\t\tthis.convertedImages.set(index, converted);\n\t\t\t\t\tthis.updateDisplay();\n\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\t// For radar/glance blocks the same global toggle reveals the hidden body;\n\t\t// for full blocks `expanded` alone switches truncated ↔ everything.\n\t\tthis.revealed = expanded;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetView(view: ToolOutputView): void {\n\t\tthis.view = view;\n\t\tthis.updateDisplay();\n\t}\n\n\t/**\n\t * Whether this block is currently opened up.\n\t *\n\t * Read by the one-at-a-time unfold, which walks back from the newest block\n\t * to find the first one still folded.\n\t */\n\tisRevealed(): boolean {\n\t\treturn this.revealed;\n\t}\n\n\t/** This call's contribution to its chain's summary line. */\n\tchainEntry(): ChainEntry {\n\t\tconst output = this.result ? this.getTextOutput() : \"\";\n\t\treturn {\n\t\t\ttool: this.toolName,\n\t\t\tsubject: toolSubject(this.args, this.cwd),\n\t\t\tisError: this.result?.isError === true,\n\t\t\tisPartial: this.result === undefined || this.isPartial,\n\t\t\toutputLines: output.trim() ? output.split(\"\\n\").length : 0,\n\t\t};\n\t}\n\n\t/** The failure text, for a collapsed chain to print under its line. */\n\terrorText(): string {\n\t\treturn this.result?.isError ? this.getTextOutput() : \"\";\n\t}\n\n\t/**\n\t * Whether the result body should render.\n\t *\n\t * A failure always shows its reason, in every view. Everything else about\n\t * these views is a judgement about how much detail you want; why something\n\t * broke is not detail, and a red dot with no explanation was the one thing\n\t * the folded views got wrong.\n\t */\n\tprivate shouldShowBody(): boolean {\n\t\treturn this.view === \"full\" || this.revealed || this.result?.isError === true;\n\t}\n\n\t/**\n\t * Whether this block draws its radar signal line instead of the tool's own\n\t * call renderer. A revealed block leaves radar for as long as it is open, so\n\t * \"expand\" means the same thing in every view.\n\t */\n\tprivate isLatest = false;\n\n\tprivate shouldShowSignalLine(): boolean {\n\t\treturn this.view === \"radar\" && !this.revealed;\n\t}\n\n\t/**\n\t * A failure's body under a radar row hangs off the row; anywhere else it sits\n\t * directly under its own call line and needs no extra indent.\n\t */\n\tprivate indentUnderSignalRow(component: Component): Component {\n\t\treturn this.shouldShowSignalLine() ? new IndentAll(component, 3) : component;\n\t}\n\n\t/**\n\t * Mark this block as the newest call in the transcript, or no longer it.\n\t *\n\t * Only radar draws anything from it: the other two views already show each\n\t * call in full, so there is nothing for a \"where am I\" mark to add.\n\t */\n\tsetLatest(isLatest: boolean): void {\n\t\tif (this.isLatest === isLatest) return;\n\t\tthis.isLatest = isLatest;\n\t\tthis.signalComponent?.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate getSignalComponent(): ToolSignalComponent {\n\t\tconst input = {\n\t\t\ttoolName: this.toolName,\n\t\t\targs: this.args,\n\t\t\tcwd: this.cwd,\n\t\t\tresult: this.result,\n\t\t\tisPartial: this.isPartial,\n\t\t\tshowImages: this.showImages,\n\t\t\tisLatest: this.isLatest,\n\t\t};\n\t\tif (this.signalComponent) {\n\t\t\tthis.signalComponent.setInput(input);\n\t\t} else {\n\t\t\tthis.signalComponent = new ToolSignalComponent(input);\n\t\t}\n\t\treturn this.signalComponent;\n\t}\n\n\tsetShowImages(show: boolean): void {\n\t\tthis.showImages = show;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetImageWidthCells(width: number): void {\n\t\tthis.imageWidthCells = Math.max(1, Math.floor(width));\n\t\tthis.updateDisplay();\n\t}\n\n\toverride invalidate(): void {\n\t\t// A frozen block has released the state updateDisplay would rebuild from;\n\t\t// its captured snapshot is authoritative, so skip the rebuild entirely.\n\t\tif (this.frozen) return;\n\t\tsuper.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\t/**\n\t * True when this block is a finished, visible tool result that still holds its\n\t * heavy source payloads — i.e. a candidate for freeze() once it scrolls out of\n\t * the live window. In-flight (partial) and already-frozen blocks are excluded.\n\t */\n\tisFreezable(): boolean {\n\t\treturn !this.frozen && !this.isPartial && !this.hideComponent && !!this.result;\n\t}\n\n\t/** Mark this block for freezing; the snapshot is captured on the next render\n\t * (at the real render width) and the heavy state released then. */\n\tfreeze(): void {\n\t\tif (this.isFreezable()) this.frozen = true;\n\t}\n\n\tprivate releaseHeavyState(): void {\n\t\tthis.result = undefined;\n\t\tthis.convertedImages.clear();\n\t\tthis.imageComponents = [];\n\t\tthis.imageSpacers = [];\n\t\tthis.rendererState = {};\n\t\tthis.callRendererComponent = undefined;\n\t\tthis.resultRendererComponent = undefined;\n\t\t// Drop child components so their line caches (which embed base64 image\n\t\t// payloads and full text output) become collectable.\n\t\tthis.clear();\n\t}\n\n\toverride render(width: number): string[] {\n\t\tif (this.hideComponent) {\n\t\t\treturn [];\n\t\t}\n\t\tif (this.frozenLines) {\n\t\t\t// Captured snapshot. Wider (or equal) terminal: emit as-is. Narrower:\n\t\t\t// re-truncate non-image lines to avoid the TUI's over-width crash guard,\n\t\t\t// caching the result per width so it stays O(1) on unchanged frames.\n\t\t\tif (width >= this.frozenWidth) return this.frozenLines;\n\t\t\tif (this.frozenTruncatedWidth === width && this.frozenTruncated) return this.frozenTruncated;\n\t\t\tthis.frozenTruncated = this.frozenLines.map((line) =>\n\t\t\t\tisImageLine(line) || visibleWidth(line) <= width ? line : truncateToWidth(line, width),\n\t\t\t);\n\t\t\tthis.frozenTruncatedWidth = width;\n\t\t\treturn this.frozenTruncated;\n\t\t}\n\t\tconst lines = super.render(width);\n\t\tif (this.frozen) {\n\t\t\tthis.frozenLines = lines;\n\t\t\tthis.frozenWidth = width;\n\t\t\tthis.releaseHeavyState();\n\t\t}\n\t\treturn lines;\n\t}\n\n\t/**\n\t * The container this block renders into.\n\t *\n\t * A self-rendering tool (`edit` draws its own framed diff) normally gets the\n\t * bare container so its frame can use the full width; everything else gets\n\t * the padded box. That only matters while the body is on screen. With the\n\t * body folded away the block is a single line, and the unpadded container\n\t * put it one column left of every other row — invisible while `peek` was an\n\t * opt-in, glaring now that `glance` is the default. So: padded box whenever\n\t * nothing is expanded, which also gives radar the uniform rows it exists for.\n\t */\n\tprivate activeShell(): Box | Container {\n\t\tif (!this.shouldShowBody()) return this.contentBox;\n\t\treturn this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox;\n\t}\n\n\t/** Swap the attached shell when the view changes which one applies. */\n\tprivate syncShellChild(): void {\n\t\tconst wanted = this.activeShell();\n\t\tconst other = wanted === this.contentBox ? this.selfRenderContainer : this.contentBox;\n\t\tif (this.children.includes(wanted)) return;\n\t\tthis.removeChild(other);\n\t\tother.clear();\n\t\tthis.addChild(wanted);\n\t}\n\n\tprivate updateDisplay(): void {\n\t\t// Frozen blocks are immutable snapshots with their source state released.\n\t\tif (this.frozen) return;\n\t\tlet hasContent = false;\n\t\tthis.hideComponent = false;\n\t\tthis.leadingSpacer.setLines(this.shouldShowSignalLine() ? 0 : 1);\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tthis.syncShellChild();\n\t\t\tconst renderContainer = this.activeShell();\n\t\t\t// Boxless: no background fill on the container.\n\t\t\tif (renderContainer instanceof Box) {\n\t\t\t\trenderContainer.setBgFn(undefined);\n\t\t\t}\n\t\t\trenderContainer.clear();\n\n\t\t\t// Status dot prefix: green for complete success, yellow for pending/partial, red for error.\n\t\t\t// The dot is prepended to the first line of the call renderer so it stays inline\n\t\t\t// (adding it as a separate child would stack it on its own line).\n\t\t\tconst dotColor = this.result?.isError ? \"error\" : this.isPartial ? \"warning\" : \"success\";\n\t\t\t// No disclosure caret. It is a click-target idiom in a TUI with no\n\t\t\t// pointer, it cost two columns on every row for an action that could\n\t\t\t// only ever be reached by keyboard, and reading it as \"this row opens\"\n\t\t\t// set an expectation the view does not meet.\n\t\t\tconst dot = theme.fg(dotColor, \"● \");\n\n\t\t\t// Radar replaces the tool's own call renderer with the uniform signal\n\t\t\t// row, so a screen of mixed tools lines up into one readable map.\n\t\t\tif (this.shouldShowSignalLine()) {\n\t\t\t\trenderContainer.addChild(new PrefixFirstLine(dot, this.getSignalComponent()));\n\t\t\t\thasContent = true;\n\t\t\t} else {\n\t\t\t\tconst callRenderer = this.getCallRenderer();\n\t\t\t\tif (!callRenderer) {\n\t\t\t\t\trenderContainer.addChild(new PrefixFirstLine(dot, this.createCallFallback()));\n\t\t\t\t\thasContent = true;\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst component = callRenderer(this.args, theme, this.getRenderContext(this.callRendererComponent));\n\t\t\t\t\t\tthis.callRendererComponent = component;\n\t\t\t\t\t\trenderContainer.addChild(new PrefixFirstLine(dot, component));\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tthis.callRendererComponent = undefined;\n\t\t\t\t\t\trenderContainer.addChild(new PrefixFirstLine(dot, this.createCallFallback()));\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.result && this.shouldShowBody()) {\n\t\t\t\tconst resultRenderer = this.getResultRenderer();\n\t\t\t\tif (!resultRenderer) {\n\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\tif (component) {\n\t\t\t\t\t\trenderContainer.addChild(this.indentUnderSignalRow(component));\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst component = resultRenderer(\n\t\t\t\t\t\t\t{ content: this.result.content as any, details: this.result.details },\n\t\t\t\t\t\t\t{ expanded: this.expanded, isPartial: this.isPartial },\n\t\t\t\t\t\t\ttheme,\n\t\t\t\t\t\t\tthis.getRenderContext(this.resultRendererComponent),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.resultRendererComponent = component;\n\t\t\t\t\t\trenderContainer.addChild(this.indentUnderSignalRow(component));\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tthis.resultRendererComponent = undefined;\n\t\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\t\tif (component) {\n\t\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// Boxless: no background fill.\n\t\t\tthis.contentText.setCustomBgFn(undefined);\n\t\t\tthis.contentText.setText(this.formatToolExecution());\n\t\t\thasContent = true;\n\t\t}\n\n\t\tfor (const img of this.imageComponents) {\n\t\t\tthis.removeChild(img);\n\t\t}\n\t\tthis.imageComponents = [];\n\t\tfor (const spacer of this.imageSpacers) {\n\t\t\tthis.removeChild(spacer);\n\t\t}\n\t\tthis.imageSpacers = [];\n\n\t\tif (this.result && !this.shouldShowSignalLine()) {\n\t\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\t\tconst caps = getCapabilities();\n\t\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\t\tconst img = imageBlocks[i];\n\t\t\t\tif (caps.images && this.showImages && img.data && img.mimeType) {\n\t\t\t\t\tconst converted = this.convertedImages.get(i);\n\t\t\t\t\tconst imageData = converted?.data ?? img.data;\n\t\t\t\t\tconst imageMimeType = converted?.mimeType ?? img.mimeType;\n\t\t\t\t\tif (caps.images === \"kitty\" && imageMimeType !== \"image/png\") continue;\n\n\t\t\t\t\tconst spacer = new Spacer(1);\n\t\t\t\t\tthis.addChild(spacer);\n\t\t\t\t\tthis.imageSpacers.push(spacer);\n\t\t\t\t\tconst imageComponent = new Image(\n\t\t\t\t\t\timageData,\n\t\t\t\t\t\timageMimeType,\n\t\t\t\t\t\t{ fallbackColor: (s: string) => theme.fg(\"toolOutput\", s) },\n\t\t\t\t\t\t{ maxWidthCells: this.imageWidthCells },\n\t\t\t\t\t);\n\t\t\t\t\tthis.imageComponents.push(imageComponent);\n\t\t\t\t\tthis.addChild(imageComponent);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (this.hasRendererDefinition() && !hasContent && this.imageComponents.length === 0) {\n\t\t\tthis.hideComponent = true;\n\t\t}\n\t}\n\n\tprivate getTextOutput(): string {\n\t\treturn getRenderedTextOutput(this.result, this.showImages);\n\t}\n\n\tprivate formatToolExecution(): string {\n\t\tconst dotColor = this.result?.isError ? \"error\" : this.isPartial ? \"warning\" : \"success\";\n\t\t// A tool with no renderer still gets a radar row, just without the\n\t\t// flush-right signal column (this path has no width to align against).\n\t\tif (this.shouldShowSignalLine()) {\n\t\t\tconst subject = toolSubject(this.args, this.cwd);\n\t\t\treturn (\n\t\t\t\ttheme.fg(dotColor, \"● \") +\n\t\t\t\ttheme.fg(\"toolTitle\", theme.bold(this.toolName)) +\n\t\t\t\t(subject ? ` ${theme.fg(\"toolOutput\", subject)}` : \"\")\n\t\t\t);\n\t\t}\n\t\tlet text = theme.fg(dotColor, \"● \") + theme.fg(\"toolTitle\", theme.bold(this.toolName));\n\t\tconst content = JSON.stringify(this.args, null, 2);\n\t\tif (content) {\n\t\t\ttext += `\\n\\n${content}`;\n\t\t}\n\t\tconst output = this.shouldShowBody() ? this.getTextOutput() : \"\";\n\t\tif (output) {\n\t\t\ttext += `\\n${output}`;\n\t\t}\n\t\treturn text;\n\t}\n}\n"]}
1
+ {"version":3,"file":"tool-execution.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,SAAS,EAMT,KAAK,GAAG,EAGR,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,mCAAmC,CAAC;AAC3F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAKxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAG1D;;;GAGG;AACH,YAAY,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAExE,MAAM,WAAW,oBAAoB;IACpC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,cAAc,CAAC;CACtB;AAwED,qBAAa,sBAAuB,SAAQ,SAAS;IACpD,OAAO,CAAC,UAAU,CAAM;IACxB,OAAO,CAAC,WAAW,CAAO;IAC1B,OAAO,CAAC,mBAAmB,CAAY;IACvC,OAAO,CAAC,qBAAqB,CAAC,CAAY;I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EAAE,MAAM,GAAG,IAAI,CAGtC;IAEQ,UAAU,IAAI,IAAI,CAM1B;IAED;;;;OAIG;IACH,WAAW,IAAI,OAAO,CAErB;IAED;uEACmE;IACnE,MAAM,IAAI,IAAI,CAEb;IAED,OAAO,CAAC,iBAAiB;IAahB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAuBvC;IAED;;;;;;;;;;OAUG;IACH,OAAO,CAAC,WAAW;IAKnB,uEAAuE;IACvE,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,aAAa;IA6HrB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,mBAAmB;CAuB3B","sourcesContent":["import {\n\tBox,\n\ttype Component,\n\tContainer,\n\tgetCapabilities,\n\tImage,\n\tisImageLine,\n\tSpacer,\n\tText,\n\ttype TUI,\n\ttruncateToWidth,\n\tvisibleWidth,\n} from \"@kolisachint/hoocode-tui\";\nimport type { ToolDefinition, ToolRenderContext } from \"../../../core/extensions/types.js\";\nimport type { ToolOutputView } from \"../../../core/tool-output-view.js\";\nimport { createAllToolDefinitions, type ToolName } from \"../../../core/tools/index.js\";\nimport { getTextOutput as getRenderedTextOutput } from \"../../../core/tools/render-utils.js\";\nimport { convertToPng } from \"../../../utils/image-convert.js\";\nimport { theme } from \"../theme/theme.js\";\nimport type { ChainEntry } from \"./tool-chain-summary.js\";\nimport { ToolSignalComponent, toolSubject } from \"./tool-signal.js\";\n\n/**\n * Re-exported so tool-block callers keep a single import site for the view\n * dial; the type itself lives in core (the settings manager persists it).\n */\nexport type { ToolOutputView } from \"../../../core/tool-output-view.js\";\n\nexport interface ToolExecutionOptions {\n\tshowImages?: boolean;\n\timageWidthCells?: number;\n\tview?: ToolOutputView;\n}\n\n/**\n * Renders a child component and prepends a prefix (e.g. a status dot) to its\n * first line, indenting continuation lines so they align under the content.\n *\n * This keeps the dot inline with the first line instead of stacking it on its\n * own line (which happens when a Container holds the dot as a separate child).\n */\nclass PrefixFirstLine implements Component {\n\tprivate prefix: string;\n\tprivate child: Component;\n\tprivate indentWidth: number;\n\t// Keyed on the child's returned array identity so an unchanged child keeps\n\t// this wrapper reference-stable too (parents memoize flattening by ref).\n\tprivate memo?: { src: string[]; width: number; out: string[] };\n\n\tconstructor(prefix: string, child: Component) {\n\t\tthis.prefix = prefix;\n\t\tthis.child = child;\n\t\tthis.indentWidth = visibleWidth(prefix);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.child.invalidate?.();\n\t\tthis.memo = undefined;\n\t}\n\n\trender(width: number): string[] {\n\t\t// Reserve room for the prefix so the child wraps within the remaining width.\n\t\tconst childWidth = Math.max(1, width - this.indentWidth);\n\t\tconst lines = this.child.render(childWidth);\n\t\tif (this.memo && this.memo.src === lines && this.memo.width === width) {\n\t\t\treturn this.memo.out;\n\t\t}\n\t\tconst indent = \" \".repeat(this.indentWidth);\n\t\tconst out =\n\t\t\tlines.length === 0 ? [this.prefix] : lines.map((line, i) => (i === 0 ? this.prefix + line : indent + line));\n\t\tthis.memo = { src: lines, width, out };\n\t\treturn out;\n\t}\n}\n\n/**\n * Indents every line of a child, unlike PrefixFirstLine which only offsets the\n * first. Used for a failure's body under a radar row, so the reason reads as\n * hanging off the row rather than starting a new column.\n */\nclass IndentAll implements Component {\n\tprivate child: Component;\n\tprivate indent: string;\n\tprivate memo?: { src: string[]; width: number; out: string[] };\n\n\tconstructor(child: Component, width: number) {\n\t\tthis.child = child;\n\t\tthis.indent = \" \".repeat(width);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.child.invalidate?.();\n\t\tthis.memo = undefined;\n\t}\n\n\trender(width: number): string[] {\n\t\tconst lines = this.child.render(Math.max(1, width - this.indent.length));\n\t\tif (this.memo && this.memo.src === lines && this.memo.width === width) return this.memo.out;\n\t\tconst out = lines.map((line) => (line.trim() === \"\" ? line : this.indent + line));\n\t\tthis.memo = { src: lines, width, out };\n\t\treturn out;\n\t}\n}\n\nexport class ToolExecutionComponent extends Container {\n\tprivate contentBox: Box;\n\tprivate contentText: Text;\n\tprivate selfRenderContainer: Container;\n\tprivate callRendererComponent?: Component;\n\tprivate resultRendererComponent?: Component;\n\tprivate rendererState: any = {};\n\tprivate imageComponents: Image[] = [];\n\tprivate imageSpacers: Spacer[] = [];\n\tprivate toolName: string;\n\tprivate toolCallId: string;\n\tprivate args: any;\n\tprivate expanded = false;\n\t// Persisted view (radar/glance/full). Controls how the call line is drawn and\n\t// whether the result body renders at all; `revealed` is the per-block override\n\t// the global expand key flips for radar/glance blocks.\n\tprivate view: ToolOutputView;\n\tprivate revealed = false;\n\tprivate signalComponent?: ToolSignalComponent;\n\tprivate leadingSpacer: Spacer;\n\tprivate showImages: boolean;\n\tprivate imageWidthCells: number;\n\tprivate isPartial = true;\n\tprivate toolDefinition?: ToolDefinition<any, any>;\n\tprivate builtInToolDefinition?: ToolDefinition<any, any>;\n\tprivate ui: TUI;\n\tprivate cwd: string;\n\tprivate executionStarted = false;\n\tprivate argsComplete = false;\n\tprivate result?: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tisError: boolean;\n\t\tdetails?: any;\n\t};\n\tprivate convertedImages: Map<number, { data: string; mimeType: string }> = new Map();\n\tprivate hideComponent = false;\n\t// Once a finished tool block has scrolled far out of view the interactive mode\n\t// freezes it (see freeze()): its already-rendered lines are captured and the\n\t// heavy source payloads (full tool result, base64 image copies, per-renderer\n\t// state, child component caches) are released. A frozen block is immutable and\n\t// no longer reflows on resize — old off-screen scrollback keeps its wrapping,\n\t// which self-heals on any full rebuild (theme toggle / session reload, both of\n\t// which reconstruct components from the intact session data).\n\tprivate frozen = false;\n\tprivate frozenLines?: string[];\n\t/** Width the frozen snapshot was captured at; a wider terminal is safe as-is,\n\t * a narrower one needs re-truncation to avoid the TUI's over-width crash guard. */\n\tprivate frozenWidth = 0;\n\tprivate frozenTruncated?: string[];\n\tprivate frozenTruncatedWidth = -1;\n\n\tconstructor(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: any,\n\t\toptions: ToolExecutionOptions = {},\n\t\ttoolDefinition: ToolDefinition<any, any> | undefined,\n\t\tui: TUI,\n\t\tcwd: string,\n\t) {\n\t\tsuper();\n\t\tthis.toolName = toolName;\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.args = args;\n\t\tthis.toolDefinition = toolDefinition;\n\t\tthis.builtInToolDefinition = createAllToolDefinitions(cwd)[toolName as ToolName];\n\t\tthis.showImages = options.showImages ?? true;\n\t\tthis.imageWidthCells = options.imageWidthCells ?? 60;\n\t\tthis.view = options.view ?? \"glance\";\n\t\tthis.ui = ui;\n\t\tthis.cwd = cwd;\n\n\t\t// The separator between consecutive tool blocks. Radar drops it: rows that\n\t\t// are one line each only read as a map when they stack without gaps.\n\t\tthis.leadingSpacer = new Spacer(1);\n\t\tthis.addChild(this.leadingSpacer);\n\n\t\t// Always create all shell variants. contentBox is used for default renderer-based composition.\n\t\t// selfRenderContainer is used when the tool renders its own framing.\n\t\t// contentText is reserved for generic fallback rendering when no tool definition exists.\n\t\t// Boxless: no filled background — hierarchy comes from status dots + indent.\n\t\t// paddingY is 0: the single leading Spacer(1) is the only separator between\n\t\t// tool blocks, so consecutive commands don't stack 3 blank lines between them.\n\t\tthis.contentBox = new Box(1, 0);\n\t\tthis.contentText = new Text(\"\", 1, 0);\n\t\tthis.selfRenderContainer = new Container();\n\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tthis.addChild(this.activeShell());\n\t\t} else {\n\t\t\tthis.addChild(this.contentText);\n\t\t}\n\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate getCallRenderer(): ToolDefinition<any, any>[\"renderCall\"] | undefined {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderCall;\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderCall;\n\t\t}\n\t\treturn this.toolDefinition.renderCall ?? this.builtInToolDefinition.renderCall;\n\t}\n\n\tprivate getResultRenderer(): ToolDefinition<any, any>[\"renderResult\"] | undefined {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderResult;\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderResult;\n\t\t}\n\t\treturn this.toolDefinition.renderResult ?? this.builtInToolDefinition.renderResult;\n\t}\n\n\tprivate hasRendererDefinition(): boolean {\n\t\treturn this.builtInToolDefinition !== undefined || this.toolDefinition !== undefined;\n\t}\n\n\tprivate getRenderShell(): \"default\" | \"self\" {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderShell ?? \"default\";\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderShell ?? \"default\";\n\t\t}\n\t\treturn this.toolDefinition.renderShell ?? this.builtInToolDefinition.renderShell ?? \"default\";\n\t}\n\n\tprivate getRenderContext(lastComponent: Component | undefined): ToolRenderContext {\n\t\treturn {\n\t\t\targs: this.args,\n\t\t\ttoolCallId: this.toolCallId,\n\t\t\tinvalidate: () => {\n\t\t\t\tthis.invalidate();\n\t\t\t\tthis.ui.requestRender();\n\t\t\t},\n\t\t\tlastComponent,\n\t\t\tstate: this.rendererState,\n\t\t\tcwd: this.cwd,\n\t\t\texecutionStarted: this.executionStarted,\n\t\t\targsComplete: this.argsComplete,\n\t\t\tisPartial: this.isPartial,\n\t\t\texpanded: this.expanded,\n\t\t\tshowImages: this.showImages,\n\t\t\tisError: this.result?.isError ?? false,\n\t\t};\n\t}\n\n\tprivate createCallFallback(): Component {\n\t\treturn new Text(theme.fg(\"toolTitle\", theme.bold(this.toolName)), 0, 0);\n\t}\n\n\tprivate createResultFallback(): Component | undefined {\n\t\tconst output = this.getTextOutput();\n\t\tif (!output) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn new Text(theme.fg(\"toolOutput\", output), 0, 0);\n\t}\n\n\tupdateArgs(args: any): void {\n\t\tthis.args = args;\n\t\tthis.updateDisplay();\n\t}\n\n\tmarkExecutionStarted(): void {\n\t\tthis.executionStarted = true;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tsetArgsComplete(): void {\n\t\tthis.argsComplete = true;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tupdateResult(\n\t\tresult: {\n\t\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\t\tdetails?: any;\n\t\t\tisError: boolean;\n\t\t},\n\t\tisPartial = false,\n\t): void {\n\t\tthis.result = result;\n\t\tthis.isPartial = isPartial;\n\t\tthis.updateDisplay();\n\t\tthis.maybeConvertImagesForKitty();\n\t}\n\n\tprivate maybeConvertImagesForKitty(): void {\n\t\tconst caps = getCapabilities();\n\t\tif (caps.images !== \"kitty\") return;\n\t\tif (!this.result) return;\n\n\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\tconst img = imageBlocks[i];\n\t\t\tif (!img.data || !img.mimeType) continue;\n\t\t\tif (img.mimeType === \"image/png\") continue;\n\t\t\tif (this.convertedImages.has(i)) continue;\n\n\t\t\tconst index = i;\n\t\t\tconvertToPng(img.data, img.mimeType).then((converted) => {\n\t\t\t\tif (this.frozen) return;\n\t\t\t\tif (converted) {\n\t\t\t\t\tthis.convertedImages.set(index, converted);\n\t\t\t\t\tthis.updateDisplay();\n\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\t// For radar/glance blocks the same global toggle reveals the hidden body;\n\t\t// for full blocks `expanded` alone switches truncated ↔ everything.\n\t\tthis.revealed = expanded;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetView(view: ToolOutputView): void {\n\t\tthis.view = view;\n\t\tthis.updateDisplay();\n\t}\n\n\t/**\n\t * Whether this block is currently opened up.\n\t *\n\t * Read by the one-at-a-time unfold, which walks back from the newest block\n\t * to find the first one still folded.\n\t */\n\tisRevealed(): boolean {\n\t\treturn this.revealed;\n\t}\n\n\t/** This call's contribution to its chain's summary line. */\n\tchainEntry(): ChainEntry {\n\t\tconst output = this.result ? this.getTextOutput() : \"\";\n\t\treturn {\n\t\t\ttool: this.toolName,\n\t\t\tsubject: toolSubject(this.args, this.cwd),\n\t\t\tisError: this.result?.isError === true,\n\t\t\tisPartial: this.result === undefined || this.isPartial,\n\t\t\toutputLines: output.trim() ? output.split(\"\\n\").length : 0,\n\t\t};\n\t}\n\n\t/** The failure text, for a collapsed chain to print under its line. */\n\terrorText(): string {\n\t\treturn this.result?.isError ? this.getTextOutput() : \"\";\n\t}\n\n\t/**\n\t * Whether the result body should render.\n\t *\n\t * A failure always shows its reason, in every view. Everything else about\n\t * these views is a judgement about how much detail you want; why something\n\t * broke is not detail, and a red dot with no explanation was the one thing\n\t * the folded views got wrong.\n\t */\n\tprivate shouldShowBody(): boolean {\n\t\treturn this.view === \"full\" || this.revealed || this.result?.isError === true;\n\t}\n\n\t/**\n\t * Whether this block draws its radar signal line instead of the tool's own\n\t * call renderer. A revealed block leaves radar for as long as it is open, so\n\t * \"expand\" means the same thing in every view.\n\t */\n\tprivate isLatest = false;\n\n\tprivate shouldShowSignalLine(): boolean {\n\t\treturn this.view === \"radar\" && !this.revealed;\n\t}\n\n\t/**\n\t * Whether this block draws its own blank row above itself.\n\t *\n\t * Radar rows do not — rows that are one line each only read as a map when\n\t * they stack without gaps — which leaves the first row of a run with nothing\n\t * between it and whatever introduced it. `ToolChainComponent` asks this so\n\t * the run can draw that one gap itself without doubling a gap the block was\n\t * already drawing, which is what happens in every other view and for a radar\n\t * block that has been opened.\n\t */\n\tdrawsLeadingGap(): boolean {\n\t\treturn !this.shouldShowSignalLine();\n\t}\n\n\t/**\n\t * A failure's body under a radar row hangs off the row; anywhere else it sits\n\t * directly under its own call line and needs no extra indent.\n\t */\n\tprivate indentUnderSignalRow(component: Component): Component {\n\t\treturn this.shouldShowSignalLine() ? new IndentAll(component, 3) : component;\n\t}\n\n\t/**\n\t * Mark this block as the newest call in the transcript, or no longer it.\n\t *\n\t * Only radar draws anything from it: the other two views already show each\n\t * call in full, so there is nothing for a \"where am I\" mark to add.\n\t */\n\tsetLatest(isLatest: boolean): void {\n\t\tif (this.isLatest === isLatest) return;\n\t\tthis.isLatest = isLatest;\n\t\tthis.signalComponent?.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate getSignalComponent(): ToolSignalComponent {\n\t\tconst input = {\n\t\t\ttoolName: this.toolName,\n\t\t\targs: this.args,\n\t\t\tcwd: this.cwd,\n\t\t\tresult: this.result,\n\t\t\tisPartial: this.isPartial,\n\t\t\tshowImages: this.showImages,\n\t\t\tisLatest: this.isLatest,\n\t\t};\n\t\tif (this.signalComponent) {\n\t\t\tthis.signalComponent.setInput(input);\n\t\t} else {\n\t\t\tthis.signalComponent = new ToolSignalComponent(input);\n\t\t}\n\t\treturn this.signalComponent;\n\t}\n\n\tsetShowImages(show: boolean): void {\n\t\tthis.showImages = show;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetImageWidthCells(width: number): void {\n\t\tthis.imageWidthCells = Math.max(1, Math.floor(width));\n\t\tthis.updateDisplay();\n\t}\n\n\toverride invalidate(): void {\n\t\t// A frozen block has released the state updateDisplay would rebuild from;\n\t\t// its captured snapshot is authoritative, so skip the rebuild entirely.\n\t\tif (this.frozen) return;\n\t\tsuper.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\t/**\n\t * True when this block is a finished, visible tool result that still holds its\n\t * heavy source payloads — i.e. a candidate for freeze() once it scrolls out of\n\t * the live window. In-flight (partial) and already-frozen blocks are excluded.\n\t */\n\tisFreezable(): boolean {\n\t\treturn !this.frozen && !this.isPartial && !this.hideComponent && !!this.result;\n\t}\n\n\t/** Mark this block for freezing; the snapshot is captured on the next render\n\t * (at the real render width) and the heavy state released then. */\n\tfreeze(): void {\n\t\tif (this.isFreezable()) this.frozen = true;\n\t}\n\n\tprivate releaseHeavyState(): void {\n\t\tthis.result = undefined;\n\t\tthis.convertedImages.clear();\n\t\tthis.imageComponents = [];\n\t\tthis.imageSpacers = [];\n\t\tthis.rendererState = {};\n\t\tthis.callRendererComponent = undefined;\n\t\tthis.resultRendererComponent = undefined;\n\t\t// Drop child components so their line caches (which embed base64 image\n\t\t// payloads and full text output) become collectable.\n\t\tthis.clear();\n\t}\n\n\toverride render(width: number): string[] {\n\t\tif (this.hideComponent) {\n\t\t\treturn [];\n\t\t}\n\t\tif (this.frozenLines) {\n\t\t\t// Captured snapshot. Wider (or equal) terminal: emit as-is. Narrower:\n\t\t\t// re-truncate non-image lines to avoid the TUI's over-width crash guard,\n\t\t\t// caching the result per width so it stays O(1) on unchanged frames.\n\t\t\tif (width >= this.frozenWidth) return this.frozenLines;\n\t\t\tif (this.frozenTruncatedWidth === width && this.frozenTruncated) return this.frozenTruncated;\n\t\t\tthis.frozenTruncated = this.frozenLines.map((line) =>\n\t\t\t\tisImageLine(line) || visibleWidth(line) <= width ? line : truncateToWidth(line, width),\n\t\t\t);\n\t\t\tthis.frozenTruncatedWidth = width;\n\t\t\treturn this.frozenTruncated;\n\t\t}\n\t\tconst lines = super.render(width);\n\t\tif (this.frozen) {\n\t\t\tthis.frozenLines = lines;\n\t\t\tthis.frozenWidth = width;\n\t\t\tthis.releaseHeavyState();\n\t\t}\n\t\treturn lines;\n\t}\n\n\t/**\n\t * The container this block renders into.\n\t *\n\t * A self-rendering tool (`edit` draws its own framed diff) normally gets the\n\t * bare container so its frame can use the full width; everything else gets\n\t * the padded box. That only matters while the body is on screen. With the\n\t * body folded away the block is a single line, and the unpadded container\n\t * put it one column left of every other row — invisible while `peek` was an\n\t * opt-in, glaring now that `glance` is the default. So: padded box whenever\n\t * nothing is expanded, which also gives radar the uniform rows it exists for.\n\t */\n\tprivate activeShell(): Box | Container {\n\t\tif (!this.shouldShowBody()) return this.contentBox;\n\t\treturn this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox;\n\t}\n\n\t/** Swap the attached shell when the view changes which one applies. */\n\tprivate syncShellChild(): void {\n\t\tconst wanted = this.activeShell();\n\t\tconst other = wanted === this.contentBox ? this.selfRenderContainer : this.contentBox;\n\t\tif (this.children.includes(wanted)) return;\n\t\tthis.removeChild(other);\n\t\tother.clear();\n\t\tthis.addChild(wanted);\n\t}\n\n\tprivate updateDisplay(): void {\n\t\t// Frozen blocks are immutable snapshots with their source state released.\n\t\tif (this.frozen) return;\n\t\tlet hasContent = false;\n\t\tthis.hideComponent = false;\n\t\tthis.leadingSpacer.setLines(this.shouldShowSignalLine() ? 0 : 1);\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tthis.syncShellChild();\n\t\t\tconst renderContainer = this.activeShell();\n\t\t\t// Boxless: no background fill on the container.\n\t\t\tif (renderContainer instanceof Box) {\n\t\t\t\trenderContainer.setBgFn(undefined);\n\t\t\t}\n\t\t\trenderContainer.clear();\n\n\t\t\t// Status dot prefix: green for complete success, yellow for pending/partial, red for error.\n\t\t\t// The dot is prepended to the first line of the call renderer so it stays inline\n\t\t\t// (adding it as a separate child would stack it on its own line).\n\t\t\tconst dotColor = this.result?.isError ? \"error\" : this.isPartial ? \"warning\" : \"success\";\n\t\t\t// No disclosure caret. It is a click-target idiom in a TUI with no\n\t\t\t// pointer, it cost two columns on every row for an action that could\n\t\t\t// only ever be reached by keyboard, and reading it as \"this row opens\"\n\t\t\t// set an expectation the view does not meet.\n\t\t\tconst dot = theme.fg(dotColor, \"● \");\n\n\t\t\t// Radar replaces the tool's own call renderer with the uniform signal\n\t\t\t// row, so a screen of mixed tools lines up into one readable map.\n\t\t\tif (this.shouldShowSignalLine()) {\n\t\t\t\trenderContainer.addChild(new PrefixFirstLine(dot, this.getSignalComponent()));\n\t\t\t\thasContent = true;\n\t\t\t} else {\n\t\t\t\tconst callRenderer = this.getCallRenderer();\n\t\t\t\tif (!callRenderer) {\n\t\t\t\t\trenderContainer.addChild(new PrefixFirstLine(dot, this.createCallFallback()));\n\t\t\t\t\thasContent = true;\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst component = callRenderer(this.args, theme, this.getRenderContext(this.callRendererComponent));\n\t\t\t\t\t\tthis.callRendererComponent = component;\n\t\t\t\t\t\trenderContainer.addChild(new PrefixFirstLine(dot, component));\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tthis.callRendererComponent = undefined;\n\t\t\t\t\t\trenderContainer.addChild(new PrefixFirstLine(dot, this.createCallFallback()));\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.result && this.shouldShowBody()) {\n\t\t\t\tconst resultRenderer = this.getResultRenderer();\n\t\t\t\tif (!resultRenderer) {\n\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\tif (component) {\n\t\t\t\t\t\trenderContainer.addChild(this.indentUnderSignalRow(component));\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst component = resultRenderer(\n\t\t\t\t\t\t\t{ content: this.result.content as any, details: this.result.details },\n\t\t\t\t\t\t\t{ expanded: this.expanded, isPartial: this.isPartial },\n\t\t\t\t\t\t\ttheme,\n\t\t\t\t\t\t\tthis.getRenderContext(this.resultRendererComponent),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.resultRendererComponent = component;\n\t\t\t\t\t\trenderContainer.addChild(this.indentUnderSignalRow(component));\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tthis.resultRendererComponent = undefined;\n\t\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\t\tif (component) {\n\t\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// Boxless: no background fill.\n\t\t\tthis.contentText.setCustomBgFn(undefined);\n\t\t\tthis.contentText.setText(this.formatToolExecution());\n\t\t\thasContent = true;\n\t\t}\n\n\t\tfor (const img of this.imageComponents) {\n\t\t\tthis.removeChild(img);\n\t\t}\n\t\tthis.imageComponents = [];\n\t\tfor (const spacer of this.imageSpacers) {\n\t\t\tthis.removeChild(spacer);\n\t\t}\n\t\tthis.imageSpacers = [];\n\n\t\tif (this.result && !this.shouldShowSignalLine()) {\n\t\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\t\tconst caps = getCapabilities();\n\t\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\t\tconst img = imageBlocks[i];\n\t\t\t\tif (caps.images && this.showImages && img.data && img.mimeType) {\n\t\t\t\t\tconst converted = this.convertedImages.get(i);\n\t\t\t\t\tconst imageData = converted?.data ?? img.data;\n\t\t\t\t\tconst imageMimeType = converted?.mimeType ?? img.mimeType;\n\t\t\t\t\tif (caps.images === \"kitty\" && imageMimeType !== \"image/png\") continue;\n\n\t\t\t\t\tconst spacer = new Spacer(1);\n\t\t\t\t\tthis.addChild(spacer);\n\t\t\t\t\tthis.imageSpacers.push(spacer);\n\t\t\t\t\tconst imageComponent = new Image(\n\t\t\t\t\t\timageData,\n\t\t\t\t\t\timageMimeType,\n\t\t\t\t\t\t{ fallbackColor: (s: string) => theme.fg(\"toolOutput\", s) },\n\t\t\t\t\t\t{ maxWidthCells: this.imageWidthCells },\n\t\t\t\t\t);\n\t\t\t\t\tthis.imageComponents.push(imageComponent);\n\t\t\t\t\tthis.addChild(imageComponent);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (this.hasRendererDefinition() && !hasContent && this.imageComponents.length === 0) {\n\t\t\tthis.hideComponent = true;\n\t\t}\n\t}\n\n\tprivate getTextOutput(): string {\n\t\treturn getRenderedTextOutput(this.result, this.showImages);\n\t}\n\n\tprivate formatToolExecution(): string {\n\t\tconst dotColor = this.result?.isError ? \"error\" : this.isPartial ? \"warning\" : \"success\";\n\t\t// A tool with no renderer still gets a radar row, just without the\n\t\t// flush-right signal column (this path has no width to align against).\n\t\tif (this.shouldShowSignalLine()) {\n\t\t\tconst subject = toolSubject(this.args, this.cwd);\n\t\t\treturn (\n\t\t\t\ttheme.fg(dotColor, \"● \") +\n\t\t\t\ttheme.fg(\"toolTitle\", theme.bold(this.toolName)) +\n\t\t\t\t(subject ? ` ${theme.fg(\"toolOutput\", subject)}` : \"\")\n\t\t\t);\n\t\t}\n\t\tlet text = theme.fg(dotColor, \"● \") + theme.fg(\"toolTitle\", theme.bold(this.toolName));\n\t\tconst content = JSON.stringify(this.args, null, 2);\n\t\tif (content) {\n\t\t\ttext += `\\n\\n${content}`;\n\t\t}\n\t\tconst output = this.shouldShowBody() ? this.getTextOutput() : \"\";\n\t\tif (output) {\n\t\t\ttext += `\\n${output}`;\n\t\t}\n\t\treturn text;\n\t}\n}\n"]}
@@ -306,6 +306,19 @@ export class ToolExecutionComponent extends Container {
306
306
  shouldShowSignalLine() {
307
307
  return this.view === "radar" && !this.revealed;
308
308
  }
309
+ /**
310
+ * Whether this block draws its own blank row above itself.
311
+ *
312
+ * Radar rows do not — rows that are one line each only read as a map when
313
+ * they stack without gaps — which leaves the first row of a run with nothing
314
+ * between it and whatever introduced it. `ToolChainComponent` asks this so
315
+ * the run can draw that one gap itself without doubling a gap the block was
316
+ * already drawing, which is what happens in every other view and for a radar
317
+ * block that has been opened.
318
+ */
319
+ drawsLeadingGap() {
320
+ return !this.shouldShowSignalLine();
321
+ }
309
322
  /**
310
323
  * A failure's body under a radar row hangs off the row; anywhere else it sits
311
324
  * directly under its own call line and needs no extra indent.
@@ -1 +1 @@
1
- {"version":3,"file":"tool-execution.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,GAAG,EAEH,SAAS,EACT,eAAe,EACf,KAAK,EACL,WAAW,EACX,MAAM,EACN,IAA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CAAC;QACvF,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACnD,IAAI,OAAO,EAAE,CAAC;YACb,IAAI,IAAI,OAAO,OAAO,EAAE,CAAC;QAC1B,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjE,IAAI,MAAM,EAAE,CAAC;YACZ,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACvB,CAAC;QACD,OAAO,IAAI,CAAC;IAAA,CACZ;CACD","sourcesContent":["import {\n\tBox,\n\ttype Component,\n\tContainer,\n\tgetCapabilities,\n\tImage,\n\tisImageLine,\n\tSpacer,\n\tText,\n\ttype TUI,\n\ttruncateToWidth,\n\tvisibleWidth,\n} from \"@kolisachint/hoocode-tui\";\nimport type { ToolDefinition, ToolRenderContext } from \"../../../core/extensions/types.js\";\nimport type { ToolOutputView } from \"../../../core/tool-output-view.js\";\nimport { createAllToolDefinitions, type ToolName } from \"../../../core/tools/index.js\";\nimport { getTextOutput as getRenderedTextOutput } from \"../../../core/tools/render-utils.js\";\nimport { convertToPng } from \"../../../utils/image-convert.js\";\nimport { theme } from \"../theme/theme.js\";\nimport type { ChainEntry } from \"./tool-chain-summary.js\";\nimport { ToolSignalComponent, toolSubject } from \"./tool-signal.js\";\n\n/**\n * Re-exported so tool-block callers keep a single import site for the view\n * dial; the type itself lives in core (the settings manager persists it).\n */\nexport type { ToolOutputView } from \"../../../core/tool-output-view.js\";\n\nexport interface ToolExecutionOptions {\n\tshowImages?: boolean;\n\timageWidthCells?: number;\n\tview?: ToolOutputView;\n}\n\n/**\n * Renders a child component and prepends a prefix (e.g. a status dot) to its\n * first line, indenting continuation lines so they align under the content.\n *\n * This keeps the dot inline with the first line instead of stacking it on its\n * own line (which happens when a Container holds the dot as a separate child).\n */\nclass PrefixFirstLine implements Component {\n\tprivate prefix: string;\n\tprivate child: Component;\n\tprivate indentWidth: number;\n\t// Keyed on the child's returned array identity so an unchanged child keeps\n\t// this wrapper reference-stable too (parents memoize flattening by ref).\n\tprivate memo?: { src: string[]; width: number; out: string[] };\n\n\tconstructor(prefix: string, child: Component) {\n\t\tthis.prefix = prefix;\n\t\tthis.child = child;\n\t\tthis.indentWidth = visibleWidth(prefix);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.child.invalidate?.();\n\t\tthis.memo = undefined;\n\t}\n\n\trender(width: number): string[] {\n\t\t// Reserve room for the prefix so the child wraps within the remaining width.\n\t\tconst childWidth = Math.max(1, width - this.indentWidth);\n\t\tconst lines = this.child.render(childWidth);\n\t\tif (this.memo && this.memo.src === lines && this.memo.width === width) {\n\t\t\treturn this.memo.out;\n\t\t}\n\t\tconst indent = \" \".repeat(this.indentWidth);\n\t\tconst out =\n\t\t\tlines.length === 0 ? [this.prefix] : lines.map((line, i) => (i === 0 ? this.prefix + line : indent + line));\n\t\tthis.memo = { src: lines, width, out };\n\t\treturn out;\n\t}\n}\n\n/**\n * Indents every line of a child, unlike PrefixFirstLine which only offsets the\n * first. Used for a failure's body under a radar row, so the reason reads as\n * hanging off the row rather than starting a new column.\n */\nclass IndentAll implements Component {\n\tprivate child: Component;\n\tprivate indent: string;\n\tprivate memo?: { src: string[]; width: number; out: string[] };\n\n\tconstructor(child: Component, width: number) {\n\t\tthis.child = child;\n\t\tthis.indent = \" \".repeat(width);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.child.invalidate?.();\n\t\tthis.memo = undefined;\n\t}\n\n\trender(width: number): string[] {\n\t\tconst lines = this.child.render(Math.max(1, width - this.indent.length));\n\t\tif (this.memo && this.memo.src === lines && this.memo.width === width) return this.memo.out;\n\t\tconst out = lines.map((line) => (line.trim() === \"\" ? line : this.indent + line));\n\t\tthis.memo = { src: lines, width, out };\n\t\treturn out;\n\t}\n}\n\nexport class ToolExecutionComponent extends Container {\n\tprivate contentBox: Box;\n\tprivate contentText: Text;\n\tprivate selfRenderContainer: Container;\n\tprivate callRendererComponent?: Component;\n\tprivate resultRendererComponent?: Component;\n\tprivate rendererState: any = {};\n\tprivate imageComponents: Image[] = [];\n\tprivate imageSpacers: Spacer[] = [];\n\tprivate toolName: string;\n\tprivate toolCallId: string;\n\tprivate args: any;\n\tprivate expanded = false;\n\t// Persisted view (radar/glance/full). Controls how the call line is drawn and\n\t// whether the result body renders at all; `revealed` is the per-block override\n\t// the global expand key flips for radar/glance blocks.\n\tprivate view: ToolOutputView;\n\tprivate revealed = false;\n\tprivate signalComponent?: ToolSignalComponent;\n\tprivate leadingSpacer: Spacer;\n\tprivate showImages: boolean;\n\tprivate imageWidthCells: number;\n\tprivate isPartial = true;\n\tprivate toolDefinition?: ToolDefinition<any, any>;\n\tprivate builtInToolDefinition?: ToolDefinition<any, any>;\n\tprivate ui: TUI;\n\tprivate cwd: string;\n\tprivate executionStarted = false;\n\tprivate argsComplete = false;\n\tprivate result?: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tisError: boolean;\n\t\tdetails?: any;\n\t};\n\tprivate convertedImages: Map<number, { data: string; mimeType: string }> = new Map();\n\tprivate hideComponent = false;\n\t// Once a finished tool block has scrolled far out of view the interactive mode\n\t// freezes it (see freeze()): its already-rendered lines are captured and the\n\t// heavy source payloads (full tool result, base64 image copies, per-renderer\n\t// state, child component caches) are released. A frozen block is immutable and\n\t// no longer reflows on resize — old off-screen scrollback keeps its wrapping,\n\t// which self-heals on any full rebuild (theme toggle / session reload, both of\n\t// which reconstruct components from the intact session data).\n\tprivate frozen = false;\n\tprivate frozenLines?: string[];\n\t/** Width the frozen snapshot was captured at; a wider terminal is safe as-is,\n\t * a narrower one needs re-truncation to avoid the TUI's over-width crash guard. */\n\tprivate frozenWidth = 0;\n\tprivate frozenTruncated?: string[];\n\tprivate frozenTruncatedWidth = -1;\n\n\tconstructor(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: any,\n\t\toptions: ToolExecutionOptions = {},\n\t\ttoolDefinition: ToolDefinition<any, any> | undefined,\n\t\tui: TUI,\n\t\tcwd: string,\n\t) {\n\t\tsuper();\n\t\tthis.toolName = toolName;\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.args = args;\n\t\tthis.toolDefinition = toolDefinition;\n\t\tthis.builtInToolDefinition = createAllToolDefinitions(cwd)[toolName as ToolName];\n\t\tthis.showImages = options.showImages ?? true;\n\t\tthis.imageWidthCells = options.imageWidthCells ?? 60;\n\t\tthis.view = options.view ?? \"glance\";\n\t\tthis.ui = ui;\n\t\tthis.cwd = cwd;\n\n\t\t// The separator between consecutive tool blocks. Radar drops it: rows that\n\t\t// are one line each only read as a map when they stack without gaps.\n\t\tthis.leadingSpacer = new Spacer(1);\n\t\tthis.addChild(this.leadingSpacer);\n\n\t\t// Always create all shell variants. contentBox is used for default renderer-based composition.\n\t\t// selfRenderContainer is used when the tool renders its own framing.\n\t\t// contentText is reserved for generic fallback rendering when no tool definition exists.\n\t\t// Boxless: no filled background — hierarchy comes from status dots + indent.\n\t\t// paddingY is 0: the single leading Spacer(1) is the only separator between\n\t\t// tool blocks, so consecutive commands don't stack 3 blank lines between them.\n\t\tthis.contentBox = new Box(1, 0);\n\t\tthis.contentText = new Text(\"\", 1, 0);\n\t\tthis.selfRenderContainer = new Container();\n\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tthis.addChild(this.activeShell());\n\t\t} else {\n\t\t\tthis.addChild(this.contentText);\n\t\t}\n\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate getCallRenderer(): ToolDefinition<any, any>[\"renderCall\"] | undefined {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderCall;\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderCall;\n\t\t}\n\t\treturn this.toolDefinition.renderCall ?? this.builtInToolDefinition.renderCall;\n\t}\n\n\tprivate getResultRenderer(): ToolDefinition<any, any>[\"renderResult\"] | undefined {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderResult;\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderResult;\n\t\t}\n\t\treturn this.toolDefinition.renderResult ?? this.builtInToolDefinition.renderResult;\n\t}\n\n\tprivate hasRendererDefinition(): boolean {\n\t\treturn this.builtInToolDefinition !== undefined || this.toolDefinition !== undefined;\n\t}\n\n\tprivate getRenderShell(): \"default\" | \"self\" {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderShell ?? \"default\";\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderShell ?? \"default\";\n\t\t}\n\t\treturn this.toolDefinition.renderShell ?? this.builtInToolDefinition.renderShell ?? \"default\";\n\t}\n\n\tprivate getRenderContext(lastComponent: Component | undefined): ToolRenderContext {\n\t\treturn {\n\t\t\targs: this.args,\n\t\t\ttoolCallId: this.toolCallId,\n\t\t\tinvalidate: () => {\n\t\t\t\tthis.invalidate();\n\t\t\t\tthis.ui.requestRender();\n\t\t\t},\n\t\t\tlastComponent,\n\t\t\tstate: this.rendererState,\n\t\t\tcwd: this.cwd,\n\t\t\texecutionStarted: this.executionStarted,\n\t\t\targsComplete: this.argsComplete,\n\t\t\tisPartial: this.isPartial,\n\t\t\texpanded: this.expanded,\n\t\t\tshowImages: this.showImages,\n\t\t\tisError: this.result?.isError ?? false,\n\t\t};\n\t}\n\n\tprivate createCallFallback(): Component {\n\t\treturn new Text(theme.fg(\"toolTitle\", theme.bold(this.toolName)), 0, 0);\n\t}\n\n\tprivate createResultFallback(): Component | undefined {\n\t\tconst output = this.getTextOutput();\n\t\tif (!output) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn new Text(theme.fg(\"toolOutput\", output), 0, 0);\n\t}\n\n\tupdateArgs(args: any): void {\n\t\tthis.args = args;\n\t\tthis.updateDisplay();\n\t}\n\n\tmarkExecutionStarted(): void {\n\t\tthis.executionStarted = true;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tsetArgsComplete(): void {\n\t\tthis.argsComplete = true;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tupdateResult(\n\t\tresult: {\n\t\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\t\tdetails?: any;\n\t\t\tisError: boolean;\n\t\t},\n\t\tisPartial = false,\n\t): void {\n\t\tthis.result = result;\n\t\tthis.isPartial = isPartial;\n\t\tthis.updateDisplay();\n\t\tthis.maybeConvertImagesForKitty();\n\t}\n\n\tprivate maybeConvertImagesForKitty(): void {\n\t\tconst caps = getCapabilities();\n\t\tif (caps.images !== \"kitty\") return;\n\t\tif (!this.result) return;\n\n\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\tconst img = imageBlocks[i];\n\t\t\tif (!img.data || !img.mimeType) continue;\n\t\t\tif (img.mimeType === \"image/png\") continue;\n\t\t\tif (this.convertedImages.has(i)) continue;\n\n\t\t\tconst index = i;\n\t\t\tconvertToPng(img.data, img.mimeType).then((converted) => {\n\t\t\t\tif (this.frozen) return;\n\t\t\t\tif (converted) {\n\t\t\t\t\tthis.convertedImages.set(index, converted);\n\t\t\t\t\tthis.updateDisplay();\n\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\t// For radar/glance blocks the same global toggle reveals the hidden body;\n\t\t// for full blocks `expanded` alone switches truncated ↔ everything.\n\t\tthis.revealed = expanded;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetView(view: ToolOutputView): void {\n\t\tthis.view = view;\n\t\tthis.updateDisplay();\n\t}\n\n\t/**\n\t * Whether this block is currently opened up.\n\t *\n\t * Read by the one-at-a-time unfold, which walks back from the newest block\n\t * to find the first one still folded.\n\t */\n\tisRevealed(): boolean {\n\t\treturn this.revealed;\n\t}\n\n\t/** This call's contribution to its chain's summary line. */\n\tchainEntry(): ChainEntry {\n\t\tconst output = this.result ? this.getTextOutput() : \"\";\n\t\treturn {\n\t\t\ttool: this.toolName,\n\t\t\tsubject: toolSubject(this.args, this.cwd),\n\t\t\tisError: this.result?.isError === true,\n\t\t\tisPartial: this.result === undefined || this.isPartial,\n\t\t\toutputLines: output.trim() ? output.split(\"\\n\").length : 0,\n\t\t};\n\t}\n\n\t/** The failure text, for a collapsed chain to print under its line. */\n\terrorText(): string {\n\t\treturn this.result?.isError ? this.getTextOutput() : \"\";\n\t}\n\n\t/**\n\t * Whether the result body should render.\n\t *\n\t * A failure always shows its reason, in every view. Everything else about\n\t * these views is a judgement about how much detail you want; why something\n\t * broke is not detail, and a red dot with no explanation was the one thing\n\t * the folded views got wrong.\n\t */\n\tprivate shouldShowBody(): boolean {\n\t\treturn this.view === \"full\" || this.revealed || this.result?.isError === true;\n\t}\n\n\t/**\n\t * Whether this block draws its radar signal line instead of the tool's own\n\t * call renderer. A revealed block leaves radar for as long as it is open, so\n\t * \"expand\" means the same thing in every view.\n\t */\n\tprivate isLatest = false;\n\n\tprivate shouldShowSignalLine(): boolean {\n\t\treturn this.view === \"radar\" && !this.revealed;\n\t}\n\n\t/**\n\t * A failure's body under a radar row hangs off the row; anywhere else it sits\n\t * directly under its own call line and needs no extra indent.\n\t */\n\tprivate indentUnderSignalRow(component: Component): Component {\n\t\treturn this.shouldShowSignalLine() ? new IndentAll(component, 3) : component;\n\t}\n\n\t/**\n\t * Mark this block as the newest call in the transcript, or no longer it.\n\t *\n\t * Only radar draws anything from it: the other two views already show each\n\t * call in full, so there is nothing for a \"where am I\" mark to add.\n\t */\n\tsetLatest(isLatest: boolean): void {\n\t\tif (this.isLatest === isLatest) return;\n\t\tthis.isLatest = isLatest;\n\t\tthis.signalComponent?.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate getSignalComponent(): ToolSignalComponent {\n\t\tconst input = {\n\t\t\ttoolName: this.toolName,\n\t\t\targs: this.args,\n\t\t\tcwd: this.cwd,\n\t\t\tresult: this.result,\n\t\t\tisPartial: this.isPartial,\n\t\t\tshowImages: this.showImages,\n\t\t\tisLatest: this.isLatest,\n\t\t};\n\t\tif (this.signalComponent) {\n\t\t\tthis.signalComponent.setInput(input);\n\t\t} else {\n\t\t\tthis.signalComponent = new ToolSignalComponent(input);\n\t\t}\n\t\treturn this.signalComponent;\n\t}\n\n\tsetShowImages(show: boolean): void {\n\t\tthis.showImages = show;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetImageWidthCells(width: number): void {\n\t\tthis.imageWidthCells = Math.max(1, Math.floor(width));\n\t\tthis.updateDisplay();\n\t}\n\n\toverride invalidate(): void {\n\t\t// A frozen block has released the state updateDisplay would rebuild from;\n\t\t// its captured snapshot is authoritative, so skip the rebuild entirely.\n\t\tif (this.frozen) return;\n\t\tsuper.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\t/**\n\t * True when this block is a finished, visible tool result that still holds its\n\t * heavy source payloads — i.e. a candidate for freeze() once it scrolls out of\n\t * the live window. In-flight (partial) and already-frozen blocks are excluded.\n\t */\n\tisFreezable(): boolean {\n\t\treturn !this.frozen && !this.isPartial && !this.hideComponent && !!this.result;\n\t}\n\n\t/** Mark this block for freezing; the snapshot is captured on the next render\n\t * (at the real render width) and the heavy state released then. */\n\tfreeze(): void {\n\t\tif (this.isFreezable()) this.frozen = true;\n\t}\n\n\tprivate releaseHeavyState(): void {\n\t\tthis.result = undefined;\n\t\tthis.convertedImages.clear();\n\t\tthis.imageComponents = [];\n\t\tthis.imageSpacers = [];\n\t\tthis.rendererState = {};\n\t\tthis.callRendererComponent = undefined;\n\t\tthis.resultRendererComponent = undefined;\n\t\t// Drop child components so their line caches (which embed base64 image\n\t\t// payloads and full text output) become collectable.\n\t\tthis.clear();\n\t}\n\n\toverride render(width: number): string[] {\n\t\tif (this.hideComponent) {\n\t\t\treturn [];\n\t\t}\n\t\tif (this.frozenLines) {\n\t\t\t// Captured snapshot. Wider (or equal) terminal: emit as-is. Narrower:\n\t\t\t// re-truncate non-image lines to avoid the TUI's over-width crash guard,\n\t\t\t// caching the result per width so it stays O(1) on unchanged frames.\n\t\t\tif (width >= this.frozenWidth) return this.frozenLines;\n\t\t\tif (this.frozenTruncatedWidth === width && this.frozenTruncated) return this.frozenTruncated;\n\t\t\tthis.frozenTruncated = this.frozenLines.map((line) =>\n\t\t\t\tisImageLine(line) || visibleWidth(line) <= width ? line : truncateToWidth(line, width),\n\t\t\t);\n\t\t\tthis.frozenTruncatedWidth = width;\n\t\t\treturn this.frozenTruncated;\n\t\t}\n\t\tconst lines = super.render(width);\n\t\tif (this.frozen) {\n\t\t\tthis.frozenLines = lines;\n\t\t\tthis.frozenWidth = width;\n\t\t\tthis.releaseHeavyState();\n\t\t}\n\t\treturn lines;\n\t}\n\n\t/**\n\t * The container this block renders into.\n\t *\n\t * A self-rendering tool (`edit` draws its own framed diff) normally gets the\n\t * bare container so its frame can use the full width; everything else gets\n\t * the padded box. That only matters while the body is on screen. With the\n\t * body folded away the block is a single line, and the unpadded container\n\t * put it one column left of every other row — invisible while `peek` was an\n\t * opt-in, glaring now that `glance` is the default. So: padded box whenever\n\t * nothing is expanded, which also gives radar the uniform rows it exists for.\n\t */\n\tprivate activeShell(): Box | Container {\n\t\tif (!this.shouldShowBody()) return this.contentBox;\n\t\treturn this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox;\n\t}\n\n\t/** Swap the attached shell when the view changes which one applies. */\n\tprivate syncShellChild(): void {\n\t\tconst wanted = this.activeShell();\n\t\tconst other = wanted === this.contentBox ? this.selfRenderContainer : this.contentBox;\n\t\tif (this.children.includes(wanted)) return;\n\t\tthis.removeChild(other);\n\t\tother.clear();\n\t\tthis.addChild(wanted);\n\t}\n\n\tprivate updateDisplay(): void {\n\t\t// Frozen blocks are immutable snapshots with their source state released.\n\t\tif (this.frozen) return;\n\t\tlet hasContent = false;\n\t\tthis.hideComponent = false;\n\t\tthis.leadingSpacer.setLines(this.shouldShowSignalLine() ? 0 : 1);\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tthis.syncShellChild();\n\t\t\tconst renderContainer = this.activeShell();\n\t\t\t// Boxless: no background fill on the container.\n\t\t\tif (renderContainer instanceof Box) {\n\t\t\t\trenderContainer.setBgFn(undefined);\n\t\t\t}\n\t\t\trenderContainer.clear();\n\n\t\t\t// Status dot prefix: green for complete success, yellow for pending/partial, red for error.\n\t\t\t// The dot is prepended to the first line of the call renderer so it stays inline\n\t\t\t// (adding it as a separate child would stack it on its own line).\n\t\t\tconst dotColor = this.result?.isError ? \"error\" : this.isPartial ? \"warning\" : \"success\";\n\t\t\t// No disclosure caret. It is a click-target idiom in a TUI with no\n\t\t\t// pointer, it cost two columns on every row for an action that could\n\t\t\t// only ever be reached by keyboard, and reading it as \"this row opens\"\n\t\t\t// set an expectation the view does not meet.\n\t\t\tconst dot = theme.fg(dotColor, \"● \");\n\n\t\t\t// Radar replaces the tool's own call renderer with the uniform signal\n\t\t\t// row, so a screen of mixed tools lines up into one readable map.\n\t\t\tif (this.shouldShowSignalLine()) {\n\t\t\t\trenderContainer.addChild(new PrefixFirstLine(dot, this.getSignalComponent()));\n\t\t\t\thasContent = true;\n\t\t\t} else {\n\t\t\t\tconst callRenderer = this.getCallRenderer();\n\t\t\t\tif (!callRenderer) {\n\t\t\t\t\trenderContainer.addChild(new PrefixFirstLine(dot, this.createCallFallback()));\n\t\t\t\t\thasContent = true;\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst component = callRenderer(this.args, theme, this.getRenderContext(this.callRendererComponent));\n\t\t\t\t\t\tthis.callRendererComponent = component;\n\t\t\t\t\t\trenderContainer.addChild(new PrefixFirstLine(dot, component));\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tthis.callRendererComponent = undefined;\n\t\t\t\t\t\trenderContainer.addChild(new PrefixFirstLine(dot, this.createCallFallback()));\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.result && this.shouldShowBody()) {\n\t\t\t\tconst resultRenderer = this.getResultRenderer();\n\t\t\t\tif (!resultRenderer) {\n\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\tif (component) {\n\t\t\t\t\t\trenderContainer.addChild(this.indentUnderSignalRow(component));\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst component = resultRenderer(\n\t\t\t\t\t\t\t{ content: this.result.content as any, details: this.result.details },\n\t\t\t\t\t\t\t{ expanded: this.expanded, isPartial: this.isPartial },\n\t\t\t\t\t\t\ttheme,\n\t\t\t\t\t\t\tthis.getRenderContext(this.resultRendererComponent),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.resultRendererComponent = component;\n\t\t\t\t\t\trenderContainer.addChild(this.indentUnderSignalRow(component));\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tthis.resultRendererComponent = undefined;\n\t\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\t\tif (component) {\n\t\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// Boxless: no background fill.\n\t\t\tthis.contentText.setCustomBgFn(undefined);\n\t\t\tthis.contentText.setText(this.formatToolExecution());\n\t\t\thasContent = true;\n\t\t}\n\n\t\tfor (const img of this.imageComponents) {\n\t\t\tthis.removeChild(img);\n\t\t}\n\t\tthis.imageComponents = [];\n\t\tfor (const spacer of this.imageSpacers) {\n\t\t\tthis.removeChild(spacer);\n\t\t}\n\t\tthis.imageSpacers = [];\n\n\t\tif (this.result && !this.shouldShowSignalLine()) {\n\t\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\t\tconst caps = getCapabilities();\n\t\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\t\tconst img = imageBlocks[i];\n\t\t\t\tif (caps.images && this.showImages && img.data && img.mimeType) {\n\t\t\t\t\tconst converted = this.convertedImages.get(i);\n\t\t\t\t\tconst imageData = converted?.data ?? img.data;\n\t\t\t\t\tconst imageMimeType = converted?.mimeType ?? img.mimeType;\n\t\t\t\t\tif (caps.images === \"kitty\" && imageMimeType !== \"image/png\") continue;\n\n\t\t\t\t\tconst spacer = new Spacer(1);\n\t\t\t\t\tthis.addChild(spacer);\n\t\t\t\t\tthis.imageSpacers.push(spacer);\n\t\t\t\t\tconst imageComponent = new Image(\n\t\t\t\t\t\timageData,\n\t\t\t\t\t\timageMimeType,\n\t\t\t\t\t\t{ fallbackColor: (s: string) => theme.fg(\"toolOutput\", s) },\n\t\t\t\t\t\t{ maxWidthCells: this.imageWidthCells },\n\t\t\t\t\t);\n\t\t\t\t\tthis.imageComponents.push(imageComponent);\n\t\t\t\t\tthis.addChild(imageComponent);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (this.hasRendererDefinition() && !hasContent && this.imageComponents.length === 0) {\n\t\t\tthis.hideComponent = true;\n\t\t}\n\t}\n\n\tprivate getTextOutput(): string {\n\t\treturn getRenderedTextOutput(this.result, this.showImages);\n\t}\n\n\tprivate formatToolExecution(): string {\n\t\tconst dotColor = this.result?.isError ? \"error\" : this.isPartial ? \"warning\" : \"success\";\n\t\t// A tool with no renderer still gets a radar row, just without the\n\t\t// flush-right signal column (this path has no width to align against).\n\t\tif (this.shouldShowSignalLine()) {\n\t\t\tconst subject = toolSubject(this.args, this.cwd);\n\t\t\treturn (\n\t\t\t\ttheme.fg(dotColor, \"● \") +\n\t\t\t\ttheme.fg(\"toolTitle\", theme.bold(this.toolName)) +\n\t\t\t\t(subject ? ` ${theme.fg(\"toolOutput\", subject)}` : \"\")\n\t\t\t);\n\t\t}\n\t\tlet text = theme.fg(dotColor, \"● \") + theme.fg(\"toolTitle\", theme.bold(this.toolName));\n\t\tconst content = JSON.stringify(this.args, null, 2);\n\t\tif (content) {\n\t\t\ttext += `\\n\\n${content}`;\n\t\t}\n\t\tconst output = this.shouldShowBody() ? this.getTextOutput() : \"\";\n\t\tif (output) {\n\t\t\ttext += `\\n${output}`;\n\t\t}\n\t\treturn text;\n\t}\n}\n"]}
1
+ {"version":3,"file":"tool-execution.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,GAAG,EAEH,SAAS,EACT,eAAe,EACf,KAAK,EACL,WAAW,EACX,MAAM,EACN,IAAI,EAEJ,eAAe,EACf,YAAY,GACZ,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,wBAAwB,EAAiB,MAAM,8BAA8B,CAAC;AACvF,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC7F,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAcpE;;;;;;GAMG;AACH,MAAM,eAAe;IACZ,MAAM,CAAS;IACf,KAAK,CAAY;IACjB,WAAW,CAAS;IAC5B,2EAA2E;IAC3E,yEAAyE;IACjE,IAAI,CAAmD;IAE/D,YAAY,MAAc,EAAE,KAAgB,EAAE;QAC7C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,WAAW,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IAAA,CACxC;IAED,UAAU,GAAS;QAClB,IAAI,CAAC,KAAK,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AAI,CAAC,oBAAoB,EAAE,EAAE,CAAC;YACjC,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;YACjD,OAAO,CACN,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAI,CAAC;gBACxB,KAAK,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAChD,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC,YAAY,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CACtD,CAAC;QACH,CAAC;QACD,IAAI,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAI,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QACvF,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACnD,IAAI,OAAO,EAAE,CAAC;YACb,IAAI,IAAI,OAAO,OAAO,EAAE,CAAC;QAC1B,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjE,IAAI,MAAM,EAAE,CAAC;YACZ,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACvB,CAAC;QACD,OAAO,IAAI,CAAC;IAAA,CACZ;CACD","sourcesContent":["import {\n\tBox,\n\ttype Component,\n\tContainer,\n\tgetCapabilities,\n\tImage,\n\tisImageLine,\n\tSpacer,\n\tText,\n\ttype TUI,\n\ttruncateToWidth,\n\tvisibleWidth,\n} from \"@kolisachint/hoocode-tui\";\nimport type { ToolDefinition, ToolRenderContext } from \"../../../core/extensions/types.js\";\nimport type { ToolOutputView } from \"../../../core/tool-output-view.js\";\nimport { createAllToolDefinitions, type ToolName } from \"../../../core/tools/index.js\";\nimport { getTextOutput as getRenderedTextOutput } from \"../../../core/tools/render-utils.js\";\nimport { convertToPng } from \"../../../utils/image-convert.js\";\nimport { theme } from \"../theme/theme.js\";\nimport type { ChainEntry } from \"./tool-chain-summary.js\";\nimport { ToolSignalComponent, toolSubject } from \"./tool-signal.js\";\n\n/**\n * Re-exported so tool-block callers keep a single import site for the view\n * dial; the type itself lives in core (the settings manager persists it).\n */\nexport type { ToolOutputView } from \"../../../core/tool-output-view.js\";\n\nexport interface ToolExecutionOptions {\n\tshowImages?: boolean;\n\timageWidthCells?: number;\n\tview?: ToolOutputView;\n}\n\n/**\n * Renders a child component and prepends a prefix (e.g. a status dot) to its\n * first line, indenting continuation lines so they align under the content.\n *\n * This keeps the dot inline with the first line instead of stacking it on its\n * own line (which happens when a Container holds the dot as a separate child).\n */\nclass PrefixFirstLine implements Component {\n\tprivate prefix: string;\n\tprivate child: Component;\n\tprivate indentWidth: number;\n\t// Keyed on the child's returned array identity so an unchanged child keeps\n\t// this wrapper reference-stable too (parents memoize flattening by ref).\n\tprivate memo?: { src: string[]; width: number; out: string[] };\n\n\tconstructor(prefix: string, child: Component) {\n\t\tthis.prefix = prefix;\n\t\tthis.child = child;\n\t\tthis.indentWidth = visibleWidth(prefix);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.child.invalidate?.();\n\t\tthis.memo = undefined;\n\t}\n\n\trender(width: number): string[] {\n\t\t// Reserve room for the prefix so the child wraps within the remaining width.\n\t\tconst childWidth = Math.max(1, width - this.indentWidth);\n\t\tconst lines = this.child.render(childWidth);\n\t\tif (this.memo && this.memo.src === lines && this.memo.width === width) {\n\t\t\treturn this.memo.out;\n\t\t}\n\t\tconst indent = \" \".repeat(this.indentWidth);\n\t\tconst out =\n\t\t\tlines.length === 0 ? [this.prefix] : lines.map((line, i) => (i === 0 ? this.prefix + line : indent + line));\n\t\tthis.memo = { src: lines, width, out };\n\t\treturn out;\n\t}\n}\n\n/**\n * Indents every line of a child, unlike PrefixFirstLine which only offsets the\n * first. Used for a failure's body under a radar row, so the reason reads as\n * hanging off the row rather than starting a new column.\n */\nclass IndentAll implements Component {\n\tprivate child: Component;\n\tprivate indent: string;\n\tprivate memo?: { src: string[]; width: number; out: string[] };\n\n\tconstructor(child: Component, width: number) {\n\t\tthis.child = child;\n\t\tthis.indent = \" \".repeat(width);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.child.invalidate?.();\n\t\tthis.memo = undefined;\n\t}\n\n\trender(width: number): string[] {\n\t\tconst lines = this.child.render(Math.max(1, width - this.indent.length));\n\t\tif (this.memo && this.memo.src === lines && this.memo.width === width) return this.memo.out;\n\t\tconst out = lines.map((line) => (line.trim() === \"\" ? line : this.indent + line));\n\t\tthis.memo = { src: lines, width, out };\n\t\treturn out;\n\t}\n}\n\nexport class ToolExecutionComponent extends Container {\n\tprivate contentBox: Box;\n\tprivate contentText: Text;\n\tprivate selfRenderContainer: Container;\n\tprivate callRendererComponent?: Component;\n\tprivate resultRendererComponent?: Component;\n\tprivate rendererState: any = {};\n\tprivate imageComponents: Image[] = [];\n\tprivate imageSpacers: Spacer[] = [];\n\tprivate toolName: string;\n\tprivate toolCallId: string;\n\tprivate args: any;\n\tprivate expanded = false;\n\t// Persisted view (radar/glance/full). Controls how the call line is drawn and\n\t// whether the result body renders at all; `revealed` is the per-block override\n\t// the global expand key flips for radar/glance blocks.\n\tprivate view: ToolOutputView;\n\tprivate revealed = false;\n\tprivate signalComponent?: ToolSignalComponent;\n\tprivate leadingSpacer: Spacer;\n\tprivate showImages: boolean;\n\tprivate imageWidthCells: number;\n\tprivate isPartial = true;\n\tprivate toolDefinition?: ToolDefinition<any, any>;\n\tprivate builtInToolDefinition?: ToolDefinition<any, any>;\n\tprivate ui: TUI;\n\tprivate cwd: string;\n\tprivate executionStarted = false;\n\tprivate argsComplete = false;\n\tprivate result?: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tisError: boolean;\n\t\tdetails?: any;\n\t};\n\tprivate convertedImages: Map<number, { data: string; mimeType: string }> = new Map();\n\tprivate hideComponent = false;\n\t// Once a finished tool block has scrolled far out of view the interactive mode\n\t// freezes it (see freeze()): its already-rendered lines are captured and the\n\t// heavy source payloads (full tool result, base64 image copies, per-renderer\n\t// state, child component caches) are released. A frozen block is immutable and\n\t// no longer reflows on resize — old off-screen scrollback keeps its wrapping,\n\t// which self-heals on any full rebuild (theme toggle / session reload, both of\n\t// which reconstruct components from the intact session data).\n\tprivate frozen = false;\n\tprivate frozenLines?: string[];\n\t/** Width the frozen snapshot was captured at; a wider terminal is safe as-is,\n\t * a narrower one needs re-truncation to avoid the TUI's over-width crash guard. */\n\tprivate frozenWidth = 0;\n\tprivate frozenTruncated?: string[];\n\tprivate frozenTruncatedWidth = -1;\n\n\tconstructor(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: any,\n\t\toptions: ToolExecutionOptions = {},\n\t\ttoolDefinition: ToolDefinition<any, any> | undefined,\n\t\tui: TUI,\n\t\tcwd: string,\n\t) {\n\t\tsuper();\n\t\tthis.toolName = toolName;\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.args = args;\n\t\tthis.toolDefinition = toolDefinition;\n\t\tthis.builtInToolDefinition = createAllToolDefinitions(cwd)[toolName as ToolName];\n\t\tthis.showImages = options.showImages ?? true;\n\t\tthis.imageWidthCells = options.imageWidthCells ?? 60;\n\t\tthis.view = options.view ?? \"glance\";\n\t\tthis.ui = ui;\n\t\tthis.cwd = cwd;\n\n\t\t// The separator between consecutive tool blocks. Radar drops it: rows that\n\t\t// are one line each only read as a map when they stack without gaps.\n\t\tthis.leadingSpacer = new Spacer(1);\n\t\tthis.addChild(this.leadingSpacer);\n\n\t\t// Always create all shell variants. contentBox is used for default renderer-based composition.\n\t\t// selfRenderContainer is used when the tool renders its own framing.\n\t\t// contentText is reserved for generic fallback rendering when no tool definition exists.\n\t\t// Boxless: no filled background — hierarchy comes from status dots + indent.\n\t\t// paddingY is 0: the single leading Spacer(1) is the only separator between\n\t\t// tool blocks, so consecutive commands don't stack 3 blank lines between them.\n\t\tthis.contentBox = new Box(1, 0);\n\t\tthis.contentText = new Text(\"\", 1, 0);\n\t\tthis.selfRenderContainer = new Container();\n\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tthis.addChild(this.activeShell());\n\t\t} else {\n\t\t\tthis.addChild(this.contentText);\n\t\t}\n\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate getCallRenderer(): ToolDefinition<any, any>[\"renderCall\"] | undefined {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderCall;\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderCall;\n\t\t}\n\t\treturn this.toolDefinition.renderCall ?? this.builtInToolDefinition.renderCall;\n\t}\n\n\tprivate getResultRenderer(): ToolDefinition<any, any>[\"renderResult\"] | undefined {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderResult;\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderResult;\n\t\t}\n\t\treturn this.toolDefinition.renderResult ?? this.builtInToolDefinition.renderResult;\n\t}\n\n\tprivate hasRendererDefinition(): boolean {\n\t\treturn this.builtInToolDefinition !== undefined || this.toolDefinition !== undefined;\n\t}\n\n\tprivate getRenderShell(): \"default\" | \"self\" {\n\t\tif (!this.builtInToolDefinition) {\n\t\t\treturn this.toolDefinition?.renderShell ?? \"default\";\n\t\t}\n\t\tif (!this.toolDefinition) {\n\t\t\treturn this.builtInToolDefinition.renderShell ?? \"default\";\n\t\t}\n\t\treturn this.toolDefinition.renderShell ?? this.builtInToolDefinition.renderShell ?? \"default\";\n\t}\n\n\tprivate getRenderContext(lastComponent: Component | undefined): ToolRenderContext {\n\t\treturn {\n\t\t\targs: this.args,\n\t\t\ttoolCallId: this.toolCallId,\n\t\t\tinvalidate: () => {\n\t\t\t\tthis.invalidate();\n\t\t\t\tthis.ui.requestRender();\n\t\t\t},\n\t\t\tlastComponent,\n\t\t\tstate: this.rendererState,\n\t\t\tcwd: this.cwd,\n\t\t\texecutionStarted: this.executionStarted,\n\t\t\targsComplete: this.argsComplete,\n\t\t\tisPartial: this.isPartial,\n\t\t\texpanded: this.expanded,\n\t\t\tshowImages: this.showImages,\n\t\t\tisError: this.result?.isError ?? false,\n\t\t};\n\t}\n\n\tprivate createCallFallback(): Component {\n\t\treturn new Text(theme.fg(\"toolTitle\", theme.bold(this.toolName)), 0, 0);\n\t}\n\n\tprivate createResultFallback(): Component | undefined {\n\t\tconst output = this.getTextOutput();\n\t\tif (!output) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn new Text(theme.fg(\"toolOutput\", output), 0, 0);\n\t}\n\n\tupdateArgs(args: any): void {\n\t\tthis.args = args;\n\t\tthis.updateDisplay();\n\t}\n\n\tmarkExecutionStarted(): void {\n\t\tthis.executionStarted = true;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tsetArgsComplete(): void {\n\t\tthis.argsComplete = true;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tupdateResult(\n\t\tresult: {\n\t\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\t\tdetails?: any;\n\t\t\tisError: boolean;\n\t\t},\n\t\tisPartial = false,\n\t): void {\n\t\tthis.result = result;\n\t\tthis.isPartial = isPartial;\n\t\tthis.updateDisplay();\n\t\tthis.maybeConvertImagesForKitty();\n\t}\n\n\tprivate maybeConvertImagesForKitty(): void {\n\t\tconst caps = getCapabilities();\n\t\tif (caps.images !== \"kitty\") return;\n\t\tif (!this.result) return;\n\n\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\tconst img = imageBlocks[i];\n\t\t\tif (!img.data || !img.mimeType) continue;\n\t\t\tif (img.mimeType === \"image/png\") continue;\n\t\t\tif (this.convertedImages.has(i)) continue;\n\n\t\t\tconst index = i;\n\t\t\tconvertToPng(img.data, img.mimeType).then((converted) => {\n\t\t\t\tif (this.frozen) return;\n\t\t\t\tif (converted) {\n\t\t\t\t\tthis.convertedImages.set(index, converted);\n\t\t\t\t\tthis.updateDisplay();\n\t\t\t\t\tthis.ui.requestRender();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\t// For radar/glance blocks the same global toggle reveals the hidden body;\n\t\t// for full blocks `expanded` alone switches truncated ↔ everything.\n\t\tthis.revealed = expanded;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetView(view: ToolOutputView): void {\n\t\tthis.view = view;\n\t\tthis.updateDisplay();\n\t}\n\n\t/**\n\t * Whether this block is currently opened up.\n\t *\n\t * Read by the one-at-a-time unfold, which walks back from the newest block\n\t * to find the first one still folded.\n\t */\n\tisRevealed(): boolean {\n\t\treturn this.revealed;\n\t}\n\n\t/** This call's contribution to its chain's summary line. */\n\tchainEntry(): ChainEntry {\n\t\tconst output = this.result ? this.getTextOutput() : \"\";\n\t\treturn {\n\t\t\ttool: this.toolName,\n\t\t\tsubject: toolSubject(this.args, this.cwd),\n\t\t\tisError: this.result?.isError === true,\n\t\t\tisPartial: this.result === undefined || this.isPartial,\n\t\t\toutputLines: output.trim() ? output.split(\"\\n\").length : 0,\n\t\t};\n\t}\n\n\t/** The failure text, for a collapsed chain to print under its line. */\n\terrorText(): string {\n\t\treturn this.result?.isError ? this.getTextOutput() : \"\";\n\t}\n\n\t/**\n\t * Whether the result body should render.\n\t *\n\t * A failure always shows its reason, in every view. Everything else about\n\t * these views is a judgement about how much detail you want; why something\n\t * broke is not detail, and a red dot with no explanation was the one thing\n\t * the folded views got wrong.\n\t */\n\tprivate shouldShowBody(): boolean {\n\t\treturn this.view === \"full\" || this.revealed || this.result?.isError === true;\n\t}\n\n\t/**\n\t * Whether this block draws its radar signal line instead of the tool's own\n\t * call renderer. A revealed block leaves radar for as long as it is open, so\n\t * \"expand\" means the same thing in every view.\n\t */\n\tprivate isLatest = false;\n\n\tprivate shouldShowSignalLine(): boolean {\n\t\treturn this.view === \"radar\" && !this.revealed;\n\t}\n\n\t/**\n\t * Whether this block draws its own blank row above itself.\n\t *\n\t * Radar rows do not — rows that are one line each only read as a map when\n\t * they stack without gaps — which leaves the first row of a run with nothing\n\t * between it and whatever introduced it. `ToolChainComponent` asks this so\n\t * the run can draw that one gap itself without doubling a gap the block was\n\t * already drawing, which is what happens in every other view and for a radar\n\t * block that has been opened.\n\t */\n\tdrawsLeadingGap(): boolean {\n\t\treturn !this.shouldShowSignalLine();\n\t}\n\n\t/**\n\t * A failure's body under a radar row hangs off the row; anywhere else it sits\n\t * directly under its own call line and needs no extra indent.\n\t */\n\tprivate indentUnderSignalRow(component: Component): Component {\n\t\treturn this.shouldShowSignalLine() ? new IndentAll(component, 3) : component;\n\t}\n\n\t/**\n\t * Mark this block as the newest call in the transcript, or no longer it.\n\t *\n\t * Only radar draws anything from it: the other two views already show each\n\t * call in full, so there is nothing for a \"where am I\" mark to add.\n\t */\n\tsetLatest(isLatest: boolean): void {\n\t\tif (this.isLatest === isLatest) return;\n\t\tthis.isLatest = isLatest;\n\t\tthis.signalComponent?.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate getSignalComponent(): ToolSignalComponent {\n\t\tconst input = {\n\t\t\ttoolName: this.toolName,\n\t\t\targs: this.args,\n\t\t\tcwd: this.cwd,\n\t\t\tresult: this.result,\n\t\t\tisPartial: this.isPartial,\n\t\t\tshowImages: this.showImages,\n\t\t\tisLatest: this.isLatest,\n\t\t};\n\t\tif (this.signalComponent) {\n\t\t\tthis.signalComponent.setInput(input);\n\t\t} else {\n\t\t\tthis.signalComponent = new ToolSignalComponent(input);\n\t\t}\n\t\treturn this.signalComponent;\n\t}\n\n\tsetShowImages(show: boolean): void {\n\t\tthis.showImages = show;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetImageWidthCells(width: number): void {\n\t\tthis.imageWidthCells = Math.max(1, Math.floor(width));\n\t\tthis.updateDisplay();\n\t}\n\n\toverride invalidate(): void {\n\t\t// A frozen block has released the state updateDisplay would rebuild from;\n\t\t// its captured snapshot is authoritative, so skip the rebuild entirely.\n\t\tif (this.frozen) return;\n\t\tsuper.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\t/**\n\t * True when this block is a finished, visible tool result that still holds its\n\t * heavy source payloads — i.e. a candidate for freeze() once it scrolls out of\n\t * the live window. In-flight (partial) and already-frozen blocks are excluded.\n\t */\n\tisFreezable(): boolean {\n\t\treturn !this.frozen && !this.isPartial && !this.hideComponent && !!this.result;\n\t}\n\n\t/** Mark this block for freezing; the snapshot is captured on the next render\n\t * (at the real render width) and the heavy state released then. */\n\tfreeze(): void {\n\t\tif (this.isFreezable()) this.frozen = true;\n\t}\n\n\tprivate releaseHeavyState(): void {\n\t\tthis.result = undefined;\n\t\tthis.convertedImages.clear();\n\t\tthis.imageComponents = [];\n\t\tthis.imageSpacers = [];\n\t\tthis.rendererState = {};\n\t\tthis.callRendererComponent = undefined;\n\t\tthis.resultRendererComponent = undefined;\n\t\t// Drop child components so their line caches (which embed base64 image\n\t\t// payloads and full text output) become collectable.\n\t\tthis.clear();\n\t}\n\n\toverride render(width: number): string[] {\n\t\tif (this.hideComponent) {\n\t\t\treturn [];\n\t\t}\n\t\tif (this.frozenLines) {\n\t\t\t// Captured snapshot. Wider (or equal) terminal: emit as-is. Narrower:\n\t\t\t// re-truncate non-image lines to avoid the TUI's over-width crash guard,\n\t\t\t// caching the result per width so it stays O(1) on unchanged frames.\n\t\t\tif (width >= this.frozenWidth) return this.frozenLines;\n\t\t\tif (this.frozenTruncatedWidth === width && this.frozenTruncated) return this.frozenTruncated;\n\t\t\tthis.frozenTruncated = this.frozenLines.map((line) =>\n\t\t\t\tisImageLine(line) || visibleWidth(line) <= width ? line : truncateToWidth(line, width),\n\t\t\t);\n\t\t\tthis.frozenTruncatedWidth = width;\n\t\t\treturn this.frozenTruncated;\n\t\t}\n\t\tconst lines = super.render(width);\n\t\tif (this.frozen) {\n\t\t\tthis.frozenLines = lines;\n\t\t\tthis.frozenWidth = width;\n\t\t\tthis.releaseHeavyState();\n\t\t}\n\t\treturn lines;\n\t}\n\n\t/**\n\t * The container this block renders into.\n\t *\n\t * A self-rendering tool (`edit` draws its own framed diff) normally gets the\n\t * bare container so its frame can use the full width; everything else gets\n\t * the padded box. That only matters while the body is on screen. With the\n\t * body folded away the block is a single line, and the unpadded container\n\t * put it one column left of every other row — invisible while `peek` was an\n\t * opt-in, glaring now that `glance` is the default. So: padded box whenever\n\t * nothing is expanded, which also gives radar the uniform rows it exists for.\n\t */\n\tprivate activeShell(): Box | Container {\n\t\tif (!this.shouldShowBody()) return this.contentBox;\n\t\treturn this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox;\n\t}\n\n\t/** Swap the attached shell when the view changes which one applies. */\n\tprivate syncShellChild(): void {\n\t\tconst wanted = this.activeShell();\n\t\tconst other = wanted === this.contentBox ? this.selfRenderContainer : this.contentBox;\n\t\tif (this.children.includes(wanted)) return;\n\t\tthis.removeChild(other);\n\t\tother.clear();\n\t\tthis.addChild(wanted);\n\t}\n\n\tprivate updateDisplay(): void {\n\t\t// Frozen blocks are immutable snapshots with their source state released.\n\t\tif (this.frozen) return;\n\t\tlet hasContent = false;\n\t\tthis.hideComponent = false;\n\t\tthis.leadingSpacer.setLines(this.shouldShowSignalLine() ? 0 : 1);\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tthis.syncShellChild();\n\t\t\tconst renderContainer = this.activeShell();\n\t\t\t// Boxless: no background fill on the container.\n\t\t\tif (renderContainer instanceof Box) {\n\t\t\t\trenderContainer.setBgFn(undefined);\n\t\t\t}\n\t\t\trenderContainer.clear();\n\n\t\t\t// Status dot prefix: green for complete success, yellow for pending/partial, red for error.\n\t\t\t// The dot is prepended to the first line of the call renderer so it stays inline\n\t\t\t// (adding it as a separate child would stack it on its own line).\n\t\t\tconst dotColor = this.result?.isError ? \"error\" : this.isPartial ? \"warning\" : \"success\";\n\t\t\t// No disclosure caret. It is a click-target idiom in a TUI with no\n\t\t\t// pointer, it cost two columns on every row for an action that could\n\t\t\t// only ever be reached by keyboard, and reading it as \"this row opens\"\n\t\t\t// set an expectation the view does not meet.\n\t\t\tconst dot = theme.fg(dotColor, \"● \");\n\n\t\t\t// Radar replaces the tool's own call renderer with the uniform signal\n\t\t\t// row, so a screen of mixed tools lines up into one readable map.\n\t\t\tif (this.shouldShowSignalLine()) {\n\t\t\t\trenderContainer.addChild(new PrefixFirstLine(dot, this.getSignalComponent()));\n\t\t\t\thasContent = true;\n\t\t\t} else {\n\t\t\t\tconst callRenderer = this.getCallRenderer();\n\t\t\t\tif (!callRenderer) {\n\t\t\t\t\trenderContainer.addChild(new PrefixFirstLine(dot, this.createCallFallback()));\n\t\t\t\t\thasContent = true;\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst component = callRenderer(this.args, theme, this.getRenderContext(this.callRendererComponent));\n\t\t\t\t\t\tthis.callRendererComponent = component;\n\t\t\t\t\t\trenderContainer.addChild(new PrefixFirstLine(dot, component));\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tthis.callRendererComponent = undefined;\n\t\t\t\t\t\trenderContainer.addChild(new PrefixFirstLine(dot, this.createCallFallback()));\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.result && this.shouldShowBody()) {\n\t\t\t\tconst resultRenderer = this.getResultRenderer();\n\t\t\t\tif (!resultRenderer) {\n\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\tif (component) {\n\t\t\t\t\t\trenderContainer.addChild(this.indentUnderSignalRow(component));\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst component = resultRenderer(\n\t\t\t\t\t\t\t{ content: this.result.content as any, details: this.result.details },\n\t\t\t\t\t\t\t{ expanded: this.expanded, isPartial: this.isPartial },\n\t\t\t\t\t\t\ttheme,\n\t\t\t\t\t\t\tthis.getRenderContext(this.resultRendererComponent),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.resultRendererComponent = component;\n\t\t\t\t\t\trenderContainer.addChild(this.indentUnderSignalRow(component));\n\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tthis.resultRendererComponent = undefined;\n\t\t\t\t\t\tconst component = this.createResultFallback();\n\t\t\t\t\t\tif (component) {\n\t\t\t\t\t\t\trenderContainer.addChild(component);\n\t\t\t\t\t\t\thasContent = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// Boxless: no background fill.\n\t\t\tthis.contentText.setCustomBgFn(undefined);\n\t\t\tthis.contentText.setText(this.formatToolExecution());\n\t\t\thasContent = true;\n\t\t}\n\n\t\tfor (const img of this.imageComponents) {\n\t\t\tthis.removeChild(img);\n\t\t}\n\t\tthis.imageComponents = [];\n\t\tfor (const spacer of this.imageSpacers) {\n\t\t\tthis.removeChild(spacer);\n\t\t}\n\t\tthis.imageSpacers = [];\n\n\t\tif (this.result && !this.shouldShowSignalLine()) {\n\t\t\tconst imageBlocks = this.result.content.filter((c) => c.type === \"image\");\n\t\t\tconst caps = getCapabilities();\n\t\t\tfor (let i = 0; i < imageBlocks.length; i++) {\n\t\t\t\tconst img = imageBlocks[i];\n\t\t\t\tif (caps.images && this.showImages && img.data && img.mimeType) {\n\t\t\t\t\tconst converted = this.convertedImages.get(i);\n\t\t\t\t\tconst imageData = converted?.data ?? img.data;\n\t\t\t\t\tconst imageMimeType = converted?.mimeType ?? img.mimeType;\n\t\t\t\t\tif (caps.images === \"kitty\" && imageMimeType !== \"image/png\") continue;\n\n\t\t\t\t\tconst spacer = new Spacer(1);\n\t\t\t\t\tthis.addChild(spacer);\n\t\t\t\t\tthis.imageSpacers.push(spacer);\n\t\t\t\t\tconst imageComponent = new Image(\n\t\t\t\t\t\timageData,\n\t\t\t\t\t\timageMimeType,\n\t\t\t\t\t\t{ fallbackColor: (s: string) => theme.fg(\"toolOutput\", s) },\n\t\t\t\t\t\t{ maxWidthCells: this.imageWidthCells },\n\t\t\t\t\t);\n\t\t\t\t\tthis.imageComponents.push(imageComponent);\n\t\t\t\t\tthis.addChild(imageComponent);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (this.hasRendererDefinition() && !hasContent && this.imageComponents.length === 0) {\n\t\t\tthis.hideComponent = true;\n\t\t}\n\t}\n\n\tprivate getTextOutput(): string {\n\t\treturn getRenderedTextOutput(this.result, this.showImages);\n\t}\n\n\tprivate formatToolExecution(): string {\n\t\tconst dotColor = this.result?.isError ? \"error\" : this.isPartial ? \"warning\" : \"success\";\n\t\t// A tool with no renderer still gets a radar row, just without the\n\t\t// flush-right signal column (this path has no width to align against).\n\t\tif (this.shouldShowSignalLine()) {\n\t\t\tconst subject = toolSubject(this.args, this.cwd);\n\t\t\treturn (\n\t\t\t\ttheme.fg(dotColor, \"● \") +\n\t\t\t\ttheme.fg(\"toolTitle\", theme.bold(this.toolName)) +\n\t\t\t\t(subject ? ` ${theme.fg(\"toolOutput\", subject)}` : \"\")\n\t\t\t);\n\t\t}\n\t\tlet text = theme.fg(dotColor, \"● \") + theme.fg(\"toolTitle\", theme.bold(this.toolName));\n\t\tconst content = JSON.stringify(this.args, null, 2);\n\t\tif (content) {\n\t\t\ttext += `\\n\\n${content}`;\n\t\t}\n\t\tconst output = this.shouldShowBody() ? this.getTextOutput() : \"\";\n\t\tif (output) {\n\t\t\ttext += `\\n${output}`;\n\t\t}\n\t\treturn text;\n\t}\n}\n"]}
package/docs/themes.md CHANGED
@@ -393,9 +393,11 @@ message, an extension message, an error or warning notice — so the block reads
393
393
  as a sheet laid on the page rather than a colour printed into it. A terminal has
394
394
  no sub-pixel offsets and no blur, so the band is one extra row of `▀`: an upper
395
395
  half-block, which paints solid colour across the top half of its cells and so
396
- hugs the block's bottom edge, indented one column to give the offset. There is
397
- no matching right-hand column, because these boxes render at the full terminal
398
- width and a column past the last cell has nowhere to go.
396
+ hugs the block's bottom edge, indented one column to give the offset. The
397
+ block's right edge gets the matching column of `▌` a left half-block, which
398
+ paints the half of its cell nearest the sheet and the bottom run reaches under
399
+ that column, so the two close the corner instead of stopping a cell short of
400
+ each other.
399
401
 
400
402
  Setting it also gives the block the rest of the paper treatment, because the
401
403
  three are one decision rather than three. A block that runs from margin to
@@ -407,6 +409,15 @@ than ruled: roughly one row in five gives up a single column, always out of
407
409
  padding and never out of content, from a hash that is stable for the block so
408
410
  the edge does not reshuffle between frames.
409
411
 
412
+ The cut moves the sheet, never the shadow. Letting the shadow follow the nick
413
+ was the first attempt and it cost the shadow its line: `▌` paints half a cell,
414
+ so a one-column step leaves no overlap between one row's mark and the next, and
415
+ a column that stepped in and out every fifth row read as a dashed staircase
416
+ rather than an edge — the more so because the sheet's own edge is a quiet colour
417
+ and the shadow is the loud one. A nicked row now shows its cut as a column of
418
+ page between sheet and shadow, which is what a nick looks like, and the shadow
419
+ stays one straight line down the sheet.
420
+
410
421
  It is a shape, not text, so it answers to the 2.8:1 decorative floor rather than
411
422
  a text-contrast one — and it has to stay ΔE-clear of every `*Bg` token as well,
412
423
  or the shadow sinks into the sheet it is hugging. On a dark theme nothing can be
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kolisachint/hoocode-extension-custom-provider-anthropic",
3
3
  "private": true,
4
- "version": "0.3.37",
4
+ "version": "0.3.38",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "bun": ">=1.0.0"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kolisachint/hoocode-extension-custom-provider-gitlab-duo",
3
3
  "private": true,
4
- "version": "0.3.37",
4
+ "version": "0.3.38",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "bun": ">=1.0.0"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kolisachint/hoocode-extension-sandbox",
3
3
  "private": true,
4
- "version": "0.3.37",
4
+ "version": "0.3.38",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "bun": ">=1.0.0"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kolisachint/hoocode-extension-with-deps",
3
3
  "private": true,
4
- "version": "0.3.37",
4
+ "version": "0.3.38",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "bun": ">=1.0.0"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kolisachint/hoocode-agent",
3
- "version": "0.5.37",
3
+ "version": "0.5.38",
4
4
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "hoocodeConfig": {
@@ -50,9 +50,9 @@
50
50
  "prepublishOnly": "npm run clean && npm run build"
51
51
  },
52
52
  "dependencies": {
53
- "@kolisachint/hoocode-agent-core": "^0.5.37",
54
- "@kolisachint/hoocode-ai": "^0.5.37",
55
- "@kolisachint/hoocode-tui": "^0.5.37",
53
+ "@kolisachint/hoocode-agent-core": "^0.5.38",
54
+ "@kolisachint/hoocode-ai": "^0.5.38",
55
+ "@kolisachint/hoocode-tui": "^0.5.38",
56
56
  "@silvia-odwyer/photon-node": "^0.3.4",
57
57
  "chalk": "^5.5.0",
58
58
  "cli-highlight": "^2.1.11",