@frankieai/react 0.2.4 → 0.2.5
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/index.cjs +11 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/chat/FrankieChatPage.tsx +11 -2
- package/src/hooks/useFrankieChat.ts +10 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frankieai/react",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Embeddable, themeable chat widget for the Frankie onboarding agent — shadcn/ui components, works with or without Tailwind in the host app.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -6,7 +6,7 @@ import type { FrankieProviderProps } from "../../hooks/FrankieProvider.jsx";
|
|
|
6
6
|
import { FrankieProvider, useFrankie, useFrankieTheme } from "../../hooks/FrankieProvider.jsx";
|
|
7
7
|
import { useFrankieChat } from "../../hooks/useFrankieChat.js";
|
|
8
8
|
import { themeToCssVars, resolveMode } from "../../lib/theme.js";
|
|
9
|
-
import type
|
|
9
|
+
import { FrankieApiError, type ChatConversation } from "../../lib/client.js";
|
|
10
10
|
import { FrankieInline } from "./FrankieInline.js";
|
|
11
11
|
import type { ChatPanelProps } from "./ChatPanel.js";
|
|
12
12
|
|
|
@@ -48,7 +48,16 @@ function PageChrome({ showHistory, navigation, currentId, onSelect, onNew, ...pa
|
|
|
48
48
|
const version = ++requestVersion.current;
|
|
49
49
|
setHistoryLoading(true); setHistoryError("");
|
|
50
50
|
try { const items = await client.listConversations(); if (version === requestVersion.current) setConversations(items); }
|
|
51
|
-
catch
|
|
51
|
+
catch (caught) {
|
|
52
|
+
if (version !== requestVersion.current) { /* superseded by a newer request */ }
|
|
53
|
+
else {
|
|
54
|
+
const message =
|
|
55
|
+
caught instanceof FrankieApiError ? caught.message
|
|
56
|
+
: caught instanceof Error && caught.message.startsWith("Frankie") ? caught.message
|
|
57
|
+
: "History couldn’t load. Check your sign-in and try again.";
|
|
58
|
+
setHistoryError(message);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
52
61
|
finally { if (version === requestVersion.current) setHistoryLoading(false); }
|
|
53
62
|
}, [client, showHistory, config?.allowAnonymous]);
|
|
54
63
|
useEffect(() => { if (!busy) void refresh(); return () => { requestVersion.current++; }; }, [refresh, busy]);
|
|
@@ -91,8 +91,16 @@ export function useFrankieChatState(): UseFrankieChatResult {
|
|
|
91
91
|
messagesRef.current = restoredMessages;
|
|
92
92
|
setMessages(restoredMessages);
|
|
93
93
|
}
|
|
94
|
-
} catch {
|
|
95
|
-
if (active)
|
|
94
|
+
} catch (caught) {
|
|
95
|
+
if (active) {
|
|
96
|
+
const message =
|
|
97
|
+
caught instanceof FrankieApiError
|
|
98
|
+
? caught.message
|
|
99
|
+
: caught instanceof Error && caught.message.startsWith("Frankie")
|
|
100
|
+
? caught.message
|
|
101
|
+
: "Could not restore this conversation. Check your sign-in and connection, then try opening it again.";
|
|
102
|
+
setError(message);
|
|
103
|
+
}
|
|
96
104
|
} finally {
|
|
97
105
|
if (active) setRestored(true);
|
|
98
106
|
}
|