@wallavi/widget 1.6.7 → 1.6.8

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.js CHANGED
@@ -125,7 +125,7 @@ function useChat({
125
125
  const [streaming, setStreaming] = react.useState(false);
126
126
  const [threadId, setThreadId] = react.useState(() => {
127
127
  if (persistKey && typeof window !== "undefined") {
128
- const saved = sessionStorage.getItem(`${persistKey}_tid`);
128
+ const saved = localStorage.getItem(`${persistKey}_tid`);
129
129
  if (saved) return saved;
130
130
  }
131
131
  return crypto.randomUUID();
@@ -141,10 +141,31 @@ function useChat({
141
141
  react.useEffect(() => {
142
142
  if (!persistKey) return;
143
143
  try {
144
- sessionStorage.setItem(`${persistKey}_tid`, threadId);
144
+ localStorage.setItem(`${persistKey}_tid`, threadId);
145
145
  } catch {
146
146
  }
147
147
  }, [persistKey, threadId]);
148
+ react.useEffect(() => {
149
+ if (!persistKey || typeof window === "undefined") return;
150
+ if (messages.length > 0) return;
151
+ void (async () => {
152
+ try {
153
+ const res = await fetch(
154
+ `${API_URL}/api/chat/messages?agentId=${encodeURIComponent(agentId)}&threadId=${encodeURIComponent(threadId)}`
155
+ );
156
+ if (!res.ok) return;
157
+ const { data } = await res.json();
158
+ if (!data?.length) return;
159
+ const restored = data.map((m) => ({
160
+ id: m.id,
161
+ role: m.role,
162
+ parts: m.parts.filter((p) => p?.type)
163
+ })).filter((m) => m.parts.length > 0);
164
+ if (restored.length > 0) setMessages(restored);
165
+ } catch {
166
+ }
167
+ })();
168
+ }, []);
148
169
  const reset = react.useCallback(() => {
149
170
  setMessages([]);
150
171
  setInput("");
@@ -155,6 +176,7 @@ function useChat({
155
176
  try {
156
177
  sessionStorage.removeItem(`${persistKey}_msgs`);
157
178
  sessionStorage.removeItem(`${persistKey}_tid`);
179
+ localStorage.removeItem(`${persistKey}_tid`);
158
180
  } catch {
159
181
  }
160
182
  }
@@ -1286,7 +1308,7 @@ function ChatWidget({
1286
1308
  suggestedMessages = [],
1287
1309
  messagePlaceholder,
1288
1310
  watermark = true,
1289
- watermarkLogoUrl = "https:ww-//app.wallavi.com/wallavi.svg",
1311
+ watermarkLogoUrl = "https://app.wallavi.com/wallavi.svg",
1290
1312
  footer,
1291
1313
  theme,
1292
1314
  showThinking = false,
@@ -1452,7 +1474,7 @@ function ChatWidget({
1452
1474
  /* @__PURE__ */ jsxRuntime.jsxs(
1453
1475
  "a",
1454
1476
  {
1455
- href: "https:ww-//wallavi.com",
1477
+ href: "https://wallavi.com",
1456
1478
  target: "_blank",
1457
1479
  rel: "noopener noreferrer",
1458
1480
  className: "ww-flex ww-items-center ww-gap-1 ww-text-[10px] ww-text-muted-foreground hover:ww-text-foreground ww-transition-colors",
package/dist/index.mjs CHANGED
@@ -99,7 +99,7 @@ function useChat({
99
99
  const [streaming, setStreaming] = useState(false);
100
100
  const [threadId, setThreadId] = useState(() => {
101
101
  if (persistKey && typeof window !== "undefined") {
102
- const saved = sessionStorage.getItem(`${persistKey}_tid`);
102
+ const saved = localStorage.getItem(`${persistKey}_tid`);
103
103
  if (saved) return saved;
104
104
  }
105
105
  return crypto.randomUUID();
@@ -115,10 +115,31 @@ function useChat({
115
115
  useEffect(() => {
116
116
  if (!persistKey) return;
117
117
  try {
118
- sessionStorage.setItem(`${persistKey}_tid`, threadId);
118
+ localStorage.setItem(`${persistKey}_tid`, threadId);
119
119
  } catch {
120
120
  }
121
121
  }, [persistKey, threadId]);
122
+ useEffect(() => {
123
+ if (!persistKey || typeof window === "undefined") return;
124
+ if (messages.length > 0) return;
125
+ void (async () => {
126
+ try {
127
+ const res = await fetch(
128
+ `${API_URL}/api/chat/messages?agentId=${encodeURIComponent(agentId)}&threadId=${encodeURIComponent(threadId)}`
129
+ );
130
+ if (!res.ok) return;
131
+ const { data } = await res.json();
132
+ if (!data?.length) return;
133
+ const restored = data.map((m) => ({
134
+ id: m.id,
135
+ role: m.role,
136
+ parts: m.parts.filter((p) => p?.type)
137
+ })).filter((m) => m.parts.length > 0);
138
+ if (restored.length > 0) setMessages(restored);
139
+ } catch {
140
+ }
141
+ })();
142
+ }, []);
122
143
  const reset = useCallback(() => {
123
144
  setMessages([]);
124
145
  setInput("");
@@ -129,6 +150,7 @@ function useChat({
129
150
  try {
130
151
  sessionStorage.removeItem(`${persistKey}_msgs`);
131
152
  sessionStorage.removeItem(`${persistKey}_tid`);
153
+ localStorage.removeItem(`${persistKey}_tid`);
132
154
  } catch {
133
155
  }
134
156
  }
@@ -1260,7 +1282,7 @@ function ChatWidget({
1260
1282
  suggestedMessages = [],
1261
1283
  messagePlaceholder,
1262
1284
  watermark = true,
1263
- watermarkLogoUrl = "https:ww-//app.wallavi.com/wallavi.svg",
1285
+ watermarkLogoUrl = "https://app.wallavi.com/wallavi.svg",
1264
1286
  footer,
1265
1287
  theme,
1266
1288
  showThinking = false,
@@ -1426,7 +1448,7 @@ function ChatWidget({
1426
1448
  /* @__PURE__ */ jsxs(
1427
1449
  "a",
1428
1450
  {
1429
- href: "https:ww-//wallavi.com",
1451
+ href: "https://wallavi.com",
1430
1452
  target: "_blank",
1431
1453
  rel: "noopener noreferrer",
1432
1454
  className: "ww-flex ww-items-center ww-gap-1 ww-text-[10px] ww-text-muted-foreground hover:ww-text-foreground ww-transition-colors",
package/package.json CHANGED
@@ -24,7 +24,8 @@
24
24
  "import": "./dist/index.mjs",
25
25
  "require": "./dist/index.js",
26
26
  "types": "./dist/index.d.ts"
27
- }
27
+ },
28
+ "./styles.css": "./dist/styles.css"
28
29
  },
29
30
  "files": [
30
31
  "dist"
@@ -37,9 +38,12 @@
37
38
  },
38
39
  "private": false,
39
40
  "types": "./dist/index.d.ts",
40
- "version": "1.6.7",
41
+ "version": "1.6.8",
41
42
  "scripts": {
42
- "build": "tsup",
43
+ "build": "pnpm build:css && tsup",
44
+ "build:css": "tailwindcss -i ./src/styles.css -o ./dist/styles.css --config tailwind.config.cjs --minify",
45
+ "dev": "tailwindcss -i ./src/styles.css -o ./dist/styles.css --config tailwind.config.cjs --watch",
46
+ "dev:css": "tailwindcss -i ./src/styles.css -o ./dist/styles.css --config tailwind.config.cjs --watch",
43
47
  "typecheck": "tsc --noEmit"
44
48
  },
45
49
  "module": "./dist/index.mjs"