@tanstack/ai-remix 0.2.0 → 0.3.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-remix",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Remix 3 bindings for TanStack AI streaming chat, structured outputs, and media generation.",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -46,11 +46,11 @@
46
46
  "README.md"
47
47
  ],
48
48
  "dependencies": {
49
- "@tanstack/ai-client": "^0.31.0"
49
+ "@tanstack/ai-client": "^0.32.0"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "remix": "^3.0.0-rc.1",
53
- "@tanstack/ai": "^0.53.0"
53
+ "@tanstack/ai": "^0.55.0"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/node": "^24.10.1",
@@ -59,7 +59,7 @@
59
59
  "remix": "^3.0.0-rc.1",
60
60
  "vite": "^8.2.1",
61
61
  "vitest": "^4.1.10",
62
- "@tanstack/ai": "0.53.0"
62
+ "@tanstack/ai": "0.55.0"
63
63
  },
64
64
  "scripts": {
65
65
  "lint:fix": "oxlint src --type-aware --fix",
@@ -83,6 +83,7 @@ export function createChat<
83
83
  ) {
84
84
  let messages = options.initialMessages || []
85
85
  let isLoading = false
86
+ let hasOlderMessages = false
86
87
  let error: Error | undefined
87
88
  let status: ChatClientState = 'ready'
88
89
  let isSubscribed = false
@@ -117,12 +118,20 @@ export function createChat<
117
118
  ...(options.initialMessages !== undefined && {
118
119
  initialMessages: options.initialMessages,
119
120
  }),
120
- ...(options.persistence
121
+ ...(options.persistence === true
121
122
  ? {
122
- persistence: options.persistence,
123
+ persistence: true,
123
124
  threadId,
125
+ ...(options.history !== undefined && {
126
+ history: options.history,
127
+ }),
124
128
  }
125
- : { threadId }),
129
+ : options.persistence
130
+ ? {
131
+ persistence: options.persistence,
132
+ threadId,
133
+ }
134
+ : { threadId }),
126
135
  ...(options.initialResumeSnapshot !== undefined && {
127
136
  initialResumeSnapshot: options.initialResumeSnapshot,
128
137
  }),
@@ -160,6 +169,7 @@ export function createChat<
160
169
  }),
161
170
  onMessagesChange: (newMessages: Array<UIMessage<TTools>>) => {
162
171
  messages = newMessages
172
+ hasOlderMessages = client.getHasOlderMessages()
163
173
  commit()
164
174
  },
165
175
  onLoadingChange: (newIsLoading: boolean) => {
@@ -264,6 +274,12 @@ export function createChat<
264
274
  }
265
275
  }
266
276
 
277
+ const loadOlderMessages = async () => {
278
+ await client.loadOlderMessages()
279
+ hasOlderMessages = client.getHasOlderMessages()
280
+ commit()
281
+ }
282
+
267
283
  const stop = () => {
268
284
  client.stop()
269
285
  }
@@ -359,6 +375,9 @@ export function createChat<
359
375
  get isLoading() {
360
376
  return isLoading
361
377
  },
378
+ get hasOlderMessages() {
379
+ return hasOlderMessages
380
+ },
362
381
  get error() {
363
382
  return error
364
383
  },
@@ -407,6 +426,7 @@ export function createChat<
407
426
  cancelQueued,
408
427
  append,
409
428
  reload,
429
+ loadOlderMessages,
410
430
  stop,
411
431
  setMessages,
412
432
  clear,
package/src/types.ts CHANGED
@@ -270,6 +270,16 @@ interface BaseCreateChatReturn<
270
270
  */
271
271
  isLoading: boolean
272
272
 
273
+ /**
274
+ * True when the last hydrate or older-page response said more messages exist.
275
+ */
276
+ hasOlderMessages: boolean
277
+
278
+ /**
279
+ * Fetch the next older window and put it in front of the painted messages.
280
+ */
281
+ loadOlderMessages: () => Promise<void>
282
+
273
283
  /**
274
284
  * Current error, if any
275
285
  */