@tangle-network/agent-app 0.60.234 → 0.60.235
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/assistant/index.js +3 -4
- package/dist/assistant/index.js.map +1 -1
- package/dist/{chunk-3K45OQ5X.js → chunk-5IZRAZEZ.js} +41 -1
- package/dist/chunk-5IZRAZEZ.js.map +1 -0
- package/dist/chunk-BDEBQ4WO.js +38 -0
- package/dist/chunk-BDEBQ4WO.js.map +1 -0
- package/dist/{chunk-FJEGGUOQ.js → chunk-JYIMW5U5.js} +1267 -557
- package/dist/chunk-JYIMW5U5.js.map +1 -0
- package/dist/studio-react/index.js +1 -3
- package/dist/studio-react/index.js.map +1 -1
- package/dist/web-react/index.js +8 -9
- package/dist/web-react/session-history-panel.d.ts +84 -0
- package/dist/web-react/session-history.d.ts +4 -187
- package/dist/web-react/use-infinite-scroll.d.ts +20 -0
- package/dist/web-react/use-session-actions.d.ts +47 -0
- package/dist/web-react/use-session-history.d.ts +44 -0
- package/dist/workspace-react/index.js +3 -5
- package/dist/workspace-react/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-35APKGPB.js +0 -749
- package/dist/chunk-35APKGPB.js.map +0 -1
- package/dist/chunk-3K45OQ5X.js.map +0 -1
- package/dist/chunk-A2GG4D4A.js +0 -43
- package/dist/chunk-A2GG4D4A.js.map +0 -1
- package/dist/chunk-FJEGGUOQ.js.map +0 -1
|
@@ -4,6 +4,9 @@ import {
|
|
|
4
4
|
charAt,
|
|
5
5
|
charBefore
|
|
6
6
|
} from "./chunk-3HUFJ5LO.js";
|
|
7
|
+
import {
|
|
8
|
+
useInfiniteScroll
|
|
9
|
+
} from "./chunk-BDEBQ4WO.js";
|
|
7
10
|
import {
|
|
8
11
|
stepActivityFlowTrace
|
|
9
12
|
} from "./chunk-FBVLEGEG.js";
|
|
@@ -15,8 +18,15 @@ import {
|
|
|
15
18
|
joinClasses
|
|
16
19
|
} from "./chunk-L7MB2LLM.js";
|
|
17
20
|
import {
|
|
21
|
+
ActionDialog,
|
|
22
|
+
ActionDialogButton
|
|
23
|
+
} from "./chunk-5IZRAZEZ.js";
|
|
24
|
+
import {
|
|
25
|
+
UNTITLED_SESSION_LABEL,
|
|
18
26
|
filterCommandPaletteItems,
|
|
19
|
-
groupCommandPaletteItems
|
|
27
|
+
groupCommandPaletteItems,
|
|
28
|
+
mergeSessionPages,
|
|
29
|
+
sessionLabel
|
|
20
30
|
} from "./chunk-SJWIZT7B.js";
|
|
21
31
|
import {
|
|
22
32
|
BrainGlyph,
|
|
@@ -61,7 +71,7 @@ import {
|
|
|
61
71
|
} from "./chunk-LQYIBL3G.js";
|
|
62
72
|
|
|
63
73
|
// src/web-react/index.tsx
|
|
64
|
-
import { useEffect as
|
|
74
|
+
import { useEffect as useEffect17, useMemo as useMemo9, useRef as useRef17, useState as useState25, memo } from "react";
|
|
65
75
|
import { isViewerMessage, MessageAuthor, TRANSCRIPT_TEXT } from "@tangle-network/ui/chat";
|
|
66
76
|
import { TerminalDisplay, TerminalLine } from "@tangle-network/ui/primitives";
|
|
67
77
|
import { InlineToolItem } from "@tangle-network/ui/run";
|
|
@@ -3451,18 +3461,714 @@ function SeatPaywall({
|
|
|
3451
3461
|
] }) });
|
|
3452
3462
|
}
|
|
3453
3463
|
|
|
3464
|
+
// src/web-react/use-session-history.ts
|
|
3465
|
+
import { useCallback as useCallback8, useEffect as useEffect10, useMemo as useMemo6, useRef as useRef10, useState as useState16 } from "react";
|
|
3466
|
+
function seedSignature(page) {
|
|
3467
|
+
return JSON.stringify({
|
|
3468
|
+
nextCursor: page.nextCursor ?? null,
|
|
3469
|
+
items: page.items.map((item) => ({
|
|
3470
|
+
id: item.id,
|
|
3471
|
+
title: item.title,
|
|
3472
|
+
updatedAt: item.updatedAt,
|
|
3473
|
+
isPinned: Boolean(item.isPinned),
|
|
3474
|
+
unread: Boolean(item.unread),
|
|
3475
|
+
category: item.category ?? null
|
|
3476
|
+
}))
|
|
3477
|
+
});
|
|
3478
|
+
}
|
|
3479
|
+
function useSessionHistory({
|
|
3480
|
+
fetchPage,
|
|
3481
|
+
q,
|
|
3482
|
+
sort,
|
|
3483
|
+
initialPage,
|
|
3484
|
+
defaultSort = "newest"
|
|
3485
|
+
}) {
|
|
3486
|
+
const [items, setItems] = useState16(initialPage.items);
|
|
3487
|
+
const [nextCursor, setNextCursor] = useState16(initialPage.nextCursor ?? null);
|
|
3488
|
+
const [phase, setPhase] = useState16("idle");
|
|
3489
|
+
const [reloadKey, setReloadKey] = useState16(0);
|
|
3490
|
+
const seqRef = useRef10(0);
|
|
3491
|
+
const resetAbortRef = useRef10(null);
|
|
3492
|
+
const loadMoreAbortRef = useRef10(null);
|
|
3493
|
+
const loadingMoreRef = useRef10(false);
|
|
3494
|
+
const lastOpRef = useRef10("first");
|
|
3495
|
+
const nextCursorRef = useRef10(nextCursor);
|
|
3496
|
+
nextCursorRef.current = nextCursor;
|
|
3497
|
+
const viewRef = useRef10({ q, sort, fetchPage });
|
|
3498
|
+
viewRef.current = { q, sort, fetchPage };
|
|
3499
|
+
const seedRef = useRef10(initialPage);
|
|
3500
|
+
seedRef.current = initialPage;
|
|
3501
|
+
const isDefaultView = q === "" && sort === defaultSort;
|
|
3502
|
+
const seedKey = useMemo6(() => seedSignature(initialPage), [initialPage]);
|
|
3503
|
+
useEffect10(() => {
|
|
3504
|
+
resetAbortRef.current?.abort();
|
|
3505
|
+
loadMoreAbortRef.current?.abort();
|
|
3506
|
+
loadingMoreRef.current = false;
|
|
3507
|
+
const seq = ++seqRef.current;
|
|
3508
|
+
if (isDefaultView && reloadKey === 0) {
|
|
3509
|
+
setItems(seedRef.current.items);
|
|
3510
|
+
setNextCursor(seedRef.current.nextCursor ?? null);
|
|
3511
|
+
setPhase("idle");
|
|
3512
|
+
return;
|
|
3513
|
+
}
|
|
3514
|
+
const controller = new AbortController();
|
|
3515
|
+
resetAbortRef.current = controller;
|
|
3516
|
+
lastOpRef.current = "first";
|
|
3517
|
+
setItems([]);
|
|
3518
|
+
setNextCursor(null);
|
|
3519
|
+
setPhase("loadingFirst");
|
|
3520
|
+
void (async () => {
|
|
3521
|
+
try {
|
|
3522
|
+
const page = await viewRef.current.fetchPage({ q, sort, cursor: null, signal: controller.signal });
|
|
3523
|
+
if (seq !== seqRef.current) return;
|
|
3524
|
+
setItems(page.items);
|
|
3525
|
+
setNextCursor(page.nextCursor ?? null);
|
|
3526
|
+
setPhase("idle");
|
|
3527
|
+
} catch {
|
|
3528
|
+
if (controller.signal.aborted || seq !== seqRef.current) return;
|
|
3529
|
+
setPhase("error");
|
|
3530
|
+
}
|
|
3531
|
+
})();
|
|
3532
|
+
return () => controller.abort();
|
|
3533
|
+
}, [q, sort, seedKey, isDefaultView, reloadKey]);
|
|
3534
|
+
const loadMore = useCallback8(() => {
|
|
3535
|
+
const cursor = nextCursorRef.current;
|
|
3536
|
+
if (!cursor || loadingMoreRef.current) return;
|
|
3537
|
+
const { q: currentQ, sort: currentSort, fetchPage: currentFetch } = viewRef.current;
|
|
3538
|
+
const seq = seqRef.current;
|
|
3539
|
+
loadingMoreRef.current = true;
|
|
3540
|
+
lastOpRef.current = "more";
|
|
3541
|
+
const controller = new AbortController();
|
|
3542
|
+
loadMoreAbortRef.current = controller;
|
|
3543
|
+
setPhase("loadingMore");
|
|
3544
|
+
void (async () => {
|
|
3545
|
+
try {
|
|
3546
|
+
const page = await currentFetch({ q: currentQ, sort: currentSort, cursor, signal: controller.signal });
|
|
3547
|
+
if (seq !== seqRef.current) return;
|
|
3548
|
+
setItems((prev) => mergeSessionPages(prev, page.items));
|
|
3549
|
+
setNextCursor(page.nextCursor ?? null);
|
|
3550
|
+
setPhase("idle");
|
|
3551
|
+
} catch {
|
|
3552
|
+
if (controller.signal.aborted || seq !== seqRef.current) return;
|
|
3553
|
+
setPhase("error");
|
|
3554
|
+
} finally {
|
|
3555
|
+
if (seq === seqRef.current) loadingMoreRef.current = false;
|
|
3556
|
+
}
|
|
3557
|
+
})();
|
|
3558
|
+
}, []);
|
|
3559
|
+
const retry = useCallback8(() => {
|
|
3560
|
+
if (lastOpRef.current === "more") loadMore();
|
|
3561
|
+
else setReloadKey((key) => key + 1);
|
|
3562
|
+
}, [loadMore]);
|
|
3563
|
+
const reload = useCallback8(() => {
|
|
3564
|
+
setReloadKey((key) => key + 1);
|
|
3565
|
+
}, []);
|
|
3566
|
+
useEffect10(
|
|
3567
|
+
() => () => {
|
|
3568
|
+
resetAbortRef.current?.abort();
|
|
3569
|
+
loadMoreAbortRef.current?.abort();
|
|
3570
|
+
},
|
|
3571
|
+
[]
|
|
3572
|
+
);
|
|
3573
|
+
return {
|
|
3574
|
+
items,
|
|
3575
|
+
hasMore: nextCursor !== null,
|
|
3576
|
+
isLoadingFirst: phase === "loadingFirst",
|
|
3577
|
+
isLoadingMore: phase === "loadingMore",
|
|
3578
|
+
isError: phase === "error",
|
|
3579
|
+
loadMore,
|
|
3580
|
+
retry,
|
|
3581
|
+
reload
|
|
3582
|
+
};
|
|
3583
|
+
}
|
|
3584
|
+
|
|
3585
|
+
// src/web-react/use-session-actions.tsx
|
|
3586
|
+
import { useCallback as useCallback9, useState as useState17 } from "react";
|
|
3587
|
+
import { Input } from "@tangle-network/ui/primitives";
|
|
3588
|
+
import { Fragment as Fragment4, jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3589
|
+
var DEFAULT_LABELS = {
|
|
3590
|
+
renameTitle: "Rename session",
|
|
3591
|
+
renameField: "Title",
|
|
3592
|
+
renameSubmit: "Save",
|
|
3593
|
+
deleteTitle: "Delete session?",
|
|
3594
|
+
deleteBody: (title) => `This will permanently delete \u201C${title}\u201D and its messages. This cannot be undone.`,
|
|
3595
|
+
deleteSubmit: "Delete",
|
|
3596
|
+
cancel: "Cancel",
|
|
3597
|
+
renamed: "Session renamed",
|
|
3598
|
+
deleted: "Session deleted",
|
|
3599
|
+
renameFailed: "Failed to rename session",
|
|
3600
|
+
deleteFailed: "Failed to delete session"
|
|
3601
|
+
};
|
|
3602
|
+
function useSessionActions({
|
|
3603
|
+
renameSession,
|
|
3604
|
+
deleteSession,
|
|
3605
|
+
onChanged,
|
|
3606
|
+
onDeletedCurrent,
|
|
3607
|
+
currentSessionId,
|
|
3608
|
+
notify,
|
|
3609
|
+
labels
|
|
3610
|
+
}) {
|
|
3611
|
+
const text = { ...DEFAULT_LABELS, ...labels };
|
|
3612
|
+
const [renameTarget, setRenameTarget] = useState17(null);
|
|
3613
|
+
const [renameValue, setRenameValue] = useState17("");
|
|
3614
|
+
const [deleteTarget, setDeleteTarget] = useState17(null);
|
|
3615
|
+
const [busy, setBusy] = useState17(false);
|
|
3616
|
+
const [error, setError] = useState17(null);
|
|
3617
|
+
const openRename = useCallback9((session) => {
|
|
3618
|
+
setError(null);
|
|
3619
|
+
setRenameTarget(session);
|
|
3620
|
+
setRenameValue(session.title ?? "");
|
|
3621
|
+
}, []);
|
|
3622
|
+
const openDelete = useCallback9((session) => {
|
|
3623
|
+
setError(null);
|
|
3624
|
+
setDeleteTarget(session);
|
|
3625
|
+
}, []);
|
|
3626
|
+
const submitRename = useCallback9(async () => {
|
|
3627
|
+
if (!renameTarget) return;
|
|
3628
|
+
const title = renameValue.trim();
|
|
3629
|
+
if (!title || title === renameTarget.title) {
|
|
3630
|
+
setRenameTarget(null);
|
|
3631
|
+
return;
|
|
3632
|
+
}
|
|
3633
|
+
setBusy(true);
|
|
3634
|
+
setError(null);
|
|
3635
|
+
try {
|
|
3636
|
+
await renameSession(renameTarget.id, title);
|
|
3637
|
+
setRenameTarget(null);
|
|
3638
|
+
notify?.("success", text.renamed);
|
|
3639
|
+
onChanged?.();
|
|
3640
|
+
} catch (e) {
|
|
3641
|
+
const message = e instanceof Error ? e.message : text.renameFailed;
|
|
3642
|
+
setError(message);
|
|
3643
|
+
notify?.("error", message);
|
|
3644
|
+
} finally {
|
|
3645
|
+
setBusy(false);
|
|
3646
|
+
}
|
|
3647
|
+
}, [renameTarget, renameValue, renameSession, notify, onChanged, text.renamed, text.renameFailed]);
|
|
3648
|
+
const confirmDelete = useCallback9(async () => {
|
|
3649
|
+
if (!deleteTarget) return;
|
|
3650
|
+
const deletingCurrent = currentSessionId != null && deleteTarget.id === currentSessionId;
|
|
3651
|
+
setBusy(true);
|
|
3652
|
+
setError(null);
|
|
3653
|
+
try {
|
|
3654
|
+
await deleteSession(deleteTarget.id);
|
|
3655
|
+
setDeleteTarget(null);
|
|
3656
|
+
notify?.("success", text.deleted);
|
|
3657
|
+
onChanged?.();
|
|
3658
|
+
if (deletingCurrent) onDeletedCurrent?.();
|
|
3659
|
+
} catch (e) {
|
|
3660
|
+
const message = e instanceof Error ? e.message : text.deleteFailed;
|
|
3661
|
+
setError(message);
|
|
3662
|
+
notify?.("error", message);
|
|
3663
|
+
} finally {
|
|
3664
|
+
setBusy(false);
|
|
3665
|
+
}
|
|
3666
|
+
}, [deleteTarget, currentSessionId, deleteSession, notify, onChanged, onDeletedCurrent, text.deleted, text.deleteFailed]);
|
|
3667
|
+
const dialogs = /* @__PURE__ */ jsxs12(Fragment4, { children: [
|
|
3668
|
+
renameTarget && /* @__PURE__ */ jsxs12(
|
|
3669
|
+
ActionDialog,
|
|
3670
|
+
{
|
|
3671
|
+
title: text.renameTitle,
|
|
3672
|
+
onClose: () => setRenameTarget(null),
|
|
3673
|
+
busy,
|
|
3674
|
+
error,
|
|
3675
|
+
footer: /* @__PURE__ */ jsxs12(Fragment4, { children: [
|
|
3676
|
+
/* @__PURE__ */ jsx14(ActionDialogButton, { onClick: () => setRenameTarget(null), disabled: busy, variant: "ghost", children: text.cancel }),
|
|
3677
|
+
/* @__PURE__ */ jsx14(ActionDialogButton, { onClick: () => void submitRename(), disabled: busy || !renameValue.trim(), children: text.renameSubmit })
|
|
3678
|
+
] }),
|
|
3679
|
+
children: [
|
|
3680
|
+
/* @__PURE__ */ jsx14("label", { htmlFor: "agent-app-rename-session", className: "text-xs text-muted-foreground", children: text.renameField }),
|
|
3681
|
+
/* @__PURE__ */ jsx14(
|
|
3682
|
+
Input,
|
|
3683
|
+
{
|
|
3684
|
+
id: "agent-app-rename-session",
|
|
3685
|
+
value: renameValue,
|
|
3686
|
+
autoFocus: true,
|
|
3687
|
+
onChange: (e) => setRenameValue(e.target.value),
|
|
3688
|
+
onKeyDown: (e) => {
|
|
3689
|
+
if (e.key === "Enter" && !busy) {
|
|
3690
|
+
e.preventDefault();
|
|
3691
|
+
void submitRename();
|
|
3692
|
+
}
|
|
3693
|
+
},
|
|
3694
|
+
className: "mt-1.5"
|
|
3695
|
+
}
|
|
3696
|
+
)
|
|
3697
|
+
]
|
|
3698
|
+
}
|
|
3699
|
+
),
|
|
3700
|
+
deleteTarget && /* @__PURE__ */ jsx14(
|
|
3701
|
+
ActionDialog,
|
|
3702
|
+
{
|
|
3703
|
+
title: text.deleteTitle,
|
|
3704
|
+
onClose: () => setDeleteTarget(null),
|
|
3705
|
+
busy,
|
|
3706
|
+
error,
|
|
3707
|
+
footer: /* @__PURE__ */ jsxs12(Fragment4, { children: [
|
|
3708
|
+
/* @__PURE__ */ jsx14(ActionDialogButton, { onClick: () => setDeleteTarget(null), disabled: busy, variant: "ghost", children: text.cancel }),
|
|
3709
|
+
/* @__PURE__ */ jsx14(ActionDialogButton, { onClick: () => void confirmDelete(), disabled: busy, variant: "destructive", children: text.deleteSubmit })
|
|
3710
|
+
] }),
|
|
3711
|
+
children: /* @__PURE__ */ jsx14("p", { className: "text-sm text-muted-foreground", children: text.deleteBody(sessionLabel(deleteTarget)) })
|
|
3712
|
+
}
|
|
3713
|
+
)
|
|
3714
|
+
] });
|
|
3715
|
+
return { openRename, openDelete, dialogs, busy };
|
|
3716
|
+
}
|
|
3717
|
+
|
|
3718
|
+
// src/web-react/session-history-panel.tsx
|
|
3719
|
+
import { useCallback as useCallback10, useEffect as useEffect11, useId as useId2, useRef as useRef11, useState as useState18 } from "react";
|
|
3720
|
+
import { Button as Button3, Checkbox, Input as Input2, Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@tangle-network/ui/primitives";
|
|
3721
|
+
import { ShellHeader } from "@tangle-network/sandbox-ui/workspace";
|
|
3722
|
+
import { Fragment as Fragment5, jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
3723
|
+
function AnchorLink({ to, className, children }) {
|
|
3724
|
+
return /* @__PURE__ */ jsx15("a", { href: to, className, children });
|
|
3725
|
+
}
|
|
3726
|
+
var MINUTE = 6e4;
|
|
3727
|
+
var HOUR = 60 * MINUTE;
|
|
3728
|
+
var DAY = 24 * HOUR;
|
|
3729
|
+
function formatSessionTimestamp(isoDate) {
|
|
3730
|
+
if (!isoDate) return "";
|
|
3731
|
+
const at = Date.parse(isoDate);
|
|
3732
|
+
if (Number.isNaN(at)) return "";
|
|
3733
|
+
const delta = Date.now() - at;
|
|
3734
|
+
if (delta < MINUTE) return "just now";
|
|
3735
|
+
if (delta < HOUR) return `${Math.floor(delta / MINUTE)}m ago`;
|
|
3736
|
+
if (delta < DAY) return `${Math.floor(delta / HOUR)}h ago`;
|
|
3737
|
+
if (delta < 7 * DAY) return `${Math.floor(delta / DAY)}d ago`;
|
|
3738
|
+
return new Date(at).toLocaleDateString(void 0, { month: "short", day: "numeric" });
|
|
3739
|
+
}
|
|
3740
|
+
function SkeletonRows() {
|
|
3741
|
+
return /* @__PURE__ */ jsxs13(Fragment5, { children: [
|
|
3742
|
+
/* @__PURE__ */ jsx15("span", { role: "status", "aria-live": "polite", "aria-busy": true, className: "sr-only", children: "Loading sessions\u2026" }),
|
|
3743
|
+
/* @__PURE__ */ jsx15("div", { className: "flex flex-col gap-0.5", "aria-hidden": true, children: Array.from({ length: 8 }).map((_, i) => /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-3 px-3 py-2.5", children: [
|
|
3744
|
+
/* @__PURE__ */ jsx15("div", { className: "h-4 w-4 animate-pulse rounded bg-muted" }),
|
|
3745
|
+
/* @__PURE__ */ jsx15("div", { className: "h-4 w-1/2 animate-pulse rounded bg-muted" }),
|
|
3746
|
+
/* @__PURE__ */ jsx15("div", { className: "ml-auto h-3 w-12 animate-pulse rounded bg-muted" })
|
|
3747
|
+
] }, i)) })
|
|
3748
|
+
] });
|
|
3749
|
+
}
|
|
3750
|
+
function MessageIcon({ className }) {
|
|
3751
|
+
return /* @__PURE__ */ jsx15("svg", { viewBox: "0 0 24 24", className, fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx15("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }) });
|
|
3752
|
+
}
|
|
3753
|
+
function SessionHistoryPanel({
|
|
3754
|
+
history,
|
|
3755
|
+
hasAnySessions,
|
|
3756
|
+
query,
|
|
3757
|
+
onQueryChange,
|
|
3758
|
+
sort,
|
|
3759
|
+
onSortChange,
|
|
3760
|
+
hrefForSession,
|
|
3761
|
+
linkComponent: Link = AnchorLink,
|
|
3762
|
+
respondingSessionIds,
|
|
3763
|
+
onRename,
|
|
3764
|
+
onDelete,
|
|
3765
|
+
onBulkAction,
|
|
3766
|
+
renameLabel = "Rename",
|
|
3767
|
+
deleteLabel = "Delete",
|
|
3768
|
+
extraActions,
|
|
3769
|
+
newSessionHref,
|
|
3770
|
+
title = "History",
|
|
3771
|
+
showHeader = true,
|
|
3772
|
+
untitledLabel = UNTITLED_SESSION_LABEL,
|
|
3773
|
+
emptyTitle = "No sessions yet",
|
|
3774
|
+
emptyDescription = "Your chat sessions will show up here once you start one.",
|
|
3775
|
+
formatTimestamp = formatSessionTimestamp,
|
|
3776
|
+
contentWidth = "reading",
|
|
3777
|
+
className
|
|
3778
|
+
}) {
|
|
3779
|
+
const scrollRef = useRef11(null);
|
|
3780
|
+
const sentinelRef = useInfiniteScroll(history.loadMore, {
|
|
3781
|
+
enabled: history.hasMore && !history.isLoadingMore && !history.isError,
|
|
3782
|
+
root: scrollRef,
|
|
3783
|
+
rootMargin: "300px"
|
|
3784
|
+
});
|
|
3785
|
+
const searchTerm = query.trim();
|
|
3786
|
+
const isSearching = searchTerm.length > 0;
|
|
3787
|
+
const column = contentWidth === "full" ? "w-full" : "mx-auto w-full max-w-4xl";
|
|
3788
|
+
const [selectedIds, setSelectedIds] = useState18(/* @__PURE__ */ new Set());
|
|
3789
|
+
const [ageDays, setAgeDays] = useState18("30");
|
|
3790
|
+
const [bulkTarget, setBulkTarget] = useState18(null);
|
|
3791
|
+
const [bulkBusy, setBulkBusy] = useState18(false);
|
|
3792
|
+
const [bulkError, setBulkError] = useState18(null);
|
|
3793
|
+
useEffect11(() => {
|
|
3794
|
+
setSelectedIds(/* @__PURE__ */ new Set());
|
|
3795
|
+
}, [searchTerm, sort]);
|
|
3796
|
+
useEffect11(() => {
|
|
3797
|
+
const visible = new Set(history.items.map((item) => item.id));
|
|
3798
|
+
setSelectedIds((current) => {
|
|
3799
|
+
const next = new Set([...current].filter((id) => visible.has(id)));
|
|
3800
|
+
return next.size === current.size ? current : next;
|
|
3801
|
+
});
|
|
3802
|
+
}, [history.items]);
|
|
3803
|
+
const selectedCount = selectedIds.size;
|
|
3804
|
+
const allVisibleSelected = history.items.length > 0 && history.items.every((item) => selectedIds.has(item.id));
|
|
3805
|
+
const parsedAgeDays = Number(ageDays);
|
|
3806
|
+
const validAgeDays = Number.isInteger(parsedAgeDays) && parsedAgeDays >= 1 && parsedAgeDays <= 36500;
|
|
3807
|
+
const openBulkAction = useCallback10((action) => {
|
|
3808
|
+
const verb = deleteLabel.toLowerCase();
|
|
3809
|
+
if (action.kind === "selected") {
|
|
3810
|
+
setBulkTarget({
|
|
3811
|
+
action,
|
|
3812
|
+
title: `${deleteLabel} selected sessions?`,
|
|
3813
|
+
body: `${verb === "delete" ? "This permanently removes" : `This ${verb}s`} ${action.ids.length} selected session${action.ids.length === 1 ? "" : "s"} and its messages.`
|
|
3814
|
+
});
|
|
3815
|
+
return;
|
|
3816
|
+
}
|
|
3817
|
+
const range = action.kind === "older-than" ? `older than ${action.days} days` : `from the last ${action.days} days`;
|
|
3818
|
+
setBulkTarget({
|
|
3819
|
+
action,
|
|
3820
|
+
title: `${deleteLabel} sessions ${range}?`,
|
|
3821
|
+
body: "This applies to every matching session in this workspace, including sessions not currently loaded in this list."
|
|
3822
|
+
});
|
|
3823
|
+
}, [deleteLabel]);
|
|
3824
|
+
const confirmBulkAction = useCallback10(async () => {
|
|
3825
|
+
if (!bulkTarget || !onBulkAction) return;
|
|
3826
|
+
setBulkBusy(true);
|
|
3827
|
+
setBulkError(null);
|
|
3828
|
+
try {
|
|
3829
|
+
await onBulkAction(bulkTarget.action);
|
|
3830
|
+
setBulkTarget(null);
|
|
3831
|
+
setSelectedIds(/* @__PURE__ */ new Set());
|
|
3832
|
+
history.reload();
|
|
3833
|
+
} catch (error) {
|
|
3834
|
+
setBulkError(error instanceof Error ? error.message : `Could not ${deleteLabel.toLowerCase()} sessions`);
|
|
3835
|
+
} finally {
|
|
3836
|
+
setBulkBusy(false);
|
|
3837
|
+
}
|
|
3838
|
+
}, [bulkTarget, deleteLabel, history, onBulkAction]);
|
|
3839
|
+
return /* @__PURE__ */ jsxs13("div", { className: `flex min-h-0 min-w-0 flex-1 flex-col ${className ?? ""}`, children: [
|
|
3840
|
+
showHeader && /* @__PURE__ */ jsx15(ShellHeader, { as: "header", className: "bg-transparent px-4 sm:px-6", children: /* @__PURE__ */ jsxs13("div", { className: `flex items-center gap-3 px-3 ${column}`, children: [
|
|
3841
|
+
/* @__PURE__ */ jsx15("h1", { className: "flex-1 truncate text-sm font-semibold text-foreground", children: title }),
|
|
3842
|
+
newSessionHref && /* @__PURE__ */ jsxs13(
|
|
3843
|
+
Link,
|
|
3844
|
+
{
|
|
3845
|
+
to: newSessionHref,
|
|
3846
|
+
className: "inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground transition hover:opacity-90",
|
|
3847
|
+
children: [
|
|
3848
|
+
/* @__PURE__ */ jsx15("span", { "aria-hidden": true, className: "text-sm leading-none", children: "+" }),
|
|
3849
|
+
"New chat"
|
|
3850
|
+
]
|
|
3851
|
+
}
|
|
3852
|
+
)
|
|
3853
|
+
] }) }),
|
|
3854
|
+
/* @__PURE__ */ jsxs13("div", { ref: scrollRef, className: "min-h-0 flex-1 overflow-y-auto", children: [
|
|
3855
|
+
hasAnySessions && /* @__PURE__ */ jsxs13("div", { className: "sticky top-0 z-10 bg-background px-4 sm:px-6", children: [
|
|
3856
|
+
/* @__PURE__ */ jsxs13("div", { className: `flex flex-col gap-2 px-3 pb-3 pt-4 sm:flex-row sm:items-center sm:gap-3 ${column}`, children: [
|
|
3857
|
+
/* @__PURE__ */ jsx15(
|
|
3858
|
+
Input2,
|
|
3859
|
+
{
|
|
3860
|
+
type: "search",
|
|
3861
|
+
value: query,
|
|
3862
|
+
onChange: (e) => onQueryChange(e.target.value),
|
|
3863
|
+
placeholder: "Search your sessions\u2026",
|
|
3864
|
+
"aria-label": "Search sessions",
|
|
3865
|
+
className: "sm:flex-1 [&::-webkit-search-cancel-button]:appearance-none"
|
|
3866
|
+
}
|
|
3867
|
+
),
|
|
3868
|
+
/* @__PURE__ */ jsxs13(Select, { value: sort, onValueChange: (value) => onSortChange(value), children: [
|
|
3869
|
+
/* @__PURE__ */ jsx15(SelectTrigger, { "aria-label": "Sort sessions", className: "shrink-0 sm:w-[132px]", children: /* @__PURE__ */ jsx15(SelectValue, {}) }),
|
|
3870
|
+
/* @__PURE__ */ jsxs13(SelectContent, { children: [
|
|
3871
|
+
/* @__PURE__ */ jsx15(SelectItem, { value: "newest", children: "Newest" }),
|
|
3872
|
+
/* @__PURE__ */ jsx15(SelectItem, { value: "oldest", children: "Oldest" })
|
|
3873
|
+
] })
|
|
3874
|
+
] })
|
|
3875
|
+
] }),
|
|
3876
|
+
onBulkAction && /* @__PURE__ */ jsxs13("div", { className: `flex flex-col gap-2 border-t border-border px-3 py-3 ${column}`, children: [
|
|
3877
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
3878
|
+
/* @__PURE__ */ jsx15(
|
|
3879
|
+
Button3,
|
|
3880
|
+
{
|
|
3881
|
+
type: "button",
|
|
3882
|
+
variant: "outline",
|
|
3883
|
+
size: "sm",
|
|
3884
|
+
onClick: () => setSelectedIds(new Set(history.items.map((item) => item.id))),
|
|
3885
|
+
disabled: allVisibleSelected || history.items.length === 0,
|
|
3886
|
+
children: "Select all"
|
|
3887
|
+
}
|
|
3888
|
+
),
|
|
3889
|
+
/* @__PURE__ */ jsx15(
|
|
3890
|
+
Button3,
|
|
3891
|
+
{
|
|
3892
|
+
type: "button",
|
|
3893
|
+
variant: "outline",
|
|
3894
|
+
size: "sm",
|
|
3895
|
+
onClick: () => setSelectedIds(/* @__PURE__ */ new Set()),
|
|
3896
|
+
disabled: selectedCount === 0,
|
|
3897
|
+
children: "Deselect all"
|
|
3898
|
+
}
|
|
3899
|
+
),
|
|
3900
|
+
selectedCount > 0 && /* @__PURE__ */ jsxs13(
|
|
3901
|
+
Button3,
|
|
3902
|
+
{
|
|
3903
|
+
type: "button",
|
|
3904
|
+
variant: "destructive",
|
|
3905
|
+
size: "sm",
|
|
3906
|
+
onClick: () => openBulkAction({ kind: "selected", ids: [...selectedIds] }),
|
|
3907
|
+
children: [
|
|
3908
|
+
deleteLabel,
|
|
3909
|
+
" selected"
|
|
3910
|
+
]
|
|
3911
|
+
}
|
|
3912
|
+
)
|
|
3913
|
+
] }),
|
|
3914
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
3915
|
+
/* @__PURE__ */ jsx15("label", { htmlFor: "agent-app-session-age", className: "text-xs text-muted-foreground", children: "Session age" }),
|
|
3916
|
+
/* @__PURE__ */ jsx15(
|
|
3917
|
+
Input2,
|
|
3918
|
+
{
|
|
3919
|
+
id: "agent-app-session-age",
|
|
3920
|
+
type: "number",
|
|
3921
|
+
min: 1,
|
|
3922
|
+
max: 36500,
|
|
3923
|
+
value: ageDays,
|
|
3924
|
+
onChange: (event) => setAgeDays(event.target.value),
|
|
3925
|
+
"aria-invalid": ageDays.length > 0 && !validAgeDays,
|
|
3926
|
+
size: "sm",
|
|
3927
|
+
className: "w-20 tabular-nums"
|
|
3928
|
+
}
|
|
3929
|
+
),
|
|
3930
|
+
/* @__PURE__ */ jsx15("span", { className: "text-xs text-muted-foreground", children: "days" }),
|
|
3931
|
+
/* @__PURE__ */ jsxs13(
|
|
3932
|
+
Button3,
|
|
3933
|
+
{
|
|
3934
|
+
type: "button",
|
|
3935
|
+
variant: "outline",
|
|
3936
|
+
size: "sm",
|
|
3937
|
+
onClick: () => openBulkAction({ kind: "older-than", days: parsedAgeDays }),
|
|
3938
|
+
disabled: !validAgeDays,
|
|
3939
|
+
children: [
|
|
3940
|
+
deleteLabel,
|
|
3941
|
+
" older"
|
|
3942
|
+
]
|
|
3943
|
+
}
|
|
3944
|
+
),
|
|
3945
|
+
/* @__PURE__ */ jsxs13(
|
|
3946
|
+
Button3,
|
|
3947
|
+
{
|
|
3948
|
+
type: "button",
|
|
3949
|
+
variant: "outline",
|
|
3950
|
+
size: "sm",
|
|
3951
|
+
onClick: () => openBulkAction({ kind: "newer-than", days: parsedAgeDays }),
|
|
3952
|
+
disabled: !validAgeDays,
|
|
3953
|
+
children: [
|
|
3954
|
+
deleteLabel,
|
|
3955
|
+
" recent"
|
|
3956
|
+
]
|
|
3957
|
+
}
|
|
3958
|
+
)
|
|
3959
|
+
] })
|
|
3960
|
+
] })
|
|
3961
|
+
] }),
|
|
3962
|
+
/* @__PURE__ */ jsx15("div", { className: `px-4 pb-8 pt-1 sm:px-6 ${column}`, children: !hasAnySessions ? /* @__PURE__ */ jsxs13("div", { className: "flex min-h-[50vh] flex-col items-center justify-center gap-2 text-center", children: [
|
|
3963
|
+
/* @__PURE__ */ jsx15("p", { className: "text-sm font-medium text-foreground", children: emptyTitle }),
|
|
3964
|
+
/* @__PURE__ */ jsx15("p", { className: "max-w-xs text-xs text-muted-foreground", children: emptyDescription })
|
|
3965
|
+
] }) : history.isLoadingFirst ? /* @__PURE__ */ jsx15(SkeletonRows, {}) : history.items.length === 0 ? history.isError ? /* @__PURE__ */ jsx15(ErrorBlock, { onRetry: history.retry, message: "Couldn\u2019t load your sessions." }) : isSearching ? /* @__PURE__ */ jsxs13("p", { className: "py-16 text-center text-sm text-muted-foreground", children: [
|
|
3966
|
+
"No sessions match \u201C",
|
|
3967
|
+
searchTerm,
|
|
3968
|
+
"\u201D."
|
|
3969
|
+
] }) : /* @__PURE__ */ jsx15("p", { className: "py-16 text-center text-sm text-muted-foreground", children: "No sessions remain." }) : /* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-0.5", children: [
|
|
3970
|
+
history.items.map((session) => /* @__PURE__ */ jsx15(
|
|
3971
|
+
SessionRow,
|
|
3972
|
+
{
|
|
3973
|
+
session,
|
|
3974
|
+
href: hrefForSession(session.id),
|
|
3975
|
+
Link,
|
|
3976
|
+
responding: respondingSessionIds?.has(session.id) ?? false,
|
|
3977
|
+
untitledLabel,
|
|
3978
|
+
timestamp: formatTimestamp(session.updatedAt),
|
|
3979
|
+
onRename,
|
|
3980
|
+
onDelete,
|
|
3981
|
+
selectable: Boolean(onBulkAction),
|
|
3982
|
+
selected: selectedIds.has(session.id),
|
|
3983
|
+
onSelectedChange: (selected) => {
|
|
3984
|
+
setSelectedIds((current) => {
|
|
3985
|
+
const next = new Set(current);
|
|
3986
|
+
if (selected) next.add(session.id);
|
|
3987
|
+
else next.delete(session.id);
|
|
3988
|
+
return next;
|
|
3989
|
+
});
|
|
3990
|
+
},
|
|
3991
|
+
renameLabel,
|
|
3992
|
+
deleteLabel,
|
|
3993
|
+
extraActions
|
|
3994
|
+
},
|
|
3995
|
+
session.id
|
|
3996
|
+
)),
|
|
3997
|
+
history.isError ? /* @__PURE__ */ jsx15(ErrorBlock, { onRetry: history.retry, message: "Couldn\u2019t load more sessions.", inline: true }) : history.hasMore ? /* @__PURE__ */ jsx15("div", { ref: sentinelRef, className: "flex items-center justify-center py-6", children: history.isLoadingMore && /* @__PURE__ */ jsx15("span", { role: "status", "aria-live": "polite", "aria-busy": true, className: "text-xs text-muted-foreground", children: "Loading\u2026" }) }) : null
|
|
3998
|
+
] }) })
|
|
3999
|
+
] }),
|
|
4000
|
+
bulkTarget && /* @__PURE__ */ jsx15(
|
|
4001
|
+
ActionDialog,
|
|
4002
|
+
{
|
|
4003
|
+
title: bulkTarget.title,
|
|
4004
|
+
onClose: () => {
|
|
4005
|
+
if (!bulkBusy) {
|
|
4006
|
+
setBulkTarget(null);
|
|
4007
|
+
setBulkError(null);
|
|
4008
|
+
}
|
|
4009
|
+
},
|
|
4010
|
+
busy: bulkBusy,
|
|
4011
|
+
error: bulkError,
|
|
4012
|
+
footer: /* @__PURE__ */ jsxs13(Fragment5, { children: [
|
|
4013
|
+
/* @__PURE__ */ jsx15(
|
|
4014
|
+
ActionDialogButton,
|
|
4015
|
+
{
|
|
4016
|
+
onClick: () => {
|
|
4017
|
+
setBulkTarget(null);
|
|
4018
|
+
setBulkError(null);
|
|
4019
|
+
},
|
|
4020
|
+
disabled: bulkBusy,
|
|
4021
|
+
variant: "ghost",
|
|
4022
|
+
children: "Cancel"
|
|
4023
|
+
}
|
|
4024
|
+
),
|
|
4025
|
+
/* @__PURE__ */ jsx15(ActionDialogButton, { onClick: () => void confirmBulkAction(), disabled: bulkBusy, variant: "destructive", children: bulkBusy ? "Working\u2026" : deleteLabel })
|
|
4026
|
+
] }),
|
|
4027
|
+
children: /* @__PURE__ */ jsx15("p", { className: "text-sm text-muted-foreground", children: bulkTarget.body })
|
|
4028
|
+
}
|
|
4029
|
+
)
|
|
4030
|
+
] });
|
|
4031
|
+
}
|
|
4032
|
+
function ErrorBlock({ message, onRetry, inline }) {
|
|
4033
|
+
return /* @__PURE__ */ jsxs13(
|
|
4034
|
+
"div",
|
|
4035
|
+
{
|
|
4036
|
+
className: inline ? "flex items-center justify-center gap-3 py-6 text-sm text-muted-foreground" : "flex min-h-[40vh] flex-col items-center justify-center gap-3 text-center",
|
|
4037
|
+
children: [
|
|
4038
|
+
/* @__PURE__ */ jsx15("span", { className: "text-sm text-muted-foreground", children: message }),
|
|
4039
|
+
/* @__PURE__ */ jsx15(Button3, { type: "button", variant: "outline", size: "sm", onClick: onRetry, children: "Retry" })
|
|
4040
|
+
]
|
|
4041
|
+
}
|
|
4042
|
+
);
|
|
4043
|
+
}
|
|
4044
|
+
function SessionRow({
|
|
4045
|
+
session,
|
|
4046
|
+
href,
|
|
4047
|
+
Link,
|
|
4048
|
+
responding,
|
|
4049
|
+
untitledLabel,
|
|
4050
|
+
timestamp,
|
|
4051
|
+
onRename,
|
|
4052
|
+
onDelete,
|
|
4053
|
+
renameLabel,
|
|
4054
|
+
deleteLabel,
|
|
4055
|
+
extraActions,
|
|
4056
|
+
selectable,
|
|
4057
|
+
selected,
|
|
4058
|
+
onSelectedChange
|
|
4059
|
+
}) {
|
|
4060
|
+
const [menuOpen, setMenuOpen] = useState18(false);
|
|
4061
|
+
const panelId = useId2();
|
|
4062
|
+
const { containerRef, triggerRef, panelRef, triggerProps } = usePopover(menuOpen, setMenuOpen);
|
|
4063
|
+
const extras = extraActions?.(session) ?? [];
|
|
4064
|
+
const hasMenu = Boolean(onRename) || Boolean(onDelete) || extras.length > 0;
|
|
4065
|
+
const showUnread = Boolean(session.unread) && !responding;
|
|
4066
|
+
return /* @__PURE__ */ jsxs13("div", { className: `group relative flex items-center gap-2 rounded-lg px-3 py-2.5 transition-colors hover:bg-accent ${selected ? "bg-primary/10" : ""}`, children: [
|
|
4067
|
+
selectable && /* @__PURE__ */ jsx15(
|
|
4068
|
+
Checkbox,
|
|
4069
|
+
{
|
|
4070
|
+
checked: selected,
|
|
4071
|
+
onCheckedChange: (checked) => onSelectedChange(checked === true),
|
|
4072
|
+
"aria-label": `Select ${sessionLabel(session, untitledLabel)}`
|
|
4073
|
+
}
|
|
4074
|
+
),
|
|
4075
|
+
/* @__PURE__ */ jsxs13(Link, { to: href, className: "flex min-w-0 flex-1 items-center gap-3", children: [
|
|
4076
|
+
showUnread && /* @__PURE__ */ jsx15("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full bg-primary", "aria-hidden": true }),
|
|
4077
|
+
/* @__PURE__ */ jsx15(MessageIcon, { className: "h-4 w-4 shrink-0 text-muted-foreground" }),
|
|
4078
|
+
/* @__PURE__ */ jsx15(
|
|
4079
|
+
"span",
|
|
4080
|
+
{
|
|
4081
|
+
className: `truncate text-sm ${responding ? "text-muted-foreground" : "text-foreground"} ${showUnread ? "font-semibold" : ""}`,
|
|
4082
|
+
...responding ? { role: "status", "aria-label": "Agent responding" } : {},
|
|
4083
|
+
children: sessionLabel(session, untitledLabel)
|
|
4084
|
+
}
|
|
4085
|
+
)
|
|
4086
|
+
] }),
|
|
4087
|
+
/* @__PURE__ */ jsx15("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: timestamp }),
|
|
4088
|
+
hasMenu && /* @__PURE__ */ jsxs13("div", { ref: containerRef, className: "relative shrink-0", children: [
|
|
4089
|
+
/* @__PURE__ */ jsx15(
|
|
4090
|
+
Button3,
|
|
4091
|
+
{
|
|
4092
|
+
type: "button",
|
|
4093
|
+
variant: "ghost",
|
|
4094
|
+
size: "icon-sm",
|
|
4095
|
+
...triggerProps,
|
|
4096
|
+
"aria-label": "Session actions",
|
|
4097
|
+
"aria-controls": menuOpen ? panelId : void 0,
|
|
4098
|
+
onClick: () => setMenuOpen((open) => !open),
|
|
4099
|
+
className: "text-muted-foreground focus-visible:opacity-100 sm:opacity-0 sm:group-hover:opacity-100 aria-expanded:opacity-100",
|
|
4100
|
+
children: /* @__PURE__ */ jsx15("span", { "aria-hidden": true, className: "text-base leading-none", children: "\u22EF" })
|
|
4101
|
+
}
|
|
4102
|
+
),
|
|
4103
|
+
/* @__PURE__ */ jsxs13(
|
|
4104
|
+
PopoverSurface,
|
|
4105
|
+
{
|
|
4106
|
+
open: menuOpen,
|
|
4107
|
+
id: panelId,
|
|
4108
|
+
role: "menu",
|
|
4109
|
+
triggerRef,
|
|
4110
|
+
panelRef,
|
|
4111
|
+
className: `w-36 overflow-hidden rounded-md border border-card-edge bg-popover py-1 ${OVERLAY_SHADOW}`,
|
|
4112
|
+
children: [
|
|
4113
|
+
onRename && /* @__PURE__ */ jsx15(
|
|
4114
|
+
"button",
|
|
4115
|
+
{
|
|
4116
|
+
type: "button",
|
|
4117
|
+
role: "menuitem",
|
|
4118
|
+
onClick: () => {
|
|
4119
|
+
setMenuOpen(false);
|
|
4120
|
+
onRename(session);
|
|
4121
|
+
},
|
|
4122
|
+
className: "block w-full px-3 py-1.5 text-left text-xs text-foreground transition hover:bg-accent",
|
|
4123
|
+
children: renameLabel
|
|
4124
|
+
}
|
|
4125
|
+
),
|
|
4126
|
+
extras.map((action) => /* @__PURE__ */ jsx15(
|
|
4127
|
+
"button",
|
|
4128
|
+
{
|
|
4129
|
+
type: "button",
|
|
4130
|
+
role: "menuitem",
|
|
4131
|
+
onClick: () => {
|
|
4132
|
+
setMenuOpen(false);
|
|
4133
|
+
action.onSelect();
|
|
4134
|
+
},
|
|
4135
|
+
className: `block w-full px-3 py-1.5 text-left text-xs transition ${action.destructive ? "text-destructive hover:bg-destructive/10" : "text-foreground hover:bg-accent"}`,
|
|
4136
|
+
children: action.label
|
|
4137
|
+
},
|
|
4138
|
+
action.id
|
|
4139
|
+
)),
|
|
4140
|
+
onDelete && /* @__PURE__ */ jsx15(
|
|
4141
|
+
"button",
|
|
4142
|
+
{
|
|
4143
|
+
type: "button",
|
|
4144
|
+
role: "menuitem",
|
|
4145
|
+
onClick: () => {
|
|
4146
|
+
setMenuOpen(false);
|
|
4147
|
+
onDelete(session);
|
|
4148
|
+
},
|
|
4149
|
+
className: "block w-full px-3 py-1.5 text-left text-xs text-destructive transition hover:bg-destructive/10",
|
|
4150
|
+
children: deleteLabel
|
|
4151
|
+
}
|
|
4152
|
+
)
|
|
4153
|
+
]
|
|
4154
|
+
}
|
|
4155
|
+
)
|
|
4156
|
+
] })
|
|
4157
|
+
] });
|
|
4158
|
+
}
|
|
4159
|
+
|
|
3454
4160
|
// src/web-react/record-grid.tsx
|
|
3455
4161
|
import {
|
|
3456
|
-
Fragment as
|
|
4162
|
+
Fragment as Fragment6,
|
|
3457
4163
|
isValidElement,
|
|
3458
|
-
useCallback as
|
|
3459
|
-
useEffect as
|
|
3460
|
-
useId as
|
|
3461
|
-
useMemo as
|
|
3462
|
-
useRef as
|
|
3463
|
-
useState as
|
|
4164
|
+
useCallback as useCallback11,
|
|
4165
|
+
useEffect as useEffect12,
|
|
4166
|
+
useId as useId3,
|
|
4167
|
+
useMemo as useMemo7,
|
|
4168
|
+
useRef as useRef12,
|
|
4169
|
+
useState as useState19
|
|
3464
4170
|
} from "react";
|
|
3465
|
-
import { Button as
|
|
4171
|
+
import { Button as Button4, EmptyState, Skeleton, Table, TableHeader, TableBody, TableFooter, TableRow, TableHead, TableCell } from "@tangle-network/ui/primitives";
|
|
3466
4172
|
|
|
3467
4173
|
// src/web-react/record-grid-model.ts
|
|
3468
4174
|
function recordGridOk(value) {
|
|
@@ -3817,7 +4523,7 @@ function pruneRecordGridOverlay(rows, overlay) {
|
|
|
3817
4523
|
}
|
|
3818
4524
|
|
|
3819
4525
|
// src/web-react/record-grid.tsx
|
|
3820
|
-
import { jsx as
|
|
4526
|
+
import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
3821
4527
|
var EMPTY_RECORD_GRID_ROWS = [];
|
|
3822
4528
|
var CELL_KEY_SEPARATOR = "\0";
|
|
3823
4529
|
function cellKey(rowId, columnId) {
|
|
@@ -3876,57 +4582,57 @@ function RecordGrid({
|
|
|
3876
4582
|
loadingRowCount = 3,
|
|
3877
4583
|
className
|
|
3878
4584
|
}) {
|
|
3879
|
-
const fieldPrefix =
|
|
3880
|
-
const [overlay, setOverlay] =
|
|
3881
|
-
const [editing, setEditingState] =
|
|
3882
|
-
const [cellErrors, setCellErrors] =
|
|
3883
|
-
const [rowErrors, setRowErrors] =
|
|
3884
|
-
const [pendingRows, setPendingRows] =
|
|
3885
|
-
const [focus, setFocus] =
|
|
3886
|
-
const [openSource, setOpenSource] =
|
|
3887
|
-
const [confirmDelete, setConfirmDelete] =
|
|
3888
|
-
const [adding, setAdding] =
|
|
3889
|
-
const [draft, setDraft] =
|
|
3890
|
-
const [draftErrors, setDraftErrors] =
|
|
3891
|
-
const [draftError, setDraftError] =
|
|
3892
|
-
const [creating, setCreating] =
|
|
3893
|
-
const cellRefs =
|
|
3894
|
-
const settling =
|
|
3895
|
-
const draftCounter =
|
|
3896
|
-
const editingRef =
|
|
3897
|
-
const setEditing =
|
|
4585
|
+
const fieldPrefix = useId3();
|
|
4586
|
+
const [overlay, setOverlay] = useState19(EMPTY_RECORD_GRID_OVERLAY);
|
|
4587
|
+
const [editing, setEditingState] = useState19(null);
|
|
4588
|
+
const [cellErrors, setCellErrors] = useState19({});
|
|
4589
|
+
const [rowErrors, setRowErrors] = useState19({});
|
|
4590
|
+
const [pendingRows, setPendingRows] = useState19({});
|
|
4591
|
+
const [focus, setFocus] = useState19(null);
|
|
4592
|
+
const [openSource, setOpenSource] = useState19(null);
|
|
4593
|
+
const [confirmDelete, setConfirmDelete] = useState19(null);
|
|
4594
|
+
const [adding, setAdding] = useState19(false);
|
|
4595
|
+
const [draft, setDraft] = useState19({ ...newRowDefaults ?? {} });
|
|
4596
|
+
const [draftErrors, setDraftErrors] = useState19({});
|
|
4597
|
+
const [draftError, setDraftError] = useState19(null);
|
|
4598
|
+
const [creating, setCreating] = useState19(false);
|
|
4599
|
+
const cellRefs = useRef12(/* @__PURE__ */ new Map());
|
|
4600
|
+
const settling = useRef12(false);
|
|
4601
|
+
const draftCounter = useRef12(0);
|
|
4602
|
+
const editingRef = useRef12(null);
|
|
4603
|
+
const setEditing = useCallback11((next) => {
|
|
3898
4604
|
editingRef.current = next;
|
|
3899
4605
|
setEditingState(next);
|
|
3900
4606
|
}, []);
|
|
3901
4607
|
const callerRows = state.status === "ready" || state.status === "empty" ? state.value : EMPTY_RECORD_GRID_ROWS;
|
|
3902
|
-
|
|
4608
|
+
useEffect12(() => {
|
|
3903
4609
|
setOverlay((current) => pruneRecordGridOverlay(callerRows, current));
|
|
3904
4610
|
}, [callerRows]);
|
|
3905
|
-
const visibleRows =
|
|
3906
|
-
const diffs =
|
|
4611
|
+
const visibleRows = useMemo7(() => projectRecordGridRows(callerRows, overlay), [callerRows, overlay]);
|
|
4612
|
+
const diffs = useMemo7(
|
|
3907
4613
|
() => proposed === void 0 ? null : diffRecordGridProposal(visibleRows, proposed),
|
|
3908
4614
|
[proposed, visibleRows]
|
|
3909
4615
|
);
|
|
3910
4616
|
const reviewing = diffs !== null && diffs.length > 0;
|
|
3911
|
-
const diffByRow =
|
|
3912
|
-
const diffCellByKey =
|
|
4617
|
+
const diffByRow = useMemo7(() => new Map((diffs ?? []).map((diff) => [diff.rowId, diff])), [diffs]);
|
|
4618
|
+
const diffCellByKey = useMemo7(() => {
|
|
3913
4619
|
const map = /* @__PURE__ */ new Map();
|
|
3914
4620
|
for (const diff of diffs ?? []) {
|
|
3915
4621
|
for (const cell of diff.cells) map.set(cellKey(diff.rowId, cell.columnId), cell);
|
|
3916
4622
|
}
|
|
3917
4623
|
return map;
|
|
3918
4624
|
}, [diffs]);
|
|
3919
|
-
const addedRows =
|
|
4625
|
+
const addedRows = useMemo7(
|
|
3920
4626
|
() => (diffs ?? []).filter((diff) => diff.kind === "added").map((diff) => diff.row),
|
|
3921
4627
|
[diffs]
|
|
3922
4628
|
);
|
|
3923
|
-
const activeFocus =
|
|
4629
|
+
const activeFocus = useMemo7(() => {
|
|
3924
4630
|
if (focus === null) return null;
|
|
3925
4631
|
if (!visibleRows.some((row) => row.id === focus.rowId)) return null;
|
|
3926
4632
|
if (!columns.some((column) => column.id === focus.columnId)) return null;
|
|
3927
4633
|
return focus;
|
|
3928
4634
|
}, [columns, focus, visibleRows]);
|
|
3929
|
-
const setCellError =
|
|
4635
|
+
const setCellError = useCallback11((key, message) => {
|
|
3930
4636
|
setCellErrors((current) => {
|
|
3931
4637
|
if (message === null) {
|
|
3932
4638
|
if (!(key in current)) return current;
|
|
@@ -3938,7 +4644,7 @@ function RecordGrid({
|
|
|
3938
4644
|
return { ...current, [key]: message };
|
|
3939
4645
|
});
|
|
3940
4646
|
}, []);
|
|
3941
|
-
const setRowError =
|
|
4647
|
+
const setRowError = useCallback11((rowId, message) => {
|
|
3942
4648
|
setRowErrors((current) => {
|
|
3943
4649
|
if (message === null) {
|
|
3944
4650
|
if (!(rowId in current)) return current;
|
|
@@ -3949,7 +4655,7 @@ function RecordGrid({
|
|
|
3949
4655
|
return { ...current, [rowId]: message };
|
|
3950
4656
|
});
|
|
3951
4657
|
}, []);
|
|
3952
|
-
const setRowPending =
|
|
4658
|
+
const setRowPending = useCallback11((rowId, pending) => {
|
|
3953
4659
|
setPendingRows((current) => {
|
|
3954
4660
|
if (pending) return rowId in current ? current : { ...current, [rowId]: true };
|
|
3955
4661
|
if (!(rowId in current)) return current;
|
|
@@ -3958,11 +4664,11 @@ function RecordGrid({
|
|
|
3958
4664
|
return next;
|
|
3959
4665
|
});
|
|
3960
4666
|
}, []);
|
|
3961
|
-
const focusCell =
|
|
4667
|
+
const focusCell = useCallback11((rowId, columnId) => {
|
|
3962
4668
|
setFocus({ rowId, columnId });
|
|
3963
4669
|
cellRefs.current.get(cellKey(rowId, columnId))?.focus();
|
|
3964
4670
|
}, []);
|
|
3965
|
-
const beginEdit =
|
|
4671
|
+
const beginEdit = useCallback11(
|
|
3966
4672
|
(row, column) => {
|
|
3967
4673
|
setCellError(cellKey(row.id, column.id), null);
|
|
3968
4674
|
setEditing({
|
|
@@ -3973,7 +4679,7 @@ function RecordGrid({
|
|
|
3973
4679
|
},
|
|
3974
4680
|
[setCellError, setEditing]
|
|
3975
4681
|
);
|
|
3976
|
-
const applyCellWrite =
|
|
4682
|
+
const applyCellWrite = useCallback11(
|
|
3977
4683
|
async (row, column, value) => {
|
|
3978
4684
|
if (!onUpdate) return;
|
|
3979
4685
|
const values = { ...row.values, [column.id]: value };
|
|
@@ -4001,7 +4707,7 @@ function RecordGrid({
|
|
|
4001
4707
|
},
|
|
4002
4708
|
[locale, onUpdate, setRowError, setRowPending]
|
|
4003
4709
|
);
|
|
4004
|
-
const commitEdit =
|
|
4710
|
+
const commitEdit = useCallback11(
|
|
4005
4711
|
async (row, column, text) => {
|
|
4006
4712
|
const open = editingRef.current;
|
|
4007
4713
|
if (open === null || open.rowId !== row.id || open.columnId !== column.id) return;
|
|
@@ -4025,7 +4731,7 @@ function RecordGrid({
|
|
|
4025
4731
|
},
|
|
4026
4732
|
[applyCellWrite, setCellError, setEditing]
|
|
4027
4733
|
);
|
|
4028
|
-
const cancelEdit =
|
|
4734
|
+
const cancelEdit = useCallback11(
|
|
4029
4735
|
(row, column) => {
|
|
4030
4736
|
setCellError(cellKey(row.id, column.id), null);
|
|
4031
4737
|
setEditing(null);
|
|
@@ -4033,7 +4739,7 @@ function RecordGrid({
|
|
|
4033
4739
|
},
|
|
4034
4740
|
[focusCell, setCellError, setEditing]
|
|
4035
4741
|
);
|
|
4036
|
-
const performDelete =
|
|
4742
|
+
const performDelete = useCallback11(
|
|
4037
4743
|
async (row) => {
|
|
4038
4744
|
if (!onDelete) return;
|
|
4039
4745
|
setConfirmDelete(null);
|
|
@@ -4051,16 +4757,16 @@ function RecordGrid({
|
|
|
4051
4757
|
},
|
|
4052
4758
|
[columns, onDelete, setRowError]
|
|
4053
4759
|
);
|
|
4054
|
-
const resetDraft =
|
|
4760
|
+
const resetDraft = useCallback11(() => {
|
|
4055
4761
|
setDraft({ ...newRowDefaults ?? {} });
|
|
4056
4762
|
setDraftErrors({});
|
|
4057
4763
|
setDraftError(null);
|
|
4058
4764
|
}, [newRowDefaults]);
|
|
4059
|
-
const openAdd =
|
|
4765
|
+
const openAdd = useCallback11(() => {
|
|
4060
4766
|
resetDraft();
|
|
4061
4767
|
setAdding(true);
|
|
4062
4768
|
}, [resetDraft]);
|
|
4063
|
-
const submitDraft =
|
|
4769
|
+
const submitDraft = useCallback11(async () => {
|
|
4064
4770
|
if (!onCreate) return;
|
|
4065
4771
|
const validated = validateRecordGridRow(columns, draft);
|
|
4066
4772
|
if (!validated.succeeded) {
|
|
@@ -4090,7 +4796,7 @@ function RecordGrid({
|
|
|
4090
4796
|
setOverlay((current) => withoutRecordGridCreated(current, draftId));
|
|
4091
4797
|
setDraftError(outcome.error);
|
|
4092
4798
|
}, [columns, draft, fieldPrefix, onCreate, resetDraft]);
|
|
4093
|
-
const handleGridKeyDown =
|
|
4799
|
+
const handleGridKeyDown = useCallback11(
|
|
4094
4800
|
(event) => {
|
|
4095
4801
|
if (editing !== null) return;
|
|
4096
4802
|
const target = event.target;
|
|
@@ -4129,9 +4835,9 @@ function RecordGrid({
|
|
|
4129
4835
|
[beginEdit, columns, editing, focusCell, onUpdate, reviewing, visibleRows]
|
|
4130
4836
|
);
|
|
4131
4837
|
if (state.status === "idle" || state.status === "loading") {
|
|
4132
|
-
return /* @__PURE__ */
|
|
4838
|
+
return /* @__PURE__ */ jsxs14("div", { className: `space-y-3 ${className ?? ""}`, children: [
|
|
4133
4839
|
toolbar,
|
|
4134
|
-
/* @__PURE__ */
|
|
4840
|
+
/* @__PURE__ */ jsxs14(
|
|
4135
4841
|
"div",
|
|
4136
4842
|
{
|
|
4137
4843
|
role: "status",
|
|
@@ -4139,22 +4845,22 @@ function RecordGrid({
|
|
|
4139
4845
|
"aria-live": "polite",
|
|
4140
4846
|
className: "space-y-2 rounded-xl border border-card-edge bg-card p-4",
|
|
4141
4847
|
children: [
|
|
4142
|
-
/* @__PURE__ */
|
|
4848
|
+
/* @__PURE__ */ jsxs14("span", { className: "sr-only", children: [
|
|
4143
4849
|
"Loading ",
|
|
4144
4850
|
caption
|
|
4145
4851
|
] }),
|
|
4146
|
-
Array.from({ length: Math.max(1, loadingRowCount) }, (_, index) => /* @__PURE__ */
|
|
4852
|
+
Array.from({ length: Math.max(1, loadingRowCount) }, (_, index) => /* @__PURE__ */ jsx16(Skeleton, { className: "h-8", "aria-hidden": true }, index))
|
|
4147
4853
|
]
|
|
4148
4854
|
}
|
|
4149
4855
|
)
|
|
4150
4856
|
] });
|
|
4151
4857
|
}
|
|
4152
4858
|
if (state.status === "error") {
|
|
4153
|
-
return /* @__PURE__ */
|
|
4859
|
+
return /* @__PURE__ */ jsxs14("div", { className: `space-y-3 ${className ?? ""}`, children: [
|
|
4154
4860
|
toolbar,
|
|
4155
|
-
/* @__PURE__ */
|
|
4156
|
-
/* @__PURE__ */
|
|
4157
|
-
/* @__PURE__ */
|
|
4861
|
+
/* @__PURE__ */ jsxs14("div", { role: "alert", className: "rounded-xl border border-destructive/40 bg-destructive/10 px-4 py-4", children: [
|
|
4862
|
+
/* @__PURE__ */ jsx16("p", { className: "text-sm font-medium text-destructive", children: state.message }),
|
|
4863
|
+
/* @__PURE__ */ jsx16(
|
|
4158
4864
|
"button",
|
|
4159
4865
|
{
|
|
4160
4866
|
type: "button",
|
|
@@ -4166,7 +4872,7 @@ function RecordGrid({
|
|
|
4166
4872
|
] })
|
|
4167
4873
|
] });
|
|
4168
4874
|
}
|
|
4169
|
-
const addForm = adding && onCreate && !reviewing ? /* @__PURE__ */
|
|
4875
|
+
const addForm = adding && onCreate && !reviewing ? /* @__PURE__ */ jsx16(
|
|
4170
4876
|
AddRecordForm,
|
|
4171
4877
|
{
|
|
4172
4878
|
columns,
|
|
@@ -4185,17 +4891,17 @@ function RecordGrid({
|
|
|
4185
4891
|
}
|
|
4186
4892
|
) : null;
|
|
4187
4893
|
if (visibleRows.length === 0 && !reviewing) {
|
|
4188
|
-
return /* @__PURE__ */
|
|
4894
|
+
return /* @__PURE__ */ jsxs14("div", { className: `space-y-3 ${className ?? ""}`, children: [
|
|
4189
4895
|
toolbar,
|
|
4190
|
-
addForm ?? /* @__PURE__ */
|
|
4896
|
+
addForm ?? /* @__PURE__ */ jsx16(
|
|
4191
4897
|
EmptyState,
|
|
4192
4898
|
{
|
|
4193
4899
|
title: empty.title,
|
|
4194
4900
|
description: empty.description,
|
|
4195
4901
|
className: "rounded-xl border border-dashed border-border",
|
|
4196
|
-
action: /* @__PURE__ */
|
|
4197
|
-
empty.action && (isValidElement(empty.action) ? empty.action : /* @__PURE__ */
|
|
4198
|
-
onCreate && /* @__PURE__ */
|
|
4902
|
+
action: /* @__PURE__ */ jsxs14("div", { className: "flex flex-wrap items-center justify-center gap-2", children: [
|
|
4903
|
+
empty.action && (isValidElement(empty.action) ? empty.action : /* @__PURE__ */ jsx16(Button4, { type: "button", variant: "outline", size: "sm", onClick: empty.action.onClick, children: empty.action.label })),
|
|
4904
|
+
onCreate && /* @__PURE__ */ jsx16(Button4, { type: "button", variant: "outline", size: "sm", onClick: openAdd, children: addLabel })
|
|
4199
4905
|
] })
|
|
4200
4906
|
}
|
|
4201
4907
|
)
|
|
@@ -4213,18 +4919,18 @@ function RecordGrid({
|
|
|
4213
4919
|
addedCount > 0 ? `${addedCount} added` : null,
|
|
4214
4920
|
removedCount > 0 ? `${removedCount} removed` : null
|
|
4215
4921
|
].filter((part) => part !== null).join(" \xB7 ");
|
|
4216
|
-
const reviewBar = reviewing ? /* @__PURE__ */
|
|
4922
|
+
const reviewBar = reviewing ? /* @__PURE__ */ jsxs14(
|
|
4217
4923
|
"div",
|
|
4218
4924
|
{
|
|
4219
4925
|
"data-record-grid-review": "",
|
|
4220
4926
|
className: "flex flex-wrap items-center justify-between gap-3 rounded-xl border border-card-edge bg-card px-4 py-2.5",
|
|
4221
4927
|
children: [
|
|
4222
|
-
/* @__PURE__ */
|
|
4223
|
-
/* @__PURE__ */
|
|
4224
|
-
/* @__PURE__ */
|
|
4928
|
+
/* @__PURE__ */ jsxs14("div", { className: "min-w-0", children: [
|
|
4929
|
+
/* @__PURE__ */ jsx16("p", { className: "text-[11px] font-semibold uppercase tracking-[0.05em] text-muted-foreground", children: "Proposed changes" }),
|
|
4930
|
+
/* @__PURE__ */ jsx16("p", { className: "mt-0.5 text-xs tabular-nums text-muted-foreground", children: reviewSummary })
|
|
4225
4931
|
] }),
|
|
4226
|
-
(onAcceptAll || onRejectAll) && /* @__PURE__ */
|
|
4227
|
-
onRejectAll && /* @__PURE__ */
|
|
4932
|
+
(onAcceptAll || onRejectAll) && /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2", children: [
|
|
4933
|
+
onRejectAll && /* @__PURE__ */ jsx16(
|
|
4228
4934
|
"button",
|
|
4229
4935
|
{
|
|
4230
4936
|
type: "button",
|
|
@@ -4234,7 +4940,7 @@ function RecordGrid({
|
|
|
4234
4940
|
children: "Reject all"
|
|
4235
4941
|
}
|
|
4236
4942
|
),
|
|
4237
|
-
onAcceptAll && /* @__PURE__ */
|
|
4943
|
+
onAcceptAll && /* @__PURE__ */ jsx16(
|
|
4238
4944
|
"button",
|
|
4239
4945
|
{
|
|
4240
4946
|
type: "button",
|
|
@@ -4248,10 +4954,10 @@ function RecordGrid({
|
|
|
4248
4954
|
]
|
|
4249
4955
|
}
|
|
4250
4956
|
) : null;
|
|
4251
|
-
return /* @__PURE__ */
|
|
4957
|
+
return /* @__PURE__ */ jsxs14("div", { className: `space-y-3 ${className ?? ""}`, children: [
|
|
4252
4958
|
toolbar,
|
|
4253
4959
|
reviewBar,
|
|
4254
|
-
/* @__PURE__ */
|
|
4960
|
+
/* @__PURE__ */ jsx16("div", { className: "overflow-x-auto rounded-xl border border-card-edge bg-card", children: /* @__PURE__ */ jsxs14(
|
|
4255
4961
|
Table,
|
|
4256
4962
|
{
|
|
4257
4963
|
wrapper: false,
|
|
@@ -4260,8 +4966,8 @@ function RecordGrid({
|
|
|
4260
4966
|
className: "border-collapse text-left",
|
|
4261
4967
|
onKeyDown: handleGridKeyDown,
|
|
4262
4968
|
children: [
|
|
4263
|
-
/* @__PURE__ */
|
|
4264
|
-
columns.map((column) => /* @__PURE__ */
|
|
4969
|
+
/* @__PURE__ */ jsx16(TableHeader, { children: /* @__PURE__ */ jsxs14(TableRow, { role: "row", className: "text-xs uppercase tracking-[0.05em] text-muted-foreground", children: [
|
|
4970
|
+
columns.map((column) => /* @__PURE__ */ jsx16(
|
|
4265
4971
|
TableHead,
|
|
4266
4972
|
{
|
|
4267
4973
|
role: "columnheader",
|
|
@@ -4271,17 +4977,17 @@ function RecordGrid({
|
|
|
4271
4977
|
},
|
|
4272
4978
|
column.id
|
|
4273
4979
|
)),
|
|
4274
|
-
showActionsColumn && /* @__PURE__ */
|
|
4980
|
+
showActionsColumn && /* @__PURE__ */ jsx16(TableHead, { role: "columnheader", scope: "col", className: "h-auto w-px px-3 py-2", children: /* @__PURE__ */ jsx16("span", { className: "sr-only", children: reviewing ? "Review" : "Row actions" }) })
|
|
4275
4981
|
] }) }),
|
|
4276
|
-
/* @__PURE__ */
|
|
4982
|
+
/* @__PURE__ */ jsxs14(TableBody, { children: [
|
|
4277
4983
|
visibleRows.map((row) => {
|
|
4278
4984
|
const rowLabel = recordGridRowLabel(columns, row);
|
|
4279
4985
|
const pending = row.id in pendingRows;
|
|
4280
4986
|
const rowError = rowErrors[row.id];
|
|
4281
4987
|
const rowDiff = reviewing ? diffByRow.get(row.id) : void 0;
|
|
4282
4988
|
const removedRow = rowDiff?.kind === "removed";
|
|
4283
|
-
return /* @__PURE__ */
|
|
4284
|
-
/* @__PURE__ */
|
|
4989
|
+
return /* @__PURE__ */ jsxs14(Fragment6, { children: [
|
|
4990
|
+
/* @__PURE__ */ jsxs14(
|
|
4285
4991
|
TableRow,
|
|
4286
4992
|
{
|
|
4287
4993
|
role: "row",
|
|
@@ -4301,8 +5007,8 @@ function RecordGrid({
|
|
|
4301
5007
|
const errorId = `${fieldPrefix}-cell-error-${row.id}-${column.id}`;
|
|
4302
5008
|
const cellDiff = rowDiff?.kind === "changed" ? diffCellByKey.get(key) : void 0;
|
|
4303
5009
|
if (isEditing && editable) {
|
|
4304
|
-
return /* @__PURE__ */
|
|
4305
|
-
/* @__PURE__ */
|
|
5010
|
+
return /* @__PURE__ */ jsxs14(TableCell, { role: "gridcell", className: `px-3 py-1.5 ${alignmentClass(column)}`, children: [
|
|
5011
|
+
/* @__PURE__ */ jsx16(
|
|
4306
5012
|
CellEditor,
|
|
4307
5013
|
{
|
|
4308
5014
|
column,
|
|
@@ -4315,11 +5021,11 @@ function RecordGrid({
|
|
|
4315
5021
|
onCancel: () => cancelEdit(row, column)
|
|
4316
5022
|
}
|
|
4317
5023
|
),
|
|
4318
|
-
cellError !== void 0 && /* @__PURE__ */
|
|
5024
|
+
cellError !== void 0 && /* @__PURE__ */ jsx16("p", { id: errorId, role: "alert", className: "mt-1 text-xs leading-snug text-destructive", children: cellError })
|
|
4319
5025
|
] }, column.id);
|
|
4320
5026
|
}
|
|
4321
5027
|
if (column.kind === "boolean" && editable) {
|
|
4322
|
-
return /* @__PURE__ */
|
|
5028
|
+
return /* @__PURE__ */ jsx16(TableCell, { role: "gridcell", className: `px-3 py-2 ${alignmentClass(column)}`, children: /* @__PURE__ */ jsx16(
|
|
4323
5029
|
"input",
|
|
4324
5030
|
{
|
|
4325
5031
|
type: "checkbox",
|
|
@@ -4338,7 +5044,7 @@ function RecordGrid({
|
|
|
4338
5044
|
) }, column.id);
|
|
4339
5045
|
}
|
|
4340
5046
|
const display = applicable ? formatRecordGridValue(column, value, locale) : "";
|
|
4341
|
-
return /* @__PURE__ */
|
|
5047
|
+
return /* @__PURE__ */ jsx16(
|
|
4342
5048
|
TableCell,
|
|
4343
5049
|
{
|
|
4344
5050
|
role: "gridcell",
|
|
@@ -4356,20 +5062,20 @@ function RecordGrid({
|
|
|
4356
5062
|
className: `px-3 py-2 outline-none focus:ring-2 focus:ring-inset focus:ring-primary/50 ${alignmentClass(
|
|
4357
5063
|
column
|
|
4358
5064
|
)} ${editable ? "cursor-text" : ""}`,
|
|
4359
|
-
children: /* @__PURE__ */
|
|
4360
|
-
column.id === columns[0]?.id && removedRow && /* @__PURE__ */
|
|
4361
|
-
cellDiff ? /* @__PURE__ */
|
|
4362
|
-
/* @__PURE__ */
|
|
4363
|
-
/* @__PURE__ */
|
|
4364
|
-
/* @__PURE__ */
|
|
4365
|
-
] }) : /* @__PURE__ */
|
|
5065
|
+
children: /* @__PURE__ */ jsxs14("span", { className: "inline-flex max-w-full items-center gap-1.5", children: [
|
|
5066
|
+
column.id === columns[0]?.id && removedRow && /* @__PURE__ */ jsx16("span", { className: "inline-flex shrink-0 rounded border border-destructive/60 px-1 py-px text-[11px] font-semibold uppercase tracking-[0.05em] text-destructive", children: "Remove" }),
|
|
5067
|
+
cellDiff ? /* @__PURE__ */ jsxs14("span", { className: "inline-flex max-w-full flex-wrap items-baseline gap-x-1.5", children: [
|
|
5068
|
+
/* @__PURE__ */ jsx16("span", { className: "tabular-nums text-destructive line-through decoration-destructive/60", children: formatRecordGridValue(column, cellDiff.before, locale) || "\u2014" }),
|
|
5069
|
+
/* @__PURE__ */ jsx16("span", { "aria-hidden": "true", className: "text-muted-foreground", children: "\u2192" }),
|
|
5070
|
+
/* @__PURE__ */ jsx16("span", { className: "tabular-nums font-medium text-success", children: formatRecordGridValue(column, cellDiff.after, locale) || "\u2014" })
|
|
5071
|
+
] }) : /* @__PURE__ */ jsx16(
|
|
4366
5072
|
"span",
|
|
4367
5073
|
{
|
|
4368
5074
|
className: removedRow ? "truncate text-destructive line-through decoration-destructive/60" : display === "" ? "text-muted-foreground" : "truncate text-foreground",
|
|
4369
5075
|
children: display === "" ? applicable ? "\u2014" : "n/a" : display
|
|
4370
5076
|
}
|
|
4371
5077
|
),
|
|
4372
|
-
source && /* @__PURE__ */
|
|
5078
|
+
source && /* @__PURE__ */ jsx16(
|
|
4373
5079
|
SourceMarker,
|
|
4374
5080
|
{
|
|
4375
5081
|
panelId: `${fieldPrefix}-source-${row.id}-${column.id}`,
|
|
@@ -4385,7 +5091,7 @@ function RecordGrid({
|
|
|
4385
5091
|
column.id
|
|
4386
5092
|
);
|
|
4387
5093
|
}),
|
|
4388
|
-
showActionsColumn && /* @__PURE__ */
|
|
5094
|
+
showActionsColumn && /* @__PURE__ */ jsx16(TableCell, { role: "gridcell", className: "px-3 py-2 text-right", children: reviewing ? rowDiff && /* @__PURE__ */ jsx16(
|
|
4389
5095
|
ReviewActions,
|
|
4390
5096
|
{
|
|
4391
5097
|
rowId: row.id,
|
|
@@ -4394,8 +5100,8 @@ function RecordGrid({
|
|
|
4394
5100
|
onAccept: onAcceptRow,
|
|
4395
5101
|
onReject: onRejectRow
|
|
4396
5102
|
}
|
|
4397
|
-
) : row.readOnly === true ? null : confirmDelete === row.id ? /* @__PURE__ */
|
|
4398
|
-
/* @__PURE__ */
|
|
5103
|
+
) : row.readOnly === true ? null : confirmDelete === row.id ? /* @__PURE__ */ jsxs14("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
5104
|
+
/* @__PURE__ */ jsx16(
|
|
4399
5105
|
"button",
|
|
4400
5106
|
{
|
|
4401
5107
|
type: "button",
|
|
@@ -4405,7 +5111,7 @@ function RecordGrid({
|
|
|
4405
5111
|
children: "Delete"
|
|
4406
5112
|
}
|
|
4407
5113
|
),
|
|
4408
|
-
/* @__PURE__ */
|
|
5114
|
+
/* @__PURE__ */ jsx16(
|
|
4409
5115
|
"button",
|
|
4410
5116
|
{
|
|
4411
5117
|
type: "button",
|
|
@@ -4415,14 +5121,14 @@ function RecordGrid({
|
|
|
4415
5121
|
children: "Cancel"
|
|
4416
5122
|
}
|
|
4417
5123
|
)
|
|
4418
|
-
] }) : /* @__PURE__ */
|
|
5124
|
+
] }) : /* @__PURE__ */ jsx16(
|
|
4419
5125
|
"button",
|
|
4420
5126
|
{
|
|
4421
5127
|
type: "button",
|
|
4422
5128
|
"aria-label": `Delete ${rowLabel}`,
|
|
4423
5129
|
onClick: () => setConfirmDelete(row.id),
|
|
4424
5130
|
className: "rounded-md p-1.5 text-muted-foreground transition hover:bg-destructive/10 hover:text-destructive",
|
|
4425
|
-
children: /* @__PURE__ */
|
|
5131
|
+
children: /* @__PURE__ */ jsxs14(
|
|
4426
5132
|
"svg",
|
|
4427
5133
|
{
|
|
4428
5134
|
viewBox: "0 0 24 24",
|
|
@@ -4434,8 +5140,8 @@ function RecordGrid({
|
|
|
4434
5140
|
strokeLinejoin: "round",
|
|
4435
5141
|
"aria-hidden": true,
|
|
4436
5142
|
children: [
|
|
4437
|
-
/* @__PURE__ */
|
|
4438
|
-
/* @__PURE__ */
|
|
5143
|
+
/* @__PURE__ */ jsx16("polyline", { points: "3 6 5 6 21 6" }),
|
|
5144
|
+
/* @__PURE__ */ jsx16("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" })
|
|
4439
5145
|
]
|
|
4440
5146
|
}
|
|
4441
5147
|
)
|
|
@@ -4444,12 +5150,12 @@ function RecordGrid({
|
|
|
4444
5150
|
]
|
|
4445
5151
|
}
|
|
4446
5152
|
),
|
|
4447
|
-
rowError !== void 0 && /* @__PURE__ */
|
|
5153
|
+
rowError !== void 0 && /* @__PURE__ */ jsx16(TableRow, { role: "row", children: /* @__PURE__ */ jsx16(TableCell, { role: "gridcell", colSpan: columnSpan, className: "px-3 pb-2", children: /* @__PURE__ */ jsx16("p", { role: "alert", className: "rounded-md bg-destructive/10 px-2.5 py-1.5 text-xs text-destructive", children: rowError }) }) })
|
|
4448
5154
|
] }, row.id);
|
|
4449
5155
|
}),
|
|
4450
5156
|
reviewing && addedRows.map((row) => {
|
|
4451
5157
|
const rowLabel = recordGridRowLabel(columns, row);
|
|
4452
|
-
return /* @__PURE__ */
|
|
5158
|
+
return /* @__PURE__ */ jsxs14(
|
|
4453
5159
|
TableRow,
|
|
4454
5160
|
{
|
|
4455
5161
|
role: "row",
|
|
@@ -4460,9 +5166,9 @@ function RecordGrid({
|
|
|
4460
5166
|
const applicable = isRecordGridCellApplicable(column, row.values);
|
|
4461
5167
|
const value = row.values[column.id] ?? null;
|
|
4462
5168
|
const display = applicable ? formatRecordGridValue(column, value, locale) : "";
|
|
4463
|
-
return /* @__PURE__ */
|
|
4464
|
-
columnIndex === 0 && /* @__PURE__ */
|
|
4465
|
-
/* @__PURE__ */
|
|
5169
|
+
return /* @__PURE__ */ jsx16(TableCell, { role: "gridcell", className: `px-3 py-2 ${alignmentClass(column)}`, children: /* @__PURE__ */ jsxs14("span", { className: "inline-flex max-w-full items-center gap-1.5", children: [
|
|
5170
|
+
columnIndex === 0 && /* @__PURE__ */ jsx16("span", { className: "inline-flex shrink-0 rounded border border-success/60 px-1 py-px text-[11px] font-semibold uppercase tracking-[0.05em] text-success", children: "New" }),
|
|
5171
|
+
/* @__PURE__ */ jsx16(
|
|
4466
5172
|
"span",
|
|
4467
5173
|
{
|
|
4468
5174
|
className: `tabular-nums ${display === "" ? "text-muted-foreground" : "truncate text-foreground"}`,
|
|
@@ -4471,7 +5177,7 @@ function RecordGrid({
|
|
|
4471
5177
|
)
|
|
4472
5178
|
] }) }, column.id);
|
|
4473
5179
|
}),
|
|
4474
|
-
/* @__PURE__ */
|
|
5180
|
+
/* @__PURE__ */ jsx16(TableCell, { role: "gridcell", className: "px-3 py-2 text-right", children: /* @__PURE__ */ jsx16(
|
|
4475
5181
|
ReviewActions,
|
|
4476
5182
|
{
|
|
4477
5183
|
rowId: row.id,
|
|
@@ -4487,8 +5193,8 @@ function RecordGrid({
|
|
|
4487
5193
|
);
|
|
4488
5194
|
})
|
|
4489
5195
|
] }),
|
|
4490
|
-
hasFooter && /* @__PURE__ */
|
|
4491
|
-
columns.map((column) => /* @__PURE__ */
|
|
5196
|
+
hasFooter && /* @__PURE__ */ jsx16(TableFooter, { children: /* @__PURE__ */ jsxs14(TableRow, { role: "row", className: "border-t-2 border-border", children: [
|
|
5197
|
+
columns.map((column) => /* @__PURE__ */ jsx16(
|
|
4492
5198
|
TableCell,
|
|
4493
5199
|
{
|
|
4494
5200
|
role: "gridcell",
|
|
@@ -4497,19 +5203,19 @@ function RecordGrid({
|
|
|
4497
5203
|
},
|
|
4498
5204
|
column.id
|
|
4499
5205
|
)),
|
|
4500
|
-
showActionsColumn && /* @__PURE__ */
|
|
5206
|
+
showActionsColumn && /* @__PURE__ */ jsx16(TableCell, { role: "gridcell" })
|
|
4501
5207
|
] }) })
|
|
4502
5208
|
]
|
|
4503
5209
|
}
|
|
4504
5210
|
) }),
|
|
4505
|
-
onCreate && !reviewing && (addForm ?? /* @__PURE__ */
|
|
5211
|
+
onCreate && !reviewing && (addForm ?? /* @__PURE__ */ jsxs14(
|
|
4506
5212
|
"button",
|
|
4507
5213
|
{
|
|
4508
5214
|
type: "button",
|
|
4509
5215
|
onClick: openAdd,
|
|
4510
5216
|
className: "inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-sm font-medium text-foreground transition hover:bg-accent",
|
|
4511
5217
|
children: [
|
|
4512
|
-
/* @__PURE__ */
|
|
5218
|
+
/* @__PURE__ */ jsxs14(
|
|
4513
5219
|
"svg",
|
|
4514
5220
|
{
|
|
4515
5221
|
viewBox: "0 0 24 24",
|
|
@@ -4521,8 +5227,8 @@ function RecordGrid({
|
|
|
4521
5227
|
strokeLinejoin: "round",
|
|
4522
5228
|
"aria-hidden": true,
|
|
4523
5229
|
children: [
|
|
4524
|
-
/* @__PURE__ */
|
|
4525
|
-
/* @__PURE__ */
|
|
5230
|
+
/* @__PURE__ */ jsx16("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
|
|
5231
|
+
/* @__PURE__ */ jsx16("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
|
|
4526
5232
|
]
|
|
4527
5233
|
}
|
|
4528
5234
|
),
|
|
@@ -4534,8 +5240,8 @@ function RecordGrid({
|
|
|
4534
5240
|
}
|
|
4535
5241
|
function ReviewActions({ rowId, kind, rowLabel, onAccept, onReject }) {
|
|
4536
5242
|
const noun = kind === "changed" ? `proposed change to ${rowLabel}` : kind === "added" ? `new row ${rowLabel}` : `removal of ${rowLabel}`;
|
|
4537
|
-
return /* @__PURE__ */
|
|
4538
|
-
onReject && /* @__PURE__ */
|
|
5243
|
+
return /* @__PURE__ */ jsxs14("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
5244
|
+
onReject && /* @__PURE__ */ jsx16(
|
|
4539
5245
|
"button",
|
|
4540
5246
|
{
|
|
4541
5247
|
type: "button",
|
|
@@ -4545,7 +5251,7 @@ function ReviewActions({ rowId, kind, rowLabel, onAccept, onReject }) {
|
|
|
4545
5251
|
children: "Reject"
|
|
4546
5252
|
}
|
|
4547
5253
|
),
|
|
4548
|
-
onAccept && /* @__PURE__ */
|
|
5254
|
+
onAccept && /* @__PURE__ */ jsx16(
|
|
4549
5255
|
"button",
|
|
4550
5256
|
{
|
|
4551
5257
|
type: "button",
|
|
@@ -4566,7 +5272,7 @@ function CellEditor({ column, rowLabel, text, invalid, describedBy, onText, onCo
|
|
|
4566
5272
|
className: INPUT_CLASS
|
|
4567
5273
|
};
|
|
4568
5274
|
if (column.kind === "select") {
|
|
4569
|
-
return /* @__PURE__ */
|
|
5275
|
+
return /* @__PURE__ */ jsxs14(
|
|
4570
5276
|
"select",
|
|
4571
5277
|
{
|
|
4572
5278
|
...shared,
|
|
@@ -4583,8 +5289,8 @@ function CellEditor({ column, rowLabel, text, invalid, describedBy, onText, onCo
|
|
|
4583
5289
|
},
|
|
4584
5290
|
onBlur: () => onCommit(text),
|
|
4585
5291
|
children: [
|
|
4586
|
-
/* @__PURE__ */
|
|
4587
|
-
column.options.map((option) => /* @__PURE__ */
|
|
5292
|
+
/* @__PURE__ */ jsx16("option", { value: "", children: "\u2014" }),
|
|
5293
|
+
column.options.map((option) => /* @__PURE__ */ jsx16("option", { value: option.value, children: option.label }, option.value))
|
|
4588
5294
|
]
|
|
4589
5295
|
}
|
|
4590
5296
|
);
|
|
@@ -4602,7 +5308,7 @@ function CellEditor({ column, rowLabel, text, invalid, describedBy, onText, onCo
|
|
|
4602
5308
|
}
|
|
4603
5309
|
};
|
|
4604
5310
|
if (column.kind === "text" && column.multiline === true) {
|
|
4605
|
-
return /* @__PURE__ */
|
|
5311
|
+
return /* @__PURE__ */ jsx16(
|
|
4606
5312
|
"textarea",
|
|
4607
5313
|
{
|
|
4608
5314
|
...shared,
|
|
@@ -4614,7 +5320,7 @@ function CellEditor({ column, rowLabel, text, invalid, describedBy, onText, onCo
|
|
|
4614
5320
|
}
|
|
4615
5321
|
);
|
|
4616
5322
|
}
|
|
4617
|
-
return /* @__PURE__ */
|
|
5323
|
+
return /* @__PURE__ */ jsx16(
|
|
4618
5324
|
"input",
|
|
4619
5325
|
{
|
|
4620
5326
|
...shared,
|
|
@@ -4629,15 +5335,15 @@ function CellEditor({ column, rowLabel, text, invalid, describedBy, onText, onCo
|
|
|
4629
5335
|
}
|
|
4630
5336
|
function SourceMarker({ panelId, columnHeader, rowLabel, source, open, onToggle }) {
|
|
4631
5337
|
const basis = source.basis ?? "asserted";
|
|
4632
|
-
const setOpen =
|
|
5338
|
+
const setOpen = useCallback11(
|
|
4633
5339
|
(next) => {
|
|
4634
5340
|
if (!next) onToggle();
|
|
4635
5341
|
},
|
|
4636
5342
|
[onToggle]
|
|
4637
5343
|
);
|
|
4638
5344
|
const { containerRef, triggerRef, panelRef, triggerProps } = usePopover(open, setOpen);
|
|
4639
|
-
return /* @__PURE__ */
|
|
4640
|
-
/* @__PURE__ */
|
|
5345
|
+
return /* @__PURE__ */ jsxs14("span", { ref: containerRef, className: "relative inline-flex", children: [
|
|
5346
|
+
/* @__PURE__ */ jsx16(
|
|
4641
5347
|
"button",
|
|
4642
5348
|
{
|
|
4643
5349
|
type: "button",
|
|
@@ -4650,7 +5356,7 @@ function SourceMarker({ panelId, columnHeader, rowLabel, source, open, onToggle
|
|
|
4650
5356
|
onToggle();
|
|
4651
5357
|
},
|
|
4652
5358
|
className: `inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border ${BASIS_TONES2[basis]}`,
|
|
4653
|
-
children: /* @__PURE__ */
|
|
5359
|
+
children: /* @__PURE__ */ jsx16(
|
|
4654
5360
|
"svg",
|
|
4655
5361
|
{
|
|
4656
5362
|
viewBox: "0 0 24 24",
|
|
@@ -4660,12 +5366,12 @@ function SourceMarker({ panelId, columnHeader, rowLabel, source, open, onToggle
|
|
|
4660
5366
|
strokeWidth: "2.5",
|
|
4661
5367
|
strokeLinecap: "round",
|
|
4662
5368
|
"aria-hidden": true,
|
|
4663
|
-
children: /* @__PURE__ */
|
|
5369
|
+
children: /* @__PURE__ */ jsx16("path", { d: "M9 8h6M9 12h6M9 16h3" })
|
|
4664
5370
|
}
|
|
4665
5371
|
)
|
|
4666
5372
|
}
|
|
4667
5373
|
),
|
|
4668
|
-
/* @__PURE__ */
|
|
5374
|
+
/* @__PURE__ */ jsxs14(
|
|
4669
5375
|
PopoverSurface,
|
|
4670
5376
|
{
|
|
4671
5377
|
open,
|
|
@@ -4675,17 +5381,17 @@ function SourceMarker({ panelId, columnHeader, rowLabel, source, open, onToggle
|
|
|
4675
5381
|
panelRef,
|
|
4676
5382
|
className: `w-64 rounded-lg border border-card-edge bg-popover p-3 text-left ${OVERLAY_SHADOW}`,
|
|
4677
5383
|
children: [
|
|
4678
|
-
source.quote && /* @__PURE__ */
|
|
5384
|
+
source.quote && /* @__PURE__ */ jsxs14("span", { className: "block border-l-2 border-primary/50 pl-2 text-xs italic leading-snug text-foreground", children: [
|
|
4679
5385
|
"\u201C",
|
|
4680
5386
|
source.quote,
|
|
4681
5387
|
"\u201D"
|
|
4682
5388
|
] }),
|
|
4683
|
-
/* @__PURE__ */
|
|
5389
|
+
/* @__PURE__ */ jsxs14("span", { className: "mt-2 block text-xs text-muted-foreground", children: [
|
|
4684
5390
|
source.label ?? "Source",
|
|
4685
5391
|
source.locator ? ` \xB7 ${source.locator}` : "",
|
|
4686
5392
|
` \xB7 ${BASIS_TITLES[basis]}`
|
|
4687
5393
|
] }),
|
|
4688
|
-
source.href && /* @__PURE__ */
|
|
5394
|
+
source.href && /* @__PURE__ */ jsx16(
|
|
4689
5395
|
"a",
|
|
4690
5396
|
{
|
|
4691
5397
|
href: source.href,
|
|
@@ -4713,8 +5419,8 @@ function AddRecordForm({
|
|
|
4713
5419
|
onSubmit,
|
|
4714
5420
|
onCancel
|
|
4715
5421
|
}) {
|
|
4716
|
-
const groups =
|
|
4717
|
-
return /* @__PURE__ */
|
|
5422
|
+
const groups = useMemo7(() => groupColumns(columns), [columns]);
|
|
5423
|
+
return /* @__PURE__ */ jsxs14(
|
|
4718
5424
|
"form",
|
|
4719
5425
|
{
|
|
4720
5426
|
noValidate: true,
|
|
@@ -4725,31 +5431,31 @@ function AddRecordForm({
|
|
|
4725
5431
|
},
|
|
4726
5432
|
className: "space-y-4 rounded-xl border border-card-edge bg-card p-4",
|
|
4727
5433
|
children: [
|
|
4728
|
-
/* @__PURE__ */
|
|
4729
|
-
formError !== null && /* @__PURE__ */
|
|
5434
|
+
/* @__PURE__ */ jsx16("h3", { className: "text-sm font-semibold text-foreground", children: label }),
|
|
5435
|
+
formError !== null && /* @__PURE__ */ jsx16("p", { role: "alert", className: "rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive", children: formError }),
|
|
4730
5436
|
groups.map((group) => {
|
|
4731
5437
|
const fields = group.columns.filter((column) => isRecordGridCellApplicable(column, draft));
|
|
4732
5438
|
if (fields.length === 0) return null;
|
|
4733
|
-
return /* @__PURE__ */
|
|
5439
|
+
return /* @__PURE__ */ jsxs14(
|
|
4734
5440
|
"fieldset",
|
|
4735
5441
|
{
|
|
4736
5442
|
className: group.label === null ? "min-w-0" : "min-w-0 rounded-lg border border-card-edge p-3",
|
|
4737
5443
|
children: [
|
|
4738
|
-
group.label !== null && /* @__PURE__ */
|
|
4739
|
-
/* @__PURE__ */
|
|
5444
|
+
group.label !== null && /* @__PURE__ */ jsx16("legend", { className: "px-1 text-xs font-medium text-muted-foreground", children: group.label }),
|
|
5445
|
+
/* @__PURE__ */ jsx16("div", { className: "grid gap-3 sm:grid-cols-2", children: fields.map((column) => {
|
|
4740
5446
|
const fieldId = `${fieldPrefix}-${column.id}`;
|
|
4741
5447
|
const errorId = `${fieldId}-error`;
|
|
4742
5448
|
const message = errors[column.id];
|
|
4743
|
-
return /* @__PURE__ */
|
|
5449
|
+
return /* @__PURE__ */ jsxs14(
|
|
4744
5450
|
"div",
|
|
4745
5451
|
{
|
|
4746
5452
|
className: column.kind === "text" && column.multiline === true ? "sm:col-span-2" : "",
|
|
4747
5453
|
children: [
|
|
4748
|
-
/* @__PURE__ */
|
|
5454
|
+
/* @__PURE__ */ jsxs14("label", { htmlFor: fieldId, className: "mb-1 block text-xs font-medium text-muted-foreground", children: [
|
|
4749
5455
|
column.header,
|
|
4750
|
-
column.required === true && /* @__PURE__ */
|
|
5456
|
+
column.required === true && /* @__PURE__ */ jsx16("span", { className: "ml-0.5 text-destructive", children: "*" })
|
|
4751
5457
|
] }),
|
|
4752
|
-
/* @__PURE__ */
|
|
5458
|
+
/* @__PURE__ */ jsx16(
|
|
4753
5459
|
DraftField,
|
|
4754
5460
|
{
|
|
4755
5461
|
column,
|
|
@@ -4760,8 +5466,8 @@ function AddRecordForm({
|
|
|
4760
5466
|
onValue: (next) => setDraft({ ...draft, [column.id]: next })
|
|
4761
5467
|
}
|
|
4762
5468
|
),
|
|
4763
|
-
column.hint && /* @__PURE__ */
|
|
4764
|
-
message !== void 0 && /* @__PURE__ */
|
|
5469
|
+
column.hint && /* @__PURE__ */ jsx16("p", { className: "mt-1 text-xs text-muted-foreground", children: column.hint }),
|
|
5470
|
+
message !== void 0 && /* @__PURE__ */ jsx16("p", { id: errorId, role: "alert", className: "mt-1 text-xs text-destructive", children: message })
|
|
4765
5471
|
]
|
|
4766
5472
|
},
|
|
4767
5473
|
column.id
|
|
@@ -4772,8 +5478,8 @@ function AddRecordForm({
|
|
|
4772
5478
|
group.label ?? "_"
|
|
4773
5479
|
);
|
|
4774
5480
|
}),
|
|
4775
|
-
/* @__PURE__ */
|
|
4776
|
-
/* @__PURE__ */
|
|
5481
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2", children: [
|
|
5482
|
+
/* @__PURE__ */ jsx16(
|
|
4777
5483
|
"button",
|
|
4778
5484
|
{
|
|
4779
5485
|
type: "submit",
|
|
@@ -4782,7 +5488,7 @@ function AddRecordForm({
|
|
|
4782
5488
|
children: busy ? "Saving\u2026" : "Save"
|
|
4783
5489
|
}
|
|
4784
5490
|
),
|
|
4785
|
-
/* @__PURE__ */
|
|
5491
|
+
/* @__PURE__ */ jsx16(
|
|
4786
5492
|
"button",
|
|
4787
5493
|
{
|
|
4788
5494
|
type: "button",
|
|
@@ -4803,7 +5509,7 @@ function DraftField({ column, id, value, invalid, describedBy, onValue }) {
|
|
|
4803
5509
|
"aria-describedby": describedBy
|
|
4804
5510
|
};
|
|
4805
5511
|
if (column.kind === "boolean") {
|
|
4806
|
-
return /* @__PURE__ */
|
|
5512
|
+
return /* @__PURE__ */ jsx16(
|
|
4807
5513
|
"input",
|
|
4808
5514
|
{
|
|
4809
5515
|
...shared,
|
|
@@ -4815,7 +5521,7 @@ function DraftField({ column, id, value, invalid, describedBy, onValue }) {
|
|
|
4815
5521
|
);
|
|
4816
5522
|
}
|
|
4817
5523
|
if (column.kind === "select") {
|
|
4818
|
-
return /* @__PURE__ */
|
|
5524
|
+
return /* @__PURE__ */ jsxs14(
|
|
4819
5525
|
"select",
|
|
4820
5526
|
{
|
|
4821
5527
|
...shared,
|
|
@@ -4823,14 +5529,14 @@ function DraftField({ column, id, value, invalid, describedBy, onValue }) {
|
|
|
4823
5529
|
value: typeof value === "string" ? value : "",
|
|
4824
5530
|
onChange: (event) => onValue(event.target.value === "" ? null : event.target.value),
|
|
4825
5531
|
children: [
|
|
4826
|
-
/* @__PURE__ */
|
|
4827
|
-
column.options.map((option) => /* @__PURE__ */
|
|
5532
|
+
/* @__PURE__ */ jsx16("option", { value: "", children: "\u2014" }),
|
|
5533
|
+
column.options.map((option) => /* @__PURE__ */ jsx16("option", { value: option.value, children: option.label }, option.value))
|
|
4828
5534
|
]
|
|
4829
5535
|
}
|
|
4830
5536
|
);
|
|
4831
5537
|
}
|
|
4832
5538
|
if (column.kind === "text" && column.multiline === true) {
|
|
4833
|
-
return /* @__PURE__ */
|
|
5539
|
+
return /* @__PURE__ */ jsx16(
|
|
4834
5540
|
"textarea",
|
|
4835
5541
|
{
|
|
4836
5542
|
...shared,
|
|
@@ -4842,7 +5548,7 @@ function DraftField({ column, id, value, invalid, describedBy, onValue }) {
|
|
|
4842
5548
|
);
|
|
4843
5549
|
}
|
|
4844
5550
|
if (column.kind === "number" || column.kind === "currency") {
|
|
4845
|
-
return /* @__PURE__ */
|
|
5551
|
+
return /* @__PURE__ */ jsx16(
|
|
4846
5552
|
"input",
|
|
4847
5553
|
{
|
|
4848
5554
|
...shared,
|
|
@@ -4862,7 +5568,7 @@ function DraftField({ column, id, value, invalid, describedBy, onValue }) {
|
|
|
4862
5568
|
}
|
|
4863
5569
|
);
|
|
4864
5570
|
}
|
|
4865
|
-
return /* @__PURE__ */
|
|
5571
|
+
return /* @__PURE__ */ jsx16(
|
|
4866
5572
|
"input",
|
|
4867
5573
|
{
|
|
4868
5574
|
...shared,
|
|
@@ -4876,19 +5582,19 @@ function DraftField({ column, id, value, invalid, describedBy, onValue }) {
|
|
|
4876
5582
|
|
|
4877
5583
|
// src/web-react/command-palette.tsx
|
|
4878
5584
|
import {
|
|
4879
|
-
useCallback as
|
|
4880
|
-
useEffect as
|
|
4881
|
-
useId as
|
|
4882
|
-
useMemo as
|
|
4883
|
-
useRef as
|
|
4884
|
-
useState as
|
|
5585
|
+
useCallback as useCallback12,
|
|
5586
|
+
useEffect as useEffect13,
|
|
5587
|
+
useId as useId4,
|
|
5588
|
+
useMemo as useMemo8,
|
|
5589
|
+
useRef as useRef13,
|
|
5590
|
+
useState as useState20
|
|
4885
5591
|
} from "react";
|
|
4886
5592
|
import { Dialog, DialogContent, DialogTitle } from "@tangle-network/ui/primitives";
|
|
4887
|
-
import { jsx as
|
|
5593
|
+
import { jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
4888
5594
|
function SearchGlyph({ className }) {
|
|
4889
|
-
return /* @__PURE__ */
|
|
4890
|
-
/* @__PURE__ */
|
|
4891
|
-
/* @__PURE__ */
|
|
5595
|
+
return /* @__PURE__ */ jsxs15("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
|
|
5596
|
+
/* @__PURE__ */ jsx17("circle", { cx: "11", cy: "11", r: "8" }),
|
|
5597
|
+
/* @__PURE__ */ jsx17("path", { d: "m21 21-4.3-4.3" })
|
|
4892
5598
|
] });
|
|
4893
5599
|
}
|
|
4894
5600
|
function CommandPalette({
|
|
@@ -4905,25 +5611,25 @@ function CommandPalette({
|
|
|
4905
5611
|
emptyMessage,
|
|
4906
5612
|
label = "Command palette"
|
|
4907
5613
|
}) {
|
|
4908
|
-
const [internalOpen, setInternalOpen] =
|
|
5614
|
+
const [internalOpen, setInternalOpen] = useState20(false);
|
|
4909
5615
|
const open = controlledOpen ?? internalOpen;
|
|
4910
|
-
const setOpen =
|
|
5616
|
+
const setOpen = useCallback12(
|
|
4911
5617
|
(next) => {
|
|
4912
5618
|
if (controlledOpen === void 0) setInternalOpen(next);
|
|
4913
5619
|
onOpenChange?.(next);
|
|
4914
5620
|
},
|
|
4915
5621
|
[controlledOpen, onOpenChange]
|
|
4916
5622
|
);
|
|
4917
|
-
const [query, setQuery] =
|
|
4918
|
-
const [active, setActive] =
|
|
4919
|
-
const inputRef =
|
|
4920
|
-
const surfaceId =
|
|
5623
|
+
const [query, setQuery] = useState20(initialQuery ?? "");
|
|
5624
|
+
const [active, setActive] = useState20(0);
|
|
5625
|
+
const inputRef = useRef13(null);
|
|
5626
|
+
const surfaceId = useId4();
|
|
4921
5627
|
const listId = `${surfaceId}-list`;
|
|
4922
|
-
const flat =
|
|
4923
|
-
const sections =
|
|
5628
|
+
const flat = useMemo8(() => filterCommandPaletteItems(items, query), [items, query]);
|
|
5629
|
+
const sections = useMemo8(() => groupCommandPaletteItems(flat), [flat]);
|
|
4924
5630
|
const activeIndex = flat.length === 0 ? 0 : Math.min(active, flat.length - 1);
|
|
4925
5631
|
const activeId = flat.length > 0 ? `${listId}-${activeIndex}` : void 0;
|
|
4926
|
-
|
|
5632
|
+
useEffect13(() => {
|
|
4927
5633
|
if (!hotkey) return;
|
|
4928
5634
|
function onKeyDown(e) {
|
|
4929
5635
|
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "k") {
|
|
@@ -4934,18 +5640,18 @@ function CommandPalette({
|
|
|
4934
5640
|
document.addEventListener("keydown", onKeyDown);
|
|
4935
5641
|
return () => document.removeEventListener("keydown", onKeyDown);
|
|
4936
5642
|
}, [hotkey, open, setOpen]);
|
|
4937
|
-
const restoreFocusRef =
|
|
4938
|
-
|
|
5643
|
+
const restoreFocusRef = useRef13(null);
|
|
5644
|
+
useEffect13(() => {
|
|
4939
5645
|
if (open) return;
|
|
4940
5646
|
setQuery(initialQuery ?? "");
|
|
4941
5647
|
onQueryChange?.(initialQuery ?? "");
|
|
4942
5648
|
setActive(0);
|
|
4943
5649
|
}, [open]);
|
|
4944
|
-
|
|
5650
|
+
useEffect13(() => {
|
|
4945
5651
|
if (!open || !activeId) return;
|
|
4946
5652
|
document.getElementById(activeId)?.scrollIntoView?.({ block: "nearest" });
|
|
4947
5653
|
}, [open, activeId]);
|
|
4948
|
-
const choose =
|
|
5654
|
+
const choose = useCallback12(
|
|
4949
5655
|
(item) => {
|
|
4950
5656
|
onSelect(item);
|
|
4951
5657
|
setOpen(false);
|
|
@@ -4966,7 +5672,7 @@ function CommandPalette({
|
|
|
4966
5672
|
}
|
|
4967
5673
|
};
|
|
4968
5674
|
let rowIndex = -1;
|
|
4969
|
-
return /* @__PURE__ */
|
|
5675
|
+
return /* @__PURE__ */ jsx17(Dialog, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs15(
|
|
4970
5676
|
DialogContent,
|
|
4971
5677
|
{
|
|
4972
5678
|
hideCloseButton: true,
|
|
@@ -4985,10 +5691,10 @@ function CommandPalette({
|
|
|
4985
5691
|
...{ [POPOVER_SURFACE_ATTR]: surfaceId },
|
|
4986
5692
|
className: `top-[15%] z-[1000] flex max-h-[70vh] w-[560px] max-w-[calc(100vw-2rem)] translate-y-0 flex-col gap-0 overflow-hidden rounded-xl border-card-edge bg-popover p-0 ${OVERLAY_SHADOW}`,
|
|
4987
5693
|
children: [
|
|
4988
|
-
/* @__PURE__ */
|
|
4989
|
-
/* @__PURE__ */
|
|
4990
|
-
/* @__PURE__ */
|
|
4991
|
-
/* @__PURE__ */
|
|
5694
|
+
/* @__PURE__ */ jsx17(DialogTitle, { className: "sr-only", children: label }),
|
|
5695
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex shrink-0 items-center gap-2 border-b border-border px-3 py-2.5", children: [
|
|
5696
|
+
/* @__PURE__ */ jsx17(SearchGlyph, { className: "h-4 w-4 shrink-0 text-muted-foreground" }),
|
|
5697
|
+
/* @__PURE__ */ jsx17(
|
|
4992
5698
|
"input",
|
|
4993
5699
|
{
|
|
4994
5700
|
ref: inputRef,
|
|
@@ -5010,15 +5716,15 @@ function CommandPalette({
|
|
|
5010
5716
|
}
|
|
5011
5717
|
)
|
|
5012
5718
|
] }),
|
|
5013
|
-
/* @__PURE__ */
|
|
5014
|
-
loading && /* @__PURE__ */
|
|
5015
|
-
!loading && flat.length === 0 && /* @__PURE__ */
|
|
5016
|
-
!loading && sections.map((section) => /* @__PURE__ */
|
|
5017
|
-
/* @__PURE__ */
|
|
5719
|
+
/* @__PURE__ */ jsxs15("div", { role: "listbox", id: listId, className: "min-h-0 flex-1 overflow-y-auto p-1 pb-2", children: [
|
|
5720
|
+
loading && /* @__PURE__ */ jsx17("div", { className: "px-3 py-4 text-center text-sm text-muted-foreground", children: "Loading\u2026" }),
|
|
5721
|
+
!loading && flat.length === 0 && /* @__PURE__ */ jsx17("div", { className: "px-3 py-4 text-center text-sm text-muted-foreground", children: emptyMessage ?? (query.trim() ? `No results for \u201C${query.trim()}\u201D` : "Nothing here yet") }),
|
|
5722
|
+
!loading && sections.map((section) => /* @__PURE__ */ jsxs15("div", { children: [
|
|
5723
|
+
/* @__PURE__ */ jsx17("div", { className: "px-3 pb-1 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: section.group }),
|
|
5018
5724
|
section.items.map((item) => {
|
|
5019
5725
|
rowIndex += 1;
|
|
5020
5726
|
const index = rowIndex;
|
|
5021
|
-
return /* @__PURE__ */
|
|
5727
|
+
return /* @__PURE__ */ jsxs15(
|
|
5022
5728
|
"div",
|
|
5023
5729
|
{
|
|
5024
5730
|
id: `${listId}-${index}`,
|
|
@@ -5028,9 +5734,9 @@ function CommandPalette({
|
|
|
5028
5734
|
onClick: () => choose(item),
|
|
5029
5735
|
className: `flex w-full cursor-pointer items-center gap-2.5 rounded-md px-3 py-2.5 text-left text-sm ${index === activeIndex ? "bg-accent" : ""}`,
|
|
5030
5736
|
children: [
|
|
5031
|
-
/* @__PURE__ */
|
|
5032
|
-
item.description && /* @__PURE__ */
|
|
5033
|
-
item.hint && /* @__PURE__ */
|
|
5737
|
+
/* @__PURE__ */ jsx17("span", { className: "truncate text-foreground", children: item.label }),
|
|
5738
|
+
item.description && /* @__PURE__ */ jsx17("span", { className: "truncate text-xs text-muted-foreground", children: item.description }),
|
|
5739
|
+
item.hint && /* @__PURE__ */ jsx17("span", { className: "ml-auto shrink-0 text-xs tabular-nums text-muted-foreground", children: item.hint })
|
|
5034
5740
|
]
|
|
5035
5741
|
},
|
|
5036
5742
|
item.id
|
|
@@ -5038,15 +5744,15 @@ function CommandPalette({
|
|
|
5038
5744
|
})
|
|
5039
5745
|
] }, section.group))
|
|
5040
5746
|
] }),
|
|
5041
|
-
/* @__PURE__ */
|
|
5042
|
-
/* @__PURE__ */
|
|
5043
|
-
/* @__PURE__ */
|
|
5044
|
-
/* @__PURE__ */
|
|
5045
|
-
/* @__PURE__ */
|
|
5046
|
-
/* @__PURE__ */
|
|
5047
|
-
/* @__PURE__ */
|
|
5048
|
-
/* @__PURE__ */
|
|
5049
|
-
/* @__PURE__ */
|
|
5747
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex shrink-0 items-center justify-between border-t border-border px-3 py-2 text-xs text-muted-foreground", children: [
|
|
5748
|
+
/* @__PURE__ */ jsx17("span", { className: "tabular-nums", children: query.trim() ? `${flat.length} of ${items.length}` : `${items.length} items` }),
|
|
5749
|
+
/* @__PURE__ */ jsxs15("span", { className: "flex items-center gap-1.5", children: [
|
|
5750
|
+
/* @__PURE__ */ jsx17("kbd", { className: "rounded border border-border bg-background px-1 py-0.5", children: "\u2191\u2193" }),
|
|
5751
|
+
/* @__PURE__ */ jsx17("span", { children: "navigate" }),
|
|
5752
|
+
/* @__PURE__ */ jsx17("kbd", { className: "ml-1.5 rounded border border-border bg-background px-1 py-0.5", children: "\u21B5" }),
|
|
5753
|
+
/* @__PURE__ */ jsx17("span", { children: "select" }),
|
|
5754
|
+
/* @__PURE__ */ jsx17("kbd", { className: "ml-1.5 rounded border border-border bg-background px-1 py-0.5", children: "esc" }),
|
|
5755
|
+
/* @__PURE__ */ jsx17("span", { children: "close" })
|
|
5050
5756
|
] })
|
|
5051
5757
|
] })
|
|
5052
5758
|
]
|
|
@@ -5055,7 +5761,7 @@ function CommandPalette({
|
|
|
5055
5761
|
}
|
|
5056
5762
|
|
|
5057
5763
|
// src/web-react/sparkline.tsx
|
|
5058
|
-
import { jsx as
|
|
5764
|
+
import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
5059
5765
|
var DEFAULT_SPARKLINE_WIDTH = 96;
|
|
5060
5766
|
var DEFAULT_SPARKLINE_HEIGHT = 24;
|
|
5061
5767
|
var DEFAULT_INSET = 2.5;
|
|
@@ -5161,21 +5867,21 @@ function Sparkline({
|
|
|
5161
5867
|
const geometry = sparklineGeometry(values, { width, height });
|
|
5162
5868
|
const accessibleName = sparklineLabel(values, { label, format });
|
|
5163
5869
|
if (geometry.points.length === 0) {
|
|
5164
|
-
return /* @__PURE__ */
|
|
5870
|
+
return /* @__PURE__ */ jsxs16(
|
|
5165
5871
|
"span",
|
|
5166
5872
|
{
|
|
5167
5873
|
"data-sparkline": geometry.gaps > 0 ? "unavailable" : "empty",
|
|
5168
5874
|
className: joinClasses("text-[11px] text-muted-foreground", className),
|
|
5169
5875
|
children: [
|
|
5170
|
-
/* @__PURE__ */
|
|
5171
|
-
/* @__PURE__ */
|
|
5876
|
+
/* @__PURE__ */ jsx18("span", { className: "sr-only", children: accessibleName }),
|
|
5877
|
+
/* @__PURE__ */ jsx18("span", { "aria-hidden": "true", children: geometry.gaps > 0 ? unavailableLabel : emptyLabel })
|
|
5172
5878
|
]
|
|
5173
5879
|
}
|
|
5174
5880
|
);
|
|
5175
5881
|
}
|
|
5176
5882
|
const drawsLine = geometry.segments.some((segment) => segment.length > 1);
|
|
5177
5883
|
const end = geometry.points[geometry.points.length - 1];
|
|
5178
|
-
return /* @__PURE__ */
|
|
5884
|
+
return /* @__PURE__ */ jsxs16(
|
|
5179
5885
|
"svg",
|
|
5180
5886
|
{
|
|
5181
5887
|
role: "img",
|
|
@@ -5192,7 +5898,7 @@ function Sparkline({
|
|
|
5192
5898
|
geometry.segments.map((segment, index) => {
|
|
5193
5899
|
const key = `segment-${index}`;
|
|
5194
5900
|
if (segment.length > 1) {
|
|
5195
|
-
return /* @__PURE__ */
|
|
5901
|
+
return /* @__PURE__ */ jsx18(
|
|
5196
5902
|
"polyline",
|
|
5197
5903
|
{
|
|
5198
5904
|
points: sparklinePointsAttribute(segment),
|
|
@@ -5208,9 +5914,9 @@ function Sparkline({
|
|
|
5208
5914
|
}
|
|
5209
5915
|
const only = segment[0];
|
|
5210
5916
|
if (only.x === end.x && only.y === end.y) return null;
|
|
5211
|
-
return /* @__PURE__ */
|
|
5917
|
+
return /* @__PURE__ */ jsx18("circle", { cx: only.x, cy: only.y, r: DOT_RADIUS, fill: "currentColor" }, key);
|
|
5212
5918
|
}),
|
|
5213
|
-
/* @__PURE__ */
|
|
5919
|
+
/* @__PURE__ */ jsx18("circle", { cx: end.x, cy: end.y, r: DOT_RADIUS, fill: "currentColor" })
|
|
5214
5920
|
]
|
|
5215
5921
|
}
|
|
5216
5922
|
);
|
|
@@ -5219,12 +5925,12 @@ function Sparkline({
|
|
|
5219
5925
|
// src/web-react/insight-card.tsx
|
|
5220
5926
|
import {
|
|
5221
5927
|
isValidElement as isValidElement2,
|
|
5222
|
-
useCallback as
|
|
5223
|
-
useEffect as
|
|
5224
|
-
useRef as
|
|
5225
|
-
useState as
|
|
5928
|
+
useCallback as useCallback13,
|
|
5929
|
+
useEffect as useEffect14,
|
|
5930
|
+
useRef as useRef14,
|
|
5931
|
+
useState as useState21
|
|
5226
5932
|
} from "react";
|
|
5227
|
-
import { Fragment as
|
|
5933
|
+
import { Fragment as Fragment7, jsx as jsx19, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
5228
5934
|
function insightDelta(value, previous) {
|
|
5229
5935
|
if (typeof value !== "number" || !Number.isFinite(value)) return null;
|
|
5230
5936
|
if (typeof previous !== "number" || !Number.isFinite(previous)) return null;
|
|
@@ -5277,7 +5983,7 @@ function InsightCard({
|
|
|
5277
5983
|
const tone = delta ? insightDeltaTone(delta.direction, polarity) : "neutral";
|
|
5278
5984
|
const unavailable = typeof value === "number" && !Number.isFinite(value);
|
|
5279
5985
|
const shown = typeof value === "number" ? format(value) : value;
|
|
5280
|
-
return /* @__PURE__ */
|
|
5986
|
+
return /* @__PURE__ */ jsxs17(
|
|
5281
5987
|
"article",
|
|
5282
5988
|
{
|
|
5283
5989
|
"data-insight-card": "",
|
|
@@ -5285,40 +5991,40 @@ function InsightCard({
|
|
|
5285
5991
|
className: joinClasses("agent-arrive flex h-full flex-col rounded-xl border border-card-edge bg-card p-4", className),
|
|
5286
5992
|
style,
|
|
5287
5993
|
children: [
|
|
5288
|
-
eyebrow ? /* @__PURE__ */
|
|
5289
|
-
/* @__PURE__ */
|
|
5290
|
-
/* @__PURE__ */
|
|
5994
|
+
eyebrow ? /* @__PURE__ */ jsx19("p", { "data-insight-eyebrow": "", className: "mb-0.5 text-[11px] font-semibold uppercase tracking-[0.05em] text-muted-foreground", children: eyebrow }) : null,
|
|
5995
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex items-baseline justify-between gap-2", children: [
|
|
5996
|
+
/* @__PURE__ */ jsx19("h3", { className: "text-[13px] font-medium text-muted-foreground", children: title }),
|
|
5291
5997
|
live ? (
|
|
5292
5998
|
// No `data-motion` opt-out: the word is the signal and the sweep is
|
|
5293
5999
|
// emphasis, so the reduced-motion floor reaches this like everything
|
|
5294
6000
|
// else and leaves a static, legible label.
|
|
5295
|
-
/* @__PURE__ */
|
|
6001
|
+
/* @__PURE__ */ jsx19("span", { className: "agent-shimmer shrink-0 text-[11px] font-medium", "data-insight-live": "", children: liveLabel })
|
|
5296
6002
|
) : null
|
|
5297
6003
|
] }),
|
|
5298
|
-
/* @__PURE__ */
|
|
5299
|
-
/* @__PURE__ */
|
|
5300
|
-
/* @__PURE__ */
|
|
5301
|
-
] }) : /* @__PURE__ */
|
|
5302
|
-
/* @__PURE__ */
|
|
5303
|
-
unit ? /* @__PURE__ */
|
|
6004
|
+
/* @__PURE__ */ jsx19("p", { className: "mt-1 flex items-baseline gap-1", children: unavailable ? /* @__PURE__ */ jsxs17("span", { "data-insight-value": "unavailable", className: "text-xl font-semibold text-muted-foreground", children: [
|
|
6005
|
+
/* @__PURE__ */ jsx19("span", { "aria-hidden": "true", children: INSIGHT_UNAVAILABLE_GLYPH }),
|
|
6006
|
+
/* @__PURE__ */ jsx19("span", { className: "sr-only", children: INSIGHT_UNAVAILABLE_LABEL })
|
|
6007
|
+
] }) : /* @__PURE__ */ jsxs17(Fragment7, { children: [
|
|
6008
|
+
/* @__PURE__ */ jsx19("span", { className: "text-xl font-semibold tabular-nums text-foreground", children: shown }),
|
|
6009
|
+
unit ? /* @__PURE__ */ jsx19("span", { className: "text-[11px] text-muted-foreground", children: unit }) : null
|
|
5304
6010
|
] }) }),
|
|
5305
|
-
delta ? /* @__PURE__ */
|
|
5306
|
-
/* @__PURE__ */
|
|
6011
|
+
delta ? /* @__PURE__ */ jsxs17("p", { "data-insight-delta": delta.direction, className: `mt-0.5 text-[11px] font-medium ${TONE_CLASS[tone]}`, children: [
|
|
6012
|
+
/* @__PURE__ */ jsxs17("span", { "aria-hidden": "true", children: [
|
|
5307
6013
|
DIRECTION_GLYPH[delta.direction],
|
|
5308
6014
|
" "
|
|
5309
6015
|
] }),
|
|
5310
6016
|
formatInsightDelta(delta, format)
|
|
5311
6017
|
] }) : null,
|
|
5312
|
-
description ? /* @__PURE__ */
|
|
5313
|
-
series ? /* @__PURE__ */
|
|
5314
|
-
action ? /* @__PURE__ */
|
|
6018
|
+
description ? /* @__PURE__ */ jsx19("p", { className: "mt-1 text-[11px] text-muted-foreground", children: description }) : null,
|
|
6019
|
+
series ? /* @__PURE__ */ jsx19("div", { className: "mt-2 text-muted-foreground", children: /* @__PURE__ */ jsx19(Sparkline, { values: series, label: seriesLabel ?? title, format }) }) : null,
|
|
6020
|
+
action ? /* @__PURE__ */ jsx19("div", { className: "mt-3", children: renderInsightAction(action) }) : null
|
|
5315
6021
|
]
|
|
5316
6022
|
}
|
|
5317
6023
|
);
|
|
5318
6024
|
}
|
|
5319
6025
|
function renderInsightAction(action) {
|
|
5320
6026
|
if (isValidElement2(action)) return action;
|
|
5321
|
-
return /* @__PURE__ */
|
|
6027
|
+
return /* @__PURE__ */ jsx19(
|
|
5322
6028
|
"button",
|
|
5323
6029
|
{
|
|
5324
6030
|
type: "button",
|
|
@@ -5387,15 +6093,15 @@ function InsightDeck({
|
|
|
5387
6093
|
className,
|
|
5388
6094
|
onPageChange
|
|
5389
6095
|
}) {
|
|
5390
|
-
const [page, setPage] =
|
|
5391
|
-
const [held, setHeld] =
|
|
6096
|
+
const [page, setPage] = useState21(0);
|
|
6097
|
+
const [held, setHeld] = useState21(null);
|
|
5392
6098
|
const answered = state.status === "error" || state.status === "empty";
|
|
5393
6099
|
const carried = state.status === "ready" ? state.value : answered ? null : held;
|
|
5394
6100
|
if (carried !== held) setHeld(carried);
|
|
5395
6101
|
const shown = carried !== null && state.status !== "ready" ? { status: "ready", value: carried, retry: state.retry } : state;
|
|
5396
6102
|
const refreshing = shown !== state;
|
|
5397
|
-
const reported =
|
|
5398
|
-
const settlePage =
|
|
6103
|
+
const reported = useRef14(0);
|
|
6104
|
+
const settlePage = useCallback13(
|
|
5399
6105
|
(next) => {
|
|
5400
6106
|
if (reported.current === next) return;
|
|
5401
6107
|
reported.current = next;
|
|
@@ -5403,7 +6109,7 @@ function InsightDeck({
|
|
|
5403
6109
|
},
|
|
5404
6110
|
[onPageChange]
|
|
5405
6111
|
);
|
|
5406
|
-
return /* @__PURE__ */
|
|
6112
|
+
return /* @__PURE__ */ jsx19(
|
|
5407
6113
|
AsyncView,
|
|
5408
6114
|
{
|
|
5409
6115
|
state: shown,
|
|
@@ -5411,7 +6117,7 @@ function InsightDeck({
|
|
|
5411
6117
|
loadingLabel,
|
|
5412
6118
|
retryLabel,
|
|
5413
6119
|
className,
|
|
5414
|
-
children: (insights) => /* @__PURE__ */
|
|
6120
|
+
children: (insights) => /* @__PURE__ */ jsx19(
|
|
5415
6121
|
InsightPages,
|
|
5416
6122
|
{
|
|
5417
6123
|
insights,
|
|
@@ -5478,18 +6184,18 @@ function InsightPages({
|
|
|
5478
6184
|
const pageCount = insightPageCount(insights.length, size);
|
|
5479
6185
|
const current = Math.min(Math.max(page, 0), pageCount - 1);
|
|
5480
6186
|
const visible = insightPageSlice(insights, current, size);
|
|
5481
|
-
const sectionRef =
|
|
5482
|
-
const listRef =
|
|
5483
|
-
const recoverFocus =
|
|
5484
|
-
|
|
6187
|
+
const sectionRef = useRef14(null);
|
|
6188
|
+
const listRef = useRef14(null);
|
|
6189
|
+
const recoverFocus = useRef14(false);
|
|
6190
|
+
useEffect14(() => {
|
|
5485
6191
|
onPageSettled(current);
|
|
5486
6192
|
}, [current, onPageSettled]);
|
|
5487
|
-
|
|
6193
|
+
useEffect14(() => {
|
|
5488
6194
|
if (!recoverFocus.current) return;
|
|
5489
6195
|
recoverFocus.current = false;
|
|
5490
6196
|
sectionRef.current?.focus();
|
|
5491
6197
|
}, [current]);
|
|
5492
|
-
const goTo =
|
|
6198
|
+
const goTo = useCallback13(
|
|
5493
6199
|
(next) => {
|
|
5494
6200
|
const clamped = Math.min(Math.max(next, 0), pageCount - 1);
|
|
5495
6201
|
if (clamped === current) return false;
|
|
@@ -5524,7 +6230,7 @@ function InsightPages({
|
|
|
5524
6230
|
}
|
|
5525
6231
|
if (moved) event.preventDefault();
|
|
5526
6232
|
};
|
|
5527
|
-
return /* @__PURE__ */
|
|
6233
|
+
return /* @__PURE__ */ jsxs17(
|
|
5528
6234
|
"section",
|
|
5529
6235
|
{
|
|
5530
6236
|
ref: sectionRef,
|
|
@@ -5536,7 +6242,7 @@ function InsightPages({
|
|
|
5536
6242
|
tabIndex: pageCount > 1 ? 0 : void 0,
|
|
5537
6243
|
"aria-keyshortcuts": pageCount > 1 ? "ArrowLeft ArrowRight PageUp PageDown Home End" : void 0,
|
|
5538
6244
|
children: [
|
|
5539
|
-
/* @__PURE__ */
|
|
6245
|
+
/* @__PURE__ */ jsx19("ul", { ref: listRef, className: "grid gap-3 sm:grid-cols-2 lg:grid-cols-3", children: visible.map(({ id, style, ...card }, index) => (
|
|
5540
6246
|
// The page index is in the key on purpose: a page turn is an arrival,
|
|
5541
6247
|
// and reusing the node would swap the text under a card that never
|
|
5542
6248
|
// moved. Remounting replays `.agent-arrive` with the new stagger.
|
|
@@ -5547,10 +6253,10 @@ function InsightPages({
|
|
|
5547
6253
|
// does not arrive a second time. The key does BOTH jobs — but only
|
|
5548
6254
|
// because the deck now keeps this subtree mounted across a reload
|
|
5549
6255
|
// (see `InsightDeck`); a key is never compared across a teardown.
|
|
5550
|
-
/* @__PURE__ */
|
|
6256
|
+
/* @__PURE__ */ jsx19("li", { children: /* @__PURE__ */ jsx19(InsightCard, { ...card, style: staggerStyle(index, style) }) }, `${current}:${id}`)
|
|
5551
6257
|
)) }),
|
|
5552
|
-
/* @__PURE__ */
|
|
5553
|
-
/* @__PURE__ */
|
|
6258
|
+
/* @__PURE__ */ jsxs17("div", { className: pageCount > 1 ? "flex items-center justify-between gap-2" : void 0, children: [
|
|
6259
|
+
/* @__PURE__ */ jsxs17(
|
|
5554
6260
|
"p",
|
|
5555
6261
|
{
|
|
5556
6262
|
role: "status",
|
|
@@ -5564,8 +6270,8 @@ function InsightPages({
|
|
|
5564
6270
|
]
|
|
5565
6271
|
}
|
|
5566
6272
|
),
|
|
5567
|
-
pageCount > 1 ? /* @__PURE__ */
|
|
5568
|
-
/* @__PURE__ */
|
|
6273
|
+
pageCount > 1 ? /* @__PURE__ */ jsxs17("div", { className: "flex items-center gap-1", children: [
|
|
6274
|
+
/* @__PURE__ */ jsx19(PagerButton, { label: "Previous insights", glyph: "\u2039", atEnd: current === 0, onClick: () => goTo(current - 1) }),
|
|
5569
6275
|
pageCount <= MAX_PAGE_DOTS ? Array.from({ length: pageCount }, (_, index) => (
|
|
5570
6276
|
// WCAG 2.2 SC 2.5.8 wants a 24x24 CSS px target. The dot stays
|
|
5571
6277
|
// 8px because a 24px dot is a different control; the BUTTON
|
|
@@ -5573,7 +6279,7 @@ function InsightPages({
|
|
|
5573
6279
|
// and the span is the graphic. The Spacing exception cannot
|
|
5574
6280
|
// rescue the bare dot — at a 12px pitch the 24px circle around
|
|
5575
6281
|
// each centre overlaps its neighbour's.
|
|
5576
|
-
/* @__PURE__ */
|
|
6282
|
+
/* @__PURE__ */ jsx19(
|
|
5577
6283
|
"button",
|
|
5578
6284
|
{
|
|
5579
6285
|
type: "button",
|
|
@@ -5581,7 +6287,7 @@ function InsightPages({
|
|
|
5581
6287
|
"aria-current": index === current ? "page" : void 0,
|
|
5582
6288
|
onClick: () => goTo(index),
|
|
5583
6289
|
className: "group flex h-6 w-6 shrink-0 items-center justify-center rounded-full",
|
|
5584
|
-
children: /* @__PURE__ */
|
|
6290
|
+
children: /* @__PURE__ */ jsx19(
|
|
5585
6291
|
"span",
|
|
5586
6292
|
{
|
|
5587
6293
|
"aria-hidden": "true",
|
|
@@ -5595,7 +6301,7 @@ function InsightPages({
|
|
|
5595
6301
|
index
|
|
5596
6302
|
)
|
|
5597
6303
|
)) : null,
|
|
5598
|
-
/* @__PURE__ */
|
|
6304
|
+
/* @__PURE__ */ jsx19(
|
|
5599
6305
|
PagerButton,
|
|
5600
6306
|
{
|
|
5601
6307
|
label: "Next insights",
|
|
@@ -5616,7 +6322,7 @@ function PagerButton({
|
|
|
5616
6322
|
atEnd,
|
|
5617
6323
|
onClick
|
|
5618
6324
|
}) {
|
|
5619
|
-
return /* @__PURE__ */
|
|
6325
|
+
return /* @__PURE__ */ jsx19(
|
|
5620
6326
|
"button",
|
|
5621
6327
|
{
|
|
5622
6328
|
type: "button",
|
|
@@ -5626,33 +6332,33 @@ function PagerButton({
|
|
|
5626
6332
|
if (!atEnd) onClick();
|
|
5627
6333
|
},
|
|
5628
6334
|
className: `flex h-6 w-6 items-center justify-center rounded-md border border-border text-xs text-muted-foreground transition ${atEnd ? "opacity-40" : "hover:bg-accent hover:text-foreground"}`,
|
|
5629
|
-
children: /* @__PURE__ */
|
|
6335
|
+
children: /* @__PURE__ */ jsx19("span", { "aria-hidden": "true", children: glyph })
|
|
5630
6336
|
}
|
|
5631
6337
|
);
|
|
5632
6338
|
}
|
|
5633
6339
|
|
|
5634
6340
|
// src/web-react/review-inbox.tsx
|
|
5635
|
-
import { useEffect as
|
|
5636
|
-
import { Button as
|
|
5637
|
-
import { Fragment as
|
|
6341
|
+
import { useEffect as useEffect15, useRef as useRef15, useState as useState22 } from "react";
|
|
6342
|
+
import { Button as Button5, PageHeader } from "@tangle-network/ui/primitives";
|
|
6343
|
+
import { Fragment as Fragment8, jsx as jsx20, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
5638
6344
|
var revisionKey = (item) => JSON.stringify([item.id, item.revision]);
|
|
5639
6345
|
function ordered(items) {
|
|
5640
6346
|
return [...items].sort((left, right) => left.createdAt - right.createdAt || (left.id < right.id ? -1 : left.id > right.id ? 1 : 0));
|
|
5641
6347
|
}
|
|
5642
6348
|
function ReviewInbox({ items, initialSelectedId, renderItem, onVerdict, onFeedback, loading = false, error, onRefresh }) {
|
|
5643
|
-
const [round2, setRound] =
|
|
5644
|
-
const [answered, setAnswered] =
|
|
5645
|
-
const [resolvedElsewhere, setResolvedElsewhere] =
|
|
5646
|
-
const [activeId, setActiveId] =
|
|
5647
|
-
const [busy, setBusy] =
|
|
5648
|
-
const [refreshing, setRefreshing] =
|
|
5649
|
-
const [restart, setRestart] =
|
|
5650
|
-
const [refreshError, setRefreshError] =
|
|
5651
|
-
const cache =
|
|
5652
|
-
const drafts =
|
|
5653
|
-
const pending =
|
|
5654
|
-
const section =
|
|
5655
|
-
const form =
|
|
6349
|
+
const [round2, setRound] = useState22(() => ordered(items).map((item) => item.id));
|
|
6350
|
+
const [answered, setAnswered] = useState22(/* @__PURE__ */ new Set());
|
|
6351
|
+
const [resolvedElsewhere, setResolvedElsewhere] = useState22(/* @__PURE__ */ new Set());
|
|
6352
|
+
const [activeId, setActiveId] = useState22(() => items.some((item) => item.id === initialSelectedId) ? initialSelectedId : ordered(items)[0]?.id ?? null);
|
|
6353
|
+
const [busy, setBusy] = useState22(false);
|
|
6354
|
+
const [refreshing, setRefreshing] = useState22(false);
|
|
6355
|
+
const [restart, setRestart] = useState22(false);
|
|
6356
|
+
const [refreshError, setRefreshError] = useState22("");
|
|
6357
|
+
const cache = useRef15(/* @__PURE__ */ new Map());
|
|
6358
|
+
const drafts = useRef15(/* @__PURE__ */ new Map());
|
|
6359
|
+
const pending = useRef15(false);
|
|
6360
|
+
const section = useRef15(null);
|
|
6361
|
+
const form = useRef15(null);
|
|
5656
6362
|
for (const item of items) cache.current.set(item.id, item);
|
|
5657
6363
|
const currentItems = new Map(items.map((item) => [item.id, item]));
|
|
5658
6364
|
const missing = loading || error || busy || refreshing ? resolvedElsewhere : new Set(round2.filter((id) => !currentItems.has(id)));
|
|
@@ -5667,7 +6373,7 @@ function ReviewInbox({ items, initialSelectedId, renderItem, onVerdict, onFeedba
|
|
|
5667
6373
|
const canReview = !!active && available && active.canReview;
|
|
5668
6374
|
const rank = currentId ? round2.indexOf(currentId) + 1 : round2.length;
|
|
5669
6375
|
const reviewed = round2.length - unanswered.length;
|
|
5670
|
-
|
|
6376
|
+
useEffect15(() => {
|
|
5671
6377
|
if (loading || !restart && (round2.length > 0 || items.length === 0)) return;
|
|
5672
6378
|
const next = ordered(items).map((item) => item.id);
|
|
5673
6379
|
setRound(next);
|
|
@@ -5676,7 +6382,7 @@ function ReviewInbox({ items, initialSelectedId, renderItem, onVerdict, onFeedba
|
|
|
5676
6382
|
setResolvedElsewhere(/* @__PURE__ */ new Set());
|
|
5677
6383
|
setRestart(false);
|
|
5678
6384
|
}, [items, loading, restart, round2.length, initialSelectedId]);
|
|
5679
|
-
|
|
6385
|
+
useEffect15(() => {
|
|
5680
6386
|
if (loading || error || busy || refreshing) return;
|
|
5681
6387
|
const present = new Set(items.map((item) => item.id));
|
|
5682
6388
|
setResolvedElsewhere((previous) => {
|
|
@@ -5684,7 +6390,7 @@ function ReviewInbox({ items, initialSelectedId, renderItem, onVerdict, onFeedba
|
|
|
5684
6390
|
return next.size === previous.size && [...next].every((id) => previous.has(id)) ? previous : next;
|
|
5685
6391
|
});
|
|
5686
6392
|
}, [items, loading, error, busy, refreshing, round2]);
|
|
5687
|
-
|
|
6393
|
+
useEffect15(() => {
|
|
5688
6394
|
setActiveId(currentId ?? null);
|
|
5689
6395
|
section.current?.focus({ preventScroll: true });
|
|
5690
6396
|
}, [currentKey]);
|
|
@@ -5738,7 +6444,7 @@ function ReviewInbox({ items, initialSelectedId, renderItem, onVerdict, onFeedba
|
|
|
5738
6444
|
setRefreshing(false);
|
|
5739
6445
|
}
|
|
5740
6446
|
}
|
|
5741
|
-
|
|
6447
|
+
useEffect15(() => {
|
|
5742
6448
|
function shortcut(event) {
|
|
5743
6449
|
if (event.defaultPrevented || event.repeat || event.altKey || event.ctrlKey || event.metaKey || event.isComposing) return;
|
|
5744
6450
|
const target = event.target instanceof Element ? event.target : null;
|
|
@@ -5767,7 +6473,7 @@ function ReviewInbox({ items, initialSelectedId, renderItem, onVerdict, onFeedba
|
|
|
5767
6473
|
window.addEventListener("keydown", shortcut);
|
|
5768
6474
|
return () => window.removeEventListener("keydown", shortcut);
|
|
5769
6475
|
});
|
|
5770
|
-
return /* @__PURE__ */
|
|
6476
|
+
return /* @__PURE__ */ jsxs18(
|
|
5771
6477
|
"section",
|
|
5772
6478
|
{
|
|
5773
6479
|
ref: section,
|
|
@@ -5777,39 +6483,39 @@ function ReviewInbox({ items, initialSelectedId, renderItem, onVerdict, onFeedba
|
|
|
5777
6483
|
className: "mx-auto min-w-0 max-w-4xl space-y-5 outline-none",
|
|
5778
6484
|
"data-review-inbox": true,
|
|
5779
6485
|
children: [
|
|
5780
|
-
/* @__PURE__ */
|
|
6486
|
+
/* @__PURE__ */ jsx20(
|
|
5781
6487
|
PageHeader,
|
|
5782
6488
|
{
|
|
5783
6489
|
title: "Review inbox",
|
|
5784
6490
|
description: "Review the oldest work first. Every decision includes your score and feedback.",
|
|
5785
|
-
actions: onRefresh && /* @__PURE__ */
|
|
5786
|
-
meta: /* @__PURE__ */
|
|
6491
|
+
actions: onRefresh && /* @__PURE__ */ jsx20(Button5, { variant: "outline", disabled: busy || refreshing || loading, onClick: () => void refresh(), children: refreshing ? "Refreshing\u2026" : "Refresh" }),
|
|
6492
|
+
meta: /* @__PURE__ */ jsx20("p", { role: "status", "data-review-progress": true, children: active ? `${rank} of ${round2.length}` : `${reviewed} of ${round2.length} resolved` })
|
|
5787
6493
|
}
|
|
5788
6494
|
),
|
|
5789
|
-
(error || refreshError) && /* @__PURE__ */
|
|
5790
|
-
round2.length > 0 && /* @__PURE__ */
|
|
5791
|
-
(loading || error) && !active ? /* @__PURE__ */
|
|
5792
|
-
/* @__PURE__ */
|
|
5793
|
-
/* @__PURE__ */
|
|
6495
|
+
(error || refreshError) && /* @__PURE__ */ jsx20("p", { role: "alert", className: "text-sm text-[var(--surface-danger-text)]", children: error || refreshError }),
|
|
6496
|
+
round2.length > 0 && /* @__PURE__ */ jsx20("progress", { "aria-label": "Items resolved this round", value: reviewed, max: round2.length, className: "h-1.5 w-full accent-primary" }),
|
|
6497
|
+
(loading || error) && !active ? /* @__PURE__ */ jsx20("p", { role: "status", children: loading ? "Loading the review inbox\u2026" : "The review inbox could not load." }) : !active ? /* @__PURE__ */ jsxs18("div", { className: "py-12 text-center", children: [
|
|
6498
|
+
/* @__PURE__ */ jsx20("h2", { className: "text-xl font-semibold", children: "All caught up" }),
|
|
6499
|
+
/* @__PURE__ */ jsxs18("p", { className: "mt-2 text-sm text-muted-foreground", children: [
|
|
5794
6500
|
reviewed,
|
|
5795
6501
|
" of ",
|
|
5796
6502
|
round2.length,
|
|
5797
6503
|
" resolved this round."
|
|
5798
6504
|
] })
|
|
5799
|
-
] }) : /* @__PURE__ */
|
|
5800
|
-
/* @__PURE__ */
|
|
5801
|
-
/* @__PURE__ */
|
|
5802
|
-
/* @__PURE__ */
|
|
5803
|
-
/* @__PURE__ */
|
|
6505
|
+
] }) : /* @__PURE__ */ jsxs18(Fragment8, { children: [
|
|
6506
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex flex-wrap items-center justify-between gap-3", children: [
|
|
6507
|
+
/* @__PURE__ */ jsxs18("div", { className: "min-w-0", children: [
|
|
6508
|
+
/* @__PURE__ */ jsx20("p", { className: "text-sm text-muted-foreground", children: active.kind }),
|
|
6509
|
+
/* @__PURE__ */ jsx20("h2", { className: "break-words text-lg font-semibold", "data-review-title": true, children: active.title })
|
|
5804
6510
|
] }),
|
|
5805
|
-
/* @__PURE__ */
|
|
5806
|
-
/* @__PURE__ */
|
|
5807
|
-
/* @__PURE__ */
|
|
6511
|
+
/* @__PURE__ */ jsxs18("div", { className: "flex gap-2", children: [
|
|
6512
|
+
/* @__PURE__ */ jsx20(Button5, { variant: "outline", "aria-keyshortcuts": "K", disabled: busy || unanswered.length < 2, onClick: () => navigate(-1), children: "Previous" }),
|
|
6513
|
+
/* @__PURE__ */ jsx20(Button5, { variant: "outline", "aria-keyshortcuts": "J", disabled: busy || unanswered.length < 2, onClick: () => navigate(1), children: "Next" })
|
|
5808
6514
|
] })
|
|
5809
6515
|
] }),
|
|
5810
|
-
available && !active.canReview && /* @__PURE__ */
|
|
5811
|
-
/* @__PURE__ */
|
|
5812
|
-
/* @__PURE__ */
|
|
6516
|
+
available && !active.canReview && /* @__PURE__ */ jsx20("p", { className: "text-sm text-muted-foreground", children: "You do not have permission to review this item." }),
|
|
6517
|
+
/* @__PURE__ */ jsx20("div", { className: "min-w-0", "data-review-content": true, children: renderItem(active) }),
|
|
6518
|
+
/* @__PURE__ */ jsx20(
|
|
5813
6519
|
ReviewFeedbackForm,
|
|
5814
6520
|
{
|
|
5815
6521
|
ref: form,
|
|
@@ -5826,7 +6532,7 @@ function ReviewInbox({ items, initialSelectedId, renderItem, onVerdict, onFeedba
|
|
|
5826
6532
|
},
|
|
5827
6533
|
currentKey
|
|
5828
6534
|
),
|
|
5829
|
-
/* @__PURE__ */
|
|
6535
|
+
/* @__PURE__ */ jsx20("p", { className: "text-xs leading-5 text-muted-foreground", children: "A approve \xB7 R request changes \xB7 S score \xB7 J/K next/previous \xB7 Esc leave a field. Shortcuts pause while typing." })
|
|
5830
6536
|
] })
|
|
5831
6537
|
]
|
|
5832
6538
|
}
|
|
@@ -5834,9 +6540,9 @@ function ReviewInbox({ items, initialSelectedId, renderItem, onVerdict, onFeedba
|
|
|
5834
6540
|
}
|
|
5835
6541
|
|
|
5836
6542
|
// src/web-react/api-access-panel.tsx
|
|
5837
|
-
import { useEffect as
|
|
5838
|
-
import { Button as
|
|
5839
|
-
import { jsx as
|
|
6543
|
+
import { useEffect as useEffect16, useRef as useRef16, useState as useState23 } from "react";
|
|
6544
|
+
import { Button as Button6, Input as Input3, PageHeader as PageHeader2 } from "@tangle-network/ui/primitives";
|
|
6545
|
+
import { jsx as jsx21, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
5840
6546
|
var defaultExpiryChoices = [1, 7, 30];
|
|
5841
6547
|
function pruneScopes(scopes, access) {
|
|
5842
6548
|
const offered = new Map(access.map((option) => [option.scope, option]));
|
|
@@ -5887,31 +6593,31 @@ function ApiAccessPanel({
|
|
|
5887
6593
|
onRevoke,
|
|
5888
6594
|
onChanged
|
|
5889
6595
|
}) {
|
|
5890
|
-
const [name, setName] =
|
|
5891
|
-
const [reach, setReach] =
|
|
6596
|
+
const [name, setName] = useState23("");
|
|
6597
|
+
const [reach, setReach] = useState23("");
|
|
5892
6598
|
const selectedWorkspace = workspaces?.some((workspace) => workspace.id === reach) ? reach : "";
|
|
5893
6599
|
const workspaceName = (id) => workspaces?.find((workspace) => workspace.id === id)?.name ?? `A removed ${workspaceNoun.singular}`;
|
|
5894
6600
|
const allowedDays = [...new Set(expiryDays)].filter((days2) => days2 > 0 && Number.isFinite(new Date(Date.now() + days2 * 864e5).getTime()));
|
|
5895
6601
|
const fallbackDays = allowedDays.includes(defaultExpiryDays) ? defaultExpiryDays : allowedDays[0];
|
|
5896
|
-
const [days, setDays] =
|
|
6602
|
+
const [days, setDays] = useState23(fallbackDays);
|
|
5897
6603
|
const selectedDays = days !== void 0 && allowedDays.includes(days) ? days : fallbackDays;
|
|
5898
|
-
const [scopes, setScopes] =
|
|
5899
|
-
const [creating, setCreating] =
|
|
5900
|
-
const [revoking, setRevoking] =
|
|
5901
|
-
const [created, setCreated] =
|
|
5902
|
-
const [notice, setNotice] =
|
|
5903
|
-
const [error, setError] =
|
|
5904
|
-
const keyHeading =
|
|
5905
|
-
const nameInput =
|
|
5906
|
-
const keyWasShown =
|
|
6604
|
+
const [scopes, setScopes] = useState23(() => expandScopes(defaultScopes, access));
|
|
6605
|
+
const [creating, setCreating] = useState23(false);
|
|
6606
|
+
const [revoking, setRevoking] = useState23(null);
|
|
6607
|
+
const [created, setCreated] = useState23(null);
|
|
6608
|
+
const [notice, setNotice] = useState23(null);
|
|
6609
|
+
const [error, setError] = useState23(null);
|
|
6610
|
+
const keyHeading = useRef16(null);
|
|
6611
|
+
const nameInput = useRef16(null);
|
|
6612
|
+
const keyWasShown = useRef16(false);
|
|
5907
6613
|
const selectedScopes = pruneScopes(scopes, access);
|
|
5908
|
-
|
|
6614
|
+
useEffect16(() => {
|
|
5909
6615
|
setScopes((current) => {
|
|
5910
6616
|
const next = pruneScopes(current, access);
|
|
5911
6617
|
return next.length === current.length ? current : next;
|
|
5912
6618
|
});
|
|
5913
6619
|
}, [access]);
|
|
5914
|
-
|
|
6620
|
+
useEffect16(() => {
|
|
5915
6621
|
if (created) {
|
|
5916
6622
|
keyHeading.current?.focus();
|
|
5917
6623
|
keyWasShown.current = true;
|
|
@@ -5957,10 +6663,10 @@ function ApiAccessPanel({
|
|
|
5957
6663
|
setRevoking(null);
|
|
5958
6664
|
}
|
|
5959
6665
|
}
|
|
5960
|
-
return /* @__PURE__ */
|
|
5961
|
-
/* @__PURE__ */
|
|
5962
|
-
accountHref && /* @__PURE__ */
|
|
5963
|
-
/* @__PURE__ */
|
|
6666
|
+
return /* @__PURE__ */ jsx21("main", { className: "flex-1 overflow-y-auto", children: /* @__PURE__ */ jsxs19("div", { className: "mx-auto max-w-2xl space-y-8 px-4 py-8 sm:px-8", children: [
|
|
6667
|
+
/* @__PURE__ */ jsxs19("div", { className: "space-y-2", children: [
|
|
6668
|
+
accountHref && /* @__PURE__ */ jsx21("a", { href: accountHref, className: "text-sm text-muted-foreground hover:text-foreground", children: "Account" }),
|
|
6669
|
+
/* @__PURE__ */ jsx21(
|
|
5964
6670
|
PageHeader2,
|
|
5965
6671
|
{
|
|
5966
6672
|
className: "mb-0",
|
|
@@ -5969,14 +6675,14 @@ function ApiAccessPanel({
|
|
|
5969
6675
|
}
|
|
5970
6676
|
)
|
|
5971
6677
|
] }),
|
|
5972
|
-
error && /* @__PURE__ */
|
|
5973
|
-
notice && /* @__PURE__ */
|
|
5974
|
-
created ? /* @__PURE__ */
|
|
5975
|
-
/* @__PURE__ */
|
|
5976
|
-
/* @__PURE__ */
|
|
5977
|
-
/* @__PURE__ */
|
|
5978
|
-
/* @__PURE__ */
|
|
5979
|
-
/* @__PURE__ */
|
|
6678
|
+
error && /* @__PURE__ */ jsx21("p", { role: "alert", className: "rounded-lg border border-destructive/40 p-3 text-sm text-destructive", children: error }),
|
|
6679
|
+
notice && /* @__PURE__ */ jsx21("p", { role: "status", className: "text-sm text-muted-foreground", children: notice }),
|
|
6680
|
+
created ? /* @__PURE__ */ jsxs19("section", { "aria-labelledby": "save-api-key", className: "space-y-4 rounded-xl border border-border bg-card p-5", children: [
|
|
6681
|
+
/* @__PURE__ */ jsx21("h2", { ref: keyHeading, tabIndex: -1, id: "save-api-key", className: "font-medium outline-none", children: "Save your key" }),
|
|
6682
|
+
/* @__PURE__ */ jsx21("p", { className: "text-sm text-muted-foreground", children: "Copy it directly into your client\u2019s secret storage. It is shown only now. Keep it out of chat messages and prompts." }),
|
|
6683
|
+
/* @__PURE__ */ jsxs19("div", { className: "flex gap-2", children: [
|
|
6684
|
+
/* @__PURE__ */ jsx21(Input3, { size: "lg", "aria-label": "New API key", type: "password", value: created.key, readOnly: true, autoComplete: "off", className: "min-w-0 font-mono" }),
|
|
6685
|
+
/* @__PURE__ */ jsx21(Button6, { onClick: async () => {
|
|
5980
6686
|
try {
|
|
5981
6687
|
await navigator.clipboard.writeText(created.key);
|
|
5982
6688
|
setNotice("Key copied");
|
|
@@ -5985,46 +6691,46 @@ function ApiAccessPanel({
|
|
|
5985
6691
|
}
|
|
5986
6692
|
}, children: "Copy key" })
|
|
5987
6693
|
] }),
|
|
5988
|
-
/* @__PURE__ */
|
|
6694
|
+
/* @__PURE__ */ jsx21(Button6, { variant: "outline", onClick: () => {
|
|
5989
6695
|
setCreated(null);
|
|
5990
6696
|
setNotice(null);
|
|
5991
6697
|
}, children: "I\u2019ve saved it" })
|
|
5992
|
-
] }) : /* @__PURE__ */
|
|
5993
|
-
/* @__PURE__ */
|
|
5994
|
-
/* @__PURE__ */
|
|
5995
|
-
/* @__PURE__ */
|
|
5996
|
-
/* @__PURE__ */
|
|
5997
|
-
/* @__PURE__ */
|
|
6698
|
+
] }) : /* @__PURE__ */ jsxs19("form", { onSubmit: createKey, className: "space-y-5 rounded-xl border border-border bg-card p-5", children: [
|
|
6699
|
+
/* @__PURE__ */ jsx21("h2", { className: "font-medium", children: "Create a key" }),
|
|
6700
|
+
/* @__PURE__ */ jsxs19("div", { className: "grid gap-4 sm:grid-cols-[1fr_10rem]", children: [
|
|
6701
|
+
/* @__PURE__ */ jsxs19("div", { className: "space-y-1.5", children: [
|
|
6702
|
+
/* @__PURE__ */ jsx21("label", { className: "text-sm font-medium", htmlFor: "key-name", children: "Name" }),
|
|
6703
|
+
/* @__PURE__ */ jsx21(Input3, { size: "lg", ref: nameInput, id: "key-name", value: name, onChange: (event) => setName(event.target.value), placeholder: "Client on my server", maxLength: 100, required: true, autoComplete: "off" })
|
|
5998
6704
|
] }),
|
|
5999
|
-
/* @__PURE__ */
|
|
6000
|
-
/* @__PURE__ */
|
|
6001
|
-
/* @__PURE__ */
|
|
6705
|
+
/* @__PURE__ */ jsxs19("div", { className: "space-y-1.5", children: [
|
|
6706
|
+
/* @__PURE__ */ jsx21("label", { className: "text-sm font-medium", htmlFor: "key-expiry", children: "Expires in" }),
|
|
6707
|
+
/* @__PURE__ */ jsx21("select", { id: "key-expiry", value: selectedDays ?? "", onChange: (event) => setDays(Number(event.target.value)), className: "h-11 w-full rounded-lg border border-input bg-background px-3 text-sm", children: allowedDays.map((days2) => /* @__PURE__ */ jsxs19("option", { value: days2, children: [
|
|
6002
6708
|
days2,
|
|
6003
6709
|
" ",
|
|
6004
6710
|
days2 === 1 ? "day" : "days"
|
|
6005
6711
|
] }, days2)) })
|
|
6006
6712
|
] })
|
|
6007
6713
|
] }),
|
|
6008
|
-
workspaces && workspaces.length > 0 && /* @__PURE__ */
|
|
6009
|
-
/* @__PURE__ */
|
|
6010
|
-
/* @__PURE__ */
|
|
6011
|
-
/* @__PURE__ */
|
|
6714
|
+
workspaces && workspaces.length > 0 && /* @__PURE__ */ jsxs19("div", { className: "space-y-1.5", children: [
|
|
6715
|
+
/* @__PURE__ */ jsx21("label", { className: "text-sm font-medium", htmlFor: "key-reach", children: "Reaches" }),
|
|
6716
|
+
/* @__PURE__ */ jsxs19("select", { id: "key-reach", value: selectedWorkspace, onChange: (event) => setReach(event.target.value), className: "h-11 w-full rounded-lg border border-input bg-background px-3 text-sm", children: [
|
|
6717
|
+
/* @__PURE__ */ jsxs19("option", { value: "", children: [
|
|
6012
6718
|
"All ",
|
|
6013
6719
|
workspaceNoun.plural,
|
|
6014
6720
|
", including new ones"
|
|
6015
6721
|
] }),
|
|
6016
|
-
workspaces.map((workspace) => /* @__PURE__ */
|
|
6722
|
+
workspaces.map((workspace) => /* @__PURE__ */ jsxs19("option", { value: workspace.id, children: [
|
|
6017
6723
|
"Only ",
|
|
6018
6724
|
workspace.name
|
|
6019
6725
|
] }, workspace.id))
|
|
6020
6726
|
] })
|
|
6021
6727
|
] }),
|
|
6022
|
-
/* @__PURE__ */
|
|
6023
|
-
/* @__PURE__ */
|
|
6728
|
+
/* @__PURE__ */ jsxs19("fieldset", { className: "space-y-3", children: [
|
|
6729
|
+
/* @__PURE__ */ jsx21("legend", { className: "mb-3 text-sm font-medium", children: "Permissions" }),
|
|
6024
6730
|
access.map((option) => {
|
|
6025
6731
|
const unavailable = !expandScopes([option.scope], access).includes(option.scope);
|
|
6026
|
-
return /* @__PURE__ */
|
|
6027
|
-
/* @__PURE__ */
|
|
6732
|
+
return /* @__PURE__ */ jsxs19("label", { className: "flex cursor-pointer items-start gap-3", children: [
|
|
6733
|
+
/* @__PURE__ */ jsx21(
|
|
6028
6734
|
"input",
|
|
6029
6735
|
{
|
|
6030
6736
|
type: "checkbox",
|
|
@@ -6034,42 +6740,42 @@ function ApiAccessPanel({
|
|
|
6034
6740
|
onChange: (event) => setScopes((current) => event.target.checked ? expandScopes([...current, option.scope], access) : pruneScopes(current.filter((scope) => scope !== option.scope), access))
|
|
6035
6741
|
}
|
|
6036
6742
|
),
|
|
6037
|
-
/* @__PURE__ */
|
|
6038
|
-
/* @__PURE__ */
|
|
6039
|
-
/* @__PURE__ */
|
|
6040
|
-
unavailable && /* @__PURE__ */
|
|
6743
|
+
/* @__PURE__ */ jsxs19("span", { className: "text-sm", children: [
|
|
6744
|
+
/* @__PURE__ */ jsx21("span", { className: "block font-medium", children: option.label }),
|
|
6745
|
+
/* @__PURE__ */ jsx21("span", { className: "text-muted-foreground", children: option.description }),
|
|
6746
|
+
unavailable && /* @__PURE__ */ jsx21("span", { className: "block text-muted-foreground", children: "Required permission unavailable." })
|
|
6041
6747
|
] })
|
|
6042
6748
|
] }, option.scope);
|
|
6043
6749
|
})
|
|
6044
6750
|
] }),
|
|
6045
|
-
limitsDescription && /* @__PURE__ */
|
|
6046
|
-
/* @__PURE__ */
|
|
6751
|
+
limitsDescription && /* @__PURE__ */ jsx21("p", { className: "text-sm text-muted-foreground", children: limitsDescription }),
|
|
6752
|
+
/* @__PURE__ */ jsx21(Button6, { type: "submit", disabled: creating || !name.trim() || !selectedScopes.length || selectedDays === void 0, children: creating ? "Creating\u2026" : "Create key" })
|
|
6047
6753
|
] }),
|
|
6048
|
-
/* @__PURE__ */
|
|
6049
|
-
/* @__PURE__ */
|
|
6050
|
-
keys.length === 0 ? /* @__PURE__ */
|
|
6051
|
-
/* @__PURE__ */
|
|
6052
|
-
/* @__PURE__ */
|
|
6053
|
-
/* @__PURE__ */
|
|
6054
|
-
/* @__PURE__ */
|
|
6055
|
-
workspaces && /* @__PURE__ */
|
|
6754
|
+
/* @__PURE__ */ jsxs19("section", { "aria-labelledby": "existing-keys", className: "space-y-3", children: [
|
|
6755
|
+
/* @__PURE__ */ jsx21("h2", { id: "existing-keys", className: "font-medium", children: "Your keys" }),
|
|
6756
|
+
keys.length === 0 ? /* @__PURE__ */ jsx21("p", { className: "text-sm text-muted-foreground", children: "No keys yet." }) : /* @__PURE__ */ jsx21("ul", { className: "divide-y divide-border rounded-xl border border-border bg-card", children: keys.map((key) => /* @__PURE__ */ jsxs19("li", { className: "flex items-start justify-between gap-3 p-4", children: [
|
|
6757
|
+
/* @__PURE__ */ jsxs19("div", { className: "min-w-0 space-y-1", children: [
|
|
6758
|
+
/* @__PURE__ */ jsx21("p", { className: "break-words text-sm font-medium", children: key.name }),
|
|
6759
|
+
/* @__PURE__ */ jsx21("p", { className: "text-sm text-muted-foreground", children: key.expiresAt ? `${new Date(key.expiresAt).getTime() <= Date.now() ? "Expired" : "Expires"} ${new Date(key.expiresAt).toLocaleDateString()}` : "No expiry" }),
|
|
6760
|
+
/* @__PURE__ */ jsx21("p", { className: "text-sm text-muted-foreground", children: key.scopes.map((scope) => access.find((access2) => access2.scope === scope)?.label ?? scope).join(" \xB7 ") }),
|
|
6761
|
+
workspaces && /* @__PURE__ */ jsx21("p", { className: "text-sm text-muted-foreground", children: key.workspaceIds?.length ? `Only ${key.workspaceIds.map(workspaceName).join(", ")}` : `All ${workspaceNoun.plural}` })
|
|
6056
6762
|
] }),
|
|
6057
|
-
/* @__PURE__ */
|
|
6763
|
+
/* @__PURE__ */ jsx21(Button6, { variant: "outline", disabled: revoking !== null, onClick: () => revokeKey(key.id), "aria-label": `Revoke ${key.name}`, children: revoking === key.id ? "Revoking\u2026" : "Revoke" })
|
|
6058
6764
|
] }, key.id)) })
|
|
6059
6765
|
] }),
|
|
6060
|
-
/* @__PURE__ */
|
|
6766
|
+
/* @__PURE__ */ jsxs19("p", { className: "text-sm text-muted-foreground", children: [
|
|
6061
6767
|
"Use ",
|
|
6062
|
-
/* @__PURE__ */
|
|
6768
|
+
/* @__PURE__ */ jsx21("code", { className: "text-sm", children: baseUrl }),
|
|
6063
6769
|
" as the API base and send the key as a Bearer credential."
|
|
6064
6770
|
] })
|
|
6065
6771
|
] }) });
|
|
6066
6772
|
}
|
|
6067
6773
|
|
|
6068
6774
|
// src/web-react/agent-setup-block.tsx
|
|
6069
|
-
import { useState as
|
|
6070
|
-
import { jsx as
|
|
6775
|
+
import { useState as useState24 } from "react";
|
|
6776
|
+
import { jsx as jsx22, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
6071
6777
|
function AgentSetupBlock({ productName, setupUrl, markdown, description, className }) {
|
|
6072
|
-
const [notice, setNotice] =
|
|
6778
|
+
const [notice, setNotice] = useState24(null);
|
|
6073
6779
|
const prompt = markdown ?? `Set up ${productName} for me. Fetch ${setupUrl} and follow every step in it.`;
|
|
6074
6780
|
async function copy() {
|
|
6075
6781
|
try {
|
|
@@ -6079,15 +6785,15 @@ function AgentSetupBlock({ productName, setupUrl, markdown, description, classNa
|
|
|
6079
6785
|
setNotice(`Clipboard unavailable. Open ${setupUrl} and copy it from there.`);
|
|
6080
6786
|
}
|
|
6081
6787
|
}
|
|
6082
|
-
return /* @__PURE__ */
|
|
6788
|
+
return /* @__PURE__ */ jsxs20(
|
|
6083
6789
|
"section",
|
|
6084
6790
|
{
|
|
6085
6791
|
"aria-labelledby": "agent-setup-heading",
|
|
6086
6792
|
className: `space-y-3 rounded-xl border border-border bg-card p-5 ${className ?? ""}`.trim(),
|
|
6087
6793
|
children: [
|
|
6088
|
-
/* @__PURE__ */
|
|
6089
|
-
/* @__PURE__ */
|
|
6090
|
-
/* @__PURE__ */
|
|
6794
|
+
/* @__PURE__ */ jsxs20("div", { className: "flex flex-wrap items-center justify-between gap-3", children: [
|
|
6795
|
+
/* @__PURE__ */ jsx22("h2", { id: "agent-setup-heading", className: "font-medium text-foreground", children: "Hand this to your agent" }),
|
|
6796
|
+
/* @__PURE__ */ jsx22(
|
|
6091
6797
|
"button",
|
|
6092
6798
|
{
|
|
6093
6799
|
type: "button",
|
|
@@ -6097,51 +6803,51 @@ function AgentSetupBlock({ productName, setupUrl, markdown, description, classNa
|
|
|
6097
6803
|
}
|
|
6098
6804
|
)
|
|
6099
6805
|
] }),
|
|
6100
|
-
/* @__PURE__ */
|
|
6101
|
-
/* @__PURE__ */
|
|
6806
|
+
/* @__PURE__ */ jsx22("p", { className: "text-sm text-muted-foreground", children: description ?? `Your coding agent sets up ${productName} end to end: it asks you to approve once, gets its own capped key, installs the client, and verifies a first call.` }),
|
|
6807
|
+
/* @__PURE__ */ jsxs20("p", { className: "text-sm text-muted-foreground", children: [
|
|
6102
6808
|
"Raw prompt:",
|
|
6103
6809
|
" ",
|
|
6104
|
-
/* @__PURE__ */
|
|
6810
|
+
/* @__PURE__ */ jsx22("a", { href: setupUrl, className: "font-mono text-foreground underline", children: setupUrl })
|
|
6105
6811
|
] }),
|
|
6106
|
-
notice ? /* @__PURE__ */
|
|
6812
|
+
notice ? /* @__PURE__ */ jsx22("p", { role: "status", className: "text-sm text-foreground", children: notice }) : null
|
|
6107
6813
|
]
|
|
6108
6814
|
}
|
|
6109
6815
|
);
|
|
6110
6816
|
}
|
|
6111
6817
|
|
|
6112
6818
|
// src/web-react/agent-profile-choices.tsx
|
|
6113
|
-
import { useId as
|
|
6114
|
-
import { jsx as
|
|
6819
|
+
import { useId as useId5 } from "react";
|
|
6820
|
+
import { jsx as jsx23, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
6115
6821
|
function AgentProfileChoices({ value, profiles, onChange, disabled, locked, lockReason, onNewChat, label = "Agent profile" }) {
|
|
6116
|
-
const name =
|
|
6822
|
+
const name = useId5();
|
|
6117
6823
|
const selected = profiles.find((profile) => profile.id === value);
|
|
6118
6824
|
if (locked) {
|
|
6119
|
-
return /* @__PURE__ */
|
|
6120
|
-
/* @__PURE__ */
|
|
6121
|
-
/* @__PURE__ */
|
|
6122
|
-
onNewChat && !disabled && /* @__PURE__ */
|
|
6825
|
+
return /* @__PURE__ */ jsxs21("div", { className: "space-y-2 rounded-lg border border-border p-3 text-sm", children: [
|
|
6826
|
+
/* @__PURE__ */ jsx23("p", { className: "font-medium text-foreground", children: selected?.name ?? value }),
|
|
6827
|
+
/* @__PURE__ */ jsx23("p", { className: "text-muted-foreground", children: lockReason ?? "This conversation stays on its current profile." }),
|
|
6828
|
+
onNewChat && !disabled && /* @__PURE__ */ jsx23("button", { type: "button", onClick: onNewChat, className: "text-sm font-medium text-primary underline underline-offset-4", children: "New chat to switch profile" })
|
|
6123
6829
|
] });
|
|
6124
6830
|
}
|
|
6125
|
-
return /* @__PURE__ */
|
|
6126
|
-
/* @__PURE__ */
|
|
6127
|
-
/* @__PURE__ */
|
|
6128
|
-
profiles.map((profile) => /* @__PURE__ */
|
|
6129
|
-
/* @__PURE__ */
|
|
6831
|
+
return /* @__PURE__ */ jsxs21("fieldset", { disabled, className: "min-w-0 space-y-1", children: [
|
|
6832
|
+
/* @__PURE__ */ jsx23("legend", { className: "sr-only", children: label }),
|
|
6833
|
+
/* @__PURE__ */ jsxs21("div", { className: "max-h-48 space-y-1 overflow-y-auto", children: [
|
|
6834
|
+
profiles.map((profile) => /* @__PURE__ */ jsxs21("label", { className: "flex min-h-10 cursor-pointer items-start gap-2 rounded-lg border border-transparent p-2 text-sm hover:bg-muted has-[:checked]:border-border has-[:checked]:bg-muted has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-60", children: [
|
|
6835
|
+
/* @__PURE__ */ jsx23("input", { type: "radio", name, value: profile.id, checked: profile.id === value, disabled, onChange: () => {
|
|
6130
6836
|
if (!disabled) onChange(profile.id);
|
|
6131
6837
|
}, className: "mt-1 shrink-0 accent-primary" }),
|
|
6132
|
-
/* @__PURE__ */
|
|
6133
|
-
/* @__PURE__ */
|
|
6134
|
-
profile.description && /* @__PURE__ */
|
|
6838
|
+
/* @__PURE__ */ jsxs21("span", { className: "min-w-0", children: [
|
|
6839
|
+
/* @__PURE__ */ jsx23("span", { className: "block font-medium text-foreground", children: profile.name }),
|
|
6840
|
+
profile.description && /* @__PURE__ */ jsx23("span", { className: "mt-0.5 block text-xs text-muted-foreground", children: profile.description })
|
|
6135
6841
|
] })
|
|
6136
6842
|
] }, profile.id)),
|
|
6137
|
-
profiles.length === 0 && /* @__PURE__ */
|
|
6843
|
+
profiles.length === 0 && /* @__PURE__ */ jsx23("p", { role: "status", className: "p-2 text-sm text-muted-foreground", children: "No profiles available." })
|
|
6138
6844
|
] })
|
|
6139
6845
|
] });
|
|
6140
6846
|
}
|
|
6141
6847
|
|
|
6142
6848
|
// src/web-react/composer-profile-pill.tsx
|
|
6143
6849
|
import { AgentProfilePicker } from "@tangle-network/sandbox-ui/chat";
|
|
6144
|
-
import { jsx as
|
|
6850
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
6145
6851
|
var TRIGGER = {
|
|
6146
6852
|
composer: "max-w-[180px]",
|
|
6147
6853
|
// A menu panel repoints surface-container to its own tone, which would leave
|
|
@@ -6166,7 +6872,7 @@ function ComposerProfilePill({
|
|
|
6166
6872
|
placement = "composer",
|
|
6167
6873
|
className
|
|
6168
6874
|
}) {
|
|
6169
|
-
return /* @__PURE__ */
|
|
6875
|
+
return /* @__PURE__ */ jsx24(
|
|
6170
6876
|
AgentProfilePicker,
|
|
6171
6877
|
{
|
|
6172
6878
|
value: selection.value,
|
|
@@ -6190,7 +6896,7 @@ function ComposerProfilePill({
|
|
|
6190
6896
|
}
|
|
6191
6897
|
|
|
6192
6898
|
// src/web-react/index.tsx
|
|
6193
|
-
import { Fragment as
|
|
6899
|
+
import { Fragment as Fragment9, jsx as jsx25, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
6194
6900
|
function formatModelCost(msg, models) {
|
|
6195
6901
|
if (msg.promptTokens == null && msg.completionTokens == null) return null;
|
|
6196
6902
|
const pricing = models.find((m) => m.id === msg.modelUsed)?.pricing;
|
|
@@ -6204,41 +6910,41 @@ function formatTokensPerSecond(msg) {
|
|
|
6204
6910
|
return `${Math.round(msg.completionTokens / (msg.durationMs / 1e3))} tok/s`;
|
|
6205
6911
|
}
|
|
6206
6912
|
function RunDrillIn({ run, onClose }) {
|
|
6207
|
-
return /* @__PURE__ */
|
|
6208
|
-
/* @__PURE__ */
|
|
6209
|
-
/* @__PURE__ */
|
|
6913
|
+
return /* @__PURE__ */ jsxs22("div", { className: `fixed inset-y-0 right-0 z-50 flex w-[480px] max-w-full flex-col border-l border-card-edge bg-popover ${OVERLAY_SHADOW}`, children: [
|
|
6914
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex items-center gap-2 border-b border-border px-4 py-3", children: [
|
|
6915
|
+
/* @__PURE__ */ jsx25(
|
|
6210
6916
|
"span",
|
|
6211
6917
|
{
|
|
6212
6918
|
className: `h-2 w-2 shrink-0 rounded-full ${run.status === "running" ? "bg-warning" : run.status === "error" ? "bg-destructive" : "bg-success"}`
|
|
6213
6919
|
}
|
|
6214
6920
|
),
|
|
6215
|
-
/* @__PURE__ */
|
|
6216
|
-
/* @__PURE__ */
|
|
6217
|
-
/* @__PURE__ */
|
|
6921
|
+
/* @__PURE__ */ jsxs22("div", { className: "min-w-0 flex-1", children: [
|
|
6922
|
+
/* @__PURE__ */ jsx25("p", { className: "truncate text-[15px] font-semibold", children: run.title }),
|
|
6923
|
+
/* @__PURE__ */ jsx25("p", { className: "truncate font-mono text-xs text-muted-foreground", children: run.toolName })
|
|
6218
6924
|
] }),
|
|
6219
|
-
/* @__PURE__ */
|
|
6925
|
+
/* @__PURE__ */ jsx25(
|
|
6220
6926
|
"button",
|
|
6221
6927
|
{
|
|
6222
6928
|
type: "button",
|
|
6223
6929
|
onClick: onClose,
|
|
6224
6930
|
"aria-label": "Close",
|
|
6225
6931
|
className: "rounded-md p-1.5 text-muted-foreground transition hover:bg-accent hover:text-foreground",
|
|
6226
|
-
children: /* @__PURE__ */
|
|
6932
|
+
children: /* @__PURE__ */ jsx25("svg", { className: "h-4 w-4", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx25("path", { d: "M18 6 6 18M6 6l12 12" }) })
|
|
6227
6933
|
}
|
|
6228
6934
|
)
|
|
6229
6935
|
] }),
|
|
6230
|
-
/* @__PURE__ */
|
|
6231
|
-
run.steps.length === 0 && /* @__PURE__ */
|
|
6232
|
-
run.steps.map((step, i) => /* @__PURE__ */
|
|
6233
|
-
/* @__PURE__ */
|
|
6234
|
-
/* @__PURE__ */
|
|
6235
|
-
/* @__PURE__ */
|
|
6236
|
-
/* @__PURE__ */
|
|
6936
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex-1 space-y-3 overflow-y-auto p-4", children: [
|
|
6937
|
+
run.steps.length === 0 && /* @__PURE__ */ jsx25("p", { className: "text-sm text-muted-foreground", children: "No steps recorded yet." }),
|
|
6938
|
+
run.steps.map((step, i) => /* @__PURE__ */ jsxs22("div", { className: "rounded-lg border border-card-edge bg-card", children: [
|
|
6939
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex items-baseline gap-2 border-b border-border px-3 py-1.5", children: [
|
|
6940
|
+
/* @__PURE__ */ jsx25("span", { className: `font-mono text-xs ${step.status === "error" ? "text-destructive" : "text-muted-foreground"}`, children: step.status === "error" ? "\u2717" : "$" }),
|
|
6941
|
+
/* @__PURE__ */ jsx25("code", { className: "min-w-0 flex-1 truncate font-mono text-xs", children: step.label }),
|
|
6942
|
+
/* @__PURE__ */ jsx25("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: new Date(step.at).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" }) })
|
|
6237
6943
|
] }),
|
|
6238
|
-
step.detail && /* @__PURE__ */
|
|
6944
|
+
step.detail && /* @__PURE__ */ jsx25("pre", { className: "max-h-48 overflow-auto whitespace-pre-wrap px-3 py-2 font-mono text-xs leading-relaxed text-muted-foreground", children: step.detail })
|
|
6239
6945
|
] }, i))
|
|
6240
6946
|
] }),
|
|
6241
|
-
/* @__PURE__ */
|
|
6947
|
+
/* @__PURE__ */ jsx25("p", { className: "border-t border-border px-4 py-2 text-xs text-muted-foreground", children: "Read-only transcript \u2014 reply in the main chat." })
|
|
6242
6948
|
] });
|
|
6243
6949
|
}
|
|
6244
6950
|
function pendingApprovalOf(call) {
|
|
@@ -6254,23 +6960,23 @@ function ChatEmptyState({
|
|
|
6254
6960
|
}) {
|
|
6255
6961
|
const doorCount = Math.min(doors?.length ?? 0, 3);
|
|
6256
6962
|
const doorsGridClass = doorCount === 1 ? "mx-auto max-w-sm sm:grid-cols-1" : doorCount === 2 ? "sm:grid-cols-2" : "sm:grid-cols-3";
|
|
6257
|
-
return /* @__PURE__ */
|
|
6258
|
-
/* @__PURE__ */
|
|
6259
|
-
/* @__PURE__ */
|
|
6260
|
-
/* @__PURE__ */
|
|
6261
|
-
subline && /* @__PURE__ */
|
|
6262
|
-
doors && doors.length > 0 && /* @__PURE__ */
|
|
6963
|
+
return /* @__PURE__ */ jsxs22("div", { className: "mx-auto flex w-full max-w-2xl flex-col items-center px-6 py-12 text-center sm:py-20", children: [
|
|
6964
|
+
/* @__PURE__ */ jsx25("span", { className: "mb-5 inline-flex h-14 w-14 items-center justify-center rounded-2xl bg-primary/10 ring-1 ring-primary/15", children: /* @__PURE__ */ jsx25(BrandMark, { size: 32, className: "shrink-0" }) }),
|
|
6965
|
+
/* @__PURE__ */ jsx25("p", { className: "text-xs font-semibold uppercase tracking-[0.05em] text-muted-foreground", children: productName }),
|
|
6966
|
+
/* @__PURE__ */ jsx25("h2", { className: "mt-1.5 text-balance text-2xl font-semibold leading-tight text-foreground", children: headline }),
|
|
6967
|
+
subline && /* @__PURE__ */ jsx25("p", { className: "mt-3 max-w-md text-[15px] leading-relaxed text-muted-foreground", children: subline }),
|
|
6968
|
+
doors && doors.length > 0 && /* @__PURE__ */ jsx25("div", { className: `mt-7 grid w-full gap-2.5 ${doorsGridClass}`, children: doors.slice(0, 3).map((door, i) => /* @__PURE__ */ jsxs22(
|
|
6263
6969
|
"button",
|
|
6264
6970
|
{
|
|
6265
6971
|
type: "button",
|
|
6266
6972
|
onClick: door.onSelect,
|
|
6267
6973
|
className: "group flex min-h-[44px] flex-col items-start rounded-xl border border-border bg-card px-4 py-3 text-left transition hover:border-primary/40 hover:bg-accent",
|
|
6268
6974
|
children: [
|
|
6269
|
-
/* @__PURE__ */
|
|
6975
|
+
/* @__PURE__ */ jsxs22("span", { className: "flex items-center gap-2 text-sm font-semibold text-foreground", children: [
|
|
6270
6976
|
door.icon,
|
|
6271
6977
|
door.label
|
|
6272
6978
|
] }),
|
|
6273
|
-
door.description && /* @__PURE__ */
|
|
6979
|
+
door.description && /* @__PURE__ */ jsx25("span", { className: "mt-0.5 text-[12px] leading-snug text-muted-foreground", children: door.description })
|
|
6274
6980
|
]
|
|
6275
6981
|
},
|
|
6276
6982
|
i
|
|
@@ -6279,26 +6985,26 @@ function ChatEmptyState({
|
|
|
6279
6985
|
}
|
|
6280
6986
|
function ToolGlyph({ name, className }) {
|
|
6281
6987
|
if (name.startsWith("sandbox_")) {
|
|
6282
|
-
return /* @__PURE__ */
|
|
6283
|
-
/* @__PURE__ */
|
|
6284
|
-
/* @__PURE__ */
|
|
6988
|
+
return /* @__PURE__ */ jsxs22("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
|
|
6989
|
+
/* @__PURE__ */ jsx25("polyline", { points: "4 17 10 11 4 5" }),
|
|
6990
|
+
/* @__PURE__ */ jsx25("line", { x1: "12", y1: "19", x2: "20", y2: "19" })
|
|
6285
6991
|
] });
|
|
6286
6992
|
}
|
|
6287
6993
|
if (name === "submit_proposal") {
|
|
6288
|
-
return /* @__PURE__ */
|
|
6289
|
-
/* @__PURE__ */
|
|
6290
|
-
/* @__PURE__ */
|
|
6994
|
+
return /* @__PURE__ */ jsxs22("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
|
|
6995
|
+
/* @__PURE__ */ jsx25("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
|
|
6996
|
+
/* @__PURE__ */ jsx25("path", { d: "M14 2v6h6M9 15l2 2 4-4" })
|
|
6291
6997
|
] });
|
|
6292
6998
|
}
|
|
6293
6999
|
if (name === "schedule_followup") {
|
|
6294
|
-
return /* @__PURE__ */
|
|
6295
|
-
/* @__PURE__ */
|
|
6296
|
-
/* @__PURE__ */
|
|
7000
|
+
return /* @__PURE__ */ jsxs22("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", "aria-hidden": true, children: [
|
|
7001
|
+
/* @__PURE__ */ jsx25("circle", { cx: "12", cy: "12", r: "9" }),
|
|
7002
|
+
/* @__PURE__ */ jsx25("path", { d: "M12 7v5l3 3" })
|
|
6297
7003
|
] });
|
|
6298
7004
|
}
|
|
6299
|
-
return /* @__PURE__ */
|
|
6300
|
-
/* @__PURE__ */
|
|
6301
|
-
/* @__PURE__ */
|
|
7005
|
+
return /* @__PURE__ */ jsxs22("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
|
|
7006
|
+
/* @__PURE__ */ jsx25("path", { d: "M12 3v3m0 12v3M3 12h3m12 0h3" }),
|
|
7007
|
+
/* @__PURE__ */ jsx25("circle", { cx: "12", cy: "12", r: "4" })
|
|
6302
7008
|
] });
|
|
6303
7009
|
}
|
|
6304
7010
|
function toolOutcomeOf(call) {
|
|
@@ -6384,37 +7090,37 @@ function truncate(v, max = 240) {
|
|
|
6384
7090
|
function KvRows({ data }) {
|
|
6385
7091
|
const entries = Object.entries(data).filter(([, v]) => v !== void 0 && v !== null && v !== "");
|
|
6386
7092
|
if (!entries.length) return null;
|
|
6387
|
-
return /* @__PURE__ */
|
|
6388
|
-
/* @__PURE__ */
|
|
6389
|
-
/* @__PURE__ */
|
|
7093
|
+
return /* @__PURE__ */ jsx25("dl", { className: "grid grid-cols-[auto_1fr] gap-x-3 gap-y-1", children: entries.map(([k, v]) => /* @__PURE__ */ jsxs22("div", { className: "contents", children: [
|
|
7094
|
+
/* @__PURE__ */ jsx25("dt", { className: "font-mono text-xs text-muted-foreground", children: k }),
|
|
7095
|
+
/* @__PURE__ */ jsx25("dd", { className: "min-w-0 whitespace-pre-wrap break-words font-mono text-xs text-muted-foreground", children: truncate(v) })
|
|
6390
7096
|
] }, k)) });
|
|
6391
7097
|
}
|
|
6392
7098
|
function ShellDetail({ call }) {
|
|
6393
7099
|
const outcome = toolOutcomeOf(call);
|
|
6394
7100
|
const r = outcome?.result ?? {};
|
|
6395
|
-
return /* @__PURE__ */
|
|
6396
|
-
/* @__PURE__ */
|
|
6397
|
-
r.exitCode != null && /* @__PURE__ */
|
|
7101
|
+
return /* @__PURE__ */ jsxs22(TerminalDisplay, { showHeader: false, autoScroll: false, maxHeight: "14rem", className: "text-xs", children: [
|
|
7102
|
+
/* @__PURE__ */ jsx25(TerminalLine, { type: "command", children: String(call.args?.command ?? "") }),
|
|
7103
|
+
r.exitCode != null && /* @__PURE__ */ jsxs22(TerminalLine, { type: r.exitCode === 0 ? "success" : "error", children: [
|
|
6398
7104
|
"exit ",
|
|
6399
7105
|
r.exitCode
|
|
6400
7106
|
] }),
|
|
6401
|
-
/* @__PURE__ */
|
|
7107
|
+
/* @__PURE__ */ jsx25(TerminalLine, { type: outcome?.ok === false ? "error" : "output", children: outcome?.ok === false ? outcome.message ?? "failed" : [r.stdout, r.stderr].filter(Boolean).join("\n") || "(no output)" })
|
|
6402
7108
|
] });
|
|
6403
7109
|
}
|
|
6404
7110
|
function DefaultToolDetail({ call }) {
|
|
6405
7111
|
const result = call.result;
|
|
6406
7112
|
const envelope = typeof result === "object" && result !== null ? result : null;
|
|
6407
|
-
return /* @__PURE__ */
|
|
6408
|
-
call.args && Object.keys(call.args).length > 0 && /* @__PURE__ */
|
|
6409
|
-
/* @__PURE__ */
|
|
6410
|
-
/* @__PURE__ */
|
|
7113
|
+
return /* @__PURE__ */ jsxs22("div", { className: "space-y-2", children: [
|
|
7114
|
+
call.args && Object.keys(call.args).length > 0 && /* @__PURE__ */ jsxs22("div", { children: [
|
|
7115
|
+
/* @__PURE__ */ jsx25("p", { className: "mb-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: "Called with" }),
|
|
7116
|
+
/* @__PURE__ */ jsx25(KvRows, { data: call.args })
|
|
6411
7117
|
] }),
|
|
6412
|
-
envelope ? /* @__PURE__ */
|
|
6413
|
-
/* @__PURE__ */
|
|
6414
|
-
envelope.ok === false ? /* @__PURE__ */
|
|
6415
|
-
] }) : result != null ? /* @__PURE__ */
|
|
6416
|
-
/* @__PURE__ */
|
|
6417
|
-
/* @__PURE__ */
|
|
7118
|
+
envelope ? /* @__PURE__ */ jsxs22("div", { children: [
|
|
7119
|
+
/* @__PURE__ */ jsx25("p", { className: "mb-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: envelope.ok === false ? "Failed" : "Result" }),
|
|
7120
|
+
envelope.ok === false ? /* @__PURE__ */ jsx25("p", { className: "text-xs text-destructive", children: envelope.message ?? "Tool failed" }) : envelope.result && typeof envelope.result === "object" ? /* @__PURE__ */ jsx25(KvRows, { data: envelope.result }) : envelope.result != null ? /* @__PURE__ */ jsx25("p", { className: "font-mono text-xs text-muted-foreground", children: truncate(envelope.result) }) : null
|
|
7121
|
+
] }) : result != null ? /* @__PURE__ */ jsxs22("div", { children: [
|
|
7122
|
+
/* @__PURE__ */ jsx25("p", { className: "mb-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: "Result" }),
|
|
7123
|
+
/* @__PURE__ */ jsx25("p", { className: "font-mono text-xs text-muted-foreground", children: truncate(result) })
|
|
6418
7124
|
] }) : null
|
|
6419
7125
|
] });
|
|
6420
7126
|
}
|
|
@@ -6425,24 +7131,24 @@ function ProposalCard({
|
|
|
6425
7131
|
approval,
|
|
6426
7132
|
renderers
|
|
6427
7133
|
}) {
|
|
6428
|
-
const [expanded, setExpanded] =
|
|
7134
|
+
const [expanded, setExpanded] = useState25(false);
|
|
6429
7135
|
const { summary, meta, typeSlug } = proposalPreview(call);
|
|
6430
7136
|
const custom = renderers?.[call.name]?.(call, message);
|
|
6431
7137
|
const { pending: deciding, run: decide } = usePending();
|
|
6432
|
-
return /* @__PURE__ */
|
|
6433
|
-
/* @__PURE__ */
|
|
6434
|
-
/* @__PURE__ */
|
|
6435
|
-
/* @__PURE__ */
|
|
6436
|
-
/* @__PURE__ */
|
|
6437
|
-
/* @__PURE__ */
|
|
6438
|
-
summary && /* @__PURE__ */
|
|
6439
|
-
typeSlug && /* @__PURE__ */
|
|
6440
|
-
meta.length > 0 && /* @__PURE__ */
|
|
7138
|
+
return /* @__PURE__ */ jsxs22("div", { className: "w-full max-w-full rounded-xl border border-warning/50 bg-warning/[0.06] text-sm shadow-sm ring-1 ring-warning/10", children: [
|
|
7139
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex items-start gap-2.5 px-4 pt-3.5", children: [
|
|
7140
|
+
/* @__PURE__ */ jsx25("span", { className: "mt-0.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-warning/15 text-warning", children: /* @__PURE__ */ jsx25(ToolGlyph, { name: call.name, className: "h-3.5 w-3.5" }) }),
|
|
7141
|
+
/* @__PURE__ */ jsxs22("div", { className: "min-w-0 flex-1", children: [
|
|
7142
|
+
/* @__PURE__ */ jsx25("p", { className: "text-xs font-semibold uppercase tracking-[0.05em] text-warning-strong", children: approval ? "Needs your approval" : "Awaiting approval" }),
|
|
7143
|
+
/* @__PURE__ */ jsx25("p", { className: "mt-0.5 text-[15px] font-semibold leading-snug text-foreground", children: friendlyToolTitle(call) }),
|
|
7144
|
+
summary && /* @__PURE__ */ jsx25("p", { className: "mt-1 text-xs leading-relaxed text-muted-foreground", children: summary }),
|
|
7145
|
+
typeSlug && /* @__PURE__ */ jsx25("p", { className: "mt-1 font-mono text-xs text-muted-foreground", children: typeSlug }),
|
|
7146
|
+
meta.length > 0 && /* @__PURE__ */ jsx25("div", { className: "mt-1.5 flex flex-wrap items-center gap-1.5", children: meta.map((m, i) => /* @__PURE__ */ jsx25("span", { className: "rounded-full bg-secondary px-2 py-0.5 text-xs font-medium text-muted-foreground", children: m }, i)) })
|
|
6441
7147
|
] })
|
|
6442
7148
|
] }),
|
|
6443
|
-
/* @__PURE__ */
|
|
6444
|
-
approval && /* @__PURE__ */
|
|
6445
|
-
/* @__PURE__ */
|
|
7149
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex flex-wrap items-center gap-2 px-4 pb-3.5 pt-3", children: [
|
|
7150
|
+
approval && /* @__PURE__ */ jsxs22(Fragment9, { children: [
|
|
7151
|
+
/* @__PURE__ */ jsx25(
|
|
6446
7152
|
"button",
|
|
6447
7153
|
{
|
|
6448
7154
|
type: "button",
|
|
@@ -6452,7 +7158,7 @@ function ProposalCard({
|
|
|
6452
7158
|
children: "Approve & run"
|
|
6453
7159
|
}
|
|
6454
7160
|
),
|
|
6455
|
-
/* @__PURE__ */
|
|
7161
|
+
/* @__PURE__ */ jsx25(
|
|
6456
7162
|
"button",
|
|
6457
7163
|
{
|
|
6458
7164
|
type: "button",
|
|
@@ -6463,7 +7169,7 @@ function ProposalCard({
|
|
|
6463
7169
|
}
|
|
6464
7170
|
)
|
|
6465
7171
|
] }),
|
|
6466
|
-
/* @__PURE__ */
|
|
7172
|
+
/* @__PURE__ */ jsxs22(
|
|
6467
7173
|
"button",
|
|
6468
7174
|
{
|
|
6469
7175
|
type: "button",
|
|
@@ -6472,12 +7178,12 @@ function ProposalCard({
|
|
|
6472
7178
|
className: "ml-auto inline-flex items-center gap-1 rounded text-[12px] font-medium text-muted-foreground transition hover:text-foreground",
|
|
6473
7179
|
children: [
|
|
6474
7180
|
expanded ? "Hide details" : "View details",
|
|
6475
|
-
/* @__PURE__ */
|
|
7181
|
+
/* @__PURE__ */ jsx25(ChevronDown, { className: `h-3 w-3 transition-transform ${expanded ? "rotate-180" : ""}` })
|
|
6476
7182
|
]
|
|
6477
7183
|
}
|
|
6478
7184
|
)
|
|
6479
7185
|
] }),
|
|
6480
|
-
expanded && /* @__PURE__ */
|
|
7186
|
+
expanded && /* @__PURE__ */ jsx25("div", { className: "border-t border-warning/20 px-4 py-3 text-xs", children: custom ?? /* @__PURE__ */ jsx25(DefaultToolDetail, { call }) })
|
|
6481
7187
|
] });
|
|
6482
7188
|
}
|
|
6483
7189
|
function formatFollowupWhen(when) {
|
|
@@ -6492,14 +7198,14 @@ function FollowupCard({ call }) {
|
|
|
6492
7198
|
const when = typeof a.when === "string" ? a.when : typeof a.at === "string" ? a.at : typeof a.schedule === "string" ? a.schedule : null;
|
|
6493
7199
|
const failed = toolCallFailed(call);
|
|
6494
7200
|
const errorText = failed ? toolOutcomeOf(call)?.message ?? "Scheduling failed" : null;
|
|
6495
|
-
return /* @__PURE__ */
|
|
6496
|
-
/* @__PURE__ */
|
|
6497
|
-
/* @__PURE__ */
|
|
6498
|
-
/* @__PURE__ */
|
|
6499
|
-
when && /* @__PURE__ */
|
|
6500
|
-
/* @__PURE__ */
|
|
7201
|
+
return /* @__PURE__ */ jsx25("div", { className: "flex items-start gap-2", children: /* @__PURE__ */ jsxs22("div", { className: "min-w-0 flex-1 overflow-hidden rounded-[var(--radius-lg)] border border-[var(--border-subtle)] bg-[var(--md3-surface-container)]", children: [
|
|
7202
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex w-full items-center gap-2.5 px-3 py-2", children: [
|
|
7203
|
+
/* @__PURE__ */ jsx25("span", { className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-[var(--radius-sm)] border border-border bg-muted text-muted-foreground", children: /* @__PURE__ */ jsx25(ToolGlyph, { name: call.name, className: "h-3.5 w-3.5" }) }),
|
|
7204
|
+
/* @__PURE__ */ jsx25("span", { className: "shrink-0 whitespace-nowrap text-xs font-medium text-foreground", children: friendlyToolTitle(call) }),
|
|
7205
|
+
when && /* @__PURE__ */ jsx25("span", { title: when, className: "hidden min-w-0 flex-1 truncate font-mono text-xs tabular-nums text-muted-foreground sm:inline", children: formatFollowupWhen(when) }),
|
|
7206
|
+
/* @__PURE__ */ jsx25("span", { className: "ml-auto flex shrink-0 items-center gap-1.5", children: call.status === "running" ? /* @__PURE__ */ jsx25("svg", { className: "h-3 w-3 shrink-0 animate-spin text-[var(--accent-text)]", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", "aria-hidden": true, children: /* @__PURE__ */ jsx25("path", { d: "M21 12a9 9 0 1 1-6.219-8.56", strokeLinecap: "round" }) }) : /* @__PURE__ */ jsx25("span", { className: `h-1.5 w-1.5 shrink-0 rounded-full ${failed ? "bg-[var(--surface-danger-text)]" : "bg-[var(--surface-success-text)]"}` }) })
|
|
6501
7207
|
] }),
|
|
6502
|
-
errorText && /* @__PURE__ */
|
|
7208
|
+
errorText && /* @__PURE__ */ jsx25("div", { className: "border-t border-border px-3 py-2 text-xs text-[var(--surface-danger-text)]", children: errorText })
|
|
6503
7209
|
] }) });
|
|
6504
7210
|
}
|
|
6505
7211
|
function toolRowTitle(call) {
|
|
@@ -6522,10 +7228,10 @@ function ToolCallCard({
|
|
|
6522
7228
|
const arrival = useArrivalStyle(staggerIndex ?? 0);
|
|
6523
7229
|
const pending = call.status === "done" ? pendingApprovalOf(call) : null;
|
|
6524
7230
|
const kind = blockKindOf(call);
|
|
6525
|
-
const arrive = (row) => /* @__PURE__ */
|
|
7231
|
+
const arrive = (row) => /* @__PURE__ */ jsx25("div", { className: "agent-arrive", style: arrival, children: row });
|
|
6526
7232
|
if (pending) {
|
|
6527
7233
|
return arrive(
|
|
6528
|
-
/* @__PURE__ */
|
|
7234
|
+
/* @__PURE__ */ jsx25(
|
|
6529
7235
|
ProposalCard,
|
|
6530
7236
|
{
|
|
6531
7237
|
call,
|
|
@@ -6538,18 +7244,18 @@ function ToolCallCard({
|
|
|
6538
7244
|
);
|
|
6539
7245
|
}
|
|
6540
7246
|
if (kind === "followup") {
|
|
6541
|
-
return arrive(/* @__PURE__ */
|
|
7247
|
+
return arrive(/* @__PURE__ */ jsx25(FollowupCard, { call }));
|
|
6542
7248
|
}
|
|
6543
7249
|
const custom = renderers?.[call.name]?.(call, message);
|
|
6544
7250
|
return arrive(
|
|
6545
|
-
/* @__PURE__ */
|
|
7251
|
+
/* @__PURE__ */ jsx25(
|
|
6546
7252
|
InlineToolItem,
|
|
6547
7253
|
{
|
|
6548
7254
|
part: chatToolCallPart(call),
|
|
6549
7255
|
title: toolRowTitle(call),
|
|
6550
7256
|
description: toolRowDescription(call),
|
|
6551
|
-
renderToolDetail: () => custom ?? (call.name === "sandbox_run_command" ? /* @__PURE__ */
|
|
6552
|
-
actions: onOpenRun && call.name.startsWith("sandbox_") ? /* @__PURE__ */
|
|
7257
|
+
renderToolDetail: () => custom ?? (call.name === "sandbox_run_command" ? /* @__PURE__ */ jsx25(ShellDetail, { call }) : /* @__PURE__ */ jsx25(DefaultToolDetail, { call })),
|
|
7258
|
+
actions: onOpenRun && call.name.startsWith("sandbox_") ? /* @__PURE__ */ jsx25(
|
|
6553
7259
|
"button",
|
|
6554
7260
|
{
|
|
6555
7261
|
type: "button",
|
|
@@ -6557,9 +7263,9 @@ function ToolCallCard({
|
|
|
6557
7263
|
"aria-label": "Open full transcript",
|
|
6558
7264
|
title: "Open full transcript",
|
|
6559
7265
|
className: "rounded-md p-1.5 text-muted-foreground transition hover:bg-accent hover:text-foreground",
|
|
6560
|
-
children: /* @__PURE__ */
|
|
6561
|
-
/* @__PURE__ */
|
|
6562
|
-
/* @__PURE__ */
|
|
7266
|
+
children: /* @__PURE__ */ jsxs22("svg", { className: "h-3.5 w-3.5", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
|
|
7267
|
+
/* @__PURE__ */ jsx25("path", { d: "M7 17 17 7" }),
|
|
7268
|
+
/* @__PURE__ */ jsx25("path", { d: "M7 7h10v10" })
|
|
6563
7269
|
] })
|
|
6564
7270
|
}
|
|
6565
7271
|
) : void 0
|
|
@@ -6568,7 +7274,7 @@ function ToolCallCard({
|
|
|
6568
7274
|
);
|
|
6569
7275
|
}
|
|
6570
7276
|
function StreamingCaret() {
|
|
6571
|
-
return /* @__PURE__ */
|
|
7277
|
+
return /* @__PURE__ */ jsx25(
|
|
6572
7278
|
"span",
|
|
6573
7279
|
{
|
|
6574
7280
|
className: "ml-0.5 inline-block h-[1.1em] w-[3px] translate-y-[2px] animate-[agent-caret_1s_step-end_infinite] rounded-sm bg-foreground/70",
|
|
@@ -6585,7 +7291,7 @@ function SegmentText({
|
|
|
6585
7291
|
messageClassName
|
|
6586
7292
|
}) {
|
|
6587
7293
|
const text = useSmoothText(content, streaming);
|
|
6588
|
-
const body =
|
|
7294
|
+
const body = useMemo9(() => renderBody(text), [renderBody, text]);
|
|
6589
7295
|
if (!content.trim() && !showCaret) return null;
|
|
6590
7296
|
return (
|
|
6591
7297
|
// A settled run arrives from a short blur; the LIVE run does not, because
|
|
@@ -6593,9 +7299,9 @@ function SegmentText({
|
|
|
6593
7299
|
// the container on top of that makes the paragraph shimmer while it types.
|
|
6594
7300
|
// The distinction is what separates "the answer materialised" from "the
|
|
6595
7301
|
// log was appended to".
|
|
6596
|
-
/* @__PURE__ */
|
|
7302
|
+
/* @__PURE__ */ jsxs22("div", { className: `${messageClassName}${streaming ? "" : " agent-stream-in"}`, children: [
|
|
6597
7303
|
body,
|
|
6598
|
-
showCaret && /* @__PURE__ */
|
|
7304
|
+
showCaret && /* @__PURE__ */ jsx25(StreamingCaret, {})
|
|
6599
7305
|
] })
|
|
6600
7306
|
);
|
|
6601
7307
|
}
|
|
@@ -6620,7 +7326,7 @@ function SegmentedBody({
|
|
|
6620
7326
|
const leftoverToolCalls = (msg.toolCalls ?? []).filter(
|
|
6621
7327
|
(tc) => !segmentToolIds.has(tc.id)
|
|
6622
7328
|
);
|
|
6623
|
-
const renderToolCard = (call, index) => /* @__PURE__ */
|
|
7329
|
+
const renderToolCard = (call, index) => /* @__PURE__ */ jsx25(
|
|
6624
7330
|
ToolCallCard,
|
|
6625
7331
|
{
|
|
6626
7332
|
call,
|
|
@@ -6649,12 +7355,12 @@ function SegmentedBody({
|
|
|
6649
7355
|
const children = [];
|
|
6650
7356
|
for (const g of groups) {
|
|
6651
7357
|
if (g.kind === "notice") {
|
|
6652
|
-
children.push(/* @__PURE__ */
|
|
7358
|
+
children.push(/* @__PURE__ */ jsx25(SegmentNotice, { tone: g.tone, content: g.content }, `notice-${g.index}`));
|
|
6653
7359
|
continue;
|
|
6654
7360
|
}
|
|
6655
7361
|
if (g.kind === "text") {
|
|
6656
7362
|
children.push(
|
|
6657
|
-
/* @__PURE__ */
|
|
7363
|
+
/* @__PURE__ */ jsx25(
|
|
6658
7364
|
SegmentText,
|
|
6659
7365
|
{
|
|
6660
7366
|
content: g.content,
|
|
@@ -6670,13 +7376,13 @@ function SegmentedBody({
|
|
|
6670
7376
|
}
|
|
6671
7377
|
if (!streaming && g.calls.length >= COLLAPSE_TOOL_RUN_AT && !g.calls.some(isImportantTool)) {
|
|
6672
7378
|
children.push(
|
|
6673
|
-
/* @__PURE__ */
|
|
6674
|
-
/* @__PURE__ */
|
|
7379
|
+
/* @__PURE__ */ jsxs22("details", { children: [
|
|
7380
|
+
/* @__PURE__ */ jsxs22("summary", { className: "cursor-pointer select-none rounded-md py-0.5 text-xs font-medium text-muted-foreground [transition:color_var(--motion-control)] hover:text-foreground", children: [
|
|
6675
7381
|
"Worked through ",
|
|
6676
7382
|
g.calls.length,
|
|
6677
7383
|
" steps"
|
|
6678
7384
|
] }),
|
|
6679
|
-
/* @__PURE__ */
|
|
7385
|
+
/* @__PURE__ */ jsx25("div", { className: "mt-1.5 flex flex-col gap-1.5", children: g.calls.map(renderToolCard) })
|
|
6680
7386
|
] }, `tools-fold-${g.index}`)
|
|
6681
7387
|
);
|
|
6682
7388
|
continue;
|
|
@@ -6685,9 +7391,9 @@ function SegmentedBody({
|
|
|
6685
7391
|
}
|
|
6686
7392
|
leftoverToolCalls.forEach((call, index) => children.push(renderToolCard(call, index)));
|
|
6687
7393
|
if (streaming && segments[lastIndex]?.kind === "tool") {
|
|
6688
|
-
children.push(/* @__PURE__ */
|
|
7394
|
+
children.push(/* @__PURE__ */ jsx25(StreamingCaret, {}, "streaming-caret"));
|
|
6689
7395
|
}
|
|
6690
|
-
return /* @__PURE__ */
|
|
7396
|
+
return /* @__PURE__ */ jsx25("div", { className: "flex flex-col gap-2", children });
|
|
6691
7397
|
}
|
|
6692
7398
|
var QUIET_META_LANE_CLASS = "mt-1 flex h-[18px] items-center gap-2 text-xs tabular-nums text-muted-foreground opacity-0 transition-opacity duration-150 group-hover:opacity-100 group-focus-within:opacity-100 motion-reduce:transition-none [@media(hover:none)]:opacity-100";
|
|
6693
7399
|
function copyTextOf(msg) {
|
|
@@ -6696,9 +7402,9 @@ function copyTextOf(msg) {
|
|
|
6696
7402
|
return msg.content;
|
|
6697
7403
|
}
|
|
6698
7404
|
function CopyMessageButton({ text }) {
|
|
6699
|
-
const [copied, setCopied] =
|
|
6700
|
-
const timerRef =
|
|
6701
|
-
|
|
7405
|
+
const [copied, setCopied] = useState25(false);
|
|
7406
|
+
const timerRef = useRef17(null);
|
|
7407
|
+
useEffect17(
|
|
6702
7408
|
() => () => {
|
|
6703
7409
|
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
6704
7410
|
},
|
|
@@ -6717,7 +7423,7 @@ function CopyMessageButton({ text }) {
|
|
|
6717
7423
|
}
|
|
6718
7424
|
);
|
|
6719
7425
|
};
|
|
6720
|
-
return /* @__PURE__ */
|
|
7426
|
+
return /* @__PURE__ */ jsx25(
|
|
6721
7427
|
"button",
|
|
6722
7428
|
{
|
|
6723
7429
|
type: "button",
|
|
@@ -6725,9 +7431,9 @@ function CopyMessageButton({ text }) {
|
|
|
6725
7431
|
"aria-label": "Copy message",
|
|
6726
7432
|
title: "Copy message",
|
|
6727
7433
|
className: "rounded p-0.5 text-muted-foreground transition hover:bg-accent hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
6728
|
-
children: copied ? /* @__PURE__ */
|
|
6729
|
-
/* @__PURE__ */
|
|
6730
|
-
/* @__PURE__ */
|
|
7434
|
+
children: copied ? /* @__PURE__ */ jsx25("svg", { className: "h-3.5 w-3.5", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx25("polyline", { points: "20 6 9 17 4 12" }) }) : /* @__PURE__ */ jsxs22("svg", { className: "h-3.5 w-3.5", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
|
|
7435
|
+
/* @__PURE__ */ jsx25("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2" }),
|
|
7436
|
+
/* @__PURE__ */ jsx25("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
|
|
6731
7437
|
] })
|
|
6732
7438
|
}
|
|
6733
7439
|
);
|
|
@@ -6749,25 +7455,25 @@ function AssistantMessageImpl({
|
|
|
6749
7455
|
chrome
|
|
6750
7456
|
}) {
|
|
6751
7457
|
const content = useSmoothText(msg.content, streaming);
|
|
6752
|
-
const body =
|
|
7458
|
+
const body = useMemo9(() => renderBody(content), [renderBody, content]);
|
|
6753
7459
|
const segments = msg.segments;
|
|
6754
7460
|
const hasAnswerText = content !== "" || (segments?.some((s) => (s.kind === "text" || s.kind === "notice") && s.content.trim() !== "") ?? false);
|
|
6755
7461
|
const quiet = chrome === "quiet";
|
|
6756
|
-
return /* @__PURE__ */
|
|
6757
|
-
quiet && msg.author && /* @__PURE__ */
|
|
6758
|
-
!quiet && /* @__PURE__ */
|
|
7462
|
+
return /* @__PURE__ */ jsxs22("div", { className: `mx-auto w-full max-w-3xl px-6 ${quiet ? "group pb-1 pt-3" : "py-3"}`, children: [
|
|
7463
|
+
quiet && msg.author && /* @__PURE__ */ jsx25(MessageAuthor, { author: msg.author, className: "mb-1.5" }),
|
|
7464
|
+
!quiet && /* @__PURE__ */ jsxs22(
|
|
6759
7465
|
"div",
|
|
6760
7466
|
{
|
|
6761
7467
|
className: `mb-1 flex ${msg.author ? "items-center" : "items-baseline"} gap-2 text-xs tabular-nums text-muted-foreground`,
|
|
6762
7468
|
children: [
|
|
6763
|
-
msg.author ? /* @__PURE__ */
|
|
6764
|
-
msg.modelUsed && /* @__PURE__ */
|
|
6765
|
-
formatTokensPerSecond(msg) && /* @__PURE__ */
|
|
6766
|
-
formatModelCost(msg, models) && /* @__PURE__ */
|
|
7469
|
+
msg.author ? /* @__PURE__ */ jsx25(MessageAuthor, { author: msg.author }) : /* @__PURE__ */ jsx25("span", { className: "font-semibold uppercase tracking-[0.05em]", children: agentLabel }),
|
|
7470
|
+
msg.modelUsed && /* @__PURE__ */ jsx25("span", { className: "font-mono normal-case", children: msg.modelUsed }),
|
|
7471
|
+
formatTokensPerSecond(msg) && /* @__PURE__ */ jsx25("span", { children: formatTokensPerSecond(msg) }),
|
|
7472
|
+
formatModelCost(msg, models) && /* @__PURE__ */ jsx25("span", { children: formatModelCost(msg, models) })
|
|
6767
7473
|
]
|
|
6768
7474
|
}
|
|
6769
7475
|
),
|
|
6770
|
-
/* @__PURE__ */
|
|
7476
|
+
/* @__PURE__ */ jsx25(
|
|
6771
7477
|
ReasoningRow,
|
|
6772
7478
|
{
|
|
6773
7479
|
className: "mb-2",
|
|
@@ -6777,7 +7483,7 @@ function AssistantMessageImpl({
|
|
|
6777
7483
|
thinking: streaming && !hasAnswerText && msg.reasoningEndedAt === void 0
|
|
6778
7484
|
}
|
|
6779
7485
|
),
|
|
6780
|
-
segments && segments.length > 0 ? /* @__PURE__ */
|
|
7486
|
+
segments && segments.length > 0 ? /* @__PURE__ */ jsx25(
|
|
6781
7487
|
SegmentedBody,
|
|
6782
7488
|
{
|
|
6783
7489
|
segments,
|
|
@@ -6789,12 +7495,12 @@ function AssistantMessageImpl({
|
|
|
6789
7495
|
toolRenderers,
|
|
6790
7496
|
messageClassName
|
|
6791
7497
|
}
|
|
6792
|
-
) : /* @__PURE__ */
|
|
6793
|
-
/* @__PURE__ */
|
|
7498
|
+
) : /* @__PURE__ */ jsxs22(Fragment9, { children: [
|
|
7499
|
+
/* @__PURE__ */ jsxs22("div", { className: messageClassName, children: [
|
|
6794
7500
|
body,
|
|
6795
|
-
streaming && content && !msg.toolCalls?.length && /* @__PURE__ */
|
|
7501
|
+
streaming && content && !msg.toolCalls?.length && /* @__PURE__ */ jsx25(StreamingCaret, {})
|
|
6796
7502
|
] }),
|
|
6797
|
-
msg.toolCalls && msg.toolCalls.length > 0 && /* @__PURE__ */
|
|
7503
|
+
msg.toolCalls && msg.toolCalls.length > 0 && /* @__PURE__ */ jsx25("div", { className: "mt-2 flex flex-col gap-1.5", children: msg.toolCalls.map((tc, index) => /* @__PURE__ */ jsx25(
|
|
6798
7504
|
ToolCallCard,
|
|
6799
7505
|
{
|
|
6800
7506
|
call: tc,
|
|
@@ -6807,7 +7513,7 @@ function AssistantMessageImpl({
|
|
|
6807
7513
|
tc.id
|
|
6808
7514
|
)) })
|
|
6809
7515
|
] }),
|
|
6810
|
-
durableCards && msg.parts && /* @__PURE__ */
|
|
7516
|
+
durableCards && msg.parts && /* @__PURE__ */ jsx25(
|
|
6811
7517
|
DurableChatCards,
|
|
6812
7518
|
{
|
|
6813
7519
|
...durableCards,
|
|
@@ -6816,7 +7522,7 @@ function AssistantMessageImpl({
|
|
|
6816
7522
|
className: "mt-3"
|
|
6817
7523
|
}
|
|
6818
7524
|
),
|
|
6819
|
-
workProductCards && workProductPartsFromMessageParts(msg.parts).map((part) => /* @__PURE__ */
|
|
7525
|
+
workProductCards && workProductPartsFromMessageParts(msg.parts).map((part) => /* @__PURE__ */ jsx25(
|
|
6820
7526
|
WorkProductCard,
|
|
6821
7527
|
{
|
|
6822
7528
|
part,
|
|
@@ -6826,7 +7532,7 @@ function AssistantMessageImpl({
|
|
|
6826
7532
|
`${part.ref.id}:${part.ref.version}`
|
|
6827
7533
|
)),
|
|
6828
7534
|
renderExtras?.(msg),
|
|
6829
|
-
resolveAttachmentUrl && attachmentPartsFromMessageParts(msg.parts).length > 0 && /* @__PURE__ */
|
|
7535
|
+
resolveAttachmentUrl && attachmentPartsFromMessageParts(msg.parts).length > 0 && /* @__PURE__ */ jsx25("div", { className: "mt-2", children: /* @__PURE__ */ jsx25(
|
|
6830
7536
|
MessageAttachments,
|
|
6831
7537
|
{
|
|
6832
7538
|
parts: attachmentPartsFromMessageParts(msg.parts),
|
|
@@ -6834,18 +7540,18 @@ function AssistantMessageImpl({
|
|
|
6834
7540
|
justify: "start"
|
|
6835
7541
|
}
|
|
6836
7542
|
) }),
|
|
6837
|
-
quiet && /* @__PURE__ */
|
|
6838
|
-
/* @__PURE__ */
|
|
6839
|
-
msg.modelUsed && /* @__PURE__ */
|
|
6840
|
-
formatTokensPerSecond(msg) && /* @__PURE__ */
|
|
6841
|
-
formatModelCost(msg, models) && /* @__PURE__ */
|
|
7543
|
+
quiet && /* @__PURE__ */ jsxs22("div", { "data-testid": "message-meta-lane", className: QUIET_META_LANE_CLASS, children: [
|
|
7544
|
+
/* @__PURE__ */ jsx25(CopyMessageButton, { text: copyTextOf(msg) }),
|
|
7545
|
+
msg.modelUsed && /* @__PURE__ */ jsx25("span", { className: "font-mono", children: msg.modelUsed }),
|
|
7546
|
+
formatTokensPerSecond(msg) && /* @__PURE__ */ jsx25("span", { children: formatTokensPerSecond(msg) }),
|
|
7547
|
+
formatModelCost(msg, models) && /* @__PURE__ */ jsx25("span", { children: formatModelCost(msg, models) })
|
|
6842
7548
|
] })
|
|
6843
7549
|
] });
|
|
6844
7550
|
}
|
|
6845
7551
|
var AssistantMessage = memo(AssistantMessageImpl);
|
|
6846
7552
|
function useThinkingSeconds(active) {
|
|
6847
|
-
const [seconds, setSeconds] =
|
|
6848
|
-
|
|
7553
|
+
const [seconds, setSeconds] = useState25(0);
|
|
7554
|
+
useEffect17(() => {
|
|
6849
7555
|
if (!active) return;
|
|
6850
7556
|
setSeconds(0);
|
|
6851
7557
|
const id = setInterval(() => setSeconds((s) => s + 1), 1e3);
|
|
@@ -6854,9 +7560,9 @@ function useThinkingSeconds(active) {
|
|
|
6854
7560
|
return seconds;
|
|
6855
7561
|
}
|
|
6856
7562
|
function ThinkingRow({ agentLabel, chrome = "labeled", phase }) {
|
|
6857
|
-
return /* @__PURE__ */
|
|
6858
|
-
chrome !== "quiet" && /* @__PURE__ */
|
|
6859
|
-
/* @__PURE__ */
|
|
7563
|
+
return /* @__PURE__ */ jsxs22("div", { className: "mx-auto w-full max-w-3xl px-6 py-3", children: [
|
|
7564
|
+
chrome !== "quiet" && /* @__PURE__ */ jsx25("p", { className: "mb-1 text-xs font-semibold uppercase tracking-[0.05em] text-muted-foreground", children: agentLabel }),
|
|
7565
|
+
/* @__PURE__ */ jsx25(TurnProgress, { phase, pendingMessage: "Thinking\u2026", className: "text-[15px]" })
|
|
6860
7566
|
] });
|
|
6861
7567
|
}
|
|
6862
7568
|
var NOTICE_TONE_CLASS = {
|
|
@@ -6864,29 +7570,29 @@ var NOTICE_TONE_CLASS = {
|
|
|
6864
7570
|
warning: "border-warning/40 bg-warning/10 text-warning-strong"
|
|
6865
7571
|
};
|
|
6866
7572
|
function SegmentNotice({ tone, content }) {
|
|
6867
|
-
return /* @__PURE__ */
|
|
7573
|
+
return /* @__PURE__ */ jsxs22(
|
|
6868
7574
|
"div",
|
|
6869
7575
|
{
|
|
6870
7576
|
"data-notice-tone": tone,
|
|
6871
7577
|
className: `flex items-start gap-2.5 rounded-lg border px-3 py-2.5 text-sm ${NOTICE_TONE_CLASS[tone]}`,
|
|
6872
7578
|
children: [
|
|
6873
|
-
/* @__PURE__ */
|
|
6874
|
-
/* @__PURE__ */
|
|
6875
|
-
/* @__PURE__ */
|
|
7579
|
+
/* @__PURE__ */ jsxs22("svg", { className: "mt-0.5 h-4 w-4 shrink-0", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
|
|
7580
|
+
/* @__PURE__ */ jsx25("circle", { cx: "12", cy: "12", r: "9" }),
|
|
7581
|
+
/* @__PURE__ */ jsx25("path", { d: "M12 8v4m0 4h.01" })
|
|
6876
7582
|
] }),
|
|
6877
|
-
/* @__PURE__ */
|
|
7583
|
+
/* @__PURE__ */ jsx25("span", { className: "min-w-0 flex-1 whitespace-pre-wrap break-words", children: content })
|
|
6878
7584
|
]
|
|
6879
7585
|
}
|
|
6880
7586
|
);
|
|
6881
7587
|
}
|
|
6882
7588
|
function StreamErrorRow({ message, onRetry }) {
|
|
6883
|
-
return /* @__PURE__ */
|
|
6884
|
-
/* @__PURE__ */
|
|
6885
|
-
/* @__PURE__ */
|
|
6886
|
-
/* @__PURE__ */
|
|
7589
|
+
return /* @__PURE__ */ jsx25("div", { className: "mx-auto w-full max-w-3xl px-6 py-3", children: /* @__PURE__ */ jsxs22("div", { role: "alert", className: "flex items-start gap-2.5 rounded-lg border border-destructive/40 bg-destructive/5 px-3 py-2.5 text-sm text-destructive", children: [
|
|
7590
|
+
/* @__PURE__ */ jsxs22("svg", { className: "mt-0.5 h-4 w-4 shrink-0", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
|
|
7591
|
+
/* @__PURE__ */ jsx25("circle", { cx: "12", cy: "12", r: "9" }),
|
|
7592
|
+
/* @__PURE__ */ jsx25("path", { d: "M12 8v4m0 4h.01" })
|
|
6887
7593
|
] }),
|
|
6888
|
-
/* @__PURE__ */
|
|
6889
|
-
onRetry && /* @__PURE__ */
|
|
7594
|
+
/* @__PURE__ */ jsx25("span", { className: "min-w-0 flex-1 break-words", children: message }),
|
|
7595
|
+
onRetry && /* @__PURE__ */ jsx25(
|
|
6890
7596
|
"button",
|
|
6891
7597
|
{
|
|
6892
7598
|
type: "button",
|
|
@@ -6905,19 +7611,19 @@ function OtherPersonMessage({
|
|
|
6905
7611
|
resolveAttachmentUrl
|
|
6906
7612
|
}) {
|
|
6907
7613
|
const attachments = resolveAttachmentUrl ? attachmentPartsFromMessageParts(msg.parts) : [];
|
|
6908
|
-
return /* @__PURE__ */
|
|
6909
|
-
/* @__PURE__ */
|
|
6910
|
-
/* @__PURE__ */
|
|
6911
|
-
/* @__PURE__ */
|
|
7614
|
+
return /* @__PURE__ */ jsxs22("div", { className: `mx-auto w-full max-w-3xl px-6 ${quiet ? "group pb-1 pt-3" : "py-3"}`, children: [
|
|
7615
|
+
/* @__PURE__ */ jsxs22("div", { className: `w-fit ${quiet ? "max-w-[72%]" : "max-w-[85%]"}`, children: [
|
|
7616
|
+
/* @__PURE__ */ jsx25(MessageAuthor, { author, className: "mb-1.5" }),
|
|
7617
|
+
/* @__PURE__ */ jsx25(
|
|
6912
7618
|
"div",
|
|
6913
7619
|
{
|
|
6914
7620
|
className: `w-fit max-w-full rounded-2xl border border-[hsl(var(--border))] bg-[hsl(var(--card))] px-4 py-2.5 text-[hsl(var(--foreground))] ${quiet ? "" : "rounded-tl-md "}${messageClassName}`,
|
|
6915
|
-
children: /* @__PURE__ */
|
|
7621
|
+
children: /* @__PURE__ */ jsx25("p", { className: "whitespace-pre-wrap", children: msg.content })
|
|
6916
7622
|
}
|
|
6917
7623
|
),
|
|
6918
|
-
resolveAttachmentUrl && attachments.length > 0 && /* @__PURE__ */
|
|
7624
|
+
resolveAttachmentUrl && attachments.length > 0 && /* @__PURE__ */ jsx25("div", { className: "mt-1.5", children: /* @__PURE__ */ jsx25(MessageAttachments, { parts: attachments, resolveFileUrl: resolveAttachmentUrl, justify: "start" }) })
|
|
6919
7625
|
] }),
|
|
6920
|
-
quiet && /* @__PURE__ */
|
|
7626
|
+
quiet && /* @__PURE__ */ jsx25("div", { "data-testid": "message-meta-lane", className: `${QUIET_META_LANE_CLASS} justify-start`, children: /* @__PURE__ */ jsx25(CopyMessageButton, { text: msg.content }) })
|
|
6921
7627
|
] });
|
|
6922
7628
|
}
|
|
6923
7629
|
function ChatMessages({
|
|
@@ -6946,23 +7652,23 @@ function ChatMessages({
|
|
|
6946
7652
|
}) {
|
|
6947
7653
|
const messageClassName = messageSize === "large" ? `agent-app-message-copy ${TRANSCRIPT_TEXT} [--transcript-font-size:1.0625rem]` : `agent-app-message-copy ${TRANSCRIPT_TEXT}`;
|
|
6948
7654
|
const assistantMessageClassName = `${messageClassName} bg-transparent text-[hsl(var(--foreground))]`;
|
|
6949
|
-
const renderBody =
|
|
6950
|
-
() => renderMarkdown ?? ((content) => /* @__PURE__ */
|
|
7655
|
+
const renderBody = useMemo9(
|
|
7656
|
+
() => renderMarkdown ?? ((content) => /* @__PURE__ */ jsx25("p", { className: "whitespace-pre-wrap", children: content })),
|
|
6951
7657
|
[renderMarkdown]
|
|
6952
7658
|
);
|
|
6953
7659
|
const lastIsUser = messages[messages.length - 1]?.role === "user";
|
|
6954
7660
|
const quiet = chrome === "quiet";
|
|
6955
7661
|
if (messages.length === 0 && !loading && !error) {
|
|
6956
|
-
const empty = renderEmpty ? renderEmpty() : /* @__PURE__ */
|
|
6957
|
-
return /* @__PURE__ */
|
|
7662
|
+
const empty = renderEmpty ? renderEmpty() : /* @__PURE__ */ jsx25(ChatEmptyState, { ...emptyState });
|
|
7663
|
+
return /* @__PURE__ */ jsxs22(Fragment9, { children: [
|
|
6958
7664
|
header,
|
|
6959
7665
|
empty
|
|
6960
7666
|
] });
|
|
6961
7667
|
}
|
|
6962
|
-
return /* @__PURE__ */
|
|
7668
|
+
return /* @__PURE__ */ jsxs22(Fragment9, { children: [
|
|
6963
7669
|
header,
|
|
6964
7670
|
messages.map(
|
|
6965
|
-
(msg) => msg.role === "user" && msg.author && !isViewerMessage(msg.author, viewerId) ? /* @__PURE__ */
|
|
7671
|
+
(msg) => msg.role === "user" && msg.author && !isViewerMessage(msg.author, viewerId) ? /* @__PURE__ */ jsx25(
|
|
6966
7672
|
OtherPersonMessage,
|
|
6967
7673
|
{
|
|
6968
7674
|
msg,
|
|
@@ -6972,17 +7678,17 @@ function ChatMessages({
|
|
|
6972
7678
|
resolveAttachmentUrl
|
|
6973
7679
|
},
|
|
6974
7680
|
msg.id
|
|
6975
|
-
) : msg.role === "user" ? /* @__PURE__ */
|
|
6976
|
-
/* @__PURE__ */
|
|
6977
|
-
!quiet && /* @__PURE__ */
|
|
6978
|
-
/* @__PURE__ */
|
|
7681
|
+
) : msg.role === "user" ? /* @__PURE__ */ jsxs22("div", { className: `mx-auto w-full max-w-3xl px-6 ${quiet ? "group pb-1 pt-3" : "py-3"}`, children: [
|
|
7682
|
+
/* @__PURE__ */ jsxs22("div", { className: `ml-auto w-fit ${quiet ? "max-w-[72%]" : "max-w-[85%]"}`, children: [
|
|
7683
|
+
!quiet && /* @__PURE__ */ jsx25("p", { className: "mb-1 text-right text-xs font-semibold uppercase tracking-[0.05em] text-muted-foreground", children: userLabel }),
|
|
7684
|
+
/* @__PURE__ */ jsx25(
|
|
6979
7685
|
"div",
|
|
6980
7686
|
{
|
|
6981
7687
|
className: `rounded-2xl bg-[hsl(var(--foreground))] px-4 py-2.5 text-[hsl(var(--background))] ${quiet ? "" : "rounded-tr-md "}${messageClassName}`,
|
|
6982
|
-
children: /* @__PURE__ */
|
|
7688
|
+
children: /* @__PURE__ */ jsx25("p", { className: "whitespace-pre-wrap", children: msg.content })
|
|
6983
7689
|
}
|
|
6984
7690
|
),
|
|
6985
|
-
resolveAttachmentUrl && attachmentPartsFromMessageParts(msg.parts).length > 0 && /* @__PURE__ */
|
|
7691
|
+
resolveAttachmentUrl && attachmentPartsFromMessageParts(msg.parts).length > 0 && /* @__PURE__ */ jsx25("div", { className: "mt-1.5", children: /* @__PURE__ */ jsx25(
|
|
6986
7692
|
MessageAttachments,
|
|
6987
7693
|
{
|
|
6988
7694
|
parts: attachmentPartsFromMessageParts(msg.parts),
|
|
@@ -6991,8 +7697,8 @@ function ChatMessages({
|
|
|
6991
7697
|
}
|
|
6992
7698
|
) })
|
|
6993
7699
|
] }),
|
|
6994
|
-
quiet && /* @__PURE__ */
|
|
6995
|
-
] }, msg.id) : /* @__PURE__ */
|
|
7700
|
+
quiet && /* @__PURE__ */ jsx25("div", { "data-testid": "message-meta-lane", className: `${QUIET_META_LANE_CLASS} justify-end`, children: /* @__PURE__ */ jsx25(CopyMessageButton, { text: msg.content }) })
|
|
7701
|
+
] }, msg.id) : /* @__PURE__ */ jsx25(
|
|
6996
7702
|
AssistantMessage,
|
|
6997
7703
|
{
|
|
6998
7704
|
msg,
|
|
@@ -7013,8 +7719,8 @@ function ChatMessages({
|
|
|
7013
7719
|
msg.id
|
|
7014
7720
|
)
|
|
7015
7721
|
),
|
|
7016
|
-
loading && lastIsUser && /* @__PURE__ */
|
|
7017
|
-
error && !loading && /* @__PURE__ */
|
|
7722
|
+
loading && lastIsUser && /* @__PURE__ */ jsx25(ThinkingRow, { agentLabel, chrome, phase: turnPhase }),
|
|
7723
|
+
error && !loading && /* @__PURE__ */ jsx25(StreamErrorRow, { message: error, onRetry })
|
|
7018
7724
|
] });
|
|
7019
7725
|
}
|
|
7020
7726
|
|
|
@@ -7103,6 +7809,10 @@ export {
|
|
|
7103
7809
|
ProvenanceValue,
|
|
7104
7810
|
ProvenanceLegend,
|
|
7105
7811
|
SeatPaywall,
|
|
7812
|
+
useSessionHistory,
|
|
7813
|
+
useSessionActions,
|
|
7814
|
+
formatSessionTimestamp,
|
|
7815
|
+
SessionHistoryPanel,
|
|
7106
7816
|
recordGridOk,
|
|
7107
7817
|
recordGridFail,
|
|
7108
7818
|
isRecordGridCellApplicable,
|
|
@@ -7162,4 +7872,4 @@ export {
|
|
|
7162
7872
|
useThinkingSeconds,
|
|
7163
7873
|
ChatMessages
|
|
7164
7874
|
};
|
|
7165
|
-
//# sourceMappingURL=chunk-
|
|
7875
|
+
//# sourceMappingURL=chunk-JYIMW5U5.js.map
|