teodor-new-chat-ui 3.0.12 → 3.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.
- package/dist/index.esm.js +138 -134
- package/dist/index.umd.js +5 -5
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -2269,24 +2269,24 @@ function Un({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
2269
2269
|
}), [g, m] = re(() => typeof l.getAuthToken == "function" ? l.getAuthToken() : null);
|
|
2270
2270
|
ge(() => {
|
|
2271
2271
|
v(typeof l.getAuthToken == "function" ? l.getAuthToken() : null);
|
|
2272
|
-
const
|
|
2273
|
-
m(
|
|
2272
|
+
const J = l.onTokenChange((X) => {
|
|
2273
|
+
m(X), v(X);
|
|
2274
2274
|
});
|
|
2275
2275
|
return () => {
|
|
2276
|
-
|
|
2276
|
+
J();
|
|
2277
2277
|
};
|
|
2278
2278
|
}, [l, v]);
|
|
2279
|
-
const b = ve((
|
|
2280
|
-
l.setAuthToken(
|
|
2279
|
+
const b = ve((J) => {
|
|
2280
|
+
l.setAuthToken(J);
|
|
2281
2281
|
}, [l]), { state: w, seed: x, prepend: y, pushUser: C, onEvent: R, reset: _ } = hp(), N = s && s > 0 ? s : 6, [k, L] = re(!1), [I, $] = re(!1), [K, B] = re(null), [M, H] = re(void 0), O = ve(
|
|
2282
|
-
(
|
|
2283
|
-
const he = Array.isArray(
|
|
2284
|
-
|
|
2282
|
+
(J, X) => {
|
|
2283
|
+
const he = Array.isArray(J == null ? void 0 : J.messages) ? J.messages : [];
|
|
2284
|
+
X === "replace" ? x(he) : X === "prepend" && he.length && y(he), B((J == null ? void 0 : J.nextCursor) ?? null), L(!!(J != null && J.hasMore)), H((Oe) => (J == null ? void 0 : J.checkpointId) ?? Oe ?? void 0);
|
|
2285
2285
|
},
|
|
2286
2286
|
[x, y]
|
|
2287
2287
|
), [G, D] = re([]), [T, Q] = re(null), q = ve(async () => {
|
|
2288
|
-
const
|
|
2289
|
-
D(
|
|
2288
|
+
const J = await l.listThreads();
|
|
2289
|
+
D(J);
|
|
2290
2290
|
}, [l]);
|
|
2291
2291
|
ge(() => {
|
|
2292
2292
|
q().catch(() => {
|
|
@@ -2300,46 +2300,50 @@ function Un({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
2300
2300
|
}));
|
|
2301
2301
|
}, [o]);
|
|
2302
2302
|
const F = Te(null), j = ve(
|
|
2303
|
-
async (
|
|
2304
|
-
if (F.current !==
|
|
2305
|
-
F.current =
|
|
2303
|
+
async (J, X, he) => {
|
|
2304
|
+
if (F.current !== J) {
|
|
2305
|
+
F.current = J;
|
|
2306
2306
|
try {
|
|
2307
2307
|
L(!1), B(null), H(void 0);
|
|
2308
2308
|
const Oe = await l.getMessages({
|
|
2309
|
-
threadId:
|
|
2310
|
-
checkpointId:
|
|
2309
|
+
threadId: J,
|
|
2310
|
+
checkpointId: X,
|
|
2311
2311
|
checkpointNs: he,
|
|
2312
2312
|
limit: N
|
|
2313
2313
|
});
|
|
2314
|
-
Q(
|
|
2314
|
+
Q(J), O(Oe, "replace");
|
|
2315
2315
|
} finally {
|
|
2316
2316
|
F.current = null;
|
|
2317
2317
|
}
|
|
2318
2318
|
}
|
|
2319
2319
|
},
|
|
2320
2320
|
[l, O]
|
|
2321
|
-
), ce = ve(async (
|
|
2321
|
+
), ce = ve(async (J) => {
|
|
2322
|
+
console.log("ChatProvider debug - listCheckpoints called for threadId:", J);
|
|
2323
|
+
const X = await l.listCheckpoints(J);
|
|
2324
|
+
return console.log("ChatProvider debug - listCheckpoints result:", X), X;
|
|
2325
|
+
}, [l]), pe = ve(async (J) => {
|
|
2322
2326
|
if (!T) throw new Error("No active thread");
|
|
2323
2327
|
L(!1), B(null), H(void 0);
|
|
2324
|
-
const
|
|
2328
|
+
const X = await l.getMessages({
|
|
2325
2329
|
threadId: T,
|
|
2326
|
-
checkpointId:
|
|
2330
|
+
checkpointId: J,
|
|
2327
2331
|
limit: N
|
|
2328
2332
|
});
|
|
2329
|
-
O(
|
|
2333
|
+
O(X, "replace");
|
|
2330
2334
|
}, [l, T, O, N]), z = ve(async () => {
|
|
2331
2335
|
if (!T) throw new Error("No active thread");
|
|
2332
2336
|
await j(T);
|
|
2333
2337
|
}, [T, j]), W = Te(!1);
|
|
2334
2338
|
ge(() => {
|
|
2335
|
-
const
|
|
2336
|
-
if (W.current = f,
|
|
2337
|
-
const
|
|
2339
|
+
const J = W.current;
|
|
2340
|
+
if (W.current = f, J && !f && T) {
|
|
2341
|
+
const X = w.lastCheckpointId ?? void 0;
|
|
2338
2342
|
(async () => {
|
|
2339
2343
|
try {
|
|
2340
2344
|
const he = await l.getMessages({
|
|
2341
2345
|
threadId: T,
|
|
2342
|
-
checkpointId:
|
|
2346
|
+
checkpointId: X,
|
|
2343
2347
|
limit: N
|
|
2344
2348
|
});
|
|
2345
2349
|
O(he, "replace");
|
|
@@ -2352,14 +2356,14 @@ function Un({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
2352
2356
|
})();
|
|
2353
2357
|
}
|
|
2354
2358
|
}, [f, T, w.lastCheckpointId, l, O, q]);
|
|
2355
|
-
const oe = ve(async (
|
|
2356
|
-
const
|
|
2357
|
-
return await q(), await j(
|
|
2358
|
-
}, [l, q, j]), V = ve(async (
|
|
2359
|
-
await l.deleteThread(
|
|
2360
|
-
}, [l, q, T, _]),
|
|
2361
|
-
await l.updateThread(
|
|
2362
|
-
}, [l, q]), te = ve(async (
|
|
2359
|
+
const oe = ve(async (J) => {
|
|
2360
|
+
const X = await l.createThread(J);
|
|
2361
|
+
return await q(), await j(X.threadId), X.threadId;
|
|
2362
|
+
}, [l, q, j]), V = ve(async (J) => {
|
|
2363
|
+
await l.deleteThread(J), await q(), T === J && (Q(null), _([]), L(!1), B(null), H(void 0));
|
|
2364
|
+
}, [l, q, T, _]), Y = ve(async (J, X) => {
|
|
2365
|
+
await l.updateThread(J, X), await q();
|
|
2366
|
+
}, [l, q]), te = ve(async (J, X) => {
|
|
2363
2367
|
var En;
|
|
2364
2368
|
async function he(se) {
|
|
2365
2369
|
return await new Promise((xe, Ne) => {
|
|
@@ -2384,8 +2388,8 @@ function Un({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
2384
2388
|
});
|
|
2385
2389
|
}
|
|
2386
2390
|
const Ce = [];
|
|
2387
|
-
|
|
2388
|
-
const Xt = (
|
|
2391
|
+
J && Ce.push({ type: "text", text: J });
|
|
2392
|
+
const Xt = (X == null ? void 0 : X.attachments) || [];
|
|
2389
2393
|
let st = [];
|
|
2390
2394
|
if (Xt.length > 0)
|
|
2391
2395
|
for (const se of Xt)
|
|
@@ -2423,13 +2427,13 @@ function Un({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
2423
2427
|
role: "user",
|
|
2424
2428
|
content: Ce,
|
|
2425
2429
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2426
|
-
checkpointId: (
|
|
2430
|
+
checkpointId: (X == null ? void 0 : X.checkpointId) ?? w.lastCheckpointId ?? void 0
|
|
2427
2431
|
};
|
|
2428
2432
|
C(Tt);
|
|
2429
2433
|
const Hr = {
|
|
2430
2434
|
...Tt,
|
|
2431
2435
|
content: Tt.content.filter((se) => se.type === "text" || se.type === "image_url")
|
|
2432
|
-
}, At = { ...(
|
|
2436
|
+
}, At = { ...(X == null ? void 0 : X.payloadExtras) ?? {} }, zr = !!At.edit, Sn = At.originalMessageId, Cn = typeof Sn == "string" ? Sn : void 0, Wr = (X == null ? void 0 : X.attachments) && X.attachments.length > 0, Yt = {
|
|
2433
2437
|
...T ? { threadId: T } : {},
|
|
2434
2438
|
payload: {
|
|
2435
2439
|
messages: [Hr],
|
|
@@ -2438,10 +2442,10 @@ function Un({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
2438
2442
|
...a && Wr && i ? { agent_id: i } : {},
|
|
2439
2443
|
...At
|
|
2440
2444
|
},
|
|
2441
|
-
checkpointId: (
|
|
2442
|
-
checkpointNs:
|
|
2443
|
-
nodeFilter:
|
|
2444
|
-
config:
|
|
2445
|
+
checkpointId: (X == null ? void 0 : X.checkpointId) ?? w.lastCheckpointId ?? void 0,
|
|
2446
|
+
checkpointNs: X == null ? void 0 : X.checkpointNs,
|
|
2447
|
+
nodeFilter: X == null ? void 0 : X.nodeFilter,
|
|
2448
|
+
config: X == null ? void 0 : X.config,
|
|
2445
2449
|
edit: zr,
|
|
2446
2450
|
originalMessageId: Cn
|
|
2447
2451
|
};
|
|
@@ -2457,18 +2461,18 @@ function Un({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
2457
2461
|
}
|
|
2458
2462
|
);
|
|
2459
2463
|
}, [T, C, p, R, w.lastCheckpointId, l, t == null ? void 0 : t.uploadPath, q, Q]), me = ve(
|
|
2460
|
-
async (
|
|
2464
|
+
async (J) => {
|
|
2461
2465
|
if (!T) throw new Error("No active thread");
|
|
2462
2466
|
if (I || !k) return;
|
|
2463
|
-
const
|
|
2464
|
-
if (
|
|
2467
|
+
const X = K;
|
|
2468
|
+
if (X) {
|
|
2465
2469
|
$(!0);
|
|
2466
2470
|
try {
|
|
2467
2471
|
const he = await l.getMessages({
|
|
2468
2472
|
threadId: T,
|
|
2469
2473
|
checkpointId: M,
|
|
2470
|
-
limit: (
|
|
2471
|
-
beforeId:
|
|
2474
|
+
limit: (J == null ? void 0 : J.limit) ?? N,
|
|
2475
|
+
beforeId: X
|
|
2472
2476
|
});
|
|
2473
2477
|
O(he, "prepend");
|
|
2474
2478
|
} finally {
|
|
@@ -2500,7 +2504,7 @@ function Un({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
2500
2504
|
refreshThreads: q,
|
|
2501
2505
|
createThread: oe,
|
|
2502
2506
|
deleteThread: V,
|
|
2503
|
-
renameThread:
|
|
2507
|
+
renameThread: Y,
|
|
2504
2508
|
loadThread: j,
|
|
2505
2509
|
send: te,
|
|
2506
2510
|
stop: h
|
|
@@ -3115,12 +3119,12 @@ function $p({
|
|
|
3115
3119
|
}
|
|
3116
3120
|
}, pe = () => {
|
|
3117
3121
|
if (e.model === "reflection") {
|
|
3118
|
-
const V = M.trim(),
|
|
3119
|
-
if (
|
|
3120
|
-
return /* @__PURE__ */ c(Gp, { data:
|
|
3122
|
+
const V = M.trim(), Y = Zr(V);
|
|
3123
|
+
if (Y && typeof Y == "object")
|
|
3124
|
+
return /* @__PURE__ */ c(Gp, { data: Y });
|
|
3121
3125
|
}
|
|
3122
3126
|
if (K && H.name === "get_issues") {
|
|
3123
|
-
const V = e.content.find((me) => me.type === "tool_result"),
|
|
3127
|
+
const V = e.content.find((me) => me.type === "tool_result"), Y = (V == null ? void 0 : V.output) ?? Pt(e.content), te = hi(Y);
|
|
3124
3128
|
if (te) return /* @__PURE__ */ c(qp, { issues: te });
|
|
3125
3129
|
}
|
|
3126
3130
|
if (K && !_) {
|
|
@@ -3131,10 +3135,10 @@ function $p({
|
|
|
3131
3135
|
] }) });
|
|
3132
3136
|
}
|
|
3133
3137
|
if (K && f) {
|
|
3134
|
-
const V = Pt(e.content),
|
|
3138
|
+
const V = Pt(e.content), Y = V.length > d;
|
|
3135
3139
|
return /* @__PURE__ */ c(Js, { open: C, onOpenChange: R, children: /* @__PURE__ */ E("div", { className: "font-mono text-sm text-current", children: [
|
|
3136
|
-
/* @__PURE__ */ c("pre", { className: A("whitespace-pre-wrap break-words text-current", I && "text-xs"), children:
|
|
3137
|
-
|
|
3140
|
+
/* @__PURE__ */ c("pre", { className: A("whitespace-pre-wrap break-words text-current", I && "text-xs"), children: Y && !C ? V.substring(0, d) + "..." : V }),
|
|
3141
|
+
Y && /* @__PURE__ */ c(Zs, { asChild: !0, children: /* @__PURE__ */ c(fe, { variant: "ghost", size: "sm", className: "h-6 text-xs text-current", children: C ? /* @__PURE__ */ E(Ae, { children: [
|
|
3138
3142
|
/* @__PURE__ */ c(Zt, { className: "h-3 w-3 mr-1" }),
|
|
3139
3143
|
"Show less"
|
|
3140
3144
|
] }) : /* @__PURE__ */ E(Ae, { children: [
|
|
@@ -3149,8 +3153,8 @@ function $p({
|
|
|
3149
3153
|
const V = Xp(e.content);
|
|
3150
3154
|
if (V && Up(V))
|
|
3151
3155
|
return /* @__PURE__ */ c(_n, { content: V.trim() });
|
|
3152
|
-
const
|
|
3153
|
-
return /* @__PURE__ */ c("div", { className: "font-mono text-sm text-current", children: /* @__PURE__ */ c("pre", { className: A("whitespace-pre-wrap break-words text-current", I && "text-xs"), children:
|
|
3156
|
+
const Y = Pt(e.content);
|
|
3157
|
+
return /* @__PURE__ */ c("div", { className: "font-mono text-sm text-current", children: /* @__PURE__ */ c("pre", { className: A("whitespace-pre-wrap break-words text-current", I && "text-xs"), children: Y }) });
|
|
3154
3158
|
}
|
|
3155
3159
|
const W = O.length > 0 && $ !== "tool", oe = G.length > 0 && $ !== "tool";
|
|
3156
3160
|
return /* @__PURE__ */ E("div", { children: [
|
|
@@ -3164,11 +3168,11 @@ function $p({
|
|
|
3164
3168
|
const V = Zr(M.trim());
|
|
3165
3169
|
if (V !== null) return /* @__PURE__ */ c(Qs, { data: V });
|
|
3166
3170
|
if ($ === "user" && p) {
|
|
3167
|
-
const
|
|
3168
|
-
if (
|
|
3171
|
+
const Y = M.trim();
|
|
3172
|
+
if (Y.length > h)
|
|
3169
3173
|
return /* @__PURE__ */ E(Js, { open: k, onOpenChange: L, children: [
|
|
3170
|
-
/* @__PURE__ */ c("div", { className: A("text-sm text-[hsl(var(--chat-bubble-user-text))]", I && "text-xs"), children: k ? /* @__PURE__ */ c(_n, { content:
|
|
3171
|
-
|
|
3174
|
+
/* @__PURE__ */ c("div", { className: A("text-sm text-[hsl(var(--chat-bubble-user-text))]", I && "text-xs"), children: k ? /* @__PURE__ */ c(_n, { content: Y }) : /* @__PURE__ */ E("pre", { className: A("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]", I && "text-xs"), children: [
|
|
3175
|
+
Y.substring(0, h),
|
|
3172
3176
|
"..."
|
|
3173
3177
|
] }) }),
|
|
3174
3178
|
/* @__PURE__ */ c(Zs, { asChild: !0, children: /* @__PURE__ */ c(
|
|
@@ -3183,7 +3187,7 @@ function $p({
|
|
|
3183
3187
|
] }) : /* @__PURE__ */ E(Ae, { children: [
|
|
3184
3188
|
/* @__PURE__ */ c(Mt, { className: "h-3 w-3 mr-1" }),
|
|
3185
3189
|
" Show more (",
|
|
3186
|
-
|
|
3190
|
+
Y.length - h,
|
|
3187
3191
|
" chars)"
|
|
3188
3192
|
] })
|
|
3189
3193
|
}
|
|
@@ -3192,14 +3196,14 @@ function $p({
|
|
|
3192
3196
|
}
|
|
3193
3197
|
return /* @__PURE__ */ c(_n, { content: M.trim() });
|
|
3194
3198
|
})(),
|
|
3195
|
-
W && /* @__PURE__ */ c("div", { className: "mt-2 grid grid-cols-2 gap-2", children: O.map((V,
|
|
3199
|
+
W && /* @__PURE__ */ c("div", { className: "mt-2 grid grid-cols-2 gap-2", children: O.map((V, Y) => /* @__PURE__ */ E("div", { className: "relative border rounded overflow-hidden", children: [
|
|
3196
3200
|
/* @__PURE__ */ c("img", { src: V.url, alt: V.alt ?? "image", className: "w-full h-auto" }),
|
|
3197
3201
|
/* @__PURE__ */ E("div", { className: "absolute top-1 right-1 bg-background/70 rounded px-1 py-0.5 text-[10px] flex items-center gap-1", children: [
|
|
3198
3202
|
/* @__PURE__ */ c(od, { className: "h-3 w-3" }),
|
|
3199
3203
|
/* @__PURE__ */ c("span", { children: "image" })
|
|
3200
3204
|
] })
|
|
3201
|
-
] },
|
|
3202
|
-
oe && /* @__PURE__ */ c("div", { className: "mt-2 flex flex-wrap gap-2", children: G.map((V,
|
|
3205
|
+
] }, Y)) }),
|
|
3206
|
+
oe && /* @__PURE__ */ c("div", { className: "mt-2 flex flex-wrap gap-2", children: G.map((V, Y) => {
|
|
3203
3207
|
const te = V, me = te.name || "file";
|
|
3204
3208
|
return /* @__PURE__ */ E(
|
|
3205
3209
|
"a",
|
|
@@ -3220,7 +3224,7 @@ function $p({
|
|
|
3220
3224
|
/* @__PURE__ */ c("span", { className: "truncate max-w-[180px]", children: me })
|
|
3221
3225
|
]
|
|
3222
3226
|
},
|
|
3223
|
-
|
|
3227
|
+
Y
|
|
3224
3228
|
);
|
|
3225
3229
|
}) })
|
|
3226
3230
|
] });
|
|
@@ -5333,7 +5337,7 @@ var Mi = "PopperAnchor", Di = u.forwardRef(
|
|
|
5333
5337
|
Di.displayName = Mi;
|
|
5334
5338
|
var ns = "PopperContent", [Am, Pm] = _i(ns), Li = u.forwardRef(
|
|
5335
5339
|
(e, t) => {
|
|
5336
|
-
var z, W, oe, V,
|
|
5340
|
+
var z, W, oe, V, Y, te;
|
|
5337
5341
|
const {
|
|
5338
5342
|
__scopePopper: n,
|
|
5339
5343
|
side: r = "bottom",
|
|
@@ -5375,9 +5379,9 @@ var ns = "PopperContent", [Am, Pm] = _i(ns), Li = u.forwardRef(
|
|
|
5375
5379
|
l && xm({ ...B }),
|
|
5376
5380
|
Sm({
|
|
5377
5381
|
...B,
|
|
5378
|
-
apply: ({ elements: me, rects: de, availableWidth:
|
|
5382
|
+
apply: ({ elements: me, rects: de, availableWidth: J, availableHeight: X }) => {
|
|
5379
5383
|
const { width: he, height: Oe } = de.reference, Ce = me.floating.style;
|
|
5380
|
-
Ce.setProperty("--radix-popper-available-width", `${
|
|
5384
|
+
Ce.setProperty("--radix-popper-available-width", `${J}px`), Ce.setProperty("--radix-popper-available-height", `${X}px`), Ce.setProperty("--radix-popper-anchor-width", `${he}px`), Ce.setProperty("--radix-popper-anchor-height", `${Oe}px`);
|
|
5381
5385
|
}
|
|
5382
5386
|
}),
|
|
5383
5387
|
C && Em({ element: C, padding: i }),
|
|
@@ -5404,7 +5408,7 @@ var ns = "PopperContent", [Am, Pm] = _i(ns), Li = u.forwardRef(
|
|
|
5404
5408
|
zIndex: ce,
|
|
5405
5409
|
"--radix-popper-transform-origin": [
|
|
5406
5410
|
(V = D.transformOrigin) == null ? void 0 : V.x,
|
|
5407
|
-
(
|
|
5411
|
+
(Y = D.transformOrigin) == null ? void 0 : Y.y
|
|
5408
5412
|
].join(" "),
|
|
5409
5413
|
// hide the content if using the hide middleware and should be hidden
|
|
5410
5414
|
// set visibility to hidden and disable pointer events so the UI behaves
|
|
@@ -7101,11 +7105,11 @@ function Vn({
|
|
|
7101
7105
|
} catch (P) {
|
|
7102
7106
|
console.log("ChatInterface debug - localStorage not available", P);
|
|
7103
7107
|
}
|
|
7104
|
-
const [$, K] = re(""), [B, M] = re(null), [H, O] = re(null), [G, D] = re([]), [T, Q] = re(!1), [q, ae] = re(null), [F, j] = re(null), [ce, pe] = re(!1), [z, W] = re(null), [oe, V] = re([]), [
|
|
7108
|
+
const [$, K] = re(""), [B, M] = re(null), [H, O] = re(null), [G, D] = re([]), [T, Q] = re(!1), [q, ae] = re(null), [F, j] = re(null), [ce, pe] = re(!1), [z, W] = re(null), [oe, V] = re([]), [Y, te] = re(null), me = Te(null), de = Te(null), J = Te(null), X = Te(null), he = Te(null), Oe = Te(!1), Ce = Te(!0), Xt = Te(0), st = Te(null), [Tt, Hr] = re("desktop");
|
|
7105
7109
|
ge(() => {
|
|
7106
7110
|
const P = () => {
|
|
7107
|
-
const
|
|
7108
|
-
Hr(
|
|
7111
|
+
const Z = window.innerWidth;
|
|
7112
|
+
Hr(Z < 640 ? "phone" : Z < 1024 ? "tablet" : "desktop");
|
|
7109
7113
|
};
|
|
7110
7114
|
return P(), window.addEventListener("resize", P), () => window.removeEventListener("resize", P);
|
|
7111
7115
|
}, []), ge(() => {
|
|
@@ -7114,12 +7118,12 @@ function Vn({
|
|
|
7114
7118
|
V([]), te(null), st.current = null;
|
|
7115
7119
|
return;
|
|
7116
7120
|
}
|
|
7117
|
-
const
|
|
7121
|
+
const Z = {
|
|
7118
7122
|
threadId: h,
|
|
7119
7123
|
checkpointId: y ?? null
|
|
7120
7124
|
}, ue = st.current;
|
|
7121
|
-
if (!(ue && ue.threadId ===
|
|
7122
|
-
return st.current =
|
|
7125
|
+
if (!(ue && ue.threadId === Z.threadId && ue.checkpointId === Z.checkpointId))
|
|
7126
|
+
return st.current = Z, C(h).then((le) => {
|
|
7123
7127
|
if (console.log("ChatInterface debug - listCheckpoints response:", le), P) return;
|
|
7124
7128
|
const De = ((le == null ? void 0 : le.checkpoints) ?? []).slice().sort((at, Tn) => new Date(Tn.createdAt).getTime() - new Date(at.createdAt).getTime());
|
|
7125
7129
|
console.log("ChatInterface debug - computed checkpoints:", De), V(De), te((at) => {
|
|
@@ -7138,7 +7142,7 @@ function Vn({
|
|
|
7138
7142
|
if (!N || k) return;
|
|
7139
7143
|
const P = he.current;
|
|
7140
7144
|
if (!P) return;
|
|
7141
|
-
const
|
|
7145
|
+
const Z = P.scrollHeight, ue = P.scrollTop;
|
|
7142
7146
|
Oe.current = !0;
|
|
7143
7147
|
try {
|
|
7144
7148
|
await L();
|
|
@@ -7152,7 +7156,7 @@ function Vn({
|
|
|
7152
7156
|
return;
|
|
7153
7157
|
}
|
|
7154
7158
|
const De = le.scrollHeight;
|
|
7155
|
-
le.scrollTop = ue + (De -
|
|
7159
|
+
le.scrollTop = ue + (De - Z);
|
|
7156
7160
|
const at = De - le.scrollTop - le.clientHeight;
|
|
7157
7161
|
Ce.current = at <= 32, Oe.current = !1;
|
|
7158
7162
|
});
|
|
@@ -7161,12 +7165,12 @@ function Vn({
|
|
|
7161
7165
|
ge(() => {
|
|
7162
7166
|
const P = he.current;
|
|
7163
7167
|
if (!P) return;
|
|
7164
|
-
const
|
|
7168
|
+
const Z = () => {
|
|
7165
7169
|
P.scrollTop <= 80 && At();
|
|
7166
7170
|
const De = P.scrollHeight - P.scrollTop - P.clientHeight;
|
|
7167
7171
|
Ce.current = De <= 80;
|
|
7168
7172
|
};
|
|
7169
|
-
return P.addEventListener("scroll",
|
|
7173
|
+
return P.addEventListener("scroll", Z), () => P.removeEventListener("scroll", Z);
|
|
7170
7174
|
}, [At]), ge(() => {
|
|
7171
7175
|
v.length < Xt.current && (Ce.current = !0), Xt.current = v.length;
|
|
7172
7176
|
}, [v.length]), ge(() => {
|
|
@@ -7178,10 +7182,10 @@ function Vn({
|
|
|
7178
7182
|
}, [n]), ge(() => {
|
|
7179
7183
|
(async () => {
|
|
7180
7184
|
try {
|
|
7181
|
-
const
|
|
7182
|
-
W(
|
|
7183
|
-
} catch (
|
|
7184
|
-
console.warn("Failed to fetch default message:",
|
|
7185
|
+
const Z = await I.getAgent("default");
|
|
7186
|
+
W(Z.uiDefaultMessage || null);
|
|
7187
|
+
} catch (Z) {
|
|
7188
|
+
console.warn("Failed to fetch default message:", Z), W(null);
|
|
7185
7189
|
}
|
|
7186
7190
|
})();
|
|
7187
7191
|
}, [I]), ge(() => {
|
|
@@ -7192,36 +7196,36 @@ function Vn({
|
|
|
7192
7196
|
return `Message too long (${P.length}/${kt} characters)`;
|
|
7193
7197
|
try {
|
|
7194
7198
|
return Zp(P), null;
|
|
7195
|
-
} catch (
|
|
7196
|
-
return (
|
|
7199
|
+
} catch (Z) {
|
|
7200
|
+
return (Z == null ? void 0 : Z.message) || "Invalid message";
|
|
7197
7201
|
}
|
|
7198
7202
|
}, Sn = (P) => {
|
|
7199
|
-
const
|
|
7203
|
+
const Z = P.content || [], ue = Z.filter((le) => le.type === "text").map((le) => le.text).join("");
|
|
7200
7204
|
if (ue) return ue;
|
|
7201
7205
|
try {
|
|
7202
|
-
return JSON.stringify(
|
|
7206
|
+
return JSON.stringify(Z, null, 2);
|
|
7203
7207
|
} catch {
|
|
7204
|
-
return String(
|
|
7208
|
+
return String(Z);
|
|
7205
7209
|
}
|
|
7206
7210
|
}, Cn = async () => {
|
|
7207
7211
|
const P = $.trim();
|
|
7208
7212
|
if (!(!P && G.length === 0)) {
|
|
7209
7213
|
if (P) {
|
|
7210
|
-
const
|
|
7211
|
-
if (
|
|
7212
|
-
O(
|
|
7214
|
+
const Z = zr(P);
|
|
7215
|
+
if (Z) {
|
|
7216
|
+
O(Z);
|
|
7213
7217
|
return;
|
|
7214
7218
|
}
|
|
7215
7219
|
}
|
|
7216
7220
|
try {
|
|
7217
|
-
await w(P, { checkpointId:
|
|
7218
|
-
} catch (
|
|
7219
|
-
const ue = (
|
|
7221
|
+
await w(P, { checkpointId: Y || y || void 0, payloadExtras: B ? { edit: !0, originalMessageId: B } : void 0, attachments: G }), f == null || f(P), K(""), O(null), D([]), M(null), de.current && (de.current.style.height = "auto");
|
|
7222
|
+
} catch (Z) {
|
|
7223
|
+
const ue = (Z == null ? void 0 : Z.message) || "Failed to send message";
|
|
7220
7224
|
O(ue), p == null || p(ue);
|
|
7221
7225
|
}
|
|
7222
7226
|
}
|
|
7223
|
-
}, Wr = (P,
|
|
7224
|
-
i && (M(P), K(
|
|
7227
|
+
}, Wr = (P, Z) => {
|
|
7228
|
+
i && (M(P), K(Z), O(null), setTimeout(() => {
|
|
7225
7229
|
de.current && (de.current.focus(), de.current.style.height = "auto", de.current.style.height = de.current.scrollHeight + "px");
|
|
7226
7230
|
}, 0));
|
|
7227
7231
|
}, Yt = () => {
|
|
@@ -7229,15 +7233,15 @@ function Vn({
|
|
|
7229
7233
|
}, En = (P) => {
|
|
7230
7234
|
P.key === "Enter" && !P.shiftKey ? (P.preventDefault(), Cn()) : P.key === "Escape" && B && (P.preventDefault(), Yt());
|
|
7231
7235
|
}, se = (P) => {
|
|
7232
|
-
const
|
|
7233
|
-
D((ue) => [...ue, ...
|
|
7234
|
-
}, xe = (P) => D((
|
|
7235
|
-
const
|
|
7236
|
-
if (
|
|
7236
|
+
const Z = Array.from(P.target.files || []);
|
|
7237
|
+
D((ue) => [...ue, ...Z]);
|
|
7238
|
+
}, xe = (P) => D((Z) => Z.filter((ue, le) => P !== le)), Ne = async (P) => {
|
|
7239
|
+
const Z = (P.target.files || [])[0];
|
|
7240
|
+
if (Z) {
|
|
7237
7241
|
ae(null), j(null), Q(!0);
|
|
7238
7242
|
try {
|
|
7239
|
-
const ue = await I.uploadExcel(
|
|
7240
|
-
j(De), d == null || d({ file:
|
|
7243
|
+
const ue = await I.uploadExcel(Z), le = ue.sheets.map((at) => `${at.sheetName} -> ${at.tableName}`).join(", "), De = le ? `Uploaded ${Z.name} (${ue.sheets.length} sheet${ue.sheets.length === 1 ? "" : "s"}: ${le})` : `Uploaded ${Z.name}`;
|
|
7244
|
+
j(De), d == null || d({ file: Z, response: ue });
|
|
7241
7245
|
} catch (ue) {
|
|
7242
7246
|
const le = ue instanceof Error ? ue.message : "Failed to upload Excel file";
|
|
7243
7247
|
console.error("Excel upload failed", ue), ae(le), p == null || p(le);
|
|
@@ -7247,8 +7251,8 @@ function Vn({
|
|
|
7247
7251
|
}
|
|
7248
7252
|
}, Be = (P) => {
|
|
7249
7253
|
if (!P) return "Unknown";
|
|
7250
|
-
const
|
|
7251
|
-
return Number.isNaN(
|
|
7254
|
+
const Z = Date.parse(P);
|
|
7255
|
+
return Number.isNaN(Z) ? P : new Date(Z).toLocaleString();
|
|
7252
7256
|
}, tt = async (P) => {
|
|
7253
7257
|
if (h) {
|
|
7254
7258
|
if (!P) {
|
|
@@ -7273,17 +7277,17 @@ function Vn({
|
|
|
7273
7277
|
}
|
|
7274
7278
|
)
|
|
7275
7279
|
] }),
|
|
7276
|
-
(console.log("Checkpoint toolbar render", { currentThreadId: h, checkpoints: oe, activeCheckpointId:
|
|
7280
|
+
(console.log("Checkpoint toolbar render", { currentThreadId: h, checkpoints: oe, activeCheckpointId: Y }), null),
|
|
7277
7281
|
h && oe.length > 0 && /* @__PURE__ */ E("div", { className: "flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50", children: [
|
|
7278
7282
|
/* @__PURE__ */ c("span", { className: "opacity-70", children: "Checkpoint:" }),
|
|
7279
7283
|
/* @__PURE__ */ E(
|
|
7280
7284
|
"select",
|
|
7281
7285
|
{
|
|
7282
7286
|
className: "border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",
|
|
7283
|
-
value:
|
|
7287
|
+
value: Y ?? "",
|
|
7284
7288
|
onChange: (P) => {
|
|
7285
|
-
const
|
|
7286
|
-
tt(
|
|
7289
|
+
const Z = P.target.value || null;
|
|
7290
|
+
tt(Z);
|
|
7287
7291
|
},
|
|
7288
7292
|
children: [
|
|
7289
7293
|
/* @__PURE__ */ c("option", { value: "", children: "Latest" }),
|
|
@@ -7304,11 +7308,11 @@ function Vn({
|
|
|
7304
7308
|
children: [
|
|
7305
7309
|
v.length === 0 ? /* @__PURE__ */ c("div", { className: "flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto", children: z || "No messages yet. Start a conversation!" }) : /* @__PURE__ */ E(Ae, { children: [
|
|
7306
7310
|
(k || !N) && /* @__PURE__ */ c("div", { className: "flex justify-center py-2 text-xs text-muted-foreground", children: k ? /* @__PURE__ */ c(Ps, { className: "h-4 w-4 animate-spin" }) : "You've reached the beginning" }),
|
|
7307
|
-
v.map((P,
|
|
7311
|
+
v.map((P, Z) => /* @__PURE__ */ c(
|
|
7308
7312
|
$p,
|
|
7309
7313
|
{
|
|
7310
7314
|
message: P,
|
|
7311
|
-
messageIndex:
|
|
7315
|
+
messageIndex: Z,
|
|
7312
7316
|
isStreamingMessage: g && m === P.id,
|
|
7313
7317
|
streamingDebounceMs: o,
|
|
7314
7318
|
isEditing: B === P.id,
|
|
@@ -7321,11 +7325,11 @@ function Vn({
|
|
|
7321
7325
|
onEdit: (ue, le) => Wr(ue, le),
|
|
7322
7326
|
onRegenerate: () => {
|
|
7323
7327
|
const ue = [...v].reverse().find((De) => De.role === "user"), le = ue ? Sn(ue) : "";
|
|
7324
|
-
le && w(le, { checkpointId:
|
|
7328
|
+
le && w(le, { checkpointId: Y || y || void 0 });
|
|
7325
7329
|
},
|
|
7326
7330
|
onCancelEdit: Yt
|
|
7327
7331
|
},
|
|
7328
|
-
P.id ||
|
|
7332
|
+
P.id || Z
|
|
7329
7333
|
))
|
|
7330
7334
|
] }),
|
|
7331
7335
|
/* @__PURE__ */ c("div", { ref: me })
|
|
@@ -7354,14 +7358,14 @@ function Vn({
|
|
|
7354
7358
|
/* @__PURE__ */ c(
|
|
7355
7359
|
"input",
|
|
7356
7360
|
{
|
|
7357
|
-
ref:
|
|
7361
|
+
ref: J,
|
|
7358
7362
|
type: "file",
|
|
7359
7363
|
multiple: !0,
|
|
7360
7364
|
onChange: (P) => se(P),
|
|
7361
7365
|
className: "hidden"
|
|
7362
7366
|
}
|
|
7363
7367
|
),
|
|
7364
|
-
G.length > 0 && /* @__PURE__ */ c("div", { className: "flex flex-wrap gap-2", children: G.map((P,
|
|
7368
|
+
G.length > 0 && /* @__PURE__ */ c("div", { className: "flex flex-wrap gap-2", children: G.map((P, Z) => /* @__PURE__ */ E("div", { className: "flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100", children: [
|
|
7365
7369
|
/* @__PURE__ */ c(Is, { size: 14 }),
|
|
7366
7370
|
/* @__PURE__ */ c("span", { className: "truncate max-w-[150px]", children: P.name }),
|
|
7367
7371
|
/* @__PURE__ */ c(
|
|
@@ -7369,19 +7373,19 @@ function Vn({
|
|
|
7369
7373
|
{
|
|
7370
7374
|
variant: "ghost",
|
|
7371
7375
|
size: "sm",
|
|
7372
|
-
onClick: () => xe(
|
|
7376
|
+
onClick: () => xe(Z),
|
|
7373
7377
|
className: "h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400",
|
|
7374
7378
|
"aria-label": `Remove ${P.name}`,
|
|
7375
7379
|
children: /* @__PURE__ */ c(tn, { size: 12 })
|
|
7376
7380
|
}
|
|
7377
7381
|
)
|
|
7378
|
-
] },
|
|
7382
|
+
] }, Z)) })
|
|
7379
7383
|
] }),
|
|
7380
7384
|
a && /* @__PURE__ */ E(Ae, { children: [
|
|
7381
7385
|
/* @__PURE__ */ c(
|
|
7382
7386
|
"input",
|
|
7383
7387
|
{
|
|
7384
|
-
ref:
|
|
7388
|
+
ref: X,
|
|
7385
7389
|
type: "file",
|
|
7386
7390
|
accept: ".xls,.xlsx,.xlsm",
|
|
7387
7391
|
onChange: Ne,
|
|
@@ -7414,7 +7418,7 @@ function Vn({
|
|
|
7414
7418
|
/* @__PURE__ */ E(Gc, { align: "start", sideOffset: 6, className: "w-52", children: [
|
|
7415
7419
|
s && /* @__PURE__ */ E(To, { onClick: () => {
|
|
7416
7420
|
var P;
|
|
7417
|
-
return (P =
|
|
7421
|
+
return (P = J.current) == null ? void 0 : P.click();
|
|
7418
7422
|
}, className: "cursor-pointer", children: [
|
|
7419
7423
|
/* @__PURE__ */ c(Is, { className: "h-4 w-4 mr-2" }),
|
|
7420
7424
|
" Attach files or images"
|
|
@@ -7424,7 +7428,7 @@ function Vn({
|
|
|
7424
7428
|
{
|
|
7425
7429
|
onClick: () => {
|
|
7426
7430
|
var P;
|
|
7427
|
-
T || (P =
|
|
7431
|
+
T || (P = X.current) == null || P.click();
|
|
7428
7432
|
},
|
|
7429
7433
|
className: `cursor-pointer ${T ? "opacity-60 pointer-events-none" : ""}`,
|
|
7430
7434
|
children: [
|
|
@@ -9855,9 +9859,9 @@ var Ue = 10, [Nu, ht] = qt(Et), Lw = "SelectContentImpl", Fw = Ft("SelectContent
|
|
|
9855
9859
|
}, [y]), qo();
|
|
9856
9860
|
const O = u.useCallback(
|
|
9857
9861
|
(z) => {
|
|
9858
|
-
const [W, ...oe] = K().map((te) => te.ref.current), [V] = oe.slice(-1),
|
|
9862
|
+
const [W, ...oe] = K().map((te) => te.ref.current), [V] = oe.slice(-1), Y = document.activeElement;
|
|
9859
9863
|
for (const te of z)
|
|
9860
|
-
if (te ===
|
|
9864
|
+
if (te === Y || (te == null || te.scrollIntoView({ block: "nearest" }), te === W && R && (R.scrollTop = 0), te === V && R && (R.scrollTop = R.scrollHeight), te == null || te.focus(), document.activeElement !== Y)) return;
|
|
9861
9865
|
},
|
|
9862
9866
|
[K, R]
|
|
9863
9867
|
), G = u.useCallback(
|
|
@@ -9872,9 +9876,9 @@ var Ue = 10, [Nu, ht] = qt(Et), Lw = "SelectContentImpl", Fw = Ft("SelectContent
|
|
|
9872
9876
|
if (y) {
|
|
9873
9877
|
let z = { x: 0, y: 0 };
|
|
9874
9878
|
const W = (V) => {
|
|
9875
|
-
var
|
|
9879
|
+
var Y, te;
|
|
9876
9880
|
z = {
|
|
9877
|
-
x: Math.abs(Math.round(V.pageX) - (((
|
|
9881
|
+
x: Math.abs(Math.round(V.pageX) - (((Y = T.current) == null ? void 0 : Y.x) ?? 0)),
|
|
9878
9882
|
y: Math.abs(Math.round(V.pageY) - (((te = T.current) == null ? void 0 : te.y) ?? 0))
|
|
9879
9883
|
};
|
|
9880
9884
|
}, oe = (V) => {
|
|
@@ -9891,7 +9895,7 @@ var Ue = 10, [Nu, ht] = qt(Et), Lw = "SelectContentImpl", Fw = Ft("SelectContent
|
|
|
9891
9895
|
};
|
|
9892
9896
|
}, [D]);
|
|
9893
9897
|
const [Q, q] = Wu((z) => {
|
|
9894
|
-
const W = K().filter((
|
|
9898
|
+
const W = K().filter((Y) => !Y.disabled), oe = W.find((Y) => Y.ref.current === document.activeElement), V = ju(W, z, oe);
|
|
9895
9899
|
V && setTimeout(() => V.ref.current.focus());
|
|
9896
9900
|
}), ae = u.useCallback(
|
|
9897
9901
|
(z, W, oe) => {
|
|
@@ -9977,9 +9981,9 @@ var Ue = 10, [Nu, ht] = qt(Et), Lw = "SelectContentImpl", Fw = Ft("SelectContent
|
|
|
9977
9981
|
onKeyDown: U(w.onKeyDown, (z) => {
|
|
9978
9982
|
const W = z.ctrlKey || z.altKey || z.metaKey;
|
|
9979
9983
|
if (z.key === "Tab" && z.preventDefault(), !W && z.key.length === 1 && q(z.key), ["ArrowUp", "ArrowDown", "Home", "End"].includes(z.key)) {
|
|
9980
|
-
let V = K().filter((
|
|
9984
|
+
let V = K().filter((Y) => !Y.disabled).map((Y) => Y.ref.current);
|
|
9981
9985
|
if (["ArrowUp", "End"].includes(z.key) && (V = V.slice().reverse()), ["ArrowUp", "ArrowDown"].includes(z.key)) {
|
|
9982
|
-
const
|
|
9986
|
+
const Y = z.target, te = V.indexOf(Y);
|
|
9983
9987
|
V = V.slice(te + 1);
|
|
9984
9988
|
}
|
|
9985
9989
|
setTimeout(() => O(V)), z.preventDefault();
|
|
@@ -10001,40 +10005,40 @@ var $w = "SelectItemAlignedPosition", Tu = u.forwardRef((e, t) => {
|
|
|
10001
10005
|
if (s.trigger && s.valueNode && i && f && m && b && w) {
|
|
10002
10006
|
const N = s.trigger.getBoundingClientRect(), k = f.getBoundingClientRect(), L = s.valueNode.getBoundingClientRect(), I = w.getBoundingClientRect();
|
|
10003
10007
|
if (s.dir !== "rtl") {
|
|
10004
|
-
const
|
|
10008
|
+
const Y = I.left - k.left, te = L.left - Y, me = N.left - te, de = N.width + me, J = Math.max(de, k.width), X = window.innerWidth - Ue, he = Ao(te, [
|
|
10005
10009
|
Ue,
|
|
10006
10010
|
// Prevents the content from going off the starting edge of the
|
|
10007
10011
|
// viewport. It may still go off the ending edge, but this can be
|
|
10008
10012
|
// controlled by the user since they may want to manage overflow in a
|
|
10009
10013
|
// specific way.
|
|
10010
10014
|
// https://github.com/radix-ui/primitives/issues/2049
|
|
10011
|
-
Math.max(Ue,
|
|
10015
|
+
Math.max(Ue, X - J)
|
|
10012
10016
|
]);
|
|
10013
10017
|
i.style.minWidth = de + "px", i.style.left = he + "px";
|
|
10014
10018
|
} else {
|
|
10015
|
-
const
|
|
10019
|
+
const Y = k.right - I.right, te = window.innerWidth - L.right - Y, me = window.innerWidth - N.right - te, de = N.width + me, J = Math.max(de, k.width), X = window.innerWidth - Ue, he = Ao(te, [
|
|
10016
10020
|
Ue,
|
|
10017
|
-
Math.max(Ue,
|
|
10021
|
+
Math.max(Ue, X - J)
|
|
10018
10022
|
]);
|
|
10019
10023
|
i.style.minWidth = de + "px", i.style.right = he + "px";
|
|
10020
10024
|
}
|
|
10021
10025
|
const $ = h(), K = window.innerHeight - Ue * 2, B = m.scrollHeight, M = window.getComputedStyle(f), H = parseInt(M.borderTopWidth, 10), O = parseInt(M.paddingTop, 10), G = parseInt(M.borderBottomWidth, 10), D = parseInt(M.paddingBottom, 10), T = H + O + B + D + G, Q = Math.min(b.offsetHeight * 5, T), q = window.getComputedStyle(m), ae = parseInt(q.paddingTop, 10), F = parseInt(q.paddingBottom, 10), j = N.top + N.height / 2 - Ue, ce = K - j, pe = b.offsetHeight / 2, z = b.offsetTop + pe, W = H + O + z, oe = T - W;
|
|
10022
10026
|
if (W <= j) {
|
|
10023
|
-
const
|
|
10027
|
+
const Y = $.length > 0 && b === $[$.length - 1].ref.current;
|
|
10024
10028
|
i.style.bottom = "0px";
|
|
10025
10029
|
const te = f.clientHeight - m.offsetTop - m.offsetHeight, me = Math.max(
|
|
10026
10030
|
ce,
|
|
10027
10031
|
pe + // viewport might have padding bottom, include it to avoid a scrollable viewport
|
|
10028
|
-
(
|
|
10032
|
+
(Y ? F : 0) + te + G
|
|
10029
10033
|
), de = W + me;
|
|
10030
10034
|
i.style.height = de + "px";
|
|
10031
10035
|
} else {
|
|
10032
|
-
const
|
|
10036
|
+
const Y = $.length > 0 && b === $[0].ref.current;
|
|
10033
10037
|
i.style.top = "0px";
|
|
10034
10038
|
const me = Math.max(
|
|
10035
10039
|
j,
|
|
10036
10040
|
H + m.offsetTop + // viewport might have padding top, include it to avoid a scrollable viewport
|
|
10037
|
-
(
|
|
10041
|
+
(Y ? ae : 0) + pe
|
|
10038
10042
|
) + oe;
|
|
10039
10043
|
i.style.height = me + "px", m.scrollTop = W - j + m.offsetTop;
|
|
10040
10044
|
}
|