@tanstack/ai-octane 0.6.5 → 0.7.0

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/ai-octane",
3
- "version": "0.6.5",
3
+ "version": "0.7.0",
4
4
  "description": "Octane bindings for TanStack AI streaming chat, structured outputs, and media generation.",
5
5
  "author": "Dominic Gannaway",
6
6
  "license": "MIT",
@@ -48,11 +48,11 @@
48
48
  ],
49
49
  "//lint": "The .tsrx.d.ts companions are generated declaration emits of the .tsrx implementations, so they are not hand-formatted and are excluded from lint rather than edited in place (a regeneration would undo any fix).",
50
50
  "dependencies": {
51
- "@tanstack/ai-client": "0.36.2"
51
+ "@tanstack/ai-client": "0.38.0"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "octane": "^0.1.17",
55
- "@tanstack/ai": "^0.64.1"
55
+ "@tanstack/ai": "^0.65.1"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@octanejs/testing-library": "0.1.14",
@@ -63,7 +63,7 @@
63
63
  "octane": "0.1.17",
64
64
  "vite": "^8.2.1",
65
65
  "zod": "^4.2.0",
66
- "@tanstack/ai": "0.64.1"
66
+ "@tanstack/ai": "0.65.1"
67
67
  },
68
68
  "scripts": {
69
69
  "lint:fix": "oxlint src --type-aware --ignore-pattern '**/*.tsrx.d.ts' --fix",
package/src/types.ts CHANGED
@@ -95,6 +95,7 @@ export type UseChatOptions<
95
95
  | 'onSubscriptionChange'
96
96
  | 'onConnectionStatusChange'
97
97
  | 'onSessionGeneratingChange'
98
+ | 'onHydratingChange'
98
99
  | 'onQueueChange'
99
100
  | 'onResumeStateChange'
100
101
  | 'onRunIdChange'
@@ -301,6 +302,14 @@ interface BaseUseChatReturn<
301
302
  */
302
303
  sessionGenerating: boolean
303
304
 
305
+ /**
306
+ * Whether the chat is being rebuilt from persistence (the server hydrate, or
307
+ * an async storage adapter). While it is true, show a loading state instead
308
+ * of an empty chat. It turns false when the transcript is in place and any
309
+ * in-flight run is re-joined. From then on `isLoading` covers the stream.
310
+ */
311
+ isHydrating: boolean
312
+
304
313
  /**
305
314
  * Set messages manually
306
315
  */
package/src/use-chat.tsrx CHANGED
@@ -254,6 +254,11 @@ export function useChat<
254
254
  setSessionGenerating(isGenerating)
255
255
  })
256
256
  },
257
+ onHydratingChange: (nextIsHydrating: boolean) => {
258
+ runOrQueueForActiveInstance(() => {
259
+ setHydration({ client: instance, value: nextIsHydrating })
260
+ })
261
+ },
257
262
  ...(optionsRef.current.queue !== undefined && {
258
263
  queue: optionsRef.current.queue,
259
264
  }),
@@ -290,6 +295,17 @@ export function useChat<
290
295
  return { client: instance, initialization: initializationState }
291
296
  }, [clientId, syncResumeState])
292
297
 
298
+ // Seeded from the client so the first render already shows hydrating, not an
299
+ // empty chat. The constructor sets it without firing a callback. Tagged with
300
+ // its client: after a thread switch, the new client's value shows on the
301
+ // first render, before the effects sync it.
302
+ const [hydration, setHydration] = useState(() => ({
303
+ client,
304
+ value: client.getIsHydrating(),
305
+ }))
306
+ const isHydrating =
307
+ hydration.client === client ? hydration.value : client.getIsHydrating()
308
+
293
309
  useEffect(() => {
294
310
  activeClientRef.current = client
295
311
  try {
@@ -314,6 +330,7 @@ export function useChat<
314
330
  setMessages(clientMessages)
315
331
  }
316
332
  setHasOlderMessages(client.getHasOlderMessages())
333
+ setHydration({ client, value: client.getIsHydrating() })
317
334
  }, [client])
318
335
 
319
336
  // OCTANE DIVERGENCE: upstream captures the initial transport. ChatClient
@@ -586,6 +603,7 @@ export function useChat<
586
603
  isSubscribed,
587
604
  connectionStatus,
588
605
  sessionGenerating,
606
+ isHydrating,
589
607
  setMessages: setMessagesManually,
590
608
  clear,
591
609
  addToolResult,