@dbx-tools/ui-mastra 0.6.72 → 0.6.73

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/package.json CHANGED
@@ -24,12 +24,12 @@
24
24
  "typescript": "^5.9.3"
25
25
  },
26
26
  "dependencies": {
27
- "@dbx-tools/shared-core": "0.6.72",
28
- "@dbx-tools/shared-genie": "0.6.72",
29
- "@dbx-tools/shared-mastra": "0.6.72",
30
- "@dbx-tools/shared-model": "0.6.72",
31
- "@dbx-tools/ui-appkit": "0.6.72",
32
- "@dbx-tools/ui-branding": "0.6.72",
27
+ "@dbx-tools/shared-core": "0.6.73",
28
+ "@dbx-tools/shared-genie": "0.6.73",
29
+ "@dbx-tools/shared-mastra": "0.6.73",
30
+ "@dbx-tools/shared-model": "0.6.73",
31
+ "@dbx-tools/ui-appkit": "0.6.73",
32
+ "@dbx-tools/ui-branding": "0.6.73",
33
33
  "@mastra/client-js": "^1.28.0",
34
34
  "@tanstack/react-table": "^8.21.3",
35
35
  "ai": "^5.0.0",
@@ -47,7 +47,7 @@
47
47
  "publishConfig": {
48
48
  "access": "public"
49
49
  },
50
- "version": "0.6.72",
50
+ "version": "0.6.73",
51
51
  "type": "module",
52
52
  "exports": {
53
53
  "./react": "./src/react/index.ts",
@@ -54,7 +54,7 @@ const _loadChatExport = () => import("../support/export.ts");
54
54
  // fresh stream Response we run through the same chunk handler.
55
55
  //
56
56
  // On mount the transcript hydrates with the most recent page of thread
57
- // history from the Mastra plugin's `/history` endpoint; scrolling near
57
+ // history from the Mastra plugin's `/route/history` endpoint; scrolling near
58
58
  // the top lazy-loads and prepends the next older page, with `ChatView`
59
59
  // preserving the visual scroll position across the prepend.
60
60
 
@@ -413,8 +413,11 @@ export const useMastraChat = (
413
413
  return ids;
414
414
  }, [sessionsTick]);
415
415
  const [isLoadingHistory, setIsLoadingHistory] = useState(true);
416
- const [isLoadingMore, setIsLoadingMore] = useState(false);
417
- const historyInFlightRef = useRef(false);
416
+ const [loadingMoreThreads, setLoadingMoreThreads] = useState<ReadonlySet<string>>(
417
+ () => new Set(),
418
+ );
419
+ const isLoadingMore = loadingMoreThreads.has(activeKey);
420
+ const historyInFlightRef = useRef(new Set<string>());
418
421
  const feedbackByMessageRef = useRef<Record<string, MessageFeedback>>({});
419
422
  feedbackByMessageRef.current = activeSession.feedbackByMessage;
420
423
  // Drains the next queued steer when a turn ends. Held in a ref because it
@@ -1159,7 +1162,7 @@ export const useMastraChat = (
1159
1162
 
1160
1163
  let cancelled = false;
1161
1164
  const controller = new AbortController();
1162
- historyInFlightRef.current = true;
1165
+ historyInFlightRef.current.add(threadId);
1163
1166
  setIsLoadingHistory(true);
1164
1167
  mastraClient
1165
1168
  .history({
@@ -1187,10 +1190,14 @@ export const useMastraChat = (
1187
1190
  logger.error("history load error", {
1188
1191
  error: errorUtil.errorMessage(error),
1189
1192
  });
1190
- updateSession(threadId, (current) => ({ ...current, hasMoreHistory: false }));
1193
+ updateSession(threadId, (current) => ({
1194
+ ...current,
1195
+ historyLoaded: true,
1196
+ hasMoreHistory: false,
1197
+ }));
1191
1198
  })
1192
1199
  .finally(() => {
1193
- historyInFlightRef.current = false;
1200
+ historyInFlightRef.current.delete(threadId);
1194
1201
  if (!cancelled) setIsLoadingHistory(false);
1195
1202
  });
1196
1203
  return () => {
@@ -1202,9 +1209,9 @@ export const useMastraChat = (
1202
1209
  const loadOlderHistory = useCallback(() => {
1203
1210
  const threadId = activeKey;
1204
1211
  const session = getSession(threadId);
1205
- if (historyInFlightRef.current || !session.hasMoreHistory) return;
1206
- historyInFlightRef.current = true;
1207
- setIsLoadingMore(true);
1212
+ if (historyInFlightRef.current.has(threadId) || !session.hasMoreHistory) return;
1213
+ historyInFlightRef.current.add(threadId);
1214
+ setLoadingMoreThreads((current) => new Set(current).add(threadId));
1208
1215
  const page = session.historyPage;
1209
1216
  updateSession(threadId, (current) => ({ ...current, historyPage: page + 1 }));
1210
1217
  mastraClient
@@ -1232,8 +1239,13 @@ export const useMastraChat = (
1232
1239
  }));
1233
1240
  })
1234
1241
  .finally(() => {
1235
- historyInFlightRef.current = false;
1236
- setIsLoadingMore(false);
1242
+ historyInFlightRef.current.delete(threadId);
1243
+ setLoadingMoreThreads((current) => {
1244
+ if (!current.has(threadId)) return current;
1245
+ const next = new Set(current);
1246
+ next.delete(threadId);
1247
+ return next;
1248
+ });
1237
1249
  });
1238
1250
  }, [activeKey, activeThreadId, getSession, mastraClient, agentId, updateSession, writeMessages]);
1239
1251
 
@@ -225,7 +225,7 @@ export class MastraPluginClient extends MastraClient {
225
225
  }
226
226
 
227
227
  /**
228
- * Fetch one page of thread history from `GET ${basePath}/history`.
228
+ * Fetch one page of thread history from `GET ${basePath}/route/history`.
229
229
  * Messages come back oldest -> newest so the caller can prepend them
230
230
  * to a live transcript. `threadId` targets a specific conversation
231
231
  * (sent as the `?threadId=` query so it doesn't depend on shared client
@@ -254,7 +254,7 @@ export class MastraPluginClient extends MastraClient {
254
254
  }
255
255
 
256
256
  /**
257
- * Wipe a thread's history (`DELETE ${basePath}/history`). `threadId`
257
+ * Wipe a thread's history (`DELETE ${basePath}/route/history`). `threadId`
258
258
  * targets a specific conversation via the thread-selection header (so it
259
259
  * doesn't depend on shared client state); omit it to clear the per-session
260
260
  * cookie thread. The session cookie that anchors the thread id is