@blackbelt-technology/pi-dashboard-client-utils 0.9.0 → 0.10.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 +11 -3
- package/src/ActionList.tsx +46 -19
- package/src/ActionListMenuContext.ts +19 -0
- package/src/Dialog.tsx +20 -11
- package/src/Popover.tsx +25 -23
- package/src/StatusPill.tsx +26 -58
- package/src/ZoomControls.tsx +23 -13
- package/src/identity/dpop.ts +18 -2
- package/src/minimal-chat/MinimalChatView.tsx +107 -14
- package/src/minimal-chat/index.ts +2 -0
- package/src/minimal-chat/live-tail-text.ts +27 -0
- package/src/minimal-chat/types.ts +26 -0
- package/src/tone.ts +28 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blackbelt-technology/pi-dashboard-client-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Small reusable React components, hooks, and helpers shared between the pi-dashboard shell and dashboard plugins. Per-subpath exports; no markdown stack.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -29,6 +29,10 @@
|
|
|
29
29
|
"types": "./src/LayerPortal.tsx",
|
|
30
30
|
"default": "./src/LayerPortal.tsx"
|
|
31
31
|
},
|
|
32
|
+
"./tone": {
|
|
33
|
+
"types": "./src/tone.ts",
|
|
34
|
+
"default": "./src/tone.ts"
|
|
35
|
+
},
|
|
32
36
|
"./escape-stack": {
|
|
33
37
|
"types": "./src/escape-stack.ts",
|
|
34
38
|
"default": "./src/escape-stack.ts"
|
|
@@ -109,6 +113,10 @@
|
|
|
109
113
|
"types": "./src/ActionList.tsx",
|
|
110
114
|
"default": "./src/ActionList.tsx"
|
|
111
115
|
},
|
|
116
|
+
"./ActionListMenuContext": {
|
|
117
|
+
"types": "./src/ActionListMenuContext.ts",
|
|
118
|
+
"default": "./src/ActionListMenuContext.ts"
|
|
119
|
+
},
|
|
112
120
|
"./mdi-by-key": {
|
|
113
121
|
"types": "./src/mdi-by-key.ts",
|
|
114
122
|
"default": "./src/mdi-by-key.ts"
|
|
@@ -151,8 +159,8 @@
|
|
|
151
159
|
"react-dom": ">=18.0.0"
|
|
152
160
|
},
|
|
153
161
|
"dependencies": {
|
|
154
|
-
"@blackbelt-technology/dashboard-plugin-runtime": "^0.
|
|
155
|
-
"@blackbelt-technology/pi-dashboard-shared": "^0.
|
|
162
|
+
"@blackbelt-technology/dashboard-plugin-runtime": "^0.10.0",
|
|
163
|
+
"@blackbelt-technology/pi-dashboard-shared": "^0.10.0",
|
|
156
164
|
"@mdi/js": "^7.4.47",
|
|
157
165
|
"@mdi/react": "^1.6.1"
|
|
158
166
|
},
|
package/src/ActionList.tsx
CHANGED
|
@@ -10,9 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
import { sendPluginAction } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
12
12
|
// Icon is an MDI key string, resolved lazily via useMdiIconByKey.
|
|
13
|
-
import type { UiActionListProps } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
13
|
+
import type { UiActionListItem, UiActionListProps } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
14
14
|
import Icon from "@mdi/react";
|
|
15
|
+
import { useContext } from "react";
|
|
16
|
+
import { ActionListMenuContext } from "./ActionListMenuContext.js";
|
|
15
17
|
import { useMdiIconByKey } from "./mdi-by-key.js";
|
|
18
|
+
import { toneAttr, toneIconClass, toneRowClass } from "./tone.js";
|
|
16
19
|
|
|
17
20
|
/**
|
|
18
21
|
* Extended item shape: in addition to `onClick`, items may carry a
|
|
@@ -21,36 +24,59 @@ import { useMdiIconByKey } from "./mdi-by-key.js";
|
|
|
21
24
|
* Plugins emitting intents use `dataAction`; direct React callers can
|
|
22
25
|
* still pass `onClick`.
|
|
23
26
|
*/
|
|
24
|
-
|
|
25
|
-
label: string;
|
|
26
|
-
icon?: string;
|
|
27
|
-
tooltip?: string;
|
|
28
|
-
onClick?: () => void;
|
|
29
|
-
disabled?: boolean;
|
|
27
|
+
type ExtendedActionItem = UiActionListItem & {
|
|
30
28
|
dataAction?: {
|
|
31
29
|
pluginId: string;
|
|
32
30
|
sessionId?: string | null;
|
|
33
31
|
action: string;
|
|
34
32
|
payload?: Record<string, unknown>;
|
|
35
33
|
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
function runAction(a: ExtendedActionItem): void {
|
|
37
|
+
if (a.dataAction) {
|
|
38
|
+
sendPluginAction(a.dataAction.pluginId, a.dataAction.sessionId ?? null, a.dataAction.action, a.dataAction.payload);
|
|
39
|
+
}
|
|
40
|
+
if (a.onClick) a.onClick();
|
|
36
41
|
}
|
|
37
42
|
|
|
38
43
|
export function ActionList({ actions }: UiActionListProps) {
|
|
44
|
+
const menu = useContext(ActionListMenuContext);
|
|
39
45
|
if (!actions || actions.length === 0) return null;
|
|
46
|
+
if (menu) {
|
|
47
|
+
// Menu context: vertical menuitems. Disabled items stay focusable
|
|
48
|
+
// (aria-disabled) and neither dispatch nor report activation.
|
|
49
|
+
return (
|
|
50
|
+
<div className="flex flex-col items-stretch">
|
|
51
|
+
{(actions as ExtendedActionItem[]).map((a, i) => (
|
|
52
|
+
<button
|
|
53
|
+
key={i}
|
|
54
|
+
type="button"
|
|
55
|
+
role="menuitem"
|
|
56
|
+
data-testid="action-list-item"
|
|
57
|
+
aria-disabled={a.disabled ? "true" : undefined}
|
|
58
|
+
data-action-tone={toneAttr(a.tone)}
|
|
59
|
+
title={a.tooltip}
|
|
60
|
+
onClick={() => {
|
|
61
|
+
if (a.disabled) return;
|
|
62
|
+
runAction(a);
|
|
63
|
+
menu.onActivate?.();
|
|
64
|
+
}}
|
|
65
|
+
className={`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-[var(--text-primary)] ${toneRowClass(a.tone, { disabled: !!a.disabled }) || "hover:bg-[var(--bg-tertiary)]"} aria-disabled:opacity-50 aria-disabled:cursor-not-allowed transition-colors`}
|
|
66
|
+
>
|
|
67
|
+
{a.icon ? <IconByKey iconKey={a.icon} className={toneIconClass(a.tone, { disabled: !!a.disabled })} /> : null}
|
|
68
|
+
<span>{a.label}</span>
|
|
69
|
+
</button>
|
|
70
|
+
))}
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
40
74
|
return (
|
|
41
75
|
<div className="flex flex-row flex-wrap gap-1 items-center">
|
|
42
76
|
{(actions as ExtendedActionItem[]).map((a, i) => {
|
|
43
77
|
const handleClick = () => {
|
|
44
78
|
if (a.disabled) return;
|
|
45
|
-
|
|
46
|
-
sendPluginAction(
|
|
47
|
-
a.dataAction.pluginId,
|
|
48
|
-
a.dataAction.sessionId ?? null,
|
|
49
|
-
a.dataAction.action,
|
|
50
|
-
a.dataAction.payload,
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
if (a.onClick) a.onClick();
|
|
79
|
+
runAction(a);
|
|
54
80
|
};
|
|
55
81
|
return (
|
|
56
82
|
<button
|
|
@@ -58,10 +84,11 @@ export function ActionList({ actions }: UiActionListProps) {
|
|
|
58
84
|
type="button"
|
|
59
85
|
onClick={handleClick}
|
|
60
86
|
disabled={a.disabled}
|
|
87
|
+
data-action-tone={toneAttr(a.tone)}
|
|
61
88
|
title={a.tooltip}
|
|
62
89
|
className={`inline-flex items-center gap-1 px-2 py-1 rounded text-xs border border-[var(--border-subtle)] bg-[var(--bg-secondary)] hover:bg-[var(--bg-tertiary)] text-[var(--text-primary)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors`}
|
|
63
90
|
>
|
|
64
|
-
{a.icon ? <IconByKey iconKey={a.icon} /> : null}
|
|
91
|
+
{a.icon ? <IconByKey iconKey={a.icon} className={toneIconClass(a.tone, { disabled: !!a.disabled })} /> : null}
|
|
65
92
|
<span>{a.label}</span>
|
|
66
93
|
</button>
|
|
67
94
|
);
|
|
@@ -75,8 +102,8 @@ export function ActionList({ actions }: UiActionListProps) {
|
|
|
75
102
|
* icon set loads and for unknown keys. See change:
|
|
76
103
|
* harden-ios-safari-memory-and-ws-diagnostics.
|
|
77
104
|
*/
|
|
78
|
-
function IconByKey({ iconKey }: { iconKey: string }) {
|
|
105
|
+
function IconByKey({ iconKey, className }: { iconKey: string; className?: string }) {
|
|
79
106
|
const path = useMdiIconByKey(iconKey);
|
|
80
107
|
if (!path) return null;
|
|
81
|
-
return <Icon path={path} size={0.6} />;
|
|
108
|
+
return <Icon path={path} size={0.6} {...(className ? { className } : {})} />;
|
|
82
109
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Menu context for the `ui:action-list` primitive.
|
|
3
|
+
*
|
|
4
|
+
* When a non-null value is provided, `ActionList` renders its items as a
|
|
5
|
+
* vertical list of `role="menuitem"` buttons (instead of the horizontal chip
|
|
6
|
+
* row) and calls `onActivate` after a successful (enabled) activation so the
|
|
7
|
+
* hosting menu can close itself. `null` (the default) keeps the standalone
|
|
8
|
+
* horizontal-row rendering unchanged.
|
|
9
|
+
*
|
|
10
|
+
* See change: add-session-actions-flyout.
|
|
11
|
+
*/
|
|
12
|
+
import { createContext } from "react";
|
|
13
|
+
|
|
14
|
+
export interface ActionListMenuContextValue {
|
|
15
|
+
/** Called after an enabled item was activated (handler already ran). */
|
|
16
|
+
onActivate?: () => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const ActionListMenuContext = createContext<ActionListMenuContextValue | null>(null);
|
package/src/Dialog.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mdiClose } from "@mdi/js";
|
|
2
2
|
import { Icon } from "@mdi/react";
|
|
3
|
-
import
|
|
3
|
+
import {
|
|
4
4
|
type ReactNode,
|
|
5
5
|
useCallback,
|
|
6
6
|
useId,
|
|
@@ -109,7 +109,7 @@ export function Dialog({
|
|
|
109
109
|
<DialogPortal>
|
|
110
110
|
<div className="fixed inset-0 z-dialog flex items-center justify-center">
|
|
111
111
|
<div
|
|
112
|
-
className="absolute inset-0 bg-
|
|
112
|
+
className="absolute inset-0 bg-[var(--bg-overlay)]"
|
|
113
113
|
onClick={onClose}
|
|
114
114
|
data-testid={testId ? `${testId}-overlay` : undefined}
|
|
115
115
|
/>
|
|
@@ -121,7 +121,7 @@ export function Dialog({
|
|
|
121
121
|
aria-label={!title ? ariaLabel : undefined}
|
|
122
122
|
tabIndex={-1}
|
|
123
123
|
data-testid={testId}
|
|
124
|
-
className={`relative w-full mx-4 ${SIZE_MAX_W[size]} ${SIZE_MAX_H[size]} ${flush ? "overflow-hidden flex flex-col min-h-0" : "overflow-y-auto p-5 space-y-4"} bg-[var(--bg-
|
|
124
|
+
className={`relative w-full mx-4 ${SIZE_MAX_W[size]} ${SIZE_MAX_H[size]} ${flush ? "overflow-hidden flex flex-col min-h-0" : "overflow-y-auto p-5 space-y-4"} bg-[var(--bg-secondary)] border border-[var(--border-secondary)] rounded-xl shadow-xl focus:outline-none`}
|
|
125
125
|
>
|
|
126
126
|
{/* Standard close affordance on every non-flush dialog (Escape +
|
|
127
127
|
backdrop also close). Absolutely positioned; the headered branch
|
|
@@ -133,22 +133,22 @@ export function Dialog({
|
|
|
133
133
|
onClick={onClose}
|
|
134
134
|
aria-label="Close"
|
|
135
135
|
data-testid={testId ? `${testId}-close` : undefined}
|
|
136
|
-
className="absolute top-
|
|
136
|
+
className="absolute top-2 right-2 z-10 flex items-center justify-center min-h-[44px] min-w-[44px] sm:min-h-[36px] sm:min-w-[36px] rounded text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-surface)] transition-colors"
|
|
137
137
|
>
|
|
138
138
|
<Icon path={mdiClose} size={0.8} />
|
|
139
139
|
</button>
|
|
140
140
|
)}
|
|
141
141
|
{hasHeader && (
|
|
142
|
-
<div className="flex items-center gap-3 pr-
|
|
142
|
+
<div className="flex items-center gap-3 pr-12">
|
|
143
143
|
{icon && (
|
|
144
|
-
<div className="flex-shrink-0 flex items-center justify-center w-9 h-9 rounded-md bg-[var(--
|
|
144
|
+
<div className="flex-shrink-0 flex items-center justify-center w-9 h-9 rounded-md border border-[var(--severity-info-border)] bg-[var(--severity-info-bg)] text-[var(--severity-info-fg)]">
|
|
145
145
|
<Icon path={icon} size={0.85} />
|
|
146
146
|
</div>
|
|
147
147
|
)}
|
|
148
148
|
{title && (
|
|
149
149
|
<h3
|
|
150
150
|
id={titleId}
|
|
151
|
-
className="text-
|
|
151
|
+
className="text-lg font-semibold text-[var(--text-primary)]"
|
|
152
152
|
>
|
|
153
153
|
{title}
|
|
154
154
|
</h3>
|
|
@@ -170,6 +170,11 @@ function DialogFooter({ children }: { children: ReactNode }) {
|
|
|
170
170
|
);
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
// Shared by every action and Cancel: contract target size (44 px below `sm`,
|
|
174
|
+
// 36 px from `sm`) and semibold text. See change: align-ui-contract-recipes.
|
|
175
|
+
const ACTION_BASE =
|
|
176
|
+
"inline-flex items-center justify-center text-xs font-semibold px-3 rounded transition-colors min-h-[44px] sm:min-h-[36px]";
|
|
177
|
+
|
|
173
178
|
interface DialogCancelProps {
|
|
174
179
|
onClick: () => void;
|
|
175
180
|
children?: ReactNode;
|
|
@@ -182,17 +187,21 @@ function DialogCancel({ onClick, children = "Cancel", testId }: DialogCancelProp
|
|
|
182
187
|
type="button"
|
|
183
188
|
onClick={onClick}
|
|
184
189
|
data-testid={testId}
|
|
185
|
-
className=
|
|
190
|
+
className={`${ACTION_BASE} border border-[var(--border-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]`}
|
|
186
191
|
>
|
|
187
192
|
{children}
|
|
188
193
|
</button>
|
|
189
194
|
);
|
|
190
195
|
}
|
|
191
196
|
|
|
197
|
+
// Primary fills with --accent-solid (white on it is 5.17:1 in every theme);
|
|
198
|
+
// --accent-primary under white text is only 3.68:1.
|
|
199
|
+
// See change: add-pi-spec-driven-schema.
|
|
192
200
|
const INTENT_CLASS: Record<DialogIntent, string> = {
|
|
193
201
|
primary:
|
|
194
|
-
"bg-[var(--accent-
|
|
195
|
-
danger:
|
|
202
|
+
"bg-[var(--accent-solid)] text-white hover:opacity-90 border border-transparent",
|
|
203
|
+
danger:
|
|
204
|
+
"bg-[var(--tint-red-bg)] text-[var(--tint-red-fg)] border border-[var(--tint-red-border)] hover:opacity-90",
|
|
196
205
|
neutral:
|
|
197
206
|
"bg-transparent border border-[var(--border-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]",
|
|
198
207
|
};
|
|
@@ -218,7 +227,7 @@ function DialogAction({
|
|
|
218
227
|
onClick={onClick}
|
|
219
228
|
disabled={disabled}
|
|
220
229
|
data-testid={testId}
|
|
221
|
-
className={
|
|
230
|
+
className={`${ACTION_BASE} disabled:opacity-50 disabled:cursor-not-allowed ${INTENT_CLASS[intent]}`}
|
|
222
231
|
>
|
|
223
232
|
{children}
|
|
224
233
|
</button>
|
package/src/Popover.tsx
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* The companion of `DialogPortal` for non-modal floating UI. Plugins render
|
|
5
5
|
* `<Popover anchorEl={btnRef.current} onDismiss={...}>...</Popover>` inline
|
|
6
6
|
* from their own component; the popover positions itself relative to
|
|
7
|
-
* `anchorEl`'s viewport rect, lives in a body
|
|
8
|
-
* escapes parent overflow/transform
|
|
9
|
-
* click or
|
|
7
|
+
* `anchorEl`'s viewport rect, lives in a `LayerPortal` (body, or the
|
|
8
|
+
* enclosing dialog's layer host) so it escapes parent overflow/transform
|
|
9
|
+
* contexts, paints at `var(--z-popover)`, and dismisses on outside click or
|
|
10
|
+
* Esc.
|
|
10
11
|
*
|
|
11
12
|
* NOT a modal. NOT a scroll-lock. NOT a tooltip. Strictly a click-anchored
|
|
12
13
|
* floating panel.
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
* See change: add-ui-popover-primitive.
|
|
27
28
|
*/
|
|
28
29
|
import { useEffect, useLayoutEffect, useRef, useState, type ReactNode } from "react";
|
|
29
|
-
import {
|
|
30
|
+
import { LayerPortal } from "./LayerPortal.js";
|
|
30
31
|
|
|
31
32
|
export interface PopoverProps {
|
|
32
33
|
/** DOM element the popover is anchored to. Required. */
|
|
@@ -130,24 +131,25 @@ export function Popover({ anchorEl, onDismiss, children, offset = 6 }: PopoverPr
|
|
|
130
131
|
};
|
|
131
132
|
}, [anchorEl, onDismiss]);
|
|
132
133
|
|
|
133
|
-
return
|
|
134
|
-
<
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
134
|
+
return (
|
|
135
|
+
<LayerPortal>
|
|
136
|
+
<div
|
|
137
|
+
ref={popoverRef}
|
|
138
|
+
role="dialog"
|
|
139
|
+
data-testid="ui-popover"
|
|
140
|
+
data-placement={position?.placement ?? "below"}
|
|
141
|
+
style={{
|
|
142
|
+
position: "fixed",
|
|
143
|
+
top: position?.top ?? -9999,
|
|
144
|
+
left: position?.left ?? -9999,
|
|
145
|
+
zIndex: "var(--z-popover)",
|
|
146
|
+
// Until the first layout effect runs we render off-screen so the
|
|
147
|
+
// measurement happens without flicker.
|
|
148
|
+
visibility: position ? "visible" : "hidden",
|
|
149
|
+
}}
|
|
150
|
+
>
|
|
151
|
+
{children}
|
|
152
|
+
</div>
|
|
153
|
+
</LayerPortal>
|
|
152
154
|
);
|
|
153
155
|
}
|
package/src/StatusPill.tsx
CHANGED
|
@@ -1,77 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* StatusPill primitive
|
|
2
|
+
* StatusPill primitive (`ui:status-pill`): state-tinted pill with a default icon.
|
|
3
3
|
*
|
|
4
4
|
* Registered as `ui:status-pill` in the primitive registry. Plugins emit
|
|
5
|
-
* `{primitive: "ui:status-pill", props: {state, text, icon?}}`.
|
|
5
|
+
* `{primitive: "ui:status-pill", props: {state, text, icon?, tooltip?}}`.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* Renders the runtime kit's `SettingsStatusPill`, so colours come from the
|
|
8
|
+
* `--severity-*` tokens in every theme palette (no raw colours, no theme
|
|
9
|
+
* observer). The public props and `data-status-pill` are unchanged.
|
|
10
|
+
*
|
|
11
|
+
* See change: adopt-server-driven-intent-rendering,
|
|
12
|
+
* align-ui-contract-recipes (design D2).
|
|
10
13
|
*/
|
|
11
14
|
|
|
15
|
+
import { SettingsStatusPill, type SettingsStatusTone } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
12
16
|
import type {
|
|
13
17
|
UiStatusPillProps,
|
|
14
18
|
UiStatusPillState,
|
|
15
19
|
} from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
16
|
-
import
|
|
17
|
-
import React, { useEffect, useState } from "react";
|
|
20
|
+
import { mdiLoading, mdiMinusCircleOutline } from "@mdi/js";
|
|
18
21
|
import { useMdiIconByKey } from "./mdi-by-key.js";
|
|
19
22
|
|
|
20
|
-
const
|
|
21
|
-
running:
|
|
22
|
-
success:
|
|
23
|
-
info:
|
|
24
|
-
warn:
|
|
25
|
-
error:
|
|
26
|
-
muted:
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const STATE_STYLE_LIGHT: Record<UiStatusPillState, { bg: string; fg: string }> = {
|
|
30
|
-
running: { bg: "rgba(34, 197, 94, 0.18)", fg: "rgb(21, 128, 61)" },
|
|
31
|
-
success: { bg: "rgba(34, 197, 94, 0.18)", fg: "rgb(21, 128, 61)" },
|
|
32
|
-
info: { bg: "rgba(59, 130, 246, 0.15)", fg: "rgb(29, 78, 216)" },
|
|
33
|
-
warn: { bg: "rgba(234, 179, 8, 0.20)", fg: "rgb(161, 98, 7)" },
|
|
34
|
-
error: { bg: "rgba(239, 68, 68, 0.15)", fg: "rgb(185, 28, 28)" },
|
|
35
|
-
muted: { bg: "rgba(107, 114, 128, 0.20)", fg: "rgb(55, 65, 81)" },
|
|
23
|
+
const STATE_TONE: Record<UiStatusPillState, SettingsStatusTone> = {
|
|
24
|
+
running: "info",
|
|
25
|
+
success: "success",
|
|
26
|
+
info: "info",
|
|
27
|
+
warn: "warning",
|
|
28
|
+
error: "error",
|
|
29
|
+
muted: "neutral",
|
|
36
30
|
};
|
|
37
31
|
|
|
38
|
-
function useIsLightTheme(): boolean {
|
|
39
|
-
const read = () =>
|
|
40
|
-
typeof document !== "undefined" &&
|
|
41
|
-
document.documentElement.getAttribute("data-theme") === "light";
|
|
42
|
-
const [light, setLight] = useState(read);
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
if (typeof document === "undefined") return;
|
|
45
|
-
const obs = new MutationObserver(() => setLight(read()));
|
|
46
|
-
obs.observe(document.documentElement, { attributes: true, attributeFilter: ["data-theme"] });
|
|
47
|
-
return () => obs.disconnect();
|
|
48
|
-
}, []);
|
|
49
|
-
return light;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
32
|
export function StatusPill({ state, text, icon, tooltip }: UiStatusPillProps) {
|
|
53
|
-
const
|
|
54
|
-
|
|
33
|
+
const running = state === "running";
|
|
34
|
+
// A progress state always shows the progress glyph, so it never needs the lazy set.
|
|
35
|
+
const resolved = useMdiIconByKey(running ? undefined : icon);
|
|
36
|
+
// The kit's neutral tone has no default glyph; `muted` still reads without colour.
|
|
37
|
+
const glyph = running ? mdiLoading : (resolved ?? (state === "muted" ? mdiMinusCircleOutline : undefined));
|
|
55
38
|
return (
|
|
56
|
-
<span
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
data-status-pill={state}
|
|
61
|
-
>
|
|
62
|
-
{icon ? <IconByKey iconKey={icon} /> : null}
|
|
63
|
-
<span>{text}</span>
|
|
39
|
+
<span title={tooltip} data-status-pill={state} className="inline-flex">
|
|
40
|
+
<SettingsStatusPill tone={STATE_TONE[state]} icon={glyph} spinning={running}>
|
|
41
|
+
{text}
|
|
42
|
+
</SettingsStatusPill>
|
|
64
43
|
</span>
|
|
65
44
|
);
|
|
66
45
|
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Render an MDI icon by its export-name key. Renders nothing while the full
|
|
70
|
-
* icon set loads and for unknown keys. See change:
|
|
71
|
-
* harden-ios-safari-memory-and-ws-diagnostics.
|
|
72
|
-
*/
|
|
73
|
-
function IconByKey({ iconKey }: { iconKey: string }) {
|
|
74
|
-
const path = useMdiIconByKey(iconKey);
|
|
75
|
-
if (!path) return null;
|
|
76
|
-
return <Icon path={path} size={0.55} />;
|
|
77
|
-
}
|
package/src/ZoomControls.tsx
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { mdiArrowExpandAll, mdiMagnifyMinusOutline, mdiMagnifyPlusOutline } from "@mdi/js";
|
|
2
2
|
import { Icon } from "@mdi/react";
|
|
3
3
|
import React from "react";
|
|
4
|
-
// Shared zoom controls — used by MermaidBlock and
|
|
4
|
+
// Shared zoom controls — used by MermaidBlock, DiagramPreview, FlowGraph and team-app
|
|
5
|
+
|
|
6
|
+
export interface ZoomControlLabels {
|
|
7
|
+
zoomIn: string;
|
|
8
|
+
zoomOut: string;
|
|
9
|
+
reset: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const DEFAULT_LABELS: ZoomControlLabels = { zoomIn: "Zoom in", zoomOut: "Zoom out", reset: "Reset zoom" };
|
|
5
13
|
|
|
6
14
|
export function ZoomControls({
|
|
7
15
|
onZoomIn,
|
|
@@ -9,6 +17,7 @@ export function ZoomControls({
|
|
|
9
17
|
onReset,
|
|
10
18
|
scale,
|
|
11
19
|
initialScale = 1,
|
|
20
|
+
labels = DEFAULT_LABELS,
|
|
12
21
|
}: {
|
|
13
22
|
onZoomIn: () => void;
|
|
14
23
|
onZoomOut: () => void;
|
|
@@ -16,9 +25,12 @@ export function ZoomControls({
|
|
|
16
25
|
scale: number;
|
|
17
26
|
/** Scale the surface starts/resets at; the % readout shows only when scale differs. */
|
|
18
27
|
initialScale?: number;
|
|
28
|
+
/** Accessible names + titles. client-utils has no i18n, so hosts pass translated strings. */
|
|
29
|
+
labels?: ZoomControlLabels;
|
|
19
30
|
}) {
|
|
31
|
+
// Icon-only buttons: 44 px below `sm`, 32 px from `sm` (ui-contract tap-target).
|
|
20
32
|
const btnClass =
|
|
21
|
-
"w-
|
|
33
|
+
"focus-ring min-w-[44px] min-h-[44px] sm:min-w-[32px] sm:min-h-[32px] flex items-center justify-center rounded " +
|
|
22
34
|
"bg-[var(--bg-surface)]/80 hover:bg-[var(--bg-surface)] " +
|
|
23
35
|
"border border-[var(--border-subtle)] " +
|
|
24
36
|
"text-[var(--text-secondary)] hover:text-[var(--text-primary)] " +
|
|
@@ -29,20 +41,18 @@ export function ZoomControls({
|
|
|
29
41
|
className="absolute top-2 right-2 z-10 flex flex-col gap-1"
|
|
30
42
|
onPointerDown={(e) => e.stopPropagation()}
|
|
31
43
|
>
|
|
32
|
-
<button className={btnClass} onClick={onZoomIn} title=
|
|
33
|
-
<Icon path={mdiMagnifyPlusOutline} size={0.6} />
|
|
44
|
+
<button type="button" className={btnClass} onClick={onZoomIn} title={labels.zoomIn} aria-label={labels.zoomIn}>
|
|
45
|
+
<Icon path={mdiMagnifyPlusOutline} size={0.6} aria-hidden="true" />
|
|
34
46
|
</button>
|
|
35
|
-
<button className={btnClass} onClick={onZoomOut} title=
|
|
36
|
-
<Icon path={mdiMagnifyMinusOutline} size={0.6} />
|
|
47
|
+
<button type="button" className={btnClass} onClick={onZoomOut} title={labels.zoomOut} aria-label={labels.zoomOut}>
|
|
48
|
+
<Icon path={mdiMagnifyMinusOutline} size={0.6} aria-hidden="true" />
|
|
37
49
|
</button>
|
|
38
|
-
<button className={btnClass} onClick={onReset} title=
|
|
39
|
-
<Icon path={mdiArrowExpandAll} size={0.6} />
|
|
50
|
+
<button type="button" className={btnClass} onClick={onReset} title={labels.reset} aria-label={labels.reset}>
|
|
51
|
+
<Icon path={mdiArrowExpandAll} size={0.6} aria-hidden="true" />
|
|
40
52
|
</button>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
</div>
|
|
45
|
-
)}
|
|
53
|
+
<div aria-live="polite" className="text-[11px] text-[var(--text-secondary)] text-center tabular-nums">
|
|
54
|
+
{scale !== initialScale ? `${Math.round(scale * 100)}%` : null}
|
|
55
|
+
</div>
|
|
46
56
|
</div>
|
|
47
57
|
);
|
|
48
58
|
}
|
package/src/identity/dpop.ts
CHANGED
|
@@ -26,8 +26,24 @@ function base64Url(bytes: ArrayBuffer | Uint8Array): string {
|
|
|
26
26
|
return btoa(bin).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
/**
|
|
30
|
-
|
|
29
|
+
/**
|
|
30
|
+
* True when WebCrypto's `crypto.subtle` exists. It is secure-context-only
|
|
31
|
+
* (HTTPS / localhost), so a dashboard served on a plain-http LAN origin — e.g.
|
|
32
|
+
* after a knock pairing — has no DPoP: callers must treat that as "unbound
|
|
33
|
+
* bearer client" rather than an error. See change: add-lan-knock-pairing (D17).
|
|
34
|
+
*/
|
|
35
|
+
export function isDpopAvailable(): boolean {
|
|
36
|
+
return typeof crypto !== "undefined" && !!crypto.subtle;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Generate a non-extractable ES256 keypair + export its public JWK.
|
|
41
|
+
* Resolves `null` (never throws a TypeError) when DPoP is unavailable in this
|
|
42
|
+
* context — check `isDpopAvailable()` or the result. A `DpopKey` can only exist
|
|
43
|
+
* where `crypto.subtle` does, so `createDpopProof` needs no separate guard.
|
|
44
|
+
*/
|
|
45
|
+
export async function generateDpopKey(): Promise<DpopKey | null> {
|
|
46
|
+
if (!isDpopAvailable()) return null;
|
|
31
47
|
const keyPair = await crypto.subtle.generateKey({ name: "ECDSA", namedCurve: "P-256" }, false, [
|
|
32
48
|
"sign",
|
|
33
49
|
"verify",
|
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
*
|
|
18
18
|
* See change: extract-minimal-chat-view.
|
|
19
19
|
*/
|
|
20
|
-
|
|
21
|
-
import {
|
|
20
|
+
|
|
21
|
+
import { useUiPrimitive, useUiPrimitiveOrNull } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
22
|
+
import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
22
23
|
import {
|
|
23
24
|
mdiAlertCircle,
|
|
24
25
|
mdiArrowLeft,
|
|
@@ -26,11 +27,15 @@ import {
|
|
|
26
27
|
mdiCircle,
|
|
27
28
|
mdiCircleOutline,
|
|
28
29
|
mdiCloseCircle,
|
|
30
|
+
mdiHeadLightbulb,
|
|
31
|
+
mdiPencil,
|
|
29
32
|
} from "@mdi/js";
|
|
30
|
-
import {
|
|
31
|
-
import
|
|
33
|
+
import { Icon } from "@mdi/react";
|
|
34
|
+
import React from "react";
|
|
35
|
+
import { plainTail } from "./live-tail-text.js";
|
|
32
36
|
import type {
|
|
33
37
|
MinimalChatEntry,
|
|
38
|
+
MinimalChatLiveEntry,
|
|
34
39
|
MinimalChatStatus,
|
|
35
40
|
MinimalChatViewProps,
|
|
36
41
|
} from "./types.js";
|
|
@@ -113,12 +118,7 @@ function ToolCallEntry({
|
|
|
113
118
|
entry.input && typeof entry.input === "object" && !Array.isArray(entry.input)
|
|
114
119
|
? (entry.input as Record<string, unknown>)
|
|
115
120
|
: { value: entry.input };
|
|
116
|
-
const result =
|
|
117
|
-
entry.output === undefined
|
|
118
|
-
? undefined
|
|
119
|
-
: typeof entry.output === "string"
|
|
120
|
-
? entry.output
|
|
121
|
-
: JSON.stringify(entry.output, null, 2);
|
|
121
|
+
const result = formatToolOutput(entry.output);
|
|
122
122
|
if (ToolCallStepImpl) {
|
|
123
123
|
const toolCallId = `minimal-${index}`;
|
|
124
124
|
const status = entry.isError ? "error" : entry.output !== undefined ? "complete" : "running";
|
|
@@ -197,14 +197,14 @@ function TextEntry({ text }: { text: string }) {
|
|
|
197
197
|
);
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
function ThinkingEntry({ text }: { text: string }) {
|
|
200
|
+
function ThinkingEntry({ text, defaultExpanded }: { text: string; defaultExpanded?: boolean }) {
|
|
201
201
|
// Prefer the shell-registered `thinkingBlock` primitive for parity with
|
|
202
202
|
// the main chat view. Falls back to a simple inline rendition when the
|
|
203
203
|
// primitive is not registered.
|
|
204
204
|
// See change: fix-flows-plugin-polish (chat-view parity).
|
|
205
205
|
const ThinkingBlockImpl = useUiPrimitiveOrNull(UI_PRIMITIVE_KEYS.thinkingBlock);
|
|
206
206
|
if (ThinkingBlockImpl) {
|
|
207
|
-
return <ThinkingBlockImpl content={text} />;
|
|
207
|
+
return <ThinkingBlockImpl content={text} defaultExpanded={defaultExpanded} />;
|
|
208
208
|
}
|
|
209
209
|
return <FallbackThinkingEntry text={text} />;
|
|
210
210
|
}
|
|
@@ -229,6 +229,80 @@ function FallbackThinkingEntry({ text }: { text: string }) {
|
|
|
229
229
|
);
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
+
/**
|
|
233
|
+
* In-progress block (streaming tail), mock `mockups/live-tail.html`:
|
|
234
|
+
* main-chat ThinkingBlock header (icon, label, pulsing dots) over a tinted
|
|
235
|
+
* box at READING size (13px), line breaks kept, newest line at the bottom,
|
|
236
|
+
* oldest fading out at the top (mask, not a leading "…"), pulse caret.
|
|
237
|
+
* Thinking = purple rail/tint; writing = neutral, markdown markers stripped
|
|
238
|
+
* (the tail is a partial block). See change: stream-subagent-reasoning-and-stable-card.
|
|
239
|
+
*/
|
|
240
|
+
function LiveEntry({ entry }: { entry: MinimalChatLiveEntry }) {
|
|
241
|
+
const isThinking = entry.kind === "thinking";
|
|
242
|
+
const body = isThinking ? entry.text : plainTail(entry.text);
|
|
243
|
+
return (
|
|
244
|
+
<div
|
|
245
|
+
data-testid="minimal-live-entry"
|
|
246
|
+
data-kind={entry.kind}
|
|
247
|
+
className={`border-l-2 pl-3 py-1 ${isThinking ? "border-purple-500/30" : "border-[var(--text-muted)]"}`}
|
|
248
|
+
>
|
|
249
|
+
<div className="flex items-center gap-1.5 text-xs text-[var(--text-tertiary)]">
|
|
250
|
+
<span className={`inline-flex ${isThinking ? "text-purple-400" : ""}`}>
|
|
251
|
+
<Icon path={isThinking ? mdiHeadLightbulb : mdiPencil} size={0.55} />
|
|
252
|
+
</span>
|
|
253
|
+
<span>
|
|
254
|
+
{isThinking ? "Reasoning" : "Writing"}
|
|
255
|
+
<span className="ml-1 motion-safe:animate-pulse">…</span>
|
|
256
|
+
<span className="sr-only"> in progress</span>
|
|
257
|
+
</span>
|
|
258
|
+
</div>
|
|
259
|
+
<div
|
|
260
|
+
className={`mt-1 ml-4 rounded-xl border shadow-md ${
|
|
261
|
+
isThinking ? "bg-purple-500/5 border-purple-500/10" : "bg-[var(--bg-tertiary)] border-[var(--border-subtle)]"
|
|
262
|
+
}`}
|
|
263
|
+
>
|
|
264
|
+
<div
|
|
265
|
+
className={
|
|
266
|
+
entry.growing
|
|
267
|
+
? "px-3 py-2"
|
|
268
|
+
: "max-h-36 overflow-hidden flex flex-col justify-end px-3 py-2 [mask-image:linear-gradient(to_bottom,transparent_0,#000_22%)]"
|
|
269
|
+
}
|
|
270
|
+
>
|
|
271
|
+
<div className="text-[13px] leading-5 text-[var(--text-secondary)] whitespace-pre-line break-words">
|
|
272
|
+
{body}
|
|
273
|
+
<span
|
|
274
|
+
className={`inline-block w-0.5 h-[0.95em] align-[-0.12em] ml-0.5 motion-safe:animate-pulse ${
|
|
275
|
+
isThinking ? "bg-purple-400/70" : "bg-[var(--text-tertiary)]"
|
|
276
|
+
}`}
|
|
277
|
+
/>
|
|
278
|
+
</div>
|
|
279
|
+
</div>
|
|
280
|
+
</div>
|
|
281
|
+
</div>
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Tool output as text: a string as-is; a `{ content: [{ type: "text", text }] }`
|
|
287
|
+
* result envelope as its texts joined by newlines; anything else as JSON.
|
|
288
|
+
* See change: add-plugin-bridge-contributions (D11).
|
|
289
|
+
*/
|
|
290
|
+
export function formatToolOutput(output: unknown): string | undefined {
|
|
291
|
+
if (output === undefined) return undefined;
|
|
292
|
+
if (typeof output === "string") return output;
|
|
293
|
+
if (output && typeof output === "object" && !Array.isArray(output)) {
|
|
294
|
+
const content = (output as { content?: unknown }).content;
|
|
295
|
+
if (Array.isArray(content) && content.length > 0) {
|
|
296
|
+
const texts = content.filter(
|
|
297
|
+
(b): b is { type: "text"; text: string } =>
|
|
298
|
+
!!b && typeof b === "object" && (b as { type?: unknown }).type === "text" && typeof (b as { text?: unknown }).text === "string",
|
|
299
|
+
);
|
|
300
|
+
if (texts.length === content.length) return texts.map((b) => b.text).join("\n");
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return JSON.stringify(output, null, 2);
|
|
304
|
+
}
|
|
305
|
+
|
|
232
306
|
function ErrorEntry({ text }: { text: string }) {
|
|
233
307
|
return <div className="py-1.5 pl-3 text-sm text-red-400">{text}</div>;
|
|
234
308
|
}
|
|
@@ -248,6 +322,8 @@ export function MinimalChatView({
|
|
|
248
322
|
footer,
|
|
249
323
|
activity,
|
|
250
324
|
sessionId,
|
|
325
|
+
liveEntry,
|
|
326
|
+
expandLastThinking,
|
|
251
327
|
}: MinimalChatViewProps) {
|
|
252
328
|
// Soft-read formatters — fall back to identity formatting when the
|
|
253
329
|
// primitive registry is partially populated (matches the spec’s
|
|
@@ -345,6 +421,16 @@ export function MinimalChatView({
|
|
|
345
421
|
? "flex flex-col h-full overflow-hidden"
|
|
346
422
|
: "flex flex-col h-[60vh] overflow-hidden";
|
|
347
423
|
|
|
424
|
+
// Newest reasoning entry opens on mount while the producer is live, so a
|
|
425
|
+
// just-finished block stays readable (main-chat parity). Mount-time only.
|
|
426
|
+
let lastThinkingIdx = -1;
|
|
427
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
428
|
+
if (entries[i].kind === "thinking") {
|
|
429
|
+
lastThinkingIdx = i;
|
|
430
|
+
break;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
348
434
|
const defaultEmpty = "No activity yet";
|
|
349
435
|
const empty = emptyMessage ?? defaultEmpty;
|
|
350
436
|
|
|
@@ -357,7 +443,7 @@ export function MinimalChatView({
|
|
|
357
443
|
// See change: fix-flows-plugin-polish (scrollbar fix).
|
|
358
444
|
const body = (
|
|
359
445
|
<div className="flex-1 min-h-0 overflow-y-auto px-3 py-2 space-y-0.5">
|
|
360
|
-
{entries.length === 0 ? (
|
|
446
|
+
{entries.length === 0 && !liveEntry ? (
|
|
361
447
|
<div className="text-sm text-[var(--text-muted)] py-4 text-center">{empty}</div>
|
|
362
448
|
) : (
|
|
363
449
|
entries.map((entry, i) => {
|
|
@@ -367,7 +453,13 @@ export function MinimalChatView({
|
|
|
367
453
|
case "text":
|
|
368
454
|
return <TextEntry key={i} text={entry.text} />;
|
|
369
455
|
case "thinking":
|
|
370
|
-
return
|
|
456
|
+
return (
|
|
457
|
+
<ThinkingEntry
|
|
458
|
+
key={i}
|
|
459
|
+
text={entry.text}
|
|
460
|
+
defaultExpanded={expandLastThinking && i === lastThinkingIdx}
|
|
461
|
+
/>
|
|
462
|
+
);
|
|
371
463
|
case "error":
|
|
372
464
|
return <ErrorEntry key={i} text={entry.text} />;
|
|
373
465
|
default:
|
|
@@ -376,6 +468,7 @@ export function MinimalChatView({
|
|
|
376
468
|
})
|
|
377
469
|
)}
|
|
378
470
|
{footer}
|
|
471
|
+
{liveEntry && <LiveEntry entry={liveEntry} />}
|
|
379
472
|
</div>
|
|
380
473
|
);
|
|
381
474
|
|
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
* See change: extract-minimal-chat-view.
|
|
8
8
|
*/
|
|
9
9
|
export { MinimalChatView, statusVisualsFor, extractInputPreview } from "./MinimalChatView.js";
|
|
10
|
+
export { currentSentence, plainTail } from "./live-tail-text.js";
|
|
10
11
|
export type {
|
|
11
12
|
MinimalChatEntry,
|
|
13
|
+
MinimalChatLiveEntry,
|
|
12
14
|
MinimalChatMeta,
|
|
13
15
|
MinimalChatMode,
|
|
14
16
|
MinimalChatStatus,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text helpers for a subagent's streaming tail (a bounded SUFFIX of a block
|
|
3
|
+
* that is still being written). Partial markdown renders badly, so previews
|
|
4
|
+
* strip simple markers while keeping line breaks.
|
|
5
|
+
*
|
|
6
|
+
* See change: stream-subagent-reasoning-and-stable-card.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** Strip heading/bullet/code/bold markers; keep line breaks. */
|
|
10
|
+
export function plainTail(text: string): string {
|
|
11
|
+
return text
|
|
12
|
+
.replace(/^#{1,6}\s+/gm, "")
|
|
13
|
+
.replace(/^(\s*)[-*]\s+/gm, "$1• ")
|
|
14
|
+
.replace(/`/g, "")
|
|
15
|
+
.replace(/\*\*/g, "");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The sentence currently being written, flattened to one line (card ticker).
|
|
20
|
+
* When the last sentence just ended, returns that sentence.
|
|
21
|
+
*/
|
|
22
|
+
export function currentSentence(text: string): string {
|
|
23
|
+
const flat = plainTail(text).replace(/\s+/g, " ").trim();
|
|
24
|
+
if (!flat) return "";
|
|
25
|
+
const parts = flat.split(/(?<=[.!?:])\s+/);
|
|
26
|
+
return parts[parts.length - 1] ?? flat;
|
|
27
|
+
}
|
|
@@ -99,4 +99,30 @@ export interface MinimalChatViewProps {
|
|
|
99
99
|
* See change: improve-flow-ui.
|
|
100
100
|
*/
|
|
101
101
|
hideToolStatusIcon?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Optional in-progress block (e.g. a running subagent's streaming thinking
|
|
104
|
+
* or text tail). Rendered after `entries` with an "in progress" affordance;
|
|
105
|
+
* counts as body content, so the empty state is suppressed while present.
|
|
106
|
+
*
|
|
107
|
+
* See change: stream-subagent-reasoning-and-stable-card.
|
|
108
|
+
*/
|
|
109
|
+
liveEntry?: MinimalChatLiveEntry;
|
|
110
|
+
/**
|
|
111
|
+
* When true, the newest `thinking` entry mounts expanded (running agents:
|
|
112
|
+
* a just-finished block stays readable). See change:
|
|
113
|
+
* stream-subagent-reasoning-and-stable-card.
|
|
114
|
+
*/
|
|
115
|
+
expandLastThinking?: boolean;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** In-progress thinking/text block rendered after the finished entries. */
|
|
119
|
+
export interface MinimalChatLiveEntry {
|
|
120
|
+
kind: "thinking" | "text";
|
|
121
|
+
text: string;
|
|
122
|
+
/**
|
|
123
|
+
* The FULL block so far (delta stream), rendered growing like the main
|
|
124
|
+
* chat's live block. Absent = a bounded tail, rendered as the fading window.
|
|
125
|
+
* See change: add-plugin-bridge-contributions (D8).
|
|
126
|
+
*/
|
|
127
|
+
growing?: boolean;
|
|
102
128
|
}
|
package/src/tone.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tone → class helpers. Total and prototype-safe: any non-UiTone value yields
|
|
3
|
+
* "" / undefined. Maps hold complete literals (Tailwind scans them); a tone is
|
|
4
|
+
* never interpolated. See change: colorize-actions-menus.
|
|
5
|
+
*/
|
|
6
|
+
import { isUiTone, type UiTone } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
7
|
+
|
|
8
|
+
const ICON: Record<UiTone, string> = {
|
|
9
|
+
go: "text-[var(--accent-green-text)]",
|
|
10
|
+
create: "text-[var(--accent-blue-text)]",
|
|
11
|
+
caution: "text-[var(--accent-orange-text)]",
|
|
12
|
+
danger: "text-[var(--accent-red-text)]",
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const DANGER_ROW =
|
|
16
|
+
"hover:bg-[var(--tint-red-bg)] focus:bg-[var(--tint-red-bg)] hover:text-[var(--accent-red-text)] focus:text-[var(--accent-red-text)]";
|
|
17
|
+
|
|
18
|
+
export function toneIconClass(tone: unknown, opts: { disabled: boolean }): string {
|
|
19
|
+
return isUiTone(tone) && !opts.disabled ? ICON[tone] : "";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function toneRowClass(tone: unknown, opts: { disabled: boolean }): string {
|
|
23
|
+
return tone === "danger" && !opts.disabled ? DANGER_ROW : "";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function toneAttr(tone: unknown): UiTone | undefined {
|
|
27
|
+
return isUiTone(tone) ? tone : undefined;
|
|
28
|
+
}
|