@blackbelt-technology/pi-dashboard-flows-plugin 0.6.0 → 0.7.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blackbelt-technology/pi-dashboard-flows-plugin",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Flow rendering plugin for pi-dashboard — pi-flows event reaction (FlowDashboard, FlowAgentCard, FlowArchitect, etc.)",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -83,9 +83,9 @@
83
83
  },
84
84
  "//deps-rationale": "client-utils retained for hooks (useMobile, useZoomPan) and Phase-2 extension-ui slot consumers (AgentMetricSlot, BreadcrumbSlot, GateSlot, aggregateGateState helper). All UI primitive components (AgentCardShell, MarkdownContent, ConfirmDialog, DialogPortal, SearchableSelectDialog, ZoomControls, format-tokens, format-duration) flow through the UI primitive registry per add-plugin-ui-primitive-registry.",
85
85
  "dependencies": {
86
- "@blackbelt-technology/dashboard-plugin-runtime": "^0.6.0",
87
- "@blackbelt-technology/pi-dashboard-client-utils": "^0.6.0",
88
- "@blackbelt-technology/pi-dashboard-shared": "^0.6.0",
86
+ "@blackbelt-technology/dashboard-plugin-runtime": "^0.7.0",
87
+ "@blackbelt-technology/pi-dashboard-client-utils": "^0.7.0",
88
+ "@blackbelt-technology/pi-dashboard-shared": "^0.7.0",
89
89
  "yaml": "^2.9.0"
90
90
  },
91
91
  "devDependencies": {
@@ -7,16 +7,17 @@
7
7
  * /api/pi-resource-file, and renders it wrapped in a fenced ```ts block.
8
8
  * See change: open-code-handler-from-flow-card.
9
9
  */
10
- import React from "react";
11
- import { describe, it, expect, afterEach, beforeEach, vi } from "vitest";
12
- import { render, cleanup, fireEvent, waitFor } from "@testing-library/react";
10
+
13
11
  import {
14
- UiPrimitiveProvider,
15
12
  createUiPrimitiveRegistry,
16
13
  registerUiPrimitive,
14
+ UiPrimitiveProvider,
17
15
  } from "@blackbelt-technology/dashboard-plugin-runtime";
18
16
  import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
19
17
  import type { FlowAgentState } from "@blackbelt-technology/pi-dashboard-shared/types.js";
18
+ import { cleanup, fireEvent, render, waitFor } from "@testing-library/react";
19
+ import type React from "react";
20
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
20
21
  import { FlowAgentCard } from "../client/FlowAgentCard.js";
21
22
 
22
23
  const registry = createUiPrimitiveRegistry();
@@ -52,6 +53,19 @@ registerUiPrimitive(
52
53
  UI_PRIMITIVE_KEYS.markdownContent,
53
54
  (({ content }: { content: string }) => <pre data-testid="md">{content}</pre>) as never,
54
55
  );
56
+ // LogBlock: preview mode surfaces last-N lines + a copy button carrying the
57
+ // FULL text so the code-node preview's copy/expand affordances are testable.
58
+ registerUiPrimitive(
59
+ registry,
60
+ UI_PRIMITIVE_KEYS.logBlock,
61
+ (({ label, text, previewLines = 3 }: { label: string; text: string; previewLines?: number }) => (
62
+ <div data-testid="log-block">
63
+ <span>{label}</span>
64
+ <button type="button" data-testid="log-block-copy" data-full={text}>copy</button>
65
+ <pre data-testid="log-block-body">{text.split("\n").slice(-previewLines).join("\n")}</pre>
66
+ </div>
67
+ )) as never,
68
+ );
55
69
 
56
70
  function makeAgent(over: Partial<FlowAgentState>): FlowAgentState {
57
71
  return {
@@ -132,6 +146,28 @@ describe("FlowAgentCard code-handler source", () => {
132
146
  expect(md.textContent).toBe("```ts\nexport const x = 1;\n```");
133
147
  });
134
148
 
149
+ it("3.5 code-node log preview renders via LogBlock with copy carrying the FULL log", () => {
150
+ const agent = makeAgent({
151
+ nodeKind: "code",
152
+ codeTarget: HANDLER_PATH,
153
+ detailHistory: [
154
+ { kind: "text", text: "line-1" },
155
+ { kind: "text", text: "line-2" },
156
+ { kind: "text", text: "line-3" },
157
+ { kind: "text", text: "line-4" },
158
+ ],
159
+ } as Partial<FlowAgentState>);
160
+ const { getByTestId } = renderCard(agent);
161
+ const body = getByTestId("log-block-body");
162
+ // Preview shows the last 3 lines.
163
+ expect(body.textContent).toContain("line-4");
164
+ expect(body.textContent).not.toContain("line-1");
165
+ // Copy carries the FULL log (all 4 lines).
166
+ expect(getByTestId("log-block-copy").getAttribute("data-full")).toBe(
167
+ "line-1\nline-2\nline-3\nline-4",
168
+ );
169
+ });
170
+
135
171
  it("3.4 fetch error surfaces in the dialog", async () => {
136
172
  vi.stubGlobal(
137
173
  "fetch",
@@ -1,4 +1,4 @@
1
- import { useT, useUiPrimitive } from "@blackbelt-technology/dashboard-plugin-runtime";
1
+ import { useT, useUiPrimitive, useUiPrimitiveOrNull } from "@blackbelt-technology/dashboard-plugin-runtime";
2
2
  // AgentMetricSlot is a slot CONSUMER (Phase-2 decorator slot), not a primitive
3
3
  // — it stays as a direct import. See add-plugin-ui-primitive-registry Decision 4.
4
4
  import { AgentMetricSlot } from "@blackbelt-technology/pi-dashboard-client-utils/extension-ui/AgentMetricSlot";
@@ -53,6 +53,9 @@ export function FlowAgentCard({
53
53
  const stepId = agent.stepId || agent.agentName;
54
54
  const t = useT();
55
55
  const AgentCardShell = useUiPrimitive(UI_PRIMITIVE_KEYS.agentCard);
56
+ // Soft lookup: production registers `logBlock` (main.tsx); when absent the
57
+ // code-node preview falls back to the padded placeholder below.
58
+ const LogBlock = useUiPrimitiveOrNull(UI_PRIMITIVE_KEYS.logBlock);
56
59
  const formatTokens = useUiPrimitive(UI_PRIMITIVE_KEYS.formatTokens);
57
60
  const formatDuration = useUiPrimitive(UI_PRIMITIVE_KEYS.formatDuration);
58
61
  const Dialog = useUiPrimitive(UI_PRIMITIVE_KEYS.dialog);
@@ -219,14 +222,22 @@ export function FlowAgentCard({
219
222
  {/* Body: code nodes show a Log preview (program logs); agent nodes
220
223
  show their recent tool calls. */}
221
224
  {isCodeKind ? (
222
- <div className="mt-1 space-y-0">
223
- {logLines.slice(-3).map((line, i) => (
224
- <div key={i} className="text-[10px] text-[var(--text-tertiary)] truncate font-mono" title={line}>{line}</div>
225
- ))}
226
- {Array.from({ length: Math.max(0, 3 - Math.min(3, logLines.length)) }).map((_, i) => (
227
- <div key={`pad-${i}`} className="text-[10px]">&nbsp;</div>
228
- ))}
229
- </div>
225
+ logLines.length > 0 && LogBlock ? (
226
+ <div className="mt-1">
227
+ <LogBlock
228
+ label={t("programLog", undefined, "Program log")}
229
+ text={logLines.join("\n")}
230
+ preview
231
+ previewLines={3}
232
+ />
233
+ </div>
234
+ ) : (
235
+ <div className="mt-1 space-y-0">
236
+ {Array.from({ length: 3 }).map((_, i) => (
237
+ <div key={`pad-${i}`} className="text-[10px]">&nbsp;</div>
238
+ ))}
239
+ </div>
240
+ )
230
241
  ) : (
231
242
  <div className="mt-1 space-y-0">
232
243
  {agent.recentTools.map((tool, i) => (