apex-code 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/core/keybindings.d.ts +5 -0
  3. package/dist/core/keybindings.d.ts.map +1 -1
  4. package/dist/core/keybindings.js +1 -0
  5. package/dist/core/keybindings.js.map +1 -1
  6. package/dist/modes/interactive/components/bash-execution.d.ts +13 -2
  7. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  8. package/dist/modes/interactive/components/bash-execution.js +56 -1
  9. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  10. package/dist/modes/interactive/components/error-summary.d.ts +2 -0
  11. package/dist/modes/interactive/components/error-summary.d.ts.map +1 -1
  12. package/dist/modes/interactive/components/error-summary.js +10 -0
  13. package/dist/modes/interactive/components/error-summary.js.map +1 -1
  14. package/dist/modes/interactive/components/footer.d.ts +3 -0
  15. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  16. package/dist/modes/interactive/components/footer.js +13 -0
  17. package/dist/modes/interactive/components/footer.js.map +1 -1
  18. package/dist/modes/interactive/components/tool-execution.d.ts +9 -1
  19. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  20. package/dist/modes/interactive/components/tool-execution.js +81 -8
  21. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  22. package/dist/modes/interactive/components/tool-panel.d.ts +7 -0
  23. package/dist/modes/interactive/components/tool-panel.d.ts.map +1 -1
  24. package/dist/modes/interactive/components/tool-panel.js +35 -0
  25. package/dist/modes/interactive/components/tool-panel.js.map +1 -1
  26. package/dist/modes/interactive/interactive-mode.d.ts +1 -0
  27. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  28. package/dist/modes/interactive/interactive-mode.js +29 -11
  29. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  30. package/docs/keybindings.md +2 -1
  31. package/npm-shrinkwrap.json +5 -5
  32. package/package.json +2 -2
@@ -1,9 +1,11 @@
1
1
  import { Box, Container, getCapabilities, Image, MouseRegion, Spacer, Text, } from "@earendil-works/pi-tui";
2
2
  import { getTextOutput as getRenderedTextOutput } from "../../../core/tools/render-utils.js";
3
+ import { stripAnsi } from "../../../utils/ansi.js";
3
4
  import { convertToPng } from "../../../utils/image-convert.js";
4
5
  import { theme } from "../theme/theme.js";
5
- import { formatHiddenLines, previewLineCount } from "./keybinding-hints.js";
6
- import { ToolPanelComponent, ToolStatusLineComponent, } from "./tool-panel.js";
6
+ import { summarizeOperationError } from "./error-summary.js";
7
+ import { formatHiddenLines, keyText, previewLineCount } from "./keybinding-hints.js";
8
+ import { countOutputLines, renderCompactOperationRow, ToolPanelComponent, ToolStatusLineComponent, } from "./tool-panel.js";
7
9
  const COLLAPSED_ERROR_VISUAL_LINE_LIMIT = 3;
8
10
  const FALLBACK_PREVIEW_LINES = 10;
9
11
  /** The phrase every expand affordance ends with, here and in each tool's own renderer. */
@@ -21,6 +23,8 @@ export class ToolExecutionComponent extends Container {
21
23
  toolCallId;
22
24
  args;
23
25
  expanded = false;
26
+ collapsedOverride = false;
27
+ chatDetail = "details";
24
28
  editDiffsExpanded = true;
25
29
  showImages;
26
30
  imageWidthCells;
@@ -39,6 +43,7 @@ export class ToolExecutionComponent extends Container {
39
43
  // per-frame cost grow with the number of tools on screen; see
40
44
  // test/tool-execution-render-cache.test.ts.
41
45
  displayVersion = 0;
46
+ compactContent;
42
47
  cachedRender;
43
48
  result;
44
49
  convertedImages = new Map();
@@ -97,7 +102,7 @@ export class ToolExecutionComponent extends Container {
97
102
  argsComplete: this.argsComplete,
98
103
  isPartial: this.isPartial,
99
104
  expanded: this.expanded,
100
- editDiffsExpanded: this.editDiffsExpanded,
105
+ editDiffsExpanded: this.expanded || this.editDiffsExpanded,
101
106
  showImages: this.showImages,
102
107
  isError: this.result?.isError ?? false,
103
108
  };
@@ -124,7 +129,7 @@ export class ToolExecutionComponent extends Container {
124
129
  return new MouseRegion(component, (event) => {
125
130
  if (!this.result || event.type !== "click" || event.button !== "left")
126
131
  return undefined;
127
- this.setExpanded(!this.expanded);
132
+ this.toggleExpanded();
128
133
  return { handled: true };
129
134
  });
130
135
  }
@@ -208,7 +213,22 @@ export class ToolExecutionComponent extends Container {
208
213
  this.editDiffsExpanded = expanded;
209
214
  this.updateDisplay();
210
215
  }
216
+ setChatDetail(detail) {
217
+ this.chatDetail = detail;
218
+ this.collapsedOverride = false;
219
+ this.expanded = detail === "all";
220
+ this.editDiffsExpanded = detail !== "overview";
221
+ this.updateDisplay();
222
+ }
223
+ toggleExpanded() {
224
+ this.expanded = !this.expanded;
225
+ this.collapsedOverride = !this.expanded;
226
+ this.editDiffsExpanded = this.expanded;
227
+ this.updateDisplay();
228
+ this.ui.requestRender();
229
+ }
211
230
  setExpanded(expanded) {
231
+ this.collapsedOverride = false;
212
232
  this.expanded = expanded;
213
233
  this.updateDisplay();
214
234
  }
@@ -281,7 +301,58 @@ export class ToolExecutionComponent extends Container {
281
301
  const durationKey = lifecycle === "running" ? Math.floor((durationMs ?? 0) / 250) : (durationMs ?? -1);
282
302
  return `${this.displayVersion}:${lifecycle}:${durationKey}`;
283
303
  }
304
+ isCompact() {
305
+ return this.collapsedOverride || (this.chatDetail === "overview" && !this.expanded);
306
+ }
307
+ composeCompact(width) {
308
+ let content = this.compactContent;
309
+ if (!content || content.version !== this.displayVersion) {
310
+ // Inspect each renderer once per display update, not on every elapsed-time tick.
311
+ const callLines = this.callRendererComponent?.render(400);
312
+ const visibleCall = callLines?.find((line) => stripAnsi(line).trim().length > 0);
313
+ const resultLines = this.resultRendererComponent?.render(400);
314
+ const resultHidden = !!this.resultRendererComponent && resultLines?.length === 0;
315
+ const args = this.args;
316
+ const target = args?.path ?? args?.file_path ?? args?.command ?? args?.pattern;
317
+ const fallbackLabel = `${this.toolName}${typeof target === "string" ? ` ${target}` : ""}`;
318
+ const output = resultHidden
319
+ ? ""
320
+ : (this.result?.content
321
+ .filter((block) => block.type === "text")
322
+ .map((block) => block.text ?? "")
323
+ .join("\n") ?? "");
324
+ const outputLines = countOutputLines(output);
325
+ const images = resultHidden ? 0 : (this.result?.content.filter((block) => block.type === "image").length ?? 0);
326
+ const summary = this.result?.isError && output
327
+ ? summarizeOperationError(output)
328
+ : [
329
+ outputLines ? `${outputLines} output line${outputLines === 1 ? "" : "s"}` : "",
330
+ images ? `${images} image${images === 1 ? "" : "s"}` : "",
331
+ ]
332
+ .filter(Boolean)
333
+ .join(", ");
334
+ const label = stripAnsi(visibleCall ?? fallbackLabel).replace(` (${keyText("app.tools.expand")} to expand)`, "");
335
+ content = {
336
+ version: this.displayVersion,
337
+ label,
338
+ summary,
339
+ hidden: callLines?.length === 0 && (!this.result || resultHidden) && !images,
340
+ };
341
+ this.compactContent = content;
342
+ }
343
+ if (content.hidden)
344
+ return [];
345
+ return renderCompactOperationRow({
346
+ label: content.label,
347
+ summary: content.summary,
348
+ lifecycle: this.getLifecycle(),
349
+ symbolPreset: this.symbolPreset,
350
+ durationMs: this.getDurationMs(),
351
+ }, width);
352
+ }
284
353
  compose(width) {
354
+ if (this.isCompact())
355
+ return this.composeCompact(width);
285
356
  const shell = this.hasRendererDefinition()
286
357
  ? this.getRenderShell() === "self"
287
358
  ? this.selfRenderContainer
@@ -323,14 +394,16 @@ export class ToolExecutionComponent extends Container {
323
394
  * handlers do. Apex composes the panel itself (lifecycle header, spine,
324
395
  * padding, the separator row it inserts), so rendered rows do not line up
325
396
  * with the children's rows and the inherited child-by-child dispatch would
326
- * resolve the wrong region. Row 0 is the leading spacer and is inert.
397
+ * resolve the wrong region. Row 0 is clickable in a compact row and otherwise a spacer.
327
398
  */
328
399
  handleMouse(event) {
329
- if (this.hideComponent || event.y <= 0 || event.y >= event.height)
400
+ if (this.hideComponent || event.y < 0 || event.y >= event.height)
401
+ return undefined;
402
+ if (event.y === 0 && !this.isCompact())
330
403
  return undefined;
331
- if (!this.result || event.type !== "click" || event.button !== "left")
404
+ if ((!this.result && !this.isCompact()) || event.type !== "click" || event.button !== "left")
332
405
  return undefined;
333
- this.setExpanded(!this.expanded);
406
+ this.toggleExpanded();
334
407
  return {
335
408
  handled: true,
336
409
  target: {
@@ -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,IAAI,GAGJ,MAAM,wBAAwB,CAAC;AAuBhC,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;AAC1C,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAEN,kBAAkB,EAClB,uBAAuB,GAEvB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,iCAAiC,GAAG,CAAC,CAAC;AAE5C,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAQlC,0FAA0F;AAE1F,MAAM,OAAO,sBAAuB,SAAQ,SAAS;IAC5C,UAAU,CAAM;IAChB,WAAW,CAAO;IAClB,iBAAiB,CAAc;IAC/B,mBAAmB,CAAY;IAC/B,qBAAqB,CAAa;IAClC,uBAAuB,CAAa;IACpC,aAAa,GAAQ,EAAE,CAAC;IACxB,eAAe,GAAY,EAAE,CAAC;IAC9B,YAAY,GAAa,EAAE,CAAC;IAC5B,QAAQ,CAAS;IACjB,UAAU,CAAS;IACnB,IAAI,CAAM;IACV,QAAQ,GAAG,KAAK,CAAC;IACjB,iBAAiB,GAAG,IAAI,CAAC;IACzB,UAAU,CAAU;IACpB,eAAe,CAAS;IACxB,SAAS,GAAG,IAAI,CAAC;IACjB,cAAc,CAAiB;IAC/B,EAAE,CAAM;IACR,GAAG,CAA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,eAAe,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;oBAC1C,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;gBAC/B,CAAC;YACF,CAAC;QACF,CAAC;QAED,IAAI,IAAI,CAAC,qBAAqB,EAAE,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtF,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC3B,CAAC;IAAA,CACD;IAEO,aAAa,GAAW;QAC/B,OAAO,qBAAqB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAAA,CAC3D;IAEO,mBAAmB,GAAW;QACrC,IAAI,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC5D,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,aAAa,EAAE,CAAC;QACpC,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\tMouseRegion,\n\tSpacer,\n\tText,\n\ttype TUI,\n\ttype TuiMouseEvent,\n} from \"@earendil-works/pi-tui\";\nimport type { AgentToolResult } from \"apex-code-agent-core\";\nimport type { ToolDefinition, ToolRenderContext, ToolRenderResultOptions } from \"../../../core/extensions/types.ts\";\nimport type { Theme } from \"../theme/theme.ts\";\n\n/**\n * What this component needs from a tool: how to draw it. It neither executes tools nor reads their\n * parameter schemas, so a definition and a bare renderer pair are equally acceptable.\n *\n * The renderer parameters are `any` on purpose: a `ToolDefinition` types them from its schema, and\n * narrowing them here would make those definitions unassignable.\n */\nexport interface ToolRenderers {\n\trenderShell?: \"default\" | \"self\";\n\trenderCall?: (args: any, theme: Theme, context: ToolRenderContext<any, any>) => Component;\n\trenderResult?: (\n\t\tresult: AgentToolResult<any>,\n\t\toptions: ToolRenderResultOptions,\n\t\ttheme: Theme,\n\t\tcontext: ToolRenderContext<any, any>,\n\t) => Component;\n}\n\nimport { getTextOutput as getRenderedTextOutput } from \"../../../core/tools/render-utils.ts\";\nimport { convertToPng } from \"../../../utils/image-convert.ts\";\nimport { theme } from \"../theme/theme.ts\";\nimport { formatHiddenLines, previewLineCount } from \"./keybinding-hints.ts\";\nimport {\n\ttype ToolLifecycle,\n\tToolPanelComponent,\n\tToolStatusLineComponent,\n\ttype ToolSymbolPreset,\n} from \"./tool-panel.ts\";\n\nconst COLLAPSED_ERROR_VISUAL_LINE_LIMIT = 3;\n\nconst FALLBACK_PREVIEW_LINES = 10;\n\nexport interface ToolExecutionOptions {\n\tshowImages?: boolean;\n\timageWidthCells?: number;\n\tsymbolPreset?: ToolSymbolPreset;\n}\n\n/** The phrase every expand affordance ends with, here and in each tool's own renderer. */\n\nexport class ToolExecutionComponent extends Container {\n\tprivate contentBox: Box;\n\tprivate contentText: Text;\n\tprivate contentTextRegion: MouseRegion;\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\tprivate editDiffsExpanded = true;\n\tprivate showImages: boolean;\n\tprivate imageWidthCells: number;\n\tprivate isPartial = true;\n\tprivate toolDefinition?: ToolRenderers;\n\tprivate ui: TUI;\n\tprivate cwd: string;\n\tprivate executionStarted = false;\n\tprivate executionStartedAt?: number;\n\tprivate executionEndedAt?: number;\n\tprivate elapsedTimer?: ReturnType<typeof setInterval>;\n\tprivate argsComplete = false;\n\tprivate symbolPreset: ToolSymbolPreset;\n\t// Composed-line cache. Recomposing the panel (ANSI-aware truncation, width\n\t// measurement, background paint per content line) on every frame made\n\t// per-frame cost grow with the number of tools on screen; see\n\t// test/tool-execution-render-cache.test.ts.\n\tprivate displayVersion = 0;\n\tprivate cachedRender?: { key: string; width: number; lines: string[] };\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<\n\t\tnumber,\n\t\t{ sourceData: string; sourceMimeType: string; data: string; mimeType: string }\n\t> = new Map();\n\tprivate hideComponent = false;\n\n\tconstructor(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: any,\n\t\toptions: ToolExecutionOptions = {},\n\t\ttoolDefinition: ToolRenderers | ToolDefinition<any, 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.showImages = options.showImages ?? true;\n\t\tthis.imageWidthCells = options.imageWidthCells ?? 60;\n\t\tthis.symbolPreset = options.symbolPreset ?? \"unicode\";\n\t\tthis.ui = ui;\n\t\tthis.cwd = cwd;\n\n\t\tthis.addChild(new Spacer(1));\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\tthis.contentBox = new Box(0, 0);\n\t\tthis.contentText = new Text(\"\", 0, 0);\n\t\tthis.contentTextRegion = this.createResultRegion(this.contentText);\n\t\tthis.selfRenderContainer = new Container();\n\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tthis.addChild(this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox);\n\t\t} else {\n\t\t\tthis.addChild(this.contentTextRegion);\n\t\t}\n\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate getCallRenderer(): ToolDefinition<any, any>[\"renderCall\"] | undefined {\n\t\treturn this.toolDefinition?.renderCall;\n\t}\n\n\tprivate getResultRenderer(): ToolDefinition<any, any>[\"renderResult\"] | undefined {\n\t\treturn this.toolDefinition?.renderResult;\n\t}\n\n\tprivate hasRendererDefinition(): boolean {\n\t\treturn this.toolDefinition !== undefined;\n\t}\n\n\tprivate getRenderShell(): \"default\" | \"self\" {\n\t\treturn this.toolDefinition?.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\teditDiffsExpanded: this.editDiffsExpanded,\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\n\t\tconst lines = output.split(\"\\n\");\n\t\tconst displayLines = this.expanded\n\t\t\t? lines\n\t\t\t: lines.slice(0, previewLineCount(lines.length, FALLBACK_PREVIEW_LINES));\n\t\tconst remaining = lines.length - displayLines.length;\n\t\tlet text = displayLines.map((line) => theme.fg(\"toolOutput\", line)).join(\"\\n\");\n\t\tif (remaining > 0) text += `\\n${formatHiddenLines(remaining, \"more\")}`;\n\t\treturn new Text(text, 0, 0);\n\t}\n\n\tprivate createResultRegion(component: Component): MouseRegion {\n\t\treturn new MouseRegion(component, (event) => {\n\t\t\tif (!this.result || event.type !== \"click\" || event.button !== \"left\") return undefined;\n\t\t\tthis.setExpanded(!this.expanded);\n\t\t\treturn { handled: true };\n\t\t});\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.executionStartedAt ??= Date.now();\n\t\tthis.startElapsedTimer();\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\tif (!isPartial) {\n\t\t\tthis.executionEndedAt ??= Date.now();\n\t\t\tthis.stopElapsedTimer();\n\t\t}\n\t\tthis.updateDisplay();\n\t\tthis.maybeConvertImagesForKitty();\n\t}\n\n\tdispose(): void {\n\t\tthis.stopElapsedTimer();\n\t\tthis.cachedRender = undefined;\n\t}\n\n\tprivate startElapsedTimer(): void {\n\t\tif (this.elapsedTimer) return;\n\t\tthis.elapsedTimer = setInterval(() => this.ui.requestRender(), 1000);\n\t}\n\n\tprivate stopElapsedTimer(): void {\n\t\tif (!this.elapsedTimer) return;\n\t\tclearInterval(this.elapsedTimer);\n\t\tthis.elapsedTimer = undefined;\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\tconst sourceData = img.data;\n\t\t\tconst sourceMimeType = img.mimeType;\n\t\t\tif (sourceMimeType === \"image/png\") continue;\n\t\t\tconst cached = this.convertedImages.get(i);\n\t\t\tif (cached?.sourceData === sourceData && cached.sourceMimeType === sourceMimeType) continue;\n\n\t\t\tconst index = i;\n\t\t\tconvertToPng(sourceData, sourceMimeType).then((converted) => {\n\t\t\t\tconst currentImage = this.result?.content.filter((content) => content.type === \"image\")[index];\n\t\t\t\tif (!converted || currentImage?.data !== sourceData || currentImage.mimeType !== sourceMimeType) return;\n\t\t\t\tthis.convertedImages.set(index, {\n\t\t\t\t\tsourceData,\n\t\t\t\t\tsourceMimeType,\n\t\t\t\t\t...converted,\n\t\t\t\t});\n\t\t\t\tthis.updateDisplay();\n\t\t\t\tthis.ui.requestRender();\n\t\t\t});\n\t\t}\n\t}\n\n\tsetEditDiffsExpanded(expanded: boolean): void {\n\t\tif (this.editDiffsExpanded === expanded) return;\n\t\tthis.editDiffsExpanded = expanded;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tthis.updateDisplay();\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\tsuper.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate getLifecycle(): ToolLifecycle {\n\t\tif (this.result && !this.isPartial) return this.result.isError ? \"error\" : \"done\";\n\t\treturn this.executionStarted ? \"running\" : \"queued\";\n\t}\n\n\tprivate getDurationMs(): number | undefined {\n\t\tif (this.executionStartedAt === undefined) return undefined;\n\t\treturn (this.executionEndedAt ?? Date.now()) - this.executionStartedAt;\n\t}\n\n\tprivate renderWithStatus(component: Component, width: number): string[] {\n\t\tconst options = {\n\t\t\tlifecycle: this.getLifecycle(),\n\t\t\tsymbolPreset: this.symbolPreset,\n\t\t\tdurationMs: this.getDurationMs(),\n\t\t};\n\t\tif (this.hasRendererDefinition() && this.getRenderShell() === \"self\") {\n\t\t\treturn new ToolStatusLineComponent(component, options).render(width);\n\t\t}\n\t\treturn new ToolPanelComponent(component, options).render(width);\n\t}\n\n\tprivate renderCollapsedError(contentLines: string[], width: number): string[] {\n\t\tconst errorText = this.getTextOutput();\n\t\tif (!errorText || contentLines.length === 0) return contentLines;\n\n\t\tconst errorLines = new Text(theme.fg(\"toolOutput\", errorText), 0, 0).render(width);\n\t\tconst previewLines = errorLines.slice(0, previewLineCount(errorLines.length, COLLAPSED_ERROR_VISUAL_LINE_LIMIT));\n\t\tconst omittedLines = errorLines.length - previewLines.length;\n\t\tif (omittedLines === 0) return [...contentLines.slice(0, 1), ...previewLines];\n\n\t\treturn [...contentLines.slice(0, 1), ...previewLines, formatHiddenLines(omittedLines, \"more\")];\n\t}\n\n\toverride render(width: number): string[] {\n\t\tif (this.hideComponent || width <= 0) return [];\n\t\tconst key = this.renderCacheKey();\n\t\tconst cached = this.cachedRender;\n\t\tif (cached && cached.key === key && cached.width === width) return cached.lines;\n\t\tconst lines = this.compose(width);\n\t\tthis.cachedRender = { key, width, lines };\n\t\treturn lines;\n\t}\n\n\t/**\n\t * Cache key for the composed lines. Every state change funnels through\n\t * updateDisplay(), which bumps displayVersion; the elapsed readout is the\n\t * one input that advances without a state change, so it is bucketed at\n\t * 250 ms while running (matching the 1 s elapsed timer's cadence closely\n\t * enough that the readout never looks stale, while bounding recomposition\n\t * to at most four per second for the one running tool).\n\t */\n\tprivate renderCacheKey(): string {\n\t\tconst lifecycle = this.getLifecycle();\n\t\tconst durationMs = this.getDurationMs();\n\t\tconst durationKey = lifecycle === \"running\" ? Math.floor((durationMs ?? 0) / 250) : (durationMs ?? -1);\n\t\treturn `${this.displayVersion}:${lifecycle}:${durationKey}`;\n\t}\n\n\tprivate compose(width: number): string[] {\n\t\tconst shell = this.hasRendererDefinition()\n\t\t\t? this.getRenderShell() === \"self\"\n\t\t\t\t? this.selfRenderContainer\n\t\t\t\t: this.contentBox\n\t\t\t: this.contentText;\n\t\tconst selfRendered = this.hasRendererDefinition() && this.getRenderShell() === \"self\";\n\t\tconst panelContent: Component = selfRendered\n\t\t\t? shell\n\t\t\t: {\n\t\t\t\t\trender: (innerWidth: number) => {\n\t\t\t\t\t\tconst contentLines = shell.render(innerWidth);\n\t\t\t\t\t\tconst visibleLines =\n\t\t\t\t\t\t\tthis.result?.isError && !this.isPartial && !this.expanded\n\t\t\t\t\t\t\t\t? this.renderCollapsedError(contentLines, innerWidth)\n\t\t\t\t\t\t\t\t: contentLines;\n\t\t\t\t\t\treturn visibleLines;\n\t\t\t\t\t},\n\t\t\t\t\tinvalidate: () => shell.invalidate?.(),\n\t\t\t\t};\n\t\tconst visibleContentLines = this.renderWithStatus(panelContent, width);\n\t\tif (visibleContentLines.length === 0 && this.imageComponents.length === 0) return [];\n\n\t\tconst lines: string[] = [];\n\t\tif (visibleContentLines.length > 0) {\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(...visibleContentLines);\n\t\t}\n\t\tfor (let i = 0; i < this.imageComponents.length; i++) {\n\t\t\tconst spacer = this.imageSpacers[i];\n\t\t\tif (spacer) lines.push(...spacer.render(width));\n\t\t\tconst imageComponent = this.imageComponents[i];\n\t\t\tif (imageComponent) lines.push(...imageComponent.render(width));\n\t\t}\n\t\treturn lines;\n\t}\n\n\t/**\n\t * A left click on the panel toggles the result, as upstream's per-region\n\t * handlers do. Apex composes the panel itself (lifecycle header, spine,\n\t * padding, the separator row it inserts), so rendered rows do not line up\n\t * with the children's rows and the inherited child-by-child dispatch would\n\t * resolve the wrong region. Row 0 is the leading spacer and is inert.\n\t */\n\toverride handleMouse(event: TuiMouseEvent): ReturnType<Container[\"handleMouse\"]> {\n\t\tif (this.hideComponent || event.y <= 0 || event.y >= event.height) return undefined;\n\t\tif (!this.result || event.type !== \"click\" || event.button !== \"left\") return undefined;\n\t\tthis.setExpanded(!this.expanded);\n\t\treturn {\n\t\t\thandled: true,\n\t\t\ttarget: {\n\t\t\t\tcomponent: this,\n\t\t\t\toriginX: event.screenX - event.x,\n\t\t\t\toriginY: event.screenY - event.y,\n\t\t\t\twidth: event.width,\n\t\t\t\theight: event.height,\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate updateDisplay(): void {\n\t\tthis.displayVersion += 1;\n\t\tlet hasContent = false;\n\t\tthis.hideComponent = false;\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tconst renderContainer = this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox;\n\t\t\trenderContainer.clear();\n\n\t\t\tconst callRenderer = this.getCallRenderer();\n\t\t\tif (!callRenderer) {\n\t\t\t\trenderContainer.addChild(this.createResultRegion(this.createCallFallback()));\n\t\t\t\thasContent = true;\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tconst component = callRenderer(this.args, theme, this.getRenderContext(this.callRendererComponent));\n\t\t\t\t\tthis.callRendererComponent = component;\n\t\t\t\t\trenderContainer.addChild(this.createResultRegion(component));\n\t\t\t\t\thasContent = true;\n\t\t\t\t} catch {\n\t\t\t\t\tthis.callRendererComponent = undefined;\n\t\t\t\t\trenderContainer.addChild(this.createResultRegion(this.createCallFallback()));\n\t\t\t\t\thasContent = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.result) {\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.createResultRegion(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.createResultRegion(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(this.createResultRegion(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\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) {\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 cached = this.convertedImages.get(i);\n\t\t\t\t\tconst converted =\n\t\t\t\t\t\tcached?.sourceData === img.data && cached.sourceMimeType === img.mimeType ? cached : undefined;\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\tlet text = 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.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,GAGJ,MAAM,wBAAwB,CAAC;AAwBhC,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC7F,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iC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AC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtF,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC3B,CAAC;IAAA,CACD;IAEO,aAAa,GAAW;QAC/B,OAAO,qBAAqB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAAA,CAC3D;IAEO,mBAAmB,GAAW;QACrC,IAAI,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC5D,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,aAAa,EAAE,CAAC;QACpC,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\tMouseRegion,\n\tSpacer,\n\tText,\n\ttype TUI,\n\ttype TuiMouseEvent,\n} from \"@earendil-works/pi-tui\";\nimport type { AgentToolResult } from \"apex-code-agent-core\";\nimport type { ToolDefinition, ToolRenderContext, ToolRenderResultOptions } from \"../../../core/extensions/types.ts\";\nimport type { ChatDetail } from \"../../../core/settings-manager.ts\";\nimport type { Theme } from \"../theme/theme.ts\";\n\n/**\n * What this component needs from a tool: how to draw it. It neither executes tools nor reads their\n * parameter schemas, so a definition and a bare renderer pair are equally acceptable.\n *\n * The renderer parameters are `any` on purpose: a `ToolDefinition` types them from its schema, and\n * narrowing them here would make those definitions unassignable.\n */\nexport interface ToolRenderers {\n\trenderShell?: \"default\" | \"self\";\n\trenderCall?: (args: any, theme: Theme, context: ToolRenderContext<any, any>) => Component;\n\trenderResult?: (\n\t\tresult: AgentToolResult<any>,\n\t\toptions: ToolRenderResultOptions,\n\t\ttheme: Theme,\n\t\tcontext: ToolRenderContext<any, any>,\n\t) => Component;\n}\n\nimport { getTextOutput as getRenderedTextOutput } from \"../../../core/tools/render-utils.ts\";\nimport { stripAnsi } from \"../../../utils/ansi.ts\";\nimport { convertToPng } from \"../../../utils/image-convert.ts\";\nimport { theme } from \"../theme/theme.ts\";\nimport { summarizeOperationError } from \"./error-summary.ts\";\nimport { formatHiddenLines, keyText, previewLineCount } from \"./keybinding-hints.ts\";\nimport {\n\tcountOutputLines,\n\trenderCompactOperationRow,\n\ttype ToolLifecycle,\n\tToolPanelComponent,\n\tToolStatusLineComponent,\n\ttype ToolSymbolPreset,\n} from \"./tool-panel.ts\";\n\nconst COLLAPSED_ERROR_VISUAL_LINE_LIMIT = 3;\n\nconst FALLBACK_PREVIEW_LINES = 10;\n\nexport interface ToolExecutionOptions {\n\tshowImages?: boolean;\n\timageWidthCells?: number;\n\tsymbolPreset?: ToolSymbolPreset;\n}\n\n/** The phrase every expand affordance ends with, here and in each tool's own renderer. */\n\nexport class ToolExecutionComponent extends Container {\n\tprivate contentBox: Box;\n\tprivate contentText: Text;\n\tprivate contentTextRegion: MouseRegion;\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\tprivate collapsedOverride = false;\n\tprivate chatDetail: ChatDetail = \"details\";\n\tprivate editDiffsExpanded = true;\n\tprivate showImages: boolean;\n\tprivate imageWidthCells: number;\n\tprivate isPartial = true;\n\tprivate toolDefinition?: ToolRenderers;\n\tprivate ui: TUI;\n\tprivate cwd: string;\n\tprivate executionStarted = false;\n\tprivate executionStartedAt?: number;\n\tprivate executionEndedAt?: number;\n\tprivate elapsedTimer?: ReturnType<typeof setInterval>;\n\tprivate argsComplete = false;\n\tprivate symbolPreset: ToolSymbolPreset;\n\t// Composed-line cache. Recomposing the panel (ANSI-aware truncation, width\n\t// measurement, background paint per content line) on every frame made\n\t// per-frame cost grow with the number of tools on screen; see\n\t// test/tool-execution-render-cache.test.ts.\n\tprivate displayVersion = 0;\n\tprivate compactContent?: { version: number; label: string; summary?: string; hidden: boolean };\n\tprivate cachedRender?: { key: string; width: number; lines: string[] };\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<\n\t\tnumber,\n\t\t{ sourceData: string; sourceMimeType: string; data: string; mimeType: string }\n\t> = new Map();\n\tprivate hideComponent = false;\n\n\tconstructor(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: any,\n\t\toptions: ToolExecutionOptions = {},\n\t\ttoolDefinition: ToolRenderers | ToolDefinition<any, 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.showImages = options.showImages ?? true;\n\t\tthis.imageWidthCells = options.imageWidthCells ?? 60;\n\t\tthis.symbolPreset = options.symbolPreset ?? \"unicode\";\n\t\tthis.ui = ui;\n\t\tthis.cwd = cwd;\n\n\t\tthis.addChild(new Spacer(1));\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\tthis.contentBox = new Box(0, 0);\n\t\tthis.contentText = new Text(\"\", 0, 0);\n\t\tthis.contentTextRegion = this.createResultRegion(this.contentText);\n\t\tthis.selfRenderContainer = new Container();\n\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tthis.addChild(this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox);\n\t\t} else {\n\t\t\tthis.addChild(this.contentTextRegion);\n\t\t}\n\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate getCallRenderer(): ToolDefinition<any, any>[\"renderCall\"] | undefined {\n\t\treturn this.toolDefinition?.renderCall;\n\t}\n\n\tprivate getResultRenderer(): ToolDefinition<any, any>[\"renderResult\"] | undefined {\n\t\treturn this.toolDefinition?.renderResult;\n\t}\n\n\tprivate hasRendererDefinition(): boolean {\n\t\treturn this.toolDefinition !== undefined;\n\t}\n\n\tprivate getRenderShell(): \"default\" | \"self\" {\n\t\treturn this.toolDefinition?.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\teditDiffsExpanded: this.expanded || this.editDiffsExpanded,\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\n\t\tconst lines = output.split(\"\\n\");\n\t\tconst displayLines = this.expanded\n\t\t\t? lines\n\t\t\t: lines.slice(0, previewLineCount(lines.length, FALLBACK_PREVIEW_LINES));\n\t\tconst remaining = lines.length - displayLines.length;\n\t\tlet text = displayLines.map((line) => theme.fg(\"toolOutput\", line)).join(\"\\n\");\n\t\tif (remaining > 0) text += `\\n${formatHiddenLines(remaining, \"more\")}`;\n\t\treturn new Text(text, 0, 0);\n\t}\n\n\tprivate createResultRegion(component: Component): MouseRegion {\n\t\treturn new MouseRegion(component, (event) => {\n\t\t\tif (!this.result || event.type !== \"click\" || event.button !== \"left\") return undefined;\n\t\t\tthis.toggleExpanded();\n\t\t\treturn { handled: true };\n\t\t});\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.executionStartedAt ??= Date.now();\n\t\tthis.startElapsedTimer();\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\tif (!isPartial) {\n\t\t\tthis.executionEndedAt ??= Date.now();\n\t\t\tthis.stopElapsedTimer();\n\t\t}\n\t\tthis.updateDisplay();\n\t\tthis.maybeConvertImagesForKitty();\n\t}\n\n\tdispose(): void {\n\t\tthis.stopElapsedTimer();\n\t\tthis.cachedRender = undefined;\n\t}\n\n\tprivate startElapsedTimer(): void {\n\t\tif (this.elapsedTimer) return;\n\t\tthis.elapsedTimer = setInterval(() => this.ui.requestRender(), 1000);\n\t}\n\n\tprivate stopElapsedTimer(): void {\n\t\tif (!this.elapsedTimer) return;\n\t\tclearInterval(this.elapsedTimer);\n\t\tthis.elapsedTimer = undefined;\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\tconst sourceData = img.data;\n\t\t\tconst sourceMimeType = img.mimeType;\n\t\t\tif (sourceMimeType === \"image/png\") continue;\n\t\t\tconst cached = this.convertedImages.get(i);\n\t\t\tif (cached?.sourceData === sourceData && cached.sourceMimeType === sourceMimeType) continue;\n\n\t\t\tconst index = i;\n\t\t\tconvertToPng(sourceData, sourceMimeType).then((converted) => {\n\t\t\t\tconst currentImage = this.result?.content.filter((content) => content.type === \"image\")[index];\n\t\t\t\tif (!converted || currentImage?.data !== sourceData || currentImage.mimeType !== sourceMimeType) return;\n\t\t\t\tthis.convertedImages.set(index, {\n\t\t\t\t\tsourceData,\n\t\t\t\t\tsourceMimeType,\n\t\t\t\t\t...converted,\n\t\t\t\t});\n\t\t\t\tthis.updateDisplay();\n\t\t\t\tthis.ui.requestRender();\n\t\t\t});\n\t\t}\n\t}\n\n\tsetEditDiffsExpanded(expanded: boolean): void {\n\t\tif (this.editDiffsExpanded === expanded) return;\n\t\tthis.editDiffsExpanded = expanded;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetChatDetail(detail: ChatDetail): void {\n\t\tthis.chatDetail = detail;\n\t\tthis.collapsedOverride = false;\n\t\tthis.expanded = detail === \"all\";\n\t\tthis.editDiffsExpanded = detail !== \"overview\";\n\t\tthis.updateDisplay();\n\t}\n\n\ttoggleExpanded(): void {\n\t\tthis.expanded = !this.expanded;\n\t\tthis.collapsedOverride = !this.expanded;\n\t\tthis.editDiffsExpanded = this.expanded;\n\t\tthis.updateDisplay();\n\t\tthis.ui.requestRender();\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.collapsedOverride = false;\n\t\tthis.expanded = expanded;\n\t\tthis.updateDisplay();\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\tsuper.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate getLifecycle(): ToolLifecycle {\n\t\tif (this.result && !this.isPartial) return this.result.isError ? \"error\" : \"done\";\n\t\treturn this.executionStarted ? \"running\" : \"queued\";\n\t}\n\n\tprivate getDurationMs(): number | undefined {\n\t\tif (this.executionStartedAt === undefined) return undefined;\n\t\treturn (this.executionEndedAt ?? Date.now()) - this.executionStartedAt;\n\t}\n\n\tprivate renderWithStatus(component: Component, width: number): string[] {\n\t\tconst options = {\n\t\t\tlifecycle: this.getLifecycle(),\n\t\t\tsymbolPreset: this.symbolPreset,\n\t\t\tdurationMs: this.getDurationMs(),\n\t\t};\n\t\tif (this.hasRendererDefinition() && this.getRenderShell() === \"self\") {\n\t\t\treturn new ToolStatusLineComponent(component, options).render(width);\n\t\t}\n\t\treturn new ToolPanelComponent(component, options).render(width);\n\t}\n\n\tprivate renderCollapsedError(contentLines: string[], width: number): string[] {\n\t\tconst errorText = this.getTextOutput();\n\t\tif (!errorText || contentLines.length === 0) return contentLines;\n\n\t\tconst errorLines = new Text(theme.fg(\"toolOutput\", errorText), 0, 0).render(width);\n\t\tconst previewLines = errorLines.slice(0, previewLineCount(errorLines.length, COLLAPSED_ERROR_VISUAL_LINE_LIMIT));\n\t\tconst omittedLines = errorLines.length - previewLines.length;\n\t\tif (omittedLines === 0) return [...contentLines.slice(0, 1), ...previewLines];\n\n\t\treturn [...contentLines.slice(0, 1), ...previewLines, formatHiddenLines(omittedLines, \"more\")];\n\t}\n\n\toverride render(width: number): string[] {\n\t\tif (this.hideComponent || width <= 0) return [];\n\t\tconst key = this.renderCacheKey();\n\t\tconst cached = this.cachedRender;\n\t\tif (cached && cached.key === key && cached.width === width) return cached.lines;\n\t\tconst lines = this.compose(width);\n\t\tthis.cachedRender = { key, width, lines };\n\t\treturn lines;\n\t}\n\n\t/**\n\t * Cache key for the composed lines. Every state change funnels through\n\t * updateDisplay(), which bumps displayVersion; the elapsed readout is the\n\t * one input that advances without a state change, so it is bucketed at\n\t * 250 ms while running (matching the 1 s elapsed timer's cadence closely\n\t * enough that the readout never looks stale, while bounding recomposition\n\t * to at most four per second for the one running tool).\n\t */\n\tprivate renderCacheKey(): string {\n\t\tconst lifecycle = this.getLifecycle();\n\t\tconst durationMs = this.getDurationMs();\n\t\tconst durationKey = lifecycle === \"running\" ? Math.floor((durationMs ?? 0) / 250) : (durationMs ?? -1);\n\t\treturn `${this.displayVersion}:${lifecycle}:${durationKey}`;\n\t}\n\n\tprivate isCompact(): boolean {\n\t\treturn this.collapsedOverride || (this.chatDetail === \"overview\" && !this.expanded);\n\t}\n\n\tprivate composeCompact(width: number): string[] {\n\t\tlet content = this.compactContent;\n\t\tif (!content || content.version !== this.displayVersion) {\n\t\t\t// Inspect each renderer once per display update, not on every elapsed-time tick.\n\t\t\tconst callLines = this.callRendererComponent?.render(400);\n\t\t\tconst visibleCall = callLines?.find((line) => stripAnsi(line).trim().length > 0);\n\t\t\tconst resultLines = this.resultRendererComponent?.render(400);\n\t\t\tconst resultHidden = !!this.resultRendererComponent && resultLines?.length === 0;\n\t\t\tconst args = this.args as Record<string, unknown> | undefined;\n\t\t\tconst target = args?.path ?? args?.file_path ?? args?.command ?? args?.pattern;\n\t\t\tconst fallbackLabel = `${this.toolName}${typeof target === \"string\" ? ` ${target}` : \"\"}`;\n\t\t\tconst output = resultHidden\n\t\t\t\t? \"\"\n\t\t\t\t: (this.result?.content\n\t\t\t\t\t\t.filter((block) => block.type === \"text\")\n\t\t\t\t\t\t.map((block) => block.text ?? \"\")\n\t\t\t\t\t\t.join(\"\\n\") ?? \"\");\n\t\t\tconst outputLines = countOutputLines(output);\n\t\t\tconst images = resultHidden ? 0 : (this.result?.content.filter((block) => block.type === \"image\").length ?? 0);\n\t\t\tconst summary =\n\t\t\t\tthis.result?.isError && output\n\t\t\t\t\t? summarizeOperationError(output)\n\t\t\t\t\t: [\n\t\t\t\t\t\t\toutputLines ? `${outputLines} output line${outputLines === 1 ? \"\" : \"s\"}` : \"\",\n\t\t\t\t\t\t\timages ? `${images} image${images === 1 ? \"\" : \"s\"}` : \"\",\n\t\t\t\t\t\t]\n\t\t\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t\t\t.join(\", \");\n\t\t\tconst label = stripAnsi(visibleCall ?? fallbackLabel).replace(\n\t\t\t\t` (${keyText(\"app.tools.expand\")} to expand)`,\n\t\t\t\t\"\",\n\t\t\t);\n\t\t\tcontent = {\n\t\t\t\tversion: this.displayVersion,\n\t\t\t\tlabel,\n\t\t\t\tsummary,\n\t\t\t\thidden: callLines?.length === 0 && (!this.result || resultHidden) && !images,\n\t\t\t};\n\t\t\tthis.compactContent = content;\n\t\t}\n\t\tif (content.hidden) return [];\n\t\treturn renderCompactOperationRow(\n\t\t\t{\n\t\t\t\tlabel: content.label,\n\t\t\t\tsummary: content.summary,\n\t\t\t\tlifecycle: this.getLifecycle(),\n\t\t\t\tsymbolPreset: this.symbolPreset,\n\t\t\t\tdurationMs: this.getDurationMs(),\n\t\t\t},\n\t\t\twidth,\n\t\t);\n\t}\n\n\tprivate compose(width: number): string[] {\n\t\tif (this.isCompact()) return this.composeCompact(width);\n\t\tconst shell = this.hasRendererDefinition()\n\t\t\t? this.getRenderShell() === \"self\"\n\t\t\t\t? this.selfRenderContainer\n\t\t\t\t: this.contentBox\n\t\t\t: this.contentText;\n\t\tconst selfRendered = this.hasRendererDefinition() && this.getRenderShell() === \"self\";\n\t\tconst panelContent: Component = selfRendered\n\t\t\t? shell\n\t\t\t: {\n\t\t\t\t\trender: (innerWidth: number) => {\n\t\t\t\t\t\tconst contentLines = shell.render(innerWidth);\n\t\t\t\t\t\tconst visibleLines =\n\t\t\t\t\t\t\tthis.result?.isError && !this.isPartial && !this.expanded\n\t\t\t\t\t\t\t\t? this.renderCollapsedError(contentLines, innerWidth)\n\t\t\t\t\t\t\t\t: contentLines;\n\t\t\t\t\t\treturn visibleLines;\n\t\t\t\t\t},\n\t\t\t\t\tinvalidate: () => shell.invalidate?.(),\n\t\t\t\t};\n\t\tconst visibleContentLines = this.renderWithStatus(panelContent, width);\n\t\tif (visibleContentLines.length === 0 && this.imageComponents.length === 0) return [];\n\n\t\tconst lines: string[] = [];\n\t\tif (visibleContentLines.length > 0) {\n\t\t\tlines.push(\"\");\n\t\t\tlines.push(...visibleContentLines);\n\t\t}\n\t\tfor (let i = 0; i < this.imageComponents.length; i++) {\n\t\t\tconst spacer = this.imageSpacers[i];\n\t\t\tif (spacer) lines.push(...spacer.render(width));\n\t\t\tconst imageComponent = this.imageComponents[i];\n\t\t\tif (imageComponent) lines.push(...imageComponent.render(width));\n\t\t}\n\t\treturn lines;\n\t}\n\n\t/**\n\t * A left click on the panel toggles the result, as upstream's per-region\n\t * handlers do. Apex composes the panel itself (lifecycle header, spine,\n\t * padding, the separator row it inserts), so rendered rows do not line up\n\t * with the children's rows and the inherited child-by-child dispatch would\n\t * resolve the wrong region. Row 0 is clickable in a compact row and otherwise a spacer.\n\t */\n\toverride handleMouse(event: TuiMouseEvent): ReturnType<Container[\"handleMouse\"]> {\n\t\tif (this.hideComponent || event.y < 0 || event.y >= event.height) return undefined;\n\t\tif (event.y === 0 && !this.isCompact()) return undefined;\n\t\tif ((!this.result && !this.isCompact()) || event.type !== \"click\" || event.button !== \"left\") return undefined;\n\t\tthis.toggleExpanded();\n\t\treturn {\n\t\t\thandled: true,\n\t\t\ttarget: {\n\t\t\t\tcomponent: this,\n\t\t\t\toriginX: event.screenX - event.x,\n\t\t\t\toriginY: event.screenY - event.y,\n\t\t\t\twidth: event.width,\n\t\t\t\theight: event.height,\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate updateDisplay(): void {\n\t\tthis.displayVersion += 1;\n\t\tlet hasContent = false;\n\t\tthis.hideComponent = false;\n\t\tif (this.hasRendererDefinition()) {\n\t\t\tconst renderContainer = this.getRenderShell() === \"self\" ? this.selfRenderContainer : this.contentBox;\n\t\t\trenderContainer.clear();\n\n\t\t\tconst callRenderer = this.getCallRenderer();\n\t\t\tif (!callRenderer) {\n\t\t\t\trenderContainer.addChild(this.createResultRegion(this.createCallFallback()));\n\t\t\t\thasContent = true;\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tconst component = callRenderer(this.args, theme, this.getRenderContext(this.callRendererComponent));\n\t\t\t\t\tthis.callRendererComponent = component;\n\t\t\t\t\trenderContainer.addChild(this.createResultRegion(component));\n\t\t\t\t\thasContent = true;\n\t\t\t\t} catch {\n\t\t\t\t\tthis.callRendererComponent = undefined;\n\t\t\t\t\trenderContainer.addChild(this.createResultRegion(this.createCallFallback()));\n\t\t\t\t\thasContent = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.result) {\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.createResultRegion(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.createResultRegion(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(this.createResultRegion(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\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) {\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 cached = this.convertedImages.get(i);\n\t\t\t\t\tconst converted =\n\t\t\t\t\t\tcached?.sourceData === img.data && cached.sourceMimeType === img.mimeType ? cached : undefined;\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\tlet text = 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.getTextOutput();\n\t\tif (output) {\n\t\t\ttext += `\\n${output}`;\n\t\t}\n\t\treturn text;\n\t}\n}\n"]}
@@ -27,4 +27,11 @@ export declare class ToolStatusLineComponent implements Component {
27
27
  render(width: number): string[];
28
28
  invalidate(): void;
29
29
  }
30
+ export interface CompactOperationRowOptions extends ToolStatusLineOptions {
31
+ label: string;
32
+ summary?: string;
33
+ }
34
+ export declare function countOutputLines(output: string): number;
35
+ /** One physical row, with no panel decoration or spacing between operations. */
36
+ export declare function renderCompactOperationRow(options: CompactOperationRowOptions, width: number): string[];
30
37
  //# sourceMappingURL=tool-panel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool-panel.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-panel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAiC,MAAM,wBAAwB,CAAC;AAGvF,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AACpE,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,OAAO,CAAC;AAoCnD,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAI7D;AAED,MAAM,WAAW,qBAAqB;IACrC,SAAS,EAAE,aAAa,CAAC;IACzB,YAAY,EAAE,gBAAgB,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAQD,4DAA4D;AAC5D,qBAAa,kBAAmB,YAAW,SAAS;IACnD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAY;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwB;IAEhD,YAAY,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,qBAAqB,EAG3D;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAyC9B;IAED,UAAU,IAAI,IAAI,CAEjB;CACD;AAED;;;;GAIG;AACH,qBAAa,uBAAwB,YAAW,SAAS;IACxD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAY;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwB;IAEhD,YAAY,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,qBAAqB,EAG3D;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAmB9B;IAED,UAAU,IAAI,IAAI,CAEjB;CACD","sourcesContent":["import { type Component, truncateToWidth, visibleWidth } from \"@earendil-works/pi-tui\";\nimport { paintBackground, theme } from \"../theme/theme.ts\";\n\nexport type ToolLifecycle = \"queued\" | \"running\" | \"done\" | \"error\";\nexport type ToolSymbolPreset = \"unicode\" | \"ascii\";\n\nconst LIFECYCLE_SYMBOLS: Record<ToolSymbolPreset, Record<ToolLifecycle, string>> = {\n\tunicode: { queued: \"○\", running: \"◌\", done: \"✓\", error: \"✗\" },\n\tascii: { queued: \"[ ]\", running: \"[~]\", done: \"[x]\", error: \"[!]\" },\n};\n\n/**\n * Running takes the brand accent rather than `warning`. Work in progress is\n * not a caution; amber is reserved for states the user may need to act on.\n */\nfunction lifecycleColor(lifecycle: ToolLifecycle): \"dim\" | \"accent\" | \"success\" | \"error\" {\n\tswitch (lifecycle) {\n\t\tcase \"queued\":\n\t\t\treturn \"dim\";\n\t\tcase \"running\":\n\t\t\treturn \"accent\";\n\t\tcase \"done\":\n\t\t\treturn \"success\";\n\t\tcase \"error\":\n\t\t\treturn \"error\";\n\t}\n}\n\n/**\n * The status spine drawn down the left edge of a tool panel.\n *\n * It is a redundant channel over the lifecycle word in the header, so it is\n * free to lean on colour. The glyph still distinguishes work that has not\n * started from work that has, which is the distinction a glance most needs.\n */\nconst SPINE_GLYPHS: Record<ToolSymbolPreset, Record<ToolLifecycle, string>> = {\n\tunicode: { queued: \"┆\", running: \"▌\", done: \"▌\", error: \"▌\" },\n\tascii: { queued: \":\", running: \"|\", done: \"|\", error: \"|\" },\n};\n\nexport function formatToolDuration(durationMs: number): string {\n\tif (durationMs < 1000) return `${Math.max(0, Math.round(durationMs))}ms`;\n\tif (durationMs < 10_000) return `${(durationMs / 1000).toFixed(1)}s`;\n\treturn `${Math.round(durationMs / 1000)}s`;\n}\n\nexport interface ToolStatusLineOptions {\n\tlifecycle: ToolLifecycle;\n\tsymbolPreset: ToolSymbolPreset;\n\tdurationMs?: number;\n}\n\nfunction lifecycleBackground(lifecycle: ToolLifecycle): \"toolPendingBg\" | \"toolSuccessBg\" | \"toolErrorBg\" {\n\tif (lifecycle === \"done\") return \"toolSuccessBg\";\n\tif (lifecycle === \"error\") return \"toolErrorBg\";\n\treturn \"toolPendingBg\";\n}\n\n/** Prime-style flat shell for renderer-based tool calls. */\nexport class ToolPanelComponent implements Component {\n\tprivate readonly child: Component;\n\tprivate readonly options: ToolStatusLineOptions;\n\n\tconstructor(child: Component, options: ToolStatusLineOptions) {\n\t\tthis.child = child;\n\t\tthis.options = options;\n\t}\n\n\trender(width: number): string[] {\n\t\tif (width <= 0) return [];\n\t\tconst padding = Math.min(2, Math.floor((width - 1) / 2));\n\t\tconst innerWidth = Math.max(1, width - padding * 2);\n\t\tconst childLines = this.child.render(innerWidth);\n\t\tif (childLines.length === 0) return [];\n\n\t\tconst { lifecycle, symbolPreset, durationMs } = this.options;\n\t\tconst duration = durationMs === undefined ? \"\" : ` ${formatToolDuration(durationMs)}`;\n\t\tconst state = theme.fg(\n\t\t\tlifecycleColor(lifecycle),\n\t\t\t`${LIFECYCLE_SYMBOLS[symbolPreset][lifecycle]} ${lifecycle}${duration}`,\n\t\t);\n\t\tconst separator = theme.fg(\"dim\", symbolPreset === \"ascii\" ? \" - \" : \" · \");\n\t\tconst stateWidth = visibleWidth(separator) + visibleWidth(state);\n\t\tconst label = childLines[0].replace(/\\s+$/, \"\");\n\t\tconst header =\n\t\t\tstateWidth < innerWidth\n\t\t\t\t? `${truncateToWidth(label, innerWidth - stateWidth, \"\")}${separator}${state}`\n\t\t\t\t: truncateToWidth(state, innerWidth, \"\");\n\t\t// Renderers written before the panel open their body with their own blank row. The\n\t\t// panel owns that separation, so it drops theirs and inserts exactly one.\n\t\tlet bodyStart = 1;\n\t\twhile (bodyStart < childLines.length && visibleWidth(childLines[bodyStart].trim()) === 0) bodyStart++;\n\t\tconst panelLines = [header];\n\t\tif (bodyStart < childLines.length) panelLines.push(\"\", ...childLines.slice(bodyStart));\n\n\t\tconst background = lifecycleBackground(lifecycle);\n\t\t// The spine occupies the first column of the existing left padding, so it\n\t\t// marks state without costing the panel a column of content. Below two\n\t\t// columns of padding there is no room for it and it is dropped.\n\t\tconst showSpine = padding >= 1;\n\t\tconst spine = showSpine\n\t\t\t? paintBackground(theme.fg(lifecycleColor(lifecycle), SPINE_GLYPHS[symbolPreset][lifecycle]), background)\n\t\t\t: \"\";\n\t\tconst leftPadding = \" \".repeat(Math.max(0, padding - (showSpine ? 1 : 0)));\n\t\treturn panelLines.map((line) => {\n\t\t\tconst clipped = truncateToWidth(line, innerWidth, \"\");\n\t\t\tconst rightPadding = \" \".repeat(Math.max(0, innerWidth - visibleWidth(clipped)));\n\t\t\treturn spine + paintBackground(`${leftPadding}${clipped}${rightPadding}${\" \".repeat(padding)}`, background);\n\t\t});\n\t}\n\n\tinvalidate(): void {\n\t\tthis.child.invalidate?.();\n\t}\n}\n\n/**\n * Prefixes an existing public tool renderer with Apex-owned lifecycle text.\n * The wrapped renderer receives the remaining width, so its own wrapping and\n * cursor-free layout stay intact without a pi-tui hook.\n */\nexport class ToolStatusLineComponent implements Component {\n\tprivate readonly child: Component;\n\tprivate readonly options: ToolStatusLineOptions;\n\n\tconstructor(child: Component, options: ToolStatusLineOptions) {\n\t\tthis.child = child;\n\t\tthis.options = options;\n\t}\n\n\trender(width: number): string[] {\n\t\tif (width <= 0) return [];\n\t\tconst { lifecycle, symbolPreset, durationMs } = this.options;\n\t\tconst duration = durationMs === undefined ? \"\" : ` ${formatToolDuration(durationMs)}`;\n\t\tconst separator = symbolPreset === \"ascii\" ? \" | \" : \" · \";\n\t\tconst plainPrefix = `${LIFECYCLE_SYMBOLS[symbolPreset][lifecycle]} ${lifecycle}${duration}${separator}`;\n\t\tconst prefix = theme.fg(lifecycleColor(lifecycle), plainPrefix);\n\t\tconst prefixWidth = visibleWidth(prefix);\n\n\t\tif (prefixWidth >= width) {\n\t\t\treturn [truncateToWidth(prefix, width, \"\")];\n\t\t}\n\n\t\tconst childWidth = Math.max(1, width - prefixWidth);\n\t\tconst childLines = this.child.render(childWidth);\n\t\tif (childLines.length === 0) return [];\n\n\t\tconst continuation = \" \".repeat(prefixWidth);\n\t\treturn childLines.map((line, index) => (index === 0 ? prefix : continuation) + line);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.child.invalidate?.();\n\t}\n}\n"]}
1
+ {"version":3,"file":"tool-panel.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-panel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAiC,MAAM,wBAAwB,CAAC;AAIvF,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AACpE,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,OAAO,CAAC;AAoCnD,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAI7D;AAED,MAAM,WAAW,qBAAqB;IACrC,SAAS,EAAE,aAAa,CAAC;IACzB,YAAY,EAAE,gBAAgB,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAQD,4DAA4D;AAC5D,qBAAa,kBAAmB,YAAW,SAAS;IACnD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAY;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwB;IAEhD,YAAY,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,qBAAqB,EAG3D;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAyC9B;IAED,UAAU,IAAI,IAAI,CAEjB;CACD;AAED;;;;GAIG;AACH,qBAAa,uBAAwB,YAAW,SAAS;IACxD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAY;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwB;IAEhD,YAAY,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,qBAAqB,EAG3D;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAmB9B;IAED,UAAU,IAAI,IAAI,CAEjB;CACD;AAED,MAAM,WAAW,0BAA2B,SAAQ,qBAAqB;IACxE,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAIvD;AAED,gFAAgF;AAChF,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,0BAA0B,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CA2BtG","sourcesContent":["import { type Component, truncateToWidth, visibleWidth } from \"@earendil-works/pi-tui\";\nimport { stripAnsi } from \"../../../utils/ansi.ts\";\nimport { paintBackground, theme } from \"../theme/theme.ts\";\n\nexport type ToolLifecycle = \"queued\" | \"running\" | \"done\" | \"error\";\nexport type ToolSymbolPreset = \"unicode\" | \"ascii\";\n\nconst LIFECYCLE_SYMBOLS: Record<ToolSymbolPreset, Record<ToolLifecycle, string>> = {\n\tunicode: { queued: \"○\", running: \"◌\", done: \"✓\", error: \"✗\" },\n\tascii: { queued: \"[ ]\", running: \"[~]\", done: \"[x]\", error: \"[!]\" },\n};\n\n/**\n * Running takes the brand accent rather than `warning`. Work in progress is\n * not a caution; amber is reserved for states the user may need to act on.\n */\nfunction lifecycleColor(lifecycle: ToolLifecycle): \"dim\" | \"accent\" | \"success\" | \"error\" {\n\tswitch (lifecycle) {\n\t\tcase \"queued\":\n\t\t\treturn \"dim\";\n\t\tcase \"running\":\n\t\t\treturn \"accent\";\n\t\tcase \"done\":\n\t\t\treturn \"success\";\n\t\tcase \"error\":\n\t\t\treturn \"error\";\n\t}\n}\n\n/**\n * The status spine drawn down the left edge of a tool panel.\n *\n * It is a redundant channel over the lifecycle word in the header, so it is\n * free to lean on colour. The glyph still distinguishes work that has not\n * started from work that has, which is the distinction a glance most needs.\n */\nconst SPINE_GLYPHS: Record<ToolSymbolPreset, Record<ToolLifecycle, string>> = {\n\tunicode: { queued: \"┆\", running: \"▌\", done: \"▌\", error: \"▌\" },\n\tascii: { queued: \":\", running: \"|\", done: \"|\", error: \"|\" },\n};\n\nexport function formatToolDuration(durationMs: number): string {\n\tif (durationMs < 1000) return `${Math.max(0, Math.round(durationMs))}ms`;\n\tif (durationMs < 10_000) return `${(durationMs / 1000).toFixed(1)}s`;\n\treturn `${Math.round(durationMs / 1000)}s`;\n}\n\nexport interface ToolStatusLineOptions {\n\tlifecycle: ToolLifecycle;\n\tsymbolPreset: ToolSymbolPreset;\n\tdurationMs?: number;\n}\n\nfunction lifecycleBackground(lifecycle: ToolLifecycle): \"toolPendingBg\" | \"toolSuccessBg\" | \"toolErrorBg\" {\n\tif (lifecycle === \"done\") return \"toolSuccessBg\";\n\tif (lifecycle === \"error\") return \"toolErrorBg\";\n\treturn \"toolPendingBg\";\n}\n\n/** Prime-style flat shell for renderer-based tool calls. */\nexport class ToolPanelComponent implements Component {\n\tprivate readonly child: Component;\n\tprivate readonly options: ToolStatusLineOptions;\n\n\tconstructor(child: Component, options: ToolStatusLineOptions) {\n\t\tthis.child = child;\n\t\tthis.options = options;\n\t}\n\n\trender(width: number): string[] {\n\t\tif (width <= 0) return [];\n\t\tconst padding = Math.min(2, Math.floor((width - 1) / 2));\n\t\tconst innerWidth = Math.max(1, width - padding * 2);\n\t\tconst childLines = this.child.render(innerWidth);\n\t\tif (childLines.length === 0) return [];\n\n\t\tconst { lifecycle, symbolPreset, durationMs } = this.options;\n\t\tconst duration = durationMs === undefined ? \"\" : ` ${formatToolDuration(durationMs)}`;\n\t\tconst state = theme.fg(\n\t\t\tlifecycleColor(lifecycle),\n\t\t\t`${LIFECYCLE_SYMBOLS[symbolPreset][lifecycle]} ${lifecycle}${duration}`,\n\t\t);\n\t\tconst separator = theme.fg(\"dim\", symbolPreset === \"ascii\" ? \" - \" : \" · \");\n\t\tconst stateWidth = visibleWidth(separator) + visibleWidth(state);\n\t\tconst label = childLines[0].replace(/\\s+$/, \"\");\n\t\tconst header =\n\t\t\tstateWidth < innerWidth\n\t\t\t\t? `${truncateToWidth(label, innerWidth - stateWidth, \"\")}${separator}${state}`\n\t\t\t\t: truncateToWidth(state, innerWidth, \"\");\n\t\t// Renderers written before the panel open their body with their own blank row. The\n\t\t// panel owns that separation, so it drops theirs and inserts exactly one.\n\t\tlet bodyStart = 1;\n\t\twhile (bodyStart < childLines.length && visibleWidth(childLines[bodyStart].trim()) === 0) bodyStart++;\n\t\tconst panelLines = [header];\n\t\tif (bodyStart < childLines.length) panelLines.push(\"\", ...childLines.slice(bodyStart));\n\n\t\tconst background = lifecycleBackground(lifecycle);\n\t\t// The spine occupies the first column of the existing left padding, so it\n\t\t// marks state without costing the panel a column of content. Below two\n\t\t// columns of padding there is no room for it and it is dropped.\n\t\tconst showSpine = padding >= 1;\n\t\tconst spine = showSpine\n\t\t\t? paintBackground(theme.fg(lifecycleColor(lifecycle), SPINE_GLYPHS[symbolPreset][lifecycle]), background)\n\t\t\t: \"\";\n\t\tconst leftPadding = \" \".repeat(Math.max(0, padding - (showSpine ? 1 : 0)));\n\t\treturn panelLines.map((line) => {\n\t\t\tconst clipped = truncateToWidth(line, innerWidth, \"\");\n\t\t\tconst rightPadding = \" \".repeat(Math.max(0, innerWidth - visibleWidth(clipped)));\n\t\t\treturn spine + paintBackground(`${leftPadding}${clipped}${rightPadding}${\" \".repeat(padding)}`, background);\n\t\t});\n\t}\n\n\tinvalidate(): void {\n\t\tthis.child.invalidate?.();\n\t}\n}\n\n/**\n * Prefixes an existing public tool renderer with Apex-owned lifecycle text.\n * The wrapped renderer receives the remaining width, so its own wrapping and\n * cursor-free layout stay intact without a pi-tui hook.\n */\nexport class ToolStatusLineComponent implements Component {\n\tprivate readonly child: Component;\n\tprivate readonly options: ToolStatusLineOptions;\n\n\tconstructor(child: Component, options: ToolStatusLineOptions) {\n\t\tthis.child = child;\n\t\tthis.options = options;\n\t}\n\n\trender(width: number): string[] {\n\t\tif (width <= 0) return [];\n\t\tconst { lifecycle, symbolPreset, durationMs } = this.options;\n\t\tconst duration = durationMs === undefined ? \"\" : ` ${formatToolDuration(durationMs)}`;\n\t\tconst separator = symbolPreset === \"ascii\" ? \" | \" : \" · \";\n\t\tconst plainPrefix = `${LIFECYCLE_SYMBOLS[symbolPreset][lifecycle]} ${lifecycle}${duration}${separator}`;\n\t\tconst prefix = theme.fg(lifecycleColor(lifecycle), plainPrefix);\n\t\tconst prefixWidth = visibleWidth(prefix);\n\n\t\tif (prefixWidth >= width) {\n\t\t\treturn [truncateToWidth(prefix, width, \"\")];\n\t\t}\n\n\t\tconst childWidth = Math.max(1, width - prefixWidth);\n\t\tconst childLines = this.child.render(childWidth);\n\t\tif (childLines.length === 0) return [];\n\n\t\tconst continuation = \" \".repeat(prefixWidth);\n\t\treturn childLines.map((line, index) => (index === 0 ? prefix : continuation) + line);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.child.invalidate?.();\n\t}\n}\n\nexport interface CompactOperationRowOptions extends ToolStatusLineOptions {\n\tlabel: string;\n\tsummary?: string;\n}\n\nexport function countOutputLines(output: string): number {\n\tif (!output) return 0;\n\tconst lines = output.replace(/\\r\\n?/g, \"\\n\").split(\"\\n\");\n\treturn lines.length - (lines.at(-1) === \"\" ? 1 : 0);\n}\n\n/** One physical row, with no panel decoration or spacing between operations. */\nexport function renderCompactOperationRow(options: CompactOperationRowOptions, width: number): string[] {\n\tif (width <= 0) return [];\n\tconst singleLine = (text: string) =>\n\t\tstripAnsi(text)\n\t\t\t.replace(/\\p{Cc}/gu, \" \")\n\t\t\t.replace(/ +/g, \" \")\n\t\t\t.trim();\n\tconst { lifecycle, symbolPreset, durationMs } = options;\n\tconst status = theme.fg(lifecycleColor(lifecycle), LIFECYCLE_SYMBOLS[symbolPreset][lifecycle]);\n\tconst prefix = `${status} `;\n\tconst prefixWidth = visibleWidth(prefix);\n\tif (prefixWidth >= width) return [truncateToWidth(status, width, \"\")];\n\tconst separator = symbolPreset === \"ascii\" ? \" - \" : \" · \";\n\tconst duration = durationMs === undefined ? \"\" : formatToolDuration(durationMs);\n\tconst metadata = singleLine([lifecycle, options.summary, duration].filter(Boolean).join(separator));\n\tconst label = singleLine(options.label);\n\tconst available = width - prefixWidth - visibleWidth(separator);\n\tif (available < 2) return [truncateToWidth(`${prefix}${label}`, width, \"\")];\n\t// Preserve state and diagnostics even when a path or command fills the row.\n\tconst minimumLabel = Math.min(\n\t\tvisibleWidth(label),\n\t\tMath.max(1, Math.floor(available * (lifecycle === \"error\" ? 0.3 : 0.5))),\n\t);\n\tconst metadataWidth = Math.min(visibleWidth(metadata), available - minimumLabel);\n\tconst clippedMetadata = truncateToWidth(metadata, metadataWidth, \"\");\n\tconst clippedLabel = truncateToWidth(label, available - visibleWidth(clippedMetadata), \"\").trimEnd();\n\treturn [`${prefix}${clippedLabel}${theme.fg(\"muted\", separator + clippedMetadata)}`];\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
2
+ import { stripAnsi } from "../../../utils/ansi.js";
2
3
  import { paintBackground, theme } from "../theme/theme.js";
3
4
  const LIFECYCLE_SYMBOLS = {
4
5
  unicode: { queued: "○", running: "◌", done: "✓", error: "✗" },
@@ -132,4 +133,38 @@ export class ToolStatusLineComponent {
132
133
  this.child.invalidate?.();
133
134
  }
134
135
  }
136
+ export function countOutputLines(output) {
137
+ if (!output)
138
+ return 0;
139
+ const lines = output.replace(/\r\n?/g, "\n").split("\n");
140
+ return lines.length - (lines.at(-1) === "" ? 1 : 0);
141
+ }
142
+ /** One physical row, with no panel decoration or spacing between operations. */
143
+ export function renderCompactOperationRow(options, width) {
144
+ if (width <= 0)
145
+ return [];
146
+ const singleLine = (text) => stripAnsi(text)
147
+ .replace(/\p{Cc}/gu, " ")
148
+ .replace(/ +/g, " ")
149
+ .trim();
150
+ const { lifecycle, symbolPreset, durationMs } = options;
151
+ const status = theme.fg(lifecycleColor(lifecycle), LIFECYCLE_SYMBOLS[symbolPreset][lifecycle]);
152
+ const prefix = `${status} `;
153
+ const prefixWidth = visibleWidth(prefix);
154
+ if (prefixWidth >= width)
155
+ return [truncateToWidth(status, width, "")];
156
+ const separator = symbolPreset === "ascii" ? " - " : " · ";
157
+ const duration = durationMs === undefined ? "" : formatToolDuration(durationMs);
158
+ const metadata = singleLine([lifecycle, options.summary, duration].filter(Boolean).join(separator));
159
+ const label = singleLine(options.label);
160
+ const available = width - prefixWidth - visibleWidth(separator);
161
+ if (available < 2)
162
+ return [truncateToWidth(`${prefix}${label}`, width, "")];
163
+ // Preserve state and diagnostics even when a path or command fills the row.
164
+ const minimumLabel = Math.min(visibleWidth(label), Math.max(1, Math.floor(available * (lifecycle === "error" ? 0.3 : 0.5))));
165
+ const metadataWidth = Math.min(visibleWidth(metadata), available - minimumLabel);
166
+ const clippedMetadata = truncateToWidth(metadata, metadataWidth, "");
167
+ const clippedLabel = truncateToWidth(label, available - visibleWidth(clippedMetadata), "").trimEnd();
168
+ return [`${prefix}${clippedLabel}${theme.fg("muted", separator + clippedMetadata)}`];
169
+ }
135
170
  //# sourceMappingURL=tool-panel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool-panel.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-panel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,eAAe,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAK3D,MAAM,iBAAiB,GAA4D;IAClF,OAAO,EAAE,EAAE,MAAM,EAAE,KAAG,EAAE,OAAO,EAAE,KAAG,EAAE,IAAI,EAAE,KAAG,EAAE,KAAK,EAAE,KAAG,EAAE;IAC7D,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;CACnE,CAAC;AAEF;;;GAGG;AACH,SAAS,cAAc,CAAC,SAAwB,EAA0C;IACzF,QAAQ,SAAS,EAAE,CAAC;QACnB,KAAK,QAAQ;YACZ,OAAO,KAAK,CAAC;QACd,KAAK,SAAS;YACb,OAAO,QAAQ,CAAC;QACjB,KAAK,MAAM;YACV,OAAO,SAAS,CAAC;QAClB,KAAK,OAAO;YACX,OAAO,OAAO,CAAC;IACjB,CAAC;AAAA,CACD;AAED;;;;;;GAMG;AACH,MAAM,YAAY,GAA4D;IAC7E,OAAO,EAAE,EAAE,MAAM,EAAE,KAAG,EAAE,OAAO,EAAE,KAAG,EAAE,IAAI,EAAE,KAAG,EAAE,KAAK,EAAE,KAAG,EAAE;IAC7D,KAAK,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE;CAC3D,CAAC;AAEF,MAAM,UAAU,kBAAkB,CAAC,UAAkB,EAAU;IAC9D,IAAI,UAAU,GAAG,IAAI;QAAE,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAA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C,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,CAAC;IAAA,CACrF;IAED,UAAU,GAAS;QAClB,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,CAAC;IAAA,CAC1B;CACD","sourcesContent":["import { type Component, truncateToWidth, visibleWidth } from \"@earendil-works/pi-tui\";\nimport { paintBackground, theme } from \"../theme/theme.ts\";\n\nexport type ToolLifecycle = \"queued\" | \"running\" | \"done\" | \"error\";\nexport type ToolSymbolPreset = \"unicode\" | \"ascii\";\n\nconst LIFECYCLE_SYMBOLS: Record<ToolSymbolPreset, Record<ToolLifecycle, string>> = {\n\tunicode: { queued: \"○\", running: \"◌\", done: \"✓\", error: \"✗\" },\n\tascii: { queued: \"[ ]\", running: \"[~]\", done: \"[x]\", error: \"[!]\" },\n};\n\n/**\n * Running takes the brand accent rather than `warning`. Work in progress is\n * not a caution; amber is reserved for states the user may need to act on.\n */\nfunction lifecycleColor(lifecycle: ToolLifecycle): \"dim\" | \"accent\" | \"success\" | \"error\" {\n\tswitch (lifecycle) {\n\t\tcase \"queued\":\n\t\t\treturn \"dim\";\n\t\tcase \"running\":\n\t\t\treturn \"accent\";\n\t\tcase \"done\":\n\t\t\treturn \"success\";\n\t\tcase \"error\":\n\t\t\treturn \"error\";\n\t}\n}\n\n/**\n * The status spine drawn down the left edge of a tool panel.\n *\n * It is a redundant channel over the lifecycle word in the header, so it is\n * free to lean on colour. The glyph still distinguishes work that has not\n * started from work that has, which is the distinction a glance most needs.\n */\nconst SPINE_GLYPHS: Record<ToolSymbolPreset, Record<ToolLifecycle, string>> = {\n\tunicode: { queued: \"┆\", running: \"▌\", done: \"▌\", error: \"▌\" },\n\tascii: { queued: \":\", running: \"|\", done: \"|\", error: \"|\" },\n};\n\nexport function formatToolDuration(durationMs: number): string {\n\tif (durationMs < 1000) return `${Math.max(0, Math.round(durationMs))}ms`;\n\tif (durationMs < 10_000) return `${(durationMs / 1000).toFixed(1)}s`;\n\treturn `${Math.round(durationMs / 1000)}s`;\n}\n\nexport interface ToolStatusLineOptions {\n\tlifecycle: ToolLifecycle;\n\tsymbolPreset: ToolSymbolPreset;\n\tdurationMs?: number;\n}\n\nfunction lifecycleBackground(lifecycle: ToolLifecycle): \"toolPendingBg\" | \"toolSuccessBg\" | \"toolErrorBg\" {\n\tif (lifecycle === \"done\") return \"toolSuccessBg\";\n\tif (lifecycle === \"error\") return \"toolErrorBg\";\n\treturn \"toolPendingBg\";\n}\n\n/** Prime-style flat shell for renderer-based tool calls. */\nexport class ToolPanelComponent implements Component {\n\tprivate readonly child: Component;\n\tprivate readonly options: ToolStatusLineOptions;\n\n\tconstructor(child: Component, options: ToolStatusLineOptions) {\n\t\tthis.child = child;\n\t\tthis.options = options;\n\t}\n\n\trender(width: number): string[] {\n\t\tif (width <= 0) return [];\n\t\tconst padding = Math.min(2, Math.floor((width - 1) / 2));\n\t\tconst innerWidth = Math.max(1, width - padding * 2);\n\t\tconst childLines = this.child.render(innerWidth);\n\t\tif (childLines.length === 0) return [];\n\n\t\tconst { lifecycle, symbolPreset, durationMs } = this.options;\n\t\tconst duration = durationMs === undefined ? \"\" : ` ${formatToolDuration(durationMs)}`;\n\t\tconst state = theme.fg(\n\t\t\tlifecycleColor(lifecycle),\n\t\t\t`${LIFECYCLE_SYMBOLS[symbolPreset][lifecycle]} ${lifecycle}${duration}`,\n\t\t);\n\t\tconst separator = theme.fg(\"dim\", symbolPreset === \"ascii\" ? \" - \" : \" · \");\n\t\tconst stateWidth = visibleWidth(separator) + visibleWidth(state);\n\t\tconst label = childLines[0].replace(/\\s+$/, \"\");\n\t\tconst header =\n\t\t\tstateWidth < innerWidth\n\t\t\t\t? `${truncateToWidth(label, innerWidth - stateWidth, \"\")}${separator}${state}`\n\t\t\t\t: truncateToWidth(state, innerWidth, \"\");\n\t\t// Renderers written before the panel open their body with their own blank row. The\n\t\t// panel owns that separation, so it drops theirs and inserts exactly one.\n\t\tlet bodyStart = 1;\n\t\twhile (bodyStart < childLines.length && visibleWidth(childLines[bodyStart].trim()) === 0) bodyStart++;\n\t\tconst panelLines = [header];\n\t\tif (bodyStart < childLines.length) panelLines.push(\"\", ...childLines.slice(bodyStart));\n\n\t\tconst background = lifecycleBackground(lifecycle);\n\t\t// The spine occupies the first column of the existing left padding, so it\n\t\t// marks state without costing the panel a column of content. Below two\n\t\t// columns of padding there is no room for it and it is dropped.\n\t\tconst showSpine = padding >= 1;\n\t\tconst spine = showSpine\n\t\t\t? paintBackground(theme.fg(lifecycleColor(lifecycle), SPINE_GLYPHS[symbolPreset][lifecycle]), background)\n\t\t\t: \"\";\n\t\tconst leftPadding = \" \".repeat(Math.max(0, padding - (showSpine ? 1 : 0)));\n\t\treturn panelLines.map((line) => {\n\t\t\tconst clipped = truncateToWidth(line, innerWidth, \"\");\n\t\t\tconst rightPadding = \" \".repeat(Math.max(0, innerWidth - visibleWidth(clipped)));\n\t\t\treturn spine + paintBackground(`${leftPadding}${clipped}${rightPadding}${\" \".repeat(padding)}`, background);\n\t\t});\n\t}\n\n\tinvalidate(): void {\n\t\tthis.child.invalidate?.();\n\t}\n}\n\n/**\n * Prefixes an existing public tool renderer with Apex-owned lifecycle text.\n * The wrapped renderer receives the remaining width, so its own wrapping and\n * cursor-free layout stay intact without a pi-tui hook.\n */\nexport class ToolStatusLineComponent implements Component {\n\tprivate readonly child: Component;\n\tprivate readonly options: ToolStatusLineOptions;\n\n\tconstructor(child: Component, options: ToolStatusLineOptions) {\n\t\tthis.child = child;\n\t\tthis.options = options;\n\t}\n\n\trender(width: number): string[] {\n\t\tif (width <= 0) return [];\n\t\tconst { lifecycle, symbolPreset, durationMs } = this.options;\n\t\tconst duration = durationMs === undefined ? \"\" : ` ${formatToolDuration(durationMs)}`;\n\t\tconst separator = symbolPreset === \"ascii\" ? \" | \" : \" · \";\n\t\tconst plainPrefix = `${LIFECYCLE_SYMBOLS[symbolPreset][lifecycle]} ${lifecycle}${duration}${separator}`;\n\t\tconst prefix = theme.fg(lifecycleColor(lifecycle), plainPrefix);\n\t\tconst prefixWidth = visibleWidth(prefix);\n\n\t\tif (prefixWidth >= width) {\n\t\t\treturn [truncateToWidth(prefix, width, \"\")];\n\t\t}\n\n\t\tconst childWidth = Math.max(1, width - prefixWidth);\n\t\tconst childLines = this.child.render(childWidth);\n\t\tif (childLines.length === 0) return [];\n\n\t\tconst continuation = \" \".repeat(prefixWidth);\n\t\treturn childLines.map((line, index) => (index === 0 ? prefix : continuation) + line);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.child.invalidate?.();\n\t}\n}\n"]}
1
+ {"version":3,"file":"tool-panel.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-panel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,eAAe,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAK3D,MAAM,iBAAiB,GAA4D;IAClF,OAAO,EAAE,EAAE,MAAM,EAAE,KAAG,EAAE,OAAO,EAAE,KAAG,EAAE,IAAI,EAAE,KAAG,EAAE,KAAK,EAAE,KAAG,EAAE;IAC7D,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;CACnE,CAAC;AAEF;;;GAGG;AACH,SAAS,cAAc,CAAC,SAAwB,EAA0C;IACzF,QAAQ,SAAS,EAAE,CAAC;QACnB,KAAK,QAAQ;YACZ,OAAO,KAAK,CAAC;QACd,KAAK,SAAS;YACb,OAAO,QAAQ,CAAC;QACjB,KAAK,MAAM;YACV,OAAO,SAAS,CAAC;QAClB,KAAK,OAAO;YACX,OAAO,OAAO,CAAC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C5E,4EAA4E;IAC5E,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAC5B,YAAY,CAAC,KAAK,CAAC,EACnB,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CACxE,CAAC;IACF,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,SAAS,GAAG,YAAY,CAAC,CAAC;IACjF,MAAM,eAAe,GAAG,eAAe,CAAC,QAAQ,EAAE,aAAa,EAAE,EAAE,CAAC,CAAC;IACrE,MAAM,YAAY,GAAG,eAAe,CAAC,KAAK,EAAE,SAAS,GAAG,YAAY,CAAC,eAAe,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;IACrG,OAAO,CAAC,GAAG,MAAM,GAAG,YAAY,GAAG,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,GAAG,eAAe,CAAC,EAAE,CAAC,CAAC;AAAA,CACrF","sourcesContent":["import { type Component, truncateToWidth, visibleWidth } from \"@earendil-works/pi-tui\";\nimport { stripAnsi } from \"../../../utils/ansi.ts\";\nimport { paintBackground, theme } from \"../theme/theme.ts\";\n\nexport type ToolLifecycle = \"queued\" | \"running\" | \"done\" | \"error\";\nexport type ToolSymbolPreset = \"unicode\" | \"ascii\";\n\nconst LIFECYCLE_SYMBOLS: Record<ToolSymbolPreset, Record<ToolLifecycle, string>> = {\n\tunicode: { queued: \"○\", running: \"◌\", done: \"✓\", error: \"✗\" },\n\tascii: { queued: \"[ ]\", running: \"[~]\", done: \"[x]\", error: \"[!]\" },\n};\n\n/**\n * Running takes the brand accent rather than `warning`. Work in progress is\n * not a caution; amber is reserved for states the user may need to act on.\n */\nfunction lifecycleColor(lifecycle: ToolLifecycle): \"dim\" | \"accent\" | \"success\" | \"error\" {\n\tswitch (lifecycle) {\n\t\tcase \"queued\":\n\t\t\treturn \"dim\";\n\t\tcase \"running\":\n\t\t\treturn \"accent\";\n\t\tcase \"done\":\n\t\t\treturn \"success\";\n\t\tcase \"error\":\n\t\t\treturn \"error\";\n\t}\n}\n\n/**\n * The status spine drawn down the left edge of a tool panel.\n *\n * It is a redundant channel over the lifecycle word in the header, so it is\n * free to lean on colour. The glyph still distinguishes work that has not\n * started from work that has, which is the distinction a glance most needs.\n */\nconst SPINE_GLYPHS: Record<ToolSymbolPreset, Record<ToolLifecycle, string>> = {\n\tunicode: { queued: \"┆\", running: \"▌\", done: \"▌\", error: \"▌\" },\n\tascii: { queued: \":\", running: \"|\", done: \"|\", error: \"|\" },\n};\n\nexport function formatToolDuration(durationMs: number): string {\n\tif (durationMs < 1000) return `${Math.max(0, Math.round(durationMs))}ms`;\n\tif (durationMs < 10_000) return `${(durationMs / 1000).toFixed(1)}s`;\n\treturn `${Math.round(durationMs / 1000)}s`;\n}\n\nexport interface ToolStatusLineOptions {\n\tlifecycle: ToolLifecycle;\n\tsymbolPreset: ToolSymbolPreset;\n\tdurationMs?: number;\n}\n\nfunction lifecycleBackground(lifecycle: ToolLifecycle): \"toolPendingBg\" | \"toolSuccessBg\" | \"toolErrorBg\" {\n\tif (lifecycle === \"done\") return \"toolSuccessBg\";\n\tif (lifecycle === \"error\") return \"toolErrorBg\";\n\treturn \"toolPendingBg\";\n}\n\n/** Prime-style flat shell for renderer-based tool calls. */\nexport class ToolPanelComponent implements Component {\n\tprivate readonly child: Component;\n\tprivate readonly options: ToolStatusLineOptions;\n\n\tconstructor(child: Component, options: ToolStatusLineOptions) {\n\t\tthis.child = child;\n\t\tthis.options = options;\n\t}\n\n\trender(width: number): string[] {\n\t\tif (width <= 0) return [];\n\t\tconst padding = Math.min(2, Math.floor((width - 1) / 2));\n\t\tconst innerWidth = Math.max(1, width - padding * 2);\n\t\tconst childLines = this.child.render(innerWidth);\n\t\tif (childLines.length === 0) return [];\n\n\t\tconst { lifecycle, symbolPreset, durationMs } = this.options;\n\t\tconst duration = durationMs === undefined ? \"\" : ` ${formatToolDuration(durationMs)}`;\n\t\tconst state = theme.fg(\n\t\t\tlifecycleColor(lifecycle),\n\t\t\t`${LIFECYCLE_SYMBOLS[symbolPreset][lifecycle]} ${lifecycle}${duration}`,\n\t\t);\n\t\tconst separator = theme.fg(\"dim\", symbolPreset === \"ascii\" ? \" - \" : \" · \");\n\t\tconst stateWidth = visibleWidth(separator) + visibleWidth(state);\n\t\tconst label = childLines[0].replace(/\\s+$/, \"\");\n\t\tconst header =\n\t\t\tstateWidth < innerWidth\n\t\t\t\t? `${truncateToWidth(label, innerWidth - stateWidth, \"\")}${separator}${state}`\n\t\t\t\t: truncateToWidth(state, innerWidth, \"\");\n\t\t// Renderers written before the panel open their body with their own blank row. The\n\t\t// panel owns that separation, so it drops theirs and inserts exactly one.\n\t\tlet bodyStart = 1;\n\t\twhile (bodyStart < childLines.length && visibleWidth(childLines[bodyStart].trim()) === 0) bodyStart++;\n\t\tconst panelLines = [header];\n\t\tif (bodyStart < childLines.length) panelLines.push(\"\", ...childLines.slice(bodyStart));\n\n\t\tconst background = lifecycleBackground(lifecycle);\n\t\t// The spine occupies the first column of the existing left padding, so it\n\t\t// marks state without costing the panel a column of content. Below two\n\t\t// columns of padding there is no room for it and it is dropped.\n\t\tconst showSpine = padding >= 1;\n\t\tconst spine = showSpine\n\t\t\t? paintBackground(theme.fg(lifecycleColor(lifecycle), SPINE_GLYPHS[symbolPreset][lifecycle]), background)\n\t\t\t: \"\";\n\t\tconst leftPadding = \" \".repeat(Math.max(0, padding - (showSpine ? 1 : 0)));\n\t\treturn panelLines.map((line) => {\n\t\t\tconst clipped = truncateToWidth(line, innerWidth, \"\");\n\t\t\tconst rightPadding = \" \".repeat(Math.max(0, innerWidth - visibleWidth(clipped)));\n\t\t\treturn spine + paintBackground(`${leftPadding}${clipped}${rightPadding}${\" \".repeat(padding)}`, background);\n\t\t});\n\t}\n\n\tinvalidate(): void {\n\t\tthis.child.invalidate?.();\n\t}\n}\n\n/**\n * Prefixes an existing public tool renderer with Apex-owned lifecycle text.\n * The wrapped renderer receives the remaining width, so its own wrapping and\n * cursor-free layout stay intact without a pi-tui hook.\n */\nexport class ToolStatusLineComponent implements Component {\n\tprivate readonly child: Component;\n\tprivate readonly options: ToolStatusLineOptions;\n\n\tconstructor(child: Component, options: ToolStatusLineOptions) {\n\t\tthis.child = child;\n\t\tthis.options = options;\n\t}\n\n\trender(width: number): string[] {\n\t\tif (width <= 0) return [];\n\t\tconst { lifecycle, symbolPreset, durationMs } = this.options;\n\t\tconst duration = durationMs === undefined ? \"\" : ` ${formatToolDuration(durationMs)}`;\n\t\tconst separator = symbolPreset === \"ascii\" ? \" | \" : \" · \";\n\t\tconst plainPrefix = `${LIFECYCLE_SYMBOLS[symbolPreset][lifecycle]} ${lifecycle}${duration}${separator}`;\n\t\tconst prefix = theme.fg(lifecycleColor(lifecycle), plainPrefix);\n\t\tconst prefixWidth = visibleWidth(prefix);\n\n\t\tif (prefixWidth >= width) {\n\t\t\treturn [truncateToWidth(prefix, width, \"\")];\n\t\t}\n\n\t\tconst childWidth = Math.max(1, width - prefixWidth);\n\t\tconst childLines = this.child.render(childWidth);\n\t\tif (childLines.length === 0) return [];\n\n\t\tconst continuation = \" \".repeat(prefixWidth);\n\t\treturn childLines.map((line, index) => (index === 0 ? prefix : continuation) + line);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.child.invalidate?.();\n\t}\n}\n\nexport interface CompactOperationRowOptions extends ToolStatusLineOptions {\n\tlabel: string;\n\tsummary?: string;\n}\n\nexport function countOutputLines(output: string): number {\n\tif (!output) return 0;\n\tconst lines = output.replace(/\\r\\n?/g, \"\\n\").split(\"\\n\");\n\treturn lines.length - (lines.at(-1) === \"\" ? 1 : 0);\n}\n\n/** One physical row, with no panel decoration or spacing between operations. */\nexport function renderCompactOperationRow(options: CompactOperationRowOptions, width: number): string[] {\n\tif (width <= 0) return [];\n\tconst singleLine = (text: string) =>\n\t\tstripAnsi(text)\n\t\t\t.replace(/\\p{Cc}/gu, \" \")\n\t\t\t.replace(/ +/g, \" \")\n\t\t\t.trim();\n\tconst { lifecycle, symbolPreset, durationMs } = options;\n\tconst status = theme.fg(lifecycleColor(lifecycle), LIFECYCLE_SYMBOLS[symbolPreset][lifecycle]);\n\tconst prefix = `${status} `;\n\tconst prefixWidth = visibleWidth(prefix);\n\tif (prefixWidth >= width) return [truncateToWidth(status, width, \"\")];\n\tconst separator = symbolPreset === \"ascii\" ? \" - \" : \" · \";\n\tconst duration = durationMs === undefined ? \"\" : formatToolDuration(durationMs);\n\tconst metadata = singleLine([lifecycle, options.summary, duration].filter(Boolean).join(separator));\n\tconst label = singleLine(options.label);\n\tconst available = width - prefixWidth - visibleWidth(separator);\n\tif (available < 2) return [truncateToWidth(`${prefix}${label}`, width, \"\")];\n\t// Preserve state and diagnostics even when a path or command fills the row.\n\tconst minimumLabel = Math.min(\n\t\tvisibleWidth(label),\n\t\tMath.max(1, Math.floor(available * (lifecycle === \"error\" ? 0.3 : 0.5))),\n\t);\n\tconst metadataWidth = Math.min(visibleWidth(metadata), available - minimumLabel);\n\tconst clippedMetadata = truncateToWidth(metadata, metadataWidth, \"\");\n\tconst clippedLabel = truncateToWidth(label, available - visibleWidth(clippedMetadata), \"\").trimEnd();\n\treturn [`${prefix}${clippedLabel}${theme.fg(\"muted\", separator + clippedMetadata)}`];\n}\n"]}
@@ -465,6 +465,7 @@ export declare class InteractiveMode {
465
465
  * remembering to set every axis.
466
466
  */
467
467
  private adoptChatDetail;
468
+ private toggleLatestOperation;
468
469
  /** The expand key. A level the user picks is saved, so the next session opens at it. */
469
470
  private cycleChatDetail;
470
471
  private chooseChatDetail;