@dbx-tools/ui-mastra 0.9.93 → 0.9.95

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 CHANGED
@@ -3,7 +3,7 @@
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.93";
6
+ export const PACKAGE_VERSION = "0.9.95";
7
7
  export * as reactBubbles from "./src/react/bubbles.tsx";
8
8
  export * as reactChatApprovals from "./src/react/chat-approvals.ts";
9
9
  export * as reactChatComposer from "./src/react/chat-composer.tsx";
package/package.json CHANGED
@@ -29,11 +29,11 @@
29
29
  "react-dom": "~19.2.4"
30
30
  },
31
31
  "dependencies": {
32
- "@dbx-tools/shared-core": "^0.9.93",
33
- "@dbx-tools/shared-genie": "^0.9.93",
34
- "@dbx-tools/shared-mastra": "^0.9.93",
35
- "@dbx-tools/shared-model": "^0.9.93",
36
- "@dbx-tools/ui": "^0.9.93",
32
+ "@dbx-tools/shared-core": "^0.9.95",
33
+ "@dbx-tools/shared-genie": "^0.9.95",
34
+ "@dbx-tools/shared-mastra": "^0.9.95",
35
+ "@dbx-tools/shared-model": "^0.9.95",
36
+ "@dbx-tools/ui": "^0.9.95",
37
37
  "@mastra/client-js": "1.50.0",
38
38
  "@mastra/core": "1.71.0",
39
39
  "@tanstack/react-table": "^8.21.3",
@@ -50,7 +50,7 @@
50
50
  "publishConfig": {
51
51
  "access": "public"
52
52
  },
53
- "version": "0.9.93",
53
+ "version": "0.9.95",
54
54
  "dbxToolsConfig": {
55
55
  "tags": [
56
56
  "ui"
@@ -8,6 +8,7 @@ import {
8
8
  Item,
9
9
  ItemContent,
10
10
  ItemMedia,
11
+ RecordPreview,
11
12
  Tooltip,
12
13
  TooltipContent,
13
14
  TooltipTrigger,
@@ -191,9 +192,7 @@ const ToolApprovalCard = ({
191
192
  {asEmailInput(input) ? (
192
193
  <EmailApprovalPreview email={asEmailInput(input)!} />
193
194
  ) : (
194
- <pre className="overflow-x-auto rounded bg-background/40 p-2 text-[11px]">
195
- {JSON.stringify(input, null, 2)}
196
- </pre>
195
+ <RecordPreview value={input} className="rounded bg-background/40" />
197
196
  )}
198
197
  {expired ? (
199
198
  <div className="mt-3 flex items-center gap-1.5 text-xs font-medium text-muted-foreground">
@@ -1,5 +1,6 @@
1
- import { stringUtils } from "@dbx-tools/shared-core";
1
+ import { errorUtils, log, stringUtils } from "@dbx-tools/shared-core";
2
2
  import { feedback } from "@dbx-tools/shared-mastra";
3
+ import { isStaleMastraResumeError } from "@dbx-tools/shared-mastra/resume";
3
4
  import { readUIMessageStream, type UIMessage } from "ai";
4
5
  import { useCallback } from "react";
5
6
  import type {
@@ -9,6 +10,8 @@ import type {
9
10
  } from "./chat-sessions.ts";
10
11
  import type { MastraStreamResponse } from "../support/mastra-client.ts";
11
12
 
13
+ const logger = log.logger("ui-mastra/chat");
14
+
12
15
  /** Read the MLflow trace id captured by the server on a stream response. */
13
16
  const readMlflowTraceId = (stream: unknown): string | undefined => {
14
17
  const headers = (stream as { headers?: { get?: (name: string) => string | null } })?.headers;
@@ -80,6 +83,12 @@ export function useChatStream({ getSession, updateSession, writeMessages }: UseC
80
83
  }
81
84
  } catch (error) {
82
85
  if (error instanceof StreamAborted || signal.aborted) return;
86
+ if (isStaleMastraResumeError(error)) {
87
+ logger.warn("ignored stale mastra resume", {
88
+ error: errorUtils.errorMessage(error),
89
+ });
90
+ return;
91
+ }
83
92
  throw error;
84
93
  }
85
94
  },
@@ -1,4 +1,5 @@
1
1
  import { errorUtils, hash, log } from "@dbx-tools/shared-core";
2
+ import { isStaleMastraResumeError } from "@dbx-tools/shared-mastra/resume";
2
3
  import type { ReasoningEffort } from "@dbx-tools/shared-model";
3
4
  import { useBrand } from "@dbx-tools/ui/branding/react";
4
5
  import type { UIMessage } from "ai";
@@ -468,6 +469,25 @@ export const useMastraChat = <TValues extends Record<string, unknown> = Record<s
468
469
  }
469
470
  } catch (caught) {
470
471
  if (getSession(threadId).runToken !== token) return;
472
+ if (isStaleMastraResumeError(caught)) {
473
+ logger.warn("ignored stale mastra resume", {
474
+ error: errorUtils.errorMessage(caught),
475
+ });
476
+ updateSession(threadId, (session) => {
477
+ if (session.runToken !== token) return session;
478
+ return {
479
+ ...session,
480
+ error: null,
481
+ status: "ready",
482
+ abortController:
483
+ session.abortController === controller ? null : session.abortController,
484
+ runId: runIdRef.current,
485
+ };
486
+ });
487
+ refreshThreadsSoon();
488
+ drainQueueRef.current(threadId);
489
+ return;
490
+ }
471
491
  logger.error("stream error", {
472
492
  error: errorUtils.errorMessage(caught),
473
493
  });