@xynogen/pix-pretty 1.7.19 → 1.7.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-pretty",
3
- "version": "1.7.19",
3
+ "version": "1.7.20",
4
4
  "description": "Enhanced tool output rendering with syntax highlighting, file icons, tree views, diff rendering, and FFF search",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
package/src/types.ts CHANGED
@@ -185,6 +185,7 @@ export type FindResultDetails = {
185
185
  _type: "findResult";
186
186
  text: string;
187
187
  pattern: string;
188
+ path?: string;
188
189
  matchCount: number;
189
190
  };
190
191
 
@@ -192,6 +193,7 @@ export type GrepResultDetails = {
192
193
  _type: "grepResult";
193
194
  text: string;
194
195
  pattern: string;
196
+ path?: string;
195
197
  matchCount: number;
196
198
  };
197
199
 
package/src/utils.test.ts CHANGED
@@ -2,7 +2,14 @@ import { describe, expect, it } from "bun:test";
2
2
 
3
3
  import { MAX_PREVIEW_LINES } from "./config.js";
4
4
  import type { FgTheme } from "./types.js";
5
- import { pluralize, renderDimPreview, setResultDetails } from "./utils.js";
5
+ import {
6
+ formatCollapsedToolRow,
7
+ hideCollapsedToolCall,
8
+ pluralize,
9
+ renderCollapsedToolRow,
10
+ renderDimPreview,
11
+ setResultDetails,
12
+ } from "./utils.js";
6
13
 
7
14
  // Strip ANSI escapes so assertions test content, not color codes.
8
15
  const ANSI = /\x1b\[[0-9;]*m/g;
@@ -29,6 +36,26 @@ describe("pluralize", () => {
29
36
  });
30
37
  });
31
38
 
39
+ describe("collapsed tool rows", () => {
40
+ const rowTheme = { fg: (_key: string, text: string) => text, bold: (text: string) => text };
41
+
42
+ it("renders a consistent status, tool, target, and metadata row", () => {
43
+ expect(formatCollapsedToolRow(rowTheme, "read", "src/a.ts", "12 lines")).toBe(
44
+ "✓ read src/a.ts · 12 lines",
45
+ );
46
+ expect(plain(renderCollapsedToolRow(rowTheme, "read", "src/a.ts", "12 lines"))).toContain(
47
+ "✓ read src/a.ts · 12 lines",
48
+ );
49
+ });
50
+
51
+ it("hides only collapsed, non-expanded call rows", () => {
52
+ let value = "unchanged";
53
+ expect(hideCollapsedToolCall({ collapsed: true }, false, (text) => (value = text))).toBe(true);
54
+ expect(value).toBe("");
55
+ expect(hideCollapsedToolCall({ collapsed: true }, true, () => {})).toBe(false);
56
+ });
57
+ });
58
+
32
59
  describe("setResultDetails", () => {
33
60
  it("preserves upstream metadata while adding renderer details", () => {
34
61
  const result = {
package/src/utils.ts CHANGED
@@ -52,6 +52,55 @@ export function pluralize(count: number, noun: string, plural?: string): string
52
52
  return `${count} ${count === 1 ? noun : (plural ?? `${noun}s`)}`;
53
53
  }
54
54
 
55
+ export type CollapsedToolStatus = "success" | "error" | "warning";
56
+
57
+ type CollapsedToolTheme = {
58
+ fg: (
59
+ key: "success" | "error" | "warning" | "toolTitle" | "muted" | "dim",
60
+ text: string,
61
+ ) => string;
62
+ bold: (text: string) => string;
63
+ };
64
+
65
+ /** Format the shared one-row content without assuming a render shell. */
66
+ export function formatCollapsedToolRow(
67
+ theme: CollapsedToolTheme,
68
+ tool: string,
69
+ target: string,
70
+ meta = "",
71
+ status: CollapsedToolStatus = "success",
72
+ ): string {
73
+ const icon = status === "success" ? "✓" : status === "warning" ? "⚡" : "✗";
74
+ const parts = [
75
+ `${theme.fg(status, icon)} ${theme.fg("toolTitle", theme.bold(tool))}`,
76
+ target ? theme.fg("muted", target) : "",
77
+ meta ? `${theme.fg("dim", "·")} ${theme.fg("dim", meta)}` : "",
78
+ ].filter(Boolean);
79
+ return parts.join(" ");
80
+ }
81
+
82
+ /** Render shared one-row content for tools using the self-rendered shell. */
83
+ export function renderCollapsedToolRow(
84
+ theme: CollapsedToolTheme,
85
+ tool: string,
86
+ target: string,
87
+ meta = "",
88
+ status: CollapsedToolStatus = "success",
89
+ ): string {
90
+ return fillToolBackground(` ${formatCollapsedToolRow(theme, tool, target, meta, status)}`);
91
+ }
92
+
93
+ /** Hide renderCall after its paired result has auto-collapsed. */
94
+ export function hideCollapsedToolCall(
95
+ state: { collapsed?: boolean },
96
+ expanded: boolean,
97
+ setText: (text: string) => void,
98
+ ): boolean {
99
+ if (!state.collapsed || expanded) return false;
100
+ setText("");
101
+ return true;
102
+ }
103
+
55
104
  export type DimPreviewOptions = {
56
105
  maxLines?: number;
57
106
  header?: string;