@dbx-tools/ui-mastra 0.9.214 → 0.11.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.
@@ -8,18 +8,15 @@ import {
8
8
  Item,
9
9
  ItemContent,
10
10
  ItemMedia,
11
- Tooltip,
12
- TooltipContent,
13
- TooltipTrigger,
14
11
  cn,
15
12
  } from "@databricks/appkit-ui/react";
16
- import { RecordPreview, copyText } from "@dbx-tools/ui/react";
13
+ import { EmailFieldRow, joinAddresses } from "@dbx-tools/ui/email/react";
14
+ import { CopyButton, IconTooltipButton, RecordPreview } from "@dbx-tools/ui/react";
17
15
  import type { UIMessage } from "ai";
18
16
  import {
19
17
  BugIcon,
20
18
  CheckIcon,
21
19
  ChevronDownIcon,
22
- CopyIcon,
23
20
  MessageSquareIcon,
24
21
  RefreshCcwIcon,
25
22
  UserIcon,
@@ -90,9 +87,9 @@ type EmailApprovalInput = {
90
87
  body?: string;
91
88
  };
92
89
 
93
- /** Comma-join one-or-many addresses; empty string when none. */
94
- const joinAddresses = (value: string | string[] | undefined): string =>
95
- (Array.isArray(value) ? value : value ? [value] : []).filter(Boolean).join(", ");
90
+ /** Normalize one-or-many approval addresses for the shared email formatter. */
91
+ const emailAddresses = (value: string | string[] | undefined): string[] | undefined =>
92
+ value === undefined ? undefined : Array.isArray(value) ? value : [value];
96
93
 
97
94
  /**
98
95
  * Recognize an approval input that is an email draft (the `send_email` tool),
@@ -110,43 +107,26 @@ const asEmailInput = (input: unknown): EmailApprovalInput | null => {
110
107
 
111
108
  /**
112
109
  * Labeled To / Cc / Subject / Body preview of an email awaiting approval, with
113
- * the body rendered as Markdown (headings, tables, lists) rather than the raw
114
- * source. Mirrors `ui-email`'s `EmailPreview` without a dependency on that
115
- * optional package, so the `send_email` approval card reads like an email
116
- * instead of a JSON blob.
110
+ * the body rendered as Markdown rather than raw source.
117
111
  */
118
112
  const EmailApprovalPreview = ({ email }: { email: EmailApprovalInput }) => {
119
- const to = joinAddresses(email.to);
120
- const cc = joinAddresses(email.cc);
113
+ const to = joinAddresses(emailAddresses(email.to));
114
+ const cc = joinAddresses(emailAddresses(email.cc));
121
115
  return (
122
- <dl className="space-y-1 rounded bg-background/40 p-2 text-[11px]">
123
- {to && (
124
- <div className="flex gap-2">
125
- <dt className="w-14 shrink-0 text-muted-foreground">To</dt>
126
- <dd className="min-w-0 flex-1 truncate">{to}</dd>
127
- </div>
128
- )}
129
- {cc && (
130
- <div className="flex gap-2">
131
- <dt className="w-14 shrink-0 text-muted-foreground">Cc</dt>
132
- <dd className="min-w-0 flex-1 truncate">{cc}</dd>
133
- </div>
134
- )}
116
+ <div className="space-y-1 rounded bg-background/40 p-2 text-[11px]">
117
+ {to && <EmailFieldRow label="To">{to}</EmailFieldRow>}
118
+ {cc && <EmailFieldRow label="Cc">{cc}</EmailFieldRow>}
135
119
  {email.subject && (
136
- <div className="flex gap-2">
137
- <dt className="w-14 shrink-0 text-muted-foreground">Subject</dt>
138
- <dd className="min-w-0 flex-1 truncate font-medium">{email.subject}</dd>
139
- </div>
120
+ <EmailFieldRow label="Subject" valueClassName="font-medium text-foreground">
121
+ {email.subject}
122
+ </EmailFieldRow>
140
123
  )}
141
124
  {email.body && (
142
- <div className="flex gap-2">
143
- <dt className="w-14 shrink-0 text-muted-foreground">Body</dt>
144
- <dd className="min-w-0 flex-1 break-words">
145
- <ToolMarkdown>{email.body}</ToolMarkdown>
146
- </dd>
147
- </div>
125
+ <EmailFieldRow label="Body" valueClassName="whitespace-normal break-words text-foreground">
126
+ <ToolMarkdown>{email.body}</ToolMarkdown>
127
+ </EmailFieldRow>
148
128
  )}
149
- </dl>
129
+ </div>
150
130
  );
151
131
  };
152
132
 
@@ -399,17 +379,6 @@ export const AssistantBubble = ({
399
379
  const activityItems = assistantActivityItems(message.parts, toolEvents);
400
380
  const fullText = messageTextFromParts(message.parts);
401
381
  const hasText = fullText.length > 0;
402
- // Brief "copied" acknowledgement on the copy button (swaps the icon to a
403
- // check for ~1.5s), so a tap gives visible feedback on touch where there's
404
- // no hover/tooltip.
405
- const [copied, setCopied] = useState(false);
406
- const handleCopy = () => {
407
- void copyText(fullText).then((ok) => {
408
- if (!ok) return;
409
- setCopied(true);
410
- window.setTimeout(() => setCopied(false), 1500);
411
- });
412
- };
413
382
  // Suggestions are deferred until the turn is settled so they don't
414
383
  // pop in mid-stream. A bubble is "settled" if it isn't the active
415
384
  // streaming target - either the agent has returned to `ready` /
@@ -429,39 +398,11 @@ export const AssistantBubble = ({
429
398
  const footerActions = (
430
399
  <>
431
400
  {hasText && isLast && regenerate && (
432
- <Tooltip>
433
- <TooltipTrigger asChild>
434
- <Button
435
- type="button"
436
- size="icon"
437
- variant="ghost"
438
- className="size-7"
439
- onClick={() => regenerate()}
440
- aria-label="Retry response"
441
- >
442
- <RefreshCcwIcon className="size-3" />
443
- </Button>
444
- </TooltipTrigger>
445
- <TooltipContent>Retry</TooltipContent>
446
- </Tooltip>
447
- )}
448
- {hasText && isLast && (
449
- <Tooltip>
450
- <TooltipTrigger asChild>
451
- <Button
452
- type="button"
453
- size="icon"
454
- variant="ghost"
455
- className="size-7"
456
- onClick={handleCopy}
457
- aria-label={copied ? "Copied" : "Copy"}
458
- >
459
- {copied ? <CheckIcon className="size-3" /> : <CopyIcon className="size-3" />}
460
- </Button>
461
- </TooltipTrigger>
462
- <TooltipContent>{copied ? "Copied" : "Copy"}</TooltipContent>
463
- </Tooltip>
401
+ <IconTooltipButton tooltip="Retry" onClick={() => regenerate()} aria-label="Retry response">
402
+ <RefreshCcwIcon className="size-3" />
403
+ </IconTooltipButton>
464
404
  )}
405
+ {hasText && isLast && <CopyButton value={fullText} iconClassName="size-3" />}
465
406
  {hasText && onExport && <ExportMenu onExport={onExport} iconOnly tooltip="Export message" />}
466
407
  {hasText && onFeedback && (
467
408
  <FeedbackControls
@@ -472,21 +413,11 @@ export const AssistantBubble = ({
472
413
  />
473
414
  )}
474
415
  {hasText && mlflowTraceUrl && (
475
- <Tooltip>
476
- <TooltipTrigger asChild>
477
- <Button asChild type="button" size="icon" variant="ghost" className="size-7">
478
- <a
479
- href={mlflowTraceUrl}
480
- target="_blank"
481
- rel="noreferrer"
482
- aria-label="Open MLflow trace"
483
- >
484
- <BugIcon className="size-3" />
485
- </a>
486
- </Button>
487
- </TooltipTrigger>
488
- <TooltipContent>Open MLflow trace</TooltipContent>
489
- </Tooltip>
416
+ <IconTooltipButton tooltip="Open MLflow trace" asChild>
417
+ <a href={mlflowTraceUrl} target="_blank" rel="noreferrer">
418
+ <BugIcon className="size-3" />
419
+ </a>
420
+ </IconTooltipButton>
490
421
  )}
491
422
  {showResponseStatus && (
492
423
  <div className="flex items-center text-muted-foreground">
@@ -1,23 +1,14 @@
1
1
  import {
2
- AlertDialog,
3
- AlertDialogAction,
4
- AlertDialogCancel,
5
- AlertDialogContent,
6
- AlertDialogDescription,
7
- AlertDialogFooter,
8
- AlertDialogHeader,
9
- AlertDialogTitle,
10
2
  Button,
11
3
  InputGroup,
12
4
  InputGroupAddon,
13
5
  InputGroupButton,
14
6
  InputGroupTextarea,
15
7
  Spinner,
16
- Tooltip,
17
- TooltipContent,
18
- TooltipTrigger,
19
8
  cn,
20
9
  } from "@databricks/appkit-ui/react";
10
+ import { errorMessage } from "@dbx-tools/shared-core";
11
+ import { ConfirmDialog, IconTooltipButton } from "@dbx-tools/ui/react";
21
12
  import type { FileUIPart } from "ai";
22
13
  import {
23
14
  GripVerticalIcon,
@@ -129,38 +120,24 @@ const QueuedSteerList = ({
129
120
  {steer.text || steer.files?.map((file) => file.filename || "Image").join(", ")}
130
121
  </span>
131
122
  {onSendSteerNow && (
132
- <Tooltip>
133
- <TooltipTrigger asChild>
134
- <Button
135
- type="button"
136
- variant="ghost"
137
- size="icon"
138
- className="size-6 shrink-0"
139
- onClick={() => onSendSteerNow(steer.id)}
140
- aria-label="Send now (interrupts current turn)"
141
- >
142
- <SendHorizontalIcon className="size-3" />
143
- </Button>
144
- </TooltipTrigger>
145
- <TooltipContent>Send now - interrupts</TooltipContent>
146
- </Tooltip>
123
+ <IconTooltipButton
124
+ tooltip="Send now - interrupts"
125
+ className="size-6 shrink-0"
126
+ onClick={() => onSendSteerNow(steer.id)}
127
+ aria-label="Send now (interrupts current turn)"
128
+ >
129
+ <SendHorizontalIcon className="size-3" />
130
+ </IconTooltipButton>
147
131
  )}
148
132
  {onRemoveSteer && (
149
- <Tooltip>
150
- <TooltipTrigger asChild>
151
- <Button
152
- type="button"
153
- variant="ghost"
154
- size="icon"
155
- className="size-6 shrink-0"
156
- onClick={() => onRemoveSteer(steer.id)}
157
- aria-label="Remove queued message"
158
- >
159
- <XIcon className="size-3" />
160
- </Button>
161
- </TooltipTrigger>
162
- <TooltipContent>Remove</TooltipContent>
163
- </Tooltip>
133
+ <IconTooltipButton
134
+ tooltip="Remove"
135
+ className="size-6 shrink-0"
136
+ onClick={() => onRemoveSteer(steer.id)}
137
+ aria-label="Remove queued message"
138
+ >
139
+ <XIcon className="size-3" />
140
+ </IconTooltipButton>
164
141
  )}
165
142
  </div>
166
143
  );
@@ -191,45 +168,36 @@ const ClearConversationAction = ({ onClear, isLoadingHistory }: ClearConversatio
191
168
 
192
169
  return (
193
170
  <>
194
- <Tooltip>
195
- <TooltipTrigger asChild>
196
- <Button
197
- type="button"
198
- variant="outline"
199
- size="icon"
200
- onClick={() => setOpen(true)}
201
- disabled={isLoadingHistory}
202
- className="size-7 rounded-full [&_svg]:size-3"
203
- aria-label="Clear conversation"
204
- >
205
- <Trash2Icon className="size-3" />
206
- </Button>
207
- </TooltipTrigger>
208
- <TooltipContent>Clear chat history for this thread</TooltipContent>
209
- </Tooltip>
210
- <AlertDialog open={open} onOpenChange={setOpen}>
211
- <AlertDialogContent>
212
- <AlertDialogHeader>
213
- <AlertDialogTitle>Clear this conversation?</AlertDialogTitle>
214
- <AlertDialogDescription>
215
- This permanently deletes the chat history for this thread. This can&apos;t be undone.
216
- </AlertDialogDescription>
217
- </AlertDialogHeader>
218
- <AlertDialogFooter>
219
- <AlertDialogCancel disabled={clearing}>Cancel</AlertDialogCancel>
220
- <AlertDialogAction
221
- onClick={(event) => {
222
- event.preventDefault();
223
- void handleConfirm();
224
- }}
225
- disabled={clearing}
226
- >
227
- {clearing ? <Spinner className="size-3" /> : null}
228
- {clearing ? "Clearing..." : "Clear"}
229
- </AlertDialogAction>
230
- </AlertDialogFooter>
231
- </AlertDialogContent>
232
- </AlertDialog>
171
+ <IconTooltipButton
172
+ tooltip="Clear chat history for this thread"
173
+ variant="outline"
174
+ onClick={() => setOpen(true)}
175
+ disabled={isLoadingHistory}
176
+ className="rounded-full [&_svg]:size-3"
177
+ aria-label="Clear conversation"
178
+ >
179
+ <Trash2Icon className="size-3" />
180
+ </IconTooltipButton>
181
+ <ConfirmDialog
182
+ open={open}
183
+ onOpenChange={setOpen}
184
+ title="Clear this conversation?"
185
+ description="This permanently deletes the chat history for this thread. This can't be undone."
186
+ cancelProps={{ disabled: clearing }}
187
+ confirmLabel={
188
+ <>
189
+ {clearing ? <Spinner className="size-3" /> : null}
190
+ {clearing ? "Clearing..." : "Clear"}
191
+ </>
192
+ }
193
+ confirmProps={{
194
+ disabled: clearing,
195
+ onClick: (event) => {
196
+ event.preventDefault();
197
+ void handleConfirm();
198
+ },
199
+ }}
200
+ />
233
201
  </>
234
202
  );
235
203
  };
@@ -357,7 +325,7 @@ export const ChatComposer = ({
357
325
  setFileError(`Only the first ${remaining} images were added`);
358
326
  }
359
327
  } catch (error) {
360
- setFileError(error instanceof Error ? error.message : "Unable to attach image");
328
+ setFileError(errorMessage(error));
361
329
  } finally {
362
330
  setIsPreparingFiles(false);
363
331
  if (fileInputRef.current) fileInputRef.current.value = "";
@@ -446,6 +414,7 @@ export const ChatComposer = ({
446
414
  </InputGroupAddon>
447
415
  )}
448
416
  <InputGroupTextarea
417
+ data-slot="aui_composer-input"
449
418
  id={`${inputId}-message`}
450
419
  name="message"
451
420
  ref={textareaRef}
@@ -495,30 +464,21 @@ export const ChatComposer = ({
495
464
  className="sr-only"
496
465
  onChange={(event) => void addFiles(event.currentTarget.files)}
497
466
  />
498
- <Tooltip>
499
- <TooltipTrigger asChild>
500
- <Button
501
- type="button"
502
- variant="outline"
503
- size="icon"
504
- className="size-7 rounded-full [&_svg]:size-3"
505
- onClick={() => fileInputRef.current?.click()}
506
- disabled={
507
- isLoadingHistory ||
508
- isPreparingFiles ||
509
- files.length >= MAX_COMPOSER_IMAGES
510
- }
511
- aria-label="Upload images"
512
- >
513
- {isPreparingFiles ? (
514
- <Spinner className="size-3" />
515
- ) : (
516
- <ImagePlusIcon className="size-3" />
517
- )}
518
- </Button>
519
- </TooltipTrigger>
520
- <TooltipContent>Upload images</TooltipContent>
521
- </Tooltip>
467
+ <IconTooltipButton
468
+ tooltip="Upload images"
469
+ variant="outline"
470
+ className="rounded-full [&_svg]:size-3"
471
+ onClick={() => fileInputRef.current?.click()}
472
+ disabled={
473
+ isLoadingHistory || isPreparingFiles || files.length >= MAX_COMPOSER_IMAGES
474
+ }
475
+ >
476
+ {isPreparingFiles ? (
477
+ <Spinner className="size-3" />
478
+ ) : (
479
+ <ImagePlusIcon className="size-3" />
480
+ )}
481
+ </IconTooltipButton>
522
482
  </>
523
483
  )}
524
484
  {composerLeadingActions}
@@ -1,11 +1,5 @@
1
- import {
2
- Button,
3
- Tooltip,
4
- TooltipContent,
5
- TooltipProvider,
6
- TooltipTrigger,
7
- cn,
8
- } from "@databricks/appkit-ui/react";
1
+ import { TooltipProvider, cn } from "@databricks/appkit-ui/react";
2
+ import { IconTooltipButton, useElementSize } from "@dbx-tools/ui/react";
9
3
  import { PanelLeftIcon, PanelRightIcon } from "lucide-react";
10
4
  import React, { useEffect, useRef, useState } from "react";
11
5
  import { ThreadSidebar, type ThreadSidebarProps } from "./thread-sidebar.tsx";
@@ -15,23 +9,6 @@ import { closeThreadTab, nextActiveThreadTab, syncThreadTabs } from "../support/
15
9
 
16
10
  const SIDE_PANEL_MIN_WIDTH_PX = 768;
17
11
 
18
- const useIsNarrow = (ref: React.RefObject<HTMLElement | null>): boolean => {
19
- const [isNarrow, setIsNarrow] = useState(() =>
20
- typeof window === "undefined" ? false : window.innerWidth < SIDE_PANEL_MIN_WIDTH_PX,
21
- );
22
- useEffect(() => {
23
- const element = ref.current;
24
- if (!element || typeof ResizeObserver === "undefined") return;
25
- const observer = new ResizeObserver((entries) => {
26
- const width = entries[0]?.contentRect.width ?? element.clientWidth;
27
- if (width > 0) setIsNarrow(width < SIDE_PANEL_MIN_WIDTH_PX);
28
- });
29
- observer.observe(element);
30
- return () => observer.disconnect();
31
- }, [ref]);
32
- return isNarrow;
33
- };
34
-
35
12
  type ChatThreadLayoutProps = {
36
13
  children: React.ReactNode;
37
14
  className: ChatViewProps["className"];
@@ -111,7 +88,11 @@ export const ChatThreadLayout = ({
111
88
  onToggleSidebar,
112
89
  }: ChatThreadLayoutProps) => {
113
90
  const rootRef = useRef<HTMLDivElement>(null);
114
- const isNarrow = useIsNarrow(rootRef);
91
+ const { width } = useElementSize(rootRef);
92
+ const isNarrow =
93
+ width > 0
94
+ ? width < SIDE_PANEL_MIN_WIDTH_PX
95
+ : typeof window !== "undefined" && window.innerWidth < SIDE_PANEL_MIN_WIDTH_PX;
115
96
  const showThreads = Boolean(threads && onSelectThread) && threadPlacement !== "disabled";
116
97
  const placement = threadPlacement === "auto" ? (isNarrow ? "top" : "left") : threadPlacement;
117
98
  const tabbedThreads = showThreads && placement === "top";
@@ -229,22 +210,13 @@ export const ChatThreadLayout = ({
229
210
  dockedSide === "right" && "justify-end",
230
211
  )}
231
212
  >
232
- <Tooltip>
233
- <TooltipTrigger asChild>
234
- <Button
235
- type="button"
236
- variant="ghost"
237
- size="icon-sm"
238
- onClick={toggleSidebar}
239
- aria-label={sidebarOpen ? "Hide conversations" : "Show conversations"}
240
- >
241
- <SidebarToggleIcon className="size-4" />
242
- </Button>
243
- </TooltipTrigger>
244
- <TooltipContent>
245
- {sidebarOpen ? "Hide conversations" : "Show conversations"}
246
- </TooltipContent>
247
- </Tooltip>
213
+ <IconTooltipButton
214
+ tooltip={sidebarOpen ? "Hide conversations" : "Show conversations"}
215
+ size="icon-sm"
216
+ onClick={toggleSidebar}
217
+ >
218
+ <SidebarToggleIcon className="size-4" />
219
+ </IconTooltipButton>
248
220
  </div>
249
221
  )}
250
222
  {children}
@@ -210,6 +210,7 @@ type ChatTranscriptProps = {
210
210
  status: ChatViewProps["status"];
211
211
  error: ChatViewProps["error"];
212
212
  suggestions: NonNullable<ChatViewProps["suggestions"]>;
213
+ emptyState: ChatViewProps["emptyState"];
213
214
  followUpQuestions: string[];
214
215
  showSelectedModel: NonNullable<ChatViewProps["showSelectedModel"]>;
215
216
  metrics: ChatViewProps["metrics"];
@@ -235,6 +236,7 @@ export const ChatTranscript = ({
235
236
  status,
236
237
  error,
237
238
  suggestions,
239
+ emptyState,
238
240
  followUpQuestions,
239
241
  showSelectedModel,
240
242
  metrics,
@@ -335,19 +337,23 @@ export const ChatTranscript = ({
335
337
  className="mx-auto flex min-h-full min-w-0 w-full max-w-4xl flex-col gap-3 overflow-x-clip px-4 py-3 md:px-6"
336
338
  >
337
339
  {messages.length === 0 && !isLoadingHistory ? (
338
- <Empty className="h-full flex-1 px-0">
339
- <EmptyHeader>
340
- <EmptyMedia variant="icon">
341
- <MessageSquareIcon className="size-5" />
342
- </EmptyMedia>
343
- <EmptyTitle>Start a conversation</EmptyTitle>
344
- <EmptyDescription>
345
- {suggestions.length > 0
346
- ? "Ask anything, or pick a suggestion below."
347
- : "Ask anything to get started."}
348
- </EmptyDescription>
349
- </EmptyHeader>
350
- </Empty>
340
+ emptyState === false ? null : (
341
+ (emptyState ?? (
342
+ <Empty className="h-full flex-1 px-0">
343
+ <EmptyHeader>
344
+ <EmptyMedia variant="icon">
345
+ <MessageSquareIcon className="size-5" />
346
+ </EmptyMedia>
347
+ <EmptyTitle>Start a conversation</EmptyTitle>
348
+ <EmptyDescription>
349
+ {suggestions.length > 0
350
+ ? "Ask anything, or pick a suggestion below."
351
+ : "Ask anything to get started."}
352
+ </EmptyDescription>
353
+ </EmptyHeader>
354
+ </Empty>
355
+ ))
356
+ )
351
357
  ) : (
352
358
  <>
353
359
  {(isLoadingMore || isLoadingHistory) && (
@@ -26,6 +26,7 @@ export const ChatView = ({
26
26
  className,
27
27
  showComposer = true,
28
28
  suggestions = [],
29
+ emptyState,
29
30
  followUpSuggestions = "none",
30
31
  followUpSuggestionLimit = 3,
31
32
  showSelectedModel = false,
@@ -132,6 +133,7 @@ export const ChatView = ({
132
133
  status={status}
133
134
  error={error}
134
135
  suggestions={suggestions}
136
+ emptyState={emptyState}
135
137
  followUpQuestions={followUpQuestions}
136
138
  showSelectedModel={showSelectedModel}
137
139
  metrics={metrics}
@@ -74,7 +74,7 @@ export function colorizeDelta(content: React.ReactNode): React.ReactNode {
74
74
  * run through {@link colorizeDelta} so signed deltas keep their
75
75
  * green/red treatment.
76
76
  */
77
- export function renderDataCell(value: unknown): React.ReactNode {
77
+ function renderDataCell(value: unknown): React.ReactNode {
78
78
  return colorizeDelta(value == null ? "" : String(value));
79
79
  }
80
80
 
@@ -260,7 +260,7 @@ export const DataGrid = ({
260
260
  );
261
261
 
262
262
  return (
263
- <div className={DATA_GRID_CARD_CLASSES}>
263
+ <div data-slot="aui_chat-table" className={DATA_GRID_CARD_CLASSES}>
264
264
  <div className={DATA_GRID_TOOLBAR_CLASSES}>
265
265
  <span>
266
266
  {truncated
@@ -13,7 +13,7 @@ import { lazy, Suspense, useMemo, useRef } from "react";
13
13
  import { GenieImageSlot } from "./_genie-image.tsx";
14
14
  import { DataGrid, humanizeLabel } from "./data-grid.tsx";
15
15
  import { AssistantMarkdown } from "./markdown.tsx";
16
- import { normalizeChartOption } from "../support/chart-option.ts";
16
+ import { chartTitleText, normalizeChartOption } from "../support/chart-option.ts";
17
17
  import { useChartChrome } from "../support/chart-theme.ts";
18
18
  import {
19
19
  useChartFetch,
@@ -116,6 +116,7 @@ const ChartSlot = ({ chartId }: { chartId: string }) => {
116
116
  () => (chart?.result && chrome ? normalizeChartOption(chart.result.option, chrome) : undefined),
117
117
  [chart?.result, chrome],
118
118
  );
119
+ const accessibleTitle = chart?.result ? chartTitleText(chart.result.option) : undefined;
119
120
  const waiting = loading || chrome === undefined;
120
121
  // Settled 404 (unknown / TTL-expired id) -> small "expired" notice.
121
122
  // Hard-error / non-terminal payloads render nothing.
@@ -129,7 +130,13 @@ const ChartSlot = ({ chartId }: { chartId: string }) => {
129
130
  // across the transition, so the theme is already resolved when the
130
131
  // spec lands.
131
132
  return (
132
- <div ref={frameRef} className={CHART_FRAME_CLASSES}>
133
+ <div
134
+ ref={frameRef}
135
+ className={CHART_FRAME_CLASSES}
136
+ role={option ? "img" : undefined}
137
+ aria-label={option ? (accessibleTitle ?? "Assistant chart") : undefined}
138
+ title={option ? accessibleTitle : undefined}
139
+ >
133
140
  {option ? (
134
141
  <Suspense fallback={<ChartLoading />}>
135
142
  <ReactECharts
@@ -12,6 +12,7 @@ import {
12
12
  TooltipTrigger,
13
13
  cn,
14
14
  } from "@databricks/appkit-ui/react";
15
+ import { IconTooltipButton } from "@dbx-tools/ui/react";
15
16
  import { MessageSquareTextIcon, ThumbsDownIcon, ThumbsUpIcon } from "lucide-react";
16
17
  import { useRef, useState } from "react";
17
18
  import type { FeedbackSubmission, FeedbackValue } from "./types.ts";
@@ -67,38 +68,22 @@ export const FeedbackControls = ({
67
68
 
68
69
  return (
69
70
  <>
70
- <Tooltip>
71
- <TooltipTrigger asChild>
72
- <Button
73
- type="button"
74
- size="icon"
75
- variant="ghost"
76
- className={cn("size-7", value === "up" && "text-success")}
77
- aria-label="Good response"
78
- aria-pressed={value === "up"}
79
- onClick={() => submitRating("up")}
80
- >
81
- <ThumbsUpIcon className="size-3" />
82
- </Button>
83
- </TooltipTrigger>
84
- <TooltipContent>Good response</TooltipContent>
85
- </Tooltip>
86
- <Tooltip>
87
- <TooltipTrigger asChild>
88
- <Button
89
- type="button"
90
- size="icon"
91
- variant="ghost"
92
- className={cn("size-7", value === "down" && "text-destructive")}
93
- aria-label="Bad response"
94
- aria-pressed={value === "down"}
95
- onClick={() => submitRating("down")}
96
- >
97
- <ThumbsDownIcon className="size-3" />
98
- </Button>
99
- </TooltipTrigger>
100
- <TooltipContent>Bad response</TooltipContent>
101
- </Tooltip>
71
+ <IconTooltipButton
72
+ tooltip="Good response"
73
+ className={cn(value === "up" && "text-success")}
74
+ aria-pressed={value === "up"}
75
+ onClick={() => submitRating("up")}
76
+ >
77
+ <ThumbsUpIcon className="size-3" />
78
+ </IconTooltipButton>
79
+ <IconTooltipButton
80
+ tooltip="Bad response"
81
+ className={cn(value === "down" && "text-destructive")}
82
+ aria-pressed={value === "down"}
83
+ onClick={() => submitRating("down")}
84
+ >
85
+ <ThumbsDownIcon className="size-3" />
86
+ </IconTooltipButton>
102
87
  <Dialog open={open} onOpenChange={setOpen}>
103
88
  <Tooltip>
104
89
  <TooltipTrigger asChild>