@arbidocs/react 0.4.108 → 0.4.110
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/README.md +1 -1
- package/dist/artifacts/index.cjs +6 -6
- package/dist/artifacts/index.js +1 -1
- package/dist/{chunk-LICEKTGA.js → chunk-5L46Z7HZ.js} +442 -35
- package/dist/chunk-5L46Z7HZ.js.map +1 -0
- package/dist/{chunk-IXRNX5QB.js → chunk-5WXNTCI3.js} +25 -3
- package/dist/chunk-5WXNTCI3.js.map +1 -0
- package/dist/{chunk-X2KOIXHA.cjs → chunk-AFGE55RQ.cjs} +26 -2
- package/dist/chunk-AFGE55RQ.cjs.map +1 -0
- package/dist/{chunk-KOZ2CJY6.cjs → chunk-XD4P4KRH.cjs} +450 -34
- package/dist/chunk-XD4P4KRH.cjs.map +1 -0
- package/dist/index.cjs +476 -386
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +541 -459
- package/dist/index.d.ts +541 -459
- package/dist/index.js +154 -110
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +113 -113
- package/dist/ui/index.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-IXRNX5QB.js.map +0 -1
- package/dist/chunk-KOZ2CJY6.cjs.map +0 -1
- package/dist/chunk-LICEKTGA.js.map +0 -1
- package/dist/chunk-X2KOIXHA.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { arbiQueryKeys, useDocuments, useConversations, useAssistantQuery, useConversationThreads, useWorkspaces, useParsedDocument, useTags, useActivity, useThumbnails } from './chunk-
|
|
2
|
-
export { PROJECT_CREATION_DENIED_REASON, arbiQueryKeys, isUsageMetered, useActivity, useAgents, useAssistantQuery, useCanCreateProjects, useConfigs, useConversationThreads, useConversations, useCurrentUser, useDeleteAgents, useDocuments, useFacts, useHealth, useParsedDocument, useProjectInvoices, useProjectUsage, useProjects, useProjectsUsage, useSessions, useTags, useThumbnails, useUserUsageToday, useWorkspaceActivity, useWorkspaceUsers, useWorkspaces } from './chunk-
|
|
1
|
+
import { arbiQueryKeys, useDocuments, useConversations, useAssistantQuery, useConversationThreads, useWorkspaces, useParsedDocument, useTags, useActivity, useThumbnails } from './chunk-5WXNTCI3.js';
|
|
2
|
+
export { PROJECT_CREATION_DENIED_REASON, arbiQueryKeys, isUsageMetered, useActivity, useAgents, useAssistantQuery, useCanCreateProjects, useConfigs, useConversationThreads, useConversations, useCurrentUser, useDeleteAgents, useDocuments, useFacts, useFirmPool, useHealth, useParsedDocument, useProjectInvoices, useProjectUsage, useProjects, useProjectsUsage, useSessions, useTags, useThumbnails, useTopUpFirmPool, useUserUsageToday, useWorkspaceActivity, useWorkspaceUsers, useWorkspaces } from './chunk-5WXNTCI3.js';
|
|
3
3
|
export { cleanDraftMarkdown, cleanDraftWithReport, promoteBoldTitle, repairParsedStructure, repairParsedTitle, stripAgentPreamble, unescapeMarkdown, unwrapCitationLinks } from './chunk-G6FHNURH.js';
|
|
4
4
|
import { formatRelativeTime } from './chunk-ECOSGMTW.js';
|
|
5
5
|
export { DEFAULT_NOTIFY_TONE, NotificationBell, Toaster, formatRelativeTime, notify, seedNotifications, selectUnread, toast, useNotify } from './chunk-ECOSGMTW.js';
|
|
6
|
-
import { returnFocusToMark, MarkMenu, AiMarkdown, Card, Badge, TagEntity, Input, FILE_TYPE_COLORS, getEntityIcon, UserEntity, getEntityColorStyles, AgentBadge, Textarea, Label, Slider, DocumentEntity, DocumentCard, useAudioRecorder, MicWaveformIndicator, IconToggle, classifyMediaError, formatElapsed, PassageCard } from './chunk-
|
|
7
|
-
export { AgentBadge, AiMarkdown, ArbiBotHeadIcon, 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, DictateProvider, DocIcon, DocumentCard, DocumentEntity, ENTITY_MAPPINGS, EmlIcon, EntityIcon, EntityPill, FILE_TYPE_COLORS, HoverCard, HoverCardContent, HoverCardTrigger, HtmlIcon, IconToggle, ImgIcon, InlineMicButton, Input, Label, MarkMenu, MicRecordingOverlay, MicWaveformIndicator, NEUTRAL_GRAY, PLACEHOLDER_COLOR, PassageCard, PdfIcon, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, PresenceLabel, Progress, ProjectEntity, RadioGroup, RadioGroupItem, RagDot, RelevanceDot, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, 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, VISIBILITY_ICONS, VerifiedBadge, VidIcon, VisibilityIcon, VisibilityToggle, XlsIcon, badgeVariants, cardVariants, classifyMediaError, configureEntityRegistry, configureRagLabels, configureStatusRegistry, formatElapsed, getDocIcon, getEntityColor, getEntityColorStyles, getEntityIcon, getEntityLabel, getStatusVariant, getTagTypeIcon, getTagTypeLabel, getWorkspaceColor, toggleVariants, useAudioRecorder } from './chunk-
|
|
6
|
+
import { returnFocusToMark, MarkMenu, AiMarkdown, Card, Badge, TagEntity, Input, FILE_TYPE_COLORS, getEntityIcon, UserEntity, getEntityColorStyles, AgentBadge, Textarea, Label, Slider, DocumentEntity, DocumentCard, useAudioRecorder, MicWaveformIndicator, IconToggle, classifyMediaError, formatElapsed, PassageCard } from './chunk-5L46Z7HZ.js';
|
|
7
|
+
export { AUDIO_MIME_PREFERENCE, AgentBadge, AiMarkdown, ArbiBotHeadIcon, 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, 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, PopoverContent, PopoverTrigger, PresenceLabel, Progress, ProjectEntity, RadioGroup, RadioGroupItem, RagDot, RelevanceDot, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, 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, 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-5L46Z7HZ.js';
|
|
8
8
|
import { MarkdownRenderer } from './chunk-EKRRORFO.js';
|
|
9
9
|
export { MarkdownRenderer, MarkdownStreamingContext, markdownBaseComponents, splitMarkdownBlocks } from './chunk-EKRRORFO.js';
|
|
10
10
|
import { Button, Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from './chunk-YNNAJJ5Z.js';
|
|
@@ -22,7 +22,7 @@ import { useArbi, ArbiContext } from './chunk-BUFDJCDS.js';
|
|
|
22
22
|
export { ArbiProvider, useArbi, useDeploymentDomain } from './chunk-BUFDJCDS.js';
|
|
23
23
|
import React, { memo, useState, createContext, useMemo, useCallback, useEffect, useRef, useLayoutEffect, useContext, useId, useSyncExternalStore, Fragment as Fragment$1 } from 'react';
|
|
24
24
|
import { useQueryClient, useMutation, useQuery, onlineManager } from '@tanstack/react-query';
|
|
25
|
-
import { resolveCitations, summarizeCitations, settings, formatFileSize, connectWithReconnect,
|
|
25
|
+
import { resolveCitations, summarizeCitations, settings, formatFileSize, connectWithReconnect, chats, identityErrorCode } from '@arbidocs/sdk/browser';
|
|
26
26
|
export { Arbi, ArbiError, DEFAULT_AI_USD_PER_GBP, formatGbp, formatGbpPerMillionTokens, usdToGbp } from '@arbidocs/sdk/browser';
|
|
27
27
|
import { Link, Trash2, CheckCheck, Check, Loader2, AlertTriangle, ShieldCheck, Copy, Sparkles, FileText, GitCompareArrows, Download, Search, CornerDownLeft, X, ArrowLeft, Send, Tags, Crown, Info, Activity, Gauge, Gift, PartyPopper, UserCheck, Reply, PenLine, AtSign, MessageCircleMore, FileX2, FileCheck2, Pencil, FolderPlus, SquareArrowOutUpRight, MessagesSquare, Paperclip, ArrowRight, MoreHorizontal, SquarePen, Mic, Pause, Play, Square, RotateCcw, Camera, Circle, Image as Image$1, AppWindow } from 'lucide-react';
|
|
28
28
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -1589,27 +1589,45 @@ function useContacts(options) {
|
|
|
1589
1589
|
function usePendingContacts(options) {
|
|
1590
1590
|
const contacts = useContacts(options);
|
|
1591
1591
|
const pending = useMemo(
|
|
1592
|
-
() => (contacts.data ?? []).filter(
|
|
1593
|
-
(c) => c.status === "invitation_pending" || c.status === "invitation_expired"
|
|
1594
|
-
),
|
|
1592
|
+
() => (contacts.data ?? []).filter((c) => c.status === "invited" || c.status === "expired"),
|
|
1595
1593
|
[contacts.data]
|
|
1596
1594
|
);
|
|
1597
1595
|
return { ...contacts, pending };
|
|
1598
1596
|
}
|
|
1599
|
-
function
|
|
1600
|
-
const arbi = useArbi();
|
|
1597
|
+
function useInvalidateContacts() {
|
|
1601
1598
|
const qc = useQueryClient();
|
|
1599
|
+
return () => qc.invalidateQueries({ queryKey: arbiQueryKeys.contacts() });
|
|
1600
|
+
}
|
|
1601
|
+
function useInviteContacts() {
|
|
1602
|
+
const arbi = useArbi();
|
|
1603
|
+
const invalidate = useInvalidateContacts();
|
|
1602
1604
|
return useMutation({
|
|
1603
|
-
mutationFn: (emails) => arbi.contacts.
|
|
1604
|
-
onSuccess: () =>
|
|
1605
|
+
mutationFn: (emails) => arbi.contacts.invite(emails),
|
|
1606
|
+
onSuccess: () => invalidate()
|
|
1605
1607
|
});
|
|
1606
1608
|
}
|
|
1607
|
-
function
|
|
1609
|
+
function useCreateContact() {
|
|
1608
1610
|
const arbi = useArbi();
|
|
1609
|
-
const
|
|
1611
|
+
const invalidate = useInvalidateContacts();
|
|
1610
1612
|
return useMutation({
|
|
1611
|
-
mutationFn: (
|
|
1612
|
-
onSuccess: () =>
|
|
1613
|
+
mutationFn: (body) => arbi.contacts.create(body),
|
|
1614
|
+
onSuccess: () => invalidate()
|
|
1615
|
+
});
|
|
1616
|
+
}
|
|
1617
|
+
function useUpdateContact() {
|
|
1618
|
+
const arbi = useArbi();
|
|
1619
|
+
const invalidate = useInvalidateContacts();
|
|
1620
|
+
return useMutation({
|
|
1621
|
+
mutationFn: ({ id, card }) => arbi.contacts.update(id, card),
|
|
1622
|
+
onSuccess: () => invalidate()
|
|
1623
|
+
});
|
|
1624
|
+
}
|
|
1625
|
+
function useDeleteContact() {
|
|
1626
|
+
const arbi = useArbi();
|
|
1627
|
+
const invalidate = useInvalidateContacts();
|
|
1628
|
+
return useMutation({
|
|
1629
|
+
mutationFn: (contactId) => arbi.contacts.delete(contactId),
|
|
1630
|
+
onSuccess: () => invalidate()
|
|
1613
1631
|
});
|
|
1614
1632
|
}
|
|
1615
1633
|
function toProfileView(profile) {
|
|
@@ -4215,8 +4233,11 @@ var CitationLink = ({
|
|
|
4215
4233
|
"data-mark-kind": "citation",
|
|
4216
4234
|
className: cn(
|
|
4217
4235
|
"cited-text relative rounded-sm px-0.5 transition-colors",
|
|
4218
|
-
// 44px touch hit area without changing the text layout.
|
|
4219
|
-
|
|
4236
|
+
// 44px touch hit area without changing the text layout. `touch-hit` grows only up to
|
|
4237
|
+
// 44px (never past the mark's own width), so it doesn't reach over the neighbouring
|
|
4238
|
+
// citation: a fixed inset let citation 2's area cover citation 1, and a tap on [1]
|
|
4239
|
+
// opened [2].
|
|
4240
|
+
"touch-hit",
|
|
4220
4241
|
isStreaming ? "cursor-default" : "cursor-pointer",
|
|
4221
4242
|
isActive ? "bg-ai-soft text-foreground" : "bg-ai-soft/30 hover:bg-ai-soft/70"
|
|
4222
4243
|
),
|
|
@@ -4614,8 +4635,6 @@ function getNotificationTypeMeta(type) {
|
|
|
4614
4635
|
switch (type) {
|
|
4615
4636
|
case "agent_input_requested":
|
|
4616
4637
|
return { Icon: MessageCircleMore, iconClassName: "text-primary", label: "Input needed" };
|
|
4617
|
-
case "user_message":
|
|
4618
|
-
return { Icon: MessageCircleMore, iconClassName: "text-primary", label: "Message" };
|
|
4619
4638
|
case "workspaceuser_added_owner":
|
|
4620
4639
|
case "workspaceuser_added_collaborator":
|
|
4621
4640
|
case "workspaceuser_added_guest":
|
|
@@ -4857,6 +4876,7 @@ function isAgentUser(user) {
|
|
|
4857
4876
|
return user.external_id.startsWith("agt-");
|
|
4858
4877
|
}
|
|
4859
4878
|
var DM_QUERY_KEY = ["arbi", "directMessages"];
|
|
4879
|
+
var THREAD_LIMIT = 100;
|
|
4860
4880
|
function mergeContacts(threads, contacts) {
|
|
4861
4881
|
const byPeer = /* @__PURE__ */ new Map();
|
|
4862
4882
|
for (const t of threads) byPeer.set(t.peer.external_id, t);
|
|
@@ -4874,43 +4894,42 @@ function mergeContacts(threads, contacts) {
|
|
|
4874
4894
|
return userDisplayName(a.peer).localeCompare(userDisplayName(b.peer));
|
|
4875
4895
|
});
|
|
4876
4896
|
}
|
|
4877
|
-
function
|
|
4878
|
-
const
|
|
4879
|
-
const
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4897
|
+
function toConversation(loaded, myExtId, pending) {
|
|
4898
|
+
const { chat } = loaded;
|
|
4899
|
+
const peerMember = chat.members.find((m) => m.user.external_id !== myExtId);
|
|
4900
|
+
if (!peerMember) return null;
|
|
4901
|
+
const meMember = chat.members.find((m) => m.user.external_id === myExtId);
|
|
4902
|
+
const peer = peerMember.user;
|
|
4903
|
+
const userById = new Map(chat.members.map((m) => [m.user.external_id, m.user]));
|
|
4904
|
+
const seen = new Set(loaded.messages.map((m) => m.external_id));
|
|
4905
|
+
const rows = [
|
|
4906
|
+
...loaded.messages,
|
|
4907
|
+
...pending.filter((m) => m.chat_ext_id === chat.external_id && !seen.has(m.external_id))
|
|
4908
|
+
].filter((m) => m.kind === "text" && !m.context_only);
|
|
4909
|
+
const messages = rows.map((m) => {
|
|
4910
|
+
const isMine = m.sender_ext_id === myExtId;
|
|
4911
|
+
const sender = userById.get(m.sender_ext_id ?? "") ?? { external_id: m.sender_ext_id ?? "usr-unknown" };
|
|
4912
|
+
return {
|
|
4913
|
+
externalId: m.external_id,
|
|
4914
|
+
body: m.content ?? "",
|
|
4915
|
+
createdAt: m.created_at,
|
|
4890
4916
|
isMine,
|
|
4891
|
-
read:
|
|
4892
|
-
|
|
4893
|
-
|
|
4917
|
+
// Mine: has the peer read it? Theirs: have I?
|
|
4918
|
+
read: chats.hasRead(isMine ? peerMember : meMember, m),
|
|
4919
|
+
sender,
|
|
4920
|
+
recipient: isMine ? peer : meMember?.user,
|
|
4921
|
+
chatExtId: chat.external_id
|
|
4894
4922
|
};
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
conversations.push({
|
|
4906
|
-
peer: peers.get(peerId),
|
|
4907
|
-
messages,
|
|
4908
|
-
lastMessage: messages[messages.length - 1],
|
|
4909
|
-
unreadCount
|
|
4910
|
-
});
|
|
4911
|
-
}
|
|
4912
|
-
conversations.sort((a, b) => b.lastMessage.createdAt.localeCompare(a.lastMessage.createdAt));
|
|
4913
|
-
return conversations;
|
|
4923
|
+
});
|
|
4924
|
+
messages.sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
4925
|
+
if (messages.length === 0) return null;
|
|
4926
|
+
return {
|
|
4927
|
+
peer,
|
|
4928
|
+
chatExtId: chat.external_id,
|
|
4929
|
+
messages,
|
|
4930
|
+
lastMessage: messages[messages.length - 1],
|
|
4931
|
+
unreadCount: chat.unread_count ?? 0
|
|
4932
|
+
};
|
|
4914
4933
|
}
|
|
4915
4934
|
function useDirectMessages(options) {
|
|
4916
4935
|
const arbi = useArbi();
|
|
@@ -4918,7 +4937,10 @@ function useDirectMessages(options) {
|
|
|
4918
4937
|
const enabled = options?.enabled ?? arbi.isLoggedIn;
|
|
4919
4938
|
const query = useQuery({
|
|
4920
4939
|
queryKey: DM_QUERY_KEY,
|
|
4921
|
-
queryFn: () =>
|
|
4940
|
+
queryFn: async () => {
|
|
4941
|
+
const direct = await arbi.chats.list("direct");
|
|
4942
|
+
return Promise.all(direct.map((c) => arbi.chats.load(c.external_id, { limit: THREAD_LIMIT })));
|
|
4943
|
+
},
|
|
4922
4944
|
enabled
|
|
4923
4945
|
});
|
|
4924
4946
|
const contactsQuery = useQuery({
|
|
@@ -4926,9 +4948,10 @@ function useDirectMessages(options) {
|
|
|
4926
4948
|
queryFn: () => arbi.contacts.list(),
|
|
4927
4949
|
enabled
|
|
4928
4950
|
});
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4951
|
+
const invalidate = () => queryClient.invalidateQueries({ queryKey: DM_QUERY_KEY });
|
|
4952
|
+
useArbiWsMessage("chat.message", () => void invalidate());
|
|
4953
|
+
useArbiWsMessage("chat.read", () => void invalidate());
|
|
4954
|
+
useArbiWsMessage("chat.updated", () => void invalidate());
|
|
4932
4955
|
let myExtId = null;
|
|
4933
4956
|
try {
|
|
4934
4957
|
myExtId = arbi.user.identity()?.externalId ?? null;
|
|
@@ -4937,33 +4960,56 @@ function useDirectMessages(options) {
|
|
|
4937
4960
|
}
|
|
4938
4961
|
const [pendingSent, setPendingSent] = useState([]);
|
|
4939
4962
|
const serverIds = useMemo(
|
|
4940
|
-
() => new Set((query.data ?? []).map((
|
|
4963
|
+
() => new Set((query.data ?? []).flatMap((c) => c.messages.map((m) => m.external_id))),
|
|
4941
4964
|
[query.data]
|
|
4942
4965
|
);
|
|
4943
4966
|
useEffect(() => {
|
|
4944
4967
|
setPendingSent(
|
|
4945
|
-
(pending) => pending.some((
|
|
4968
|
+
(pending) => pending.some((p) => serverIds.has(p.message.external_id)) ? pending.filter((p) => !serverIds.has(p.message.external_id)) : pending
|
|
4946
4969
|
);
|
|
4947
4970
|
}, [serverIds]);
|
|
4948
4971
|
const conversations = useMemo(() => {
|
|
4949
|
-
const
|
|
4950
|
-
|
|
4972
|
+
const pending = pendingSent.filter((p) => !serverIds.has(p.message.external_id));
|
|
4973
|
+
const pendingMessages = pending.map((p) => p.message);
|
|
4974
|
+
const threads = (query.data ?? []).map((loaded) => toConversation(loaded, myExtId, pendingMessages)).filter((c) => c !== null);
|
|
4975
|
+
const merged = mergeContacts(threads, contactsQuery.data ?? []);
|
|
4976
|
+
return merged.map((c) => {
|
|
4977
|
+
if (c.chatExtId) return c;
|
|
4978
|
+
const mine = pending.filter((p) => p.peerExtId === c.peer.external_id);
|
|
4979
|
+
if (!mine.length) return c;
|
|
4980
|
+
const messages = mine.map(({ message: m }) => ({
|
|
4981
|
+
externalId: m.external_id,
|
|
4982
|
+
body: m.content ?? "",
|
|
4983
|
+
createdAt: m.created_at,
|
|
4984
|
+
isMine: true,
|
|
4985
|
+
read: false,
|
|
4986
|
+
sender: { external_id: myExtId ?? "usr-me" },
|
|
4987
|
+
recipient: c.peer,
|
|
4988
|
+
chatExtId: m.chat_ext_id
|
|
4989
|
+
})).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
4990
|
+
return {
|
|
4991
|
+
...c,
|
|
4992
|
+
isContactOnly: false,
|
|
4993
|
+
chatExtId: messages[0].chatExtId,
|
|
4994
|
+
messages,
|
|
4995
|
+
lastMessage: messages[messages.length - 1]
|
|
4996
|
+
};
|
|
4997
|
+
});
|
|
4951
4998
|
}, [query.data, serverIds, pendingSent, contactsQuery.data, myExtId]);
|
|
4952
|
-
const
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
invalidate();
|
|
4999
|
+
const absorbSent = (message, peerExtId) => {
|
|
5000
|
+
setPendingSent((pending) => [{ message, peerExtId }, ...pending]);
|
|
5001
|
+
void invalidate();
|
|
4956
5002
|
};
|
|
4957
5003
|
const sendMutation = useMutation({
|
|
4958
|
-
mutationFn: (vars) => arbi.dm.sendTo(vars.recipientExtId, vars.
|
|
4959
|
-
onSuccess: absorbSent
|
|
5004
|
+
mutationFn: (vars) => arbi.dm.sendTo(vars.recipientExtId, vars.text),
|
|
5005
|
+
onSuccess: (message, vars) => absorbSent(message, vars.recipientExtId)
|
|
4960
5006
|
});
|
|
4961
5007
|
const sendToMutation = useMutation({
|
|
4962
5008
|
mutationFn: (vars) => arbi.dm.send(vars.recipient, vars.text),
|
|
4963
|
-
onSuccess: absorbSent
|
|
5009
|
+
onSuccess: (message, vars) => absorbSent(message, vars.recipient.includes("@") ? void 0 : vars.recipient)
|
|
4964
5010
|
});
|
|
4965
5011
|
const markReadMutation = useMutation({
|
|
4966
|
-
mutationFn: (
|
|
5012
|
+
mutationFn: (vars) => arbi.chats.markRead(vars.chatExtId, vars.messageExtId),
|
|
4967
5013
|
onSuccess: invalidate
|
|
4968
5014
|
});
|
|
4969
5015
|
return {
|
|
@@ -4972,12 +5018,12 @@ function useDirectMessages(options) {
|
|
|
4972
5018
|
isLoading: (query.isLoading || contactsQuery.isLoading) && enabled,
|
|
4973
5019
|
isError: query.isError,
|
|
4974
5020
|
error: query.error,
|
|
4975
|
-
refetch: () => query.refetch(),
|
|
4976
|
-
sendMessage: (recipientExtId,
|
|
5021
|
+
refetch: () => void query.refetch(),
|
|
5022
|
+
sendMessage: (recipientExtId, _recipientPublicKey, text) => sendMutation.mutateAsync({ recipientExtId, text }),
|
|
4977
5023
|
sendMessageTo: (recipient, text) => sendToMutation.mutateAsync({ recipient, text }),
|
|
4978
5024
|
isSending: sendMutation.isPending || sendToMutation.isPending,
|
|
4979
5025
|
sendError: sendMutation.error ?? sendToMutation.error,
|
|
4980
|
-
markRead: (
|
|
5026
|
+
markRead: (chatExtId, messageExtId) => markReadMutation.mutateAsync({ chatExtId, messageExtId })
|
|
4981
5027
|
};
|
|
4982
5028
|
}
|
|
4983
5029
|
function DmAvatar({ user, className, size = "lg" }) {
|
|
@@ -5030,8 +5076,9 @@ function ConversationList({
|
|
|
5030
5076
|
lead,
|
|
5031
5077
|
/* @__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, i) => {
|
|
5032
5078
|
const { peer, lastMessage, unreadCount } = c;
|
|
5079
|
+
const rowId = c.id ?? peer.external_id;
|
|
5033
5080
|
const newSection = c.sectionLabel && c.sectionLabel !== conversations[i - 1]?.sectionLabel;
|
|
5034
|
-
const active =
|
|
5081
|
+
const active = rowId === selectedPeerId;
|
|
5035
5082
|
const preview = lastMessage?.body ?? "No messages yet \u2014 say hello";
|
|
5036
5083
|
const unread = unreadCount > 0;
|
|
5037
5084
|
const body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -5046,7 +5093,7 @@ function ConversationList({
|
|
|
5046
5093
|
"truncate text-sm text-foreground",
|
|
5047
5094
|
unread ? "font-bold" : "font-semibold"
|
|
5048
5095
|
),
|
|
5049
|
-
children: userDisplayName(peer)
|
|
5096
|
+
children: c.title ?? userDisplayName(peer)
|
|
5050
5097
|
}
|
|
5051
5098
|
),
|
|
5052
5099
|
c.badge ?? (isAgentUser(peer) ? /* @__PURE__ */ jsx(AgentBadge, {}) : null)
|
|
@@ -5119,27 +5166,20 @@ function ConversationList({
|
|
|
5119
5166
|
children: c.sectionLabel
|
|
5120
5167
|
}
|
|
5121
5168
|
),
|
|
5122
|
-
c.disabled ? /* @__PURE__ */ jsxs(
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
className: rowClass,
|
|
5127
|
-
children: [
|
|
5128
|
-
body,
|
|
5129
|
-
c.trailing
|
|
5130
|
-
]
|
|
5131
|
-
}
|
|
5132
|
-
) : /* @__PURE__ */ jsx(
|
|
5169
|
+
c.disabled ? /* @__PURE__ */ jsxs("div", { "data-testid": `arbi-dm-conversation-${rowId}`, className: rowClass, children: [
|
|
5170
|
+
body,
|
|
5171
|
+
c.trailing
|
|
5172
|
+
] }) : /* @__PURE__ */ jsx(
|
|
5133
5173
|
"button",
|
|
5134
5174
|
{
|
|
5135
5175
|
type: "button",
|
|
5136
|
-
onClick: () => onSelect(
|
|
5137
|
-
"data-testid": `arbi-dm-conversation-${
|
|
5176
|
+
onClick: () => onSelect(rowId),
|
|
5177
|
+
"data-testid": `arbi-dm-conversation-${rowId}`,
|
|
5138
5178
|
className: rowClass,
|
|
5139
5179
|
children: body
|
|
5140
5180
|
}
|
|
5141
5181
|
)
|
|
5142
|
-
] },
|
|
5182
|
+
] }, rowId);
|
|
5143
5183
|
}) }) })
|
|
5144
5184
|
]
|
|
5145
5185
|
}
|
|
@@ -5213,7 +5253,7 @@ function MessageThread({
|
|
|
5213
5253
|
);
|
|
5214
5254
|
useEffect(() => {
|
|
5215
5255
|
bottomRef.current?.scrollIntoView({ block: "end" });
|
|
5216
|
-
}, [conversation?.peer.external_id, conversation?.messages.length]);
|
|
5256
|
+
}, [conversation?.id, conversation?.peer.external_id, conversation?.messages.length]);
|
|
5217
5257
|
if (!conversation) {
|
|
5218
5258
|
return /* @__PURE__ */ jsx("section", { className: "flex min-h-0 flex-1 flex-col items-center justify-center gap-3 p-8 text-center", children: emptyState ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5219
5259
|
/* @__PURE__ */ jsx("div", { className: "flex size-14 items-center justify-center rounded-full bg-accent", children: /* @__PURE__ */ jsx(MessagesSquare, { className: "size-6 text-muted-foreground" }) }),
|
|
@@ -5223,13 +5263,13 @@ function MessageThread({
|
|
|
5223
5263
|
] })
|
|
5224
5264
|
] }) });
|
|
5225
5265
|
}
|
|
5226
|
-
const { peer } = conversation;
|
|
5266
|
+
const { peer, title, memberCount } = conversation;
|
|
5227
5267
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5228
5268
|
/* @__PURE__ */ jsxs("header", { className: "flex items-center gap-3 border-b border-border px-4 py-3", children: [
|
|
5229
5269
|
/* @__PURE__ */ jsx(DmAvatar, { user: peer, className: "size-9" }),
|
|
5230
5270
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
5231
|
-
/* @__PURE__ */ jsx("p", { className: "truncate text-sm font-semibold text-foreground", children: userDisplayName(peer) }),
|
|
5232
|
-
/* @__PURE__ */ jsx("p", { className: "truncate text-xs text-muted-foreground", children: peer.email })
|
|
5271
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-sm font-semibold text-foreground", children: title ?? userDisplayName(peer) }),
|
|
5272
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-xs text-muted-foreground", children: memberCount != null ? `${memberCount} members` : peer.email })
|
|
5233
5273
|
] })
|
|
5234
5274
|
] }),
|
|
5235
5275
|
/* @__PURE__ */ jsx(ScrollArea, { className: "min-h-0 flex-1 bg-background", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col px-4 py-4", "data-testid": "arbi-dm-thread", children: [
|
|
@@ -5270,7 +5310,7 @@ function DmComposer({
|
|
|
5270
5310
|
if (!allowAttachments || added.length === 0) return;
|
|
5271
5311
|
const next = [...files, ...added];
|
|
5272
5312
|
try {
|
|
5273
|
-
|
|
5313
|
+
chats.checkChatAttachmentLimits(next);
|
|
5274
5314
|
setFiles(next);
|
|
5275
5315
|
setAttachError(null);
|
|
5276
5316
|
} catch (err) {
|
|
@@ -5560,31 +5600,35 @@ function DirectMessages({
|
|
|
5560
5600
|
markRead
|
|
5561
5601
|
} = useDirectMessages();
|
|
5562
5602
|
const [selectedPeerId, setSelectedPeerId] = useState(null);
|
|
5603
|
+
const [startedChatId, setStartedChatId] = useState(null);
|
|
5563
5604
|
const conversations = useMemo(
|
|
5564
5605
|
() => hideOwnContact && myExtId ? allConversations.filter((c) => c.peer.external_id !== myExtId) : allConversations,
|
|
5565
5606
|
[allConversations, hideOwnContact, myExtId]
|
|
5566
5607
|
);
|
|
5567
5608
|
const openStarted = (created) => {
|
|
5568
|
-
const
|
|
5569
|
-
if (
|
|
5609
|
+
const chatId = created?.chat_ext_id;
|
|
5610
|
+
if (chatId) setStartedChatId(chatId);
|
|
5570
5611
|
};
|
|
5612
|
+
useEffect(() => {
|
|
5613
|
+
if (!startedChatId) return;
|
|
5614
|
+
const started = conversations.find((c) => c.chatExtId === startedChatId);
|
|
5615
|
+
if (started) {
|
|
5616
|
+
setSelectedPeerId(started.id ?? started.peer.external_id);
|
|
5617
|
+
setStartedChatId(null);
|
|
5618
|
+
}
|
|
5619
|
+
}, [conversations, startedChatId]);
|
|
5571
5620
|
const loadError = isError ? error instanceof Error ? error.message : "Couldn\u2019t load messages." : null;
|
|
5572
5621
|
const selected = useMemo(
|
|
5573
|
-
() => conversations.find((c) => c.peer.external_id === selectedPeerId) ?? null,
|
|
5622
|
+
() => conversations.find((c) => (c.id ?? c.peer.external_id) === selectedPeerId) ?? null,
|
|
5574
5623
|
[conversations, selectedPeerId]
|
|
5575
5624
|
);
|
|
5576
5625
|
useEffect(() => {
|
|
5577
|
-
if (!selected || selected.unreadCount === 0) return;
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
}, [selected?.peer.external_id, selected?.unreadCount]);
|
|
5626
|
+
if (!selected?.chatExtId || selected.unreadCount === 0) return;
|
|
5627
|
+
void markRead(selected.chatExtId);
|
|
5628
|
+
}, [selected?.chatExtId, selected?.unreadCount]);
|
|
5581
5629
|
const handleSend = async (text) => {
|
|
5582
5630
|
if (!selected) return;
|
|
5583
|
-
|
|
5584
|
-
await sendMessage(selected.peer.external_id, selected.peer.encryption_public_key, text);
|
|
5585
|
-
} else {
|
|
5586
|
-
await sendMessageTo(selected.peer.external_id, text);
|
|
5587
|
-
}
|
|
5631
|
+
await sendMessage(selected.peer.external_id, selected.peer.encryption_public_key, text);
|
|
5588
5632
|
};
|
|
5589
5633
|
return /* @__PURE__ */ jsxs(
|
|
5590
5634
|
"div",
|
|
@@ -5608,7 +5652,7 @@ function DirectMessages({
|
|
|
5608
5652
|
ConversationList,
|
|
5609
5653
|
{
|
|
5610
5654
|
conversations,
|
|
5611
|
-
selectedPeerId: selected
|
|
5655
|
+
selectedPeerId: selected ? selected.id ?? selected.peer.external_id : null,
|
|
5612
5656
|
onSelect: setSelectedPeerId,
|
|
5613
5657
|
classNames,
|
|
5614
5658
|
emptyState: isLoading ? "Loading messages\u2026" : emptyList,
|
|
@@ -5632,7 +5676,7 @@ function DirectMessages({
|
|
|
5632
5676
|
selected ? /* @__PURE__ */ jsx(
|
|
5633
5677
|
DmComposer,
|
|
5634
5678
|
{
|
|
5635
|
-
placeholder: `Message ${userDisplayName(selected.peer).split(" ")[0]}\u2026`,
|
|
5679
|
+
placeholder: `Message ${(selected.title ?? userDisplayName(selected.peer)).split(" ")[0]}\u2026`,
|
|
5636
5680
|
onSend: handleSend,
|
|
5637
5681
|
error: sendError?.message ?? null,
|
|
5638
5682
|
classNames
|
|
@@ -7043,6 +7087,6 @@ function hasVideoTrack(blob) {
|
|
|
7043
7087
|
});
|
|
7044
7088
|
}
|
|
7045
7089
|
|
|
7046
|
-
export { ActivityFeed, AiActionCard, AiAnswer, AppleIcon, ArbiBotIcon, ArbiIcon, ArbiWebSocketProvider, ArtifactCanvas, 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, DraftTitleControls, 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, SemanticSearch, StartByEmail, TypingIndicator, VideoCapture, VoiceNoteRecorder, accountPath, aliasTakenMessage, annotateThread, announceMailDraftReplaced, arbiMailClient, captureFrameAsBlob, createMailClient, cropImage, dayKey, defaultMailAlias, describeActivity, fileAttachment, formatIdentityPrice, getNotificationTypeMeta, getWorkspaceActionText, getWorkspaceKind, getWorkspaceSentPhrase, hasVideoTrack, identityStepFor, invalidateTagData, isAliasTakenError, isWorkspaceNotificationType, mailDraftIdFromContent, mailJson, mailQueryKeys, mountDiditVerification, nextAliasSuggestion, parseActivityContent, parseDeleteAccountBlockers, pickRecentWorkspaces, redlineStats, resolveActiveWorkspace, textToArtifact, titleFromQuestion, toChatCitations, toNotificationPreferences, toProfileView, toRedlineMarkdown, toShellWorkspace, useActOnStep,
|
|
7090
|
+
export { ActivityFeed, AiActionCard, AiAnswer, AppleIcon, ArbiBotIcon, ArbiIcon, ArbiWebSocketProvider, ArtifactCanvas, 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, DraftTitleControls, 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, SemanticSearch, StartByEmail, TypingIndicator, VideoCapture, VoiceNoteRecorder, accountPath, aliasTakenMessage, annotateThread, announceMailDraftReplaced, arbiMailClient, captureFrameAsBlob, createMailClient, cropImage, dayKey, defaultMailAlias, describeActivity, fileAttachment, formatIdentityPrice, getNotificationTypeMeta, getWorkspaceActionText, getWorkspaceKind, getWorkspaceSentPhrase, hasVideoTrack, identityStepFor, invalidateTagData, isAliasTakenError, isWorkspaceNotificationType, mailDraftIdFromContent, mailJson, mailQueryKeys, mountDiditVerification, nextAliasSuggestion, parseActivityContent, parseDeleteAccountBlockers, pickRecentWorkspaces, redlineStats, resolveActiveWorkspace, textToArtifact, titleFromQuestion, toChatCitations, toNotificationPreferences, toProfileView, toRedlineMarkdown, toShellWorkspace, useActOnStep, useAgentChats, useAgentConfig, useAgentModels, useAgentSession, useAgentWorkspaces, useAiTask, useArbiChat, useArbiConnected, useArbiDocumentSync, useArbiShellWorkspaces, useArbiUiStore, useArbiWebSocket, useArbiWsContext, useArbiWsMessage, useArbiWsStatus, useArbiWsStore, useArbiWsTask, useArbiWsTasks, useAvatarCrop, useCameraStream, useClaimNativeAlias, useCloseAgentSession, useCommandPalette, useConfirmEmailChange, useConnectMailAccount, useContacts, useConversationActivity, useConversationPendingAuth, useConversationUsage, useCreateAgent, useCreateContact, useCreateWork, useCreateWorkflow, useCurrentSessionId, useDeleteAccount, useDeleteAccountFlow, useDeleteContact, useDeleteWorkflow, useDirectMessages, useDisconnectMailAccount, useEmailChange, useFilteredProjects, useFollowThread, useGrantAgentAccess, useIdentityVerification, useIdentityVerificationFlow, useInvalidateTagData, useInviteContacts, useLogoutAllSessions, useMailAccounts, useMailCache, useMailClient, useMailDraftCompose, useMailDraftEditor, useMailDraftReplaced, useMailFolders, useMailMessage, useMailMessages, useMailOnline, useMailPolicy, useMailProjects, useMailUnlock, useNameEditor, useNotificationPreferences, usePasswordChange, usePasswordChangeForm, usePendingContacts, usePlanWork, useProfile, useProjectConversationUsage, useProjectEvents, useRequestEmailChange, useRevokeAgentAccess, useRunConversation, useRunWorkflow, useSaveAgentConfig, useSaveMailDraft, useSemanticSearch, useSendBackStep, useSendMail, useSetTagValues, useShellWorkspaces, useSkills, useStartAgentSession, useStartWorkQuery, useTagKindSchema, useTerminateSession, useUpdateContact, useUpdateConversation, useUpdateMailMessage, useUpdateProfile, useUpdateProjectFields, useUpdateTagKindSchema, useUpdateWorkflow, useUploadSkillFiles, useUserSettings, useVideoRecorder, useWorkNotifications, useWorkflows, useWorkspaceDocs, useWorkspaceNotificationLevel, userDisplayName, userInitials, workflowStepOf };
|
|
7047
7091
|
//# sourceMappingURL=index.js.map
|
|
7048
7092
|
//# sourceMappingURL=index.js.map
|