@shanepadgett/tau-tui 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/tool-panel.ts +22 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shanepadgett/tau-tui",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Shared TUI components and helpers for Tau Agent",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/tool-panel.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Theme } from "@earendil-works/pi-coding-agent";
2
- import { type Component, truncateToWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
2
+ import { type Component, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
3
3
  import { renderToolKeyHints, type ToolKeyHint } from "./key-hints.ts";
4
4
 
5
5
  export type ToolPanelFooter =
@@ -13,6 +13,7 @@ export interface ToolPanelConfig {
13
13
  header?: Component | readonly string[];
14
14
  body: Component;
15
15
  footer: ToolPanelFooter;
16
+ border?: "horizontal" | "box";
16
17
  }
17
18
 
18
19
  export class ToolPanel implements Component {
@@ -26,22 +27,35 @@ export class ToolPanel implements Component {
26
27
 
27
28
  render(width: number): string[] {
28
29
  const renderWidth = Math.max(1, width);
29
- const body = this.config.body.render(renderWidth).map((line) => truncateToWidth(line, renderWidth, ""));
30
- const footer = this.renderFooter(renderWidth);
30
+ const boxed = this.config.border === "box" && renderWidth >= 5;
31
+ const contentWidth = boxed ? renderWidth - 4 : renderWidth;
32
+ const body = this.config.body.render(contentWidth).map((line) => truncateToWidth(line, contentWidth, ""));
33
+ const footer = this.renderFooter(contentWidth);
31
34
  const lines: string[] = [];
32
35
 
33
- lines.push(this.theme.fg("border", "─".repeat(renderWidth)));
34
- lines.push(...this.renderTitle(renderWidth));
35
- const header = this.renderHeader(renderWidth);
36
+ if (!boxed) lines.push(this.theme.fg("border", "─".repeat(renderWidth)));
37
+ lines.push(...this.renderTitle(contentWidth));
38
+ const header = this.renderHeader(contentWidth);
36
39
  if (header.length > 0) lines.push("");
37
40
  lines.push(...header);
38
41
  if (body.length > 0) lines.push("");
39
42
  lines.push(...body);
40
43
  if (footer.length > 0) lines.push("");
41
44
  lines.push(...footer);
42
- lines.push(this.theme.fg("border", "─".repeat(renderWidth)));
45
+ if (!boxed) {
46
+ lines.push(this.theme.fg("border", "─".repeat(renderWidth)));
47
+ return lines;
48
+ }
43
49
 
44
- return lines;
50
+ const border = (text: string) => this.theme.fg("border", text);
51
+ return [
52
+ border(`╭${"─".repeat(renderWidth - 2)}╮`),
53
+ ...lines.map((line) => {
54
+ const content = truncateToWidth(line, contentWidth, "");
55
+ return `${border("│")} ${content}${" ".repeat(Math.max(0, contentWidth - visibleWidth(content)))} ${border("│")}`;
56
+ }),
57
+ border(`╰${"─".repeat(renderWidth - 2)}╯`),
58
+ ];
45
59
  }
46
60
 
47
61
  invalidate(): void {