@arbidocs/react 0.4.109 → 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 +13 -13
- package/dist/artifacts/index.js +2 -2
- package/dist/{chunk-P4A5EG5B.js → chunk-5L46Z7HZ.js} +443 -36
- package/dist/chunk-5L46Z7HZ.js.map +1 -0
- package/dist/{chunk-EEW2SH76.cjs → chunk-XD4P4KRH.cjs} +451 -35
- package/dist/chunk-XD4P4KRH.cjs.map +1 -0
- package/dist/index.cjs +371 -292
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +476 -459
- package/dist/index.d.ts +476 -459
- package/dist/index.js +149 -108
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +130 -130
- package/dist/ui/index.js +2 -2
- package/package.json +3 -3
- package/dist/chunk-EEW2SH76.cjs.map +0 -1
- package/dist/chunk-P4A5EG5B.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -3,12 +3,12 @@ export { PROJECT_CREATION_DENIED_REASON, arbiQueryKeys, isUsageMetered, useActiv
|
|
|
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-
|
|
8
|
-
import { Button, Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from './chunk-YNNAJJ5Z.js';
|
|
9
|
-
export { Button, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, buttonVariants } from './chunk-YNNAJJ5Z.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-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';
|
|
10
8
|
import { MarkdownRenderer } from './chunk-EKRRORFO.js';
|
|
11
9
|
export { MarkdownRenderer, MarkdownStreamingContext, markdownBaseComponents, splitMarkdownBlocks } from './chunk-EKRRORFO.js';
|
|
10
|
+
import { Button, Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from './chunk-YNNAJJ5Z.js';
|
|
11
|
+
export { Button, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, buttonVariants } from './chunk-YNNAJJ5Z.js';
|
|
12
12
|
import { normalizeCitationMarkup } from './chunk-QRCMKEE6.js';
|
|
13
13
|
export { closeOpenEmphasis, normalizeCitationMarkup, trimOpenCitation } from './chunk-QRCMKEE6.js';
|
|
14
14
|
import { ScrollArea } from './chunk-W4H6XAIU.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) {
|
|
@@ -4617,8 +4635,6 @@ function getNotificationTypeMeta(type) {
|
|
|
4617
4635
|
switch (type) {
|
|
4618
4636
|
case "agent_input_requested":
|
|
4619
4637
|
return { Icon: MessageCircleMore, iconClassName: "text-primary", label: "Input needed" };
|
|
4620
|
-
case "user_message":
|
|
4621
|
-
return { Icon: MessageCircleMore, iconClassName: "text-primary", label: "Message" };
|
|
4622
4638
|
case "workspaceuser_added_owner":
|
|
4623
4639
|
case "workspaceuser_added_collaborator":
|
|
4624
4640
|
case "workspaceuser_added_guest":
|
|
@@ -4860,6 +4876,7 @@ function isAgentUser(user) {
|
|
|
4860
4876
|
return user.external_id.startsWith("agt-");
|
|
4861
4877
|
}
|
|
4862
4878
|
var DM_QUERY_KEY = ["arbi", "directMessages"];
|
|
4879
|
+
var THREAD_LIMIT = 100;
|
|
4863
4880
|
function mergeContacts(threads, contacts) {
|
|
4864
4881
|
const byPeer = /* @__PURE__ */ new Map();
|
|
4865
4882
|
for (const t of threads) byPeer.set(t.peer.external_id, t);
|
|
@@ -4877,43 +4894,42 @@ function mergeContacts(threads, contacts) {
|
|
|
4877
4894
|
return userDisplayName(a.peer).localeCompare(userDisplayName(b.peer));
|
|
4878
4895
|
});
|
|
4879
4896
|
}
|
|
4880
|
-
function
|
|
4881
|
-
const
|
|
4882
|
-
const
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
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,
|
|
4893
4916
|
isMine,
|
|
4894
|
-
read:
|
|
4895
|
-
|
|
4896
|
-
|
|
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
|
|
4897
4922
|
};
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
conversations.push({
|
|
4909
|
-
peer: peers.get(peerId),
|
|
4910
|
-
messages,
|
|
4911
|
-
lastMessage: messages[messages.length - 1],
|
|
4912
|
-
unreadCount
|
|
4913
|
-
});
|
|
4914
|
-
}
|
|
4915
|
-
conversations.sort((a, b) => b.lastMessage.createdAt.localeCompare(a.lastMessage.createdAt));
|
|
4916
|
-
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
|
+
};
|
|
4917
4933
|
}
|
|
4918
4934
|
function useDirectMessages(options) {
|
|
4919
4935
|
const arbi = useArbi();
|
|
@@ -4921,7 +4937,10 @@ function useDirectMessages(options) {
|
|
|
4921
4937
|
const enabled = options?.enabled ?? arbi.isLoggedIn;
|
|
4922
4938
|
const query = useQuery({
|
|
4923
4939
|
queryKey: DM_QUERY_KEY,
|
|
4924
|
-
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
|
+
},
|
|
4925
4944
|
enabled
|
|
4926
4945
|
});
|
|
4927
4946
|
const contactsQuery = useQuery({
|
|
@@ -4929,9 +4948,10 @@ function useDirectMessages(options) {
|
|
|
4929
4948
|
queryFn: () => arbi.contacts.list(),
|
|
4930
4949
|
enabled
|
|
4931
4950
|
});
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
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());
|
|
4935
4955
|
let myExtId = null;
|
|
4936
4956
|
try {
|
|
4937
4957
|
myExtId = arbi.user.identity()?.externalId ?? null;
|
|
@@ -4940,33 +4960,56 @@ function useDirectMessages(options) {
|
|
|
4940
4960
|
}
|
|
4941
4961
|
const [pendingSent, setPendingSent] = useState([]);
|
|
4942
4962
|
const serverIds = useMemo(
|
|
4943
|
-
() => new Set((query.data ?? []).map((
|
|
4963
|
+
() => new Set((query.data ?? []).flatMap((c) => c.messages.map((m) => m.external_id))),
|
|
4944
4964
|
[query.data]
|
|
4945
4965
|
);
|
|
4946
4966
|
useEffect(() => {
|
|
4947
4967
|
setPendingSent(
|
|
4948
|
-
(pending) => pending.some((
|
|
4968
|
+
(pending) => pending.some((p) => serverIds.has(p.message.external_id)) ? pending.filter((p) => !serverIds.has(p.message.external_id)) : pending
|
|
4949
4969
|
);
|
|
4950
4970
|
}, [serverIds]);
|
|
4951
4971
|
const conversations = useMemo(() => {
|
|
4952
|
-
const
|
|
4953
|
-
|
|
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
|
+
});
|
|
4954
4998
|
}, [query.data, serverIds, pendingSent, contactsQuery.data, myExtId]);
|
|
4955
|
-
const
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
invalidate();
|
|
4999
|
+
const absorbSent = (message, peerExtId) => {
|
|
5000
|
+
setPendingSent((pending) => [{ message, peerExtId }, ...pending]);
|
|
5001
|
+
void invalidate();
|
|
4959
5002
|
};
|
|
4960
5003
|
const sendMutation = useMutation({
|
|
4961
|
-
mutationFn: (vars) => arbi.dm.sendTo(vars.recipientExtId, vars.
|
|
4962
|
-
onSuccess: absorbSent
|
|
5004
|
+
mutationFn: (vars) => arbi.dm.sendTo(vars.recipientExtId, vars.text),
|
|
5005
|
+
onSuccess: (message, vars) => absorbSent(message, vars.recipientExtId)
|
|
4963
5006
|
});
|
|
4964
5007
|
const sendToMutation = useMutation({
|
|
4965
5008
|
mutationFn: (vars) => arbi.dm.send(vars.recipient, vars.text),
|
|
4966
|
-
onSuccess: absorbSent
|
|
5009
|
+
onSuccess: (message, vars) => absorbSent(message, vars.recipient.includes("@") ? void 0 : vars.recipient)
|
|
4967
5010
|
});
|
|
4968
5011
|
const markReadMutation = useMutation({
|
|
4969
|
-
mutationFn: (
|
|
5012
|
+
mutationFn: (vars) => arbi.chats.markRead(vars.chatExtId, vars.messageExtId),
|
|
4970
5013
|
onSuccess: invalidate
|
|
4971
5014
|
});
|
|
4972
5015
|
return {
|
|
@@ -4975,12 +5018,12 @@ function useDirectMessages(options) {
|
|
|
4975
5018
|
isLoading: (query.isLoading || contactsQuery.isLoading) && enabled,
|
|
4976
5019
|
isError: query.isError,
|
|
4977
5020
|
error: query.error,
|
|
4978
|
-
refetch: () => query.refetch(),
|
|
4979
|
-
sendMessage: (recipientExtId,
|
|
5021
|
+
refetch: () => void query.refetch(),
|
|
5022
|
+
sendMessage: (recipientExtId, _recipientPublicKey, text) => sendMutation.mutateAsync({ recipientExtId, text }),
|
|
4980
5023
|
sendMessageTo: (recipient, text) => sendToMutation.mutateAsync({ recipient, text }),
|
|
4981
5024
|
isSending: sendMutation.isPending || sendToMutation.isPending,
|
|
4982
5025
|
sendError: sendMutation.error ?? sendToMutation.error,
|
|
4983
|
-
markRead: (
|
|
5026
|
+
markRead: (chatExtId, messageExtId) => markReadMutation.mutateAsync({ chatExtId, messageExtId })
|
|
4984
5027
|
};
|
|
4985
5028
|
}
|
|
4986
5029
|
function DmAvatar({ user, className, size = "lg" }) {
|
|
@@ -5033,8 +5076,9 @@ function ConversationList({
|
|
|
5033
5076
|
lead,
|
|
5034
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) => {
|
|
5035
5078
|
const { peer, lastMessage, unreadCount } = c;
|
|
5079
|
+
const rowId = c.id ?? peer.external_id;
|
|
5036
5080
|
const newSection = c.sectionLabel && c.sectionLabel !== conversations[i - 1]?.sectionLabel;
|
|
5037
|
-
const active =
|
|
5081
|
+
const active = rowId === selectedPeerId;
|
|
5038
5082
|
const preview = lastMessage?.body ?? "No messages yet \u2014 say hello";
|
|
5039
5083
|
const unread = unreadCount > 0;
|
|
5040
5084
|
const body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -5049,7 +5093,7 @@ function ConversationList({
|
|
|
5049
5093
|
"truncate text-sm text-foreground",
|
|
5050
5094
|
unread ? "font-bold" : "font-semibold"
|
|
5051
5095
|
),
|
|
5052
|
-
children: userDisplayName(peer)
|
|
5096
|
+
children: c.title ?? userDisplayName(peer)
|
|
5053
5097
|
}
|
|
5054
5098
|
),
|
|
5055
5099
|
c.badge ?? (isAgentUser(peer) ? /* @__PURE__ */ jsx(AgentBadge, {}) : null)
|
|
@@ -5122,27 +5166,20 @@ function ConversationList({
|
|
|
5122
5166
|
children: c.sectionLabel
|
|
5123
5167
|
}
|
|
5124
5168
|
),
|
|
5125
|
-
c.disabled ? /* @__PURE__ */ jsxs(
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
className: rowClass,
|
|
5130
|
-
children: [
|
|
5131
|
-
body,
|
|
5132
|
-
c.trailing
|
|
5133
|
-
]
|
|
5134
|
-
}
|
|
5135
|
-
) : /* @__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(
|
|
5136
5173
|
"button",
|
|
5137
5174
|
{
|
|
5138
5175
|
type: "button",
|
|
5139
|
-
onClick: () => onSelect(
|
|
5140
|
-
"data-testid": `arbi-dm-conversation-${
|
|
5176
|
+
onClick: () => onSelect(rowId),
|
|
5177
|
+
"data-testid": `arbi-dm-conversation-${rowId}`,
|
|
5141
5178
|
className: rowClass,
|
|
5142
5179
|
children: body
|
|
5143
5180
|
}
|
|
5144
5181
|
)
|
|
5145
|
-
] },
|
|
5182
|
+
] }, rowId);
|
|
5146
5183
|
}) }) })
|
|
5147
5184
|
]
|
|
5148
5185
|
}
|
|
@@ -5216,7 +5253,7 @@ function MessageThread({
|
|
|
5216
5253
|
);
|
|
5217
5254
|
useEffect(() => {
|
|
5218
5255
|
bottomRef.current?.scrollIntoView({ block: "end" });
|
|
5219
|
-
}, [conversation?.peer.external_id, conversation?.messages.length]);
|
|
5256
|
+
}, [conversation?.id, conversation?.peer.external_id, conversation?.messages.length]);
|
|
5220
5257
|
if (!conversation) {
|
|
5221
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: [
|
|
5222
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" }) }),
|
|
@@ -5226,13 +5263,13 @@ function MessageThread({
|
|
|
5226
5263
|
] })
|
|
5227
5264
|
] }) });
|
|
5228
5265
|
}
|
|
5229
|
-
const { peer } = conversation;
|
|
5266
|
+
const { peer, title, memberCount } = conversation;
|
|
5230
5267
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5231
5268
|
/* @__PURE__ */ jsxs("header", { className: "flex items-center gap-3 border-b border-border px-4 py-3", children: [
|
|
5232
5269
|
/* @__PURE__ */ jsx(DmAvatar, { user: peer, className: "size-9" }),
|
|
5233
5270
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
5234
|
-
/* @__PURE__ */ jsx("p", { className: "truncate text-sm font-semibold text-foreground", children: userDisplayName(peer) }),
|
|
5235
|
-
/* @__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 })
|
|
5236
5273
|
] })
|
|
5237
5274
|
] }),
|
|
5238
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: [
|
|
@@ -5273,7 +5310,7 @@ function DmComposer({
|
|
|
5273
5310
|
if (!allowAttachments || added.length === 0) return;
|
|
5274
5311
|
const next = [...files, ...added];
|
|
5275
5312
|
try {
|
|
5276
|
-
|
|
5313
|
+
chats.checkChatAttachmentLimits(next);
|
|
5277
5314
|
setFiles(next);
|
|
5278
5315
|
setAttachError(null);
|
|
5279
5316
|
} catch (err) {
|
|
@@ -5563,31 +5600,35 @@ function DirectMessages({
|
|
|
5563
5600
|
markRead
|
|
5564
5601
|
} = useDirectMessages();
|
|
5565
5602
|
const [selectedPeerId, setSelectedPeerId] = useState(null);
|
|
5603
|
+
const [startedChatId, setStartedChatId] = useState(null);
|
|
5566
5604
|
const conversations = useMemo(
|
|
5567
5605
|
() => hideOwnContact && myExtId ? allConversations.filter((c) => c.peer.external_id !== myExtId) : allConversations,
|
|
5568
5606
|
[allConversations, hideOwnContact, myExtId]
|
|
5569
5607
|
);
|
|
5570
5608
|
const openStarted = (created) => {
|
|
5571
|
-
const
|
|
5572
|
-
if (
|
|
5609
|
+
const chatId = created?.chat_ext_id;
|
|
5610
|
+
if (chatId) setStartedChatId(chatId);
|
|
5573
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]);
|
|
5574
5620
|
const loadError = isError ? error instanceof Error ? error.message : "Couldn\u2019t load messages." : null;
|
|
5575
5621
|
const selected = useMemo(
|
|
5576
|
-
() => conversations.find((c) => c.peer.external_id === selectedPeerId) ?? null,
|
|
5622
|
+
() => conversations.find((c) => (c.id ?? c.peer.external_id) === selectedPeerId) ?? null,
|
|
5577
5623
|
[conversations, selectedPeerId]
|
|
5578
5624
|
);
|
|
5579
5625
|
useEffect(() => {
|
|
5580
|
-
if (!selected || selected.unreadCount === 0) return;
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
}, [selected?.peer.external_id, selected?.unreadCount]);
|
|
5626
|
+
if (!selected?.chatExtId || selected.unreadCount === 0) return;
|
|
5627
|
+
void markRead(selected.chatExtId);
|
|
5628
|
+
}, [selected?.chatExtId, selected?.unreadCount]);
|
|
5584
5629
|
const handleSend = async (text) => {
|
|
5585
5630
|
if (!selected) return;
|
|
5586
|
-
|
|
5587
|
-
await sendMessage(selected.peer.external_id, selected.peer.encryption_public_key, text);
|
|
5588
|
-
} else {
|
|
5589
|
-
await sendMessageTo(selected.peer.external_id, text);
|
|
5590
|
-
}
|
|
5631
|
+
await sendMessage(selected.peer.external_id, selected.peer.encryption_public_key, text);
|
|
5591
5632
|
};
|
|
5592
5633
|
return /* @__PURE__ */ jsxs(
|
|
5593
5634
|
"div",
|
|
@@ -5611,7 +5652,7 @@ function DirectMessages({
|
|
|
5611
5652
|
ConversationList,
|
|
5612
5653
|
{
|
|
5613
5654
|
conversations,
|
|
5614
|
-
selectedPeerId: selected
|
|
5655
|
+
selectedPeerId: selected ? selected.id ?? selected.peer.external_id : null,
|
|
5615
5656
|
onSelect: setSelectedPeerId,
|
|
5616
5657
|
classNames,
|
|
5617
5658
|
emptyState: isLoading ? "Loading messages\u2026" : emptyList,
|
|
@@ -5635,7 +5676,7 @@ function DirectMessages({
|
|
|
5635
5676
|
selected ? /* @__PURE__ */ jsx(
|
|
5636
5677
|
DmComposer,
|
|
5637
5678
|
{
|
|
5638
|
-
placeholder: `Message ${userDisplayName(selected.peer).split(" ")[0]}\u2026`,
|
|
5679
|
+
placeholder: `Message ${(selected.title ?? userDisplayName(selected.peer)).split(" ")[0]}\u2026`,
|
|
5639
5680
|
onSend: handleSend,
|
|
5640
5681
|
error: sendError?.message ?? null,
|
|
5641
5682
|
classNames
|
|
@@ -7046,6 +7087,6 @@ function hasVideoTrack(blob) {
|
|
|
7046
7087
|
});
|
|
7047
7088
|
}
|
|
7048
7089
|
|
|
7049
|
-
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 };
|
|
7050
7091
|
//# sourceMappingURL=index.js.map
|
|
7051
7092
|
//# sourceMappingURL=index.js.map
|