@dbx-tools/ui-mastra 0.9.185 → 0.9.188

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/README.md CHANGED
@@ -226,6 +226,13 @@ supervisor agent:
226
226
  <MastraChat genieSpace="sales" threadPlacement="auto" enableExport />
227
227
  ```
228
228
 
229
+ Set `genieVisualization="image"` to show Genie's original rendered PNG in the
230
+ Chart tab while keeping the linked query result in the Table tab:
231
+
232
+ ```tsx
233
+ <MastraChat genieSpace="sales" genieVisualization="image" />
234
+ ```
235
+
229
236
  The alias comes from the server plugin's `genieSpaces`. The client still uses
230
237
  AI SDK `UIMessage` streams and the same `ChatView`. Genie conversations replace
231
238
  Mastra threads and Genie messages remain the visible history. When Mastra
@@ -236,8 +243,9 @@ Turns and history require the Genie Agent API and never fall back to classic
236
243
  Genie message polling. The sidebar filters the Genie conversation listing to
237
244
  Agent Mode conversations. Genie decides whether a query should be visualized.
238
245
  Visualization attachments render through AppKit UI's native
239
- `GenieQueryVisualization`, with Chart and Table tabs. This does not invoke a
240
- supervisor or the Mastra Model Serving chart planner. Queries without a
246
+ `GenieQueryVisualization`, with Chart and Table tabs, unless image mode is
247
+ selected. This does not invoke a supervisor or the Mastra Model Serving chart
248
+ planner. Queries without a
241
249
  visualization attachment render through the existing sortable data table.
242
250
 
243
251
  Direct mode requires the signed-in user's Databricks OBO context. It supports
package/index.support.ts CHANGED
@@ -5,7 +5,6 @@
5
5
  export * as activeRuns from "./src/support/active-runs.ts";
6
6
  export * as chartOption from "./src/support/chart-option.ts";
7
7
  export * as chartTheme from "./src/support/chart-theme.ts";
8
- export * as clipboard from "./src/support/clipboard.ts";
9
8
  export * as download from "./src/support/download.ts";
10
9
  export * as exportModule from "./src/support/export.ts";
11
10
  export * as genieClient from "./src/support/genie-client.ts";
@@ -22,7 +21,6 @@ export type { StoredActiveRun } from "./src/support/active-runs.ts";
22
21
  export { normalizeChartOption } from "./src/support/chart-option.ts";
23
22
  export { LIGHT_CHART_CHROME, resolveChartChrome, useChartChrome } from "./src/support/chart-theme.ts";
24
23
  export type { ChartChrome } from "./src/support/chart-theme.ts";
25
- export { copyText } from "./src/support/clipboard.ts";
26
24
  export { downloadFile } from "./src/support/download.ts";
27
25
  export { exportChat, messageText } from "./src/support/export.ts";
28
26
  export type { ExportFormat, ExportBrand, EmbedResolver, ExportChatOptions } from "./src/support/export.ts";
package/index.ts CHANGED
@@ -3,4 +3,4 @@
3
3
  // Hand edits are overwritten on the next watch; this file is read-only.
4
4
 
5
5
  export const PACKAGE_IDENTIFIER = "@dbx-tools/ui-mastra";
6
- export const PACKAGE_VERSION = "0.9.185";
6
+ export const PACKAGE_VERSION = "0.9.188";
package/package.json CHANGED
@@ -32,12 +32,12 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@databricks/appkit-ui": "0.81.0",
35
- "@dbx-tools/shared-auth": "^0.9.185",
36
- "@dbx-tools/shared-core": "^0.9.185",
37
- "@dbx-tools/shared-genie": "^0.9.185",
38
- "@dbx-tools/shared-mastra": "^0.9.185",
39
- "@dbx-tools/shared-model": "^0.9.185",
40
- "@dbx-tools/ui": "^0.9.185",
35
+ "@dbx-tools/shared-auth": "^0.9.188",
36
+ "@dbx-tools/shared-core": "^0.9.188",
37
+ "@dbx-tools/shared-genie": "^0.9.188",
38
+ "@dbx-tools/shared-mastra": "^0.9.188",
39
+ "@dbx-tools/shared-model": "^0.9.188",
40
+ "@dbx-tools/ui": "^0.9.188",
41
41
  "@mastra/client-js": "1.50.0",
42
42
  "@mastra/core": "1.71.0",
43
43
  "@tanstack/react-table": "^8.21.3",
@@ -55,7 +55,7 @@
55
55
  "publishConfig": {
56
56
  "access": "public"
57
57
  },
58
- "version": "0.9.185",
58
+ "version": "0.9.188",
59
59
  "types": "index.ts",
60
60
  "dbxToolsConfig": {
61
61
  "tags": [
@@ -9,10 +9,10 @@ import {
9
9
  AlertDialogTitle,
10
10
  Button,
11
11
  } from "@databricks/appkit-ui/react";
12
+ import { copyText } from "@dbx-tools/ui/react";
12
13
  import { CheckIcon, CopyIcon, ExternalLinkIcon } from "lucide-react";
13
14
  import { useEffect, useMemo, useRef, useState } from "react";
14
15
  import type { LinkSafetyModalProps } from "streamdown";
15
- import { copyText } from "../support/clipboard.ts";
16
16
 
17
17
  /** Display and clipboard values for one confirmed chat link. */
18
18
  export interface LinkPresentation {
@@ -0,0 +1,82 @@
1
+ import { Spinner, Tabs, TabsContent, TabsList, TabsTrigger } from "@databricks/appkit-ui/react";
2
+ import type { GenieVisualizationEmbed, StatementData } from "@dbx-tools/shared-mastra";
3
+ import { useEffect, useState } from "react";
4
+ import { DataGrid } from "./data-grid.tsx";
5
+ import { useMastraClient, useVisualizationFetch } from "../support/mastra-client.ts";
6
+
7
+ const GENIE_IMAGE_LOADING_HEIGHT_PX = 320;
8
+
9
+ const GenieImageLoading = () => (
10
+ <div
11
+ className="flex items-center justify-center rounded border border-border bg-card"
12
+ style={{ height: GENIE_IMAGE_LOADING_HEIGHT_PX, width: "100%" }}
13
+ >
14
+ <Spinner className="size-5 text-muted-foreground" />
15
+ <span className="sr-only">Loading Genie chart</span>
16
+ </div>
17
+ );
18
+
19
+ /** Chart/Table presentation for Genie's original, unmodified PNG. */
20
+ export function GenieImageTabs({
21
+ src,
22
+ data,
23
+ tableLoading = false,
24
+ }: {
25
+ src: string;
26
+ data?: StatementData;
27
+ tableLoading?: boolean;
28
+ }) {
29
+ const [imageState, setImageState] = useState<"loading" | "loaded" | "error">("loading");
30
+ useEffect(() => {
31
+ setImageState("loading");
32
+ }, [src]);
33
+ return (
34
+ <Tabs defaultValue="chart" className="not-prose my-3 min-w-0 max-w-full">
35
+ <TabsList>
36
+ <TabsTrigger value="chart">Chart</TabsTrigger>
37
+ <TabsTrigger value="table">Table</TabsTrigger>
38
+ </TabsList>
39
+ <TabsContent value="chart">
40
+ {imageState === "error" ? (
41
+ <p role="status" className="py-3 text-sm text-muted-foreground">
42
+ Genie chart unavailable. Open Table to view the query result.
43
+ </p>
44
+ ) : (
45
+ <>
46
+ {imageState === "loading" ? <GenieImageLoading /> : null}
47
+ <img
48
+ src={src}
49
+ alt="Genie query visualization"
50
+ className="block h-auto max-w-full rounded border border-border"
51
+ style={imageState === "loaded" ? undefined : { display: "none" }}
52
+ onLoad={() => setImageState("loaded")}
53
+ onError={() => setImageState("error")}
54
+ />
55
+ </>
56
+ )}
57
+ </TabsContent>
58
+ <TabsContent value="table" forceMount className="data-[state=inactive]:hidden">
59
+ {data ? (
60
+ <DataGrid
61
+ columns={data.columns}
62
+ rows={data.rows}
63
+ rowCount={data.rowCount}
64
+ truncated={data.truncated}
65
+ />
66
+ ) : (
67
+ <p role="status" className="py-3 text-sm text-muted-foreground">
68
+ {tableLoading ? "Loading query result…" : "Query result unavailable."}
69
+ </p>
70
+ )}
71
+ </TabsContent>
72
+ </Tabs>
73
+ );
74
+ }
75
+
76
+ /** Resolve a durable image reference through the caller's authenticated app routes. */
77
+ export function GenieImageSlot({ reference }: { reference: GenieVisualizationEmbed }) {
78
+ const client = useMastraClient();
79
+ const { data, loading } = useVisualizationFetch(reference.statementId);
80
+ const src = client.genieVisualizationImageUrl(reference);
81
+ return <GenieImageTabs key={src} src={src} data={data} tableLoading={loading} />;
82
+ }
@@ -13,7 +13,7 @@ import {
13
13
  TooltipTrigger,
14
14
  cn,
15
15
  } from "@databricks/appkit-ui/react";
16
- import { RecordPreview } from "@dbx-tools/ui/react";
16
+ import { RecordPreview, copyText } from "@dbx-tools/ui/react";
17
17
  import type { UIMessage } from "ai";
18
18
  import {
19
19
  BugIcon,
@@ -45,7 +45,6 @@ import {
45
45
  type PendingApproval,
46
46
  type ToolEvent,
47
47
  } from "./types.ts";
48
- import { copyText } from "../support/clipboard.ts";
49
48
  import type { ExportFormat } from "../support/export.ts";
50
49
  import { mergeToolEvents, toolEventsFromParts } from "../support/tool-events.ts";
51
50
 
@@ -451,6 +451,11 @@ export const ChatComposer = ({
451
451
  ref={textareaRef}
452
452
  value={input}
453
453
  onChange={(event) => setInput(event.target.value)}
454
+ onMouseDown={(event) => {
455
+ if (event.button !== 0 || document.activeElement === event.currentTarget) return;
456
+ event.currentTarget.focus({ preventScroll: true });
457
+ event.preventDefault();
458
+ }}
454
459
  onPaste={(event) => {
455
460
  if (!allowAttachments) return;
456
461
  const pastedImages = Array.from(event.clipboardData.files).filter((file) =>
@@ -22,8 +22,6 @@ import { isActiveChatStatus, type ChatViewProps, type ToolEvent } from "./types.
22
22
  import { messageText } from "../support/export.ts";
23
23
 
24
24
  const BOTTOM_THRESHOLD_PX = 24;
25
- const FOCUS_RESIZE_BOTTOM_THRESHOLD_PX = 2;
26
- const FOCUS_RESIZE_SETTLE_MS = 650;
27
25
  const TOP_LOAD_MORE_THRESHOLD_PX = 120;
28
26
 
29
27
  /** Gestures that indicate the user is intentionally navigating transcript history. */
@@ -117,81 +115,28 @@ export const useChatTranscriptController = ({
117
115
  element.scrollTop = element.scrollHeight;
118
116
  });
119
117
  observer.observe(content);
118
+ observer.observe(element);
120
119
  return () => observer.disconnect();
121
120
  }, [messages.length, isLoadingHistory]);
122
121
 
123
122
  useLayoutEffect(() => {
124
123
  const element = scrollRef.current;
125
- const frame = element?.closest<HTMLElement>('[data-slot="aui_thread-frame"]');
126
- if (!element || !frame || typeof ResizeObserver === "undefined") return;
127
-
128
- let focusResizeActive = false;
129
- let focusPinnedToBottom = false;
130
- let focusScrollTop = 0;
131
- let focusResizeTimer = 0;
124
+ if (!element) return;
132
125
 
133
- const finishFocusResize = () => {
134
- focusResizeActive = false;
135
- focusPinnedToBottom = false;
136
- window.clearTimeout(focusResizeTimer);
137
- };
138
- const scheduleFocusResizeFinish = () => {
139
- window.clearTimeout(focusResizeTimer);
140
- focusResizeTimer = window.setTimeout(finishFocusResize, FOCUS_RESIZE_SETTLE_MS);
141
- };
142
- const restoreFocusPosition = () => {
143
- if (!focusResizeActive) return;
144
- programmaticScrollRef.current = true;
145
- if (focusPinnedToBottom) {
146
- element.scrollTop = element.scrollHeight;
147
- setIsAtBottom(true);
148
- } else {
149
- element.scrollTop = focusScrollTop;
150
- }
151
- };
152
- const beginFocusResize = () => {
153
- const distanceFromBottom = element.scrollHeight - element.scrollTop - element.clientHeight;
154
- focusPinnedToBottom = distanceFromBottom <= FOCUS_RESIZE_BOTTOM_THRESHOLD_PX;
155
- focusScrollTop = element.scrollTop;
156
- pinnedRef.current = focusPinnedToBottom;
157
- focusResizeActive = true;
158
- restoreFocusPosition();
159
- scheduleFocusResizeFinish();
160
- };
161
- const handleFocusStart = (event: Event) => {
162
- const target = event.target instanceof Element ? event.target : null;
163
- if (!target?.closest(".aui-composer-input")) return;
164
- beginFocusResize();
165
- };
166
126
  const handleReaderGesture = () => {
167
- finishFocusResize();
168
127
  // A wheel/touch gesture at the bottom may not move the viewport. Let the
169
128
  // ensuing scroll event decide whether follow mode should stop so inert
170
129
  // or downward gestures cannot detach desktop chat from new content.
171
130
  programmaticScrollRef.current = false;
172
131
  };
173
- const observer = new ResizeObserver(() => {
174
- restoreFocusPosition();
175
- if (focusResizeActive) scheduleFocusResizeFinish();
176
- });
177
-
178
- frame.addEventListener("touchstart", handleFocusStart, { passive: true, capture: true });
179
- frame.addEventListener("focusin", handleFocusStart);
180
- frame.addEventListener("focusout", finishFocusResize);
181
132
  for (const eventName of TRANSCRIPT_FOLLOW_CANCEL_EVENTS) {
182
133
  element.addEventListener(eventName, handleReaderGesture, { passive: true });
183
134
  }
184
- observer.observe(element);
185
135
 
186
136
  return () => {
187
- finishFocusResize();
188
- frame.removeEventListener("touchstart", handleFocusStart, true);
189
- frame.removeEventListener("focusin", handleFocusStart);
190
- frame.removeEventListener("focusout", finishFocusResize);
191
137
  for (const eventName of TRANSCRIPT_FOLLOW_CANCEL_EVENTS) {
192
138
  element.removeEventListener(eventName, handleReaderGesture);
193
139
  }
194
- observer.disconnect();
195
140
  };
196
141
  }, []);
197
142
 
@@ -4,9 +4,13 @@ import {
4
4
  isUuid,
5
5
  parseMarkers,
6
6
  stripIncompleteMarkerTail,
7
+ type GenieVisualizationEmbed,
8
+ GENIE_VISUALIZATION_MARKER,
9
+ parseGenieVisualizationEmbed,
7
10
  } from "@dbx-tools/shared-mastra";
8
11
  import { ClockIcon } from "lucide-react";
9
12
  import { lazy, Suspense, useMemo, useRef } from "react";
13
+ import { GenieImageSlot } from "./_genie-image.tsx";
10
14
  import { DataGrid, humanizeLabel } from "./data-grid.tsx";
11
15
  import { AssistantMarkdown } from "./markdown.tsx";
12
16
  import { normalizeChartOption } from "../support/chart-option.ts";
@@ -199,6 +203,7 @@ type RenderSegment =
199
203
  | { kind: "text"; text: string }
200
204
  | { kind: "chart"; chartId: string }
201
205
  | { kind: "data"; statementId: string }
206
+ | { kind: "genie-image"; reference: GenieVisualizationEmbed }
202
207
  | { kind: "visualization"; statementId: string };
203
208
 
204
209
  /**
@@ -213,6 +218,10 @@ type RenderSegment =
213
218
  * known, renderable type resolves to a slot.
214
219
  */
215
220
  const markerSegment = (marker: ParsedMarker): RenderSegment => {
221
+ if (marker.type === GENIE_VISUALIZATION_MARKER) {
222
+ const reference = parseGenieVisualizationEmbed(marker.id);
223
+ return reference ? { kind: "genie-image", reference } : { kind: "text", text: "" };
224
+ }
216
225
  if (!isUuid(marker.id)) return { kind: "text", text: "" };
217
226
  switch (marker.type) {
218
227
  case "chart":
@@ -292,6 +301,9 @@ export const MarkdownWithEmbeds = ({
292
301
  if (seg.kind === "chart") {
293
302
  return <ChartSlot key={`c-${i}-${seg.chartId}`} chartId={seg.chartId} />;
294
303
  }
304
+ if (seg.kind === "genie-image") {
305
+ return <GenieImageSlot key={`g-${i}`} reference={seg.reference} />;
306
+ }
295
307
  if (seg.kind === "visualization") {
296
308
  return (
297
309
  <GenieVisualizationSlot
@@ -13,13 +13,17 @@ import {
13
13
  TooltipTrigger,
14
14
  cn,
15
15
  } from "@databricks/appkit-ui/react";
16
- import { createShikiPlugin, highlightToHtml, useHighlightedHtml } from "@dbx-tools/ui/react";
16
+ import {
17
+ copyText,
18
+ createShikiPlugin,
19
+ highlightToHtml,
20
+ useHighlightedHtml,
21
+ } from "@dbx-tools/ui/react";
17
22
  import { CheckIcon, CopyIcon } from "lucide-react";
18
23
  import React, { useEffect, useRef, useState } from "react";
19
24
  import { Streamdown, type LinkSafetyConfig } from "streamdown";
20
25
  import { ExternalLinkDialog, isSameOriginLink } from "./_external-link-dialog.tsx";
21
26
  import { DataGrid, TABLE_WRAPPER_CLASSES, colorizeDelta, type DataRow } from "./data-grid.tsx";
22
- import { copyText } from "../support/clipboard.ts";
23
27
 
24
28
  // Markdown rendering for the chat: the streaming `Streamdown` engine
25
29
  // wired with shiki highlighting and AppKit table primitives, plus the
@@ -1,6 +1,6 @@
1
1
  import { getAuthStatus } from "@dbx-tools/shared-auth";
2
2
  import { hash, log, toError } from "@dbx-tools/shared-core";
3
- import { isStaleMastraResumeError } from "@dbx-tools/shared-mastra";
3
+ import { isStaleMastraResumeError, type GenieVisualizationMode } from "@dbx-tools/shared-mastra";
4
4
  import type { ReasoningEffort } from "@dbx-tools/shared-model";
5
5
  import { useBrand } from "@dbx-tools/ui/branding/react";
6
6
  import type { RequestContext } from "@mastra/client-js";
@@ -176,6 +176,12 @@ export interface UseMastraChatOptions<
176
176
  * cannot be renamed, turns take no attachments, and feedback is unavailable.
177
177
  */
178
178
  genieSpace?: string;
179
+ /**
180
+ * Direct Genie visualization renderer. `"appkit"` keeps the current local
181
+ * Chart/Table rendering; `"image"` displays the PNG produced by Genie while
182
+ * retaining the backing Table tab.
183
+ */
184
+ genieVisualization?: GenieVisualizationMode;
179
185
  /**
180
186
  * Surface the built-in model picker in the header, letting the user
181
187
  * override the serving endpoint per turn (via `X-Mastra-Model`).
@@ -271,10 +277,12 @@ export const useMastraChat = <TValues extends Record<string, unknown> = Record<s
271
277
  const pluginClient = useMastraClient();
272
278
  const mastraConfig = useMastraConfig();
273
279
  const genieSpace = options.genieSpace?.trim() || undefined;
280
+ const genieVisualization = options.genieVisualization;
274
281
  const genieClient = useMemo(
275
- () => (genieSpace ? new GenieChatClient(mastraConfig, genieSpace) : undefined),
282
+ () =>
283
+ genieSpace ? new GenieChatClient(mastraConfig, genieSpace, genieVisualization) : undefined,
276
284
  // Same scalars `useMastraClient` keys on; `mastraConfig` identity churns.
277
- [genieSpace, mastraConfig.basePath, mastraConfig.defaultAgent],
285
+ [genieSpace, genieVisualization, mastraConfig.basePath, mastraConfig.defaultAgent],
278
286
  );
279
287
  const mastraClient = genieClient ?? pluginClient;
280
288
  // Genie chats key persisted state (active thread, sidebar) by space alias.
@@ -24,7 +24,14 @@
24
24
  */
25
25
 
26
26
  import { capitalize, toLabel, toSlugWithOptions, escapeHtml } from "@dbx-tools/shared-core";
27
- import { type Chart, type StatementData, parseMarkers, isUuid } from "@dbx-tools/shared-mastra";
27
+ import {
28
+ type Chart,
29
+ type StatementData,
30
+ parseMarkers,
31
+ isUuid,
32
+ GENIE_VISUALIZATION_MARKER,
33
+ parseGenieVisualizationEmbed,
34
+ } from "@dbx-tools/shared-mastra";
28
35
  import type { UIMessage } from "ai";
29
36
  import type { EChartsCoreOption } from "echarts";
30
37
  import { normalizeChartOption } from "./chart-option.ts";
@@ -203,7 +210,10 @@ function splitSegments(text: string): Segment[] {
203
210
  if (marker.start > last) {
204
211
  segments.push({ kind: "text", text: text.slice(last, marker.start) });
205
212
  }
206
- if (isUuid(marker.id) && marker.type === "chart") {
213
+ if (marker.type === GENIE_VISUALIZATION_MARKER) {
214
+ const reference = parseGenieVisualizationEmbed(marker.id);
215
+ if (reference) segments.push({ kind: "visualization", id: reference.statementId });
216
+ } else if (isUuid(marker.id) && marker.type === "chart") {
207
217
  segments.push({ kind: "chart", id: marker.id });
208
218
  } else if (isUuid(marker.id) && marker.type === "data") {
209
219
  segments.push({ kind: "data", id: marker.id });
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  type MastraClientConfig,
3
+ type GenieVisualizationMode,
3
4
  genieRoutePath,
4
5
  MASTRA_ROUTES,
5
6
  GENIE_CONVERSATION_PART_TYPE,
@@ -38,14 +39,17 @@ export class GenieChatClient extends MastraPluginClient {
38
39
  override readonly threadRename = false;
39
40
  override readonly attachments = false;
40
41
  override readonly followUpSuggestions: "none" | "genie";
42
+ /** Renderer requested for direct Genie visualization markers. */
43
+ readonly visualizationMode: GenieVisualizationMode | undefined;
41
44
  /** Local and resolved thread ids mapped to their Genie conversation id. */
42
45
  readonly #conversationIds = new Map<string, string>();
43
46
  /** Transcript message id to Genie message id, for regenerate cleanup. */
44
47
  readonly #genieMessageIds = new Map<string, string>();
45
48
 
46
- constructor(config: MastraClientConfig, alias: string) {
49
+ constructor(config: MastraClientConfig, alias: string, visualization?: GenieVisualizationMode) {
47
50
  super(config);
48
51
  this.alias = alias;
52
+ this.visualizationMode = visualization;
49
53
  this.feedbackModes = config.feedbackModes?.includes("genie") ? ["genie"] : [];
50
54
  this.followUpSuggestions =
51
55
  config.followUpSuggestions === "genie" || config.followUpSuggestions === "auto"
@@ -99,6 +103,7 @@ export class GenieChatClient extends MastraPluginClient {
99
103
  question,
100
104
  ...(conversationId ? { conversationId } : {}),
101
105
  ...(params.requestContext ? { requestContext: params.requestContext } : {}),
106
+ ...(this.visualizationMode ? { visualization: this.visualizationMode } : {}),
102
107
  },
103
108
  routing: {},
104
109
  signal: params.signal,
@@ -188,8 +193,12 @@ export class GenieChatClient extends MastraPluginClient {
188
193
  const page = options.page ?? 0;
189
194
  let messages: UIMessage[] = [];
190
195
  if (page === 0) {
196
+ const url = this.#url(MASTRA_ROUTES.threads, options.threadId, MASTRA_ROUTES.messages);
197
+ const historyUrl = this.visualizationMode
198
+ ? `${url}?${new URLSearchParams({ visualization: this.visualizationMode })}`
199
+ : url;
191
200
  const payload = await this.getJson(
192
- this.#url(MASTRA_ROUTES.threads, options.threadId, MASTRA_ROUTES.messages),
201
+ historyUrl,
193
202
  GenieThreadMessagesResponseSchema,
194
203
  options.signal,
195
204
  );
@@ -20,6 +20,8 @@ import {
20
20
  MastraSuggestionsResponseSchema,
21
21
  ChartSchema,
22
22
  StatementDataSchema,
23
+ type GenieVisualizationEmbed,
24
+ genieVisualizationImagePath,
23
25
  } from "@dbx-tools/shared-mastra";
24
26
  import type { ReasoningEffort, ServingEndpointSummary } from "@dbx-tools/shared-model";
25
27
  import {
@@ -565,6 +567,11 @@ export class MastraPluginClient extends MastraClient {
565
567
  return this.#embed("visualization", id, StatementDataSchema.parse, signal);
566
568
  }
567
569
 
570
+ /** Same-origin image URL; the app's OBO route owns workspace authentication. */
571
+ genieVisualizationImageUrl(reference: GenieVisualizationEmbed): string {
572
+ return `${this.basePath}${genieVisualizationImagePath(reference)}`;
573
+ }
574
+
568
575
  /**
569
576
  * Compose an agent-scoped URL: `${basePath}${segment}` for the
570
577
  * default agent (the mount that does not require an `:agentId`), or
@@ -1,41 +0,0 @@
1
- /**
2
- * Clipboard write that also works off a non-secure origin.
3
- *
4
- * `navigator.clipboard` only exists in a secure context (HTTPS / localhost).
5
- * Over plain HTTP - a LAN IP, a ZeroTier address, a port-forwarded dev host -
6
- * it is `undefined`, so a copy button wired straight to it silently does
7
- * nothing. {@link copyText} falls back to a hidden `<textarea>` +
8
- * `document.execCommand("copy")`, which is deprecated but still the only thing
9
- * that works there.
10
- *
11
- * @module
12
- */
13
-
14
- /**
15
- * Copy `text` to the clipboard, returning whether it succeeded so the caller
16
- * can decide whether to show a confirmation.
17
- */
18
- export async function copyText(text: string): Promise<boolean> {
19
- try {
20
- if (navigator.clipboard?.writeText) {
21
- await navigator.clipboard.writeText(text);
22
- return true;
23
- }
24
- } catch {
25
- // Permission denied or non-secure context; fall through to execCommand.
26
- }
27
- try {
28
- const area = document.createElement("textarea");
29
- area.value = text;
30
- area.setAttribute("readonly", "");
31
- area.style.position = "fixed";
32
- area.style.opacity = "0";
33
- document.body.appendChild(area);
34
- area.select();
35
- const ok = document.execCommand("copy");
36
- area.remove();
37
- return ok;
38
- } catch {
39
- return false;
40
- }
41
- }