@blackbelt-technology/pi-dashboard-client-utils 0.5.3

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.
@@ -0,0 +1,381 @@
1
+ /**
2
+ * MinimalChatView — shared subagent / agent timeline renderer.
3
+ *
4
+ * Single source of truth for the timeline UI that was previously duplicated
5
+ * across `packages/subagents-plugin/.../SubagentDetailView.tsx` and
6
+ * `packages/flows-plugin/.../FlowAgentDetail.tsx`. Producer plugins wrap this
7
+ * with a thin adapter that maps their state shape into `MinimalChatViewProps`.
8
+ *
9
+ * Modes:
10
+ * - "inline" — body capped at max-h-[60vh] (popover / expanded-card usage)
11
+ * - "popout" — fills parent (h-full) for dedicated popout pages
12
+ * - "row" — single-line summary, no body (panel-row usage)
13
+ *
14
+ * UI primitives (`MarkdownContent`, `formatTokens`, `formatDuration`) are
15
+ * resolved via `useUiPrimitive(UI_PRIMITIVE_KEYS.*)` — tests MUST wrap renders
16
+ * in `withUiPrimitiveProvider` to populate them.
17
+ *
18
+ * See change: extract-minimal-chat-view.
19
+ */
20
+ import React from "react";
21
+ import { Icon } from "@mdi/react";
22
+ import {
23
+ mdiAlertCircle,
24
+ mdiArrowLeft,
25
+ mdiCheckCircle,
26
+ mdiCircle,
27
+ mdiCircleOutline,
28
+ mdiCloseCircle,
29
+ } from "@mdi/js";
30
+ import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
31
+ import { useUiPrimitive, useUiPrimitiveOrNull } from "@blackbelt-technology/dashboard-plugin-runtime";
32
+ import type {
33
+ MinimalChatEntry,
34
+ MinimalChatStatus,
35
+ MinimalChatViewProps,
36
+ } from "./types.js";
37
+
38
+ // ---- Status visuals ----
39
+
40
+ /**
41
+ * Resolves the mdi-icon path and tailwind color class for a given status.
42
+ * Centralizing this map is the main reason for the extraction — adding a
43
+ * new status is a one-file change.
44
+ */
45
+ export function statusVisualsFor(status: MinimalChatStatus): {
46
+ iconPath: string;
47
+ colorClass: string;
48
+ } {
49
+ switch (status) {
50
+ case "complete":
51
+ return { iconPath: mdiCheckCircle, colorClass: "text-green-400" };
52
+ case "error":
53
+ return { iconPath: mdiCloseCircle, colorClass: "text-red-400" };
54
+ case "running":
55
+ return { iconPath: mdiCircle, colorClass: "text-yellow-400" };
56
+ case "blocked":
57
+ return { iconPath: mdiAlertCircle, colorClass: "text-orange-400" };
58
+ case "pending":
59
+ return { iconPath: mdiCircleOutline, colorClass: "text-[var(--text-tertiary)]" };
60
+ default: {
61
+ // Exhaustive check — TS will error if a new MinimalChatStatus branch
62
+ // is missed. The runtime fallback is the same as "pending".
63
+ const _exhaustive: never = status;
64
+ void _exhaustive;
65
+ return { iconPath: mdiCircleOutline, colorClass: "text-[var(--text-tertiary)]" };
66
+ }
67
+ }
68
+ }
69
+
70
+ // ---- Helpers ----
71
+
72
+ export function extractInputPreview(toolName: string, input: unknown): string {
73
+ if (!input || typeof input !== "object") return "";
74
+ const inp = input as Record<string, unknown>;
75
+ switch (toolName.toLowerCase()) {
76
+ case "read":
77
+ case "write":
78
+ case "edit":
79
+ return String(inp.file_path || inp.path || "");
80
+ case "bash":
81
+ return String(inp.command || "").slice(0, 80);
82
+ case "grep":
83
+ return String(inp.pattern || "").slice(0, 40);
84
+ default:
85
+ try {
86
+ return JSON.stringify(input).slice(0, 60);
87
+ } catch {
88
+ return "";
89
+ }
90
+ }
91
+ }
92
+
93
+ // ---- Entry renderers ----
94
+
95
+ function ToolCallEntry({
96
+ entry,
97
+ index,
98
+ sessionId,
99
+ }: {
100
+ entry: Extract<MinimalChatEntry, { kind: "tool" }>;
101
+ index: number;
102
+ sessionId?: string;
103
+ }) {
104
+ // Prefer the shell-registered `toolCallStep` primitive for parity with the
105
+ // main chat view (per-tool renderers, collapsible output, status icon).
106
+ // Falls back to a simple inline renderer when the primitive is not
107
+ // registered (e.g. unit tests without the full provider).
108
+ // See change: fix-flows-plugin-polish (chat-view parity).
109
+ const ToolCallStepImpl = useUiPrimitiveOrNull(UI_PRIMITIVE_KEYS.toolCallStep);
110
+ const args =
111
+ entry.input && typeof entry.input === "object" && !Array.isArray(entry.input)
112
+ ? (entry.input as Record<string, unknown>)
113
+ : { value: entry.input };
114
+ const result =
115
+ entry.output === undefined
116
+ ? undefined
117
+ : typeof entry.output === "string"
118
+ ? entry.output
119
+ : JSON.stringify(entry.output, null, 2);
120
+ if (ToolCallStepImpl) {
121
+ const toolCallId = `minimal-${index}`;
122
+ const status = entry.isError ? "error" : entry.output !== undefined ? "complete" : "running";
123
+ return (
124
+ <ToolCallStepImpl
125
+ toolName={entry.toolName}
126
+ toolCallId={toolCallId}
127
+ args={args}
128
+ status={status}
129
+ result={result}
130
+ sessionId={sessionId}
131
+ />
132
+ );
133
+ }
134
+
135
+ // Fallback: simple inline renderer.
136
+ const preview = extractInputPreview(entry.toolName, entry.input);
137
+ const hasOutput = entry.output !== undefined;
138
+ return (
139
+ <FallbackToolEntry
140
+ toolName={entry.toolName}
141
+ preview={preview}
142
+ hasOutput={hasOutput}
143
+ result={result}
144
+ isError={entry.isError ?? false}
145
+ />
146
+ );
147
+ }
148
+
149
+ function FallbackToolEntry({
150
+ toolName,
151
+ preview,
152
+ hasOutput,
153
+ result,
154
+ isError,
155
+ }: {
156
+ toolName: string;
157
+ preview: string;
158
+ hasOutput: boolean;
159
+ result?: string;
160
+ isError: boolean;
161
+ }) {
162
+ const [expanded, setExpanded] = React.useState(false);
163
+ return (
164
+ <div className={`border-l-2 pl-3 py-1.5 ${isError ? "border-red-500/50" : "border-blue-500/30"}`}>
165
+ <div
166
+ className="flex items-center gap-1.5 cursor-pointer"
167
+ onClick={() => hasOutput && setExpanded(!expanded)}
168
+ >
169
+ <span className={`text-xs font-mono ${isError ? "text-red-400" : "text-blue-400"}`}>
170
+ {toolName}
171
+ </span>
172
+ <span className="text-xs text-[var(--text-tertiary)] truncate">{preview}</span>
173
+ {hasOutput && (
174
+ <span className="text-[10px] text-[var(--text-muted)] ml-auto flex-shrink-0">
175
+ {expanded ? "▾" : "▸"}
176
+ </span>
177
+ )}
178
+ </div>
179
+ {expanded && hasOutput && result !== undefined && (
180
+ <pre className="text-[11px] text-[var(--text-secondary)] mt-1 overflow-x-auto max-h-48 overflow-y-auto whitespace-pre-wrap break-words bg-[var(--bg-tertiary)] rounded p-2">
181
+ {result}
182
+ </pre>
183
+ )}
184
+ </div>
185
+ );
186
+ }
187
+
188
+ function TextEntry({ text }: { text: string }) {
189
+ const MarkdownContent = useUiPrimitive(UI_PRIMITIVE_KEYS.markdownContent);
190
+ return (
191
+ <div className="py-1.5 pl-3">
192
+ <MarkdownContent content={text} />
193
+ </div>
194
+ );
195
+ }
196
+
197
+ function ThinkingEntry({ text }: { text: string }) {
198
+ // Prefer the shell-registered `thinkingBlock` primitive for parity with
199
+ // the main chat view. Falls back to a simple inline rendition when the
200
+ // primitive is not registered.
201
+ // See change: fix-flows-plugin-polish (chat-view parity).
202
+ const ThinkingBlockImpl = useUiPrimitiveOrNull(UI_PRIMITIVE_KEYS.thinkingBlock);
203
+ if (ThinkingBlockImpl) {
204
+ return <ThinkingBlockImpl content={text} />;
205
+ }
206
+ return <FallbackThinkingEntry text={text} />;
207
+ }
208
+
209
+ function FallbackThinkingEntry({ text }: { text: string }) {
210
+ const [expanded, setExpanded] = React.useState(false);
211
+ return (
212
+ <div className="py-1 pl-3">
213
+ <div
214
+ className="flex items-center gap-1 cursor-pointer text-[11px] text-purple-400/70"
215
+ onClick={() => setExpanded(!expanded)}
216
+ >
217
+ <span>{expanded ? "▾" : "▸"}</span>
218
+ <span>Thinking</span>
219
+ </div>
220
+ {expanded && (
221
+ <pre className="text-[11px] text-[var(--text-muted)] mt-1 whitespace-pre-wrap break-words max-h-64 overflow-y-auto">
222
+ {text}
223
+ </pre>
224
+ )}
225
+ </div>
226
+ );
227
+ }
228
+
229
+ function ErrorEntry({ text }: { text: string }) {
230
+ return <div className="py-1.5 pl-3 text-sm text-red-400">{text}</div>;
231
+ }
232
+
233
+ // ---- Main component ----
234
+
235
+ export function MinimalChatView({
236
+ title,
237
+ subtitle,
238
+ status,
239
+ entries,
240
+ meta,
241
+ mode = "inline",
242
+ onBack,
243
+ emptyMessage,
244
+ footer,
245
+ activity,
246
+ sessionId,
247
+ }: MinimalChatViewProps) {
248
+ // Soft-read formatters — fall back to identity formatting when the
249
+ // primitive registry is partially populated (matches the spec’s
250
+ // "header meta renders only when present" requirement: missing
251
+ // formatters degrade gracefully rather than throw).
252
+ const formatTokensImpl = useUiPrimitiveOrNull(UI_PRIMITIVE_KEYS.formatTokens);
253
+ const formatDurationImpl = useUiPrimitiveOrNull(UI_PRIMITIVE_KEYS.formatDuration);
254
+ const formatTokens = formatTokensImpl ?? ((n: number) => String(n));
255
+ const formatDuration = formatDurationImpl ?? ((ms: number) => `${ms}ms`);
256
+ const { iconPath, colorClass } = statusVisualsFor(status);
257
+
258
+ // Row mode: single-line summary, no body. No footer, no header chrome.
259
+ if (mode === "row") {
260
+ return (
261
+ <div className="flex items-center gap-2 py-1">
262
+ <span className={`${colorClass} inline-flex flex-shrink-0`}>
263
+ <Icon path={iconPath} size={0.5} />
264
+ </span>
265
+ <span className="text-xs font-medium text-[var(--text-primary)] truncate">{title}</span>
266
+ {activity && (
267
+ <span className="text-[10px] text-[var(--text-tertiary)] truncate ml-1">{activity}</span>
268
+ )}
269
+ </div>
270
+ );
271
+ }
272
+
273
+ const showMeta =
274
+ !!meta &&
275
+ (meta.modelName !== undefined ||
276
+ meta.durationMs !== undefined ||
277
+ (meta.tokens !== undefined && (meta.tokens.input !== undefined || meta.tokens.output !== undefined)));
278
+
279
+ const hasTokensOrDuration =
280
+ !!meta && (meta.tokens !== undefined || meta.durationMs !== undefined);
281
+
282
+ // Header (inline + popout share)
283
+ const header = (
284
+ <div className="px-3 py-2 border-b border-[var(--border-subtle)] bg-[var(--bg-secondary)] flex items-center gap-2 flex-shrink-0">
285
+ {onBack && (
286
+ <button
287
+ onClick={onBack}
288
+ className="text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors"
289
+ title="Back"
290
+ >
291
+ <Icon path={mdiArrowLeft} size={0.7} />
292
+ </button>
293
+ )}
294
+ <span className={`${colorClass} inline-flex`}>
295
+ <Icon path={iconPath} size={0.6} />
296
+ </span>
297
+ <div className="flex flex-col min-w-0 flex-1">
298
+ <span className="text-sm font-medium text-[var(--text-primary)] truncate">{title}</span>
299
+ {subtitle && (
300
+ <span
301
+ className="text-[10px] font-mono text-[var(--text-tertiary)] truncate"
302
+ title={subtitle}
303
+ >
304
+ {subtitle}
305
+ </span>
306
+ )}
307
+ {activity && status === "running" && (
308
+ <span className="text-[10px] text-[var(--text-tertiary)] truncate">{activity}</span>
309
+ )}
310
+ </div>
311
+ {showMeta && meta?.modelName && (
312
+ <span className="text-[11px] text-[var(--text-tertiary)] truncate flex-shrink-0">
313
+ {meta.modelName}
314
+ </span>
315
+ )}
316
+ {showMeta && hasTokensOrDuration && (
317
+ <span className="text-[11px] text-[var(--text-muted)] ml-auto whitespace-nowrap">
318
+ {meta?.tokens && (
319
+ <>
320
+ ↑{formatTokens(meta.tokens.input ?? 0)} ↓{formatTokens(meta.tokens.output ?? 0)}
321
+ {meta.durationMs !== undefined && " · "}
322
+ </>
323
+ )}
324
+ {meta?.durationMs !== undefined && formatDuration(meta.durationMs)}
325
+ </span>
326
+ )}
327
+ </div>
328
+ );
329
+
330
+ // Inline mode uses a STABLE height (`h-[60vh]`, not `max-h-[60vh]`) so
331
+ // the container doesn't bounce as content streams in. The body's
332
+ // `flex-1 min-h-0 overflow-y-auto` (below) gives it a consistent
333
+ // scroll surface regardless of content size.
334
+ //
335
+ // See change: fix-flows-plugin-polish (stable inline height).
336
+ const containerClasses =
337
+ mode === "popout"
338
+ ? "flex flex-col h-full overflow-hidden"
339
+ : "flex flex-col h-[60vh] overflow-hidden";
340
+
341
+ const defaultEmpty = "No activity yet";
342
+ const empty = emptyMessage ?? defaultEmpty;
343
+
344
+ // `min-h-0` is the canonical Tailwind/flexbox fix for `overflow-y-auto`:
345
+ // without it, flex children default to `min-height: auto` (= content
346
+ // height), which prevents the body from being shorter than its content,
347
+ // which prevents the scrollbar from appearing. The eye-button popover
348
+ // (max-h-[70vh] parent) and the popout page (h-full parent) both rely
349
+ // on this so the body scrolls instead of overflowing the chrome.
350
+ // See change: fix-flows-plugin-polish (scrollbar fix).
351
+ const body = (
352
+ <div className="flex-1 min-h-0 overflow-y-auto px-3 py-2 space-y-0.5">
353
+ {entries.length === 0 ? (
354
+ <div className="text-sm text-[var(--text-muted)] py-4 text-center">{empty}</div>
355
+ ) : (
356
+ entries.map((entry, i) => {
357
+ switch (entry.kind) {
358
+ case "tool":
359
+ return <ToolCallEntry key={i} entry={entry} index={i} sessionId={sessionId} />;
360
+ case "text":
361
+ return <TextEntry key={i} text={entry.text} />;
362
+ case "thinking":
363
+ return <ThinkingEntry key={i} text={entry.text} />;
364
+ case "error":
365
+ return <ErrorEntry key={i} text={entry.text} />;
366
+ default:
367
+ return null;
368
+ }
369
+ })
370
+ )}
371
+ {footer}
372
+ </div>
373
+ );
374
+
375
+ return (
376
+ <div className={containerClasses}>
377
+ {header}
378
+ {body}
379
+ </div>
380
+ );
381
+ }
@@ -0,0 +1,232 @@
1
+ /**
2
+ * MinimalChatView unit tests.
3
+ *
4
+ * Tests use `withUiPrimitiveProvider` to mock `MarkdownContent`,
5
+ * `formatTokens`, `formatDuration`. Rendering without the provider must
6
+ * throw a hook-resolution error (covered by the negative case below).
7
+ *
8
+ * See change: extract-minimal-chat-view.
9
+ */
10
+ import React from "react";
11
+ import { afterEach, describe, expect, it } from "vitest";
12
+ import { cleanup, fireEvent, render, screen } from "@testing-library/react";
13
+ import { withUiPrimitiveProvider } from "@blackbelt-technology/dashboard-plugin-runtime/test-support";
14
+ import { MinimalChatView } from "../MinimalChatView.js";
15
+ import type { MinimalChatEntry, MinimalChatStatus } from "../types.js";
16
+
17
+ const MockMarkdown: React.FC<{ content: string }> = ({ content }) => (
18
+ <div data-testid="md">{content}</div>
19
+ );
20
+
21
+ const mockFormatTokens = (n: number) => {
22
+ if (n >= 1000) return `${Math.round(n / 100) / 10}k`;
23
+ return String(n);
24
+ };
25
+ const mockFormatDuration = (ms: number) => `${(ms / 1000).toFixed(1)}s`;
26
+
27
+ function renderView(ui: React.ReactElement) {
28
+ return render(
29
+ withUiPrimitiveProvider(
30
+ {
31
+ "ui:markdown-content": MockMarkdown,
32
+ "ui:format-tokens": mockFormatTokens,
33
+ "ui:format-duration": mockFormatDuration,
34
+ },
35
+ ui,
36
+ ),
37
+ );
38
+ }
39
+
40
+ describe("MinimalChatView", () => {
41
+ afterEach(() => cleanup());
42
+
43
+ it("renders each of the four entry kinds in order", () => {
44
+ const entries: MinimalChatEntry[] = [
45
+ { kind: "tool", toolName: "Read", input: { file_path: "/foo.ts" } },
46
+ { kind: "text", text: "Hello world" },
47
+ { kind: "thinking", text: "I should look here" },
48
+ { kind: "error", text: "Boom" },
49
+ ];
50
+ renderView(
51
+ <MinimalChatView title="alpha" status="running" entries={entries} />,
52
+ );
53
+ expect(screen.getByText("Read")).toBeTruthy();
54
+ expect(screen.getByText("/foo.ts")).toBeTruthy();
55
+ expect(screen.getByText(/Hello world/)).toBeTruthy();
56
+ expect(screen.getByText("Thinking")).toBeTruthy();
57
+ expect(screen.getByText("Boom")).toBeTruthy();
58
+ });
59
+
60
+ it("status enum maps to expected icon + color (5 values)", () => {
61
+ const cases: Array<{ status: MinimalChatStatus; color: string }> = [
62
+ { status: "complete", color: "text-green-400" },
63
+ { status: "error", color: "text-red-400" },
64
+ { status: "running", color: "text-yellow-400" },
65
+ { status: "blocked", color: "text-orange-400" },
66
+ { status: "pending", color: "text-[var(--text-tertiary)]" },
67
+ ];
68
+ for (const { status, color } of cases) {
69
+ cleanup();
70
+ const { container } = renderView(
71
+ <MinimalChatView title="t" status={status} entries={[]} />,
72
+ );
73
+ // Walk all spans, find one whose classList contains both the color
74
+ // and `inline-flex`. Avoids CSS.escape (not available in jsdom env).
75
+ const spans = Array.from(container.querySelectorAll<HTMLElement>("span"));
76
+ const span = spans.find(
77
+ (s) => s.classList.contains(color) && s.classList.contains("inline-flex"),
78
+ );
79
+ expect(span, `expected color span for status=${status}`).toBeTruthy();
80
+ }
81
+ });
82
+
83
+ it("three modes apply expected root container classes", () => {
84
+ {
85
+ const { container } = renderView(
86
+ <MinimalChatView title="a" status="running" entries={[]} mode="popout" />,
87
+ );
88
+ const root = container.firstElementChild as HTMLElement;
89
+ expect(root.className).toContain("h-full");
90
+ expect(root.className).toContain("overflow-hidden");
91
+ }
92
+ cleanup();
93
+ {
94
+ const { container } = renderView(
95
+ <MinimalChatView title="a" status="running" entries={[]} mode="inline" />,
96
+ );
97
+ const root = container.firstElementChild as HTMLElement;
98
+ // Inline mode uses a STABLE height (`h-[60vh]`, not `max-h-[60vh]`) so
99
+ // the popover doesn't reflow as messages stream in. See MinimalChatView.tsx:330.
100
+ expect(root.className).toContain("h-[60vh]");
101
+ }
102
+ cleanup();
103
+ {
104
+ const { container } = renderView(
105
+ <MinimalChatView title="a" status="running" entries={[{ kind: "text", text: "body" }]} mode="row" activity="reading" />,
106
+ );
107
+ // Row mode: no body, only single line
108
+ expect(screen.queryByTestId("md")).toBeNull();
109
+ expect(screen.getByText("a")).toBeTruthy();
110
+ expect(screen.getByText("reading")).toBeTruthy();
111
+ // Root has no flex-col h-full
112
+ const root = container.firstElementChild as HTMLElement;
113
+ expect(root.className).not.toContain("h-full");
114
+ expect(root.className).not.toContain("h-[60vh]");
115
+ }
116
+ });
117
+
118
+ it("hides meta when prop is omitted", () => {
119
+ renderView(<MinimalChatView title="hdr" status="complete" entries={[]} />);
120
+ expect(screen.queryByText(/↑/)).toBeNull();
121
+ expect(screen.queryByText(/↓/)).toBeNull();
122
+ });
123
+
124
+ it("renders ↑/↓ tokens and formatted duration when meta supplied", () => {
125
+ renderView(
126
+ <MinimalChatView
127
+ title="hdr"
128
+ status="complete"
129
+ entries={[]}
130
+ meta={{ tokens: { input: 1234, output: 567 }, durationMs: 4500 }}
131
+ />,
132
+ );
133
+ expect(screen.getByText(/↑1\.2k/)).toBeTruthy();
134
+ expect(screen.getByText(/↓567/)).toBeTruthy();
135
+ expect(screen.getByText(/4\.5s/)).toBeTruthy();
136
+ });
137
+
138
+ it("renders subtitle path under the title in monospace", () => {
139
+ renderView(
140
+ <MinimalChatView
141
+ title="explorer"
142
+ subtitle="~/.pi/agent/agents/Explore.md"
143
+ status="complete"
144
+ entries={[]}
145
+ />,
146
+ );
147
+ const sub = screen.getByText("~/.pi/agent/agents/Explore.md");
148
+ expect(sub).toBeTruthy();
149
+ expect(sub.className).toContain("font-mono");
150
+ expect(sub.getAttribute("title")).toBe("~/.pi/agent/agents/Explore.md");
151
+ });
152
+
153
+ it("tool entry without output shows no expand toggle", () => {
154
+ renderView(
155
+ <MinimalChatView
156
+ title="t"
157
+ status="running"
158
+ entries={[{ kind: "tool", toolName: "Read", input: { file_path: "foo.ts" } }]}
159
+ />,
160
+ );
161
+ expect(screen.queryByText("▸")).toBeNull();
162
+ expect(screen.queryByText("▾")).toBeNull();
163
+ });
164
+
165
+ it("tool entry with output toggles open on click", () => {
166
+ renderView(
167
+ <MinimalChatView
168
+ title="t"
169
+ status="running"
170
+ entries={[{ kind: "tool", toolName: "Bash", input: { command: "ls" }, output: "abc-output" }]}
171
+ />,
172
+ );
173
+ const toggle = screen.getByText("▸");
174
+ expect(screen.queryByText("abc-output")).toBeNull();
175
+ fireEvent.click(toggle);
176
+ expect(screen.getByText("▾")).toBeTruthy();
177
+ expect(screen.getByText("abc-output")).toBeTruthy();
178
+ });
179
+
180
+ it("tool entry with isError paints row border and name red", () => {
181
+ const { container } = renderView(
182
+ <MinimalChatView
183
+ title="t"
184
+ status="error"
185
+ entries={[{ kind: "tool", toolName: "Bash", input: {}, isError: true }]}
186
+ />,
187
+ );
188
+ // Border red on row container
189
+ const row = container.querySelector("div.border-l-2");
190
+ expect(row?.className).toContain("border-red-500/50");
191
+ // Name red
192
+ const name = screen.getByText("Bash");
193
+ expect(name.className).toContain("text-red-400");
194
+ });
195
+
196
+ it("renders the supplied empty-state message when entries is empty", () => {
197
+ renderView(
198
+ <MinimalChatView
199
+ title="t"
200
+ status="pending"
201
+ entries={[]}
202
+ emptyMessage="Waiting to start..."
203
+ />,
204
+ );
205
+ expect(screen.getByText(/Waiting to start/)).toBeTruthy();
206
+ });
207
+
208
+ it("renders footer node below entries", () => {
209
+ renderView(
210
+ <MinimalChatView
211
+ title="t"
212
+ status="complete"
213
+ entries={[]}
214
+ footer={<div data-testid="footer">FOOTER</div>}
215
+ />,
216
+ );
217
+ expect(screen.getByTestId("footer")).toBeTruthy();
218
+ });
219
+
220
+ it("throws when rendered without the UiPrimitiveProvider (negative case)", () => {
221
+ // Suppress console.error noise from the rendered error
222
+ const orig = console.error;
223
+ console.error = () => {};
224
+ try {
225
+ expect(() =>
226
+ render(<MinimalChatView title="t" status="running" entries={[]} />),
227
+ ).toThrow();
228
+ } finally {
229
+ console.error = orig;
230
+ }
231
+ });
232
+ });
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Barrel for the `./minimal-chat` subpath export.
3
+ *
4
+ * Consumers import via:
5
+ * import { MinimalChatView } from "@blackbelt-technology/pi-dashboard-client-utils/minimal-chat";
6
+ *
7
+ * See change: extract-minimal-chat-view.
8
+ */
9
+ export { MinimalChatView, statusVisualsFor, extractInputPreview } from "./MinimalChatView.js";
10
+ export type {
11
+ MinimalChatEntry,
12
+ MinimalChatMeta,
13
+ MinimalChatMode,
14
+ MinimalChatStatus,
15
+ MinimalChatViewProps,
16
+ } from "./types.js";