@frankieai/react 0.2.4 → 0.2.6
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/frankie.css +1 -1
- package/dist/index.cjs +28 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/chat/FrankieChatPage.tsx +24 -4
- package/src/hooks/useFrankieChat.ts +10 -2
- package/src/styles/frankie.css +6 -1
- package/src/widget.test.tsx +34 -1
package/dist/index.js
CHANGED
|
@@ -346,8 +346,11 @@ function useFrankieChatState() {
|
|
|
346
346
|
messagesRef.current = restoredMessages;
|
|
347
347
|
setMessages(restoredMessages);
|
|
348
348
|
}
|
|
349
|
-
} catch {
|
|
350
|
-
if (active)
|
|
349
|
+
} catch (caught) {
|
|
350
|
+
if (active) {
|
|
351
|
+
const message = caught instanceof FrankieApiError ? caught.message : caught instanceof Error && caught.message.startsWith("Frankie") ? caught.message : "Could not restore this conversation. Check your sign-in and connection, then try opening it again.";
|
|
352
|
+
setError(message);
|
|
353
|
+
}
|
|
351
354
|
} finally {
|
|
352
355
|
if (active) setRestored(true);
|
|
353
356
|
}
|
|
@@ -1330,7 +1333,7 @@ function FrankieInline({ className, style, ...panelProps }) {
|
|
|
1330
1333
|
|
|
1331
1334
|
// src/components/chat/FrankieChatPage.tsx
|
|
1332
1335
|
import { useCallback as useCallback3, useEffect as useEffect6, useRef as useRef5, useState as useState7 } from "react";
|
|
1333
|
-
import { History, Menu, Plus as Plus2, Settings, X as X5 } from "lucide-react";
|
|
1336
|
+
import { ChevronsLeft, ChevronsRight, History, Menu, Plus as Plus2, Settings, X as X5 } from "lucide-react";
|
|
1334
1337
|
import { Fragment as Fragment3, jsx as jsx17, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1335
1338
|
function PageEmptyState() {
|
|
1336
1339
|
const { config } = useFrankie();
|
|
@@ -1357,6 +1360,13 @@ function PageChrome({ showHistory, navigation, currentId, onSelect, onNew, ...pa
|
|
|
1357
1360
|
const [historyError, setHistoryError] = useState7("");
|
|
1358
1361
|
const [historyLoading, setHistoryLoading] = useState7(false);
|
|
1359
1362
|
const [drawerOpen, setDrawerOpen] = useState7(false);
|
|
1363
|
+
const [collapsed, setCollapsed] = useState7(() => {
|
|
1364
|
+
try {
|
|
1365
|
+
return window.localStorage.getItem("frankie.history-collapsed") === "1";
|
|
1366
|
+
} catch {
|
|
1367
|
+
return false;
|
|
1368
|
+
}
|
|
1369
|
+
});
|
|
1360
1370
|
const [query, setQuery] = useState7("");
|
|
1361
1371
|
const dialog = useRef5(null);
|
|
1362
1372
|
const menu = useRef5(null);
|
|
@@ -1372,8 +1382,12 @@ function PageChrome({ showHistory, navigation, currentId, onSelect, onNew, ...pa
|
|
|
1372
1382
|
try {
|
|
1373
1383
|
const items = await client.listConversations();
|
|
1374
1384
|
if (version === requestVersion.current) setConversations(items);
|
|
1375
|
-
} catch {
|
|
1376
|
-
if (version
|
|
1385
|
+
} catch (caught) {
|
|
1386
|
+
if (version !== requestVersion.current) {
|
|
1387
|
+
} else {
|
|
1388
|
+
const message = caught instanceof FrankieApiError ? caught.message : caught instanceof Error && caught.message.startsWith("Frankie") ? caught.message : "History couldn\u2019t load. Check your sign-in and try again.";
|
|
1389
|
+
setHistoryError(message);
|
|
1390
|
+
}
|
|
1377
1391
|
} finally {
|
|
1378
1392
|
if (version === requestVersion.current) setHistoryLoading(false);
|
|
1379
1393
|
}
|
|
@@ -1384,6 +1398,12 @@ function PageChrome({ showHistory, navigation, currentId, onSelect, onNew, ...pa
|
|
|
1384
1398
|
requestVersion.current++;
|
|
1385
1399
|
};
|
|
1386
1400
|
}, [refresh, busy]);
|
|
1401
|
+
useEffect6(() => {
|
|
1402
|
+
try {
|
|
1403
|
+
window.localStorage.setItem("frankie.history-collapsed", collapsed ? "1" : "0");
|
|
1404
|
+
} catch {
|
|
1405
|
+
}
|
|
1406
|
+
}, [collapsed]);
|
|
1387
1407
|
useEffect6(() => {
|
|
1388
1408
|
const node = dialog.current;
|
|
1389
1409
|
if (drawerOpen) {
|
|
@@ -1429,7 +1449,10 @@ function PageChrome({ showHistory, navigation, currentId, onSelect, onNew, ...pa
|
|
|
1429
1449
|
navigation ? /* @__PURE__ */ jsx17("div", { className: "frankie-host-navigation", children: navigation }) : null
|
|
1430
1450
|
] });
|
|
1431
1451
|
return /* @__PURE__ */ jsxs7("div", { className: "frankie-page-shell" + (resolveMode(theme?.mode) === "dark" ? " dark" : ""), style: themeToCssVars(theme), children: [
|
|
1432
|
-
showHistory ? /* @__PURE__ */
|
|
1452
|
+
showHistory ? /* @__PURE__ */ jsxs7("aside", { className: "frankie-history-desktop" + (collapsed ? " frankie-history-collapsed" : ""), children: [
|
|
1453
|
+
/* @__PURE__ */ jsx17("button", { type: "button", className: "frankie-history-toggle", "aria-label": collapsed ? "Expand conversations" : "Collapse conversations", "aria-expanded": !collapsed, onClick: () => setCollapsed((value) => !value), children: collapsed ? /* @__PURE__ */ jsx17(ChevronsRight, { size: 16 }) : /* @__PURE__ */ jsx17(ChevronsLeft, { size: 16 }) }),
|
|
1454
|
+
collapsed ? null : history
|
|
1455
|
+
] }) : null,
|
|
1433
1456
|
/* @__PURE__ */ jsxs7("div", { className: "frankie-page-main", children: [
|
|
1434
1457
|
/* @__PURE__ */ jsxs7("header", { className: "frankie-page-header", children: [
|
|
1435
1458
|
/* @__PURE__ */ jsxs7("div", { children: [
|