@arbidocs/react 0.4.147 → 0.4.151
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/artifacts/index.cjs +30 -20
- package/dist/artifacts/index.cjs.map +1 -1
- package/dist/artifacts/index.d.cts +7 -1
- package/dist/artifacts/index.d.ts +7 -1
- package/dist/artifacts/index.js +13 -4
- package/dist/artifacts/index.js.map +1 -1
- package/dist/{chunk-MFMJHBJR.js → chunk-3XYIQZTH.js} +52 -3
- package/dist/chunk-3XYIQZTH.js.map +1 -0
- package/dist/{chunk-J3BYHBKW.js → chunk-D2XIJSSI.js} +2635 -2341
- package/dist/chunk-D2XIJSSI.js.map +1 -0
- package/dist/{chunk-YIFUMQGA.cjs → chunk-I7UUV7FP.cjs} +19 -17
- package/dist/chunk-I7UUV7FP.cjs.map +1 -0
- package/dist/{chunk-KLPY2HUC.cjs → chunk-JFKWH6EP.cjs} +57 -2
- package/dist/chunk-JFKWH6EP.cjs.map +1 -0
- package/dist/{chunk-7AFGROHZ.js → chunk-OKDZDDJM.js} +20 -17
- package/dist/chunk-OKDZDDJM.js.map +1 -0
- package/dist/{chunk-65WT5PHA.cjs → chunk-QCQFV5KO.cjs} +2647 -2339
- package/dist/chunk-QCQFV5KO.cjs.map +1 -0
- package/dist/document-tools/index.cjs +31 -0
- package/dist/document-tools/index.cjs.map +1 -1
- package/dist/document-tools/index.d.cts +19 -1
- package/dist/document-tools/index.d.ts +19 -1
- package/dist/document-tools/index.js +30 -1
- package/dist/document-tools/index.js.map +1 -1
- package/dist/{index-2Y2MVegs.d.ts → index-BV7pBlgY.d.cts} +119 -6
- package/dist/{index-2Y2MVegs.d.cts → index-BV7pBlgY.d.ts} +119 -6
- package/dist/{index-3E0neHf_.d.cts → index-DyFzmDZ2.d.cts} +46 -1
- package/dist/{index-3E0neHf_.d.ts → index-DyFzmDZ2.d.ts} +46 -1
- package/dist/index.cjs +1393 -1222
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1356 -340
- package/dist/index.d.ts +1356 -340
- package/dist/index.js +583 -507
- package/dist/index.js.map +1 -1
- package/dist/shell/index.cjs +33 -9
- package/dist/shell/index.d.cts +3 -1
- package/dist/shell/index.d.ts +3 -1
- package/dist/shell/index.js +1 -1
- package/dist/ui/index.cjs +190 -134
- package/dist/ui/index.d.cts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +2 -2
- package/package.json +3 -3
- package/dist/chunk-65WT5PHA.cjs.map +0 -1
- package/dist/chunk-7AFGROHZ.js.map +0 -1
- package/dist/chunk-J3BYHBKW.js.map +0 -1
- package/dist/chunk-KLPY2HUC.cjs.map +0 -1
- package/dist/chunk-MFMJHBJR.js.map +0 -1
- package/dist/chunk-YIFUMQGA.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { arbiMutationKeys, replayableTagMutations, patchDocuments, setCachedDocument, adjustTagCounts, arbiQueryKeys, patchCachedDocument, useDocuments, useConversations, useAssistantQuery, useConversationThreads, refreshDocuments, FINISHED_DOCUMENT_STATUSES, useWorkspaces, forgetDocuments, getCachedDocuments, useParsedDocument, useTags, useActivity, useThumbnails } from './chunk-7AFGROHZ.js';
|
|
2
|
-
export { DOCUMENTS_FIRST_PAGE_MEASURE, DOCUMENTS_FIRST_PAGE_SIZE, DOCUMENTS_PAGE_SIZE, FINISHED_DOCUMENT_STATUSES, PROJECT_CREATION_DENIED_REASON, SIMILARITY_THRESHOLD, adjustTagCounts, arbiMutationKeys, arbiQueryKeys, forgetDocuments, getCachedDocuments, invalidateTagData, invalidateTagTables, isDocumentsLoading, isUsageMetered, patchCachedDocument, patchDocuments, patchWorkspaceTags, refreshDocuments, setCachedDocument, stopDocumentsLoading, subscribeDocumentRows, upsertDocuments, useActivity, useAgents, useAssistantQuery, useAvailableModels, useCanCreateProjects, useConfigs, useConversationThreads, useConversations, useCreateTag, useCurrentUser, useDeleteAgents, useDeleteTag, useDocument, useDocumentVersionList, useDocuments, useDocumentsById, useDocumentsLoading, useExtractEntities, useFirmPool, useHealth, useInvalidateTagData, useParsedDocument, useProjectInvoices, useProjectUsage, useProjects, useProjectsUsage, useSetTagValues, useSimilarDocuments, useTagKindSchema, useTags, useThumbnails, useTopUpFirmPool, useUpdateTag, useUpdateTagKindSchema, useUserUsageToday, useWorkspaceActivity, useWorkspaceUsers, useWorkspaces } from './chunk-7AFGROHZ.js';
|
|
3
1
|
import { downloadBlob } from './chunk-YYTX3W6C.js';
|
|
2
|
+
import { arbiMutationKeys, replayableTagMutations, patchDocuments, setCachedDocument, adjustTagCounts, arbiQueryKeys, patchCachedDocument, useDocuments, useConversations, useAssistantQuery, useConversationThreads, refreshDocuments, FINISHED_DOCUMENT_STATUSES, useWorkspaces, forgetDocuments, getCachedDocuments, useActivity, useTags, useThumbnails, useParsedDocument } from './chunk-OKDZDDJM.js';
|
|
3
|
+
export { DOCUMENTS_FIRST_PAGE_MEASURE, DOCUMENTS_FIRST_PAGE_SIZE, DOCUMENTS_PAGE_SIZE, FINISHED_DOCUMENT_STATUSES, PROJECT_CREATION_DENIED_REASON, SIMILARITY_THRESHOLD, adjustTagCounts, arbiMutationKeys, arbiQueryKeys, forgetDocuments, getCachedDocuments, invalidateTagData, invalidateTagTables, isDocumentsLoading, isUsageMetered, patchCachedDocument, patchDocuments, patchWorkspaceTags, refreshDocuments, setCachedDocument, stopDocumentsLoading, subscribeDocumentRows, upsertDocuments, useActivity, useAgents, useAssistantQuery, useAvailableModels, useCanCreateProjects, useConfigs, useConversationThreads, useConversations, useCreateTag, useCurrentUser, useDeleteAgents, useDeleteTag, useDocument, useDocumentVersionList, useDocuments, useDocumentsById, useDocumentsLoading, useExtractEntities, useFirmPool, useHealth, useInvalidateTagData, useParsedDocument, useProjectInvoices, useProjectUsage, useProjects, useProjectsUsage, useSetTagValues, useSimilarDocuments, useTagKindSchema, useTags, useThumbnails, useTopUpFirmPool, useUpdateTag, useUpdateTagKindSchema, useUserUsageToday, useWorkspaceActivity, useWorkspaces } from './chunk-OKDZDDJM.js';
|
|
4
4
|
import { parseVersionRef } from './chunk-NNWMHMEC.js';
|
|
5
5
|
export { cleanDraftMarkdown, cleanDraftWithReport, promoteBoldTitle, repairParsedStructure, repairParsedTitle, stripAgentPreamble, unescapeMarkdown, unwrapCitationLinks } from './chunk-NNWMHMEC.js';
|
|
6
6
|
import './chunk-WUTL62MC.js';
|
|
7
|
-
import { formatRelativeTime } from './chunk-
|
|
8
|
-
export { DEFAULT_NOTIFY_TONE, MAX_SESSION_NOTIFICATIONS, NotificationBell, Toaster, configureNotify, formatRelativeTime, notify, persistNotifyHistory, seedNotifications, selectUnread, toast, useNotify } from './chunk-
|
|
9
|
-
import { returnFocusToMark, MarkMenu, AiMarkdown, Card, Badge,
|
|
10
|
-
export { AUDIO_MIME_PREFERENCE, AgentBadge, AiMarkdown, ArbiBotHeadIcon, ArbiIcon, AudIcon, Avatar, AvatarFallback, AvatarImage, BASE_COLORS, Badge, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, DEFAULT_SEGMENTER_CONFIG, DebouncedInput, DictateProvider, DocIcon, DocumentCard, DocumentEntity, ENTITY_MAPPINGS, EmlIcon, EntityIcon, EntityPill, FILE_TYPE_COLORS, HoverCard, HoverCardContent, HoverCardTrigger, HtmlIcon, INITIAL_SEGMENTER_STATE, IconToggle, ImgIcon, InlineMicButton, Input, Label, MarkMenu, MicRecordingOverlay, MicWaveformIndicator, NEUTRAL_GRAY, PLACEHOLDER_COLOR, PassageCard, PdfIcon, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, PresenceLabel, Progress, ProjectEntity, RadioGroup, RadioGroupItem, RagDot, RelevanceDot, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, ShieldIcon, Slider, StatusPill, Switch, TAG_TYPE_ICONS, TAG_TYPE_LABELS, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, TagEntity, Textarea, ThreadVisibilityIcon, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TxtIcon, UserEntity, UserMenu, VIDEO_MIME_PREFERENCE, VISIBILITY_ICONS, VerifiedBadge, VidIcon, VisibilityIcon, VisibilityToggle, XlsIcon, agentAvatarColors, badgeVariants, cardVariants, classifyMediaError, configureEntityRegistry, configureRagLabels, configureStatusRegistry, createChunkedRecorder, flushSegmenter, formatElapsed, getDocIcon, getEntityColor, getEntityColorStyles, getEntityIcon, getEntityLabel, getStatusVariant, getTagTypeIcon, getTagTypeLabel, getWorkspaceColor, levelFromRms, pickRecorderMimeType, stepSegmenter, toggleVariants, useAudioRecorder } from './chunk-
|
|
11
|
-
import { MarkdownRenderer } from './chunk-C44GO33B.js';
|
|
12
|
-
export { MarkdownCode, MarkdownLink, MarkdownRenderer, MarkdownStreamingContext, markdownBaseComponents, markdownSanitizeSchema, splitMarkdownBlocks } from './chunk-C44GO33B.js';
|
|
7
|
+
import { createSearchSession, clearSearchSession, formatRelativeTime } from './chunk-3XYIQZTH.js';
|
|
8
|
+
export { DEFAULT_NOTIFY_TONE, MAX_SESSION_NOTIFICATIONS, NotificationBell, Toaster, clearSearchSession, configureNotify, createSearchSession, formatRelativeTime, notify, persistNotifyHistory, persistSearchSession, requestSearch, seedNotifications, selectUnread, sharedSearchSession, takePendingSearch, toast, useNotify } from './chunk-3XYIQZTH.js';
|
|
9
|
+
import { returnFocusToMark, MarkMenu, AiMarkdown, Card, Badge, Input, FILE_TYPE_COLORS, getEntityIcon, UserEntity, getEntityColorStyles, AgentBadge, Textarea, Label, Slider, DocumentEntity, TagEntity, DocumentCard, useAudioRecorder, MicWaveformIndicator, IconToggle, classifyMediaError, formatElapsed } from './chunk-D2XIJSSI.js';
|
|
10
|
+
export { AUDIO_MIME_PREFERENCE, AgentBadge, AiMarkdown, ArbiBotHeadIcon, ArbiIcon, AudIcon, Avatar, AvatarFallback, AvatarImage, BASE_COLORS, Badge, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, DEFAULT_SEGMENTER_CONFIG, DebouncedInput, DictateProvider, DocIcon, DocumentCard, DocumentEntity, ENTITY_MAPPINGS, EmlIcon, EntityIcon, EntityPill, FILE_TYPE_COLORS, HoverCard, HoverCardContent, HoverCardTrigger, HtmlIcon, INITIAL_SEGMENTER_STATE, IconToggle, ImgIcon, InlineMicButton, Input, Label, MarkMenu, MicRecordingOverlay, MicWaveformIndicator, NEUTRAL_GRAY, PLACEHOLDER_COLOR, PassageCard, PdfIcon, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, PresenceLabel, Progress, ProjectEntity, RadioGroup, RadioGroupItem, RagDot, RelevanceDot, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, ShieldIcon, Slider, StatusPill, Switch, TAG_TYPE_ICONS, TAG_TYPE_LABELS, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, TagEntity, Textarea, ThreadVisibilityIcon, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TxtIcon, UserEntity, UserMenu, VIDEO_MIME_PREFERENCE, VISIBILITY_ICONS, VerifiedBadge, VerifiedToggle, VidIcon, VisibilityIcon, VisibilityToggle, XlsIcon, agentAvatarColors, badgeVariants, cardVariants, classifyMediaError, configureEntityRegistry, configureRagLabels, configureStatusRegistry, createChunkedRecorder, flushSegmenter, formatElapsed, formatFriendlyDate, friendlyFileType, getDocIcon, getDocumentTitle, getEntityColor, getEntityColorStyles, getEntityIcon, getEntityLabel, getStatusVariant, getTagTypeIcon, getTagTypeLabel, getWorkspaceColor, isAudioFile, isDownloadOnlyFile, isImageDocument, isImageFile, isMediaFile, isVideoFile, levelFromRms, pickRecorderMimeType, stepSegmenter, tagKindNouns, tagKindTitle, toggleVariants, useAudioRecorder, useDictateContext, usesOriginalBytesForViewer } from './chunk-D2XIJSSI.js';
|
|
13
11
|
import { Button, Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from './chunk-YNNAJJ5Z.js';
|
|
14
12
|
export { Button, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, buttonVariants } from './chunk-YNNAJJ5Z.js';
|
|
13
|
+
import { MarkdownRenderer } from './chunk-C44GO33B.js';
|
|
14
|
+
export { MarkdownCode, MarkdownLink, MarkdownRenderer, MarkdownStreamingContext, markdownBaseComponents, markdownSanitizeSchema, splitMarkdownBlocks } from './chunk-C44GO33B.js';
|
|
15
15
|
import { normalizeCitationMarkup } from './chunk-QRCMKEE6.js';
|
|
16
16
|
export { closeOpenEmphasis, normalizeCitationMarkup, trimOpenCitation } from './chunk-QRCMKEE6.js';
|
|
17
17
|
import { ScrollArea } from './chunk-W4H6XAIU.js';
|
|
@@ -23,11 +23,11 @@ export { cn } from './chunk-SN5YV6FF.js';
|
|
|
23
23
|
import { AudioViewer, ImageViewer, VideoViewer } from './chunk-HDCRPPBW.js';
|
|
24
24
|
import { useArbi, ArbiContext } from './chunk-CPPBN2JB.js';
|
|
25
25
|
export { ArbiProvider, useArbi, useDeploymentDomain } from './chunk-CPPBN2JB.js';
|
|
26
|
-
import
|
|
27
|
-
import { useQueryClient, useMutation, useQuery, onlineManager, partialMatchKey } from '@tanstack/react-query';
|
|
28
|
-
import { documents, doctags, houseTemplates, resolveCitations, summarizeCitations, settings, isConnectorVendorVisible, ArbiApiError, ACCOUNT_VENDOR, formatFileSize, connectWithReconnect, chats, identityErrorCode } from '@arbidocs/sdk/browser';
|
|
29
|
-
export { ACCOUNT_VENDOR, Arbi, ArbiError, DEFAULT_AI_USD_PER_GBP, DRIVE_SYNC_VENDORS, GOOGLE_VENDORS, IMANAGE_VENDORS, MAILBOX_SYNC_VENDORS, MICROSOFT_VENDORS, PublicBookingError, SHAREPOINT_VENDORS, bookPublicSlot, cancelPublicBooking, connectErrorMessage, formatGbp, formatGbpPerMillionTokens, getPublicBookingPage, isConnectorVendorVisible, isDriveSyncVendor, isMailboxSyncVendor, isSharePointVendor,
|
|
30
|
-
import { Link, Trash2, CheckCheck, Check, Loader2, AlertTriangle, ShieldCheck, Copy, Sparkles, FileText, GitCompareArrows, Download, Search, CornerDownLeft,
|
|
26
|
+
import React3, { memo, useState, createContext, useMemo, useCallback, useEffect, useRef, useLayoutEffect, useContext, useId, useSyncExternalStore, Fragment as Fragment$1 } from 'react';
|
|
27
|
+
import { useQueryClient, useMutation, useQuery, useQueries, onlineManager, partialMatchKey } from '@tanstack/react-query';
|
|
28
|
+
import { documents, doctags, houseTemplates, resolveCitations, summarizeCitations, settings, isConnectorVendorVisible, ArbiApiError, ACCOUNT_VENDOR, searchChunks, formatFileSize, connectWithReconnect, chats, identityErrorCode } from '@arbidocs/sdk/browser';
|
|
29
|
+
export { ACCOUNT_VENDOR, Arbi, ArbiError, DEFAULT_AI_USD_PER_GBP, DRIVE_SYNC_VENDORS, GOOGLE_VENDORS, IMANAGE_VENDORS, MAILBOX_SYNC_VENDORS, MAX_RETRIEVE_DOC_IDS, MICROSOFT_VENDORS, PublicBookingError, SHAREPOINT_VENDORS, bookPublicSlot, cancelPublicBooking, connectErrorMessage, formatGbp, formatGbpPerMillionTokens, getPublicBookingPage, isConnectorVendorVisible, isDriveSyncVendor, isMailboxSyncVendor, isSharePointVendor, usdToGbp } from '@arbidocs/sdk/browser';
|
|
30
|
+
import { Link, Trash2, CheckCheck, Check, Loader2, AlertTriangle, ShieldCheck, Copy, Sparkles, FileText, GitCompareArrows, Download, Search, CornerDownLeft, Send, Tags, Crown, Info, Activity, HardDrive, Gauge, Gift, PartyPopper, UserPlus, UserCheck, Reply, PenLine, AtSign, MessageCircleMore, FileX2, FileCheck2, Pencil, FolderPlus, SquareArrowOutUpRight, MessagesSquare, Paperclip, X, ArrowRight, MoreHorizontal, SquarePen, Mic, Pause, Play, Square, RotateCcw, Camera, Circle, Image as Image$1, AppWindow } from 'lucide-react';
|
|
31
31
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
32
32
|
import { isMessageType, passwordChangeErrorMessage, createRecoveryFile } from '@arbidocs/client';
|
|
33
33
|
export { isMessageType } from '@arbidocs/client';
|
|
@@ -1562,15 +1562,6 @@ function useArbiShellWorkspaces(options = {}) {
|
|
|
1562
1562
|
select: select ?? defaultSelect
|
|
1563
1563
|
});
|
|
1564
1564
|
}
|
|
1565
|
-
function useInvalidateMembership() {
|
|
1566
|
-
const qc = useQueryClient();
|
|
1567
|
-
return () => Promise.all([
|
|
1568
|
-
qc.invalidateQueries({ queryKey: arbiQueryKeys.workspaces() }),
|
|
1569
|
-
qc.invalidateQueries({ queryKey: ["arbi", "workspaceUsers"] }),
|
|
1570
|
-
qc.invalidateQueries({ queryKey: arbiQueryKeys.projects() }),
|
|
1571
|
-
qc.invalidateQueries({ queryKey: arbiQueryKeys.contacts() })
|
|
1572
|
-
]);
|
|
1573
|
-
}
|
|
1574
1565
|
function useUpdateWorkspace() {
|
|
1575
1566
|
const arbi = useArbi();
|
|
1576
1567
|
const qc = useQueryClient();
|
|
@@ -1579,22 +1570,60 @@ function useUpdateWorkspace() {
|
|
|
1579
1570
|
onSuccess: () => qc.invalidateQueries({ queryKey: arbiQueryKeys.workspaces() })
|
|
1580
1571
|
});
|
|
1581
1572
|
}
|
|
1573
|
+
var MEMBERS_STALE_MS = 15 * 60 * 1e3;
|
|
1574
|
+
function useWorkspaceUsers(workspaceId, options) {
|
|
1575
|
+
const arbi = useArbi();
|
|
1576
|
+
const workspace = workspaceId ?? (arbi.hasWorkspace ? arbi.getWorkspaceId() : "");
|
|
1577
|
+
return useQuery({
|
|
1578
|
+
queryKey: arbiQueryKeys.workspaceUsers(workspace),
|
|
1579
|
+
enabled: !!workspace && (options?.enabled ?? arbi.hasWorkspace),
|
|
1580
|
+
queryFn: async () => {
|
|
1581
|
+
await options?.beforeFetch?.();
|
|
1582
|
+
if (arbi.getWorkspaceId() !== workspace) throw new Error("The selected workspace changed.");
|
|
1583
|
+
return arbi.workspaces.listUsers();
|
|
1584
|
+
},
|
|
1585
|
+
staleTime: MEMBERS_STALE_MS
|
|
1586
|
+
});
|
|
1587
|
+
}
|
|
1588
|
+
function settleMembership(qc) {
|
|
1589
|
+
return Promise.all([
|
|
1590
|
+
qc.invalidateQueries({ queryKey: arbiQueryKeys.allWorkspaceUsers() }),
|
|
1591
|
+
qc.invalidateQueries({ queryKey: arbiQueryKeys.workspaces() }),
|
|
1592
|
+
// A project's collaborator quota counts workspace members.
|
|
1593
|
+
qc.invalidateQueries({ queryKey: arbiQueryKeys.projects() })
|
|
1594
|
+
]);
|
|
1595
|
+
}
|
|
1582
1596
|
function useAddWorkspaceMembers() {
|
|
1583
1597
|
const arbi = useArbi();
|
|
1584
|
-
const
|
|
1598
|
+
const qc = useQueryClient();
|
|
1585
1599
|
return useMutation({
|
|
1586
1600
|
mutationKey: arbiMutationKeys.workspaceMembership(),
|
|
1587
|
-
mutationFn: (
|
|
1588
|
-
onSuccess: () =>
|
|
1601
|
+
mutationFn: (request) => arbi.workspaces.addMembers(request),
|
|
1602
|
+
onSuccess: () => Promise.all([
|
|
1603
|
+
settleMembership(qc),
|
|
1604
|
+
qc.invalidateQueries({ queryKey: arbiQueryKeys.contacts() })
|
|
1605
|
+
])
|
|
1589
1606
|
});
|
|
1590
1607
|
}
|
|
1591
1608
|
function useRemoveWorkspaceMembers() {
|
|
1592
1609
|
const arbi = useArbi();
|
|
1593
|
-
const
|
|
1610
|
+
const qc = useQueryClient();
|
|
1594
1611
|
return useMutation({
|
|
1595
1612
|
mutationKey: arbiMutationKeys.workspaceMembership(),
|
|
1596
1613
|
mutationFn: (userIds) => arbi.workspaces.removeUsers(userIds),
|
|
1597
|
-
onSuccess: () =>
|
|
1614
|
+
onSuccess: () => settleMembership(qc)
|
|
1615
|
+
});
|
|
1616
|
+
}
|
|
1617
|
+
function useSetWorkspaceMemberRoles() {
|
|
1618
|
+
const arbi = useArbi();
|
|
1619
|
+
const qc = useQueryClient();
|
|
1620
|
+
return useMutation({
|
|
1621
|
+
mutationKey: arbiMutationKeys.setWorkspaceMemberRoles(),
|
|
1622
|
+
mutationFn: ({ userIds, role }) => arbi.workspaces.setUserRole(userIds, role),
|
|
1623
|
+
onSuccess: () => Promise.all([
|
|
1624
|
+
qc.invalidateQueries({ queryKey: arbiQueryKeys.allWorkspaceUsers() }),
|
|
1625
|
+
qc.invalidateQueries({ queryKey: arbiQueryKeys.workspaces() })
|
|
1626
|
+
])
|
|
1598
1627
|
});
|
|
1599
1628
|
}
|
|
1600
1629
|
function useFacts(workspaceId, options) {
|
|
@@ -1650,6 +1679,35 @@ function useSearchFacts() {
|
|
|
1650
1679
|
mutationFn: (body) => arbi.facts.search(body)
|
|
1651
1680
|
});
|
|
1652
1681
|
}
|
|
1682
|
+
var PARSED_STALE_TIME = 5 * 60 * 1e3;
|
|
1683
|
+
function indexPassages(results) {
|
|
1684
|
+
const index = /* @__PURE__ */ new Map();
|
|
1685
|
+
for (const r of results)
|
|
1686
|
+
(r.data?.chunks ?? []).forEach((chunk, order) => {
|
|
1687
|
+
const id = chunk.metadata?.chunk_ext_id;
|
|
1688
|
+
if (id && !index.has(id)) index.set(id, { text: (chunk.content ?? "").trim(), order });
|
|
1689
|
+
});
|
|
1690
|
+
return index;
|
|
1691
|
+
}
|
|
1692
|
+
function usePassageQuotes(docIds) {
|
|
1693
|
+
const arbi = useArbi();
|
|
1694
|
+
const passages = useQueries({
|
|
1695
|
+
queries: [...new Set(docIds ?? [])].map((docId) => ({
|
|
1696
|
+
queryKey: arbiQueryKeys.parsedDoc(docId, "final"),
|
|
1697
|
+
queryFn: () => arbi.documents.getParsedContent(docId, "final"),
|
|
1698
|
+
enabled: arbi.hasWorkspace,
|
|
1699
|
+
staleTime: PARSED_STALE_TIME
|
|
1700
|
+
})),
|
|
1701
|
+
combine: indexPassages
|
|
1702
|
+
});
|
|
1703
|
+
return useMemo(
|
|
1704
|
+
() => ({
|
|
1705
|
+
quoteFor: (chunkId) => passages.get(chunkId)?.text || void 0,
|
|
1706
|
+
orderOf: (chunkId) => passages.get(chunkId)?.order ?? Number.POSITIVE_INFINITY
|
|
1707
|
+
}),
|
|
1708
|
+
[passages]
|
|
1709
|
+
);
|
|
1710
|
+
}
|
|
1653
1711
|
var DocumentsSupportContext = createContext({});
|
|
1654
1712
|
function DocumentsSupportProvider({
|
|
1655
1713
|
support,
|
|
@@ -1981,7 +2039,10 @@ function useUpdateProjectFields() {
|
|
|
1981
2039
|
projectExtId,
|
|
1982
2040
|
patch
|
|
1983
2041
|
}) => arbi.projects.update(projectExtId, patch),
|
|
1984
|
-
onSuccess: () =>
|
|
2042
|
+
onSuccess: () => {
|
|
2043
|
+
void qc.invalidateQueries({ queryKey: arbiQueryKeys.projects() });
|
|
2044
|
+
void qc.invalidateQueries({ queryKey: arbiQueryKeys.workspaces() });
|
|
2045
|
+
}
|
|
1985
2046
|
});
|
|
1986
2047
|
}
|
|
1987
2048
|
function useProjectEvents(projectExtId, options) {
|
|
@@ -2013,6 +2074,207 @@ function useProjectConversationUsage(projectExtId, monthsBack = 0, options) {
|
|
|
2013
2074
|
enabled: (options?.enabled ?? true) && !!projectExtId && arbi.isLoggedIn
|
|
2014
2075
|
});
|
|
2015
2076
|
}
|
|
2077
|
+
var SLOW_AFTER_MS = 5e3;
|
|
2078
|
+
var POLL_EVERY_MS = 3e3;
|
|
2079
|
+
var STILL_WORKING = "Still working \u2014 confirm in your bank's tab if it opened. We'll update here.";
|
|
2080
|
+
function useIsSlow(isPending, ms = SLOW_AFTER_MS) {
|
|
2081
|
+
const [isSlow, setIsSlow] = useState(false);
|
|
2082
|
+
useEffect(() => {
|
|
2083
|
+
if (!isPending) {
|
|
2084
|
+
setIsSlow(false);
|
|
2085
|
+
return;
|
|
2086
|
+
}
|
|
2087
|
+
const timer = setTimeout(() => setIsSlow(true), ms);
|
|
2088
|
+
return () => clearTimeout(timer);
|
|
2089
|
+
}, [isPending, ms]);
|
|
2090
|
+
return isSlow;
|
|
2091
|
+
}
|
|
2092
|
+
function useChargeWatch(project, isPending) {
|
|
2093
|
+
const queryClient = useQueryClient();
|
|
2094
|
+
const isSlow = useIsSlow(isPending);
|
|
2095
|
+
const watchRef = useRef(null);
|
|
2096
|
+
useEffect(() => {
|
|
2097
|
+
if (!isSlow) return;
|
|
2098
|
+
const timer = setInterval(
|
|
2099
|
+
() => queryClient.invalidateQueries({ queryKey: arbiQueryKeys.projects(), exact: true }),
|
|
2100
|
+
POLL_EVERY_MS
|
|
2101
|
+
);
|
|
2102
|
+
return () => clearInterval(timer);
|
|
2103
|
+
}, [isSlow, queryClient]);
|
|
2104
|
+
const settle = useCallback((ok, onNotLanded) => {
|
|
2105
|
+
const watch2 = watchRef.current;
|
|
2106
|
+
if (!watch2 || watch2.settled) return;
|
|
2107
|
+
watch2.settled = true;
|
|
2108
|
+
if (ok) watch2.onLanded();
|
|
2109
|
+
else onNotLanded?.();
|
|
2110
|
+
}, []);
|
|
2111
|
+
useEffect(() => {
|
|
2112
|
+
const watch2 = watchRef.current;
|
|
2113
|
+
if (watch2 && !watch2.settled && watch2.landed(project)) settle(true);
|
|
2114
|
+
}, [project, settle]);
|
|
2115
|
+
const watch = useCallback((landed, onLanded) => {
|
|
2116
|
+
watchRef.current = { landed, onLanded, settled: false };
|
|
2117
|
+
}, []);
|
|
2118
|
+
const succeeded = useCallback(() => settle(true), [settle]);
|
|
2119
|
+
const refused = useCallback(() => settle(false), [settle]);
|
|
2120
|
+
const settleFailure = useCallback(
|
|
2121
|
+
async (onNotLanded) => {
|
|
2122
|
+
const watch2 = watchRef.current;
|
|
2123
|
+
if (!watch2 || watch2.settled) return;
|
|
2124
|
+
let fresh;
|
|
2125
|
+
try {
|
|
2126
|
+
await queryClient.refetchQueries({ queryKey: arbiQueryKeys.projects(), exact: true });
|
|
2127
|
+
fresh = queryClient.getQueryData(arbiQueryKeys.projects())?.find((p) => p.external_id === project.external_id);
|
|
2128
|
+
} catch {
|
|
2129
|
+
fresh = void 0;
|
|
2130
|
+
}
|
|
2131
|
+
settle(!!fresh && watch2.landed(fresh), onNotLanded);
|
|
2132
|
+
},
|
|
2133
|
+
[queryClient, project.external_id, settle]
|
|
2134
|
+
);
|
|
2135
|
+
return { isSlow, watch, succeeded, refused, settleFailure };
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2138
|
+
// src/billing.ts
|
|
2139
|
+
function refreshProjects(qc, wide = false) {
|
|
2140
|
+
void qc.invalidateQueries({ queryKey: arbiQueryKeys.projects() });
|
|
2141
|
+
if (wide) {
|
|
2142
|
+
void qc.invalidateQueries({ queryKey: arbiQueryKeys.userSettings() });
|
|
2143
|
+
void qc.invalidateQueries({ queryKey: arbiQueryKeys.workspaces() });
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
var retryAbortOnly = (failureCount, error) => failureCount < 1 && error?.name === "AbortError";
|
|
2147
|
+
function useInvalidateProjects() {
|
|
2148
|
+
const qc = useQueryClient();
|
|
2149
|
+
return () => qc.invalidateQueries({ queryKey: arbiQueryKeys.projects() });
|
|
2150
|
+
}
|
|
2151
|
+
function useProducts(options) {
|
|
2152
|
+
const arbi = useArbi();
|
|
2153
|
+
return useQuery({
|
|
2154
|
+
queryKey: arbiQueryKeys.products(),
|
|
2155
|
+
queryFn: () => arbi.projects.products(),
|
|
2156
|
+
staleTime: 5 * 6e4,
|
|
2157
|
+
enabled: (options?.enabled ?? true) && arbi.isLoggedIn
|
|
2158
|
+
});
|
|
2159
|
+
}
|
|
2160
|
+
function useCreateProject() {
|
|
2161
|
+
const arbi = useArbi();
|
|
2162
|
+
const qc = useQueryClient();
|
|
2163
|
+
return useMutation({
|
|
2164
|
+
mutationFn: ({ name, plan, ...details }) => arbi.projects.create(name, plan, details),
|
|
2165
|
+
onSuccess: () => refreshProjects(qc, true)
|
|
2166
|
+
});
|
|
2167
|
+
}
|
|
2168
|
+
function useDeleteProject() {
|
|
2169
|
+
const arbi = useArbi();
|
|
2170
|
+
const qc = useQueryClient();
|
|
2171
|
+
return useMutation({
|
|
2172
|
+
mutationFn: (projectExtId) => arbi.projects.delete(projectExtId),
|
|
2173
|
+
onSuccess: () => refreshProjects(qc, true)
|
|
2174
|
+
});
|
|
2175
|
+
}
|
|
2176
|
+
function useRefreshProject() {
|
|
2177
|
+
const arbi = useArbi();
|
|
2178
|
+
const qc = useQueryClient();
|
|
2179
|
+
return useMutation({
|
|
2180
|
+
mutationFn: (projectExtId) => arbi.projects.refresh(projectExtId),
|
|
2181
|
+
onSuccess: () => refreshProjects(qc, true)
|
|
2182
|
+
});
|
|
2183
|
+
}
|
|
2184
|
+
function useCreateProjectCheckout() {
|
|
2185
|
+
const arbi = useArbi();
|
|
2186
|
+
return useMutation({
|
|
2187
|
+
mutationFn: ({ projectExtId, body }) => arbi.projects.checkout(projectExtId, body)
|
|
2188
|
+
});
|
|
2189
|
+
}
|
|
2190
|
+
function useChangeProjectPlan() {
|
|
2191
|
+
const arbi = useArbi();
|
|
2192
|
+
const qc = useQueryClient();
|
|
2193
|
+
return useMutation({
|
|
2194
|
+
mutationFn: ({
|
|
2195
|
+
projectExtId,
|
|
2196
|
+
body
|
|
2197
|
+
}) => arbi.projects.changePlan(projectExtId, body),
|
|
2198
|
+
onSuccess: () => refreshProjects(qc, true)
|
|
2199
|
+
});
|
|
2200
|
+
}
|
|
2201
|
+
function useCancelProjectSubscription() {
|
|
2202
|
+
const arbi = useArbi();
|
|
2203
|
+
const qc = useQueryClient();
|
|
2204
|
+
return useMutation({
|
|
2205
|
+
mutationFn: (projectExtId) => arbi.projects.cancelSubscription(projectExtId),
|
|
2206
|
+
onSuccess: () => {
|
|
2207
|
+
void qc.invalidateQueries({ queryKey: arbiQueryKeys.projects() });
|
|
2208
|
+
void qc.invalidateQueries({ queryKey: arbiQueryKeys.userSettings() });
|
|
2209
|
+
}
|
|
2210
|
+
});
|
|
2211
|
+
}
|
|
2212
|
+
function usePreviewProjectPlanChange(projectExtId, change) {
|
|
2213
|
+
const arbi = useArbi();
|
|
2214
|
+
return useQuery({
|
|
2215
|
+
queryKey: [...arbiQueryKeys.billingQuotes(), "preview", projectExtId, change],
|
|
2216
|
+
queryFn: () => arbi.projects.previewPlanChange(projectExtId, change),
|
|
2217
|
+
enabled: !!change && arbi.isLoggedIn,
|
|
2218
|
+
staleTime: 6e4,
|
|
2219
|
+
retry: retryAbortOnly
|
|
2220
|
+
});
|
|
2221
|
+
}
|
|
2222
|
+
function usePlanQuote(projectExtId, body) {
|
|
2223
|
+
const arbi = useArbi();
|
|
2224
|
+
return useQuery({
|
|
2225
|
+
queryKey: [...arbiQueryKeys.billingQuotes(), "plan", projectExtId ?? null, body],
|
|
2226
|
+
queryFn: () => arbi.projects.quotePlan(projectExtId ?? null, body),
|
|
2227
|
+
enabled: !!body && arbi.isLoggedIn,
|
|
2228
|
+
staleTime: 5 * 6e4,
|
|
2229
|
+
retry: retryAbortOnly
|
|
2230
|
+
});
|
|
2231
|
+
}
|
|
2232
|
+
function useAddonQuote(projectExtId, kind, enabled = true) {
|
|
2233
|
+
const arbi = useArbi();
|
|
2234
|
+
return useQuery({
|
|
2235
|
+
queryKey: [...arbiQueryKeys.billingQuotes(), "addon", projectExtId, kind],
|
|
2236
|
+
queryFn: () => arbi.projects.quoteAddon(projectExtId, kind),
|
|
2237
|
+
enabled: enabled && arbi.isLoggedIn,
|
|
2238
|
+
staleTime: 6e4,
|
|
2239
|
+
retry: retryAbortOnly
|
|
2240
|
+
});
|
|
2241
|
+
}
|
|
2242
|
+
function useProjectBillingPortal() {
|
|
2243
|
+
const arbi = useArbi();
|
|
2244
|
+
return useMutation({
|
|
2245
|
+
mutationFn: (projectExtId) => arbi.projects.billingPortal(projectExtId)
|
|
2246
|
+
});
|
|
2247
|
+
}
|
|
2248
|
+
function useAddProjectAddonBlock() {
|
|
2249
|
+
const arbi = useArbi();
|
|
2250
|
+
const qc = useQueryClient();
|
|
2251
|
+
return useMutation({
|
|
2252
|
+
mutationFn: ({ projectExtId, kind }) => arbi.projects.addAddonBlock(projectExtId, kind),
|
|
2253
|
+
onSuccess: () => refreshProjects(qc)
|
|
2254
|
+
});
|
|
2255
|
+
}
|
|
2256
|
+
function useUpdateProjectNextPeriodAddons() {
|
|
2257
|
+
const arbi = useArbi();
|
|
2258
|
+
const qc = useQueryClient();
|
|
2259
|
+
return useMutation({
|
|
2260
|
+
mutationFn: ({
|
|
2261
|
+
projectExtId,
|
|
2262
|
+
body
|
|
2263
|
+
}) => arbi.projects.setNextPeriodAddons(projectExtId, body),
|
|
2264
|
+
onSuccess: () => refreshProjects(qc)
|
|
2265
|
+
});
|
|
2266
|
+
}
|
|
2267
|
+
function useUpdateProjectAddonSettings() {
|
|
2268
|
+
const arbi = useArbi();
|
|
2269
|
+
const qc = useQueryClient();
|
|
2270
|
+
return useMutation({
|
|
2271
|
+
mutationFn: ({
|
|
2272
|
+
projectExtId,
|
|
2273
|
+
body
|
|
2274
|
+
}) => arbi.projects.updateAddonSettings(projectExtId, body),
|
|
2275
|
+
onSuccess: () => refreshProjects(qc)
|
|
2276
|
+
});
|
|
2277
|
+
}
|
|
2016
2278
|
function useContacts(options) {
|
|
2017
2279
|
const arbi = useArbi();
|
|
2018
2280
|
return useQuery({
|
|
@@ -3453,7 +3715,6 @@ var calendarQueryKeys = {
|
|
|
3453
3715
|
],
|
|
3454
3716
|
accounts: () => ["arbi", "calendar", "accounts"],
|
|
3455
3717
|
caldavProfiles: () => ["arbi", "calendar", "caldav-profiles"],
|
|
3456
|
-
appPasswords: () => ["arbi", "calendar", "app-passwords"],
|
|
3457
3718
|
bookingPages: () => ["arbi", "calendar", "booking-pages"],
|
|
3458
3719
|
/** The offline outbox (writes made offline, not yet sent). */
|
|
3459
3720
|
outbox: () => ["arbi", "calendar", "outbox"]
|
|
@@ -4228,44 +4489,6 @@ function useSyncAccountsOnOpen(enabled = true) {
|
|
|
4228
4489
|
}, [enabled, accounts, arbi, qc]);
|
|
4229
4490
|
return { syncing };
|
|
4230
4491
|
}
|
|
4231
|
-
function useAppPasswords(enabled = true) {
|
|
4232
|
-
const arbi = useArbi();
|
|
4233
|
-
return useQuery({
|
|
4234
|
-
queryKey: calendarQueryKeys.appPasswords(),
|
|
4235
|
-
queryFn: () => arbi.calendar.listAppPasswords(),
|
|
4236
|
-
enabled: enabled && arbi.isLoggedIn,
|
|
4237
|
-
staleTime: 3e4,
|
|
4238
|
-
retry: false
|
|
4239
|
-
});
|
|
4240
|
-
}
|
|
4241
|
-
function useInvalidateAppPasswords() {
|
|
4242
|
-
const qc = useQueryClient();
|
|
4243
|
-
return () => qc.invalidateQueries({ queryKey: calendarQueryKeys.appPasswords() });
|
|
4244
|
-
}
|
|
4245
|
-
function useCreateAppPassword() {
|
|
4246
|
-
const arbi = useArbi();
|
|
4247
|
-
const invalidate = useInvalidateAppPasswords();
|
|
4248
|
-
return useMutation({
|
|
4249
|
-
mutationFn: (body) => arbi.calendar.createAppPassword(body),
|
|
4250
|
-
onSuccess: () => invalidate()
|
|
4251
|
-
});
|
|
4252
|
-
}
|
|
4253
|
-
function useCreateFeed() {
|
|
4254
|
-
const arbi = useArbi();
|
|
4255
|
-
const invalidate = useInvalidateAppPasswords();
|
|
4256
|
-
return useMutation({
|
|
4257
|
-
mutationFn: (body) => arbi.calendar.createFeed(body),
|
|
4258
|
-
onSuccess: () => invalidate()
|
|
4259
|
-
});
|
|
4260
|
-
}
|
|
4261
|
-
function useRevokeAppPassword() {
|
|
4262
|
-
const arbi = useArbi();
|
|
4263
|
-
const invalidate = useInvalidateAppPasswords();
|
|
4264
|
-
return useMutation({
|
|
4265
|
-
mutationFn: (id) => arbi.calendar.revokeAppPassword(id),
|
|
4266
|
-
onSuccess: () => invalidate()
|
|
4267
|
-
});
|
|
4268
|
-
}
|
|
4269
4492
|
function useBookingPages(enabled = true) {
|
|
4270
4493
|
const arbi = useArbi();
|
|
4271
4494
|
return useQuery({
|
|
@@ -4390,51 +4613,6 @@ function useAiTask() {
|
|
|
4390
4613
|
isDone: status === "done"
|
|
4391
4614
|
};
|
|
4392
4615
|
}
|
|
4393
|
-
function useSemanticSearch(docIds) {
|
|
4394
|
-
const arbi = useArbi();
|
|
4395
|
-
const [query, setQuery] = useState("");
|
|
4396
|
-
const mutation = useMutation({
|
|
4397
|
-
mutationFn: async ({ query: q, mode }) => {
|
|
4398
|
-
const res = await arbi.assistant.retrieve(q, docIds, { searchMode: mode });
|
|
4399
|
-
const byTool = res.retrieval_chunk?.tool_responses ?? {};
|
|
4400
|
-
return Object.values(byTool).flat().map(
|
|
4401
|
-
(c) => ({
|
|
4402
|
-
chunkExtId: c.metadata.chunk_ext_id,
|
|
4403
|
-
docId: c.metadata.doc_ext_id,
|
|
4404
|
-
docTitle: c.metadata.doc_title,
|
|
4405
|
-
page: c.metadata.page_number,
|
|
4406
|
-
score: c.metadata.rerank_score ?? c.metadata.score,
|
|
4407
|
-
content: c.content
|
|
4408
|
-
})
|
|
4409
|
-
).sort((a, b) => (b.score ?? 0) - (a.score ?? 0));
|
|
4410
|
-
}
|
|
4411
|
-
});
|
|
4412
|
-
const { mutateAsync, reset } = mutation;
|
|
4413
|
-
const search = useCallback(
|
|
4414
|
-
async (q, mode = "hybrid") => {
|
|
4415
|
-
const trimmed = q.trim();
|
|
4416
|
-
setQuery(trimmed);
|
|
4417
|
-
if (!trimmed || docIds.length === 0) {
|
|
4418
|
-
reset();
|
|
4419
|
-
return;
|
|
4420
|
-
}
|
|
4421
|
-
try {
|
|
4422
|
-
await mutateAsync({ query: trimmed, mode });
|
|
4423
|
-
} catch {
|
|
4424
|
-
}
|
|
4425
|
-
},
|
|
4426
|
-
[mutateAsync, reset, docIds]
|
|
4427
|
-
);
|
|
4428
|
-
const status = mutation.isPending ? "running" : mutation.isError ? "error" : mutation.isSuccess ? "done" : "idle";
|
|
4429
|
-
return {
|
|
4430
|
-
query,
|
|
4431
|
-
results: mutation.data ?? [],
|
|
4432
|
-
status,
|
|
4433
|
-
error: mutation.error ? mutation.error.message ?? "Search failed." : null,
|
|
4434
|
-
search,
|
|
4435
|
-
isRunning: mutation.isPending
|
|
4436
|
-
};
|
|
4437
|
-
}
|
|
4438
4616
|
function toRedlineMarkdown(original, revised) {
|
|
4439
4617
|
const parts = diffWords(original ?? "", revised ?? "");
|
|
4440
4618
|
return parts.map((p) => {
|
|
@@ -4838,6 +5016,75 @@ function MessageArtifactCard({
|
|
|
4838
5016
|
}
|
|
4839
5017
|
);
|
|
4840
5018
|
}
|
|
5019
|
+
var IDLE = {
|
|
5020
|
+
query: "",
|
|
5021
|
+
results: [],
|
|
5022
|
+
searched: false,
|
|
5023
|
+
status: "idle",
|
|
5024
|
+
error: null
|
|
5025
|
+
};
|
|
5026
|
+
function useSemanticSearch(docIds = [], options = {}) {
|
|
5027
|
+
const arbi = useArbi();
|
|
5028
|
+
const [ownSession] = useState(createSearchSession);
|
|
5029
|
+
const session = options.session ?? ownSession;
|
|
5030
|
+
const { model, workspaceId } = options;
|
|
5031
|
+
const state = useSyncExternalStore(session.subscribe, session.getState, session.getState);
|
|
5032
|
+
const foreign = !!workspaceId && !!state.workspaceId && state.workspaceId !== workspaceId;
|
|
5033
|
+
useEffect(() => {
|
|
5034
|
+
if (!workspaceId) return;
|
|
5035
|
+
const current = session.getState().workspaceId;
|
|
5036
|
+
if (current !== workspaceId) {
|
|
5037
|
+
if (current) clearSearchSession(workspaceId, session);
|
|
5038
|
+
else session.setState({ workspaceId });
|
|
5039
|
+
}
|
|
5040
|
+
}, [session, workspaceId]);
|
|
5041
|
+
const search = useCallback(
|
|
5042
|
+
async (query, mode = "hybrid") => {
|
|
5043
|
+
const trimmed = query.trim();
|
|
5044
|
+
if (!trimmed) {
|
|
5045
|
+
clearSearchSession(void 0, session);
|
|
5046
|
+
return;
|
|
5047
|
+
}
|
|
5048
|
+
const run = session.getState().run + 1;
|
|
5049
|
+
session.setState((s) => ({
|
|
5050
|
+
query: trimmed,
|
|
5051
|
+
status: "running",
|
|
5052
|
+
error: null,
|
|
5053
|
+
run,
|
|
5054
|
+
workspaceId: workspaceId ?? s.workspaceId
|
|
5055
|
+
}));
|
|
5056
|
+
try {
|
|
5057
|
+
const result = await arbi.assistant.retrieve(trimmed, docIds, {
|
|
5058
|
+
searchMode: mode,
|
|
5059
|
+
store: false,
|
|
5060
|
+
...model ? { model } : {}
|
|
5061
|
+
});
|
|
5062
|
+
if (session.getState().run !== run) return;
|
|
5063
|
+
session.setState({ results: searchChunks(result), searched: true, status: "done" });
|
|
5064
|
+
} catch (error) {
|
|
5065
|
+
if (session.getState().run !== run) return;
|
|
5066
|
+
session.setState({
|
|
5067
|
+
status: "error",
|
|
5068
|
+
error: error instanceof Error ? error.message : "Search failed"
|
|
5069
|
+
});
|
|
5070
|
+
}
|
|
5071
|
+
},
|
|
5072
|
+
[arbi, docIds, model, session, workspaceId]
|
|
5073
|
+
);
|
|
5074
|
+
const clear = useCallback(() => clearSearchSession(void 0, session), [session]);
|
|
5075
|
+
const shown = foreign ? IDLE : state;
|
|
5076
|
+
return {
|
|
5077
|
+
query: shown.query,
|
|
5078
|
+
results: shown.results,
|
|
5079
|
+
searched: shown.searched,
|
|
5080
|
+
status: shown.status,
|
|
5081
|
+
error: shown.error,
|
|
5082
|
+
isRunning: shown.status === "running",
|
|
5083
|
+
search,
|
|
5084
|
+
clear,
|
|
5085
|
+
session
|
|
5086
|
+
};
|
|
5087
|
+
}
|
|
4841
5088
|
function DocSearch({
|
|
4842
5089
|
docIds,
|
|
4843
5090
|
onOpenDoc,
|
|
@@ -4894,12 +5141,12 @@ function DocSearch({
|
|
|
4894
5141
|
children: [
|
|
4895
5142
|
/* @__PURE__ */ jsxs("div", { className: "mb-1 flex items-center gap-2", children: [
|
|
4896
5143
|
/* @__PURE__ */ jsx(FileText, { className: "size-3.5 text-ai-accent" }),
|
|
4897
|
-
/* @__PURE__ */ jsx("span", { className: "truncate text-xs font-medium text-foreground", children: r.docTitle
|
|
5144
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-xs font-medium text-foreground", children: r.docTitle || "Document" }),
|
|
4898
5145
|
r.page != null && /* @__PURE__ */ jsxs(Badge, { variant: "secondary", children: [
|
|
4899
5146
|
"p.",
|
|
4900
5147
|
r.page
|
|
4901
5148
|
] }),
|
|
4902
|
-
r.score
|
|
5149
|
+
r.score > 0 && /* @__PURE__ */ jsxs("span", { className: "ml-auto text-xs text-muted-foreground", children: [
|
|
4903
5150
|
"score ",
|
|
4904
5151
|
r.score.toFixed(2)
|
|
4905
5152
|
] })
|
|
@@ -4912,372 +5159,6 @@ function DocSearch({
|
|
|
4912
5159
|
] })
|
|
4913
5160
|
] });
|
|
4914
5161
|
}
|
|
4915
|
-
function DocumentReview({
|
|
4916
|
-
docId,
|
|
4917
|
-
doc,
|
|
4918
|
-
workspaceId,
|
|
4919
|
-
stage = "final",
|
|
4920
|
-
activeChunkId,
|
|
4921
|
-
onClose,
|
|
4922
|
-
className
|
|
4923
|
-
}) {
|
|
4924
|
-
const parsedQuery = useParsedDocument(docId, stage);
|
|
4925
|
-
const tagsQuery = useTags(workspaceId);
|
|
4926
|
-
const tagNameById = React.useMemo(() => {
|
|
4927
|
-
const map = /* @__PURE__ */ new Map();
|
|
4928
|
-
for (const t of tagsQuery.data ?? []) {
|
|
4929
|
-
if (t.external_id) map.set(t.external_id, t.name ?? t.external_id.slice(0, 8));
|
|
4930
|
-
}
|
|
4931
|
-
return map;
|
|
4932
|
-
}, [tagsQuery.data]);
|
|
4933
|
-
const title = doc?.doc_metadata?.title || doc?.file_name || "Document";
|
|
4934
|
-
const { findings, chunkToTag } = React.useMemo(() => {
|
|
4935
|
-
const list = [];
|
|
4936
|
-
const chunkTag = /* @__PURE__ */ new Map();
|
|
4937
|
-
for (const dt of doc?.doctags ?? []) {
|
|
4938
|
-
const chunkIds = (dt.citations ?? []).flatMap((d) => (d.chunks ?? []).map((c) => c.chunk_id));
|
|
4939
|
-
if (chunkIds.length === 0) continue;
|
|
4940
|
-
list.push({
|
|
4941
|
-
key: dt.tag_ext_id,
|
|
4942
|
-
tagExtId: dt.tag_ext_id,
|
|
4943
|
-
statement: dt.note ?? "",
|
|
4944
|
-
chunkIds
|
|
4945
|
-
});
|
|
4946
|
-
for (const cid of chunkIds) if (!chunkTag.has(cid)) chunkTag.set(cid, dt.tag_ext_id);
|
|
4947
|
-
}
|
|
4948
|
-
return { findings: list, chunkToTag: chunkTag };
|
|
4949
|
-
}, [doc?.doctags]);
|
|
4950
|
-
const pages = React.useMemo(() => {
|
|
4951
|
-
const chunks = parsedQuery.data?.chunks ?? [];
|
|
4952
|
-
const byPage = /* @__PURE__ */ new Map();
|
|
4953
|
-
for (const c of chunks) {
|
|
4954
|
-
const p = c.metadata?.page_number ?? 0;
|
|
4955
|
-
if (!byPage.has(p)) byPage.set(p, []);
|
|
4956
|
-
byPage.get(p).push(c);
|
|
4957
|
-
}
|
|
4958
|
-
return [...byPage.entries()].sort((a, b) => a[0] - b[0]);
|
|
4959
|
-
}, [parsedQuery.data]);
|
|
4960
|
-
const scrollRef = React.useRef(null);
|
|
4961
|
-
const [flash, setFlash] = React.useState(null);
|
|
4962
|
-
const jumpToChunk = React.useCallback((chunkId) => {
|
|
4963
|
-
const el = scrollRef.current?.querySelector(`[data-chunk-id="${chunkId}"]`);
|
|
4964
|
-
if (!el) return;
|
|
4965
|
-
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
4966
|
-
setFlash(chunkId);
|
|
4967
|
-
window.setTimeout(() => setFlash((c) => c === chunkId ? null : c), 1600);
|
|
4968
|
-
}, []);
|
|
4969
|
-
const parsedReady = !parsedQuery.isLoading && !!parsedQuery.data;
|
|
4970
|
-
React.useEffect(() => {
|
|
4971
|
-
if (!activeChunkId || !parsedReady) return;
|
|
4972
|
-
const raf = window.requestAnimationFrame(() => jumpToChunk(activeChunkId));
|
|
4973
|
-
return () => window.cancelAnimationFrame(raf);
|
|
4974
|
-
}, [activeChunkId, parsedReady, jumpToChunk]);
|
|
4975
|
-
return /* @__PURE__ */ jsxs(
|
|
4976
|
-
"div",
|
|
4977
|
-
{
|
|
4978
|
-
"data-testid": "document-review",
|
|
4979
|
-
className: cn(
|
|
4980
|
-
"flex h-full min-h-0 flex-col overflow-hidden rounded-lg border bg-card",
|
|
4981
|
-
className
|
|
4982
|
-
),
|
|
4983
|
-
children: [
|
|
4984
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 border-b px-4 py-3", children: [
|
|
4985
|
-
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
4986
|
-
/* @__PURE__ */ jsx("div", { className: "truncate text-sm font-semibold", title, children: title }),
|
|
4987
|
-
/* @__PURE__ */ jsxs("div", { className: "text-xs text-muted-foreground", children: [
|
|
4988
|
-
parsedQuery.data?.metadata?.total_number_of_pages ? `${parsedQuery.data.metadata.total_number_of_pages} pages` : `${pages.length} pages`,
|
|
4989
|
-
findings.length ? ` \xB7 ${findings.length} findings` : ""
|
|
4990
|
-
] })
|
|
4991
|
-
] }),
|
|
4992
|
-
doc?.status ? /* @__PURE__ */ jsx(Badge, { variant: "secondary", children: doc.status }) : null,
|
|
4993
|
-
onClose ? /* @__PURE__ */ jsx(
|
|
4994
|
-
"button",
|
|
4995
|
-
{
|
|
4996
|
-
type: "button",
|
|
4997
|
-
"aria-label": "Close review",
|
|
4998
|
-
"data-testid": "document-review-close",
|
|
4999
|
-
onClick: onClose,
|
|
5000
|
-
className: "rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground",
|
|
5001
|
-
children: /* @__PURE__ */ jsx(X, { className: "size-4" })
|
|
5002
|
-
}
|
|
5003
|
-
) : null
|
|
5004
|
-
] }),
|
|
5005
|
-
/* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-1", children: [
|
|
5006
|
-
findings.length > 0 ? /* @__PURE__ */ jsxs(
|
|
5007
|
-
"aside",
|
|
5008
|
-
{
|
|
5009
|
-
className: "hidden w-64 shrink-0 overflow-y-auto border-r p-3 md:block",
|
|
5010
|
-
"data-testid": "document-review-findings",
|
|
5011
|
-
children: [
|
|
5012
|
-
/* @__PURE__ */ jsx("div", { className: "mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground", children: "AI findings" }),
|
|
5013
|
-
/* @__PURE__ */ jsx("ul", { className: "space-y-2", children: findings.map((f) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
|
|
5014
|
-
"div",
|
|
5015
|
-
{
|
|
5016
|
-
role: "button",
|
|
5017
|
-
tabIndex: 0,
|
|
5018
|
-
"data-testid": "review-finding",
|
|
5019
|
-
onClick: () => jumpToChunk(f.chunkIds[0]),
|
|
5020
|
-
onKeyDown: (e) => {
|
|
5021
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
5022
|
-
e.preventDefault();
|
|
5023
|
-
jumpToChunk(f.chunkIds[0]);
|
|
5024
|
-
}
|
|
5025
|
-
},
|
|
5026
|
-
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",
|
|
5027
|
-
children: [
|
|
5028
|
-
/* @__PURE__ */ jsx(
|
|
5029
|
-
TagEntity,
|
|
5030
|
-
{
|
|
5031
|
-
size: "sm",
|
|
5032
|
-
tag: {
|
|
5033
|
-
external_id: f.tagExtId,
|
|
5034
|
-
name: tagNameById.get(f.tagExtId) ?? f.tagExtId.slice(0, 8)
|
|
5035
|
-
}
|
|
5036
|
-
}
|
|
5037
|
-
),
|
|
5038
|
-
/* @__PURE__ */ jsx("p", { className: "mt-1 line-clamp-3 text-muted-foreground", children: f.statement })
|
|
5039
|
-
]
|
|
5040
|
-
}
|
|
5041
|
-
) }, f.key)) })
|
|
5042
|
-
]
|
|
5043
|
-
}
|
|
5044
|
-
) : null,
|
|
5045
|
-
/* @__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: [
|
|
5046
|
-
/* @__PURE__ */ jsxs("div", { className: "mb-3 flex items-center gap-3", children: [
|
|
5047
|
-
/* @__PURE__ */ jsxs("span", { className: "text-xs font-medium uppercase tracking-wide text-muted-foreground", children: [
|
|
5048
|
-
"Page ",
|
|
5049
|
-
pageNum
|
|
5050
|
-
] }),
|
|
5051
|
-
/* @__PURE__ */ jsx("div", { className: "h-px flex-1 bg-border" })
|
|
5052
|
-
] }),
|
|
5053
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-3", children: chunks.map((c, i) => {
|
|
5054
|
-
const cid = c.metadata?.chunk_ext_id;
|
|
5055
|
-
const tagExtId = cid ? chunkToTag.get(cid) : void 0;
|
|
5056
|
-
const highlighted = !!tagExtId;
|
|
5057
|
-
const isActive = !!cid && cid === activeChunkId;
|
|
5058
|
-
return /* @__PURE__ */ jsxs(
|
|
5059
|
-
"div",
|
|
5060
|
-
{
|
|
5061
|
-
"data-chunk-id": cid,
|
|
5062
|
-
"data-testid": isActive ? "review-chunk-active" : highlighted ? "review-chunk-cited" : "review-chunk",
|
|
5063
|
-
className: cn(
|
|
5064
|
-
"scroll-mt-4 rounded-md px-2 py-1 transition-colors",
|
|
5065
|
-
highlighted && "bg-[var(--color-ai-accent-soft,theme(colors.amber.100))] ring-1 ring-inset ring-border",
|
|
5066
|
-
// The externally-selected search passage wins the
|
|
5067
|
-
// styling: a stronger accent ring so the matched
|
|
5068
|
-
// hit stands out from any AI-finding highlights.
|
|
5069
|
-
isActive && "bg-[var(--color-ai-accent-soft,theme(colors.amber.100))] ring-2 ring-inset ring-ai-accent",
|
|
5070
|
-
flash === cid && "ring-2 ring-ring"
|
|
5071
|
-
),
|
|
5072
|
-
children: [
|
|
5073
|
-
highlighted ? /* @__PURE__ */ jsx("div", { className: "mb-1", children: /* @__PURE__ */ jsx(
|
|
5074
|
-
TagEntity,
|
|
5075
|
-
{
|
|
5076
|
-
size: "sm",
|
|
5077
|
-
tag: {
|
|
5078
|
-
external_id: tagExtId,
|
|
5079
|
-
name: tagNameById.get(tagExtId) ?? tagExtId.slice(0, 8)
|
|
5080
|
-
}
|
|
5081
|
-
}
|
|
5082
|
-
) }) : null,
|
|
5083
|
-
/* @__PURE__ */ jsx(MarkdownRenderer, { className: "prose prose-sm max-w-none dark:prose-invert", children: c.content })
|
|
5084
|
-
]
|
|
5085
|
-
},
|
|
5086
|
-
cid ?? i
|
|
5087
|
-
);
|
|
5088
|
-
}) })
|
|
5089
|
-
] }, pageNum)) }) })
|
|
5090
|
-
] })
|
|
5091
|
-
]
|
|
5092
|
-
}
|
|
5093
|
-
);
|
|
5094
|
-
}
|
|
5095
|
-
function queryTerms(query) {
|
|
5096
|
-
const terms = /* @__PURE__ */ new Set();
|
|
5097
|
-
for (const phrase of query.match(/"([^"]+)"/g) ?? []) {
|
|
5098
|
-
const inner = phrase.slice(1, -1).trim();
|
|
5099
|
-
if (inner) terms.add(inner);
|
|
5100
|
-
}
|
|
5101
|
-
for (const word of query.replace(/"/g, " ").split(/\s+/)) {
|
|
5102
|
-
if (word.length > 2) terms.add(word);
|
|
5103
|
-
}
|
|
5104
|
-
return [...terms];
|
|
5105
|
-
}
|
|
5106
|
-
function HighlightedSnippet({ text, terms }) {
|
|
5107
|
-
const nodes = useMemo(() => {
|
|
5108
|
-
if (terms.length === 0) return [text];
|
|
5109
|
-
const escaped = terms.map((t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
|
|
5110
|
-
const re = new RegExp(`(${escaped.join("|")})`, "gi");
|
|
5111
|
-
return text.split(re).map((part, i) => i % 2 === 1 ? /* @__PURE__ */ jsx("mark", { children: part }, i) : part);
|
|
5112
|
-
}, [text, terms]);
|
|
5113
|
-
return /* @__PURE__ */ jsx(Fragment, { children: nodes });
|
|
5114
|
-
}
|
|
5115
|
-
function ResultRow({
|
|
5116
|
-
result,
|
|
5117
|
-
index,
|
|
5118
|
-
terms,
|
|
5119
|
-
isActive,
|
|
5120
|
-
onSelect
|
|
5121
|
-
}) {
|
|
5122
|
-
return /* @__PURE__ */ jsx(
|
|
5123
|
-
PassageCard,
|
|
5124
|
-
{
|
|
5125
|
-
onClick: onSelect,
|
|
5126
|
-
active: isActive,
|
|
5127
|
-
score: result.score,
|
|
5128
|
-
"data-testid": `arbi-semantic-search-result-${index}`,
|
|
5129
|
-
header: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5130
|
-
/* @__PURE__ */ jsx(FileText, { className: "size-3.5 shrink-0 text-ai-accent" }),
|
|
5131
|
-
/* @__PURE__ */ jsx("span", { className: "truncate text-xs font-medium text-foreground", children: result.docTitle ?? "Document" }),
|
|
5132
|
-
result.page != null && /* @__PURE__ */ jsxs(Badge, { variant: "secondary", children: [
|
|
5133
|
-
"p.",
|
|
5134
|
-
result.page
|
|
5135
|
-
] })
|
|
5136
|
-
] }),
|
|
5137
|
-
children: /* @__PURE__ */ jsxs("p", { className: "line-clamp-3 text-xs leading-relaxed text-muted-foreground", children: [
|
|
5138
|
-
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground/60", children: "\u2026 " }),
|
|
5139
|
-
/* @__PURE__ */ jsx(HighlightedSnippet, { text: result.content, terms }),
|
|
5140
|
-
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground/60", children: " \u2026" })
|
|
5141
|
-
] })
|
|
5142
|
-
}
|
|
5143
|
-
);
|
|
5144
|
-
}
|
|
5145
|
-
function SemanticSearch({
|
|
5146
|
-
docIds,
|
|
5147
|
-
workspaceId,
|
|
5148
|
-
searchMode = "hybrid",
|
|
5149
|
-
placeholder = "Search your documents by meaning\u2026",
|
|
5150
|
-
className,
|
|
5151
|
-
"data-testid": testId = "arbi-semantic-search"
|
|
5152
|
-
}) {
|
|
5153
|
-
const { results, status, error, search, isRunning, query } = useSemanticSearch(docIds);
|
|
5154
|
-
const [value, setValue] = useState("");
|
|
5155
|
-
const [selected, setSelected] = useState(null);
|
|
5156
|
-
const { data: docs = [] } = useDocuments(workspaceId, { enabled: !!workspaceId });
|
|
5157
|
-
const docMap = useMemo(() => {
|
|
5158
|
-
const map = /* @__PURE__ */ new Map();
|
|
5159
|
-
for (const d of docs) if (d.external_id) map.set(d.external_id, d);
|
|
5160
|
-
return map;
|
|
5161
|
-
}, [docs]);
|
|
5162
|
-
const terms = useMemo(() => queryTerms(query), [query]);
|
|
5163
|
-
const submit = useCallback(() => {
|
|
5164
|
-
const q = value.trim();
|
|
5165
|
-
if (!q) return;
|
|
5166
|
-
setSelected(null);
|
|
5167
|
-
void search(q, searchMode);
|
|
5168
|
-
}, [value, search, searchMode]);
|
|
5169
|
-
const selectedDoc = selected?.docId ? docMap.get(selected.docId) : void 0;
|
|
5170
|
-
const hasResults = status === "done" && results.length > 0;
|
|
5171
|
-
return /* @__PURE__ */ jsxs("div", { "data-testid": testId, className: cn("flex min-h-0 flex-col gap-4 md:flex-row", className), children: [
|
|
5172
|
-
/* @__PURE__ */ jsxs(
|
|
5173
|
-
"div",
|
|
5174
|
-
{
|
|
5175
|
-
className: cn(
|
|
5176
|
-
"flex min-h-0 flex-col gap-3 md:w-[22rem] md:shrink-0",
|
|
5177
|
-
selected && "hidden md:flex"
|
|
5178
|
-
),
|
|
5179
|
-
children: [
|
|
5180
|
-
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
5181
|
-
/* @__PURE__ */ jsx(Search, { className: "pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground" }),
|
|
5182
|
-
isRunning && /* @__PURE__ */ jsx(Loader2, { className: "absolute right-3 top-1/2 size-4 -translate-y-1/2 animate-spin text-ai-accent" }),
|
|
5183
|
-
/* @__PURE__ */ jsx(
|
|
5184
|
-
"input",
|
|
5185
|
-
{
|
|
5186
|
-
value,
|
|
5187
|
-
onChange: (e) => setValue(e.target.value),
|
|
5188
|
-
onKeyDown: (e) => e.key === "Enter" && (e.preventDefault(), submit()),
|
|
5189
|
-
placeholder,
|
|
5190
|
-
"aria-label": "Semantic search query",
|
|
5191
|
-
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",
|
|
5192
|
-
"data-testid": "arbi-semantic-search-input"
|
|
5193
|
-
}
|
|
5194
|
-
),
|
|
5195
|
-
/* @__PURE__ */ jsxs(
|
|
5196
|
-
"button",
|
|
5197
|
-
{
|
|
5198
|
-
type: "button",
|
|
5199
|
-
onClick: submit,
|
|
5200
|
-
disabled: !value.trim() || isRunning,
|
|
5201
|
-
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",
|
|
5202
|
-
"data-testid": "arbi-semantic-search-submit",
|
|
5203
|
-
children: [
|
|
5204
|
-
"Search ",
|
|
5205
|
-
/* @__PURE__ */ jsx(CornerDownLeft, { className: "size-3" })
|
|
5206
|
-
]
|
|
5207
|
-
}
|
|
5208
|
-
)
|
|
5209
|
-
] }),
|
|
5210
|
-
status === "error" && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", "data-testid": "arbi-semantic-search-error", children: error }),
|
|
5211
|
-
status === "done" && /* @__PURE__ */ jsxs(
|
|
5212
|
-
"div",
|
|
5213
|
-
{
|
|
5214
|
-
className: "flex min-h-0 flex-col gap-2 overflow-y-auto",
|
|
5215
|
-
"data-testid": "arbi-semantic-search-results",
|
|
5216
|
-
children: [
|
|
5217
|
-
/* @__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` }),
|
|
5218
|
-
results.map((r, i) => /* @__PURE__ */ jsx(
|
|
5219
|
-
ResultRow,
|
|
5220
|
-
{
|
|
5221
|
-
result: r,
|
|
5222
|
-
index: i,
|
|
5223
|
-
terms,
|
|
5224
|
-
isActive: selected?.chunkExtId != null && selected.chunkExtId === r.chunkExtId,
|
|
5225
|
-
onSelect: () => setSelected(r)
|
|
5226
|
-
},
|
|
5227
|
-
r.chunkExtId ?? `${r.docId}-${r.page}-${i}`
|
|
5228
|
-
))
|
|
5229
|
-
]
|
|
5230
|
-
}
|
|
5231
|
-
)
|
|
5232
|
-
]
|
|
5233
|
-
}
|
|
5234
|
-
),
|
|
5235
|
-
/* @__PURE__ */ jsx(
|
|
5236
|
-
"div",
|
|
5237
|
-
{
|
|
5238
|
-
className: cn("min-h-0 min-w-0 flex-1", !selected && "hidden md:block"),
|
|
5239
|
-
"data-testid": "arbi-semantic-search-viewer",
|
|
5240
|
-
children: selected && selected.docId ? /* @__PURE__ */ jsxs("div", { className: "flex h-full min-h-0 flex-col gap-2", children: [
|
|
5241
|
-
/* @__PURE__ */ jsxs(
|
|
5242
|
-
Button,
|
|
5243
|
-
{
|
|
5244
|
-
variant: "ghost",
|
|
5245
|
-
size: "sm",
|
|
5246
|
-
className: "self-start md:hidden",
|
|
5247
|
-
onClick: () => setSelected(null),
|
|
5248
|
-
"data-testid": "arbi-semantic-search-back",
|
|
5249
|
-
children: [
|
|
5250
|
-
/* @__PURE__ */ jsx(ArrowLeft, { className: "size-4" }),
|
|
5251
|
-
" Back to results"
|
|
5252
|
-
]
|
|
5253
|
-
}
|
|
5254
|
-
),
|
|
5255
|
-
/* @__PURE__ */ jsx(
|
|
5256
|
-
DocumentReview,
|
|
5257
|
-
{
|
|
5258
|
-
docId: selected.docId,
|
|
5259
|
-
doc: selectedDoc,
|
|
5260
|
-
workspaceId,
|
|
5261
|
-
activeChunkId: selected.chunkExtId ?? void 0,
|
|
5262
|
-
className: "min-h-0 flex-1"
|
|
5263
|
-
},
|
|
5264
|
-
selected.docId
|
|
5265
|
-
)
|
|
5266
|
-
] }) : /* @__PURE__ */ jsx(
|
|
5267
|
-
"div",
|
|
5268
|
-
{
|
|
5269
|
-
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",
|
|
5270
|
-
"data-testid": "arbi-semantic-search-empty",
|
|
5271
|
-
children: /* @__PURE__ */ jsxs("div", { className: "max-w-xs", children: [
|
|
5272
|
-
/* @__PURE__ */ jsx(Search, { className: "mx-auto mb-3 size-6 text-muted-foreground/50" }),
|
|
5273
|
-
/* @__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." })
|
|
5274
|
-
] })
|
|
5275
|
-
}
|
|
5276
|
-
)
|
|
5277
|
-
}
|
|
5278
|
-
)
|
|
5279
|
-
] });
|
|
5280
|
-
}
|
|
5281
5162
|
function DocQaPanel({ docId, docName }) {
|
|
5282
5163
|
const task = useAiTask();
|
|
5283
5164
|
const [q, setQ] = useState("");
|
|
@@ -5726,7 +5607,7 @@ var CitationLink = ({
|
|
|
5726
5607
|
]
|
|
5727
5608
|
}
|
|
5728
5609
|
);
|
|
5729
|
-
var CitationRenderer =
|
|
5610
|
+
var CitationRenderer = React3.memo(CitationRendererComponent);
|
|
5730
5611
|
var FileIcon = ({ size = 16, className = "" }) => {
|
|
5731
5612
|
return /* @__PURE__ */ jsxs(
|
|
5732
5613
|
"svg",
|
|
@@ -6364,6 +6245,7 @@ function notificationUserName(user) {
|
|
|
6364
6245
|
return [user.given_name, user.family_name].filter(Boolean).join(" ") || user.email;
|
|
6365
6246
|
}
|
|
6366
6247
|
var CONVERSATION_ID = /^con-[a-zA-Z0-9]+$/;
|
|
6248
|
+
var WORKFLOW_ID = /^wfl-[a-zA-Z0-9]+$/;
|
|
6367
6249
|
var DOCUMENT_ID = /^doc-[a-zA-Z0-9]+$/;
|
|
6368
6250
|
function parse(content) {
|
|
6369
6251
|
try {
|
|
@@ -6492,6 +6374,14 @@ function conversationTarget(n) {
|
|
|
6492
6374
|
...n.message_ext_id ? { messageId: n.message_ext_id } : {}
|
|
6493
6375
|
};
|
|
6494
6376
|
}
|
|
6377
|
+
function workflowTarget(n) {
|
|
6378
|
+
const workflowId = parse(n.content)?.workflow_ext_id;
|
|
6379
|
+
return {
|
|
6380
|
+
kind: "workflows",
|
|
6381
|
+
...typeof workflowId === "string" && WORKFLOW_ID.test(workflowId) ? { workflowId } : {},
|
|
6382
|
+
...n.workspace_ext_id ? { workspaceId: n.workspace_ext_id } : {}
|
|
6383
|
+
};
|
|
6384
|
+
}
|
|
6495
6385
|
function signatureTitle(n, senderName, documentName) {
|
|
6496
6386
|
const type = n.type;
|
|
6497
6387
|
const { documentId } = signatureRequestMeta(n.content);
|
|
@@ -6657,22 +6547,14 @@ function describeServerNotification(n, options = {}) {
|
|
|
6657
6547
|
variant: "success",
|
|
6658
6548
|
target: conversationTarget(n)
|
|
6659
6549
|
};
|
|
6660
|
-
case "workflow_completed":
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
title: "A workflow completed",
|
|
6664
|
-
variant: "success",
|
|
6665
|
-
target: {
|
|
6666
|
-
kind: "workflows",
|
|
6667
|
-
...typeof workflowId === "string" ? { workflowId } : {}
|
|
6668
|
-
}
|
|
6669
|
-
};
|
|
6670
|
-
}
|
|
6550
|
+
case "workflow_completed":
|
|
6551
|
+
return { title: "A workflow completed", variant: "success", target: workflowTarget(n) };
|
|
6552
|
+
// The failed run's thread when it has one (its error is there), else the workflow.
|
|
6671
6553
|
case "workflow_failed":
|
|
6672
6554
|
return {
|
|
6673
6555
|
title: "A workflow failed to start",
|
|
6674
6556
|
variant: "error",
|
|
6675
|
-
target:
|
|
6557
|
+
target: conversationTarget(n) ?? workflowTarget(n)
|
|
6676
6558
|
};
|
|
6677
6559
|
case "deployment_user_invited":
|
|
6678
6560
|
case "deployment_user_registered": {
|
|
@@ -7963,10 +7845,18 @@ function CommandPaletteProvider({
|
|
|
7963
7845
|
}
|
|
7964
7846
|
|
|
7965
7847
|
// src/session/store.ts
|
|
7848
|
+
var DEFAULT_DOCUMENT_VIEWER_STATE = {
|
|
7849
|
+
tab: "pdf",
|
|
7850
|
+
compareId: null,
|
|
7851
|
+
tabRequest: null,
|
|
7852
|
+
textScale: 1,
|
|
7853
|
+
phonePdfChosen: false
|
|
7854
|
+
};
|
|
7966
7855
|
var EMPTY_SESSION_STATE = {
|
|
7967
7856
|
workspaceId: null,
|
|
7968
7857
|
conversationId: null,
|
|
7969
7858
|
viewingDocument: null,
|
|
7859
|
+
documentViewer: DEFAULT_DOCUMENT_VIEWER_STATE,
|
|
7970
7860
|
selectedDocumentIds: [],
|
|
7971
7861
|
generating: {},
|
|
7972
7862
|
paMode: false,
|
|
@@ -8003,6 +7893,12 @@ function createArbiSessionStore(initial = {}) {
|
|
|
8003
7893
|
if (state.conversationId !== conversationId) update({ conversationId });
|
|
8004
7894
|
},
|
|
8005
7895
|
setViewingDocument: (input) => update({ viewingDocument: nextViewingDocument(state.viewingDocument, input) }),
|
|
7896
|
+
setDocumentViewer: (change) => {
|
|
7897
|
+
const next = { ...state.documentViewer, ...change };
|
|
7898
|
+
const keys = Object.keys(change);
|
|
7899
|
+
if (keys.some((key) => next[key] !== state.documentViewer[key]))
|
|
7900
|
+
update({ documentViewer: next });
|
|
7901
|
+
},
|
|
8006
7902
|
setSelectedDocumentIds: (ids) => update({ selectedDocumentIds: ids }),
|
|
8007
7903
|
setConversationGenerating: (conversationId, isGenerating) => {
|
|
8008
7904
|
const current = state.generating[conversationId];
|
|
@@ -8081,7 +7977,7 @@ function DocumentTable({
|
|
|
8081
7977
|
const rows = documents ?? query.data ?? [];
|
|
8082
7978
|
const isLoading = !documents && query.isLoading;
|
|
8083
7979
|
const tagsQuery = useTags(workspaceId);
|
|
8084
|
-
const tagNameById =
|
|
7980
|
+
const tagNameById = React3.useMemo(() => {
|
|
8085
7981
|
const map = /* @__PURE__ */ new Map();
|
|
8086
7982
|
for (const t of tagsQuery.data ?? []) {
|
|
8087
7983
|
if (t.external_id) map.set(t.external_id, t.name ?? t.external_id.slice(0, 8));
|
|
@@ -8094,15 +7990,15 @@ function DocumentTable({
|
|
|
8094
7990
|
const viewingDocId = useArbiSessionState(selectViewingDocumentId);
|
|
8095
7991
|
const effectiveSelected = selectedIds ?? storeSelected;
|
|
8096
7992
|
const emitSelection = onSelectionChange ?? storeSetSelected;
|
|
8097
|
-
const gridApiRef =
|
|
8098
|
-
const openDocument =
|
|
7993
|
+
const gridApiRef = React3.useRef(null);
|
|
7994
|
+
const openDocument = React3.useCallback(
|
|
8099
7995
|
(id) => {
|
|
8100
7996
|
session.setViewingDocument({ id });
|
|
8101
7997
|
onOpenDocument?.(id);
|
|
8102
7998
|
},
|
|
8103
7999
|
[onOpenDocument, session]
|
|
8104
8000
|
);
|
|
8105
|
-
const applySelection =
|
|
8001
|
+
const applySelection = React3.useCallback(() => {
|
|
8106
8002
|
const api = gridApiRef.current;
|
|
8107
8003
|
if (!api) return;
|
|
8108
8004
|
const wanted = new Set(effectiveSelected);
|
|
@@ -8112,10 +8008,10 @@ function DocumentTable({
|
|
|
8112
8008
|
if (node.isSelected() !== shouldSelect) node.setSelected(shouldSelect);
|
|
8113
8009
|
});
|
|
8114
8010
|
}, [effectiveSelected]);
|
|
8115
|
-
|
|
8011
|
+
React3.useEffect(() => {
|
|
8116
8012
|
applySelection();
|
|
8117
8013
|
}, [applySelection]);
|
|
8118
|
-
const columnDefs =
|
|
8014
|
+
const columnDefs = React3.useMemo(
|
|
8119
8015
|
() => [
|
|
8120
8016
|
{
|
|
8121
8017
|
colId: "select",
|
|
@@ -8223,7 +8119,7 @@ function DocumentTable({
|
|
|
8223
8119
|
const id = e.data?.external_id;
|
|
8224
8120
|
if (id) openDocument(id);
|
|
8225
8121
|
};
|
|
8226
|
-
const getRowId =
|
|
8122
|
+
const getRowId = React3.useCallback((params) => params.data.external_id, []);
|
|
8227
8123
|
const autoHeight = height === "auto";
|
|
8228
8124
|
const style = autoHeight ? {} : { height: typeof height === "number" ? `${height}px` : height, width: "100%" };
|
|
8229
8125
|
if (isLoading) {
|
|
@@ -8354,14 +8250,14 @@ function DocumentGallery({
|
|
|
8354
8250
|
const rows = documents ?? query.data ?? [];
|
|
8355
8251
|
const isLoading = !documents && query.isLoading;
|
|
8356
8252
|
const tagsQuery = useTags(workspaceId);
|
|
8357
|
-
const tagNameById =
|
|
8253
|
+
const tagNameById = React3.useMemo(() => {
|
|
8358
8254
|
const map = /* @__PURE__ */ new Map();
|
|
8359
8255
|
for (const t of tagsQuery.data ?? []) {
|
|
8360
8256
|
if (t.external_id) map.set(t.external_id, t.name ?? t.external_id.slice(0, 8));
|
|
8361
8257
|
}
|
|
8362
8258
|
return map;
|
|
8363
8259
|
}, [tagsQuery.data]);
|
|
8364
|
-
const docIds =
|
|
8260
|
+
const docIds = React3.useMemo(
|
|
8365
8261
|
() => rows.map((d) => d.external_id).filter((id) => !!id),
|
|
8366
8262
|
[rows]
|
|
8367
8263
|
);
|
|
@@ -8373,8 +8269,8 @@ function DocumentGallery({
|
|
|
8373
8269
|
const viewingDocId = useArbiSessionState(selectViewingDocumentId);
|
|
8374
8270
|
const effectiveSelected = selectedIds ?? storeSelected;
|
|
8375
8271
|
const emitSelection = onSelectionChange ?? storeSetSelected;
|
|
8376
|
-
const selectedSet =
|
|
8377
|
-
const toggleSelected =
|
|
8272
|
+
const selectedSet = React3.useMemo(() => new Set(effectiveSelected), [effectiveSelected]);
|
|
8273
|
+
const toggleSelected = React3.useCallback(
|
|
8378
8274
|
(id) => {
|
|
8379
8275
|
const next = new Set(effectiveSelected);
|
|
8380
8276
|
if (next.has(id)) next.delete(id);
|
|
@@ -8383,14 +8279,14 @@ function DocumentGallery({
|
|
|
8383
8279
|
},
|
|
8384
8280
|
[effectiveSelected, emitSelection]
|
|
8385
8281
|
);
|
|
8386
|
-
const openDocument =
|
|
8282
|
+
const openDocument = React3.useCallback(
|
|
8387
8283
|
(id) => {
|
|
8388
8284
|
session.setViewingDocument({ id });
|
|
8389
8285
|
onOpenDocument?.(id);
|
|
8390
8286
|
},
|
|
8391
8287
|
[onOpenDocument, session]
|
|
8392
8288
|
);
|
|
8393
|
-
const [renamingId, setRenamingId] =
|
|
8289
|
+
const [renamingId, setRenamingId] = React3.useState(null);
|
|
8394
8290
|
const update = useUpdateDocuments();
|
|
8395
8291
|
const rename = (doc, title) => update.mutate(
|
|
8396
8292
|
{
|
|
@@ -8465,6 +8361,186 @@ function DocumentGallery({
|
|
|
8465
8361
|
}
|
|
8466
8362
|
);
|
|
8467
8363
|
}
|
|
8364
|
+
function DocumentReview({
|
|
8365
|
+
docId,
|
|
8366
|
+
doc,
|
|
8367
|
+
workspaceId,
|
|
8368
|
+
stage = "final",
|
|
8369
|
+
activeChunkId,
|
|
8370
|
+
onClose,
|
|
8371
|
+
className
|
|
8372
|
+
}) {
|
|
8373
|
+
const parsedQuery = useParsedDocument(docId, stage);
|
|
8374
|
+
const tagsQuery = useTags(workspaceId);
|
|
8375
|
+
const tagNameById = React3.useMemo(() => {
|
|
8376
|
+
const map = /* @__PURE__ */ new Map();
|
|
8377
|
+
for (const t of tagsQuery.data ?? []) {
|
|
8378
|
+
if (t.external_id) map.set(t.external_id, t.name ?? t.external_id.slice(0, 8));
|
|
8379
|
+
}
|
|
8380
|
+
return map;
|
|
8381
|
+
}, [tagsQuery.data]);
|
|
8382
|
+
const title = doc?.doc_metadata?.title || doc?.file_name || "Document";
|
|
8383
|
+
const { findings, chunkToTag } = React3.useMemo(() => {
|
|
8384
|
+
const list = [];
|
|
8385
|
+
const chunkTag = /* @__PURE__ */ new Map();
|
|
8386
|
+
for (const dt of doc?.doctags ?? []) {
|
|
8387
|
+
const chunkIds = (dt.citations ?? []).flatMap((d) => (d.chunks ?? []).map((c) => c.chunk_id));
|
|
8388
|
+
if (chunkIds.length === 0) continue;
|
|
8389
|
+
list.push({
|
|
8390
|
+
key: dt.tag_ext_id,
|
|
8391
|
+
tagExtId: dt.tag_ext_id,
|
|
8392
|
+
statement: dt.note ?? "",
|
|
8393
|
+
chunkIds
|
|
8394
|
+
});
|
|
8395
|
+
for (const cid of chunkIds) if (!chunkTag.has(cid)) chunkTag.set(cid, dt.tag_ext_id);
|
|
8396
|
+
}
|
|
8397
|
+
return { findings: list, chunkToTag: chunkTag };
|
|
8398
|
+
}, [doc?.doctags]);
|
|
8399
|
+
const pages = React3.useMemo(() => {
|
|
8400
|
+
const chunks = parsedQuery.data?.chunks ?? [];
|
|
8401
|
+
const byPage = /* @__PURE__ */ new Map();
|
|
8402
|
+
for (const c of chunks) {
|
|
8403
|
+
const p = c.metadata?.page_number ?? 0;
|
|
8404
|
+
if (!byPage.has(p)) byPage.set(p, []);
|
|
8405
|
+
byPage.get(p).push(c);
|
|
8406
|
+
}
|
|
8407
|
+
return [...byPage.entries()].sort((a, b) => a[0] - b[0]);
|
|
8408
|
+
}, [parsedQuery.data]);
|
|
8409
|
+
const scrollRef = React3.useRef(null);
|
|
8410
|
+
const [flash, setFlash] = React3.useState(null);
|
|
8411
|
+
const jumpToChunk = React3.useCallback((chunkId) => {
|
|
8412
|
+
const el = scrollRef.current?.querySelector(`[data-chunk-id="${chunkId}"]`);
|
|
8413
|
+
if (!el) return;
|
|
8414
|
+
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
8415
|
+
setFlash(chunkId);
|
|
8416
|
+
window.setTimeout(() => setFlash((c) => c === chunkId ? null : c), 1600);
|
|
8417
|
+
}, []);
|
|
8418
|
+
const parsedReady = !parsedQuery.isLoading && !!parsedQuery.data;
|
|
8419
|
+
React3.useEffect(() => {
|
|
8420
|
+
if (!activeChunkId || !parsedReady) return;
|
|
8421
|
+
const raf = window.requestAnimationFrame(() => jumpToChunk(activeChunkId));
|
|
8422
|
+
return () => window.cancelAnimationFrame(raf);
|
|
8423
|
+
}, [activeChunkId, parsedReady, jumpToChunk]);
|
|
8424
|
+
return /* @__PURE__ */ jsxs(
|
|
8425
|
+
"div",
|
|
8426
|
+
{
|
|
8427
|
+
"data-testid": "document-review",
|
|
8428
|
+
className: cn(
|
|
8429
|
+
"flex h-full min-h-0 flex-col overflow-hidden rounded-lg border bg-card",
|
|
8430
|
+
className
|
|
8431
|
+
),
|
|
8432
|
+
children: [
|
|
8433
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 border-b px-4 py-3", children: [
|
|
8434
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
8435
|
+
/* @__PURE__ */ jsx("div", { className: "truncate text-sm font-semibold", title, children: title }),
|
|
8436
|
+
/* @__PURE__ */ jsxs("div", { className: "text-xs text-muted-foreground", children: [
|
|
8437
|
+
parsedQuery.data?.metadata?.total_number_of_pages ? `${parsedQuery.data.metadata.total_number_of_pages} pages` : `${pages.length} pages`,
|
|
8438
|
+
findings.length ? ` \xB7 ${findings.length} findings` : ""
|
|
8439
|
+
] })
|
|
8440
|
+
] }),
|
|
8441
|
+
doc?.status ? /* @__PURE__ */ jsx(Badge, { variant: "secondary", children: doc.status }) : null,
|
|
8442
|
+
onClose ? /* @__PURE__ */ jsx(
|
|
8443
|
+
"button",
|
|
8444
|
+
{
|
|
8445
|
+
type: "button",
|
|
8446
|
+
"aria-label": "Close review",
|
|
8447
|
+
"data-testid": "document-review-close",
|
|
8448
|
+
onClick: onClose,
|
|
8449
|
+
className: "rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground",
|
|
8450
|
+
children: /* @__PURE__ */ jsx(X, { className: "size-4" })
|
|
8451
|
+
}
|
|
8452
|
+
) : null
|
|
8453
|
+
] }),
|
|
8454
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-1", children: [
|
|
8455
|
+
findings.length > 0 ? /* @__PURE__ */ jsxs(
|
|
8456
|
+
"aside",
|
|
8457
|
+
{
|
|
8458
|
+
className: "hidden w-64 shrink-0 overflow-y-auto border-r p-3 md:block",
|
|
8459
|
+
"data-testid": "document-review-findings",
|
|
8460
|
+
children: [
|
|
8461
|
+
/* @__PURE__ */ jsx("div", { className: "mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground", children: "AI findings" }),
|
|
8462
|
+
/* @__PURE__ */ jsx("ul", { className: "space-y-2", children: findings.map((f) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
|
|
8463
|
+
"div",
|
|
8464
|
+
{
|
|
8465
|
+
role: "button",
|
|
8466
|
+
tabIndex: 0,
|
|
8467
|
+
"data-testid": "review-finding",
|
|
8468
|
+
onClick: () => jumpToChunk(f.chunkIds[0]),
|
|
8469
|
+
onKeyDown: (e) => {
|
|
8470
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
8471
|
+
e.preventDefault();
|
|
8472
|
+
jumpToChunk(f.chunkIds[0]);
|
|
8473
|
+
}
|
|
8474
|
+
},
|
|
8475
|
+
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",
|
|
8476
|
+
children: [
|
|
8477
|
+
/* @__PURE__ */ jsx(
|
|
8478
|
+
TagEntity,
|
|
8479
|
+
{
|
|
8480
|
+
size: "sm",
|
|
8481
|
+
tag: {
|
|
8482
|
+
external_id: f.tagExtId,
|
|
8483
|
+
name: tagNameById.get(f.tagExtId) ?? f.tagExtId.slice(0, 8)
|
|
8484
|
+
}
|
|
8485
|
+
}
|
|
8486
|
+
),
|
|
8487
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1 line-clamp-3 text-muted-foreground", children: f.statement })
|
|
8488
|
+
]
|
|
8489
|
+
}
|
|
8490
|
+
) }, f.key)) })
|
|
8491
|
+
]
|
|
8492
|
+
}
|
|
8493
|
+
) : null,
|
|
8494
|
+
/* @__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: [
|
|
8495
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-3 flex items-center gap-3", children: [
|
|
8496
|
+
/* @__PURE__ */ jsxs("span", { className: "text-xs font-medium uppercase tracking-wide text-muted-foreground", children: [
|
|
8497
|
+
"Page ",
|
|
8498
|
+
pageNum
|
|
8499
|
+
] }),
|
|
8500
|
+
/* @__PURE__ */ jsx("div", { className: "h-px flex-1 bg-border" })
|
|
8501
|
+
] }),
|
|
8502
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-3", children: chunks.map((c, i) => {
|
|
8503
|
+
const cid = c.metadata?.chunk_ext_id;
|
|
8504
|
+
const tagExtId = cid ? chunkToTag.get(cid) : void 0;
|
|
8505
|
+
const highlighted = !!tagExtId;
|
|
8506
|
+
const isActive = !!cid && cid === activeChunkId;
|
|
8507
|
+
return /* @__PURE__ */ jsxs(
|
|
8508
|
+
"div",
|
|
8509
|
+
{
|
|
8510
|
+
"data-chunk-id": cid,
|
|
8511
|
+
"data-testid": isActive ? "review-chunk-active" : highlighted ? "review-chunk-cited" : "review-chunk",
|
|
8512
|
+
className: cn(
|
|
8513
|
+
"scroll-mt-4 rounded-md px-2 py-1 transition-colors",
|
|
8514
|
+
highlighted && "bg-[var(--color-ai-accent-soft,theme(colors.amber.100))] ring-1 ring-inset ring-border",
|
|
8515
|
+
// The externally-selected search passage wins the
|
|
8516
|
+
// styling: a stronger accent ring so the matched
|
|
8517
|
+
// hit stands out from any AI-finding highlights.
|
|
8518
|
+
isActive && "bg-[var(--color-ai-accent-soft,theme(colors.amber.100))] ring-2 ring-inset ring-ai-accent",
|
|
8519
|
+
flash === cid && "ring-2 ring-ring"
|
|
8520
|
+
),
|
|
8521
|
+
children: [
|
|
8522
|
+
highlighted ? /* @__PURE__ */ jsx("div", { className: "mb-1", children: /* @__PURE__ */ jsx(
|
|
8523
|
+
TagEntity,
|
|
8524
|
+
{
|
|
8525
|
+
size: "sm",
|
|
8526
|
+
tag: {
|
|
8527
|
+
external_id: tagExtId,
|
|
8528
|
+
name: tagNameById.get(tagExtId) ?? tagExtId.slice(0, 8)
|
|
8529
|
+
}
|
|
8530
|
+
}
|
|
8531
|
+
) }) : null,
|
|
8532
|
+
/* @__PURE__ */ jsx(MarkdownRenderer, { className: "prose prose-sm max-w-none dark:prose-invert", children: c.content })
|
|
8533
|
+
]
|
|
8534
|
+
},
|
|
8535
|
+
cid ?? i
|
|
8536
|
+
);
|
|
8537
|
+
}) })
|
|
8538
|
+
] }, pageNum)) }) })
|
|
8539
|
+
] })
|
|
8540
|
+
]
|
|
8541
|
+
}
|
|
8542
|
+
);
|
|
8543
|
+
}
|
|
8468
8544
|
function VoiceNoteRecorder({
|
|
8469
8545
|
onSave,
|
|
8470
8546
|
onDiscard,
|
|
@@ -9010,6 +9086,6 @@ function hasVideoTrack(blob) {
|
|
|
9010
9086
|
});
|
|
9011
9087
|
}
|
|
9012
9088
|
|
|
9013
|
-
export { ALLOWED_PORTAL_ORIGINS, AccountClientProvider, ActivityFeed, AiActionCard, AiAnswer, AppleIcon, ArbiBotIcon, ArbiSessionStateProvider, ArbiWebSocketProvider, ArtifactCanvas, BOX_SEAT_REFUSED, BOX_SEAT_REFUSED_ACTION, BOX_SEAT_REFUSED_TITLE, CalendarSupportProvider, ChatBubble, CitationRenderer, ClaudeIcon, CommandPalette, CommandPaletteProvider, ConversationList, DEFAULT_ASPECT_OPTIONS, DEFAULT_PASSWORD_CHANGE_FORM_MESSAGES, DEFAULT_START_BY_EMAIL_LABELS, DateSeparator, DirectMessages, DmAvatar, DmComposer, DocQaPanel, DocSearch, DocumentCardMenu, DocumentGallery, DocumentReview, DocumentTable, DocumentsSupportProvider, DraftTitleControls, EMPTY_SESSION_STATE, FileIcon, FireworksIcon, GeminiIcon, GitHubIcon, GoogleIcon, ImageCropModal, ImageCropper, LinkedInIcon, MAIL_DRAFT_REPLACED_EVENT, MAX_AVATAR_FILE_BYTES, MailClientProvider, MailOfflineUnavailableError, MessageArtifactCard, MessageBubble, MessageThread, OpenAIIcon, PhotoCapture, ProviderIcon, RUN_WINDOW_MS, SIGNATURE_NOTIFICATION_TYPES,
|
|
9089
|
+
export { ALLOWED_PORTAL_ORIGINS, AccountClientProvider, ActivityFeed, AiActionCard, AiAnswer, AppleIcon, ArbiBotIcon, ArbiSessionStateProvider, ArbiWebSocketProvider, ArtifactCanvas, BOX_SEAT_REFUSED, BOX_SEAT_REFUSED_ACTION, BOX_SEAT_REFUSED_TITLE, CalendarSupportProvider, ChatBubble, CitationRenderer, ClaudeIcon, CommandPalette, CommandPaletteProvider, ConversationList, DEFAULT_ASPECT_OPTIONS, DEFAULT_DOCUMENT_VIEWER_STATE, DEFAULT_PASSWORD_CHANGE_FORM_MESSAGES, DEFAULT_START_BY_EMAIL_LABELS, DateSeparator, DirectMessages, DmAvatar, DmComposer, DocQaPanel, DocSearch, DocumentCardMenu, DocumentGallery, DocumentReview, DocumentTable, DocumentsSupportProvider, DraftTitleControls, EMPTY_SESSION_STATE, FileIcon, FireworksIcon, GeminiIcon, GitHubIcon, GoogleIcon, ImageCropModal, ImageCropper, LinkedInIcon, MAIL_DRAFT_REPLACED_EVENT, MAX_AVATAR_FILE_BYTES, MailClientProvider, MailOfflineUnavailableError, MessageArtifactCard, MessageBubble, MessageThread, OpenAIIcon, POLL_EVERY_MS, PhotoCapture, ProviderIcon, RUN_WINDOW_MS, SIGNATURE_NOTIFICATION_TYPES, SLOW_AFTER_MS, STILL_WORKING, StartByEmail, TypingIndicator, VideoCapture, VoiceNoteRecorder, WORK_NOTIFICATION_LABELS, accountPath, aliasTakenMessage, annotateThread, announceMailDraftReplaced, applyOptimisticDocumentEdit, arbiAccountClient, arbiMailClient, calendarQueryKeys, callNotificationMeta, captureFrameAsBlob, connectOAuthCalendarAccount, connectorErrorStatus, connectorQueryKeys, connectorReturnTo, createArbiSessionStore, createMailClient, cropImage, dayKey, defaultMailAlias, deploymentUserMeta, describeActivity, describeServerNotification, documentActivityMeta, documentActivityPhrase, documentDisplayName, docxMentionMeta, downloadRecoveryFile, fileAttachment, formatIdentityPrice, getNotificationTypeMeta, getWorkspaceActionText, getWorkspaceKind, getWorkspaceSentPhrase, hasVideoTrack, identityStepFor, inputRequestTitle, invalidateCalendarEvents, invalidateCalendars, isAliasTakenError, isDeploymentAdmin, isDeploymentUserNotification, isOfflineReadableArbiQuery, isQueuedCalendarWrite, isReplayableArbiMutation, isRestorableArbiQueryOnline, isSignatureNotificationType, isWorkspaceNotificationType, mailDraftIdFromContent, mailJson, mailQueryKeys, mountDiditVerification, nextAliasSuggestion, nextViewingDocument, notificationUserName, parseActivityContent, parseDeleteAccountBlockers, pickRecentWorkspaces, redlineStats, registerArbiMutationDefaults, resetCalendarAccountSyncState, resolveActiveWorkspace, rollbackOptimisticDocumentEdit, safePortalUrl, selectIsGenerating, selectViewingDocumentId, signatureNotificationPhrase, signatureRequestMeta, supportsHouseTemplates, textToArtifact, titleFromQuestion, toChatCitations, toNotificationPreferences, toProfileView, toRedlineMarkdown, toShellWorkspace, useAccountClient, useActOnStep, useAddHolidayCalendar, useAddProjectAddonBlock, useAddWorkspaceMembers, useAddonQuote, useAgentChats, useAgentConfig, useAgentModels, useAgentSession, useAgentWorkspaces, useAiTask, useArbiChat, useArbiConnected, useArbiDocumentSync, useArbiSessionState, useArbiSessionStore, useArbiShellWorkspaces, useArbiWebSocket, useArbiWsContext, useArbiWsMessage, useArbiWsStatus, useArbiWsStore, useArbiWsTask, useArbiWsTasks, useAssignDocTags, useAuthorizeLimits, useAvatarCrop, useBookingPages, useCalDavProfiles, useCalendarAccounts, useCalendarEvent, useCalendarEventByUid, useCalendarEvents, useCalendarInvitations, useCalendarOutbox, useCalendarOverlays, useCalendarSettings, useCalendarShares, useCalendarSupport, useCalendars, useCameraStream, useCancelDriveSync, useCancelMailboxSync, useCancelProjectSubscription, useChangeProjectPlan, useChargeWatch, useClaimNativeAlias, useCloseAgentSession, useCommandPalette, useConfirmEmailChange, useConnectCalDavAccount, useConnectMailAccount, useConnectOAuthAccount, useConnectorAutoSync, useConnectorCatalog, useConnectorVendorVisibility, useContacts, useConversationActivity, useConversationPendingAuth, useConversationUsage, useCreateAgent, useCreateCalendar, useCreateContact, useCreateEvent, useCreateFact, useCreateFacts, useCreateProject, useCreateProjectCheckout, useCreateRoom, useCreateWork, useCreateWorkflow, useCurrentSessionId, useDecideCounter, useDeleteAccount, useDeleteAccountFlow, useDeleteBookingPage, useDeleteCalendar, useDeleteContact, useDeleteDocuments, useDeleteEvent, useDeleteFact, useDeleteNotifications, useDeleteProject, useDeleteSkill, useDeleteWorkflow, useDirectMessages, useDisconnectCalendarAccount, useDisconnectConnector, useDisconnectMailAccount, useDisconnectSlack, useDocumentsSupport, useDriveFolderChildren, useDriveFolderDocCount, useDriveFolders, useDriveSyncEstimate, useDriveSyncProgress, useEmailChange, useEnableDriveSync, useEnableMailboxSync, useFacts, useFetchCalendarEvent, useFilteredProjects, useFinaliseTranslation, useFindTime, useFollowThread, useFreeBusy, useGenerateAgentAvatar, useGenerateDocTags, useGrantAgentAccess, useHolidayCountries, useHouseTemplateCandidates, useIdentityVerification, useIdentityVerificationFlow, useImportCalendar, useInvalidateProjects, useInviteContacts, useIsSlow, useMailAccounts, useMailAttachmentText, useMailCache, useMailClient, useMailDraftCompose, useMailDraftEditor, useMailDraftReplaced, useMailFolders, useMailMessage, useMailMessages, useMailOnline, useMailPolicy, useMailProjects, useMailUnlock, useMailboxFolders, useMailboxSyncProgress, useMarkNotificationsRead, useMcpTools, useMoveEvent, useMyConnectors, useNameEditor, useNotificationPreferences, useNotifications, usePassageQuotes, usePasswordChange, usePasswordChangeForm, usePendingContacts, usePlanQuote, usePlanWork, usePreviewProjectPlanChange, useProducts, useProfile, useProjectBillingPortal, useProjectConversationUsage, useProjectEvents, usePublishCalendar, useRefreshCalendar, useRefreshConnectorsOnRunEnd, useRefreshProject, useRemoveDocTags, useRemoveWorkspaceMembers, useRequestEmailChange, useRespondToEvent, useResumeCalendarAccountConnect, useRevokeAgentAccess, useRooms, useRunConversation, useRunWorkflow, useSaveAgentConfig, useSaveBookingPage, useSaveCalendarSettings, useSaveMailDraft, useSearchContacts, useSearchFacts, useSemanticSearch, useSendBackStep, useSendMail, useSessions, useSetSkillVisibility, useSetWorkspaceHouseTemplate, useSetWorkspaceMemberRoles, useShareCalendar, useShellWorkspaces, useSignOut, useSkillSource, useSkills, useSlackConnection, useStartAgentSession, useStartCalendarAccountOAuth, useStartWorkQuery, useSubscribeCalendar, useSyncAccountsOnOpen, useSyncCalendarAccount, useTerminateSession, useTriggerDriveSync, useTriggerMailboxSync, useUnshareCalendar, useUpdateCalendar, useUpdateCalendarAccount, useUpdateContact, useUpdateConversation, useUpdateDocTag, useUpdateDocuments, useUpdateEvent, useUpdateFact, useUpdateMailMessage, useUpdateProfile, useUpdateProjectAddonSettings, useUpdateProjectFields, useUpdateProjectNextPeriodAddons, useUpdateUserSettings, useUpdateWorkflow, useUpdateWorkspace, useUploadDocuments, useUploadSkillFiles, useUploadUrls, useUserSettings, useVideoRecorder, useWorkNotifications, useWorkflowRuns, useWorkflows, useWorkspaceDocs, useWorkspaceNotificationLevel, useWorkspaceUsers, userDisplayName, userInitials, workflowStepOf, workspaceHouseTemplateId };
|
|
9014
9090
|
//# sourceMappingURL=index.js.map
|
|
9015
9091
|
//# sourceMappingURL=index.js.map
|