@dbx-tools/ui-mastra 0.9.206 → 0.9.211

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/index.react.ts CHANGED
@@ -1,6 +1,6 @@
1
- // GENERATED by projen watch - DO NOT EDIT.
1
+ // GENERATED by projen barrels - DO NOT EDIT.
2
2
  // Regenerated from the exporting modules in ./src.
3
- // Hand edits are overwritten on the next watch; this file is read-only.
3
+ // Hand edits are overwritten on the next generation; this file is read-only.
4
4
 
5
5
  export * as bubbles from "./src/react/bubbles.tsx";
6
6
  export * as chatApprovals from "./src/react/chat-approvals.ts";
package/index.support.ts CHANGED
@@ -1,6 +1,6 @@
1
- // GENERATED by projen watch - DO NOT EDIT.
1
+ // GENERATED by projen barrels - DO NOT EDIT.
2
2
  // Regenerated from the exporting modules in ./src.
3
- // Hand edits are overwritten on the next watch; this file is read-only.
3
+ // Hand edits are overwritten on the next generation; this file is read-only.
4
4
 
5
5
  export * as activeRuns from "./src/support/active-runs.ts";
6
6
  export * as browserTranscript from "./src/support/browser-transcript.ts";
package/index.ts CHANGED
@@ -1,6 +1,6 @@
1
- // GENERATED by projen watch - DO NOT EDIT.
1
+ // GENERATED by projen barrels - DO NOT EDIT.
2
2
  // Regenerated from the exporting modules in ./src.
3
- // Hand edits are overwritten on the next watch; this file is read-only.
3
+ // Hand edits are overwritten on the next generation; this file is read-only.
4
4
 
5
5
  export const PACKAGE_IDENTIFIER = "@dbx-tools/ui-mastra";
6
- export const PACKAGE_VERSION = "0.9.206";
6
+ export const PACKAGE_VERSION = "0.9.211";
package/package.json CHANGED
@@ -37,13 +37,13 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@databricks/appkit-ui": "0.81.0",
40
- "@dbx-tools/shared-auth": "0.9.206",
41
- "@dbx-tools/shared-core": "0.9.206",
42
- "@dbx-tools/shared-genie": "0.9.206",
43
- "@dbx-tools/shared-mastra": "0.9.206",
44
- "@dbx-tools/shared-model": "0.9.206",
45
- "@dbx-tools/shared-model-gateway": "0.9.206",
46
- "@dbx-tools/ui": "0.9.206",
40
+ "@dbx-tools/shared-auth": "0.9.211",
41
+ "@dbx-tools/shared-core": "0.9.211",
42
+ "@dbx-tools/shared-genie": "0.9.211",
43
+ "@dbx-tools/shared-mastra": "0.9.211",
44
+ "@dbx-tools/shared-model": "0.9.211",
45
+ "@dbx-tools/shared-model-gateway": "0.9.211",
46
+ "@dbx-tools/ui": "0.9.211",
47
47
  "@mastra/client-js": "1.50.0",
48
48
  "@mastra/core": "1.71.0",
49
49
  "@tanstack/react-table": "^8.21.3",
@@ -61,7 +61,7 @@
61
61
  "publishConfig": {
62
62
  "access": "public"
63
63
  },
64
- "version": "0.9.206",
64
+ "version": "0.9.211",
65
65
  "types": "index.ts",
66
66
  "dbxToolsConfig": {
67
67
  "tags": [
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Typography shared by a suggested prompt and the user message created from it.
3
+ * Keep this as one complete Tailwind class string so host builds discover the
4
+ * utilities and both states remain visually continuous.
5
+ */
6
+ export const CHAT_PROMPT_TEXT_CLASS = "text-sm leading-snug sm:leading-normal";
@@ -0,0 +1,18 @@
1
+ /** Calculate the scroll position that centers one tab in its scroll viewport. */
2
+ export const centeredThreadTabScrollLeft = ({
3
+ currentScrollLeft,
4
+ viewportWidth,
5
+ scrollWidth,
6
+ tabLeft,
7
+ tabWidth,
8
+ }: {
9
+ currentScrollLeft: number;
10
+ viewportWidth: number;
11
+ scrollWidth: number;
12
+ /** Tab left edge relative to the visible viewport. */
13
+ tabLeft: number;
14
+ tabWidth: number;
15
+ }): number => {
16
+ const centered = currentScrollLeft + tabLeft - (viewportWidth - tabWidth) / 2;
17
+ return Math.min(Math.max(centered, 0), Math.max(scrollWidth - viewportWidth, 0));
18
+ };
@@ -31,6 +31,7 @@ import {
31
31
  AssistantResponseSpinner,
32
32
  shouldShowAssistantResponseStatus,
33
33
  } from "./_assistant-response-status.tsx";
34
+ import { CHAT_PROMPT_TEXT_CLASS } from "./_chat-prompt-style.ts";
34
35
  import { MarkdownWithEmbeds } from "./embed-slots.tsx";
35
36
  import { ExportMenu } from "./export-menu.tsx";
36
37
  import { FeedbackControls } from "./feedback-controls.tsx";
@@ -575,7 +576,7 @@ export const UserBubble = ({ message }: { message: UIMessage }) => {
575
576
  <UserAvatar />
576
577
  </ItemMedia>
577
578
  <ItemContent className="min-w-0">
578
- <div className="max-w-full rounded-lg bg-muted p-2 text-sm">
579
+ <div className={cn("max-w-full rounded-lg bg-muted p-2", CHAT_PROMPT_TEXT_CLASS)}>
579
580
  {files.length > 0 && (
580
581
  <div className={cn("grid gap-1.5", files.length > 1 && "grid-cols-2")}>
581
582
  {files.map((file, index) => (
@@ -589,12 +590,7 @@ export const UserBubble = ({ message }: { message: UIMessage }) => {
589
590
  </div>
590
591
  )}
591
592
  {text && (
592
- <div
593
- className={cn(
594
- "whitespace-pre-wrap break-words px-1 leading-snug sm:leading-normal",
595
- files.length > 0 && "pt-2",
596
- )}
597
- >
593
+ <div className={cn("whitespace-pre-wrap break-words px-1", files.length > 0 && "pt-2")}>
598
594
  {text}
599
595
  </div>
600
596
  )}
@@ -139,6 +139,33 @@ const MARKDOWN_TABLE_PARTS = {
139
139
  },
140
140
  };
141
141
 
142
+ const BLOCKED_URL_PREFIX = "Blocked URL: ";
143
+ const PLACEHOLDER_LINK_TARGETS = new Set(["undefined", "null"]);
144
+
145
+ /** Hide renderer diagnostics for model-authored links whose target was never populated. */
146
+ const MarkdownSpan = ({
147
+ children,
148
+ title,
149
+ ...rest
150
+ }: React.HTMLAttributes<HTMLSpanElement> & { node?: MarkdownNode }) => {
151
+ const blockedTarget = title?.startsWith(BLOCKED_URL_PREFIX)
152
+ ? title.slice(BLOCKED_URL_PREFIX.length).trim().toLowerCase()
153
+ : undefined;
154
+ if (blockedTarget && PLACEHOLDER_LINK_TARGETS.has(blockedTarget)) {
155
+ const content = React.Children.toArray(children);
156
+ const last = content.at(-1);
157
+ if (typeof last === "string") {
158
+ content[content.length - 1] = last.replace(/\s*\[blocked\]\s*$/, "");
159
+ }
160
+ return <>{content}</>;
161
+ }
162
+ return (
163
+ <span title={title} {...rest}>
164
+ {children}
165
+ </span>
166
+ );
167
+ };
168
+
142
169
  /** Chat links keep Streamdown's safety behavior while using a higher-contrast blue. */
143
170
  const MARKDOWN_LINK_CLASSES = cn(
144
171
  "[&_[data-streamdown=link]]:font-normal [&_[data-streamdown=link]]:text-blue-700",
@@ -158,6 +185,7 @@ const MARKDOWN_LINK_CLASSES = cn(
158
185
  */
159
186
  const MARKDOWN_COMPONENTS = {
160
187
  ...MARKDOWN_TABLE_PARTS,
188
+ span: MarkdownSpan,
161
189
  table: ({
162
190
  node,
163
191
  children,
@@ -200,6 +228,7 @@ const STREAMING_MARKDOWN_COMPONENTS = {
200
228
  */
201
229
  const TOOL_MARKDOWN_COMPONENTS = {
202
230
  ...MARKDOWN_TABLE_PARTS,
231
+ span: MarkdownSpan,
203
232
  table: plainMarkdownTable,
204
233
  };
205
234
 
@@ -71,12 +71,6 @@ export interface SelectedModelTurnMetrics {
71
71
  usd?: number;
72
72
  }
73
73
 
74
- function averageUsdPerDbu(route: ModelRoutePartData): number | undefined {
75
- const values = Object.values(route.pricing?.usdPerDbu ?? {});
76
- if (values.length === 0) return undefined;
77
- return values.reduce((sum, value) => sum + value, 0) / values.length;
78
- }
79
-
80
74
  function elapsedMs(
81
75
  message: Pick<UIMessage, "metadata">,
82
76
  active: boolean,
@@ -124,13 +118,13 @@ function activityTurnMetrics(
124
118
  fallbackStartedAt: number,
125
119
  ): SelectedModelTurnMetrics {
126
120
  const dbu = activity.usage?.estimatedCostDbu;
127
- const usdPerDbu = averageUsdPerDbu(activity.route);
121
+ const usd = activity.usage?.estimatedCostUsd;
128
122
  const timeMs = elapsedMs(message, active, now, fallbackStartedAt);
129
123
  return {
130
124
  ...(activity.usage ? { tokens: activity.usage.usage.totalTokens } : {}),
131
125
  ...(timeMs !== undefined ? { timeMs } : {}),
132
126
  ...(dbu !== undefined ? { dbu } : {}),
133
- ...(dbu !== undefined && usdPerDbu !== undefined ? { usd: dbu * usdPerDbu } : {}),
127
+ ...(usd !== undefined ? { usd } : {}),
134
128
  };
135
129
  }
136
130
 
@@ -1,4 +1,5 @@
1
1
  import { Button, cn } from "@databricks/appkit-ui/react";
2
+ import { CHAT_PROMPT_TEXT_CLASS } from "./_chat-prompt-style.ts";
2
3
 
3
4
  // Shared rendering for suggested questions. Both the initial starter
4
5
  // suggestions (above the composer when the transcript is empty) and
@@ -51,7 +52,8 @@ export const SuggestionPills = ({
51
52
  size="sm"
52
53
  variant="outline"
53
54
  className={cn(
54
- "h-auto shrink-0 whitespace-normal rounded-2xl px-3 py-1.5 text-left text-xs font-normal leading-snug",
55
+ "h-auto shrink-0 whitespace-normal rounded-2xl px-3 py-1.5 text-left font-normal",
56
+ CHAT_PROMPT_TEXT_CLASS,
55
57
  orientation === "horizontal"
56
58
  ? "max-w-[min(20rem,85vw)] md:max-w-full"
57
59
  : "w-full max-w-full justify-start",
@@ -10,6 +10,7 @@ import {
10
10
  } from "@databricks/appkit-ui/react";
11
11
  import { HistoryIcon, Loader2Icon, PlusIcon, XIcon } from "lucide-react";
12
12
  import { type ReactNode, useEffect, useRef, useState } from "react";
13
+ import { centeredThreadTabScrollLeft } from "./_thread-tab-scroll.ts";
13
14
  import { ThreadSidebar, type ThreadSidebarProps } from "./thread-sidebar.tsx";
14
15
  import { threadTitle } from "../support/thread-labels.ts";
15
16
 
@@ -151,9 +152,8 @@ export const ThreadActions = ({
151
152
  * showing its title, a spinner while it streams in the background, and a close
152
153
  * affordance; a trailing `+` starts a fresh conversation and a history button
153
154
  * opens the full conversation list (a {@link ThreadSidebar} in a popover) so
154
- * anything not currently tabbed is one click away. The active tab is scrolled
155
- * into view when the selection changes, so switching from history never leaves
156
- * the current conversation off-screen.
155
+ * anything not currently tabbed is one click away. The active tab is centered
156
+ * when the selection changes, including conversations opened from history.
157
157
  */
158
158
  export const ThreadTabs = ({
159
159
  openThreadIds,
@@ -175,12 +175,17 @@ export const ThreadTabs = ({
175
175
  if (!container || !activeTab) return;
176
176
  const containerRect = container.getBoundingClientRect();
177
177
  const tabRect = activeTab.getBoundingClientRect();
178
- if (tabRect.left < containerRect.left) {
179
- container.scrollBy({ left: tabRect.left - containerRect.left, behavior: "smooth" });
180
- } else if (tabRect.right > containerRect.right) {
181
- container.scrollBy({ left: tabRect.right - containerRect.right, behavior: "smooth" });
182
- }
183
- }, [activeThreadId]);
178
+ container.scrollTo({
179
+ left: centeredThreadTabScrollLeft({
180
+ currentScrollLeft: container.scrollLeft,
181
+ viewportWidth: container.clientWidth,
182
+ scrollWidth: container.scrollWidth,
183
+ tabLeft: tabRect.left - containerRect.left,
184
+ tabWidth: tabRect.width,
185
+ }),
186
+ behavior: "smooth",
187
+ });
188
+ }, [activeThreadId, openThreadIds]);
184
189
 
185
190
  return (
186
191
  // The divider spans the whole chat width while the strip's contents stay