@arbidocs/react 0.3.119 → 0.3.120
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/chunk-VTX77MYP.js +1338 -0
- package/dist/chunk-VTX77MYP.js.map +1 -0
- package/dist/chunk-ZBZKHBDS.cjs +1486 -0
- package/dist/chunk-ZBZKHBDS.cjs.map +1 -0
- package/dist/index.cjs +2571 -2878
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +177 -365
- package/dist/index.d.ts +177 -365
- package/dist/index.js +1768 -2362
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +432 -0
- package/dist/ui/index.cjs.map +1 -0
- package/dist/ui/index.d.cts +387 -0
- package/dist/ui/index.d.ts +387 -0
- package/dist/ui/index.js +3 -0
- package/dist/ui/index.js.map +1 -0
- package/package.json +8 -3
package/dist/index.js
CHANGED
|
@@ -1,48 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { cn, Avatar, AvatarFallback, AvatarImage, Tooltip, TooltipTrigger, TooltipContent, Popover, PopoverTrigger, PopoverContent, AiMarkdown, Card, Button, Badge, MarkdownRenderer, Input, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, ScrollArea, Textarea, Slider, Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuItem, Checkbox } from './chunk-VTX77MYP.js';
|
|
2
|
+
export { AiMarkdown, Avatar, AvatarFallback, AvatarImage, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, HoverCard, HoverCardContent, HoverCardTrigger, Input, Label, MarkdownRenderer, MarkdownStreamingContext, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Slider, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonVariants, cardVariants, cn, markdownBaseComponents, splitMarkdownBlocks, toggleVariants } from './chunk-VTX77MYP.js';
|
|
3
|
+
import React2, { createContext, memo, useState, forwardRef, useMemo, useCallback, useId, useRef, useContext, useEffect } from 'react';
|
|
3
4
|
import { Arbi, connectWithReconnect, resolveCitations, summarizeCitations } from '@arbidocs/sdk/browser';
|
|
4
5
|
export { Arbi, ArbiError } from '@arbidocs/sdk/browser';
|
|
5
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
7
|
import { useQuery, useMutation, useQueries, QueryClient, QueryClientProvider, useQueryClient } from '@tanstack/react-query';
|
|
7
|
-
import { Trash2, CheckCheck, Check,
|
|
8
|
-
import { clsx } from 'clsx';
|
|
9
|
-
import { twMerge } from 'tailwind-merge';
|
|
8
|
+
import { Trash2, CheckCheck, Check, MessageCircleMore, MoreVertical, MessageSquareLock, Info, FileQuestion, BookOpen, Upload, LogOut, LayoutGrid, Bell, MessageSquare, CircleUserRound, Wrench, Package, ClipboardList, UserPlus, Contact, Settings2, Users, User, StickyNote, FolderPlus, Hash, EyeOff, Eye, CaptionsOff, FolderOpen, MessageSquareMore, MessageSquarePlus, MessageSquareText, MessageSquareOff, MessagesSquare, Columns3Cog, SquarePlus, SquareM, ChevronsDown, Bot, Calendar, Search, Folder, List, SquareCheckBig, Loader2, AlertTriangle, ShieldCheck, Copy, Sparkles, FileText, GitCompareArrows, Download, Image as Image$1, CornerDownLeft, X, ArrowLeft, Send, Tags, Crown, Activity, Gauge, Gift, PartyPopper, UserCheck, FileX2, FileCheck2, Pencil, SquareArrowOutUpRight, XCircle, CheckCircle2, ArrowRight, ChevronDown, MoreHorizontal, SquarePen, FileX, SkipForward, CheckCircle } from 'lucide-react';
|
|
10
9
|
import { isMessageType } from '@arbidocs/client';
|
|
11
10
|
export { isMessageType } from '@arbidocs/client';
|
|
12
11
|
import { create } from 'zustand';
|
|
13
|
-
import { createPortal } from 'react-dom';
|
|
14
|
-
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|
15
|
-
import { cva } from 'class-variance-authority';
|
|
16
|
-
import { Slot } from '@radix-ui/react-slot';
|
|
17
|
-
import * as HoverCardPrimitive from '@radix-ui/react-hover-card';
|
|
18
|
-
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
|
19
|
-
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
|
|
20
|
-
import * as ProgressPrimitive from '@radix-ui/react-progress';
|
|
21
|
-
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
|
|
22
|
-
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
23
|
-
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
24
|
-
import * as SwitchPrimitives from '@radix-ui/react-switch';
|
|
25
|
-
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
26
|
-
import * as SliderPrimitive from '@radix-ui/react-slider';
|
|
27
|
-
import * as TogglePrimitive from '@radix-ui/react-toggle';
|
|
28
|
-
import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
|
|
29
|
-
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
30
|
-
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
31
|
-
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
32
|
-
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
33
|
-
import { Command as Command$1 } from 'cmdk';
|
|
34
12
|
import { diffWords } from 'diff';
|
|
35
|
-
import ReactMarkdown from 'react-markdown';
|
|
36
|
-
import remarkGfm from 'remark-gfm';
|
|
37
|
-
import rehypeRaw from 'rehype-raw';
|
|
38
13
|
import { AnimatePresence, motion } from 'framer-motion';
|
|
14
|
+
import ReactMarkdown from 'react-markdown';
|
|
39
15
|
import { Toaster as Toaster$1, toast } from 'sonner';
|
|
40
16
|
export { toast } from 'sonner';
|
|
41
17
|
import Cropper from 'react-easy-crop';
|
|
42
18
|
import { AgGridReact } from 'ag-grid-react';
|
|
43
19
|
import { ModuleRegistry, AllCommunityModule } from 'ag-grid-community';
|
|
44
20
|
|
|
45
|
-
// src/ArbiProvider.tsx
|
|
46
21
|
var ArbiContext = createContext(null);
|
|
47
22
|
function ArbiProvider({ children, ...options }) {
|
|
48
23
|
const arbi = useMemo(
|
|
@@ -990,40 +965,6 @@ function WorkspaceScreen({ theme, labels, onSelect }) {
|
|
|
990
965
|
] });
|
|
991
966
|
}
|
|
992
967
|
var CITE_RE = /\[([^\]]+)\]\(#cite-(\d+)\)/g;
|
|
993
|
-
function renderWithCitations(text, theme, onCiteClick) {
|
|
994
|
-
const nodes = [];
|
|
995
|
-
let lastIndex = 0;
|
|
996
|
-
let match;
|
|
997
|
-
while ((match = CITE_RE.exec(text)) !== null) {
|
|
998
|
-
if (match.index > lastIndex) {
|
|
999
|
-
nodes.push(text.slice(lastIndex, match.index));
|
|
1000
|
-
}
|
|
1001
|
-
const statement = match[1];
|
|
1002
|
-
const citeNum = match[2];
|
|
1003
|
-
nodes.push(
|
|
1004
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
1005
|
-
statement,
|
|
1006
|
-
/* @__PURE__ */ jsx(
|
|
1007
|
-
"sup",
|
|
1008
|
-
{
|
|
1009
|
-
onClick: (e) => {
|
|
1010
|
-
e.stopPropagation();
|
|
1011
|
-
onCiteClick(citeNum);
|
|
1012
|
-
},
|
|
1013
|
-
style: citeSupStyle(theme),
|
|
1014
|
-
title: `Citation ${citeNum}`,
|
|
1015
|
-
children: citeNum
|
|
1016
|
-
}
|
|
1017
|
-
)
|
|
1018
|
-
] }, `cite-${match.index}`)
|
|
1019
|
-
);
|
|
1020
|
-
lastIndex = match.index + match[0].length;
|
|
1021
|
-
}
|
|
1022
|
-
if (lastIndex < text.length) {
|
|
1023
|
-
nodes.push(text.slice(lastIndex));
|
|
1024
|
-
}
|
|
1025
|
-
return nodes.length > 0 ? nodes : [text];
|
|
1026
|
-
}
|
|
1027
968
|
function MessageBubble({ message, theme }) {
|
|
1028
969
|
const [expandedCite, setExpandedCite] = useState(null);
|
|
1029
970
|
const hasCitations = message.role === "assistant" && message.metadata && CITE_RE.test(message.text);
|
|
@@ -1031,13 +972,46 @@ function MessageBubble({ message, theme }) {
|
|
|
1031
972
|
const resolved = hasCitations ? resolveCitations(message.metadata) : [];
|
|
1032
973
|
const summaries = hasCitations ? summarizeCitations(resolved) : [];
|
|
1033
974
|
const summaryMap = new Map(summaries.map((s) => [s.citationNum, s]));
|
|
1034
|
-
const handleCiteClick = (num) => {
|
|
1035
|
-
setExpandedCite((prev) => prev === num ? null : num);
|
|
1036
|
-
};
|
|
1037
975
|
const activeSummary = expandedCite ? summaryMap.get(expandedCite) : null;
|
|
1038
976
|
const activeResolved = expandedCite ? resolved.find((r) => r.citationNum === expandedCite) : null;
|
|
977
|
+
const markdownComponents = useMemo(
|
|
978
|
+
() => ({
|
|
979
|
+
a: ({ href, children, ...props }) => {
|
|
980
|
+
if (href?.startsWith("#cite-")) {
|
|
981
|
+
const num = href.slice("#cite-".length);
|
|
982
|
+
return /* @__PURE__ */ jsxs("span", { children: [
|
|
983
|
+
children,
|
|
984
|
+
/* @__PURE__ */ jsx(
|
|
985
|
+
"sup",
|
|
986
|
+
{
|
|
987
|
+
onClick: (e) => {
|
|
988
|
+
e.stopPropagation();
|
|
989
|
+
setExpandedCite((prev) => prev === num ? null : num);
|
|
990
|
+
},
|
|
991
|
+
style: citeSupStyle(theme),
|
|
992
|
+
title: `Citation ${num}`,
|
|
993
|
+
children: num
|
|
994
|
+
}
|
|
995
|
+
)
|
|
996
|
+
] });
|
|
997
|
+
}
|
|
998
|
+
return /* @__PURE__ */ jsx(
|
|
999
|
+
"a",
|
|
1000
|
+
{
|
|
1001
|
+
href,
|
|
1002
|
+
target: "_blank",
|
|
1003
|
+
rel: "noopener noreferrer",
|
|
1004
|
+
style: { color: theme.primaryColor },
|
|
1005
|
+
...props,
|
|
1006
|
+
children
|
|
1007
|
+
}
|
|
1008
|
+
);
|
|
1009
|
+
}
|
|
1010
|
+
}),
|
|
1011
|
+
[theme]
|
|
1012
|
+
);
|
|
1039
1013
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
1040
|
-
/* @__PURE__ */ jsx("div", { style: messageBubbleStyle(theme, message.role), children:
|
|
1014
|
+
/* @__PURE__ */ jsx("div", { style: messageBubbleStyle(theme, message.role), children: /* @__PURE__ */ jsx(MarkdownRenderer, { components: markdownComponents, children: message.text }) }),
|
|
1041
1015
|
activeSummary && activeResolved && /* @__PURE__ */ jsxs("div", { style: citePanelStyle(theme), children: [
|
|
1042
1016
|
/* @__PURE__ */ jsxs("div", { style: citePanelHeaderStyle(theme), children: [
|
|
1043
1017
|
/* @__PURE__ */ jsxs("strong", { children: [
|
|
@@ -1380,9 +1354,6 @@ function ArbiChat({
|
|
|
1380
1354
|
}
|
|
1381
1355
|
) }) });
|
|
1382
1356
|
}
|
|
1383
|
-
function cn(...inputs) {
|
|
1384
|
-
return twMerge(clsx(inputs));
|
|
1385
|
-
}
|
|
1386
1357
|
var TypingIndicator = memo(function TypingIndicator2() {
|
|
1387
1358
|
return /* @__PURE__ */ jsx("div", { className: "flex w-full justify-start mb-2", children: /* @__PURE__ */ jsx("div", { className: "bg-card border border-primary rounded-2xl rounded-bl-md px-4 py-2.5", children: /* @__PURE__ */ jsxs("div", { className: "flex gap-1 items-center", children: [
|
|
1388
1359
|
/* @__PURE__ */ jsx("span", { className: "w-1.5 h-1.5 rounded-full bg-muted-foreground animate-bounce [animation-delay:0ms]" }),
|
|
@@ -1633,1707 +1604,1324 @@ function useArbiDocumentSync(workspaceId) {
|
|
|
1633
1604
|
}
|
|
1634
1605
|
});
|
|
1635
1606
|
}
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
const timer = React.useRef(null);
|
|
1642
|
-
const contentId = React.useId();
|
|
1643
|
-
const clearTimer = () => {
|
|
1644
|
-
if (timer.current) {
|
|
1645
|
-
clearTimeout(timer.current);
|
|
1646
|
-
timer.current = null;
|
|
1647
|
-
}
|
|
1648
|
-
};
|
|
1649
|
-
const show = React.useCallback(() => {
|
|
1650
|
-
clearTimer();
|
|
1651
|
-
timer.current = setTimeout(() => setOpen(true), delayDuration);
|
|
1652
|
-
}, [delayDuration]);
|
|
1653
|
-
const hide = React.useCallback(() => {
|
|
1654
|
-
clearTimer();
|
|
1655
|
-
setOpen(false);
|
|
1656
|
-
}, []);
|
|
1657
|
-
const setTrigger = React.useCallback((el) => {
|
|
1658
|
-
triggerRef.current = el;
|
|
1659
|
-
}, []);
|
|
1660
|
-
React.useEffect(() => () => clearTimer(), []);
|
|
1661
|
-
const value = React.useMemo(
|
|
1662
|
-
() => ({ open, show, hide, setTrigger, triggerRef, contentId }),
|
|
1663
|
-
[open, show, hide, setTrigger, contentId]
|
|
1664
|
-
);
|
|
1665
|
-
return /* @__PURE__ */ jsx(TooltipContext.Provider, { value, children });
|
|
1666
|
-
}
|
|
1667
|
-
function TooltipTrigger({ asChild, children, ...props }) {
|
|
1668
|
-
const ctx = React.useContext(TooltipContext);
|
|
1669
|
-
if (!ctx) return /* @__PURE__ */ jsx(Fragment, { children });
|
|
1670
|
-
const triggerHandlers = {
|
|
1671
|
-
onPointerEnter: (e) => {
|
|
1672
|
-
props.onPointerEnter?.(e);
|
|
1673
|
-
ctx.show();
|
|
1674
|
-
},
|
|
1675
|
-
onPointerLeave: (e) => {
|
|
1676
|
-
props.onPointerLeave?.(e);
|
|
1677
|
-
ctx.hide();
|
|
1678
|
-
},
|
|
1679
|
-
onFocus: (e) => {
|
|
1680
|
-
props.onFocus?.(e);
|
|
1681
|
-
ctx.show();
|
|
1682
|
-
},
|
|
1683
|
-
onBlur: (e) => {
|
|
1684
|
-
props.onBlur?.(e);
|
|
1685
|
-
ctx.hide();
|
|
1686
|
-
},
|
|
1687
|
-
"aria-describedby": ctx.open ? ctx.contentId : void 0,
|
|
1688
|
-
"data-state": ctx.open ? "open" : "closed"
|
|
1689
|
-
};
|
|
1690
|
-
if (asChild && React.isValidElement(children)) {
|
|
1691
|
-
const child = children;
|
|
1692
|
-
return React.cloneElement(child, {
|
|
1693
|
-
...props,
|
|
1694
|
-
...triggerHandlers,
|
|
1695
|
-
ref: ctx.setTrigger
|
|
1696
|
-
});
|
|
1697
|
-
}
|
|
1698
|
-
return /* @__PURE__ */ jsx(
|
|
1699
|
-
"button",
|
|
1700
|
-
{
|
|
1701
|
-
type: "button",
|
|
1702
|
-
...props,
|
|
1703
|
-
...triggerHandlers,
|
|
1704
|
-
ref: ctx.setTrigger,
|
|
1705
|
-
children
|
|
1706
|
-
}
|
|
1607
|
+
function useWorkspaceDocs(workspaceId) {
|
|
1608
|
+
const { data: docs = [], isLoading, isError } = useDocuments(workspaceId);
|
|
1609
|
+
const docIds = useMemo(
|
|
1610
|
+
() => docs.map((d) => d.external_id).filter((id) => !!id),
|
|
1611
|
+
[docs]
|
|
1707
1612
|
);
|
|
1613
|
+
return { wsId: workspaceId, docs, docIds, isLoading, isError, ready: docIds.length > 0 };
|
|
1708
1614
|
}
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
id: ctx.contentId,
|
|
1754
|
-
role: "tooltip",
|
|
1755
|
-
className: cn("tooltip-content pointer-events-none", className),
|
|
1756
|
-
style: {
|
|
1757
|
-
position: "fixed",
|
|
1758
|
-
top: coords?.top ?? -9999,
|
|
1759
|
-
left: coords?.left ?? -9999,
|
|
1760
|
-
transform: coords?.transform ?? TRANSFORM_BY_SIDE[side],
|
|
1761
|
-
opacity: coords ? void 0 : 0,
|
|
1762
|
-
zIndex: 9999,
|
|
1763
|
-
...style
|
|
1615
|
+
function useAiTask() {
|
|
1616
|
+
const mutation = useAssistantQuery();
|
|
1617
|
+
const [status, setStatus] = useState("idle");
|
|
1618
|
+
const [text, setText] = useState("");
|
|
1619
|
+
const [stepCount, setStepCount] = useState(0);
|
|
1620
|
+
const [error, setError] = useState(null);
|
|
1621
|
+
const [responseId, setResponseId] = useState(null);
|
|
1622
|
+
const [artifacts, setArtifacts] = useState([]);
|
|
1623
|
+
const bufferRef = useRef("");
|
|
1624
|
+
const artifactsRef = useRef(/* @__PURE__ */ new Map());
|
|
1625
|
+
const reset = useCallback(() => {
|
|
1626
|
+
setStatus("idle");
|
|
1627
|
+
setText("");
|
|
1628
|
+
setStepCount(0);
|
|
1629
|
+
setError(null);
|
|
1630
|
+
setResponseId(null);
|
|
1631
|
+
setArtifacts([]);
|
|
1632
|
+
artifactsRef.current = /* @__PURE__ */ new Map();
|
|
1633
|
+
bufferRef.current = "";
|
|
1634
|
+
}, []);
|
|
1635
|
+
const run = useCallback(
|
|
1636
|
+
async (question, docIds, opts) => {
|
|
1637
|
+
setStatus("running");
|
|
1638
|
+
setText("");
|
|
1639
|
+
setStepCount(0);
|
|
1640
|
+
setError(null);
|
|
1641
|
+
setArtifacts([]);
|
|
1642
|
+
artifactsRef.current = /* @__PURE__ */ new Map();
|
|
1643
|
+
bufferRef.current = "";
|
|
1644
|
+
let streamError = null;
|
|
1645
|
+
try {
|
|
1646
|
+
const result = await mutation.mutateAsync({
|
|
1647
|
+
question,
|
|
1648
|
+
docIds,
|
|
1649
|
+
previousResponseId: opts?.previousResponseId ?? void 0,
|
|
1650
|
+
model: opts?.model,
|
|
1651
|
+
onToken: (c) => {
|
|
1652
|
+
bufferRef.current += c;
|
|
1653
|
+
setText(bufferRef.current);
|
|
1654
|
+
},
|
|
1655
|
+
onAgentStep: () => setStepCount((n) => n + 1),
|
|
1656
|
+
onArtifact: (a) => {
|
|
1657
|
+
artifactsRef.current.set(a.doc_ext_id, a);
|
|
1658
|
+
setArtifacts([...artifactsRef.current.values()]);
|
|
1764
1659
|
},
|
|
1765
|
-
|
|
1660
|
+
onError: (m) => {
|
|
1661
|
+
streamError = m;
|
|
1662
|
+
}
|
|
1663
|
+
});
|
|
1664
|
+
const finalText = result.text || bufferRef.current;
|
|
1665
|
+
setText(finalText);
|
|
1666
|
+
setResponseId(result.assistantMessageExtId);
|
|
1667
|
+
setStepCount(result.agentSteps.length || 0);
|
|
1668
|
+
if (result.artifacts?.length) {
|
|
1669
|
+
for (const a of result.artifacts) artifactsRef.current.set(a.doc_ext_id, a);
|
|
1670
|
+
setArtifacts([...artifactsRef.current.values()]);
|
|
1766
1671
|
}
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
}
|
|
1780
|
-
));
|
|
1781
|
-
Avatar.displayName = AvatarPrimitive.Root.displayName;
|
|
1782
|
-
var AvatarImage = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1783
|
-
AvatarPrimitive.Image,
|
|
1784
|
-
{
|
|
1785
|
-
ref,
|
|
1786
|
-
className: cn("aspect-square h-full w-full", className),
|
|
1787
|
-
...props
|
|
1788
|
-
}
|
|
1789
|
-
));
|
|
1790
|
-
AvatarImage.displayName = AvatarPrimitive.Image.displayName;
|
|
1791
|
-
var AvatarFallback = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1792
|
-
AvatarPrimitive.Fallback,
|
|
1793
|
-
{
|
|
1794
|
-
ref,
|
|
1795
|
-
className: cn(
|
|
1796
|
-
"flex h-full w-full items-center justify-center rounded-full bg-muted",
|
|
1797
|
-
className
|
|
1798
|
-
),
|
|
1799
|
-
...props
|
|
1800
|
-
}
|
|
1801
|
-
));
|
|
1802
|
-
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
|
|
1803
|
-
var badgeVariants = cva(
|
|
1804
|
-
"inline-flex items-center rounded-md border px-2.5 py-0.5 text-sm font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
1805
|
-
{
|
|
1806
|
-
variants: {
|
|
1807
|
-
variant: {
|
|
1808
|
-
default: "border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
|
|
1809
|
-
accent: "border-transparent bg-ai-accent-soft text-ai-accent",
|
|
1810
|
-
secondary: "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
1811
|
-
destructive: "border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",
|
|
1812
|
-
outline: "text-foreground"
|
|
1672
|
+
const err = streamError || result.errors[0] || null;
|
|
1673
|
+
if (err && !finalText) {
|
|
1674
|
+
setError(err);
|
|
1675
|
+
setStatus("error");
|
|
1676
|
+
} else {
|
|
1677
|
+
setStatus("done");
|
|
1678
|
+
}
|
|
1679
|
+
return result;
|
|
1680
|
+
} catch (e) {
|
|
1681
|
+
setError(e instanceof Error ? e.message : "The assistant request failed.");
|
|
1682
|
+
setStatus("error");
|
|
1683
|
+
return null;
|
|
1813
1684
|
}
|
|
1814
1685
|
},
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1686
|
+
[mutation]
|
|
1687
|
+
);
|
|
1688
|
+
return {
|
|
1689
|
+
status,
|
|
1690
|
+
text,
|
|
1691
|
+
stepCount,
|
|
1692
|
+
error,
|
|
1693
|
+
responseId,
|
|
1694
|
+
artifacts,
|
|
1695
|
+
run,
|
|
1696
|
+
reset,
|
|
1697
|
+
isRunning: status === "running",
|
|
1698
|
+
isDone: status === "done"
|
|
1699
|
+
};
|
|
1822
1700
|
}
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1701
|
+
function useSemanticSearch(docIds) {
|
|
1702
|
+
const arbi = useArbi();
|
|
1703
|
+
const [query, setQuery] = useState("");
|
|
1704
|
+
const mutation = useMutation({
|
|
1705
|
+
mutationFn: async ({ query: q, mode }) => {
|
|
1706
|
+
const res = await arbi.assistant.retrieve(q, docIds, { searchMode: mode });
|
|
1707
|
+
const byTool = res.retrieval_chunk?.tool_responses ?? {};
|
|
1708
|
+
return Object.values(byTool).flat().map(
|
|
1709
|
+
(c) => ({
|
|
1710
|
+
chunkExtId: c.metadata.chunk_ext_id,
|
|
1711
|
+
docId: c.metadata.doc_ext_id,
|
|
1712
|
+
docTitle: c.metadata.doc_title,
|
|
1713
|
+
page: c.metadata.page_number,
|
|
1714
|
+
score: c.metadata.rerank_score ?? c.metadata.score,
|
|
1715
|
+
content: c.content
|
|
1716
|
+
})
|
|
1717
|
+
).sort((a, b) => (b.score ?? 0) - (a.score ?? 0));
|
|
1718
|
+
}
|
|
1719
|
+
});
|
|
1720
|
+
const { mutateAsync, reset } = mutation;
|
|
1721
|
+
const search = useCallback(
|
|
1722
|
+
async (q, mode = "hybrid") => {
|
|
1723
|
+
const trimmed = q.trim();
|
|
1724
|
+
setQuery(trimmed);
|
|
1725
|
+
if (!trimmed || docIds.length === 0) {
|
|
1726
|
+
reset();
|
|
1727
|
+
return;
|
|
1728
|
+
}
|
|
1729
|
+
try {
|
|
1730
|
+
await mutateAsync({ query: trimmed, mode });
|
|
1731
|
+
} catch {
|
|
1841
1732
|
}
|
|
1842
1733
|
},
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1734
|
+
[mutateAsync, reset, docIds]
|
|
1735
|
+
);
|
|
1736
|
+
const status = mutation.isPending ? "running" : mutation.isError ? "error" : mutation.isSuccess ? "done" : "idle";
|
|
1737
|
+
return {
|
|
1738
|
+
query,
|
|
1739
|
+
results: mutation.data ?? [],
|
|
1740
|
+
status,
|
|
1741
|
+
error: mutation.error ? mutation.error.message ?? "Search failed." : null,
|
|
1742
|
+
search,
|
|
1743
|
+
isRunning: mutation.isPending
|
|
1744
|
+
};
|
|
1745
|
+
}
|
|
1746
|
+
function toRedlineMarkdown(original, revised) {
|
|
1747
|
+
const parts = diffWords(original ?? "", revised ?? "");
|
|
1748
|
+
return parts.map((p) => {
|
|
1749
|
+
if (p.added) return `<ins>${p.value}</ins>`;
|
|
1750
|
+
if (p.removed) return `<del>${p.value}</del>`;
|
|
1751
|
+
return p.value;
|
|
1752
|
+
}).join("");
|
|
1753
|
+
}
|
|
1754
|
+
function redlineStats(original, revised) {
|
|
1755
|
+
let added = 0;
|
|
1756
|
+
let removed = 0;
|
|
1757
|
+
for (const p of diffWords(original ?? "", revised ?? "")) {
|
|
1758
|
+
const words = p.value.trim() ? p.value.trim().split(/\s+/).length : 0;
|
|
1759
|
+
if (p.added) added += words;
|
|
1760
|
+
else if (p.removed) removed += words;
|
|
1847
1761
|
}
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1762
|
+
return { added, removed };
|
|
1763
|
+
}
|
|
1764
|
+
function textToArtifact(title, content, opts) {
|
|
1765
|
+
return {
|
|
1766
|
+
type: "arbi.artifact",
|
|
1767
|
+
doc_ext_id: opts?.id ?? `local-${title.replace(/\W+/g, "-").toLowerCase()}`,
|
|
1768
|
+
title,
|
|
1769
|
+
mode: opts?.mode ?? "markdown",
|
|
1770
|
+
content,
|
|
1771
|
+
// Content-backed (markdown/text/html) artifacts carry no blob; file_type is
|
|
1772
|
+
// required on ArtifactEvent and defaults to "" for non-image artifacts.
|
|
1773
|
+
file_type: "",
|
|
1774
|
+
is_complete: opts?.isComplete ?? true,
|
|
1775
|
+
version: opts?.version ?? 1,
|
|
1776
|
+
message_ext_id: null,
|
|
1777
|
+
t: null
|
|
1778
|
+
};
|
|
1779
|
+
}
|
|
1780
|
+
function AiAnswer({
|
|
1781
|
+
status,
|
|
1782
|
+
text,
|
|
1783
|
+
stepCount,
|
|
1784
|
+
error,
|
|
1785
|
+
className,
|
|
1786
|
+
emptyHint,
|
|
1787
|
+
groundedNote = "Grounded in the live workspace \xB7 verify citations before relying on it",
|
|
1788
|
+
runningHint = "Reading the documents\u2026",
|
|
1789
|
+
testId = "ai-answer"
|
|
1790
|
+
}) {
|
|
1791
|
+
const [copied, setCopied] = useState(false);
|
|
1792
|
+
const running = status === "running";
|
|
1793
|
+
const hasText = text.trim().length > 0;
|
|
1794
|
+
const copy = async () => {
|
|
1795
|
+
await navigator.clipboard.writeText(text);
|
|
1796
|
+
setCopied(true);
|
|
1797
|
+
setTimeout(() => setCopied(false), 1600);
|
|
1798
|
+
};
|
|
1799
|
+
if (status === "idle" && !hasText) {
|
|
1800
|
+
return emptyHint ? /* @__PURE__ */ jsx("p", { className: cn("text-sm text-muted-foreground", className), "data-testid": `${testId}-empty`, children: emptyHint }) : null;
|
|
1853
1801
|
}
|
|
1854
|
-
)
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
"z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-hover-card-content-transform-origin]",
|
|
1866
|
-
className
|
|
1802
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("space-y-3", className), "data-testid": testId, "data-status": status, children: [
|
|
1803
|
+
running && /* @__PURE__ */ jsxs(
|
|
1804
|
+
"div",
|
|
1805
|
+
{
|
|
1806
|
+
className: "flex items-center gap-2 text-xs font-medium text-ai-accent",
|
|
1807
|
+
"data-testid": `${testId}-thinking`,
|
|
1808
|
+
children: [
|
|
1809
|
+
/* @__PURE__ */ jsx(Loader2, { className: "size-3.5 animate-spin" }),
|
|
1810
|
+
stepCount && stepCount > 0 ? `Working \u2014 ${stepCount} step${stepCount === 1 ? "" : "s"}\u2026` : "Thinking\u2026"
|
|
1811
|
+
]
|
|
1812
|
+
}
|
|
1867
1813
|
),
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
) }));
|
|
1871
|
-
HoverCardContent.displayName = HoverCardPrimitive.Content.displayName;
|
|
1872
|
-
var cardVariants = cva("rounded-lg bg-card text-card-foreground", {
|
|
1873
|
-
variants: {
|
|
1874
|
-
variant: {
|
|
1875
|
-
flat: "",
|
|
1876
|
-
outline: "border",
|
|
1877
|
-
elevated: "border shadow-sm"
|
|
1878
|
-
}
|
|
1879
|
-
},
|
|
1880
|
-
defaultVariants: {
|
|
1881
|
-
variant: "flat"
|
|
1882
|
-
}
|
|
1883
|
-
});
|
|
1884
|
-
var Card = React.forwardRef(
|
|
1885
|
-
({ className, variant, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1886
|
-
"div",
|
|
1887
|
-
{
|
|
1888
|
-
ref,
|
|
1889
|
-
"data-slot": "card",
|
|
1890
|
-
className: cn(cardVariants({ variant }), className),
|
|
1891
|
-
...props
|
|
1892
|
-
}
|
|
1893
|
-
)
|
|
1894
|
-
);
|
|
1895
|
-
Card.displayName = "Card";
|
|
1896
|
-
var CardHeader = React.forwardRef(
|
|
1897
|
-
({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1898
|
-
"div",
|
|
1899
|
-
{
|
|
1900
|
-
ref,
|
|
1901
|
-
"data-slot": "card-header",
|
|
1902
|
-
className: cn("flex flex-col space-y-1.5 p-6", className),
|
|
1903
|
-
...props
|
|
1904
|
-
}
|
|
1905
|
-
)
|
|
1906
|
-
);
|
|
1907
|
-
CardHeader.displayName = "CardHeader";
|
|
1908
|
-
var CardTitle = React.forwardRef(
|
|
1909
|
-
({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1910
|
-
"div",
|
|
1911
|
-
{
|
|
1912
|
-
ref,
|
|
1913
|
-
"data-slot": "card-title",
|
|
1914
|
-
className: cn("font-semibold leading-none tracking-tight", className),
|
|
1915
|
-
...props
|
|
1916
|
-
}
|
|
1917
|
-
)
|
|
1918
|
-
);
|
|
1919
|
-
CardTitle.displayName = "CardTitle";
|
|
1920
|
-
var CardDescription = React.forwardRef(
|
|
1921
|
-
({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1922
|
-
"div",
|
|
1923
|
-
{
|
|
1924
|
-
ref,
|
|
1925
|
-
"data-slot": "card-description",
|
|
1926
|
-
className: cn("text-sm text-muted-foreground", className),
|
|
1927
|
-
...props
|
|
1928
|
-
}
|
|
1929
|
-
)
|
|
1930
|
-
);
|
|
1931
|
-
CardDescription.displayName = "CardDescription";
|
|
1932
|
-
var CardContent = React.forwardRef(
|
|
1933
|
-
({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, "data-slot": "card-content", className: cn("p-6 pt-0", className), ...props })
|
|
1934
|
-
);
|
|
1935
|
-
CardContent.displayName = "CardContent";
|
|
1936
|
-
var CardFooter = React.forwardRef(
|
|
1937
|
-
({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1938
|
-
"div",
|
|
1939
|
-
{
|
|
1940
|
-
ref,
|
|
1941
|
-
"data-slot": "card-footer",
|
|
1942
|
-
className: cn("flex items-center p-6 pt-0", className),
|
|
1943
|
-
...props
|
|
1944
|
-
}
|
|
1945
|
-
)
|
|
1946
|
-
);
|
|
1947
|
-
CardFooter.displayName = "CardFooter";
|
|
1948
|
-
var Input = React.forwardRef(
|
|
1949
|
-
({ className, type, ...props }, ref) => {
|
|
1950
|
-
return /* @__PURE__ */ jsx(
|
|
1951
|
-
"input",
|
|
1814
|
+
status === "error" && !hasText && /* @__PURE__ */ jsxs(
|
|
1815
|
+
"div",
|
|
1952
1816
|
{
|
|
1953
|
-
|
|
1954
|
-
"data-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
ref,
|
|
1960
|
-
...props
|
|
1817
|
+
className: "flex items-start gap-2 rounded-lg border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive",
|
|
1818
|
+
"data-testid": `${testId}-error`,
|
|
1819
|
+
children: [
|
|
1820
|
+
/* @__PURE__ */ jsx(AlertTriangle, { className: "mt-0.5 size-4 shrink-0" }),
|
|
1821
|
+
/* @__PURE__ */ jsx("span", { children: error ?? "The assistant request failed." })
|
|
1822
|
+
]
|
|
1961
1823
|
}
|
|
1962
|
-
);
|
|
1963
|
-
}
|
|
1964
|
-
);
|
|
1965
|
-
Input.displayName = "Input";
|
|
1966
|
-
var Label = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1967
|
-
"label",
|
|
1968
|
-
{
|
|
1969
|
-
ref,
|
|
1970
|
-
className: `text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 ${className || ""}`,
|
|
1971
|
-
...props
|
|
1972
|
-
}
|
|
1973
|
-
));
|
|
1974
|
-
Label.displayName = "Label";
|
|
1975
|
-
var Separator = React.forwardRef(({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1976
|
-
SeparatorPrimitive.Root,
|
|
1977
|
-
{
|
|
1978
|
-
ref,
|
|
1979
|
-
decorative,
|
|
1980
|
-
orientation,
|
|
1981
|
-
className: cn(
|
|
1982
|
-
"shrink-0 bg-border",
|
|
1983
|
-
orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
|
|
1984
|
-
className
|
|
1985
1824
|
),
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1825
|
+
hasText && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1826
|
+
/* @__PURE__ */ jsx(AiMarkdown, { isStreaming: running, children: text }),
|
|
1827
|
+
!running && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-t border-border pt-2.5", children: [
|
|
1828
|
+
/* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1.5 text-xs text-muted-foreground", children: [
|
|
1829
|
+
/* @__PURE__ */ jsx(ShieldCheck, { className: "size-3.5 text-ai-accent" }),
|
|
1830
|
+
groundedNote
|
|
1831
|
+
] }),
|
|
1832
|
+
/* @__PURE__ */ jsxs(
|
|
1833
|
+
"button",
|
|
1834
|
+
{
|
|
1835
|
+
type: "button",
|
|
1836
|
+
onClick: copy,
|
|
1837
|
+
className: "inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground",
|
|
1838
|
+
"data-testid": `${testId}-copy`,
|
|
1839
|
+
children: [
|
|
1840
|
+
copied ? /* @__PURE__ */ jsx(Check, { className: "size-3.5 text-ai-accent" }) : /* @__PURE__ */ jsx(Copy, { className: "size-3.5" }),
|
|
1841
|
+
copied ? "Copied" : "Copy"
|
|
1842
|
+
]
|
|
1843
|
+
}
|
|
1844
|
+
)
|
|
1845
|
+
] })
|
|
1846
|
+
] }),
|
|
1847
|
+
running && !hasText && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 text-sm text-muted-foreground", children: [
|
|
1848
|
+
/* @__PURE__ */ jsx(Sparkles, { className: "size-4 animate-pulse text-ai-accent" }),
|
|
1849
|
+
" ",
|
|
1850
|
+
runningHint
|
|
1851
|
+
] })
|
|
1852
|
+
] });
|
|
1853
|
+
}
|
|
1854
|
+
function AiActionCard({
|
|
1855
|
+
icon: Icon = Sparkles,
|
|
1856
|
+
title,
|
|
1857
|
+
description,
|
|
1858
|
+
prompt,
|
|
1859
|
+
docIds,
|
|
1860
|
+
runLabel = "Run",
|
|
1861
|
+
noDocsHint = "Connect to the workspace to run this.",
|
|
1862
|
+
disabled,
|
|
1863
|
+
testId
|
|
1864
|
+
}) {
|
|
1865
|
+
const task = useAiTask();
|
|
1866
|
+
const noDocs = docIds.length === 0;
|
|
1867
|
+
const onRun = () => {
|
|
1868
|
+
const p = typeof prompt === "function" ? prompt() : prompt;
|
|
1869
|
+
void task.run(p, docIds);
|
|
1870
|
+
};
|
|
1871
|
+
return /* @__PURE__ */ jsxs(Card, { variant: "elevated", className: "rounded-xl p-5", "data-testid": testId, children: [
|
|
1872
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-4", children: [
|
|
1873
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
|
|
1874
|
+
/* @__PURE__ */ jsx("div", { className: "flex size-9 shrink-0 items-center justify-center rounded-lg bg-ai-accent-soft text-ai-accent", children: /* @__PURE__ */ jsx(Icon, { className: "size-4" }) }),
|
|
1875
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1876
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-semibold text-foreground", children: title }),
|
|
1877
|
+
/* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs leading-relaxed text-muted-foreground", children: description })
|
|
1878
|
+
] })
|
|
1879
|
+
] }),
|
|
1880
|
+
/* @__PURE__ */ jsxs(
|
|
1881
|
+
Button,
|
|
1882
|
+
{
|
|
1883
|
+
variant: task.isDone ? "outline" : "accent",
|
|
1884
|
+
size: "sm",
|
|
1885
|
+
onClick: onRun,
|
|
1886
|
+
disabled: disabled || noDocs || task.isRunning,
|
|
1887
|
+
"data-testid": testId && `${testId}-run`,
|
|
1888
|
+
children: [
|
|
1889
|
+
/* @__PURE__ */ jsx(Sparkles, { className: "size-3.5" }),
|
|
1890
|
+
task.isRunning ? "Running\u2026" : task.isDone ? "Re-run" : runLabel
|
|
1891
|
+
]
|
|
1892
|
+
}
|
|
1893
|
+
)
|
|
1894
|
+
] }),
|
|
1895
|
+
(task.status !== "idle" || noDocs) && /* @__PURE__ */ jsx("div", { className: "mt-4", children: noDocs ? /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: noDocsHint }) : /* @__PURE__ */ jsx(
|
|
1896
|
+
AiAnswer,
|
|
1897
|
+
{
|
|
1898
|
+
status: task.status,
|
|
1899
|
+
text: task.text,
|
|
1900
|
+
stepCount: task.stepCount,
|
|
1901
|
+
error: task.error,
|
|
1902
|
+
testId: testId && `${testId}-answer`
|
|
1903
|
+
}
|
|
1904
|
+
) })
|
|
1905
|
+
] });
|
|
1906
|
+
}
|
|
1907
|
+
function ArtifactCanvas({
|
|
1908
|
+
artifacts,
|
|
1909
|
+
className,
|
|
1910
|
+
emptyHint = "Draft artifacts produced by the agent will open here.",
|
|
1911
|
+
busy = false,
|
|
1912
|
+
busyHint = "The agent is working through the documents\u2026",
|
|
1913
|
+
stepCount,
|
|
1914
|
+
error = null
|
|
1915
|
+
}) {
|
|
1916
|
+
const [activeId, setActiveId] = useState(null);
|
|
1917
|
+
const [copied, setCopied] = useState(false);
|
|
1918
|
+
useEffect(() => {
|
|
1919
|
+
if (artifacts.length && (!activeId || !artifacts.some((a) => a.doc_ext_id === activeId))) {
|
|
1920
|
+
setActiveId(artifacts[artifacts.length - 1].doc_ext_id);
|
|
1921
|
+
}
|
|
1922
|
+
}, [artifacts, activeId]);
|
|
1923
|
+
if (artifacts.length === 0) {
|
|
1924
|
+
if (error && !busy) {
|
|
1925
|
+
return /* @__PURE__ */ jsxs(
|
|
1926
|
+
"div",
|
|
1927
|
+
{
|
|
1928
|
+
className: cn(
|
|
1929
|
+
"flex h-full min-h-[280px] flex-col items-center justify-center rounded-xl border border-destructive/30 bg-destructive/5 p-8 text-center",
|
|
1930
|
+
className
|
|
1931
|
+
),
|
|
1932
|
+
"data-testid": "artifact-canvas-error",
|
|
1933
|
+
children: [
|
|
1934
|
+
/* @__PURE__ */ jsx(AlertTriangle, { className: "size-8 text-destructive/70" }),
|
|
1935
|
+
/* @__PURE__ */ jsx("p", { className: "mt-3 max-w-md text-sm text-foreground", children: error })
|
|
1936
|
+
]
|
|
1937
|
+
}
|
|
1938
|
+
);
|
|
1939
|
+
}
|
|
1940
|
+
if (busy) {
|
|
1941
|
+
return /* @__PURE__ */ jsxs(
|
|
1942
|
+
"div",
|
|
1943
|
+
{
|
|
1944
|
+
className: cn(
|
|
1945
|
+
"flex h-full min-h-[280px] flex-col items-center justify-center rounded-xl border border-border bg-ai-surface/40 p-8 text-center",
|
|
1946
|
+
className
|
|
1947
|
+
),
|
|
1948
|
+
"data-testid": "artifact-canvas-busy",
|
|
1949
|
+
children: [
|
|
1950
|
+
/* @__PURE__ */ jsx(Loader2, { className: "size-8 animate-spin text-ai-accent" }),
|
|
1951
|
+
/* @__PURE__ */ jsx("p", { className: "mt-4 max-w-xs text-sm font-medium text-foreground", children: busyHint }),
|
|
1952
|
+
typeof stepCount === "number" && stepCount > 0 && /* @__PURE__ */ jsxs("p", { className: "mt-1 text-xs text-muted-foreground", "data-testid": "artifact-canvas-steps", children: [
|
|
1953
|
+
stepCount,
|
|
1954
|
+
" ",
|
|
1955
|
+
stepCount === 1 ? "step" : "steps",
|
|
1956
|
+
" so far"
|
|
1957
|
+
] })
|
|
1958
|
+
]
|
|
1959
|
+
}
|
|
1960
|
+
);
|
|
1961
|
+
}
|
|
1962
|
+
return /* @__PURE__ */ jsxs(
|
|
1963
|
+
"div",
|
|
1994
1964
|
{
|
|
1995
1965
|
className: cn(
|
|
1996
|
-
"flex min-h-[
|
|
1966
|
+
"flex h-full min-h-[280px] flex-col items-center justify-center rounded-xl border border-dashed border-border bg-secondary/30 p-8 text-center",
|
|
1997
1967
|
className
|
|
1998
1968
|
),
|
|
1999
|
-
|
|
2000
|
-
|
|
1969
|
+
"data-testid": "artifact-canvas-empty",
|
|
1970
|
+
children: [
|
|
1971
|
+
/* @__PURE__ */ jsx(FileText, { className: "size-8 text-muted-foreground/50" }),
|
|
1972
|
+
/* @__PURE__ */ jsx("p", { className: "mt-3 max-w-xs text-sm text-muted-foreground", children: emptyHint })
|
|
1973
|
+
]
|
|
2001
1974
|
}
|
|
2002
1975
|
);
|
|
2003
1976
|
}
|
|
2004
|
-
);
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
{
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
));
|
|
2024
|
-
Progress.displayName = ProgressPrimitive.Root.displayName;
|
|
2025
|
-
var ScrollArea = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
2026
|
-
ScrollAreaPrimitive.Root,
|
|
2027
|
-
{
|
|
2028
|
-
ref,
|
|
2029
|
-
className: cn("relative overflow-hidden", className),
|
|
2030
|
-
...props,
|
|
2031
|
-
children: [
|
|
2032
|
-
/* @__PURE__ */ jsx(ScrollAreaPrimitive.Viewport, { className: "h-full w-full rounded-[inherit]", children }),
|
|
2033
|
-
/* @__PURE__ */ jsx(ScrollBar, {}),
|
|
2034
|
-
/* @__PURE__ */ jsx(ScrollAreaPrimitive.Corner, {})
|
|
2035
|
-
]
|
|
2036
|
-
}
|
|
2037
|
-
));
|
|
2038
|
-
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
|
|
2039
|
-
var ScrollBar = React.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2040
|
-
ScrollAreaPrimitive.ScrollAreaScrollbar,
|
|
2041
|
-
{
|
|
2042
|
-
ref,
|
|
2043
|
-
orientation,
|
|
2044
|
-
className: cn(
|
|
2045
|
-
"flex touch-none select-none transition-colors",
|
|
2046
|
-
orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-[1px]",
|
|
2047
|
-
orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent p-[1px]",
|
|
2048
|
-
className
|
|
2049
|
-
),
|
|
2050
|
-
...props,
|
|
2051
|
-
children: /* @__PURE__ */ jsx(ScrollAreaPrimitive.ScrollAreaThumb, { className: "relative flex-1 rounded-full bg-border" })
|
|
2052
|
-
}
|
|
2053
|
-
));
|
|
2054
|
-
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
|
|
2055
|
-
var RadioGroup = React.forwardRef(({ className, ...props }, ref) => {
|
|
2056
|
-
return /* @__PURE__ */ jsx(RadioGroupPrimitive.Root, { className: cn("grid gap-2", className), ...props, ref });
|
|
2057
|
-
});
|
|
2058
|
-
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
|
|
2059
|
-
var RadioGroupItem = React.forwardRef(({ className, ...props }, ref) => {
|
|
2060
|
-
return /* @__PURE__ */ jsx(
|
|
2061
|
-
RadioGroupPrimitive.Item,
|
|
1977
|
+
const active = artifacts.find((a) => a.doc_ext_id === activeId) ?? artifacts[artifacts.length - 1];
|
|
1978
|
+
const isRedline = /~~|<ins|<del|<mark/i.test(active.content);
|
|
1979
|
+
const copy = async () => {
|
|
1980
|
+
await navigator.clipboard.writeText(active.content);
|
|
1981
|
+
setCopied(true);
|
|
1982
|
+
setTimeout(() => setCopied(false), 1600);
|
|
1983
|
+
};
|
|
1984
|
+
const download = () => {
|
|
1985
|
+
const ext = active.mode === "html" ? "html" : active.mode === "text" ? "txt" : "md";
|
|
1986
|
+
const blob = new Blob([active.content], { type: "text/plain" });
|
|
1987
|
+
const url = URL.createObjectURL(blob);
|
|
1988
|
+
const a = document.createElement("a");
|
|
1989
|
+
a.href = url;
|
|
1990
|
+
a.download = `${active.title.replace(/[^\w.-]+/g, "_") || "artifact"}.${ext}`;
|
|
1991
|
+
a.click();
|
|
1992
|
+
URL.revokeObjectURL(url);
|
|
1993
|
+
};
|
|
1994
|
+
return /* @__PURE__ */ jsxs(
|
|
1995
|
+
"div",
|
|
2062
1996
|
{
|
|
2063
|
-
ref,
|
|
2064
1997
|
className: cn(
|
|
2065
|
-
"
|
|
1998
|
+
"flex h-full flex-col overflow-hidden rounded-xl border border-border bg-card",
|
|
2066
1999
|
className
|
|
2067
2000
|
),
|
|
2068
|
-
|
|
2069
|
-
children: /* @__PURE__ */ jsx(RadioGroupPrimitive.Indicator, { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(Circle, { className: "h-2.5 w-2.5 fill-current text-current" }) })
|
|
2070
|
-
}
|
|
2071
|
-
);
|
|
2072
|
-
});
|
|
2073
|
-
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
|
|
2074
|
-
var Checkbox = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2075
|
-
CheckboxPrimitive.Root,
|
|
2076
|
-
{
|
|
2077
|
-
ref,
|
|
2078
|
-
className: cn(
|
|
2079
|
-
"peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
|
2080
|
-
className
|
|
2081
|
-
),
|
|
2082
|
-
...props,
|
|
2083
|
-
children: /* @__PURE__ */ jsx(CheckboxPrimitive.Indicator, { className: cn("flex items-center justify-center text-current"), children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }) })
|
|
2084
|
-
}
|
|
2085
|
-
));
|
|
2086
|
-
Checkbox.displayName = CheckboxPrimitive.Root.displayName;
|
|
2087
|
-
var Switch = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2088
|
-
SwitchPrimitives.Root,
|
|
2089
|
-
{
|
|
2090
|
-
className: cn(
|
|
2091
|
-
"peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
|
|
2092
|
-
className
|
|
2093
|
-
),
|
|
2094
|
-
...props,
|
|
2095
|
-
ref,
|
|
2096
|
-
children: /* @__PURE__ */ jsx(
|
|
2097
|
-
SwitchPrimitives.Thumb,
|
|
2098
|
-
{
|
|
2099
|
-
className: cn(
|
|
2100
|
-
"pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
|
|
2101
|
-
)
|
|
2102
|
-
}
|
|
2103
|
-
)
|
|
2104
|
-
}
|
|
2105
|
-
));
|
|
2106
|
-
Switch.displayName = SwitchPrimitives.Root.displayName;
|
|
2107
|
-
var Tabs = TabsPrimitive.Root;
|
|
2108
|
-
var TabsList = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2109
|
-
TabsPrimitive.List,
|
|
2110
|
-
{
|
|
2111
|
-
ref,
|
|
2112
|
-
className: cn(
|
|
2113
|
-
"inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",
|
|
2114
|
-
className
|
|
2115
|
-
),
|
|
2116
|
-
...props
|
|
2117
|
-
}
|
|
2118
|
-
));
|
|
2119
|
-
TabsList.displayName = TabsPrimitive.List.displayName;
|
|
2120
|
-
var TabsTrigger = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2121
|
-
TabsPrimitive.Trigger,
|
|
2122
|
-
{
|
|
2123
|
-
ref,
|
|
2124
|
-
className: cn(
|
|
2125
|
-
"inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",
|
|
2126
|
-
className
|
|
2127
|
-
),
|
|
2128
|
-
...props
|
|
2129
|
-
}
|
|
2130
|
-
));
|
|
2131
|
-
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
|
|
2132
|
-
var TabsContent = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2133
|
-
TabsPrimitive.Content,
|
|
2134
|
-
{
|
|
2135
|
-
ref,
|
|
2136
|
-
className: cn(
|
|
2137
|
-
"mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
2138
|
-
className
|
|
2139
|
-
),
|
|
2140
|
-
...props
|
|
2141
|
-
}
|
|
2142
|
-
));
|
|
2143
|
-
TabsContent.displayName = TabsPrimitive.Content.displayName;
|
|
2144
|
-
var Table = React.forwardRef(
|
|
2145
|
-
({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { className: "relative w-full overflow-auto", children: /* @__PURE__ */ jsx("table", { ref, className: cn("w-full caption-bottom text-sm", className), ...props }) })
|
|
2146
|
-
);
|
|
2147
|
-
Table.displayName = "Table";
|
|
2148
|
-
var TableHeader = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("thead", { ref, className: cn("[&_tr]:border-b", className), ...props }));
|
|
2149
|
-
TableHeader.displayName = "TableHeader";
|
|
2150
|
-
var TableBody = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("tbody", { ref, className: cn("[&_tr:last-child]:border-0", className), ...props }));
|
|
2151
|
-
TableBody.displayName = "TableBody";
|
|
2152
|
-
var TableFooter = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2153
|
-
"tfoot",
|
|
2154
|
-
{
|
|
2155
|
-
ref,
|
|
2156
|
-
className: cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", className),
|
|
2157
|
-
...props
|
|
2158
|
-
}
|
|
2159
|
-
));
|
|
2160
|
-
TableFooter.displayName = "TableFooter";
|
|
2161
|
-
var TableRow = React.forwardRef(
|
|
2162
|
-
({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2163
|
-
"tr",
|
|
2164
|
-
{
|
|
2165
|
-
ref,
|
|
2166
|
-
className: cn(
|
|
2167
|
-
"border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
|
|
2168
|
-
className
|
|
2169
|
-
),
|
|
2170
|
-
...props
|
|
2171
|
-
}
|
|
2172
|
-
)
|
|
2173
|
-
);
|
|
2174
|
-
TableRow.displayName = "TableRow";
|
|
2175
|
-
var TableHead = React.forwardRef(
|
|
2176
|
-
({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2177
|
-
"th",
|
|
2178
|
-
{
|
|
2179
|
-
ref,
|
|
2180
|
-
className: cn(
|
|
2181
|
-
"h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
|
|
2182
|
-
className
|
|
2183
|
-
),
|
|
2184
|
-
...props
|
|
2185
|
-
}
|
|
2186
|
-
)
|
|
2187
|
-
);
|
|
2188
|
-
TableHead.displayName = "TableHead";
|
|
2189
|
-
var TableCell = React.forwardRef(
|
|
2190
|
-
({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2191
|
-
"td",
|
|
2192
|
-
{
|
|
2193
|
-
ref,
|
|
2194
|
-
className: cn(
|
|
2195
|
-
"p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
|
|
2196
|
-
className
|
|
2197
|
-
),
|
|
2198
|
-
...props
|
|
2199
|
-
}
|
|
2200
|
-
)
|
|
2201
|
-
);
|
|
2202
|
-
TableCell.displayName = "TableCell";
|
|
2203
|
-
var TableCaption = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("caption", { ref, className: cn("mt-4 text-sm text-muted-foreground", className), ...props }));
|
|
2204
|
-
TableCaption.displayName = "TableCaption";
|
|
2205
|
-
var Slider = React.forwardRef(
|
|
2206
|
-
({ className, rangeClassName, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
2207
|
-
SliderPrimitive.Root,
|
|
2208
|
-
{
|
|
2209
|
-
ref,
|
|
2210
|
-
className: cn("relative flex w-full touch-none select-none items-center", className),
|
|
2211
|
-
...props,
|
|
2001
|
+
"data-testid": "artifact-canvas",
|
|
2212
2002
|
children: [
|
|
2213
|
-
/* @__PURE__ */
|
|
2214
|
-
|
|
2003
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 border-b border-border bg-secondary/40 px-4 py-2.5", children: [
|
|
2004
|
+
/* @__PURE__ */ jsx(FileText, { className: "size-4 shrink-0 text-ai-accent" }),
|
|
2005
|
+
/* @__PURE__ */ jsx(
|
|
2006
|
+
"span",
|
|
2007
|
+
{
|
|
2008
|
+
className: "min-w-0 flex-1 truncate text-sm font-medium text-foreground",
|
|
2009
|
+
"data-testid": "artifact-title",
|
|
2010
|
+
children: active.title
|
|
2011
|
+
}
|
|
2012
|
+
),
|
|
2013
|
+
isRedline && /* @__PURE__ */ jsxs(Badge, { variant: "accent", className: "gap-1", children: [
|
|
2014
|
+
/* @__PURE__ */ jsx(GitCompareArrows, { className: "size-3" }),
|
|
2015
|
+
" Redline"
|
|
2016
|
+
] }),
|
|
2017
|
+
/* @__PURE__ */ jsxs(Badge, { variant: "secondary", children: [
|
|
2018
|
+
"v",
|
|
2019
|
+
active.version
|
|
2020
|
+
] }),
|
|
2021
|
+
!active.is_complete ? /* @__PURE__ */ jsxs(
|
|
2022
|
+
"span",
|
|
2023
|
+
{
|
|
2024
|
+
className: "inline-flex items-center gap-1 text-xs text-ai-accent",
|
|
2025
|
+
"data-testid": "artifact-streaming",
|
|
2026
|
+
children: [
|
|
2027
|
+
/* @__PURE__ */ jsx(Loader2, { className: "size-3 animate-spin" }),
|
|
2028
|
+
" drafting"
|
|
2029
|
+
]
|
|
2030
|
+
}
|
|
2031
|
+
) : /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
2032
|
+
/* @__PURE__ */ jsx(
|
|
2033
|
+
"button",
|
|
2034
|
+
{
|
|
2035
|
+
onClick: copy,
|
|
2036
|
+
className: "rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground",
|
|
2037
|
+
title: "Copy",
|
|
2038
|
+
"data-testid": "artifact-copy",
|
|
2039
|
+
children: copied ? /* @__PURE__ */ jsx(Check, { className: "size-3.5 text-ai-accent" }) : /* @__PURE__ */ jsx(Copy, { className: "size-3.5" })
|
|
2040
|
+
}
|
|
2041
|
+
),
|
|
2042
|
+
/* @__PURE__ */ jsx(
|
|
2043
|
+
"button",
|
|
2044
|
+
{
|
|
2045
|
+
onClick: download,
|
|
2046
|
+
className: "rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground",
|
|
2047
|
+
title: "Download",
|
|
2048
|
+
"data-testid": "artifact-download",
|
|
2049
|
+
children: /* @__PURE__ */ jsx(Download, { className: "size-3.5" })
|
|
2050
|
+
}
|
|
2051
|
+
)
|
|
2052
|
+
] })
|
|
2053
|
+
] }),
|
|
2054
|
+
artifacts.length > 1 && /* @__PURE__ */ jsx("div", { className: "flex gap-1 overflow-x-auto border-b border-border bg-card px-2 py-1.5", children: artifacts.map((a) => /* @__PURE__ */ jsx(
|
|
2055
|
+
"button",
|
|
2056
|
+
{
|
|
2057
|
+
onClick: () => setActiveId(a.doc_ext_id),
|
|
2058
|
+
className: cn(
|
|
2059
|
+
"shrink-0 rounded-md px-2.5 py-1 text-xs font-medium",
|
|
2060
|
+
a.doc_ext_id === active.doc_ext_id ? "bg-ai-accent-soft text-ai-accent" : "text-muted-foreground hover:bg-accent"
|
|
2061
|
+
),
|
|
2062
|
+
children: a.title.slice(0, 28)
|
|
2063
|
+
},
|
|
2064
|
+
a.doc_ext_id
|
|
2065
|
+
)) }),
|
|
2066
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto bg-ai-surface/40 p-6", children: /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", children: /* @__PURE__ */ jsx(
|
|
2067
|
+
motion.div,
|
|
2068
|
+
{
|
|
2069
|
+
initial: { opacity: 0, y: 6 },
|
|
2070
|
+
animate: { opacity: 1, y: 0 },
|
|
2071
|
+
transition: { duration: 0.2 },
|
|
2072
|
+
className: "mx-auto max-w-2xl rounded-lg bg-card p-8 shadow-sm ring-1 ring-border",
|
|
2073
|
+
children: active.mode === "html" ? /* @__PURE__ */ jsx("div", { className: "text-sm", dangerouslySetInnerHTML: { __html: active.content } }) : active.mode === "text" ? /* @__PURE__ */ jsx("pre", { className: "whitespace-pre-wrap font-mono text-xs text-foreground", children: active.content }) : /* @__PURE__ */ jsx(AiMarkdown, { children: active.content })
|
|
2074
|
+
},
|
|
2075
|
+
active.doc_ext_id
|
|
2076
|
+
) }) })
|
|
2215
2077
|
]
|
|
2216
2078
|
}
|
|
2217
|
-
)
|
|
2218
|
-
);
|
|
2219
|
-
Slider.displayName = SliderPrimitive.Root.displayName;
|
|
2220
|
-
var toggleVariants = cva(
|
|
2221
|
-
"inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
2222
|
-
{
|
|
2223
|
-
variants: {
|
|
2224
|
-
variant: {
|
|
2225
|
-
default: "bg-transparent",
|
|
2226
|
-
outline: "border border-input bg-transparent shadow-sm hover:bg-accent hover:text-accent-foreground"
|
|
2227
|
-
},
|
|
2228
|
-
size: {
|
|
2229
|
-
default: "h-9 px-2 min-w-9",
|
|
2230
|
-
sm: "h-8 px-1.5 min-w-8",
|
|
2231
|
-
lg: "h-10 px-2.5 min-w-10"
|
|
2232
|
-
}
|
|
2233
|
-
},
|
|
2234
|
-
defaultVariants: {
|
|
2235
|
-
variant: "default",
|
|
2236
|
-
size: "default"
|
|
2237
|
-
}
|
|
2238
|
-
}
|
|
2239
|
-
);
|
|
2240
|
-
var Toggle = React.forwardRef(({ className, variant, size, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2241
|
-
TogglePrimitive.Root,
|
|
2242
|
-
{
|
|
2243
|
-
ref,
|
|
2244
|
-
className: cn(toggleVariants({ variant, size, className })),
|
|
2245
|
-
...props
|
|
2246
|
-
}
|
|
2247
|
-
));
|
|
2248
|
-
Toggle.displayName = TogglePrimitive.Root.displayName;
|
|
2249
|
-
var ToggleGroupContext = React.createContext({
|
|
2250
|
-
size: "default",
|
|
2251
|
-
variant: "default"
|
|
2252
|
-
});
|
|
2253
|
-
var ToggleGroup = React.forwardRef(({ className, variant, size, children, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2254
|
-
ToggleGroupPrimitive.Root,
|
|
2255
|
-
{
|
|
2256
|
-
ref,
|
|
2257
|
-
className: cn("flex items-center justify-center gap-1", className),
|
|
2258
|
-
...props,
|
|
2259
|
-
children: /* @__PURE__ */ jsx(ToggleGroupContext.Provider, { value: { variant, size }, children })
|
|
2260
|
-
}
|
|
2261
|
-
));
|
|
2262
|
-
ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;
|
|
2263
|
-
var ToggleGroupItem = React.forwardRef(({ className, children, variant, size, ...props }, ref) => {
|
|
2264
|
-
const context = React.useContext(ToggleGroupContext);
|
|
2265
|
-
return /* @__PURE__ */ jsx(
|
|
2266
|
-
ToggleGroupPrimitive.Item,
|
|
2267
|
-
{
|
|
2268
|
-
ref,
|
|
2269
|
-
className: cn(
|
|
2270
|
-
toggleVariants({
|
|
2271
|
-
variant: context.variant || variant,
|
|
2272
|
-
size: context.size || size
|
|
2273
|
-
}),
|
|
2274
|
-
className
|
|
2275
|
-
),
|
|
2276
|
-
...props,
|
|
2277
|
-
children
|
|
2278
|
-
}
|
|
2279
2079
|
);
|
|
2280
|
-
}
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
2292
|
-
className
|
|
2293
|
-
),
|
|
2294
|
-
...props
|
|
2295
|
-
}
|
|
2296
|
-
));
|
|
2297
|
-
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
2298
|
-
var DialogContent = React.forwardRef(({ className, children, hideCloseButton, ...props }, ref) => /* @__PURE__ */ jsxs(DialogPortal, { children: [
|
|
2299
|
-
/* @__PURE__ */ jsx(DialogOverlay, {}),
|
|
2300
|
-
/* @__PURE__ */ jsxs(
|
|
2301
|
-
DialogPrimitive.Content,
|
|
2080
|
+
}
|
|
2081
|
+
function MessageArtifactCard({
|
|
2082
|
+
artifact,
|
|
2083
|
+
onOpen
|
|
2084
|
+
}) {
|
|
2085
|
+
const { docExtId, title, isComplete, mode } = artifact;
|
|
2086
|
+
const isImage = mode === "image";
|
|
2087
|
+
const Icon = isImage ? Image$1 : FileText;
|
|
2088
|
+
const statusText = isImage ? isComplete ? "Image ready" : "Generating\u2026" : isComplete ? "Draft ready" : "Drafting\u2026";
|
|
2089
|
+
return /* @__PURE__ */ jsxs(
|
|
2090
|
+
Card,
|
|
2302
2091
|
{
|
|
2303
|
-
|
|
2304
|
-
className:
|
|
2305
|
-
|
|
2306
|
-
className
|
|
2307
|
-
),
|
|
2308
|
-
...props,
|
|
2092
|
+
variant: "outline",
|
|
2093
|
+
className: "mt-3 flex items-center gap-3 px-3 py-2.5",
|
|
2094
|
+
"data-testid": `message-artifact-card-${docExtId}`,
|
|
2309
2095
|
children: [
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2096
|
+
/* @__PURE__ */ jsx(Icon, { className: "h-4 w-4 shrink-0 text-muted-foreground", "aria-hidden": true }),
|
|
2097
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
2098
|
+
/* @__PURE__ */ jsx(
|
|
2099
|
+
"div",
|
|
2100
|
+
{
|
|
2101
|
+
className: "truncate text-chat font-semibold text-foreground",
|
|
2102
|
+
"data-testid": "artifact-title",
|
|
2103
|
+
children: title || (isImage ? "Generated image" : "Untitled draft")
|
|
2104
|
+
}
|
|
2105
|
+
),
|
|
2106
|
+
/* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground", "data-testid": "artifact-status", children: statusText })
|
|
2107
|
+
] }),
|
|
2108
|
+
/* @__PURE__ */ jsx(
|
|
2109
|
+
"button",
|
|
2313
2110
|
{
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
]
|
|
2111
|
+
type: "button",
|
|
2112
|
+
onClick: () => onOpen(docExtId),
|
|
2113
|
+
className: "shrink-0 rounded-md bg-secondary/15 px-3 py-1.5 text-sm font-semibold text-secondary transition-colors hover:bg-secondary/25",
|
|
2114
|
+
"data-testid": `view-artifact-button-${docExtId}`,
|
|
2115
|
+
children: isImage ? "View image" : "View draft"
|
|
2320
2116
|
}
|
|
2321
2117
|
)
|
|
2322
2118
|
]
|
|
2323
2119
|
}
|
|
2324
|
-
)
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
);
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
className: cn("text-lg font-semibold leading-none tracking-tight", className),
|
|
2342
|
-
...props
|
|
2343
|
-
}
|
|
2344
|
-
));
|
|
2345
|
-
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
2346
|
-
var DialogDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2347
|
-
DialogPrimitive.Description,
|
|
2348
|
-
{
|
|
2349
|
-
ref,
|
|
2350
|
-
className: cn("text-sm text-muted-foreground", className),
|
|
2351
|
-
...props
|
|
2352
|
-
}
|
|
2353
|
-
));
|
|
2354
|
-
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
2355
|
-
var Popover = PopoverPrimitive.Root;
|
|
2356
|
-
var PopoverTrigger = PopoverPrimitive.Trigger;
|
|
2357
|
-
var PopoverAnchor = PopoverPrimitive.Anchor;
|
|
2358
|
-
var PopoverContent = React.forwardRef(({ className, align = "center", sideOffset = 4, container, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { container: container ?? void 0, children: /* @__PURE__ */ jsx(
|
|
2359
|
-
PopoverPrimitive.Content,
|
|
2360
|
-
{
|
|
2361
|
-
ref,
|
|
2362
|
-
align,
|
|
2363
|
-
sideOffset,
|
|
2364
|
-
className: cn(
|
|
2365
|
-
"z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]",
|
|
2366
|
-
className
|
|
2367
|
-
),
|
|
2368
|
-
...props
|
|
2369
|
-
}
|
|
2370
|
-
) }));
|
|
2371
|
-
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
2372
|
-
var DropdownMenu = DropdownMenuPrimitive.Root;
|
|
2373
|
-
var DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
2374
|
-
var DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
|
2375
|
-
var DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
|
2376
|
-
var DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
|
2377
|
-
var DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
2378
|
-
var DropdownMenuSubTrigger = React.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
2379
|
-
DropdownMenuPrimitive.SubTrigger,
|
|
2380
|
-
{
|
|
2381
|
-
ref,
|
|
2382
|
-
className: cn(
|
|
2383
|
-
"flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
2384
|
-
inset && "pl-8",
|
|
2385
|
-
className
|
|
2386
|
-
),
|
|
2387
|
-
...props,
|
|
2388
|
-
children: [
|
|
2389
|
-
children,
|
|
2390
|
-
/* @__PURE__ */ jsx(ChevronRight, { className: "ml-auto" })
|
|
2391
|
-
]
|
|
2392
|
-
}
|
|
2393
|
-
));
|
|
2394
|
-
DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
|
|
2395
|
-
var DropdownMenuSubContent = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2396
|
-
DropdownMenuPrimitive.SubContent,
|
|
2397
|
-
{
|
|
2398
|
-
ref,
|
|
2399
|
-
className: cn(
|
|
2400
|
-
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",
|
|
2401
|
-
className
|
|
2402
|
-
),
|
|
2403
|
-
...props
|
|
2404
|
-
}
|
|
2405
|
-
));
|
|
2406
|
-
DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
|
|
2407
|
-
var DropdownMenuContent = React.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
2408
|
-
DropdownMenuPrimitive.Content,
|
|
2409
|
-
{
|
|
2410
|
-
ref,
|
|
2411
|
-
sideOffset,
|
|
2412
|
-
className: cn(
|
|
2413
|
-
"z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md",
|
|
2414
|
-
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",
|
|
2415
|
-
className
|
|
2416
|
-
),
|
|
2417
|
-
...props
|
|
2418
|
-
}
|
|
2419
|
-
) }));
|
|
2420
|
-
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
|
2421
|
-
var DropdownMenuItem = React.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2422
|
-
DropdownMenuPrimitive.Item,
|
|
2423
|
-
{
|
|
2424
|
-
ref,
|
|
2425
|
-
className: cn(
|
|
2426
|
-
"relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",
|
|
2427
|
-
inset && "pl-8",
|
|
2428
|
-
className
|
|
2429
|
-
),
|
|
2430
|
-
...props
|
|
2431
|
-
}
|
|
2432
|
-
));
|
|
2433
|
-
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
|
|
2434
|
-
var DropdownMenuCheckboxItem = React.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
2435
|
-
DropdownMenuPrimitive.CheckboxItem,
|
|
2436
|
-
{
|
|
2437
|
-
ref,
|
|
2438
|
-
className: cn(
|
|
2439
|
-
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
2440
|
-
className
|
|
2441
|
-
),
|
|
2442
|
-
checked,
|
|
2443
|
-
...props,
|
|
2444
|
-
children: [
|
|
2445
|
-
/* @__PURE__ */ jsx("span", { className: "absolute left-2 flex h-4 w-4 items-center justify-center rounded border border-border bg-popover", children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(Check, { className: "h-3.5 w-3.5 text-primary" }) }) }),
|
|
2446
|
-
children
|
|
2447
|
-
]
|
|
2448
|
-
}
|
|
2449
|
-
));
|
|
2450
|
-
DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
|
|
2451
|
-
var DropdownMenuRadioItem = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
2452
|
-
DropdownMenuPrimitive.RadioItem,
|
|
2453
|
-
{
|
|
2454
|
-
ref,
|
|
2455
|
-
className: cn(
|
|
2456
|
-
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
2457
|
-
className
|
|
2458
|
-
),
|
|
2459
|
-
...props,
|
|
2460
|
-
children: [
|
|
2461
|
-
/* @__PURE__ */ jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(Circle, { className: "h-2 w-2 fill-current" }) }) }),
|
|
2462
|
-
children
|
|
2463
|
-
]
|
|
2464
|
-
}
|
|
2465
|
-
));
|
|
2466
|
-
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
|
|
2467
|
-
var DropdownMenuLabel = React.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2468
|
-
DropdownMenuPrimitive.Label,
|
|
2469
|
-
{
|
|
2470
|
-
ref,
|
|
2471
|
-
className: cn("px-2 py-1.5 text-sm font-semibold", inset && "pl-8", className),
|
|
2472
|
-
...props
|
|
2473
|
-
}
|
|
2474
|
-
));
|
|
2475
|
-
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
|
|
2476
|
-
var DropdownMenuSeparator = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2477
|
-
DropdownMenuPrimitive.Separator,
|
|
2478
|
-
{
|
|
2479
|
-
ref,
|
|
2480
|
-
className: cn("-mx-1 my-1 h-px bg-muted", className),
|
|
2481
|
-
...props
|
|
2482
|
-
}
|
|
2483
|
-
));
|
|
2484
|
-
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
|
|
2485
|
-
var DropdownMenuShortcut = ({ className, ...props }) => {
|
|
2486
|
-
return /* @__PURE__ */ jsx("span", { className: cn("ml-auto text-sm tracking-widest opacity-60", className), ...props });
|
|
2487
|
-
};
|
|
2488
|
-
DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
|
|
2489
|
-
var Select = SelectPrimitive.Root;
|
|
2490
|
-
var SelectGroup = SelectPrimitive.Group;
|
|
2491
|
-
var SelectValue = SelectPrimitive.Value;
|
|
2492
|
-
var SelectTrigger = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
2493
|
-
SelectPrimitive.Trigger,
|
|
2494
|
-
{
|
|
2495
|
-
ref,
|
|
2496
|
-
className: cn(
|
|
2497
|
-
"flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
|
|
2498
|
-
className
|
|
2499
|
-
),
|
|
2500
|
-
...props,
|
|
2501
|
-
children: [
|
|
2502
|
-
children,
|
|
2503
|
-
/* @__PURE__ */ jsx(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 opacity-50" }) })
|
|
2504
|
-
]
|
|
2505
|
-
}
|
|
2506
|
-
));
|
|
2507
|
-
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
2508
|
-
var SelectScrollUpButton = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2509
|
-
SelectPrimitive.ScrollUpButton,
|
|
2510
|
-
{
|
|
2511
|
-
ref,
|
|
2512
|
-
className: cn("flex cursor-default items-center justify-center py-1", className),
|
|
2513
|
-
...props,
|
|
2514
|
-
children: /* @__PURE__ */ jsx(ChevronUp, { className: "h-4 w-4" })
|
|
2515
|
-
}
|
|
2516
|
-
));
|
|
2517
|
-
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
2518
|
-
var SelectScrollDownButton = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2519
|
-
SelectPrimitive.ScrollDownButton,
|
|
2520
|
-
{
|
|
2521
|
-
ref,
|
|
2522
|
-
className: cn("flex cursor-default items-center justify-center py-1", className),
|
|
2523
|
-
...props,
|
|
2524
|
-
children: /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4" })
|
|
2525
|
-
}
|
|
2526
|
-
));
|
|
2527
|
-
SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
|
|
2528
|
-
var SelectContent = React.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
|
|
2529
|
-
SelectPrimitive.Content,
|
|
2530
|
-
{
|
|
2531
|
-
ref,
|
|
2532
|
-
className: cn(
|
|
2533
|
-
"relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
2534
|
-
position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
|
2535
|
-
className
|
|
2536
|
-
),
|
|
2537
|
-
position,
|
|
2538
|
-
...props,
|
|
2539
|
-
children: [
|
|
2540
|
-
/* @__PURE__ */ jsx(SelectScrollUpButton, {}),
|
|
2120
|
+
);
|
|
2121
|
+
}
|
|
2122
|
+
function DocSearch({
|
|
2123
|
+
docIds,
|
|
2124
|
+
onOpenDoc,
|
|
2125
|
+
placeholder = "Semantic search across your documents\u2026",
|
|
2126
|
+
className
|
|
2127
|
+
}) {
|
|
2128
|
+
const { results, status, error, search, isRunning, query } = useSemanticSearch(docIds);
|
|
2129
|
+
const [value, setValue] = useState("");
|
|
2130
|
+
const submit = () => {
|
|
2131
|
+
if (value.trim()) void search(value, "hybrid");
|
|
2132
|
+
};
|
|
2133
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("space-y-3", className), "data-testid": "doc-search", children: [
|
|
2134
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
2135
|
+
/* @__PURE__ */ jsx(Search, { className: "pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground" }),
|
|
2136
|
+
isRunning && /* @__PURE__ */ jsx(Loader2, { className: "absolute right-3 top-1/2 size-4 -translate-y-1/2 animate-spin text-ai-accent" }),
|
|
2541
2137
|
/* @__PURE__ */ jsx(
|
|
2542
|
-
|
|
2138
|
+
"input",
|
|
2543
2139
|
{
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
),
|
|
2551
|
-
/* @__PURE__ */ jsx(SelectScrollDownButton, {})
|
|
2552
|
-
]
|
|
2553
|
-
}
|
|
2554
|
-
) }));
|
|
2555
|
-
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
2556
|
-
var SelectLabel = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2557
|
-
SelectPrimitive.Label,
|
|
2558
|
-
{
|
|
2559
|
-
ref,
|
|
2560
|
-
className: cn("py-1.5 pl-8 pr-2 text-sm font-semibold", className),
|
|
2561
|
-
...props
|
|
2562
|
-
}
|
|
2563
|
-
));
|
|
2564
|
-
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
2565
|
-
var SelectItem = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
2566
|
-
SelectPrimitive.Item,
|
|
2567
|
-
{
|
|
2568
|
-
ref,
|
|
2569
|
-
className: cn(
|
|
2570
|
-
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
2571
|
-
className
|
|
2572
|
-
),
|
|
2573
|
-
...props,
|
|
2574
|
-
children: [
|
|
2575
|
-
/* @__PURE__ */ jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }) }) }),
|
|
2576
|
-
/* @__PURE__ */ jsx(SelectPrimitive.ItemText, { children })
|
|
2577
|
-
]
|
|
2578
|
-
}
|
|
2579
|
-
));
|
|
2580
|
-
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
2581
|
-
var SelectSeparator = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2582
|
-
SelectPrimitive.Separator,
|
|
2583
|
-
{
|
|
2584
|
-
ref,
|
|
2585
|
-
className: cn("-mx-1 my-1 h-px bg-muted", className),
|
|
2586
|
-
...props
|
|
2587
|
-
}
|
|
2588
|
-
));
|
|
2589
|
-
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
2590
|
-
var Command = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2591
|
-
Command$1,
|
|
2592
|
-
{
|
|
2593
|
-
ref,
|
|
2594
|
-
className: cn(
|
|
2595
|
-
"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
|
|
2596
|
-
className
|
|
2597
|
-
),
|
|
2598
|
-
...props
|
|
2599
|
-
}
|
|
2600
|
-
));
|
|
2601
|
-
Command.displayName = Command$1.displayName;
|
|
2602
|
-
var CommandDialog = ({ children, ...props }) => {
|
|
2603
|
-
return /* @__PURE__ */ jsx(Dialog, { ...props, children: /* @__PURE__ */ jsx(DialogContent, { className: "overflow-hidden p-0", children: /* @__PURE__ */ jsx(Command, { className: "[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5", children }) }) });
|
|
2604
|
-
};
|
|
2605
|
-
var CommandInput = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxs("div", { className: "flex items-center border-b px-3", "data-cmdk-input-wrapper": "", children: [
|
|
2606
|
-
/* @__PURE__ */ jsx(Search, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
|
|
2607
|
-
/* @__PURE__ */ jsx(
|
|
2608
|
-
Command$1.Input,
|
|
2609
|
-
{
|
|
2610
|
-
ref,
|
|
2611
|
-
className: cn(
|
|
2612
|
-
"flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
|
|
2613
|
-
className
|
|
2614
|
-
),
|
|
2615
|
-
...props
|
|
2616
|
-
}
|
|
2617
|
-
)
|
|
2618
|
-
] }));
|
|
2619
|
-
CommandInput.displayName = Command$1.Input.displayName;
|
|
2620
|
-
var CommandList = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2621
|
-
Command$1.List,
|
|
2622
|
-
{
|
|
2623
|
-
ref,
|
|
2624
|
-
className: cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className),
|
|
2625
|
-
...props
|
|
2626
|
-
}
|
|
2627
|
-
));
|
|
2628
|
-
CommandList.displayName = Command$1.List.displayName;
|
|
2629
|
-
var CommandEmpty = React.forwardRef((props, ref) => /* @__PURE__ */ jsx(Command$1.Empty, { ref, className: "py-6 text-center text-sm", ...props }));
|
|
2630
|
-
CommandEmpty.displayName = Command$1.Empty.displayName;
|
|
2631
|
-
var CommandGroup = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2632
|
-
Command$1.Group,
|
|
2633
|
-
{
|
|
2634
|
-
ref,
|
|
2635
|
-
className: cn(
|
|
2636
|
-
"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-sm [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
|
|
2637
|
-
className
|
|
2638
|
-
),
|
|
2639
|
-
...props
|
|
2640
|
-
}
|
|
2641
|
-
));
|
|
2642
|
-
CommandGroup.displayName = Command$1.Group.displayName;
|
|
2643
|
-
var CommandSeparator = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2644
|
-
Command$1.Separator,
|
|
2645
|
-
{
|
|
2646
|
-
ref,
|
|
2647
|
-
className: cn("-mx-1 h-px bg-border", className),
|
|
2648
|
-
...props
|
|
2649
|
-
}
|
|
2650
|
-
));
|
|
2651
|
-
CommandSeparator.displayName = Command$1.Separator.displayName;
|
|
2652
|
-
var CommandItem = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2653
|
-
Command$1.Item,
|
|
2654
|
-
{
|
|
2655
|
-
ref,
|
|
2656
|
-
className: cn(
|
|
2657
|
-
"relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
2658
|
-
className
|
|
2659
|
-
),
|
|
2660
|
-
...props
|
|
2661
|
-
}
|
|
2662
|
-
));
|
|
2663
|
-
CommandItem.displayName = Command$1.Item.displayName;
|
|
2664
|
-
var CommandShortcut = ({ className, ...props }) => {
|
|
2665
|
-
return /* @__PURE__ */ jsx(
|
|
2666
|
-
"span",
|
|
2667
|
-
{
|
|
2668
|
-
className: cn("ml-auto text-sm tracking-widest text-muted-foreground", className),
|
|
2669
|
-
...props
|
|
2670
|
-
}
|
|
2671
|
-
);
|
|
2672
|
-
};
|
|
2673
|
-
CommandShortcut.displayName = "CommandShortcut";
|
|
2674
|
-
function useWorkspaceDocs(workspaceId) {
|
|
2675
|
-
const { data: docs = [], isLoading, isError } = useDocuments(workspaceId);
|
|
2676
|
-
const docIds = useMemo(
|
|
2677
|
-
() => docs.map((d) => d.external_id).filter((id) => !!id),
|
|
2678
|
-
[docs]
|
|
2679
|
-
);
|
|
2680
|
-
return { wsId: workspaceId, docs, docIds, isLoading, isError, ready: docIds.length > 0 };
|
|
2681
|
-
}
|
|
2682
|
-
function useAiTask() {
|
|
2683
|
-
const mutation = useAssistantQuery();
|
|
2684
|
-
const [status, setStatus] = useState("idle");
|
|
2685
|
-
const [text, setText] = useState("");
|
|
2686
|
-
const [stepCount, setStepCount] = useState(0);
|
|
2687
|
-
const [error, setError] = useState(null);
|
|
2688
|
-
const [responseId, setResponseId] = useState(null);
|
|
2689
|
-
const [artifacts, setArtifacts] = useState([]);
|
|
2690
|
-
const bufferRef = useRef("");
|
|
2691
|
-
const artifactsRef = useRef(/* @__PURE__ */ new Map());
|
|
2692
|
-
const reset = useCallback(() => {
|
|
2693
|
-
setStatus("idle");
|
|
2694
|
-
setText("");
|
|
2695
|
-
setStepCount(0);
|
|
2696
|
-
setError(null);
|
|
2697
|
-
setResponseId(null);
|
|
2698
|
-
setArtifacts([]);
|
|
2699
|
-
artifactsRef.current = /* @__PURE__ */ new Map();
|
|
2700
|
-
bufferRef.current = "";
|
|
2701
|
-
}, []);
|
|
2702
|
-
const run = useCallback(
|
|
2703
|
-
async (question, docIds, opts) => {
|
|
2704
|
-
setStatus("running");
|
|
2705
|
-
setText("");
|
|
2706
|
-
setStepCount(0);
|
|
2707
|
-
setError(null);
|
|
2708
|
-
setArtifacts([]);
|
|
2709
|
-
artifactsRef.current = /* @__PURE__ */ new Map();
|
|
2710
|
-
bufferRef.current = "";
|
|
2711
|
-
let streamError = null;
|
|
2712
|
-
try {
|
|
2713
|
-
const result = await mutation.mutateAsync({
|
|
2714
|
-
question,
|
|
2715
|
-
docIds,
|
|
2716
|
-
previousResponseId: opts?.previousResponseId ?? void 0,
|
|
2717
|
-
model: opts?.model,
|
|
2718
|
-
onToken: (c) => {
|
|
2719
|
-
bufferRef.current += c;
|
|
2720
|
-
setText(bufferRef.current);
|
|
2721
|
-
},
|
|
2722
|
-
onAgentStep: () => setStepCount((n) => n + 1),
|
|
2723
|
-
onArtifact: (a) => {
|
|
2724
|
-
artifactsRef.current.set(a.doc_ext_id, a);
|
|
2725
|
-
setArtifacts([...artifactsRef.current.values()]);
|
|
2726
|
-
},
|
|
2727
|
-
onError: (m) => {
|
|
2728
|
-
streamError = m;
|
|
2729
|
-
}
|
|
2730
|
-
});
|
|
2731
|
-
const finalText = result.text || bufferRef.current;
|
|
2732
|
-
setText(finalText);
|
|
2733
|
-
setResponseId(result.assistantMessageExtId);
|
|
2734
|
-
setStepCount(result.agentSteps.length || 0);
|
|
2735
|
-
if (result.artifacts?.length) {
|
|
2736
|
-
for (const a of result.artifacts) artifactsRef.current.set(a.doc_ext_id, a);
|
|
2737
|
-
setArtifacts([...artifactsRef.current.values()]);
|
|
2140
|
+
value,
|
|
2141
|
+
onChange: (e) => setValue(e.target.value),
|
|
2142
|
+
onKeyDown: (e) => e.key === "Enter" && (e.preventDefault(), submit()),
|
|
2143
|
+
placeholder,
|
|
2144
|
+
className: "h-11 w-full rounded-lg border border-input bg-background pl-9 pr-24 text-sm outline-none focus:border-ai-accent/50 focus:ring-2 focus:ring-ai-accent/15",
|
|
2145
|
+
"data-testid": "doc-search-input"
|
|
2738
2146
|
}
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2147
|
+
),
|
|
2148
|
+
/* @__PURE__ */ jsxs(
|
|
2149
|
+
"button",
|
|
2150
|
+
{
|
|
2151
|
+
type: "button",
|
|
2152
|
+
onClick: submit,
|
|
2153
|
+
className: "absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-1 rounded-md bg-ai-accent px-2.5 py-1 text-xs font-medium text-ai-accent-foreground",
|
|
2154
|
+
"data-testid": "doc-search-submit",
|
|
2155
|
+
children: [
|
|
2156
|
+
"Search ",
|
|
2157
|
+
/* @__PURE__ */ jsx(CornerDownLeft, { className: "size-3" })
|
|
2158
|
+
]
|
|
2745
2159
|
}
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2160
|
+
)
|
|
2161
|
+
] }),
|
|
2162
|
+
status === "error" && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", "data-testid": "doc-search-error", children: error }),
|
|
2163
|
+
status === "done" && /* @__PURE__ */ jsxs("div", { className: "space-y-2", "data-testid": "doc-search-results", children: [
|
|
2164
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: results.length === 0 ? `No passages matched \u201C${query}\u201D.` : `${results.length} passage${results.length === 1 ? "" : "s"} for \u201C${query}\u201D` }),
|
|
2165
|
+
results.slice(0, 8).map((r, i) => /* @__PURE__ */ jsxs(
|
|
2166
|
+
Card,
|
|
2167
|
+
{
|
|
2168
|
+
variant: "elevated",
|
|
2169
|
+
className: cn(
|
|
2170
|
+
"rounded-xl p-3",
|
|
2171
|
+
onOpenDoc && r.docId && "cursor-pointer transition-colors hover:border-ai-accent/40"
|
|
2172
|
+
),
|
|
2173
|
+
onClick: () => r.docId && onOpenDoc?.(r.docId),
|
|
2174
|
+
"data-testid": `doc-search-hit-${i}`,
|
|
2175
|
+
children: [
|
|
2176
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-1 flex items-center gap-2", children: [
|
|
2177
|
+
/* @__PURE__ */ jsx(FileText, { className: "size-3.5 text-ai-accent" }),
|
|
2178
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-xs font-medium text-foreground", children: r.docTitle ?? "Document" }),
|
|
2179
|
+
r.page != null && /* @__PURE__ */ jsxs(Badge, { variant: "secondary", children: [
|
|
2180
|
+
"p.",
|
|
2181
|
+
r.page
|
|
2182
|
+
] }),
|
|
2183
|
+
r.score != null && /* @__PURE__ */ jsxs("span", { className: "ml-auto text-[10px] text-muted-foreground", children: [
|
|
2184
|
+
"score ",
|
|
2185
|
+
r.score.toFixed(2)
|
|
2186
|
+
] })
|
|
2187
|
+
] }),
|
|
2188
|
+
/* @__PURE__ */ jsx("p", { className: "line-clamp-3 text-xs leading-relaxed text-muted-foreground", children: r.content })
|
|
2189
|
+
]
|
|
2190
|
+
},
|
|
2191
|
+
`${r.docId}-${r.page}-${i}`
|
|
2192
|
+
))
|
|
2193
|
+
] })
|
|
2194
|
+
] });
|
|
2767
2195
|
}
|
|
2768
|
-
function
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2196
|
+
var EntityPill = forwardRef(function EntityPill2({
|
|
2197
|
+
icon,
|
|
2198
|
+
label,
|
|
2199
|
+
secondaryText,
|
|
2200
|
+
size = "sm",
|
|
2201
|
+
shape = "rounded",
|
|
2202
|
+
className,
|
|
2203
|
+
labelMaxWidth = "max-w-[320px]",
|
|
2204
|
+
labelClassName,
|
|
2205
|
+
fullWidth = false,
|
|
2206
|
+
highlight = false,
|
|
2207
|
+
onClick,
|
|
2208
|
+
onIconClick,
|
|
2209
|
+
onMoreClick,
|
|
2210
|
+
moreContent,
|
|
2211
|
+
href,
|
|
2212
|
+
disabled = false,
|
|
2213
|
+
tooltipContent,
|
|
2214
|
+
tooltipSide = "bottom",
|
|
2215
|
+
"data-testid": testId
|
|
2216
|
+
}, ref) {
|
|
2217
|
+
const shapeClass = shape === "pill" ? "rounded-full" : "rounded-md";
|
|
2218
|
+
const sizeClasses2 = size === "base" ? "gap-1.5 px-1.5 py-0.5" : "gap-1 px-1";
|
|
2219
|
+
const textSizeClass = size === "base" ? "text-base" : "text-sm";
|
|
2220
|
+
const baseClasses = cn(
|
|
2221
|
+
"group/pill items-center",
|
|
2222
|
+
fullWidth ? "flex w-full" : "inline-flex",
|
|
2223
|
+
sizeClasses2,
|
|
2224
|
+
shapeClass,
|
|
2225
|
+
"bg-muted",
|
|
2226
|
+
"border border-border",
|
|
2227
|
+
"transition-all",
|
|
2228
|
+
className
|
|
2229
|
+
);
|
|
2230
|
+
const interactiveClasses = "cursor-pointer hover:bg-muted/80";
|
|
2231
|
+
const disabledClasses = "cursor-default opacity-60";
|
|
2232
|
+
const highlightClasses = "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground";
|
|
2233
|
+
const mainContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2234
|
+
onIconClick ? /* @__PURE__ */ jsx(
|
|
2235
|
+
"span",
|
|
2236
|
+
{
|
|
2237
|
+
role: "button",
|
|
2238
|
+
tabIndex: 0,
|
|
2239
|
+
className: "flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity",
|
|
2240
|
+
onClick: (e) => {
|
|
2241
|
+
e.stopPropagation();
|
|
2242
|
+
onIconClick(e);
|
|
2243
|
+
},
|
|
2244
|
+
children: icon
|
|
2782
2245
|
}
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
content: c.content
|
|
2795
|
-
})
|
|
2796
|
-
).sort((a, b) => (b.score ?? 0) - (a.score ?? 0));
|
|
2797
|
-
setResults(chunks);
|
|
2798
|
-
setStatus("done");
|
|
2799
|
-
} catch (e) {
|
|
2800
|
-
setError(e instanceof Error ? e.message : "Search failed.");
|
|
2801
|
-
setStatus("error");
|
|
2246
|
+
) : icon,
|
|
2247
|
+
/* @__PURE__ */ jsx(
|
|
2248
|
+
"span",
|
|
2249
|
+
{
|
|
2250
|
+
className: cn(
|
|
2251
|
+
textSizeClass,
|
|
2252
|
+
"font-medium truncate leading-tight min-w-0",
|
|
2253
|
+
labelMaxWidth,
|
|
2254
|
+
labelClassName
|
|
2255
|
+
),
|
|
2256
|
+
children: label
|
|
2802
2257
|
}
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
);
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
if (
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
return {
|
|
2828
|
-
type: "arbi.artifact",
|
|
2829
|
-
doc_ext_id: opts?.id ?? `local-${title.replace(/\W+/g, "-").toLowerCase()}`,
|
|
2830
|
-
title,
|
|
2831
|
-
mode: opts?.mode ?? "markdown",
|
|
2832
|
-
content,
|
|
2833
|
-
// Content-backed (markdown/text/html) artifacts carry no blob; file_type is
|
|
2834
|
-
// required on ArtifactEvent and defaults to "" for non-image artifacts.
|
|
2835
|
-
file_type: "",
|
|
2836
|
-
is_complete: opts?.isComplete ?? true,
|
|
2837
|
-
version: opts?.version ?? 1,
|
|
2838
|
-
message_ext_id: null,
|
|
2839
|
-
t: null
|
|
2840
|
-
};
|
|
2841
|
-
}
|
|
2842
|
-
var markdownBaseComponents = {
|
|
2843
|
-
h1: ({ children, ...props }) => /* @__PURE__ */ jsx("h1", { className: "text-lg font-semibold", "data-testid": "markdown-heading-1", ...props, children }),
|
|
2844
|
-
h2: ({ children, ...props }) => /* @__PURE__ */ jsx("h2", { className: "font-semibold text-base", "data-testid": "markdown-heading-2", ...props, children }),
|
|
2845
|
-
h3: ({ children, ...props }) => /* @__PURE__ */ jsx("h3", { className: "font-semibold text-base", "data-testid": "markdown-heading-3", ...props, children }),
|
|
2846
|
-
h4: ({ children, ...props }) => /* @__PURE__ */ jsx("h4", { className: "font-semibold text-base", ...props, children }),
|
|
2847
|
-
h5: ({ children, ...props }) => /* @__PURE__ */ jsx("h5", { className: "font-medium", ...props, children }),
|
|
2848
|
-
strong: ({ children, ...props }) => /* @__PURE__ */ jsx("strong", { className: "font-semibold", ...props, children }),
|
|
2849
|
-
blockquote: ({ children, ...props }) => /* @__PURE__ */ jsx("blockquote", { className: "border-l-2 border-primary pl-4", ...props, children }),
|
|
2850
|
-
ol: ({ children, ...props }) => /* @__PURE__ */ jsx("ol", { className: "list-decimal space-y-2 pl-6", "data-testid": "markdown-ordered-list", ...props, children }),
|
|
2851
|
-
ul: ({ children, ...props }) => /* @__PURE__ */ jsx("ul", { className: "list-none space-y-2 pl-6", "data-testid": "markdown-unordered-list", ...props, children }),
|
|
2852
|
-
li: ({ children, ...props }) => /* @__PURE__ */ jsx("li", { className: "my-1.5", ...props, children }),
|
|
2853
|
-
table: ({ children, ...props }) => /* @__PURE__ */ jsx("table", { "data-testid": "markdown-table", ...props, children }),
|
|
2854
|
-
th: ({ children, ...props }) => /* @__PURE__ */ jsx("th", { ...props, children }),
|
|
2855
|
-
td: ({ children, ...props }) => /* @__PURE__ */ jsx("td", { ...props, children }),
|
|
2856
|
-
tr: ({ children, ...props }) => /* @__PURE__ */ jsx("tr", { ...props, children }),
|
|
2857
|
-
p: ({ children, ...props }) => /* @__PURE__ */ jsx("p", { className: "whitespace-pre-wrap", ...props, children }),
|
|
2858
|
-
hr: (props) => /* @__PURE__ */ jsx("hr", { className: "border-foreground/20", ...props }),
|
|
2859
|
-
sup: ({ children, ...props }) => /* @__PURE__ */ jsx("sup", { className: "text-xs", ...props, children }),
|
|
2860
|
-
sub: ({ children, ...props }) => /* @__PURE__ */ jsx("sub", { className: "text-xs", ...props, children }),
|
|
2861
|
-
div: ({ children, className, ...props }) => /* @__PURE__ */ jsx("div", { className, ...props, children }),
|
|
2862
|
-
br: (props) => /* @__PURE__ */ jsx("br", { ...props }),
|
|
2863
|
-
kbd: ({ children, ...props }) => /* @__PURE__ */ jsx(
|
|
2864
|
-
"kbd",
|
|
2865
|
-
{
|
|
2866
|
-
className: "px-1.5 py-0.5 text-xs font-mono bg-muted border border-border rounded",
|
|
2867
|
-
...props,
|
|
2868
|
-
children
|
|
2869
|
-
}
|
|
2870
|
-
),
|
|
2871
|
-
abbr: ({ children, title, ...props }) => /* @__PURE__ */ jsx("abbr", { title, className: "underline decoration-dotted cursor-help", ...props, children }),
|
|
2872
|
-
cite: ({ children, ...props }) => /* @__PURE__ */ jsx("cite", { className: "italic", ...props, children })
|
|
2873
|
-
};
|
|
2874
|
-
function AiMarkdown({ children, className }) {
|
|
2875
|
-
return /* @__PURE__ */ jsx(
|
|
2876
|
-
"div",
|
|
2877
|
-
{
|
|
2878
|
-
className: cn("text-sm leading-relaxed text-foreground", className),
|
|
2879
|
-
"data-testid": "ai-markdown",
|
|
2880
|
-
children: /* @__PURE__ */ jsx(
|
|
2881
|
-
ReactMarkdown,
|
|
2258
|
+
),
|
|
2259
|
+
secondaryText && /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground flex-shrink-0 leading-none", children: secondaryText })
|
|
2260
|
+
] });
|
|
2261
|
+
const tooltipWrap = (content, tip, side = tooltipSide, triggerClassName, triggerProps) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
2262
|
+
/* @__PURE__ */ jsx(
|
|
2263
|
+
TooltipTrigger,
|
|
2264
|
+
{
|
|
2265
|
+
onFocusCapture: (e) => e.stopPropagation(),
|
|
2266
|
+
className: triggerClassName,
|
|
2267
|
+
...triggerProps,
|
|
2268
|
+
children: content
|
|
2269
|
+
}
|
|
2270
|
+
),
|
|
2271
|
+
/* @__PURE__ */ jsx(TooltipContent, { side, className: "p-2", children: tip })
|
|
2272
|
+
] });
|
|
2273
|
+
const mainAreaClass = cn("inline-flex items-center gap-1", fullWidth && "min-w-0 flex-1");
|
|
2274
|
+
if (onMoreClick || moreContent) {
|
|
2275
|
+
let mainArea;
|
|
2276
|
+
if (tooltipContent) {
|
|
2277
|
+
mainArea = tooltipWrap(
|
|
2278
|
+
mainContent,
|
|
2279
|
+
tooltipContent,
|
|
2280
|
+
tooltipSide,
|
|
2281
|
+
cn(mainAreaClass, disabled && "opacity-60"),
|
|
2882
2282
|
{
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
mark: (p) => /* @__PURE__ */ jsx("mark", { className: "rounded bg-ai-accent-soft px-0.5 text-ai-accent", ...p }),
|
|
2899
|
-
// Self-contained bordered tables (base leaves these to app CSS).
|
|
2900
|
-
table: (p) => /* @__PURE__ */ jsx("div", { className: "my-3 overflow-x-auto rounded-lg border border-border", children: /* @__PURE__ */ jsx("table", { className: "w-full border-collapse text-xs", ...p }) }),
|
|
2901
|
-
thead: (p) => /* @__PURE__ */ jsx("thead", { className: "bg-secondary/60", ...p }),
|
|
2902
|
-
th: (p) => /* @__PURE__ */ jsx(
|
|
2903
|
-
"th",
|
|
2904
|
-
{
|
|
2905
|
-
className: "border-b border-border px-3 py-2 text-left font-semibold text-foreground",
|
|
2906
|
-
...p
|
|
2907
|
-
}
|
|
2908
|
-
),
|
|
2909
|
-
td: (p) => /* @__PURE__ */ jsx(
|
|
2910
|
-
"td",
|
|
2911
|
-
{
|
|
2912
|
-
className: "border-b border-border px-3 py-2 align-top text-muted-foreground",
|
|
2913
|
-
...p
|
|
2914
|
-
}
|
|
2915
|
-
)
|
|
2916
|
-
},
|
|
2917
|
-
children
|
|
2283
|
+
type: "button",
|
|
2284
|
+
onClick: href ? onClick : disabled ? void 0 : onClick,
|
|
2285
|
+
disabled: disabled || void 0
|
|
2286
|
+
}
|
|
2287
|
+
);
|
|
2288
|
+
} else if (href) {
|
|
2289
|
+
mainArea = /* @__PURE__ */ jsx(
|
|
2290
|
+
"a",
|
|
2291
|
+
{
|
|
2292
|
+
href,
|
|
2293
|
+
target: "_blank",
|
|
2294
|
+
rel: "noopener noreferrer",
|
|
2295
|
+
className: mainAreaClass,
|
|
2296
|
+
onClick,
|
|
2297
|
+
children: mainContent
|
|
2918
2298
|
}
|
|
2919
|
-
)
|
|
2299
|
+
);
|
|
2300
|
+
} else if (onClick) {
|
|
2301
|
+
mainArea = /* @__PURE__ */ jsx(
|
|
2302
|
+
"button",
|
|
2303
|
+
{
|
|
2304
|
+
type: "button",
|
|
2305
|
+
onClick: disabled ? void 0 : onClick,
|
|
2306
|
+
disabled,
|
|
2307
|
+
className: cn("inline-flex items-center gap-1", disabled && "opacity-60"),
|
|
2308
|
+
children: mainContent
|
|
2309
|
+
}
|
|
2310
|
+
);
|
|
2311
|
+
} else {
|
|
2312
|
+
mainArea = /* @__PURE__ */ jsx("span", { className: mainAreaClass, children: mainContent });
|
|
2920
2313
|
}
|
|
2921
|
-
|
|
2922
|
-
}
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
stepCount,
|
|
2927
|
-
error,
|
|
2928
|
-
className,
|
|
2929
|
-
emptyHint,
|
|
2930
|
-
groundedNote = "Grounded in the live workspace \xB7 verify citations before relying on it",
|
|
2931
|
-
runningHint = "Reading the documents\u2026",
|
|
2932
|
-
testId = "ai-answer"
|
|
2933
|
-
}) {
|
|
2934
|
-
const [copied, setCopied] = useState(false);
|
|
2935
|
-
const running = status === "running";
|
|
2936
|
-
const hasText = text.trim().length > 0;
|
|
2937
|
-
const copy = async () => {
|
|
2938
|
-
await navigator.clipboard.writeText(text);
|
|
2939
|
-
setCopied(true);
|
|
2940
|
-
setTimeout(() => setCopied(false), 1600);
|
|
2941
|
-
};
|
|
2942
|
-
if (status === "idle" && !hasText) {
|
|
2943
|
-
return emptyHint ? /* @__PURE__ */ jsx("p", { className: cn("text-sm text-muted-foreground", className), "data-testid": `${testId}-empty`, children: emptyHint }) : null;
|
|
2944
|
-
}
|
|
2945
|
-
return /* @__PURE__ */ jsxs("div", { className: cn("space-y-3", className), "data-testid": testId, "data-status": status, children: [
|
|
2946
|
-
running && /* @__PURE__ */ jsxs(
|
|
2947
|
-
"div",
|
|
2314
|
+
const moreArea = moreContent ? /* @__PURE__ */ jsx("span", { className: "flex-shrink-0 leading-none", children: moreContent }) : tooltipWrap(
|
|
2315
|
+
/* @__PURE__ */ jsx(MoreVertical, { className: "w-3.5 h-3.5" }),
|
|
2316
|
+
"Click for more",
|
|
2317
|
+
tooltipSide,
|
|
2318
|
+
"flex-shrink-0 leading-none text-muted-foreground hover:text-foreground",
|
|
2948
2319
|
{
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
]
|
|
2320
|
+
type: "button",
|
|
2321
|
+
onClick: (e) => {
|
|
2322
|
+
e.stopPropagation();
|
|
2323
|
+
onMoreClick?.(e);
|
|
2324
|
+
}
|
|
2955
2325
|
}
|
|
2956
|
-
)
|
|
2957
|
-
|
|
2958
|
-
"
|
|
2326
|
+
);
|
|
2327
|
+
return /* @__PURE__ */ jsxs(
|
|
2328
|
+
"span",
|
|
2959
2329
|
{
|
|
2960
|
-
|
|
2961
|
-
|
|
2330
|
+
ref,
|
|
2331
|
+
className: cn(
|
|
2332
|
+
baseClasses,
|
|
2333
|
+
(onClick || href) && !disabled && interactiveClasses,
|
|
2334
|
+
highlight && highlightClasses
|
|
2335
|
+
),
|
|
2336
|
+
"data-testid": testId,
|
|
2962
2337
|
children: [
|
|
2963
|
-
|
|
2964
|
-
|
|
2338
|
+
mainArea,
|
|
2339
|
+
moreArea
|
|
2965
2340
|
]
|
|
2966
2341
|
}
|
|
2967
|
-
)
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
] }),
|
|
2975
|
-
/* @__PURE__ */ jsxs(
|
|
2976
|
-
"button",
|
|
2342
|
+
);
|
|
2343
|
+
}
|
|
2344
|
+
if (tooltipContent) {
|
|
2345
|
+
if (href) {
|
|
2346
|
+
return tooltipWrap(
|
|
2347
|
+
/* @__PURE__ */ jsx(
|
|
2348
|
+
"a",
|
|
2977
2349
|
{
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
copied ? "Copied" : "Copy"
|
|
2985
|
-
]
|
|
2350
|
+
href,
|
|
2351
|
+
target: "_blank",
|
|
2352
|
+
rel: "noopener noreferrer",
|
|
2353
|
+
className: mainAreaClass,
|
|
2354
|
+
onClick,
|
|
2355
|
+
children: mainContent
|
|
2986
2356
|
}
|
|
2987
|
-
)
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2357
|
+
),
|
|
2358
|
+
tooltipContent,
|
|
2359
|
+
tooltipSide,
|
|
2360
|
+
cn(baseClasses, interactiveClasses),
|
|
2361
|
+
{ "data-testid": testId }
|
|
2362
|
+
);
|
|
2363
|
+
}
|
|
2364
|
+
return tooltipWrap(
|
|
2365
|
+
mainContent,
|
|
2366
|
+
tooltipContent,
|
|
2367
|
+
tooltipSide,
|
|
2368
|
+
cn(
|
|
2369
|
+
baseClasses,
|
|
2370
|
+
onClick && !disabled ? interactiveClasses : "",
|
|
2371
|
+
disabled ? disabledClasses : "",
|
|
2372
|
+
highlight && highlightClasses
|
|
2373
|
+
),
|
|
2374
|
+
{
|
|
2375
|
+
type: "button",
|
|
2376
|
+
ref,
|
|
2377
|
+
onClick: onClick && !disabled ? onClick : void 0,
|
|
2378
|
+
disabled: disabled || void 0,
|
|
2379
|
+
"data-testid": testId
|
|
2380
|
+
}
|
|
2381
|
+
);
|
|
2382
|
+
}
|
|
2383
|
+
if (href) {
|
|
2384
|
+
return /* @__PURE__ */ jsx(
|
|
2385
|
+
"a",
|
|
2386
|
+
{
|
|
2387
|
+
ref,
|
|
2388
|
+
href,
|
|
2389
|
+
target: "_blank",
|
|
2390
|
+
rel: "noopener noreferrer",
|
|
2391
|
+
className: cn(baseClasses, interactiveClasses),
|
|
2392
|
+
"data-testid": testId,
|
|
2393
|
+
onClick,
|
|
2394
|
+
children: mainContent
|
|
2395
|
+
}
|
|
2396
|
+
);
|
|
2397
|
+
}
|
|
2398
|
+
if (onClick) {
|
|
2399
|
+
return /* @__PURE__ */ jsx(
|
|
2400
|
+
"button",
|
|
2401
|
+
{
|
|
2402
|
+
ref,
|
|
2403
|
+
type: "button",
|
|
2404
|
+
onClick: disabled ? void 0 : onClick,
|
|
2405
|
+
disabled,
|
|
2406
|
+
className: cn(
|
|
2407
|
+
baseClasses,
|
|
2408
|
+
disabled ? disabledClasses : interactiveClasses,
|
|
2409
|
+
highlight && highlightClasses
|
|
2410
|
+
),
|
|
2411
|
+
"data-testid": testId,
|
|
2412
|
+
children: mainContent
|
|
2413
|
+
}
|
|
2414
|
+
);
|
|
2415
|
+
}
|
|
2416
|
+
return /* @__PURE__ */ jsx(
|
|
2417
|
+
"span",
|
|
2418
|
+
{
|
|
2419
|
+
ref,
|
|
2420
|
+
className: cn(baseClasses, highlight && highlightClasses),
|
|
2421
|
+
"data-testid": testId,
|
|
2422
|
+
children: mainContent
|
|
2423
|
+
}
|
|
2424
|
+
);
|
|
2425
|
+
});
|
|
2426
|
+
var TAG_TYPE_LABELS = {
|
|
2427
|
+
checkbox: "Checkbox",
|
|
2428
|
+
select: "Select",
|
|
2429
|
+
number: "Number",
|
|
2430
|
+
text: "Text",
|
|
2431
|
+
folder: "Folder",
|
|
2432
|
+
search: "Saved Search",
|
|
2433
|
+
date: "Date",
|
|
2434
|
+
assistant: "AI Assistant"
|
|
2435
|
+
};
|
|
2436
|
+
var TAG_TYPE_ICONS = {
|
|
2437
|
+
checkbox: SquareCheckBig,
|
|
2438
|
+
select: List,
|
|
2439
|
+
number: Hash,
|
|
2440
|
+
text: StickyNote,
|
|
2441
|
+
folder: Folder,
|
|
2442
|
+
search: Search,
|
|
2443
|
+
date: Calendar,
|
|
2444
|
+
assistant: Bot
|
|
2445
|
+
};
|
|
2446
|
+
function getTagTypeIcon(type) {
|
|
2447
|
+
return TAG_TYPE_ICONS[type ?? "text"] || StickyNote;
|
|
2996
2448
|
}
|
|
2997
|
-
function
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
2449
|
+
function getTagTypeLabel(type) {
|
|
2450
|
+
const t = type ?? "text";
|
|
2451
|
+
return TAG_TYPE_LABELS[t] || t;
|
|
2452
|
+
}
|
|
2453
|
+
var BASE_COLORS = {
|
|
2454
|
+
"0": "#10b981",
|
|
2455
|
+
"1": "#3b82f6",
|
|
2456
|
+
"2": "#8b5cf6",
|
|
2457
|
+
"3": "#f43f5e",
|
|
2458
|
+
"4": "#f59e0b",
|
|
2459
|
+
"5": "#84cc16",
|
|
2460
|
+
"6": "#a855f7",
|
|
2461
|
+
"7": "#06b6d4",
|
|
2462
|
+
"8": "#f97316",
|
|
2463
|
+
"9": "#14b8a6",
|
|
2464
|
+
a: "#ef4444",
|
|
2465
|
+
b: "#6366f1",
|
|
2466
|
+
c: "#ec4899",
|
|
2467
|
+
d: "#22c55e",
|
|
2468
|
+
e: "#eab308",
|
|
2469
|
+
f: "#0ea5e9"
|
|
2470
|
+
};
|
|
2471
|
+
function getEntityColor(entityId) {
|
|
2472
|
+
return BASE_COLORS[entityId[4]] || BASE_COLORS["0"];
|
|
2473
|
+
}
|
|
2474
|
+
function TagEntity({
|
|
2475
|
+
tag,
|
|
2476
|
+
size = "md",
|
|
2477
|
+
className = "",
|
|
2478
|
+
onClick,
|
|
2479
|
+
showTooltip = true,
|
|
2480
|
+
tooltipContent
|
|
3007
2481
|
}) {
|
|
3008
|
-
const
|
|
3009
|
-
const
|
|
3010
|
-
const
|
|
3011
|
-
|
|
3012
|
-
|
|
2482
|
+
const tagType = tag.tag_type?.type ?? "text";
|
|
2483
|
+
const iconSize = size === "sm" ? 12 : size === "md" ? 14 : 16;
|
|
2484
|
+
const Icon = getTagTypeIcon(tagType);
|
|
2485
|
+
const sizeClasses2 = {
|
|
2486
|
+
sm: "p-0.5",
|
|
2487
|
+
md: "p-1",
|
|
2488
|
+
lg: "p-1.5"
|
|
3013
2489
|
};
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
2490
|
+
const tagColor = tag.color ?? getEntityColor(tag.external_id);
|
|
2491
|
+
const iconElement = /* @__PURE__ */ jsx(
|
|
2492
|
+
"span",
|
|
2493
|
+
{
|
|
2494
|
+
className: `inline-flex items-center justify-center rounded-md text-white flex-shrink-0 ${sizeClasses2[size]}`,
|
|
2495
|
+
style: { backgroundColor: tagColor },
|
|
2496
|
+
children: /* @__PURE__ */ jsx(Icon, { size: iconSize, className: "flex-shrink-0" })
|
|
2497
|
+
}
|
|
2498
|
+
);
|
|
2499
|
+
const pillSize = size === "lg" ? "base" : "sm";
|
|
2500
|
+
const defaultTooltip = /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
2501
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
2502
|
+
/* @__PURE__ */ jsx(
|
|
2503
|
+
"span",
|
|
3025
2504
|
{
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
disabled: disabled || noDocs || task.isRunning,
|
|
3030
|
-
"data-testid": testId && `${testId}-run`,
|
|
3031
|
-
children: [
|
|
3032
|
-
/* @__PURE__ */ jsx(Sparkles, { className: "size-3.5" }),
|
|
3033
|
-
task.isRunning ? "Running\u2026" : task.isDone ? "Re-run" : runLabel
|
|
3034
|
-
]
|
|
2505
|
+
className: "inline-flex items-center justify-center rounded-md text-white p-1",
|
|
2506
|
+
style: { backgroundColor: tagColor },
|
|
2507
|
+
children: /* @__PURE__ */ jsx(Icon, { size: 16 })
|
|
3035
2508
|
}
|
|
3036
|
-
)
|
|
2509
|
+
),
|
|
2510
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-sm", children: tag.name })
|
|
3037
2511
|
] }),
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
}
|
|
3047
|
-
|
|
2512
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5 text-sm", children: [
|
|
2513
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
2514
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Type:" }),
|
|
2515
|
+
/* @__PURE__ */ jsx("span", { children: getTagTypeLabel(tagType) })
|
|
2516
|
+
] }),
|
|
2517
|
+
tag.doctag_count != null && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
2518
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Documents:" }),
|
|
2519
|
+
/* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "h-5 min-w-[20px] justify-center", children: tag.doctag_count ?? 0 })
|
|
2520
|
+
] }),
|
|
2521
|
+
tag.shared != null && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: tag.shared ? "Shared" : "Private" }) })
|
|
2522
|
+
] })
|
|
3048
2523
|
] });
|
|
2524
|
+
const resolvedTooltip = showTooltip ? tooltipContent ?? defaultTooltip : void 0;
|
|
2525
|
+
return /* @__PURE__ */ jsx(
|
|
2526
|
+
EntityPill,
|
|
2527
|
+
{
|
|
2528
|
+
icon: iconElement,
|
|
2529
|
+
label: tag.name,
|
|
2530
|
+
size: pillSize,
|
|
2531
|
+
shape: "rounded",
|
|
2532
|
+
labelMaxWidth: "max-w-[180px]",
|
|
2533
|
+
tooltipContent: resolvedTooltip,
|
|
2534
|
+
onClick,
|
|
2535
|
+
className,
|
|
2536
|
+
"data-testid": `tag-entity-${tag.external_id}`
|
|
2537
|
+
}
|
|
2538
|
+
);
|
|
3049
2539
|
}
|
|
3050
|
-
function
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
2540
|
+
function DocumentReview({
|
|
2541
|
+
docId,
|
|
2542
|
+
doc,
|
|
2543
|
+
workspaceId,
|
|
2544
|
+
stage = "final",
|
|
2545
|
+
activeChunkId,
|
|
2546
|
+
onClose,
|
|
2547
|
+
className
|
|
3058
2548
|
}) {
|
|
3059
|
-
const
|
|
3060
|
-
const
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
2549
|
+
const parsedQuery = useParsedDocument(docId, stage);
|
|
2550
|
+
const tagsQuery = useTags(workspaceId);
|
|
2551
|
+
const tagNameById = React2.useMemo(() => {
|
|
2552
|
+
const map = /* @__PURE__ */ new Map();
|
|
2553
|
+
for (const t of tagsQuery.data ?? []) {
|
|
2554
|
+
if (t.external_id) map.set(t.external_id, t.name ?? t.external_id.slice(0, 8));
|
|
3064
2555
|
}
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
2556
|
+
return map;
|
|
2557
|
+
}, [tagsQuery.data]);
|
|
2558
|
+
const title = doc?.doc_metadata?.title || doc?.file_name || "Document";
|
|
2559
|
+
const { findings, chunkToTag } = React2.useMemo(() => {
|
|
2560
|
+
const list = [];
|
|
2561
|
+
const chunkTag = /* @__PURE__ */ new Map();
|
|
2562
|
+
for (const dt of doc?.doctags ?? []) {
|
|
2563
|
+
const citations = dt.citations ?? {};
|
|
2564
|
+
for (const [citId, cit] of Object.entries(citations)) {
|
|
2565
|
+
const chunkIds = cit?.chunk_ids ?? [];
|
|
2566
|
+
if (chunkIds.length === 0) continue;
|
|
2567
|
+
list.push({
|
|
2568
|
+
key: `${dt.tag_ext_id}:${citId}`,
|
|
2569
|
+
tagExtId: dt.tag_ext_id,
|
|
2570
|
+
statement: cit.statement,
|
|
2571
|
+
chunkIds
|
|
2572
|
+
});
|
|
2573
|
+
for (const cid of chunkIds) if (!chunkTag.has(cid)) chunkTag.set(cid, dt.tag_ext_id);
|
|
2574
|
+
}
|
|
3082
2575
|
}
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
children: [
|
|
3093
|
-
/* @__PURE__ */ jsx(Loader2, { className: "size-8 animate-spin text-ai-accent" }),
|
|
3094
|
-
/* @__PURE__ */ jsx("p", { className: "mt-4 max-w-xs text-sm font-medium text-foreground", children: busyHint }),
|
|
3095
|
-
typeof stepCount === "number" && stepCount > 0 && /* @__PURE__ */ jsxs("p", { className: "mt-1 text-xs text-muted-foreground", "data-testid": "artifact-canvas-steps", children: [
|
|
3096
|
-
stepCount,
|
|
3097
|
-
" ",
|
|
3098
|
-
stepCount === 1 ? "step" : "steps",
|
|
3099
|
-
" so far"
|
|
3100
|
-
] })
|
|
3101
|
-
]
|
|
3102
|
-
}
|
|
3103
|
-
);
|
|
2576
|
+
return { findings: list, chunkToTag: chunkTag };
|
|
2577
|
+
}, [doc?.doctags]);
|
|
2578
|
+
const pages = React2.useMemo(() => {
|
|
2579
|
+
const chunks = parsedQuery.data?.chunks ?? [];
|
|
2580
|
+
const byPage = /* @__PURE__ */ new Map();
|
|
2581
|
+
for (const c of chunks) {
|
|
2582
|
+
const p = c.metadata?.page_number ?? 0;
|
|
2583
|
+
if (!byPage.has(p)) byPage.set(p, []);
|
|
2584
|
+
byPage.get(p).push(c);
|
|
3104
2585
|
}
|
|
3105
|
-
return
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
);
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
const copy = async () => {
|
|
3123
|
-
await navigator.clipboard.writeText(active.content);
|
|
3124
|
-
setCopied(true);
|
|
3125
|
-
setTimeout(() => setCopied(false), 1600);
|
|
3126
|
-
};
|
|
3127
|
-
const download = () => {
|
|
3128
|
-
const ext = active.mode === "html" ? "html" : active.mode === "text" ? "txt" : "md";
|
|
3129
|
-
const blob = new Blob([active.content], { type: "text/plain" });
|
|
3130
|
-
const url = URL.createObjectURL(blob);
|
|
3131
|
-
const a = document.createElement("a");
|
|
3132
|
-
a.href = url;
|
|
3133
|
-
a.download = `${active.title.replace(/[^\w.-]+/g, "_") || "artifact"}.${ext}`;
|
|
3134
|
-
a.click();
|
|
3135
|
-
URL.revokeObjectURL(url);
|
|
3136
|
-
};
|
|
2586
|
+
return [...byPage.entries()].sort((a, b) => a[0] - b[0]);
|
|
2587
|
+
}, [parsedQuery.data]);
|
|
2588
|
+
const scrollRef = React2.useRef(null);
|
|
2589
|
+
const [flash, setFlash] = React2.useState(null);
|
|
2590
|
+
const jumpToChunk = React2.useCallback((chunkId) => {
|
|
2591
|
+
const el = scrollRef.current?.querySelector(`[data-chunk-id="${chunkId}"]`);
|
|
2592
|
+
if (!el) return;
|
|
2593
|
+
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
2594
|
+
setFlash(chunkId);
|
|
2595
|
+
window.setTimeout(() => setFlash((c) => c === chunkId ? null : c), 1600);
|
|
2596
|
+
}, []);
|
|
2597
|
+
const parsedReady = !parsedQuery.isLoading && !!parsedQuery.data;
|
|
2598
|
+
React2.useEffect(() => {
|
|
2599
|
+
if (!activeChunkId || !parsedReady) return;
|
|
2600
|
+
const raf = window.requestAnimationFrame(() => jumpToChunk(activeChunkId));
|
|
2601
|
+
return () => window.cancelAnimationFrame(raf);
|
|
2602
|
+
}, [activeChunkId, parsedReady, jumpToChunk]);
|
|
3137
2603
|
return /* @__PURE__ */ jsxs(
|
|
3138
2604
|
"div",
|
|
3139
2605
|
{
|
|
2606
|
+
"data-testid": "document-review",
|
|
3140
2607
|
className: cn(
|
|
3141
|
-
"flex h-full flex-col overflow-hidden rounded-
|
|
2608
|
+
"flex h-full min-h-0 flex-col overflow-hidden rounded-lg border bg-card",
|
|
3142
2609
|
className
|
|
3143
2610
|
),
|
|
3144
|
-
"data-testid": "artifact-canvas",
|
|
3145
2611
|
children: [
|
|
3146
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-
|
|
3147
|
-
/* @__PURE__ */
|
|
3148
|
-
|
|
3149
|
-
"
|
|
2612
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 border-b px-4 py-3", children: [
|
|
2613
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
2614
|
+
/* @__PURE__ */ jsx("div", { className: "truncate text-sm font-semibold", title, children: title }),
|
|
2615
|
+
/* @__PURE__ */ jsxs("div", { className: "text-xs text-muted-foreground", children: [
|
|
2616
|
+
parsedQuery.data?.metadata?.total_number_of_pages ? `${parsedQuery.data.metadata.total_number_of_pages} pages` : `${pages.length} pages`,
|
|
2617
|
+
findings.length ? ` \xB7 ${findings.length} findings` : ""
|
|
2618
|
+
] })
|
|
2619
|
+
] }),
|
|
2620
|
+
doc?.status ? /* @__PURE__ */ jsx(Badge, { variant: "secondary", children: doc.status }) : null,
|
|
2621
|
+
onClose ? /* @__PURE__ */ jsx(
|
|
2622
|
+
"button",
|
|
3150
2623
|
{
|
|
3151
|
-
|
|
3152
|
-
"
|
|
3153
|
-
|
|
2624
|
+
type: "button",
|
|
2625
|
+
"aria-label": "Close review",
|
|
2626
|
+
"data-testid": "document-review-close",
|
|
2627
|
+
onClick: onClose,
|
|
2628
|
+
className: "rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground",
|
|
2629
|
+
children: /* @__PURE__ */ jsx(X, { className: "size-4" })
|
|
3154
2630
|
}
|
|
3155
|
-
)
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
/* @__PURE__ */ jsxs(Badge, { variant: "secondary", children: [
|
|
3161
|
-
"v",
|
|
3162
|
-
active.version
|
|
3163
|
-
] }),
|
|
3164
|
-
!active.is_complete ? /* @__PURE__ */ jsxs(
|
|
3165
|
-
"span",
|
|
2631
|
+
) : null
|
|
2632
|
+
] }),
|
|
2633
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-1", children: [
|
|
2634
|
+
findings.length > 0 ? /* @__PURE__ */ jsxs(
|
|
2635
|
+
"aside",
|
|
3166
2636
|
{
|
|
3167
|
-
className: "
|
|
3168
|
-
"data-testid": "
|
|
2637
|
+
className: "hidden w-64 shrink-0 overflow-y-auto border-r p-3 md:block",
|
|
2638
|
+
"data-testid": "document-review-findings",
|
|
3169
2639
|
children: [
|
|
3170
|
-
/* @__PURE__ */ jsx(
|
|
3171
|
-
"
|
|
2640
|
+
/* @__PURE__ */ jsx("div", { className: "mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground", children: "AI findings" }),
|
|
2641
|
+
/* @__PURE__ */ jsx("ul", { className: "space-y-2", children: findings.map((f) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
|
|
2642
|
+
"div",
|
|
2643
|
+
{
|
|
2644
|
+
role: "button",
|
|
2645
|
+
tabIndex: 0,
|
|
2646
|
+
"data-testid": "review-finding",
|
|
2647
|
+
onClick: () => jumpToChunk(f.chunkIds[0]),
|
|
2648
|
+
onKeyDown: (e) => {
|
|
2649
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
2650
|
+
e.preventDefault();
|
|
2651
|
+
jumpToChunk(f.chunkIds[0]);
|
|
2652
|
+
}
|
|
2653
|
+
},
|
|
2654
|
+
className: "w-full cursor-pointer rounded-md border p-2 text-left text-xs transition hover:border-ring hover:bg-muted/50 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
2655
|
+
children: [
|
|
2656
|
+
/* @__PURE__ */ jsx(
|
|
2657
|
+
TagEntity,
|
|
2658
|
+
{
|
|
2659
|
+
size: "sm",
|
|
2660
|
+
tag: {
|
|
2661
|
+
external_id: f.tagExtId,
|
|
2662
|
+
name: tagNameById.get(f.tagExtId) ?? f.tagExtId.slice(0, 8)
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
),
|
|
2666
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1 line-clamp-3 text-muted-foreground", children: f.statement })
|
|
2667
|
+
]
|
|
2668
|
+
}
|
|
2669
|
+
) }, f.key)) })
|
|
3172
2670
|
]
|
|
3173
2671
|
}
|
|
3174
|
-
) :
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
{
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
2672
|
+
) : null,
|
|
2673
|
+
/* @__PURE__ */ jsx("div", { ref: scrollRef, className: "min-w-0 flex-1 overflow-y-auto px-6 py-4", children: parsedQuery.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex h-full items-center justify-center text-sm text-muted-foreground", children: "Loading document\u2026" }) : parsedQuery.isError ? /* @__PURE__ */ jsx("div", { className: "flex h-full items-center justify-center text-sm text-muted-foreground", children: "Could not load this document\u2019s content." }) : pages.length === 0 ? /* @__PURE__ */ jsx("div", { className: "flex h-full items-center justify-center text-sm text-muted-foreground", children: "No readable content." }) : /* @__PURE__ */ jsx("div", { className: "mx-auto max-w-3xl space-y-8", children: pages.map(([pageNum, chunks]) => /* @__PURE__ */ jsxs("section", { children: [
|
|
2674
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-3 flex items-center gap-3", children: [
|
|
2675
|
+
/* @__PURE__ */ jsxs("span", { className: "text-xs font-medium uppercase tracking-wide text-muted-foreground", children: [
|
|
2676
|
+
"Page ",
|
|
2677
|
+
pageNum
|
|
2678
|
+
] }),
|
|
2679
|
+
/* @__PURE__ */ jsx("div", { className: "h-px flex-1 bg-border" })
|
|
2680
|
+
] }),
|
|
2681
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-3", children: chunks.map((c, i) => {
|
|
2682
|
+
const cid = c.metadata?.chunk_ext_id;
|
|
2683
|
+
const tagExtId = cid ? chunkToTag.get(cid) : void 0;
|
|
2684
|
+
const highlighted = !!tagExtId;
|
|
2685
|
+
const isActive = !!cid && cid === activeChunkId;
|
|
2686
|
+
return /* @__PURE__ */ jsxs(
|
|
2687
|
+
"div",
|
|
2688
|
+
{
|
|
2689
|
+
"data-chunk-id": cid,
|
|
2690
|
+
"data-testid": isActive ? "review-chunk-active" : highlighted ? "review-chunk-cited" : "review-chunk",
|
|
2691
|
+
className: cn(
|
|
2692
|
+
"scroll-mt-4 rounded-md px-2 py-1 transition-colors",
|
|
2693
|
+
highlighted && "bg-[var(--color-ai-accent-soft,theme(colors.amber.100))] ring-1 ring-inset ring-border",
|
|
2694
|
+
// The externally-selected search passage wins the
|
|
2695
|
+
// styling: a stronger accent ring so the matched
|
|
2696
|
+
// hit stands out from any AI-finding highlights.
|
|
2697
|
+
isActive && "bg-[var(--color-ai-accent-soft,theme(colors.amber.100))] ring-2 ring-inset ring-ai-accent",
|
|
2698
|
+
flash === cid && "ring-2 ring-ring"
|
|
2699
|
+
),
|
|
2700
|
+
children: [
|
|
2701
|
+
highlighted ? /* @__PURE__ */ jsx("div", { className: "mb-1", children: /* @__PURE__ */ jsx(
|
|
2702
|
+
TagEntity,
|
|
2703
|
+
{
|
|
2704
|
+
size: "sm",
|
|
2705
|
+
tag: {
|
|
2706
|
+
external_id: tagExtId,
|
|
2707
|
+
name: tagNameById.get(tagExtId) ?? tagExtId.slice(0, 8)
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
) }) : null,
|
|
2711
|
+
/* @__PURE__ */ jsx(MarkdownRenderer, { className: "prose prose-sm max-w-none dark:prose-invert", children: c.content })
|
|
2712
|
+
]
|
|
2713
|
+
},
|
|
2714
|
+
cid ?? i
|
|
2715
|
+
);
|
|
2716
|
+
}) })
|
|
2717
|
+
] }, pageNum)) }) })
|
|
2718
|
+
] })
|
|
3220
2719
|
]
|
|
3221
2720
|
}
|
|
3222
2721
|
);
|
|
3223
2722
|
}
|
|
3224
|
-
function
|
|
3225
|
-
|
|
3226
|
-
|
|
2723
|
+
function queryTerms(query) {
|
|
2724
|
+
const terms = /* @__PURE__ */ new Set();
|
|
2725
|
+
for (const phrase of query.match(/"([^"]+)"/g) ?? []) {
|
|
2726
|
+
const inner = phrase.slice(1, -1).trim();
|
|
2727
|
+
if (inner) terms.add(inner);
|
|
2728
|
+
}
|
|
2729
|
+
for (const word of query.replace(/"/g, " ").split(/\s+/)) {
|
|
2730
|
+
if (word.length > 2) terms.add(word);
|
|
2731
|
+
}
|
|
2732
|
+
return [...terms];
|
|
2733
|
+
}
|
|
2734
|
+
function HighlightedSnippet({ text, terms }) {
|
|
2735
|
+
const nodes = useMemo(() => {
|
|
2736
|
+
if (terms.length === 0) return [text];
|
|
2737
|
+
const escaped = terms.map((t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
|
|
2738
|
+
const re = new RegExp(`(${escaped.join("|")})`, "gi");
|
|
2739
|
+
return text.split(re).map(
|
|
2740
|
+
(part, i) => i % 2 === 1 ? /* @__PURE__ */ jsx("mark", { className: "rounded-sm bg-ai-accent/20 px-0.5 text-foreground", children: part }, i) : part
|
|
2741
|
+
);
|
|
2742
|
+
}, [text, terms]);
|
|
2743
|
+
return /* @__PURE__ */ jsx(Fragment, { children: nodes });
|
|
2744
|
+
}
|
|
2745
|
+
function RelevanceDot({ score }) {
|
|
2746
|
+
if (score == null) return null;
|
|
2747
|
+
const tone = score >= 0.7 ? "bg-emerald-500" : score >= 0.4 ? "bg-amber-500" : "bg-muted-foreground/40";
|
|
2748
|
+
return /* @__PURE__ */ jsxs("span", { className: "ml-auto inline-flex items-center gap-1.5 text-[10px] text-muted-foreground", children: [
|
|
2749
|
+
/* @__PURE__ */ jsx("span", { className: cn("size-1.5 rounded-full", tone), "aria-hidden": true }),
|
|
2750
|
+
score.toFixed(2)
|
|
2751
|
+
] });
|
|
2752
|
+
}
|
|
2753
|
+
function ResultRow({
|
|
2754
|
+
result,
|
|
2755
|
+
index,
|
|
2756
|
+
terms,
|
|
2757
|
+
isActive,
|
|
2758
|
+
onSelect
|
|
3227
2759
|
}) {
|
|
3228
|
-
const { docExtId, title, isComplete, mode } = artifact;
|
|
3229
|
-
const isImage = mode === "image";
|
|
3230
|
-
const Icon2 = isImage ? Image$1 : FileText;
|
|
3231
|
-
const statusText = isImage ? isComplete ? "Image ready" : "Generating\u2026" : isComplete ? "Draft ready" : "Drafting\u2026";
|
|
3232
2760
|
return /* @__PURE__ */ jsxs(
|
|
3233
|
-
|
|
2761
|
+
"button",
|
|
3234
2762
|
{
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
"data-testid": `
|
|
2763
|
+
type: "button",
|
|
2764
|
+
onClick: onSelect,
|
|
2765
|
+
"data-testid": `arbi-semantic-search-result-${index}`,
|
|
2766
|
+
"aria-current": isActive,
|
|
2767
|
+
className: cn(
|
|
2768
|
+
"w-full rounded-lg border border-border bg-card p-3 text-left transition-colors",
|
|
2769
|
+
"hover:border-ai-accent/40 focus:outline-none focus-visible:ring-2 focus-visible:ring-ai-accent/40",
|
|
2770
|
+
isActive && "border-ai-accent/60 ring-1 ring-ai-accent/30"
|
|
2771
|
+
),
|
|
3238
2772
|
children: [
|
|
3239
|
-
/* @__PURE__ */
|
|
3240
|
-
|
|
3241
|
-
/* @__PURE__ */ jsx(
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
}
|
|
3248
|
-
),
|
|
3249
|
-
/* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground", "data-testid": "artifact-status", children: statusText })
|
|
2773
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-1 flex items-center gap-2", children: [
|
|
2774
|
+
/* @__PURE__ */ jsx(FileText, { className: "size-3.5 shrink-0 text-ai-accent" }),
|
|
2775
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-xs font-medium text-foreground", children: result.docTitle ?? "Document" }),
|
|
2776
|
+
result.page != null && /* @__PURE__ */ jsxs(Badge, { variant: "secondary", children: [
|
|
2777
|
+
"p.",
|
|
2778
|
+
result.page
|
|
2779
|
+
] }),
|
|
2780
|
+
/* @__PURE__ */ jsx(RelevanceDot, { score: result.score })
|
|
3250
2781
|
] }),
|
|
3251
|
-
/* @__PURE__ */
|
|
3252
|
-
"
|
|
3253
|
-
{
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
className: "shrink-0 rounded-md bg-secondary/15 px-3 py-1.5 text-sm font-semibold text-secondary transition-colors hover:bg-secondary/25",
|
|
3257
|
-
"data-testid": `view-artifact-button-${docExtId}`,
|
|
3258
|
-
children: isImage ? "View image" : "View draft"
|
|
3259
|
-
}
|
|
3260
|
-
)
|
|
2782
|
+
/* @__PURE__ */ jsxs("p", { className: "line-clamp-3 text-xs leading-relaxed text-muted-foreground", children: [
|
|
2783
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground/60", children: "\u2026 " }),
|
|
2784
|
+
/* @__PURE__ */ jsx(HighlightedSnippet, { text: result.content, terms }),
|
|
2785
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground/60", children: " \u2026" })
|
|
2786
|
+
] })
|
|
3261
2787
|
]
|
|
3262
2788
|
}
|
|
3263
2789
|
);
|
|
3264
2790
|
}
|
|
3265
|
-
function
|
|
2791
|
+
function SemanticSearch({
|
|
3266
2792
|
docIds,
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
2793
|
+
workspaceId,
|
|
2794
|
+
searchMode = "hybrid",
|
|
2795
|
+
placeholder = "Search your documents by meaning\u2026",
|
|
2796
|
+
className,
|
|
2797
|
+
"data-testid": testId = "arbi-semantic-search"
|
|
3270
2798
|
}) {
|
|
3271
2799
|
const { results, status, error, search, isRunning, query } = useSemanticSearch(docIds);
|
|
3272
2800
|
const [value, setValue] = useState("");
|
|
3273
|
-
const
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
children: [
|
|
3299
|
-
|
|
3300
|
-
/* @__PURE__ */ jsx(
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
2801
|
+
const [selected, setSelected] = useState(null);
|
|
2802
|
+
const { data: docs = [] } = useDocuments(workspaceId, { enabled: !!workspaceId });
|
|
2803
|
+
const docMap = useMemo(() => {
|
|
2804
|
+
const map = /* @__PURE__ */ new Map();
|
|
2805
|
+
for (const d of docs) if (d.external_id) map.set(d.external_id, d);
|
|
2806
|
+
return map;
|
|
2807
|
+
}, [docs]);
|
|
2808
|
+
const terms = useMemo(() => queryTerms(query), [query]);
|
|
2809
|
+
const submit = useCallback(() => {
|
|
2810
|
+
const q = value.trim();
|
|
2811
|
+
if (!q) return;
|
|
2812
|
+
setSelected(null);
|
|
2813
|
+
void search(q, searchMode);
|
|
2814
|
+
}, [value, search, searchMode]);
|
|
2815
|
+
const selectedDoc = selected?.docId ? docMap.get(selected.docId) : void 0;
|
|
2816
|
+
const hasResults = status === "done" && results.length > 0;
|
|
2817
|
+
return /* @__PURE__ */ jsxs("div", { "data-testid": testId, className: cn("flex min-h-0 flex-col gap-4 md:flex-row", className), children: [
|
|
2818
|
+
/* @__PURE__ */ jsxs(
|
|
2819
|
+
"div",
|
|
2820
|
+
{
|
|
2821
|
+
className: cn(
|
|
2822
|
+
"flex min-h-0 flex-col gap-3 md:w-[22rem] md:shrink-0",
|
|
2823
|
+
selected && "hidden md:flex"
|
|
2824
|
+
),
|
|
2825
|
+
children: [
|
|
2826
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
2827
|
+
/* @__PURE__ */ jsx(Search, { className: "pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground" }),
|
|
2828
|
+
isRunning && /* @__PURE__ */ jsx(Loader2, { className: "absolute right-3 top-1/2 size-4 -translate-y-1/2 animate-spin text-ai-accent" }),
|
|
2829
|
+
/* @__PURE__ */ jsx(
|
|
2830
|
+
"input",
|
|
2831
|
+
{
|
|
2832
|
+
value,
|
|
2833
|
+
onChange: (e) => setValue(e.target.value),
|
|
2834
|
+
onKeyDown: (e) => e.key === "Enter" && (e.preventDefault(), submit()),
|
|
2835
|
+
placeholder,
|
|
2836
|
+
"aria-label": "Semantic search query",
|
|
2837
|
+
className: "h-11 w-full rounded-lg border border-input bg-background pl-9 pr-24 text-sm outline-none focus:border-ai-accent/50 focus:ring-2 focus:ring-ai-accent/15",
|
|
2838
|
+
"data-testid": "arbi-semantic-search-input"
|
|
2839
|
+
}
|
|
2840
|
+
),
|
|
2841
|
+
/* @__PURE__ */ jsxs(
|
|
2842
|
+
"button",
|
|
2843
|
+
{
|
|
2844
|
+
type: "button",
|
|
2845
|
+
onClick: submit,
|
|
2846
|
+
disabled: !value.trim() || isRunning,
|
|
2847
|
+
className: "absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-1 rounded-md bg-ai-accent px-2.5 py-1 text-xs font-medium text-ai-accent-foreground disabled:opacity-50",
|
|
2848
|
+
"data-testid": "arbi-semantic-search-submit",
|
|
2849
|
+
children: [
|
|
2850
|
+
"Search ",
|
|
2851
|
+
/* @__PURE__ */ jsx(CornerDownLeft, { className: "size-3" })
|
|
2852
|
+
]
|
|
2853
|
+
}
|
|
2854
|
+
)
|
|
2855
|
+
] }),
|
|
2856
|
+
status === "error" && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", "data-testid": "arbi-semantic-search-error", children: error }),
|
|
2857
|
+
status === "done" && /* @__PURE__ */ jsxs(
|
|
2858
|
+
"div",
|
|
2859
|
+
{
|
|
2860
|
+
className: "flex min-h-0 flex-col gap-2 overflow-y-auto",
|
|
2861
|
+
"data-testid": "arbi-semantic-search-results",
|
|
2862
|
+
children: [
|
|
2863
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: results.length === 0 ? `No passages matched \u201C${query}\u201D.` : `${results.length} passage${results.length === 1 ? "" : "s"} for \u201C${query}\u201D` }),
|
|
2864
|
+
results.map((r, i) => /* @__PURE__ */ jsx(
|
|
2865
|
+
ResultRow,
|
|
2866
|
+
{
|
|
2867
|
+
result: r,
|
|
2868
|
+
index: i,
|
|
2869
|
+
terms,
|
|
2870
|
+
isActive: selected?.chunkExtId != null && selected.chunkExtId === r.chunkExtId,
|
|
2871
|
+
onSelect: () => setSelected(r)
|
|
2872
|
+
},
|
|
2873
|
+
r.chunkExtId ?? `${r.docId}-${r.page}-${i}`
|
|
2874
|
+
))
|
|
2875
|
+
]
|
|
2876
|
+
}
|
|
2877
|
+
)
|
|
2878
|
+
]
|
|
2879
|
+
}
|
|
2880
|
+
),
|
|
2881
|
+
/* @__PURE__ */ jsx(
|
|
2882
|
+
"div",
|
|
2883
|
+
{
|
|
2884
|
+
className: cn("min-h-0 min-w-0 flex-1", !selected && "hidden md:block"),
|
|
2885
|
+
"data-testid": "arbi-semantic-search-viewer",
|
|
2886
|
+
children: selected && selected.docId ? /* @__PURE__ */ jsxs("div", { className: "flex h-full min-h-0 flex-col gap-2", children: [
|
|
2887
|
+
/* @__PURE__ */ jsxs(
|
|
2888
|
+
Button,
|
|
2889
|
+
{
|
|
2890
|
+
variant: "ghost",
|
|
2891
|
+
size: "sm",
|
|
2892
|
+
className: "self-start md:hidden",
|
|
2893
|
+
onClick: () => setSelected(null),
|
|
2894
|
+
"data-testid": "arbi-semantic-search-back",
|
|
2895
|
+
children: [
|
|
2896
|
+
/* @__PURE__ */ jsx(ArrowLeft, { className: "size-4" }),
|
|
2897
|
+
" Back to results"
|
|
2898
|
+
]
|
|
2899
|
+
}
|
|
2900
|
+
),
|
|
2901
|
+
/* @__PURE__ */ jsx(
|
|
2902
|
+
DocumentReview,
|
|
2903
|
+
{
|
|
2904
|
+
docId: selected.docId,
|
|
2905
|
+
doc: selectedDoc,
|
|
2906
|
+
workspaceId,
|
|
2907
|
+
activeChunkId: selected.chunkExtId ?? void 0,
|
|
2908
|
+
className: "min-h-0 flex-1"
|
|
2909
|
+
},
|
|
2910
|
+
selected.docId
|
|
2911
|
+
)
|
|
2912
|
+
] }) : /* @__PURE__ */ jsx(
|
|
2913
|
+
"div",
|
|
2914
|
+
{
|
|
2915
|
+
className: "flex h-full min-h-[16rem] items-center justify-center rounded-lg border border-dashed border-border bg-muted/20 p-8 text-center",
|
|
2916
|
+
"data-testid": "arbi-semantic-search-empty",
|
|
2917
|
+
children: /* @__PURE__ */ jsxs("div", { className: "max-w-xs", children: [
|
|
2918
|
+
/* @__PURE__ */ jsx(Search, { className: "mx-auto mb-3 size-6 text-muted-foreground/50" }),
|
|
2919
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: hasResults ? "Select a passage to open the document alongside, scrolled to the match." : "Search across the record \u2014 every hit is a real, cited passage you can open in place." })
|
|
2920
|
+
] })
|
|
2921
|
+
}
|
|
2922
|
+
)
|
|
2923
|
+
}
|
|
2924
|
+
)
|
|
3337
2925
|
] });
|
|
3338
2926
|
}
|
|
3339
2927
|
function DocQaPanel({ docId, docName }) {
|
|
@@ -3679,7 +3267,7 @@ var CitationPopover = ({
|
|
|
3679
3267
|
}
|
|
3680
3268
|
);
|
|
3681
3269
|
};
|
|
3682
|
-
var CitationLink =
|
|
3270
|
+
var CitationLink = React2.forwardRef(
|
|
3683
3271
|
({ citationNum, isActive, isStreaming, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
3684
3272
|
"span",
|
|
3685
3273
|
{
|
|
@@ -3699,7 +3287,7 @@ var CitationLink = React__default.forwardRef(
|
|
|
3699
3287
|
)
|
|
3700
3288
|
);
|
|
3701
3289
|
CitationLink.displayName = "CitationLink";
|
|
3702
|
-
var CitationRenderer =
|
|
3290
|
+
var CitationRenderer = React2.memo(CitationRendererComponent);
|
|
3703
3291
|
|
|
3704
3292
|
// src/icons/colors.ts
|
|
3705
3293
|
var NEUTRAL_GRAY = "#64748b";
|
|
@@ -4589,243 +4177,19 @@ var ArbiBotIcon = ({ size = 24, className = "" }) => {
|
|
|
4589
4177
|
/* @__PURE__ */ jsx("path", { d: "M1591 1803 c-128 -67 -85 -243 60 -243 83 0 141 99 105 178 -32 69 -103 97 -165 65z m127 -59 c4 -25 -19 -47 -41 -38 -22 8 -30 34 -16 51 17 20 53 12 57 -13z" }),
|
|
4590
4178
|
/* @__PURE__ */ jsx("path", { d: "M843 1347 c-9 -15 9 -63 41 -108 148 -202 565 -209 730 -12 37 44 60 103 47 116 -13 13 -810 17 -818 4z" }),
|
|
4591
4179
|
/* @__PURE__ */ jsx("g", { transform: "translate(564,0)", children: /* @__PURE__ */ jsx(
|
|
4592
|
-
"path",
|
|
4593
|
-
{
|
|
4594
|
-
d: "M515 353 c-49 -136 -91 -253 -93 -261 -3 -10 11 -12 60 -10 l63 3 19 53 19 52 91 0 92 0 18 -55 17 -56 62 3 c76 4 79 -24 -30 275 l-88 243 -70 0 -70 0 -90 -247z m215 -55 c0 -4 -27 -8 -59 -8 l-60 0 31 92 31 93 29 -85 c15 -46 28 -88 28 -92z",
|
|
4595
|
-
stroke: "currentColor",
|
|
4596
|
-
strokeWidth: "30"
|
|
4597
|
-
}
|
|
4598
|
-
) })
|
|
4599
|
-
] })
|
|
4600
|
-
] })
|
|
4601
|
-
]
|
|
4602
|
-
}
|
|
4603
|
-
);
|
|
4604
|
-
};
|
|
4605
|
-
var EntityPill = forwardRef(function EntityPill2({
|
|
4606
|
-
icon,
|
|
4607
|
-
label,
|
|
4608
|
-
secondaryText,
|
|
4609
|
-
size = "sm",
|
|
4610
|
-
shape = "rounded",
|
|
4611
|
-
className,
|
|
4612
|
-
labelMaxWidth = "max-w-[320px]",
|
|
4613
|
-
fullWidth = false,
|
|
4614
|
-
highlight = false,
|
|
4615
|
-
onClick,
|
|
4616
|
-
onIconClick,
|
|
4617
|
-
onMoreClick,
|
|
4618
|
-
moreContent,
|
|
4619
|
-
href,
|
|
4620
|
-
disabled = false,
|
|
4621
|
-
tooltipContent,
|
|
4622
|
-
tooltipSide = "bottom",
|
|
4623
|
-
"data-testid": testId
|
|
4624
|
-
}, ref) {
|
|
4625
|
-
const shapeClass = shape === "pill" ? "rounded-full" : "rounded-md";
|
|
4626
|
-
const sizeClasses2 = size === "base" ? "gap-1.5 px-1.5 py-0.5" : "gap-1 px-1";
|
|
4627
|
-
const textSizeClass = size === "base" ? "text-base" : "text-sm";
|
|
4628
|
-
const baseClasses = cn(
|
|
4629
|
-
"group/pill items-center",
|
|
4630
|
-
fullWidth ? "flex w-full" : "inline-flex",
|
|
4631
|
-
sizeClasses2,
|
|
4632
|
-
shapeClass,
|
|
4633
|
-
"bg-muted",
|
|
4634
|
-
"border border-border",
|
|
4635
|
-
"transition-all",
|
|
4636
|
-
className
|
|
4637
|
-
);
|
|
4638
|
-
const interactiveClasses = "cursor-pointer hover:bg-muted/80";
|
|
4639
|
-
const disabledClasses = "cursor-default opacity-60";
|
|
4640
|
-
const highlightClasses = "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground";
|
|
4641
|
-
const mainContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4642
|
-
onIconClick ? /* @__PURE__ */ jsx(
|
|
4643
|
-
"span",
|
|
4644
|
-
{
|
|
4645
|
-
role: "button",
|
|
4646
|
-
tabIndex: 0,
|
|
4647
|
-
className: "flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity",
|
|
4648
|
-
onClick: (e) => {
|
|
4649
|
-
e.stopPropagation();
|
|
4650
|
-
onIconClick(e);
|
|
4651
|
-
},
|
|
4652
|
-
children: icon
|
|
4653
|
-
}
|
|
4654
|
-
) : icon,
|
|
4655
|
-
/* @__PURE__ */ jsx(
|
|
4656
|
-
"span",
|
|
4657
|
-
{
|
|
4658
|
-
className: cn(textSizeClass, "font-medium truncate leading-tight min-w-0", labelMaxWidth),
|
|
4659
|
-
children: label
|
|
4660
|
-
}
|
|
4661
|
-
),
|
|
4662
|
-
secondaryText && /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground flex-shrink-0 leading-none", children: secondaryText })
|
|
4663
|
-
] });
|
|
4664
|
-
const tooltipWrap = (content, tip, side = tooltipSide, triggerClassName, triggerProps) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
4665
|
-
/* @__PURE__ */ jsx(
|
|
4666
|
-
TooltipTrigger,
|
|
4667
|
-
{
|
|
4668
|
-
onFocusCapture: (e) => e.stopPropagation(),
|
|
4669
|
-
className: triggerClassName,
|
|
4670
|
-
...triggerProps,
|
|
4671
|
-
children: content
|
|
4672
|
-
}
|
|
4673
|
-
),
|
|
4674
|
-
/* @__PURE__ */ jsx(TooltipContent, { side, className: "p-2", children: tip })
|
|
4675
|
-
] });
|
|
4676
|
-
const mainAreaClass = cn("inline-flex items-center gap-1", fullWidth && "min-w-0 flex-1");
|
|
4677
|
-
if (onMoreClick || moreContent) {
|
|
4678
|
-
let mainArea;
|
|
4679
|
-
if (tooltipContent) {
|
|
4680
|
-
mainArea = tooltipWrap(
|
|
4681
|
-
mainContent,
|
|
4682
|
-
tooltipContent,
|
|
4683
|
-
tooltipSide,
|
|
4684
|
-
cn(mainAreaClass, disabled && "opacity-60"),
|
|
4685
|
-
{
|
|
4686
|
-
type: "button",
|
|
4687
|
-
onClick: href ? onClick : disabled ? void 0 : onClick,
|
|
4688
|
-
disabled: disabled || void 0
|
|
4689
|
-
}
|
|
4690
|
-
);
|
|
4691
|
-
} else if (href) {
|
|
4692
|
-
mainArea = /* @__PURE__ */ jsx(
|
|
4693
|
-
"a",
|
|
4694
|
-
{
|
|
4695
|
-
href,
|
|
4696
|
-
target: "_blank",
|
|
4697
|
-
rel: "noopener noreferrer",
|
|
4698
|
-
className: mainAreaClass,
|
|
4699
|
-
onClick,
|
|
4700
|
-
children: mainContent
|
|
4701
|
-
}
|
|
4702
|
-
);
|
|
4703
|
-
} else if (onClick) {
|
|
4704
|
-
mainArea = /* @__PURE__ */ jsx(
|
|
4705
|
-
"button",
|
|
4706
|
-
{
|
|
4707
|
-
type: "button",
|
|
4708
|
-
onClick: disabled ? void 0 : onClick,
|
|
4709
|
-
disabled,
|
|
4710
|
-
className: cn("inline-flex items-center gap-1", disabled && "opacity-60"),
|
|
4711
|
-
children: mainContent
|
|
4712
|
-
}
|
|
4713
|
-
);
|
|
4714
|
-
} else {
|
|
4715
|
-
mainArea = /* @__PURE__ */ jsx("span", { className: mainAreaClass, children: mainContent });
|
|
4716
|
-
}
|
|
4717
|
-
const moreArea = moreContent ? /* @__PURE__ */ jsx("span", { className: "flex-shrink-0 leading-none", children: moreContent }) : tooltipWrap(
|
|
4718
|
-
/* @__PURE__ */ jsx(MoreVertical, { className: "w-3.5 h-3.5" }),
|
|
4719
|
-
"Click for more",
|
|
4720
|
-
tooltipSide,
|
|
4721
|
-
"flex-shrink-0 leading-none text-muted-foreground hover:text-foreground",
|
|
4722
|
-
{
|
|
4723
|
-
type: "button",
|
|
4724
|
-
onClick: (e) => {
|
|
4725
|
-
e.stopPropagation();
|
|
4726
|
-
onMoreClick?.(e);
|
|
4727
|
-
}
|
|
4728
|
-
}
|
|
4729
|
-
);
|
|
4730
|
-
return /* @__PURE__ */ jsxs(
|
|
4731
|
-
"span",
|
|
4732
|
-
{
|
|
4733
|
-
ref,
|
|
4734
|
-
className: cn(
|
|
4735
|
-
baseClasses,
|
|
4736
|
-
(onClick || href) && !disabled && interactiveClasses,
|
|
4737
|
-
highlight && highlightClasses
|
|
4738
|
-
),
|
|
4739
|
-
"data-testid": testId,
|
|
4740
|
-
children: [
|
|
4741
|
-
mainArea,
|
|
4742
|
-
moreArea
|
|
4743
|
-
]
|
|
4744
|
-
}
|
|
4745
|
-
);
|
|
4746
|
-
}
|
|
4747
|
-
if (tooltipContent) {
|
|
4748
|
-
if (href) {
|
|
4749
|
-
return tooltipWrap(
|
|
4750
|
-
/* @__PURE__ */ jsx(
|
|
4751
|
-
"a",
|
|
4752
|
-
{
|
|
4753
|
-
href,
|
|
4754
|
-
target: "_blank",
|
|
4755
|
-
rel: "noopener noreferrer",
|
|
4756
|
-
className: mainAreaClass,
|
|
4757
|
-
onClick,
|
|
4758
|
-
children: mainContent
|
|
4759
|
-
}
|
|
4760
|
-
),
|
|
4761
|
-
tooltipContent,
|
|
4762
|
-
tooltipSide,
|
|
4763
|
-
cn(baseClasses, interactiveClasses),
|
|
4764
|
-
{ "data-testid": testId }
|
|
4765
|
-
);
|
|
4766
|
-
}
|
|
4767
|
-
return tooltipWrap(
|
|
4768
|
-
mainContent,
|
|
4769
|
-
tooltipContent,
|
|
4770
|
-
tooltipSide,
|
|
4771
|
-
cn(
|
|
4772
|
-
baseClasses,
|
|
4773
|
-
onClick && !disabled ? interactiveClasses : "",
|
|
4774
|
-
disabled ? disabledClasses : "",
|
|
4775
|
-
highlight && highlightClasses
|
|
4776
|
-
),
|
|
4777
|
-
{
|
|
4778
|
-
type: "button",
|
|
4779
|
-
ref,
|
|
4780
|
-
onClick: onClick && !disabled ? onClick : void 0,
|
|
4781
|
-
disabled: disabled || void 0,
|
|
4782
|
-
"data-testid": testId
|
|
4783
|
-
}
|
|
4784
|
-
);
|
|
4785
|
-
}
|
|
4786
|
-
if (href) {
|
|
4787
|
-
return /* @__PURE__ */ jsx(
|
|
4788
|
-
"a",
|
|
4789
|
-
{
|
|
4790
|
-
ref,
|
|
4791
|
-
href,
|
|
4792
|
-
target: "_blank",
|
|
4793
|
-
rel: "noopener noreferrer",
|
|
4794
|
-
className: cn(baseClasses, interactiveClasses),
|
|
4795
|
-
"data-testid": testId,
|
|
4796
|
-
onClick,
|
|
4797
|
-
children: mainContent
|
|
4798
|
-
}
|
|
4799
|
-
);
|
|
4800
|
-
}
|
|
4801
|
-
if (onClick) {
|
|
4802
|
-
return /* @__PURE__ */ jsx(
|
|
4803
|
-
"button",
|
|
4804
|
-
{
|
|
4805
|
-
ref,
|
|
4806
|
-
type: "button",
|
|
4807
|
-
onClick: disabled ? void 0 : onClick,
|
|
4808
|
-
disabled,
|
|
4809
|
-
className: cn(
|
|
4810
|
-
baseClasses,
|
|
4811
|
-
disabled ? disabledClasses : interactiveClasses,
|
|
4812
|
-
highlight && highlightClasses
|
|
4813
|
-
),
|
|
4814
|
-
"data-testid": testId,
|
|
4815
|
-
children: mainContent
|
|
4816
|
-
}
|
|
4817
|
-
);
|
|
4818
|
-
}
|
|
4819
|
-
return /* @__PURE__ */ jsx(
|
|
4820
|
-
"span",
|
|
4821
|
-
{
|
|
4822
|
-
ref,
|
|
4823
|
-
className: cn(baseClasses, highlight && highlightClasses),
|
|
4824
|
-
"data-testid": testId,
|
|
4825
|
-
children: mainContent
|
|
4180
|
+
"path",
|
|
4181
|
+
{
|
|
4182
|
+
d: "M515 353 c-49 -136 -91 -253 -93 -261 -3 -10 11 -12 60 -10 l63 3 19 53 19 52 91 0 92 0 18 -55 17 -56 62 3 c76 4 79 -24 -30 275 l-88 243 -70 0 -70 0 -90 -247z m215 -55 c0 -4 -27 -8 -59 -8 l-60 0 31 92 31 93 29 -85 c15 -46 28 -88 28 -92z",
|
|
4183
|
+
stroke: "currentColor",
|
|
4184
|
+
strokeWidth: "30"
|
|
4185
|
+
}
|
|
4186
|
+
) })
|
|
4187
|
+
] })
|
|
4188
|
+
] })
|
|
4189
|
+
]
|
|
4826
4190
|
}
|
|
4827
4191
|
);
|
|
4828
|
-
}
|
|
4192
|
+
};
|
|
4829
4193
|
function getDocumentTitle(document2, defaultValue = "") {
|
|
4830
4194
|
if (!document2) return defaultValue;
|
|
4831
4195
|
return document2.doc_metadata?.title || document2.file_name || defaultValue;
|
|
@@ -4851,6 +4215,7 @@ function DocumentEntity({
|
|
|
4851
4215
|
icon,
|
|
4852
4216
|
size = "sm",
|
|
4853
4217
|
labelMaxWidth,
|
|
4218
|
+
labelClassName,
|
|
4854
4219
|
onClick,
|
|
4855
4220
|
onIconClick,
|
|
4856
4221
|
showHoverEye,
|
|
@@ -4912,6 +4277,7 @@ function DocumentEntity({
|
|
|
4912
4277
|
size,
|
|
4913
4278
|
label: fullWidth ? title : clampLabel(title),
|
|
4914
4279
|
labelMaxWidth: labelMaxWidth ?? "max-w-[140px]",
|
|
4280
|
+
labelClassName,
|
|
4915
4281
|
fullWidth,
|
|
4916
4282
|
onClick,
|
|
4917
4283
|
onIconClick,
|
|
@@ -4922,120 +4288,6 @@ function DocumentEntity({
|
|
|
4922
4288
|
}
|
|
4923
4289
|
);
|
|
4924
4290
|
}
|
|
4925
|
-
var TAG_TYPE_LABELS = {
|
|
4926
|
-
checkbox: "Checkbox",
|
|
4927
|
-
select: "Select",
|
|
4928
|
-
number: "Number",
|
|
4929
|
-
text: "Text",
|
|
4930
|
-
folder: "Folder",
|
|
4931
|
-
search: "Saved Search",
|
|
4932
|
-
date: "Date",
|
|
4933
|
-
assistant: "AI Assistant"
|
|
4934
|
-
};
|
|
4935
|
-
var TAG_TYPE_ICONS = {
|
|
4936
|
-
checkbox: SquareCheckBig,
|
|
4937
|
-
select: List,
|
|
4938
|
-
number: Hash,
|
|
4939
|
-
text: StickyNote,
|
|
4940
|
-
folder: Folder,
|
|
4941
|
-
search: Search,
|
|
4942
|
-
date: Calendar,
|
|
4943
|
-
assistant: Bot
|
|
4944
|
-
};
|
|
4945
|
-
function getTagTypeIcon(type) {
|
|
4946
|
-
return TAG_TYPE_ICONS[type ?? "text"] || StickyNote;
|
|
4947
|
-
}
|
|
4948
|
-
function getTagTypeLabel(type) {
|
|
4949
|
-
const t = type ?? "text";
|
|
4950
|
-
return TAG_TYPE_LABELS[t] || t;
|
|
4951
|
-
}
|
|
4952
|
-
var BASE_COLORS = {
|
|
4953
|
-
"0": "#10b981",
|
|
4954
|
-
"1": "#3b82f6",
|
|
4955
|
-
"2": "#8b5cf6",
|
|
4956
|
-
"3": "#f43f5e",
|
|
4957
|
-
"4": "#f59e0b",
|
|
4958
|
-
"5": "#84cc16",
|
|
4959
|
-
"6": "#a855f7",
|
|
4960
|
-
"7": "#06b6d4",
|
|
4961
|
-
"8": "#f97316",
|
|
4962
|
-
"9": "#14b8a6",
|
|
4963
|
-
a: "#ef4444",
|
|
4964
|
-
b: "#6366f1",
|
|
4965
|
-
c: "#ec4899",
|
|
4966
|
-
d: "#22c55e",
|
|
4967
|
-
e: "#eab308",
|
|
4968
|
-
f: "#0ea5e9"
|
|
4969
|
-
};
|
|
4970
|
-
function getEntityColor(entityId) {
|
|
4971
|
-
return BASE_COLORS[entityId[4]] || BASE_COLORS["0"];
|
|
4972
|
-
}
|
|
4973
|
-
function TagEntity({
|
|
4974
|
-
tag,
|
|
4975
|
-
size = "md",
|
|
4976
|
-
className = "",
|
|
4977
|
-
onClick,
|
|
4978
|
-
showTooltip = true,
|
|
4979
|
-
tooltipContent
|
|
4980
|
-
}) {
|
|
4981
|
-
const tagType = tag.tag_type?.type ?? "text";
|
|
4982
|
-
const iconSize = size === "sm" ? 12 : size === "md" ? 14 : 16;
|
|
4983
|
-
const Icon2 = getTagTypeIcon(tagType);
|
|
4984
|
-
const sizeClasses2 = {
|
|
4985
|
-
sm: "p-0.5",
|
|
4986
|
-
md: "p-1",
|
|
4987
|
-
lg: "p-1.5"
|
|
4988
|
-
};
|
|
4989
|
-
const tagColor = tag.color ?? getEntityColor(tag.external_id);
|
|
4990
|
-
const iconElement = /* @__PURE__ */ jsx(
|
|
4991
|
-
"span",
|
|
4992
|
-
{
|
|
4993
|
-
className: `inline-flex items-center justify-center rounded-md text-white flex-shrink-0 ${sizeClasses2[size]}`,
|
|
4994
|
-
style: { backgroundColor: tagColor },
|
|
4995
|
-
children: /* @__PURE__ */ jsx(Icon2, { size: iconSize, className: "flex-shrink-0" })
|
|
4996
|
-
}
|
|
4997
|
-
);
|
|
4998
|
-
const pillSize = size === "lg" ? "base" : "sm";
|
|
4999
|
-
const defaultTooltip = /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
5000
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
5001
|
-
/* @__PURE__ */ jsx(
|
|
5002
|
-
"span",
|
|
5003
|
-
{
|
|
5004
|
-
className: "inline-flex items-center justify-center rounded-md text-white p-1",
|
|
5005
|
-
style: { backgroundColor: tagColor },
|
|
5006
|
-
children: /* @__PURE__ */ jsx(Icon2, { size: 16 })
|
|
5007
|
-
}
|
|
5008
|
-
),
|
|
5009
|
-
/* @__PURE__ */ jsx("span", { className: "font-medium text-sm", children: tag.name })
|
|
5010
|
-
] }),
|
|
5011
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5 text-sm", children: [
|
|
5012
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
5013
|
-
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Type:" }),
|
|
5014
|
-
/* @__PURE__ */ jsx("span", { children: getTagTypeLabel(tagType) })
|
|
5015
|
-
] }),
|
|
5016
|
-
tag.doctag_count != null && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
5017
|
-
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Documents:" }),
|
|
5018
|
-
/* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "h-5 min-w-[20px] justify-center", children: tag.doctag_count ?? 0 })
|
|
5019
|
-
] }),
|
|
5020
|
-
tag.shared != null && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: tag.shared ? "Shared" : "Private" }) })
|
|
5021
|
-
] })
|
|
5022
|
-
] });
|
|
5023
|
-
const resolvedTooltip = showTooltip ? tooltipContent ?? defaultTooltip : void 0;
|
|
5024
|
-
return /* @__PURE__ */ jsx(
|
|
5025
|
-
EntityPill,
|
|
5026
|
-
{
|
|
5027
|
-
icon: iconElement,
|
|
5028
|
-
label: tag.name,
|
|
5029
|
-
size: pillSize,
|
|
5030
|
-
shape: "rounded",
|
|
5031
|
-
labelMaxWidth: "max-w-[180px]",
|
|
5032
|
-
tooltipContent: resolvedTooltip,
|
|
5033
|
-
onClick,
|
|
5034
|
-
className,
|
|
5035
|
-
"data-testid": `tag-entity-${tag.external_id}`
|
|
5036
|
-
}
|
|
5037
|
-
);
|
|
5038
|
-
}
|
|
5039
4291
|
var VARIANT_STYLES = {
|
|
5040
4292
|
"mine-paid": {
|
|
5041
4293
|
pill: "bg-primary text-primary-foreground border-transparent",
|
|
@@ -5550,7 +4802,7 @@ var getEntityLabel = (entityType, form = "SINGULAR") => {
|
|
|
5550
4802
|
};
|
|
5551
4803
|
var EntityIcon = ({ entityType, variant = "DEFAULT", ...props }) => {
|
|
5552
4804
|
const IconComponent = getEntityIcon(entityType, variant);
|
|
5553
|
-
return IconComponent ?
|
|
4805
|
+
return IconComponent ? React2.createElement(IconComponent, props) : null;
|
|
5554
4806
|
};
|
|
5555
4807
|
var VISIBILITY_ICONS = {
|
|
5556
4808
|
PRIVATE: MessageSquareLock,
|
|
@@ -5561,7 +4813,7 @@ var VisibilityIcon = ({
|
|
|
5561
4813
|
...props
|
|
5562
4814
|
}) => {
|
|
5563
4815
|
const IconComponent = isShared ? VISIBILITY_ICONS.SHARED : VISIBILITY_ICONS.PRIVATE;
|
|
5564
|
-
return
|
|
4816
|
+
return React2.createElement(IconComponent, props);
|
|
5565
4817
|
};
|
|
5566
4818
|
|
|
5567
4819
|
// src/entities/colors.ts
|
|
@@ -5997,6 +5249,24 @@ function Toaster({ toastOptions, ...props }) {
|
|
|
5997
5249
|
);
|
|
5998
5250
|
}
|
|
5999
5251
|
var DM_QUERY_KEY = ["arbi", "directMessages"];
|
|
5252
|
+
var CONTACTS_QUERY_KEY = ["arbi", "contacts"];
|
|
5253
|
+
function mergeContacts(threads, contacts) {
|
|
5254
|
+
const byPeer = /* @__PURE__ */ new Map();
|
|
5255
|
+
for (const t of threads) byPeer.set(t.peer.external_id, t);
|
|
5256
|
+
for (const c of contacts) {
|
|
5257
|
+
const peer = c.user;
|
|
5258
|
+
if (!peer?.external_id || byPeer.has(peer.external_id)) continue;
|
|
5259
|
+
byPeer.set(peer.external_id, { peer, messages: [], unreadCount: 0, isContactOnly: true });
|
|
5260
|
+
}
|
|
5261
|
+
return [...byPeer.values()].sort((a, b) => {
|
|
5262
|
+
const at = a.lastMessage?.createdAt;
|
|
5263
|
+
const bt = b.lastMessage?.createdAt;
|
|
5264
|
+
if (at && bt) return bt.localeCompare(at);
|
|
5265
|
+
if (at) return -1;
|
|
5266
|
+
if (bt) return 1;
|
|
5267
|
+
return userDisplayName(a.peer).localeCompare(userDisplayName(b.peer));
|
|
5268
|
+
});
|
|
5269
|
+
}
|
|
6000
5270
|
function groupConversations(notifications, myExtId) {
|
|
6001
5271
|
const messagesByPeer = /* @__PURE__ */ new Map();
|
|
6002
5272
|
const peers = /* @__PURE__ */ new Map();
|
|
@@ -6044,28 +5314,46 @@ function useDirectMessages(options) {
|
|
|
6044
5314
|
queryFn: () => arbi.dm.list(),
|
|
6045
5315
|
enabled
|
|
6046
5316
|
});
|
|
5317
|
+
const contactsQuery = useQuery({
|
|
5318
|
+
queryKey: CONTACTS_QUERY_KEY,
|
|
5319
|
+
queryFn: () => arbi.contacts.list(),
|
|
5320
|
+
enabled
|
|
5321
|
+
});
|
|
6047
5322
|
useArbiWsMessage("user_message", () => {
|
|
6048
5323
|
queryClient.invalidateQueries({ queryKey: DM_QUERY_KEY });
|
|
6049
5324
|
});
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
const
|
|
6058
|
-
() =>
|
|
6059
|
-
[query.data
|
|
5325
|
+
let myExtId = null;
|
|
5326
|
+
try {
|
|
5327
|
+
myExtId = arbi.user.identity()?.externalId ?? null;
|
|
5328
|
+
} catch {
|
|
5329
|
+
myExtId = null;
|
|
5330
|
+
}
|
|
5331
|
+
const [pendingSent, setPendingSent] = useState([]);
|
|
5332
|
+
const serverIds = useMemo(
|
|
5333
|
+
() => new Set((query.data ?? []).map((n) => n.external_id)),
|
|
5334
|
+
[query.data]
|
|
6060
5335
|
);
|
|
5336
|
+
useEffect(() => {
|
|
5337
|
+
setPendingSent(
|
|
5338
|
+
(pending) => pending.some((n) => serverIds.has(n.external_id)) ? pending.filter((n) => !serverIds.has(n.external_id)) : pending
|
|
5339
|
+
);
|
|
5340
|
+
}, [serverIds]);
|
|
5341
|
+
const conversations = useMemo(() => {
|
|
5342
|
+
const all = [...pendingSent.filter((n) => !serverIds.has(n.external_id)), ...query.data ?? []];
|
|
5343
|
+
return mergeContacts(groupConversations(all, myExtId), contactsQuery.data ?? []);
|
|
5344
|
+
}, [query.data, serverIds, pendingSent, contactsQuery.data, myExtId]);
|
|
6061
5345
|
const invalidate = () => queryClient.invalidateQueries({ queryKey: DM_QUERY_KEY });
|
|
5346
|
+
const absorbSent = (created) => {
|
|
5347
|
+
setPendingSent((pending) => [...created, ...pending]);
|
|
5348
|
+
invalidate();
|
|
5349
|
+
};
|
|
6062
5350
|
const sendMutation = useMutation({
|
|
6063
5351
|
mutationFn: (vars) => arbi.dm.sendTo(vars.recipientExtId, vars.recipientPublicKey, vars.text),
|
|
6064
|
-
onSuccess:
|
|
5352
|
+
onSuccess: absorbSent
|
|
6065
5353
|
});
|
|
6066
5354
|
const sendToMutation = useMutation({
|
|
6067
5355
|
mutationFn: (vars) => arbi.dm.send(vars.recipient, vars.text),
|
|
6068
|
-
onSuccess:
|
|
5356
|
+
onSuccess: absorbSent
|
|
6069
5357
|
});
|
|
6070
5358
|
const markReadMutation = useMutation({
|
|
6071
5359
|
mutationFn: (messageIds) => arbi.dm.markRead(messageIds),
|
|
@@ -6074,13 +5362,14 @@ function useDirectMessages(options) {
|
|
|
6074
5362
|
return {
|
|
6075
5363
|
conversations,
|
|
6076
5364
|
myExtId,
|
|
6077
|
-
isLoading: query.isLoading && enabled,
|
|
5365
|
+
isLoading: (query.isLoading || contactsQuery.isLoading) && enabled,
|
|
6078
5366
|
isError: query.isError,
|
|
6079
5367
|
error: query.error,
|
|
6080
5368
|
refetch: () => query.refetch(),
|
|
6081
5369
|
sendMessage: (recipientExtId, recipientPublicKey, text) => sendMutation.mutateAsync({ recipientExtId, recipientPublicKey, text }),
|
|
6082
5370
|
sendMessageTo: (recipient, text) => sendToMutation.mutateAsync({ recipient, text }),
|
|
6083
5371
|
isSending: sendMutation.isPending || sendToMutation.isPending,
|
|
5372
|
+
sendError: sendMutation.error ?? sendToMutation.error,
|
|
6084
5373
|
markRead: (messageIds) => markReadMutation.mutateAsync(messageIds)
|
|
6085
5374
|
};
|
|
6086
5375
|
}
|
|
@@ -6116,7 +5405,7 @@ function ConversationList({
|
|
|
6116
5405
|
/* @__PURE__ */ jsx("div", { className: "min-h-0 flex-1 overflow-y-auto", children: conversations.length === 0 ? /* @__PURE__ */ jsx("div", { className: "px-4 py-6 text-xs text-muted-foreground", children: emptyState ?? "No conversations yet." }) : /* @__PURE__ */ jsx("ul", { className: "w-full", children: conversations.map((c) => {
|
|
6117
5406
|
const { peer, lastMessage, unreadCount } = c;
|
|
6118
5407
|
const active = peer.external_id === selectedPeerId;
|
|
6119
|
-
const preview = `${lastMessage.isMine ? "You: " : ""}${lastMessage.body}
|
|
5408
|
+
const preview = lastMessage ? `${lastMessage.isMine ? "You: " : ""}${lastMessage.body}` : "No messages yet \u2014 say hello";
|
|
6120
5409
|
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
|
|
6121
5410
|
"button",
|
|
6122
5411
|
{
|
|
@@ -6132,7 +5421,7 @@ function ConversationList({
|
|
|
6132
5421
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
6133
5422
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
6134
5423
|
/* @__PURE__ */ jsx("span", { className: "truncate text-sm font-semibold text-foreground", children: userDisplayName(peer) }),
|
|
6135
|
-
/* @__PURE__ */ jsx("span", { className: "shrink-0 text-[11px] text-muted-foreground", children: formatRelativeTime(lastMessage.createdAt) })
|
|
5424
|
+
/* @__PURE__ */ jsx("span", { className: "shrink-0 text-[11px] text-muted-foreground", children: lastMessage ? formatRelativeTime(lastMessage.createdAt) : "" })
|
|
6136
5425
|
] }),
|
|
6137
5426
|
/* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-2", children: [
|
|
6138
5427
|
/* @__PURE__ */ jsx("p", { className: "min-w-0 flex-1 truncate text-xs text-muted-foreground", children: preview }),
|
|
@@ -6206,49 +5495,56 @@ function MessageThread({ conversation, classNames, emptyState }) {
|
|
|
6206
5495
|
] }) })
|
|
6207
5496
|
] });
|
|
6208
5497
|
}
|
|
6209
|
-
function DmComposer({ placeholder, disabled, onSend, classNames }) {
|
|
5498
|
+
function DmComposer({ placeholder, disabled, onSend, error, classNames }) {
|
|
6210
5499
|
const [draft, setDraft] = useState("");
|
|
6211
|
-
const submit = () => {
|
|
5500
|
+
const submit = async () => {
|
|
6212
5501
|
const text = draft.trim();
|
|
6213
5502
|
if (!text || disabled) return;
|
|
6214
|
-
onSend(text);
|
|
6215
5503
|
setDraft("");
|
|
5504
|
+
try {
|
|
5505
|
+
await onSend(text);
|
|
5506
|
+
} catch {
|
|
5507
|
+
setDraft(text);
|
|
5508
|
+
}
|
|
6216
5509
|
};
|
|
6217
5510
|
const onKeyDown = (e) => {
|
|
6218
5511
|
if (e.key === "Enter" && !e.shiftKey) {
|
|
6219
5512
|
e.preventDefault();
|
|
6220
|
-
submit();
|
|
5513
|
+
void submit();
|
|
6221
5514
|
}
|
|
6222
5515
|
};
|
|
6223
|
-
return /* @__PURE__ */
|
|
6224
|
-
/* @__PURE__ */
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
5516
|
+
return /* @__PURE__ */ jsxs("div", { className: "border-t border-border p-3", children: [
|
|
5517
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-end gap-2", children: [
|
|
5518
|
+
/* @__PURE__ */ jsx(
|
|
5519
|
+
Textarea,
|
|
5520
|
+
{
|
|
5521
|
+
value: draft,
|
|
5522
|
+
onChange: (e) => setDraft(e.target.value),
|
|
5523
|
+
onKeyDown,
|
|
5524
|
+
placeholder,
|
|
5525
|
+
rows: 1,
|
|
5526
|
+
disabled,
|
|
5527
|
+
className: "max-h-40 min-h-[44px] resize-none",
|
|
5528
|
+
"data-testid": "arbi-dm-input"
|
|
5529
|
+
}
|
|
5530
|
+
),
|
|
5531
|
+
/* @__PURE__ */ jsxs(
|
|
5532
|
+
Button,
|
|
5533
|
+
{
|
|
5534
|
+
type: "button",
|
|
5535
|
+
onClick: () => void submit(),
|
|
5536
|
+
disabled: disabled || !draft.trim(),
|
|
5537
|
+
className: cn(classNames?.sendButton),
|
|
5538
|
+
"data-testid": "arbi-dm-send",
|
|
5539
|
+
children: [
|
|
5540
|
+
/* @__PURE__ */ jsx(Send, { className: "size-4" }),
|
|
5541
|
+
" Send"
|
|
5542
|
+
]
|
|
5543
|
+
}
|
|
5544
|
+
)
|
|
5545
|
+
] }),
|
|
5546
|
+
error && /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs text-destructive", "data-testid": "arbi-dm-error", children: error })
|
|
5547
|
+
] });
|
|
6252
5548
|
}
|
|
6253
5549
|
function DirectMessages({
|
|
6254
5550
|
className,
|
|
@@ -6256,8 +5552,18 @@ function DirectMessages({
|
|
|
6256
5552
|
emptyThread,
|
|
6257
5553
|
emptyList
|
|
6258
5554
|
}) {
|
|
6259
|
-
const {
|
|
5555
|
+
const {
|
|
5556
|
+
conversations,
|
|
5557
|
+
isLoading,
|
|
5558
|
+
isError,
|
|
5559
|
+
error,
|
|
5560
|
+
sendMessage,
|
|
5561
|
+
sendMessageTo,
|
|
5562
|
+
sendError,
|
|
5563
|
+
markRead
|
|
5564
|
+
} = useDirectMessages();
|
|
6260
5565
|
const [selectedPeerId, setSelectedPeerId] = useState(null);
|
|
5566
|
+
const loadError = isError ? error instanceof Error ? error.message : "Couldn\u2019t load messages." : null;
|
|
6261
5567
|
const selected = useMemo(
|
|
6262
5568
|
() => conversations.find((c) => c.peer.external_id === selectedPeerId) ?? null,
|
|
6263
5569
|
[conversations, selectedPeerId]
|
|
@@ -6267,9 +5573,13 @@ function DirectMessages({
|
|
|
6267
5573
|
const unreadIds = selected.messages.filter((m) => !m.isMine && !m.read).map((m) => m.externalId);
|
|
6268
5574
|
if (unreadIds.length) void markRead(unreadIds);
|
|
6269
5575
|
}, [selected?.peer.external_id, selected?.unreadCount]);
|
|
6270
|
-
const handleSend = (text) => {
|
|
5576
|
+
const handleSend = async (text) => {
|
|
6271
5577
|
if (!selected) return;
|
|
6272
|
-
|
|
5578
|
+
if (selected.peer.encryption_public_key) {
|
|
5579
|
+
await sendMessage(selected.peer.external_id, selected.peer.encryption_public_key, text);
|
|
5580
|
+
} else {
|
|
5581
|
+
await sendMessageTo(selected.peer.external_id, text);
|
|
5582
|
+
}
|
|
6273
5583
|
};
|
|
6274
5584
|
return /* @__PURE__ */ jsxs(
|
|
6275
5585
|
"div",
|
|
@@ -6277,10 +5587,18 @@ function DirectMessages({
|
|
|
6277
5587
|
"data-testid": "arbi-dm",
|
|
6278
5588
|
style: { height: "calc(100vh - 16rem)", minHeight: "28rem" },
|
|
6279
5589
|
className: cn(
|
|
6280
|
-
"flex flex-col overflow-hidden rounded-xl border border-border bg-card md:flex-row",
|
|
5590
|
+
"relative flex flex-col overflow-hidden rounded-xl border border-border bg-card md:flex-row",
|
|
6281
5591
|
className
|
|
6282
5592
|
),
|
|
6283
5593
|
children: [
|
|
5594
|
+
loadError && /* @__PURE__ */ jsx(
|
|
5595
|
+
"p",
|
|
5596
|
+
{
|
|
5597
|
+
"data-testid": "arbi-dm-load-error",
|
|
5598
|
+
className: "absolute inset-x-0 top-0 z-10 bg-destructive/10 px-3 py-2 text-center text-xs text-destructive",
|
|
5599
|
+
children: loadError
|
|
5600
|
+
}
|
|
5601
|
+
),
|
|
6284
5602
|
/* @__PURE__ */ jsx(
|
|
6285
5603
|
ConversationList,
|
|
6286
5604
|
{
|
|
@@ -6298,6 +5616,7 @@ function DirectMessages({
|
|
|
6298
5616
|
{
|
|
6299
5617
|
placeholder: `Message ${userDisplayName(selected.peer).split(" ")[0]}\u2026`,
|
|
6300
5618
|
onSend: handleSend,
|
|
5619
|
+
error: sendError?.message ?? null,
|
|
6301
5620
|
classNames
|
|
6302
5621
|
}
|
|
6303
5622
|
) : null
|
|
@@ -6804,7 +6123,7 @@ function DocumentTable({
|
|
|
6804
6123
|
const rows = documents ?? query.data ?? [];
|
|
6805
6124
|
const isLoading = !documents && query.isLoading;
|
|
6806
6125
|
const tagsQuery = useTags(workspaceId);
|
|
6807
|
-
const tagNameById =
|
|
6126
|
+
const tagNameById = React2.useMemo(() => {
|
|
6808
6127
|
const map = /* @__PURE__ */ new Map();
|
|
6809
6128
|
for (const t of tagsQuery.data ?? []) {
|
|
6810
6129
|
if (t.external_id) map.set(t.external_id, t.name ?? t.external_id.slice(0, 8));
|
|
@@ -6817,15 +6136,15 @@ function DocumentTable({
|
|
|
6817
6136
|
const setViewingDocId = useArbiUiStore((s) => s.setViewingDocId);
|
|
6818
6137
|
const effectiveSelected = selectedIds ?? storeSelected;
|
|
6819
6138
|
const emitSelection = onSelectionChange ?? storeSetSelected;
|
|
6820
|
-
const gridApiRef =
|
|
6821
|
-
const openDocument =
|
|
6139
|
+
const gridApiRef = React2.useRef(null);
|
|
6140
|
+
const openDocument = React2.useCallback(
|
|
6822
6141
|
(id) => {
|
|
6823
6142
|
setViewingDocId(id);
|
|
6824
6143
|
onOpenDocument?.(id);
|
|
6825
6144
|
},
|
|
6826
6145
|
[onOpenDocument, setViewingDocId]
|
|
6827
6146
|
);
|
|
6828
|
-
const applySelection =
|
|
6147
|
+
const applySelection = React2.useCallback(() => {
|
|
6829
6148
|
const api = gridApiRef.current;
|
|
6830
6149
|
if (!api) return;
|
|
6831
6150
|
const wanted = new Set(effectiveSelected);
|
|
@@ -6835,10 +6154,10 @@ function DocumentTable({
|
|
|
6835
6154
|
if (node.isSelected() !== shouldSelect) node.setSelected(shouldSelect);
|
|
6836
6155
|
});
|
|
6837
6156
|
}, [effectiveSelected]);
|
|
6838
|
-
|
|
6157
|
+
React2.useEffect(() => {
|
|
6839
6158
|
applySelection();
|
|
6840
6159
|
}, [applySelection]);
|
|
6841
|
-
const columnDefs =
|
|
6160
|
+
const columnDefs = React2.useMemo(
|
|
6842
6161
|
() => [
|
|
6843
6162
|
{
|
|
6844
6163
|
colId: "select",
|
|
@@ -6945,7 +6264,7 @@ function DocumentTable({
|
|
|
6945
6264
|
const id = e.data?.external_id;
|
|
6946
6265
|
if (id) openDocument(id);
|
|
6947
6266
|
};
|
|
6948
|
-
const getRowId =
|
|
6267
|
+
const getRowId = React2.useCallback((params) => params.data.external_id, []);
|
|
6949
6268
|
const autoHeight = height === "auto";
|
|
6950
6269
|
const style = autoHeight ? {} : { height: typeof height === "number" ? `${height}px` : height, width: "100%" };
|
|
6951
6270
|
if (isLoading) {
|
|
@@ -6968,54 +6287,345 @@ function DocumentTable({
|
|
|
6968
6287
|
onSelectionChanged: handleSelectionChanged,
|
|
6969
6288
|
onRowClicked: handleRowClicked
|
|
6970
6289
|
}
|
|
6971
|
-
) });
|
|
6290
|
+
) });
|
|
6291
|
+
}
|
|
6292
|
+
var ACTIVE_STATUSES = /* @__PURE__ */ new Set([
|
|
6293
|
+
"queued",
|
|
6294
|
+
"processing",
|
|
6295
|
+
"parsing",
|
|
6296
|
+
"encrypting",
|
|
6297
|
+
"indexing",
|
|
6298
|
+
"analysing"
|
|
6299
|
+
]);
|
|
6300
|
+
var TERMINAL_STATUSES2 = /* @__PURE__ */ new Set(["completed", "failed", "skipped", "empty", "low-content"]);
|
|
6301
|
+
var STATUS_LABEL = {
|
|
6302
|
+
queued: "Queued",
|
|
6303
|
+
processing: "Processing",
|
|
6304
|
+
parsing: "Parsing",
|
|
6305
|
+
encrypting: "Encrypting",
|
|
6306
|
+
indexing: "Indexing",
|
|
6307
|
+
analysing: "Analysing"
|
|
6308
|
+
};
|
|
6309
|
+
var IMAGE_EXTENSIONS2 = /* @__PURE__ */ new Set(["jpg", "jpeg", "png", "gif", "bmp", "tiff", "tif", "webp"]);
|
|
6310
|
+
var VIDEO_EXTENSIONS2 = /* @__PURE__ */ new Set(["mp4", "mpeg", "mpg", "webm", "mov", "avi", "mkv"]);
|
|
6311
|
+
var AUDIO_EXTENSIONS2 = /* @__PURE__ */ new Set(["mp3", "wav", "m4a", "aac", "ogg", "flac"]);
|
|
6312
|
+
var EMAIL_EXTENSIONS2 = /* @__PURE__ */ new Set(["eml", "msg"]);
|
|
6313
|
+
function fileIcon(fileName, size) {
|
|
6314
|
+
const ext = fileName?.split(".").pop()?.toLowerCase();
|
|
6315
|
+
if (ext && VIDEO_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsx(VidIcon, { size });
|
|
6316
|
+
if (ext && AUDIO_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsx(AudIcon, { size });
|
|
6317
|
+
if (ext && IMAGE_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsx(ImgIcon, { size });
|
|
6318
|
+
if (ext && EMAIL_EXTENSIONS2.has(ext)) return /* @__PURE__ */ jsx(EmlIcon, { size });
|
|
6319
|
+
return /* @__PURE__ */ jsx(PdfIcon, { size });
|
|
6320
|
+
}
|
|
6321
|
+
function RenameField({
|
|
6322
|
+
seed,
|
|
6323
|
+
onCommit,
|
|
6324
|
+
onCancel,
|
|
6325
|
+
testId
|
|
6326
|
+
}) {
|
|
6327
|
+
const done = React2.useRef(false);
|
|
6328
|
+
const commit = (value) => {
|
|
6329
|
+
if (done.current) return;
|
|
6330
|
+
done.current = true;
|
|
6331
|
+
const trimmed = value.trim();
|
|
6332
|
+
if (trimmed && trimmed !== seed) onCommit(trimmed);
|
|
6333
|
+
else onCancel();
|
|
6334
|
+
};
|
|
6335
|
+
return /* @__PURE__ */ jsx(
|
|
6336
|
+
"input",
|
|
6337
|
+
{
|
|
6338
|
+
autoFocus: true,
|
|
6339
|
+
defaultValue: seed,
|
|
6340
|
+
"data-testid": testId,
|
|
6341
|
+
onFocus: (e) => e.currentTarget.select(),
|
|
6342
|
+
onClick: (e) => e.stopPropagation(),
|
|
6343
|
+
onKeyDown: (e) => {
|
|
6344
|
+
if (e.key === "Enter") {
|
|
6345
|
+
e.preventDefault();
|
|
6346
|
+
commit(e.currentTarget.value);
|
|
6347
|
+
} else if (e.key === "Escape") {
|
|
6348
|
+
e.preventDefault();
|
|
6349
|
+
done.current = true;
|
|
6350
|
+
onCancel();
|
|
6351
|
+
}
|
|
6352
|
+
},
|
|
6353
|
+
onBlur: (e) => commit(e.currentTarget.value),
|
|
6354
|
+
className: "w-full rounded border border-primary bg-background px-1 py-0.5 text-xs text-foreground outline-none"
|
|
6355
|
+
}
|
|
6356
|
+
);
|
|
6357
|
+
}
|
|
6358
|
+
function StatusMarker({ status, testId }) {
|
|
6359
|
+
let icon = null;
|
|
6360
|
+
let title = "";
|
|
6361
|
+
switch (status) {
|
|
6362
|
+
case "completed":
|
|
6363
|
+
icon = /* @__PURE__ */ jsx(CheckCircle, { className: "size-4 text-success", strokeWidth: 2.75 });
|
|
6364
|
+
title = "Ready";
|
|
6365
|
+
break;
|
|
6366
|
+
case "failed":
|
|
6367
|
+
icon = /* @__PURE__ */ jsx(XCircle, { className: "size-4 text-destructive", strokeWidth: 2.75 });
|
|
6368
|
+
title = "Failed";
|
|
6369
|
+
break;
|
|
6370
|
+
case "skipped":
|
|
6371
|
+
icon = /* @__PURE__ */ jsx(SkipForward, { className: "size-4 text-muted-foreground", strokeWidth: 2.75 });
|
|
6372
|
+
title = "Skipped";
|
|
6373
|
+
break;
|
|
6374
|
+
case "empty":
|
|
6375
|
+
icon = /* @__PURE__ */ jsx(FileX, { className: "size-4 text-warning", strokeWidth: 2.75 });
|
|
6376
|
+
title = "Empty \u2014 no extractable content";
|
|
6377
|
+
break;
|
|
6378
|
+
case "low-content":
|
|
6379
|
+
icon = /* @__PURE__ */ jsx(AlertTriangle, { className: "size-4 text-warning", strokeWidth: 2.75 });
|
|
6380
|
+
title = "Low content \u2014 minimal extractable content";
|
|
6381
|
+
break;
|
|
6382
|
+
default:
|
|
6383
|
+
return null;
|
|
6384
|
+
}
|
|
6385
|
+
return /* @__PURE__ */ jsx(
|
|
6386
|
+
"span",
|
|
6387
|
+
{
|
|
6388
|
+
title,
|
|
6389
|
+
"data-testid": testId,
|
|
6390
|
+
className: "flex size-6 items-center justify-center rounded-full bg-background shadow-sm",
|
|
6391
|
+
children: icon
|
|
6392
|
+
}
|
|
6393
|
+
);
|
|
6394
|
+
}
|
|
6395
|
+
function DocumentCard({
|
|
6396
|
+
doc,
|
|
6397
|
+
thumbnailUrl,
|
|
6398
|
+
status,
|
|
6399
|
+
selected = false,
|
|
6400
|
+
onToggleSelect,
|
|
6401
|
+
viewing = false,
|
|
6402
|
+
onOpen,
|
|
6403
|
+
actions,
|
|
6404
|
+
renaming = false,
|
|
6405
|
+
onCommitRename,
|
|
6406
|
+
onCancelRename,
|
|
6407
|
+
tooltipContent,
|
|
6408
|
+
marker,
|
|
6409
|
+
testId = "document-card",
|
|
6410
|
+
className
|
|
6411
|
+
}) {
|
|
6412
|
+
const normalised = (status ?? "").toLowerCase();
|
|
6413
|
+
const isProcessing = ACTIVE_STATUSES.has(normalised);
|
|
6414
|
+
const showStatusMarker = !isProcessing && TERMINAL_STATUSES2.has(normalised);
|
|
6415
|
+
const [thumbFailed, setThumbFailed] = React2.useState(false);
|
|
6416
|
+
const [thumbLandscape, setThumbLandscape] = React2.useState(false);
|
|
6417
|
+
const showThumbnail = !!thumbnailUrl && !thumbFailed && !isProcessing;
|
|
6418
|
+
return /* @__PURE__ */ jsxs(
|
|
6419
|
+
"div",
|
|
6420
|
+
{
|
|
6421
|
+
"data-testid": testId,
|
|
6422
|
+
className: cn(
|
|
6423
|
+
// Square corners and a portrait-page aspect (height = 1.3 × width), so a
|
|
6424
|
+
// cover-page thumbnail reads edge-to-edge.
|
|
6425
|
+
"group relative aspect-[10/13] select-none overflow-hidden border bg-muted/20 transition",
|
|
6426
|
+
selected ? "border-primary bg-primary/10" : "border-border shadow-sm hover:border-border/80 hover:bg-muted/50",
|
|
6427
|
+
className
|
|
6428
|
+
),
|
|
6429
|
+
children: [
|
|
6430
|
+
showThumbnail ? /* @__PURE__ */ jsx(
|
|
6431
|
+
"img",
|
|
6432
|
+
{
|
|
6433
|
+
src: thumbnailUrl,
|
|
6434
|
+
alt: "",
|
|
6435
|
+
loading: "lazy",
|
|
6436
|
+
draggable: false,
|
|
6437
|
+
onError: () => setThumbFailed(true),
|
|
6438
|
+
onLoad: (e) => setThumbLandscape(e.currentTarget.naturalWidth > e.currentTarget.naturalHeight),
|
|
6439
|
+
className: cn(
|
|
6440
|
+
"absolute inset-0 size-full bg-white",
|
|
6441
|
+
thumbLandscape ? "object-contain" : "object-cover object-top"
|
|
6442
|
+
)
|
|
6443
|
+
}
|
|
6444
|
+
) : /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center text-muted-foreground", children: fileIcon(doc.file_name, 44) }),
|
|
6445
|
+
isProcessing && /* @__PURE__ */ jsxs(
|
|
6446
|
+
"div",
|
|
6447
|
+
{
|
|
6448
|
+
"data-testid": `${testId}-processing`,
|
|
6449
|
+
className: "absolute inset-0 z-10 flex flex-col items-center justify-center gap-1.5 bg-background/80 px-3",
|
|
6450
|
+
children: [
|
|
6451
|
+
/* @__PURE__ */ jsx("div", { className: "h-1.5 w-full overflow-hidden rounded-sm bg-muted", children: /* @__PURE__ */ jsx("div", { className: "h-full w-1/3 animate-pulse rounded-sm bg-primary" }) }),
|
|
6452
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-primary", children: STATUS_LABEL[normalised] ?? normalised })
|
|
6453
|
+
]
|
|
6454
|
+
}
|
|
6455
|
+
),
|
|
6456
|
+
onToggleSelect && /* @__PURE__ */ jsx(
|
|
6457
|
+
Checkbox,
|
|
6458
|
+
{
|
|
6459
|
+
checked: selected,
|
|
6460
|
+
onCheckedChange: () => onToggleSelect(),
|
|
6461
|
+
onClick: (e) => e.stopPropagation(),
|
|
6462
|
+
"aria-label": selected ? "Deselect" : "Select",
|
|
6463
|
+
"data-testid": `${testId}-select`,
|
|
6464
|
+
className: cn(
|
|
6465
|
+
"absolute left-1.5 top-1.5 z-20 size-6 rounded-none border-muted-foreground/60 bg-background shadow-sm transition",
|
|
6466
|
+
selected ? "opacity-100" : "opacity-40 group-hover:opacity-100"
|
|
6467
|
+
)
|
|
6468
|
+
}
|
|
6469
|
+
),
|
|
6470
|
+
actions && /* @__PURE__ */ jsx("div", { className: "absolute right-1.5 top-1.5 z-20", children: actions }),
|
|
6471
|
+
/* @__PURE__ */ jsxs("div", { className: "absolute inset-x-1.5 bottom-1.5 z-20 flex flex-col gap-1", children: [
|
|
6472
|
+
(marker || showStatusMarker) && /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
6473
|
+
marker,
|
|
6474
|
+
showStatusMarker && /* @__PURE__ */ jsx("div", { className: "ml-auto flex", children: /* @__PURE__ */ jsx(StatusMarker, { status: normalised, testId: `${testId}-status` }) })
|
|
6475
|
+
] }),
|
|
6476
|
+
renaming ? /* @__PURE__ */ jsx(
|
|
6477
|
+
RenameField,
|
|
6478
|
+
{
|
|
6479
|
+
seed: doc.doc_metadata?.title || doc.file_name || "",
|
|
6480
|
+
onCommit: (name) => onCommitRename?.(name),
|
|
6481
|
+
onCancel: () => onCancelRename?.(),
|
|
6482
|
+
testId: `${testId}-rename-input`
|
|
6483
|
+
}
|
|
6484
|
+
) : /* @__PURE__ */ jsx(
|
|
6485
|
+
DocumentEntity,
|
|
6486
|
+
{
|
|
6487
|
+
doc,
|
|
6488
|
+
fullWidth: true,
|
|
6489
|
+
showHoverEye: true,
|
|
6490
|
+
viewing,
|
|
6491
|
+
tooltipContent,
|
|
6492
|
+
labelClassName: "font-semibold",
|
|
6493
|
+
className: "w-full min-w-0 max-w-full bg-background/90 backdrop-blur-sm",
|
|
6494
|
+
onClick: (e) => {
|
|
6495
|
+
e.stopPropagation();
|
|
6496
|
+
onOpen?.();
|
|
6497
|
+
}
|
|
6498
|
+
}
|
|
6499
|
+
)
|
|
6500
|
+
] })
|
|
6501
|
+
]
|
|
6502
|
+
}
|
|
6503
|
+
);
|
|
6972
6504
|
}
|
|
6973
|
-
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
6977
|
-
|
|
6978
|
-
|
|
6979
|
-
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
|
|
6505
|
+
function DocumentCardMenu({
|
|
6506
|
+
docId,
|
|
6507
|
+
fileName,
|
|
6508
|
+
onOpen,
|
|
6509
|
+
onRename,
|
|
6510
|
+
canDelete = true,
|
|
6511
|
+
testId = "document-card-menu"
|
|
6512
|
+
}) {
|
|
6513
|
+
const arbi = useArbi();
|
|
6514
|
+
const queryClient = useQueryClient();
|
|
6515
|
+
const invalidateDocuments = () => {
|
|
6516
|
+
const workspaceId = arbi.getWorkspaceId();
|
|
6517
|
+
if (workspaceId) {
|
|
6518
|
+
void queryClient.invalidateQueries({ queryKey: arbiQueryKeys.documents(workspaceId) });
|
|
6519
|
+
}
|
|
6520
|
+
};
|
|
6521
|
+
const download = useMutation({
|
|
6522
|
+
mutationFn: async () => {
|
|
6523
|
+
const response = await arbi.documents.download(docId);
|
|
6524
|
+
if (!response.ok) throw new Error(`Failed to download ${fileName}`);
|
|
6525
|
+
return response.blob();
|
|
6526
|
+
},
|
|
6527
|
+
onSuccess: (blob) => {
|
|
6528
|
+
const url = URL.createObjectURL(blob);
|
|
6529
|
+
const anchor = document.createElement("a");
|
|
6530
|
+
anchor.href = url;
|
|
6531
|
+
anchor.download = fileName;
|
|
6532
|
+
anchor.click();
|
|
6533
|
+
URL.revokeObjectURL(url);
|
|
6534
|
+
}
|
|
6535
|
+
});
|
|
6536
|
+
const remove = useMutation({
|
|
6537
|
+
mutationFn: () => arbi.documents.delete([docId]),
|
|
6538
|
+
onSuccess: invalidateDocuments
|
|
6539
|
+
});
|
|
6540
|
+
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
6541
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
6542
|
+
"button",
|
|
6543
|
+
{
|
|
6544
|
+
type: "button",
|
|
6545
|
+
"aria-label": "More actions",
|
|
6546
|
+
"data-testid": testId,
|
|
6547
|
+
onClick: (e) => e.stopPropagation(),
|
|
6548
|
+
className: "flex size-6 items-center justify-center rounded-md bg-background/90 text-muted-foreground shadow-sm backdrop-blur-sm transition hover:bg-background hover:text-foreground data-[state=open]:bg-background data-[state=open]:text-foreground",
|
|
6549
|
+
children: /* @__PURE__ */ jsx(MoreHorizontal, { className: "size-4" })
|
|
6550
|
+
}
|
|
6551
|
+
) }),
|
|
6552
|
+
/* @__PURE__ */ jsxs(DropdownMenuContent, { align: "start", onClick: (e) => e.stopPropagation(), className: "w-44", children: [
|
|
6553
|
+
onOpen && /* @__PURE__ */ jsxs(DropdownMenuItem, { onSelect: onOpen, "data-testid": `${testId}-open`, children: [
|
|
6554
|
+
/* @__PURE__ */ jsx(SquarePen, { className: "mr-2 size-4" }),
|
|
6555
|
+
"Open"
|
|
6556
|
+
] }),
|
|
6557
|
+
onRename && /* @__PURE__ */ jsxs(DropdownMenuItem, { onSelect: onRename, "data-testid": `${testId}-rename`, children: [
|
|
6558
|
+
/* @__PURE__ */ jsx(Pencil, { className: "mr-2 size-4" }),
|
|
6559
|
+
"Rename"
|
|
6560
|
+
] }),
|
|
6561
|
+
/* @__PURE__ */ jsxs(
|
|
6562
|
+
DropdownMenuItem,
|
|
6563
|
+
{
|
|
6564
|
+
onSelect: () => download.mutate(),
|
|
6565
|
+
disabled: download.isPending,
|
|
6566
|
+
"data-testid": `${testId}-download`,
|
|
6567
|
+
children: [
|
|
6568
|
+
/* @__PURE__ */ jsx(Download, { className: "mr-2 size-4" }),
|
|
6569
|
+
"Download"
|
|
6570
|
+
]
|
|
6571
|
+
}
|
|
6572
|
+
),
|
|
6573
|
+
canDelete && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6574
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
6575
|
+
/* @__PURE__ */ jsxs(
|
|
6576
|
+
DropdownMenuItem,
|
|
6577
|
+
{
|
|
6578
|
+
onSelect: () => remove.mutate(),
|
|
6579
|
+
disabled: remove.isPending,
|
|
6580
|
+
className: "text-destructive focus:text-destructive",
|
|
6581
|
+
"data-testid": `${testId}-delete`,
|
|
6582
|
+
children: [
|
|
6583
|
+
/* @__PURE__ */ jsx(Trash2, { className: "mr-2 size-4" }),
|
|
6584
|
+
"Delete"
|
|
6585
|
+
]
|
|
6586
|
+
}
|
|
6587
|
+
)
|
|
6588
|
+
] })
|
|
6589
|
+
] })
|
|
6590
|
+
] });
|
|
6994
6591
|
}
|
|
6995
6592
|
function docTitle(doc) {
|
|
6996
6593
|
return doc.doc_metadata?.title || doc.file_name || "Untitled";
|
|
6997
6594
|
}
|
|
6595
|
+
function TileTooltip({ title, labels }) {
|
|
6596
|
+
return /* @__PURE__ */ jsxs("div", { className: "max-w-xs space-y-2", children: [
|
|
6597
|
+
/* @__PURE__ */ jsx("div", { className: "break-words text-xs font-semibold leading-snug", children: title }),
|
|
6598
|
+
labels.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1 border-t border-border/60 pt-1.5", children: labels.map((label) => /* @__PURE__ */ jsx(
|
|
6599
|
+
"span",
|
|
6600
|
+
{
|
|
6601
|
+
className: "rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium text-foreground/80",
|
|
6602
|
+
children: label
|
|
6603
|
+
},
|
|
6604
|
+
label
|
|
6605
|
+
)) })
|
|
6606
|
+
] });
|
|
6607
|
+
}
|
|
6998
6608
|
function DocumentGallery({
|
|
6999
6609
|
workspaceId,
|
|
7000
6610
|
documents,
|
|
7001
6611
|
onOpenDocument,
|
|
7002
6612
|
selectedIds,
|
|
7003
6613
|
onSelectionChange,
|
|
7004
|
-
minTileWidth =
|
|
6614
|
+
minTileWidth = 148,
|
|
7005
6615
|
className
|
|
7006
6616
|
}) {
|
|
7007
6617
|
const query = useDocuments(workspaceId, { enabled: !documents });
|
|
7008
6618
|
const rows = documents ?? query.data ?? [];
|
|
7009
6619
|
const isLoading = !documents && query.isLoading;
|
|
7010
6620
|
const tagsQuery = useTags(workspaceId);
|
|
7011
|
-
const tagNameById =
|
|
6621
|
+
const tagNameById = React2.useMemo(() => {
|
|
7012
6622
|
const map = /* @__PURE__ */ new Map();
|
|
7013
6623
|
for (const t of tagsQuery.data ?? []) {
|
|
7014
6624
|
if (t.external_id) map.set(t.external_id, t.name ?? t.external_id.slice(0, 8));
|
|
7015
6625
|
}
|
|
7016
6626
|
return map;
|
|
7017
6627
|
}, [tagsQuery.data]);
|
|
7018
|
-
const docIds =
|
|
6628
|
+
const docIds = React2.useMemo(
|
|
7019
6629
|
() => rows.map((d) => d.external_id).filter((id) => !!id),
|
|
7020
6630
|
[rows]
|
|
7021
6631
|
);
|
|
@@ -7027,8 +6637,8 @@ function DocumentGallery({
|
|
|
7027
6637
|
const setViewingDocId = useArbiUiStore((s) => s.setViewingDocId);
|
|
7028
6638
|
const effectiveSelected = selectedIds ?? storeSelected;
|
|
7029
6639
|
const emitSelection = onSelectionChange ?? storeSetSelected;
|
|
7030
|
-
const selectedSet =
|
|
7031
|
-
const toggleSelected =
|
|
6640
|
+
const selectedSet = React2.useMemo(() => new Set(effectiveSelected), [effectiveSelected]);
|
|
6641
|
+
const toggleSelected = React2.useCallback(
|
|
7032
6642
|
(id) => {
|
|
7033
6643
|
const next = new Set(effectiveSelected);
|
|
7034
6644
|
if (next.has(id)) next.delete(id);
|
|
@@ -7037,13 +6647,28 @@ function DocumentGallery({
|
|
|
7037
6647
|
},
|
|
7038
6648
|
[effectiveSelected, emitSelection]
|
|
7039
6649
|
);
|
|
7040
|
-
const openDocument =
|
|
6650
|
+
const openDocument = React2.useCallback(
|
|
7041
6651
|
(id) => {
|
|
7042
6652
|
setViewingDocId(id);
|
|
7043
6653
|
onOpenDocument?.(id);
|
|
7044
6654
|
},
|
|
7045
6655
|
[onOpenDocument, setViewingDocId]
|
|
7046
6656
|
);
|
|
6657
|
+
const arbi = useArbi();
|
|
6658
|
+
const queryClient = useQueryClient();
|
|
6659
|
+
const [renamingId, setRenamingId] = React2.useState(null);
|
|
6660
|
+
const rename = useMutation({
|
|
6661
|
+
mutationFn: ({ doc, title }) => arbi.documents.update([
|
|
6662
|
+
{ external_id: doc.external_id, doc_metadata: { ...doc.doc_metadata, title } }
|
|
6663
|
+
]),
|
|
6664
|
+
onSettled: () => {
|
|
6665
|
+
setRenamingId(null);
|
|
6666
|
+
const activeWorkspace = workspaceId ?? arbi.getWorkspaceId();
|
|
6667
|
+
if (activeWorkspace) {
|
|
6668
|
+
void queryClient.invalidateQueries({ queryKey: arbiQueryKeys.documents(activeWorkspace) });
|
|
6669
|
+
}
|
|
6670
|
+
}
|
|
6671
|
+
});
|
|
7047
6672
|
if (isLoading) {
|
|
7048
6673
|
return /* @__PURE__ */ jsx(
|
|
7049
6674
|
"div",
|
|
@@ -7072,265 +6697,46 @@ function DocumentGallery({
|
|
|
7072
6697
|
"div",
|
|
7073
6698
|
{
|
|
7074
6699
|
"data-testid": "document-gallery",
|
|
7075
|
-
className: cn("grid gap-
|
|
6700
|
+
className: cn("grid gap-3", className),
|
|
7076
6701
|
style: { gridTemplateColumns: `repeat(auto-fill, minmax(${minTileWidth}px, 1fr))` },
|
|
7077
6702
|
children: rows.map((doc) => {
|
|
7078
6703
|
const id = doc.external_id;
|
|
7079
6704
|
if (!id) return null;
|
|
7080
6705
|
const title = docTitle(doc);
|
|
7081
|
-
const
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
|
|
7085
|
-
|
|
7086
|
-
return /* @__PURE__ */ jsxs(
|
|
7087
|
-
"div",
|
|
6706
|
+
const labels = (doc.doctags ?? []).map(
|
|
6707
|
+
(dt) => tagNameById.get(dt.tag_ext_id) ?? dt.tag_ext_id.slice(0, 8)
|
|
6708
|
+
);
|
|
6709
|
+
return /* @__PURE__ */ jsx("div", { "data-doc-id": id, "data-testid": "document-gallery-card", children: /* @__PURE__ */ jsx(
|
|
6710
|
+
DocumentCard,
|
|
7088
6711
|
{
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
|
|
7092
|
-
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
|
|
6712
|
+
doc,
|
|
6713
|
+
thumbnailUrl: thumbs[id],
|
|
6714
|
+
status: doc.status,
|
|
6715
|
+
selected: selectedSet.has(id),
|
|
6716
|
+
onToggleSelect: () => toggleSelected(id),
|
|
6717
|
+
viewing: viewingDocId === id,
|
|
6718
|
+
onOpen: () => openDocument(id),
|
|
6719
|
+
renaming: renamingId === id,
|
|
6720
|
+
onCommitRename: (newTitle) => rename.mutate({ doc, title: newTitle }),
|
|
6721
|
+
onCancelRename: () => setRenamingId(null),
|
|
6722
|
+
actions: /* @__PURE__ */ jsx(
|
|
6723
|
+
DocumentCardMenu,
|
|
6724
|
+
{
|
|
6725
|
+
docId: id,
|
|
6726
|
+
fileName: doc.file_name ?? title,
|
|
6727
|
+
onOpen: () => openDocument(id),
|
|
6728
|
+
onRename: () => setRenamingId(id),
|
|
6729
|
+
testId: `document-card-menu-${id}`
|
|
7098
6730
|
}
|
|
7099
|
-
},
|
|
7100
|
-
className: cn(
|
|
7101
|
-
"group relative flex flex-col overflow-hidden rounded-lg border bg-card text-left shadow-sm transition",
|
|
7102
|
-
"hover:shadow-md hover:border-ring focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
7103
|
-
viewing && "ring-2 ring-ring",
|
|
7104
|
-
selected && "border-ring"
|
|
7105
6731
|
),
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
{
|
|
7110
|
-
className: "absolute left-2 top-2 z-10 flex h-5 w-5 items-center justify-center rounded bg-background/80 shadow-sm backdrop-blur",
|
|
7111
|
-
onClick: (e) => e.stopPropagation(),
|
|
7112
|
-
children: /* @__PURE__ */ jsx(
|
|
7113
|
-
"input",
|
|
7114
|
-
{
|
|
7115
|
-
type: "checkbox",
|
|
7116
|
-
"aria-label": `Select ${title}`,
|
|
7117
|
-
checked: selected,
|
|
7118
|
-
onChange: () => toggleSelected(id),
|
|
7119
|
-
className: "h-3.5 w-3.5 cursor-pointer accent-current"
|
|
7120
|
-
}
|
|
7121
|
-
)
|
|
7122
|
-
}
|
|
7123
|
-
),
|
|
7124
|
-
/* @__PURE__ */ jsx("div", { className: "flex aspect-[3/4] items-center justify-center overflow-hidden bg-muted", children: thumb ? /* @__PURE__ */ jsx(
|
|
7125
|
-
"img",
|
|
7126
|
-
{
|
|
7127
|
-
src: thumb,
|
|
7128
|
-
alt: title,
|
|
7129
|
-
loading: "lazy",
|
|
7130
|
-
className: "h-full w-full object-cover object-top"
|
|
7131
|
-
}
|
|
7132
|
-
) : /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center gap-2 text-muted-foreground", children: fileIcon(doc.file_name) }) }),
|
|
7133
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col gap-2 p-3", children: [
|
|
7134
|
-
/* @__PURE__ */ jsx("div", { className: "line-clamp-2 text-sm font-medium leading-snug", title, children: title }),
|
|
7135
|
-
/* @__PURE__ */ jsxs("div", { className: "mt-auto flex flex-wrap items-center gap-1", children: [
|
|
7136
|
-
status ? /* @__PURE__ */ jsx(Badge, { variant: STATUS_VARIANTS2[status.toLowerCase()] ?? "secondary", children: status }) : null,
|
|
7137
|
-
doctags.slice(0, 3).map((dt) => /* @__PURE__ */ jsx(
|
|
7138
|
-
TagEntity,
|
|
7139
|
-
{
|
|
7140
|
-
size: "sm",
|
|
7141
|
-
tag: {
|
|
7142
|
-
external_id: dt.tag_ext_id,
|
|
7143
|
-
name: tagNameById.get(dt.tag_ext_id) ?? dt.tag_ext_id.slice(0, 8)
|
|
7144
|
-
}
|
|
7145
|
-
},
|
|
7146
|
-
dt.tag_ext_id
|
|
7147
|
-
)),
|
|
7148
|
-
doctags.length > 3 ? /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
|
|
7149
|
-
"+",
|
|
7150
|
-
doctags.length - 3
|
|
7151
|
-
] }) : null
|
|
7152
|
-
] })
|
|
7153
|
-
] })
|
|
7154
|
-
]
|
|
7155
|
-
},
|
|
7156
|
-
id
|
|
7157
|
-
);
|
|
6732
|
+
tooltipContent: /* @__PURE__ */ jsx(TileTooltip, { title, labels })
|
|
6733
|
+
}
|
|
6734
|
+
) }, id);
|
|
7158
6735
|
})
|
|
7159
6736
|
}
|
|
7160
6737
|
);
|
|
7161
6738
|
}
|
|
7162
|
-
function DocumentReview({
|
|
7163
|
-
docId,
|
|
7164
|
-
doc,
|
|
7165
|
-
workspaceId,
|
|
7166
|
-
stage = "final",
|
|
7167
|
-
onClose,
|
|
7168
|
-
className
|
|
7169
|
-
}) {
|
|
7170
|
-
const parsedQuery = useParsedDocument(docId, stage);
|
|
7171
|
-
const tagsQuery = useTags(workspaceId);
|
|
7172
|
-
const tagNameById = React__default.useMemo(() => {
|
|
7173
|
-
const map = /* @__PURE__ */ new Map();
|
|
7174
|
-
for (const t of tagsQuery.data ?? []) {
|
|
7175
|
-
if (t.external_id) map.set(t.external_id, t.name ?? t.external_id.slice(0, 8));
|
|
7176
|
-
}
|
|
7177
|
-
return map;
|
|
7178
|
-
}, [tagsQuery.data]);
|
|
7179
|
-
const title = doc?.doc_metadata?.title || doc?.file_name || "Document";
|
|
7180
|
-
const { findings, chunkToTag } = React__default.useMemo(() => {
|
|
7181
|
-
const list = [];
|
|
7182
|
-
const chunkTag = /* @__PURE__ */ new Map();
|
|
7183
|
-
for (const dt of doc?.doctags ?? []) {
|
|
7184
|
-
const citations = dt.citations ?? {};
|
|
7185
|
-
for (const [citId, cit] of Object.entries(citations)) {
|
|
7186
|
-
const chunkIds = cit?.chunk_ids ?? [];
|
|
7187
|
-
if (chunkIds.length === 0) continue;
|
|
7188
|
-
list.push({
|
|
7189
|
-
key: `${dt.tag_ext_id}:${citId}`,
|
|
7190
|
-
tagExtId: dt.tag_ext_id,
|
|
7191
|
-
statement: cit.statement,
|
|
7192
|
-
chunkIds
|
|
7193
|
-
});
|
|
7194
|
-
for (const cid of chunkIds) if (!chunkTag.has(cid)) chunkTag.set(cid, dt.tag_ext_id);
|
|
7195
|
-
}
|
|
7196
|
-
}
|
|
7197
|
-
return { findings: list, chunkToTag: chunkTag };
|
|
7198
|
-
}, [doc?.doctags]);
|
|
7199
|
-
const pages = React__default.useMemo(() => {
|
|
7200
|
-
const chunks = parsedQuery.data?.chunks ?? [];
|
|
7201
|
-
const byPage = /* @__PURE__ */ new Map();
|
|
7202
|
-
for (const c of chunks) {
|
|
7203
|
-
const p = c.metadata?.page_number ?? 0;
|
|
7204
|
-
if (!byPage.has(p)) byPage.set(p, []);
|
|
7205
|
-
byPage.get(p).push(c);
|
|
7206
|
-
}
|
|
7207
|
-
return [...byPage.entries()].sort((a, b) => a[0] - b[0]);
|
|
7208
|
-
}, [parsedQuery.data]);
|
|
7209
|
-
const scrollRef = React__default.useRef(null);
|
|
7210
|
-
const [flash, setFlash] = React__default.useState(null);
|
|
7211
|
-
const jumpToChunk = React__default.useCallback((chunkId) => {
|
|
7212
|
-
const el = scrollRef.current?.querySelector(`[data-chunk-id="${chunkId}"]`);
|
|
7213
|
-
if (!el) return;
|
|
7214
|
-
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
7215
|
-
setFlash(chunkId);
|
|
7216
|
-
window.setTimeout(() => setFlash((c) => c === chunkId ? null : c), 1600);
|
|
7217
|
-
}, []);
|
|
7218
|
-
return /* @__PURE__ */ jsxs(
|
|
7219
|
-
"div",
|
|
7220
|
-
{
|
|
7221
|
-
"data-testid": "document-review",
|
|
7222
|
-
className: cn(
|
|
7223
|
-
"flex h-full min-h-0 flex-col overflow-hidden rounded-lg border bg-card",
|
|
7224
|
-
className
|
|
7225
|
-
),
|
|
7226
|
-
children: [
|
|
7227
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 border-b px-4 py-3", children: [
|
|
7228
|
-
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
7229
|
-
/* @__PURE__ */ jsx("div", { className: "truncate text-sm font-semibold", title, children: title }),
|
|
7230
|
-
/* @__PURE__ */ jsxs("div", { className: "text-xs text-muted-foreground", children: [
|
|
7231
|
-
parsedQuery.data?.metadata?.total_number_of_pages ? `${parsedQuery.data.metadata.total_number_of_pages} pages` : `${pages.length} pages`,
|
|
7232
|
-
findings.length ? ` \xB7 ${findings.length} findings` : ""
|
|
7233
|
-
] })
|
|
7234
|
-
] }),
|
|
7235
|
-
doc?.status ? /* @__PURE__ */ jsx(Badge, { variant: "secondary", children: doc.status }) : null,
|
|
7236
|
-
onClose ? /* @__PURE__ */ jsx(
|
|
7237
|
-
"button",
|
|
7238
|
-
{
|
|
7239
|
-
type: "button",
|
|
7240
|
-
"aria-label": "Close review",
|
|
7241
|
-
"data-testid": "document-review-close",
|
|
7242
|
-
onClick: onClose,
|
|
7243
|
-
className: "rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground",
|
|
7244
|
-
children: /* @__PURE__ */ jsx(X, { className: "size-4" })
|
|
7245
|
-
}
|
|
7246
|
-
) : null
|
|
7247
|
-
] }),
|
|
7248
|
-
/* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-1", children: [
|
|
7249
|
-
findings.length > 0 ? /* @__PURE__ */ jsxs(
|
|
7250
|
-
"aside",
|
|
7251
|
-
{
|
|
7252
|
-
className: "hidden w-64 shrink-0 overflow-y-auto border-r p-3 md:block",
|
|
7253
|
-
"data-testid": "document-review-findings",
|
|
7254
|
-
children: [
|
|
7255
|
-
/* @__PURE__ */ jsx("div", { className: "mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground", children: "AI findings" }),
|
|
7256
|
-
/* @__PURE__ */ jsx("ul", { className: "space-y-2", children: findings.map((f) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
|
|
7257
|
-
"div",
|
|
7258
|
-
{
|
|
7259
|
-
role: "button",
|
|
7260
|
-
tabIndex: 0,
|
|
7261
|
-
"data-testid": "review-finding",
|
|
7262
|
-
onClick: () => jumpToChunk(f.chunkIds[0]),
|
|
7263
|
-
onKeyDown: (e) => {
|
|
7264
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
7265
|
-
e.preventDefault();
|
|
7266
|
-
jumpToChunk(f.chunkIds[0]);
|
|
7267
|
-
}
|
|
7268
|
-
},
|
|
7269
|
-
className: "w-full cursor-pointer rounded-md border p-2 text-left text-xs transition hover:border-ring hover:bg-muted/50 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
7270
|
-
children: [
|
|
7271
|
-
/* @__PURE__ */ jsx(
|
|
7272
|
-
TagEntity,
|
|
7273
|
-
{
|
|
7274
|
-
size: "sm",
|
|
7275
|
-
tag: {
|
|
7276
|
-
external_id: f.tagExtId,
|
|
7277
|
-
name: tagNameById.get(f.tagExtId) ?? f.tagExtId.slice(0, 8)
|
|
7278
|
-
}
|
|
7279
|
-
}
|
|
7280
|
-
),
|
|
7281
|
-
/* @__PURE__ */ jsx("p", { className: "mt-1 line-clamp-3 text-muted-foreground", children: f.statement })
|
|
7282
|
-
]
|
|
7283
|
-
}
|
|
7284
|
-
) }, f.key)) })
|
|
7285
|
-
]
|
|
7286
|
-
}
|
|
7287
|
-
) : null,
|
|
7288
|
-
/* @__PURE__ */ jsx("div", { ref: scrollRef, className: "min-w-0 flex-1 overflow-y-auto px-6 py-4", children: parsedQuery.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex h-full items-center justify-center text-sm text-muted-foreground", children: "Loading document\u2026" }) : parsedQuery.isError ? /* @__PURE__ */ jsx("div", { className: "flex h-full items-center justify-center text-sm text-muted-foreground", children: "Could not load this document\u2019s content." }) : pages.length === 0 ? /* @__PURE__ */ jsx("div", { className: "flex h-full items-center justify-center text-sm text-muted-foreground", children: "No readable content." }) : /* @__PURE__ */ jsx("div", { className: "mx-auto max-w-3xl space-y-8", children: pages.map(([pageNum, chunks]) => /* @__PURE__ */ jsxs("section", { children: [
|
|
7289
|
-
/* @__PURE__ */ jsxs("div", { className: "mb-3 flex items-center gap-3", children: [
|
|
7290
|
-
/* @__PURE__ */ jsxs("span", { className: "text-xs font-medium uppercase tracking-wide text-muted-foreground", children: [
|
|
7291
|
-
"Page ",
|
|
7292
|
-
pageNum
|
|
7293
|
-
] }),
|
|
7294
|
-
/* @__PURE__ */ jsx("div", { className: "h-px flex-1 bg-border" })
|
|
7295
|
-
] }),
|
|
7296
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-3", children: chunks.map((c, i) => {
|
|
7297
|
-
const cid = c.metadata?.chunk_ext_id;
|
|
7298
|
-
const tagExtId = cid ? chunkToTag.get(cid) : void 0;
|
|
7299
|
-
const highlighted = !!tagExtId;
|
|
7300
|
-
return /* @__PURE__ */ jsxs(
|
|
7301
|
-
"div",
|
|
7302
|
-
{
|
|
7303
|
-
"data-chunk-id": cid,
|
|
7304
|
-
"data-testid": highlighted ? "review-chunk-cited" : "review-chunk",
|
|
7305
|
-
className: cn(
|
|
7306
|
-
"scroll-mt-4 rounded-md px-2 py-1 transition-colors",
|
|
7307
|
-
highlighted && "bg-[var(--color-ai-accent-soft,theme(colors.amber.100))] ring-1 ring-inset ring-border",
|
|
7308
|
-
flash === cid && "ring-2 ring-ring"
|
|
7309
|
-
),
|
|
7310
|
-
children: [
|
|
7311
|
-
highlighted ? /* @__PURE__ */ jsx("div", { className: "mb-1", children: /* @__PURE__ */ jsx(
|
|
7312
|
-
TagEntity,
|
|
7313
|
-
{
|
|
7314
|
-
size: "sm",
|
|
7315
|
-
tag: {
|
|
7316
|
-
external_id: tagExtId,
|
|
7317
|
-
name: tagNameById.get(tagExtId) ?? tagExtId.slice(0, 8)
|
|
7318
|
-
}
|
|
7319
|
-
}
|
|
7320
|
-
) }) : null,
|
|
7321
|
-
/* @__PURE__ */ jsx(AiMarkdown, { className: "prose prose-sm max-w-none dark:prose-invert", children: c.content })
|
|
7322
|
-
]
|
|
7323
|
-
},
|
|
7324
|
-
cid ?? i
|
|
7325
|
-
);
|
|
7326
|
-
}) })
|
|
7327
|
-
] }, pageNum)) }) })
|
|
7328
|
-
] })
|
|
7329
|
-
]
|
|
7330
|
-
}
|
|
7331
|
-
);
|
|
7332
|
-
}
|
|
7333
6739
|
|
|
7334
|
-
export { ActivityFeed, AiActionCard, AiAnswer,
|
|
6740
|
+
export { ActivityFeed, AiActionCard, AiAnswer, AppleIcon, ArbiBotHeadIcon, ArbiBotIcon, ArbiChat, ArbiChatPanel, ArbiIcon, ArbiProvider, ArbiWebSocketProvider, ArtifactCanvas, AudIcon, BASE_COLORS2 as BASE_COLORS, ChatBubble, CitationRenderer, ClaudeIcon, CommandPalette, CommandPaletteProvider, ConversationList, DEFAULT_ASPECT_OPTIONS, DEFAULT_NOTIFY_TONE, DirectMessages, DmAvatar, DmComposer, DocIcon, DocQaPanel, DocSearch, DocumentCard, DocumentCardMenu, DocumentEntity, DocumentGallery, DocumentReview, DocumentTable, ENTITY_MAPPINGS, EmlIcon, EntityIcon, EntityPill, FILE_TYPE_COLORS, FileIcon, FireworksIcon, GeminiIcon, GitHubIcon, GoogleIcon, HtmlIcon, ImageCropModal, ImageCropper, ImgIcon, LinkedInIcon, MessageArtifactCard, MessageBubble2 as MessageBubble, MessageThread, NEUTRAL_GRAY2 as NEUTRAL_GRAY, NotificationBell, OpenAIIcon, PLACEHOLDER_COLOR, PdfIcon, ProjectEntity, ProviderIcon, RagDot, SemanticSearch, StatusPill, TAG_TYPE_ICONS, TAG_TYPE_LABELS, TagEntity, Toaster, TxtIcon, TypingIndicator, UserEntity, UserMenu, VISIBILITY_ICONS, VidIcon, VisibilityIcon, XlsIcon, arbiQueryKeys, configureEntityRegistry, configureRagLabels, configureStatusRegistry, cropImage, describeActivity, formatRelativeTime, getEntityColor2 as getEntityColor, getEntityColorStyles, getEntityIcon, getEntityLabel, getNotificationTypeMeta, getStatusVariant, getTagTypeIcon, getTagTypeLabel, getWorkspaceActionText, getWorkspaceColor, getWorkspaceSentPhrase, isWorkspaceNotificationType, notify, parseActivityContent, redlineStats, seedNotifications, selectUnread, textToArtifact, toRedlineMarkdown, useActivity, useAgents, useAiTask, useArbi, useArbiConnected, useArbiDocumentSync, useArbiUiStore, useArbiWebSocket, useArbiWsContext, useArbiWsMessage, useArbiWsStatus, useArbiWsStore, useArbiWsTask, useArbiWsTasks, useAssistantQuery, useCommandPalette, useConfigs, useConversations, useDeleteAgents, useDirectMessages, useDocuments, useHealth, useMemories, useNotify, useParsedDocument, useProjectInvoices, useProjectUsage, useProjects, useProjectsUsage, useSemanticSearch, useSessions, useTags, useTasks, useThumbnails, useUserUsageToday, useWorkspaceChronology, useWorkspaceDocs, useWorkspaces, userDisplayName, userInitials };
|
|
7335
6741
|
//# sourceMappingURL=index.js.map
|
|
7336
6742
|
//# sourceMappingURL=index.js.map
|