@dbx-tools/ui-mastra 0.9.210 → 0.9.212
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.ts +1 -1
- package/package.json +8 -8
- package/src/react/_chat-prompt-style.ts +6 -0
- package/src/react/_thread-tab-scroll.ts +18 -0
- package/src/react/bubbles.tsx +3 -7
- package/src/react/markdown.tsx +29 -0
- package/src/react/suggestion-pills.tsx +3 -1
- package/src/react/thread-tabs.tsx +14 -9
package/index.ts
CHANGED
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.
|
|
41
|
-
"@dbx-tools/shared-core": "0.9.
|
|
42
|
-
"@dbx-tools/shared-genie": "0.9.
|
|
43
|
-
"@dbx-tools/shared-mastra": "0.9.
|
|
44
|
-
"@dbx-tools/shared-model": "0.9.
|
|
45
|
-
"@dbx-tools/shared-model-gateway": "0.9.
|
|
46
|
-
"@dbx-tools/ui": "0.9.
|
|
40
|
+
"@dbx-tools/shared-auth": "0.9.212",
|
|
41
|
+
"@dbx-tools/shared-core": "0.9.212",
|
|
42
|
+
"@dbx-tools/shared-genie": "0.9.212",
|
|
43
|
+
"@dbx-tools/shared-mastra": "0.9.212",
|
|
44
|
+
"@dbx-tools/shared-model": "0.9.212",
|
|
45
|
+
"@dbx-tools/shared-model-gateway": "0.9.212",
|
|
46
|
+
"@dbx-tools/ui": "0.9.212",
|
|
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.
|
|
64
|
+
"version": "0.9.212",
|
|
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
|
+
};
|
package/src/react/bubbles.tsx
CHANGED
|
@@ -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
|
|
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
|
)}
|
package/src/react/markdown.tsx
CHANGED
|
@@ -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
|
|
|
@@ -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
|
|
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
|
|
155
|
-
*
|
|
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
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
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
|