@lota-sdk/ui 0.1.11 → 0.1.13

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": "@lota-sdk/ui",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -12,21 +12,6 @@
12
12
  "bun": "./src/index.ts",
13
13
  "import": "./src/index.ts",
14
14
  "types": "./src/index.ts"
15
- },
16
- "./chat/*": {
17
- "bun": "./src/chat/*.ts",
18
- "import": "./src/chat/*.ts",
19
- "types": "./src/chat/*.ts"
20
- },
21
- "./runtime/*": {
22
- "bun": "./src/runtime/*.ts",
23
- "import": "./src/runtime/*.ts",
24
- "types": "./src/runtime/*.ts"
25
- },
26
- "./tools/*": {
27
- "bun": "./src/tools/*.ts",
28
- "import": "./src/tools/*.ts",
29
- "types": "./src/tools/*.ts"
30
15
  }
31
16
  },
32
17
  "scripts": {
@@ -40,7 +25,7 @@
40
25
  "registry": "https://registry.npmjs.org/"
41
26
  },
42
27
  "dependencies": {
43
- "@lota-sdk/shared": "0.1.9",
28
+ "@lota-sdk/shared": "0.1.13",
44
29
  "ai": "^6.0.116"
45
30
  },
46
31
  "peerDependencies": {
@@ -3,7 +3,7 @@ import {
3
3
  ATTACHMENT_MAX_TOTAL_SIZE_BYTES,
4
4
  inferContentType,
5
5
  isSupportedAttachment,
6
- } from '@lota-sdk/shared/constants/attachments'
6
+ } from '@lota-sdk/shared'
7
7
  import type { FileUIPart } from 'ai'
8
8
 
9
9
  type UploadedAttachmentPayload = {
@@ -1,4 +1,4 @@
1
- import { getMessageCreatedAt, withMessageCreatedAt } from '@lota-sdk/shared/runtime/chat-message-metadata'
1
+ import { getMessageCreatedAt, withMessageCreatedAt } from '@lota-sdk/shared'
2
2
 
3
3
  interface TimestampedMessage {
4
4
  id: string
@@ -1,4 +1,4 @@
1
- import { getMessageCreatedAt } from '@lota-sdk/shared/runtime/chat-message-metadata'
1
+ import { getMessageCreatedAt } from '@lota-sdk/shared'
2
2
  import type { FileUIPart, UIMessage } from 'ai'
3
3
  import { useCallback, useEffect, useMemo, useRef } from 'react'
4
4
 
@@ -64,6 +64,8 @@ export function useThreadChat<UI_MESSAGE extends UIMessage>({
64
64
  setThreadRunningStateRef.current = setThreadRunningState
65
65
  }, [setThreadRunningState])
66
66
 
67
+ const chatId = threadId ? `${idPrefix}:${threadId}` : `${idPrefix}:none`
68
+
67
69
  const {
68
70
  messages,
69
71
  status,
@@ -74,13 +76,13 @@ export function useThreadChat<UI_MESSAGE extends UIMessage>({
74
76
  stop: stopChatStream,
75
77
  setMessages,
76
78
  addToolApprovalResponse,
79
+ resumeStream,
77
80
  } = useChat<UI_MESSAGE>({
78
- id: threadId ? `${idPrefix}:${threadId}` : `${idPrefix}:none`,
81
+ id: chatId,
79
82
  transport,
80
83
  messages: initialMessages,
81
84
  messageMetadataSchema,
82
85
  dataPartSchemas,
83
- resume,
84
86
  experimental_throttle: experimentalThrottle,
85
87
  sendAutomaticallyWhen,
86
88
  onFinish: () => {
@@ -96,6 +98,16 @@ export function useThreadChat<UI_MESSAGE extends UIMessage>({
96
98
  },
97
99
  })
98
100
 
101
+ // Manual resume with ref guard — prevents React StrictMode double-fire.
102
+ // We do NOT pass `resume` to useChat because the AI SDK's built-in effect
103
+ // has no StrictMode guard, causing two concurrent GET streams.
104
+ const resumedForChatRef = useRef<string | null>(null)
105
+ useEffect(() => {
106
+ if (!resume || resumedForChatRef.current === chatId) return
107
+ resumedForChatRef.current = chatId
108
+ void resumeStream()
109
+ }, [resume, chatId, resumeStream])
110
+
99
111
  const stop = useCallback(async () => {
100
112
  const stopRequest = threadId && stopRemoteRun ? stopRemoteRun(threadId) : Promise.resolve(null)
101
113
  const [stopResponse] = await Promise.allSettled([stopRequest, stopChatStream()])
@@ -1,5 +1,4 @@
1
- import type { SerializablePlanNode } from '@lota-sdk/shared/schemas/execution-plan'
2
- import type { ExecutionPlanToolResultData } from '@lota-sdk/shared/schemas/tools'
1
+ import type { ExecutionPlanToolResultData, SerializablePlanNode } from '@lota-sdk/shared'
3
2
 
4
3
  export function getLatestExecutionPlanResult(output: unknown): ExecutionPlanToolResultData | null {
5
4
  if (output && typeof output === 'object' && 'hasPlan' in output) {
@@ -1,4 +1,4 @@
1
- import type { UserQuestionItem, UserQuestionsArgs } from '@lota-sdk/shared/schemas/tools'
1
+ import type { UserQuestionItem, UserQuestionsArgs } from '@lota-sdk/shared'
2
2
 
3
3
  export type UserQuestionAnswer = { selected: string[]; customText: string }
4
4
  export type UserQuestionsSubmitPayload = {