@ai-sdk/react 0.0.35 → 0.0.36

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @ai-sdk/react@0.0.35 build /home/runner/work/ai/ai/packages/react
2
+ > @ai-sdk/react@0.0.36 build /home/runner/work/ai/ai/packages/react
3
3
  > tsup
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -11,11 +11,11 @@
11
11
  ESM Build start
12
12
  ESM dist/index.mjs 25.67 KB
13
13
  ESM dist/index.mjs.map 55.92 KB
14
- ESM ⚡️ Build success in 64ms
14
+ ESM ⚡️ Build success in 58ms
15
15
  CJS dist/index.js 28.14 KB
16
16
  CJS dist/index.js.map 56.00 KB
17
- CJS ⚡️ Build success in 79ms
17
+ CJS ⚡️ Build success in 60ms
18
18
  DTS Build start
19
- DTS ⚡️ Build success in 5307ms
19
+ DTS ⚡️ Build success in 5664ms
20
20
  DTS dist/index.d.ts 10.97 KB
21
21
  DTS dist/index.d.mts 10.97 KB
@@ -1,4 +1,4 @@
1
1
 
2
- > @ai-sdk/react@0.0.35 clean /home/runner/work/ai/ai/packages/react
2
+ > @ai-sdk/react@0.0.36 clean /home/runner/work/ai/ai/packages/react
3
3
  > rm -rf dist
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @ai-sdk/react
2
2
 
3
+ ## 0.0.36
4
+
5
+ ### Patch Changes
6
+
7
+ - 5be25124: fix (ai/ui): useChat messages have stable ids with streamProtocol: "text"
8
+ - Updated dependencies [5be25124]
9
+ - @ai-sdk/ui-utils@0.0.24
10
+
3
11
  ## 0.0.35
4
12
 
5
13
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/react",
3
- "version": "0.0.35",
3
+ "version": "0.0.36",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@ai-sdk/provider-utils": "1.0.5",
19
- "@ai-sdk/ui-utils": "0.0.23",
19
+ "@ai-sdk/ui-utils": "0.0.24",
20
20
  "swr": "2.2.5"
21
21
  },
22
22
  "devDependencies": {
@@ -265,8 +265,11 @@ describe('text stream', () => {
265
265
  <div>
266
266
  {messages.map((m, idx) => (
267
267
  <div data-testid={`message-${idx}-text-stream`} key={m.id}>
268
- {m.role === 'user' ? 'User: ' : 'AI: '}
269
- {m.content}
268
+ <div data-testid={`message-${idx}-id`}>{m.id}</div>
269
+ <div data-testid={`message-${idx}-role`}>
270
+ {m.role === 'user' ? 'User: ' : 'AI: '}
271
+ </div>
272
+ <div data-testid={`message-${idx}-content`}>{m.content}</div>
270
273
  </div>
271
274
  ))}
272
275
 
@@ -302,15 +305,39 @@ describe('text stream', () => {
302
305
  async () => {
303
306
  await userEvent.click(screen.getByTestId('do-append-text-stream'));
304
307
 
305
- await screen.findByTestId('message-0-text-stream');
306
- expect(screen.getByTestId('message-0-text-stream')).toHaveTextContent(
307
- 'User: hi',
308
+ await screen.findByTestId('message-0-content');
309
+ expect(screen.getByTestId('message-0-content')).toHaveTextContent('hi');
310
+
311
+ await screen.findByTestId('message-1-content');
312
+ expect(screen.getByTestId('message-1-content')).toHaveTextContent(
313
+ 'Hello, world.',
308
314
  );
315
+ },
316
+ ),
317
+ );
309
318
 
310
- await screen.findByTestId('message-1-text-stream');
311
- expect(screen.getByTestId('message-1-text-stream')).toHaveTextContent(
312
- 'AI: Hello, world.',
319
+ it(
320
+ 'should have stable message ids',
321
+ withTestServer(
322
+ { url: '/api/chat', type: 'controlled-stream' },
323
+ async ({ streamController }) => {
324
+ streamController.enqueue('He');
325
+
326
+ await userEvent.click(screen.getByTestId('do-append-text-stream'));
327
+
328
+ await screen.findByTestId('message-1-content');
329
+ expect(screen.getByTestId('message-1-content')).toHaveTextContent('He');
330
+
331
+ const id = screen.getByTestId('message-1-id').textContent;
332
+
333
+ streamController.enqueue('llo');
334
+ streamController.close();
335
+
336
+ await screen.findByTestId('message-1-content');
337
+ expect(screen.getByTestId('message-1-content')).toHaveTextContent(
338
+ 'Hello',
313
339
  );
340
+ expect(screen.getByTestId('message-1-id').textContent).toBe(id);
314
341
  },
315
342
  ),
316
343
  );