@dbx-tools/ui-mastra 0.9.201 → 0.9.203

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.support.ts CHANGED
@@ -30,6 +30,7 @@ export type { ExportFormat, ExportBrand, EmbedResolver, ExportChatOptions } from
30
30
  export { GenieChatClient } from "./src/support/genie-client.ts";
31
31
  export { MastraChatRequestError, MastraPluginClient, useMastraConfig, useMastraClient, useMastraMlflowExperiment, useMastraModels, useMastraDefaultModel, useMastraSuggestions, useMastraThreads, useChartFetch, useStatementFetch, useVisualizationFetch } from "./src/support/mastra-client.ts";
32
32
  export type { MastraStreamResponse, MastraMemoryThread, ByIdFetchState } from "./src/support/mastra-client.ts";
33
+ export { messageTextFromParts } from "./src/support/message-text.ts";
33
34
  export { defaultReasoningEffort, modelStorageKey, readStoredModel, storeSelectedModel } from "./src/support/model-selection.ts";
34
35
  export { snapshotRequestContext } from "./src/support/request-context.ts";
35
36
  export type { MastraRequestContextInput, MastraRequestContextSource } from "./src/support/request-context.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.201";
6
+ export const PACKAGE_VERSION = "0.9.203";
package/package.json CHANGED
@@ -32,13 +32,13 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@databricks/appkit-ui": "0.81.0",
35
- "@dbx-tools/shared-auth": "0.9.201",
36
- "@dbx-tools/shared-core": "0.9.201",
37
- "@dbx-tools/shared-genie": "0.9.201",
38
- "@dbx-tools/shared-mastra": "0.9.201",
39
- "@dbx-tools/shared-model": "0.9.201",
40
- "@dbx-tools/shared-model-gateway": "0.9.201",
41
- "@dbx-tools/ui": "0.9.201",
35
+ "@dbx-tools/shared-auth": "0.9.203",
36
+ "@dbx-tools/shared-core": "0.9.203",
37
+ "@dbx-tools/shared-genie": "0.9.203",
38
+ "@dbx-tools/shared-mastra": "0.9.203",
39
+ "@dbx-tools/shared-model": "0.9.203",
40
+ "@dbx-tools/shared-model-gateway": "0.9.203",
41
+ "@dbx-tools/ui": "0.9.203",
42
42
  "@mastra/client-js": "1.50.0",
43
43
  "@mastra/core": "1.71.0",
44
44
  "@tanstack/react-table": "^8.21.3",
@@ -56,7 +56,7 @@
56
56
  "publishConfig": {
57
57
  "access": "public"
58
58
  },
59
- "version": "0.9.201",
59
+ "version": "0.9.203",
60
60
  "types": "index.ts",
61
61
  "dbxToolsConfig": {
62
62
  "tags": [
@@ -52,6 +52,7 @@ import {
52
52
  type ToolEvent,
53
53
  } from "./types.ts";
54
54
  import type { ExportFormat } from "../support/export.ts";
55
+ import { messageTextFromParts } from "../support/message-text.ts";
55
56
  import { mergeToolEvents, toolEventsFromParts } from "../support/tool-events.ts";
56
57
 
57
58
  // User / assistant message bubbles plus the inline approval card and
@@ -395,10 +396,7 @@ export const AssistantBubble = ({
395
396
  : undefined;
396
397
  const toolEvents = mergeToolEvents(toolEventsFromParts(message.parts), events, terminalToolState);
397
398
  const activityItems = assistantActivityItems(message.parts, toolEvents);
398
- const textParts = message.parts.filter(
399
- (p): p is { type: "text"; text: string } => p.type === "text",
400
- );
401
- const fullText = textParts.map((p) => p.text).join("");
399
+ const fullText = messageTextFromParts(message.parts);
402
400
  const hasText = fullText.length > 0;
403
401
  // Brief "copied" acknowledgement on the copy button (swaps the icon to a
404
402
  // check for ~1.5s), so a tap gives visible feedback on touch where there's
@@ -37,6 +37,7 @@ import type { EChartsCoreOption } from "echarts";
37
37
  import { normalizeChartOption } from "./chart-option.ts";
38
38
  import { LIGHT_CHART_CHROME } from "./chart-theme.ts";
39
39
  import { downloadFile } from "./download.ts";
40
+ import { messageTextFromParts } from "./message-text.ts";
40
41
 
41
42
  /**
42
43
  * Output formats {@link exportChat} can produce.
@@ -226,12 +227,9 @@ function splitSegments(text: string): Segment[] {
226
227
  return segments;
227
228
  }
228
229
 
229
- /** Concatenate a message's `text` parts (matches the on-screen bubbles). */
230
+ /** Extract a message's visible text using the same boundaries as the on-screen bubbles. */
230
231
  export function messageText(message: UIMessage): string {
231
- return message.parts
232
- .filter((p): p is { type: "text"; text: string } => p.type === "text")
233
- .map((p) => p.text)
234
- .join("");
232
+ return messageTextFromParts(message.parts);
235
233
  }
236
234
 
237
235
  /**
@@ -0,0 +1,25 @@
1
+ import type { UIMessage } from "ai";
2
+
3
+ /** Join visible message text without collapsing boundaries occupied by non-text parts. */
4
+ export function messageTextFromParts(parts: UIMessage["parts"]): string {
5
+ let text = "";
6
+ let separatedByNonText = false;
7
+
8
+ for (const part of parts) {
9
+ if (part.type !== "text") {
10
+ if (text.length > 0) separatedByNonText = true;
11
+ continue;
12
+ }
13
+
14
+ if (part.text.length === 0) continue;
15
+
16
+ if (separatedByNonText && !/\s$/u.test(text) && !/^\s/u.test(part.text)) {
17
+ text += "\n\n";
18
+ }
19
+
20
+ text += part.text;
21
+ separatedByNonText = false;
22
+ }
23
+
24
+ return text;
25
+ }