@gram-ai/elements 1.20.1 → 1.20.2
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/dist/components/Chat/stories/ErrorBoundary.stories.d.ts +8 -0
- package/dist/components/assistant-ui/error-boundary.d.ts +28 -0
- package/dist/elements.cjs +42 -42
- package/dist/elements.cjs.map +1 -1
- package/dist/elements.css +1 -1
- package/dist/elements.js +5953 -5912
- package/dist/elements.js.map +1 -1
- package/dist/{index-DaF9fGY-.js → index-BwdTXSZG.js} +4 -3
- package/dist/{index-DaF9fGY-.js.map → index-BwdTXSZG.js.map} +1 -1
- package/dist/{index-B52U8PL6.cjs → index-D8g4LkEy.cjs} +3 -3
- package/dist/{index-B52U8PL6.cjs.map → index-D8g4LkEy.cjs.map} +1 -1
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.js +1 -1
- package/package.json +1 -1
- package/src/components/Chat/index.tsx +10 -2
- package/src/components/Chat/stories/ErrorBoundary.stories.tsx +221 -0
- package/src/components/assistant-ui/assistant-modal.tsx +4 -1
- package/src/components/assistant-ui/assistant-sidecar.tsx +4 -1
- package/src/components/assistant-ui/error-boundary.tsx +113 -0
- package/src/contexts/ElementsProvider.tsx +16 -1
|
@@ -173,6 +173,10 @@ const ElementsProviderWithApproval = ({
|
|
|
173
173
|
// but runtime is created using transport. The ref gets populated after runtime creation.
|
|
174
174
|
const runtimeRef = useRef<ReturnType<typeof useChatRuntime> | null>(null)
|
|
175
175
|
|
|
176
|
+
// Generate a stable chat ID for server-side persistence (when history is disabled)
|
|
177
|
+
// When history is enabled, the thread adapter manages chat IDs instead
|
|
178
|
+
const chatIdRef = useRef<string | null>(null)
|
|
179
|
+
|
|
176
180
|
// Create chat transport configuration
|
|
177
181
|
const transport = useMemo<ChatTransport<UIMessage>>(
|
|
178
182
|
() => ({
|
|
@@ -183,18 +187,29 @@ const ElementsProviderWithApproval = ({
|
|
|
183
187
|
throw new Error('Session is loading')
|
|
184
188
|
}
|
|
185
189
|
|
|
190
|
+
// Generate chat ID on first message if not already set
|
|
191
|
+
if (!chatIdRef.current) {
|
|
192
|
+
chatIdRef.current = crypto.randomUUID()
|
|
193
|
+
}
|
|
194
|
+
|
|
186
195
|
const context = runtimeRef.current?.thread.getModelContext()
|
|
187
196
|
const frontendTools = toAISDKTools(
|
|
188
197
|
getEnabledTools(context?.tools ?? {})
|
|
189
198
|
)
|
|
190
199
|
|
|
200
|
+
// Include Gram-Chat-ID header for chat persistence
|
|
201
|
+
const headersWithChatId = {
|
|
202
|
+
...auth.headers,
|
|
203
|
+
'Gram-Chat-ID': chatIdRef.current,
|
|
204
|
+
}
|
|
205
|
+
|
|
191
206
|
// Create OpenRouter model (only needed when not using custom model)
|
|
192
207
|
const openRouterModel = usingCustomModel
|
|
193
208
|
? null
|
|
194
209
|
: createOpenRouter({
|
|
195
210
|
baseURL: apiUrl,
|
|
196
211
|
apiKey: 'unused, but must be set',
|
|
197
|
-
headers:
|
|
212
|
+
headers: headersWithChatId,
|
|
198
213
|
})
|
|
199
214
|
|
|
200
215
|
if (config.languageModel) {
|