@finogeeks2026/chatkit-web 0.0.11 → 0.0.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.
Files changed (2) hide show
  1. package/dist/index.js +21 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -680,11 +680,14 @@ const Ui = (e) => {
680
680
  currentSessionId: null,
681
681
  isLoading: !1,
682
682
  createSession: (n = "新对话") => {
683
- const r = dn();
684
- return r.title = n, e((i) => ({
685
- sessions: [r, ...i.sessions],
686
- currentSessionId: r.id
687
- })), r.id;
683
+ const r = t(), i = r.currentSessionId ? r.sessions.find((o) => o.id === r.currentSessionId) : null;
684
+ if (i && i.messages.length === 0)
685
+ return i.id;
686
+ const a = dn();
687
+ return a.title = n, e((o) => ({
688
+ sessions: [a, ...o.sessions],
689
+ currentSessionId: a.id
690
+ })), a.id;
688
691
  },
689
692
  switchSession: (n) => {
690
693
  t().sessions.some((r) => r.id === n) && e({ currentSessionId: n });
@@ -991,15 +994,22 @@ async function tc() {
991
994
  Ql(),
992
995
  ec()
993
996
  ]);
994
- t.length > 0 && Ne.setState({
995
- sessions: t,
996
- currentSessionId: n || ((e = t[0]) == null ? void 0 : e.id) || null
997
- });
997
+ if (t.length > 0) {
998
+ const r = n && t.some((i) => i.id === n) ? n : ((e = t[0]) == null ? void 0 : e.id) ?? null;
999
+ Ne.setState({
1000
+ sessions: t,
1001
+ currentSessionId: r
1002
+ });
1003
+ }
998
1004
  } catch (t) {
999
1005
  console.warn("[chatkit-store] Failed to load from IndexedDB:", t);
1000
1006
  }
1001
1007
  At == null || At(), At = Ne.subscribe((t) => {
1002
- Zl(t.sessions).catch(console.warn), Jl(t.currentSessionId).catch(console.warn);
1008
+ var a;
1009
+ const n = t.sessions.filter((o) => o.messages.length > 0);
1010
+ Zl(n).catch(console.warn);
1011
+ const i = t.currentSessionId && t.sessions.some((o) => o.id === t.currentSessionId && o.messages.length > 0) ? t.currentSessionId : ((a = n[0]) == null ? void 0 : a.id) ?? null;
1012
+ Jl(i).catch(console.warn);
1003
1013
  });
1004
1014
  }
1005
1015
  function ly() {
@@ -24947,7 +24957,7 @@ const fy = Et("Headphones", [
24947
24957
  overflowY: "auto",
24948
24958
  backgroundColor: "transparent",
24949
24959
  color: "var(--chatkit-text-primary)",
24950
- fontSize: 15,
24960
+ fontSize: 16,
24951
24961
  fontFamily: "inherit",
24952
24962
  lineHeight: 1.5,
24953
24963
  boxSizing: "border-box",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finogeeks2026/chatkit-web",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "面向 Web / H5 的 AI 对话 UI SDK,支持流式对话、多会话管理、主题定制",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",