@arbidocs/react 0.3.148 → 0.3.149
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/index.cjs +255 -113
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +121 -5
- package/dist/index.d.ts +121 -5
- package/dist/index.js +246 -108
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { cn, Avatar, AvatarFallback, AvatarImage, Tooltip, TooltipTrigger, TooltipContent, Popover, PopoverTrigger, PopoverContent, AiMarkdown, Card, Button, Badge, MarkdownRenderer, Input, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, ScrollArea, Textarea, Slider, Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuItem, Checkbox } from './chunk-VTX77MYP.js';
|
|
2
|
-
export { AiMarkdown, Avatar, AvatarFallback, AvatarImage, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, HoverCard, HoverCardContent, HoverCardTrigger, Input, Label, MarkdownRenderer, MarkdownStreamingContext, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Slider, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonVariants, cardVariants, cn, markdownBaseComponents, splitMarkdownBlocks, toggleVariants } from './chunk-VTX77MYP.js';
|
|
3
1
|
import { useArbi, ArbiProvider } from './chunk-J4MX2W4H.js';
|
|
4
2
|
export { ArbiProvider, useArbi } from './chunk-J4MX2W4H.js';
|
|
5
|
-
import
|
|
3
|
+
import { cn, Avatar, AvatarFallback, AvatarImage, Tooltip, TooltipTrigger, TooltipContent, Popover, PopoverTrigger, PopoverContent, AiMarkdown, Card, Button, Badge, MarkdownRenderer, Input, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, ScrollArea, Textarea, Slider, Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuItem, Checkbox } from './chunk-VTX77MYP.js';
|
|
4
|
+
export { AiMarkdown, Avatar, AvatarFallback, AvatarImage, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, HoverCard, HoverCardContent, HoverCardTrigger, Input, Label, MarkdownRenderer, MarkdownStreamingContext, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Slider, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonVariants, cardVariants, cn, markdownBaseComponents, splitMarkdownBlocks, toggleVariants } from './chunk-VTX77MYP.js';
|
|
5
|
+
import React2, { memo, useState, createContext, forwardRef, useMemo, useCallback, useId, useRef, useContext, useEffect, Fragment as Fragment$1 } from 'react';
|
|
6
6
|
import { useQuery, useMutation, useQueries, QueryClient, QueryClientProvider, useQueryClient } from '@tanstack/react-query';
|
|
7
7
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
8
|
import { connectWithReconnect, resolveCitations, summarizeCitations } from '@arbidocs/sdk/browser';
|
|
@@ -1333,7 +1333,7 @@ function ArbiChat({
|
|
|
1333
1333
|
) }) });
|
|
1334
1334
|
}
|
|
1335
1335
|
var TypingIndicator = memo(function TypingIndicator2() {
|
|
1336
|
-
return /* @__PURE__ */ jsx("div", { className: "flex w-full justify-start mb-2", children: /* @__PURE__ */ jsx("div", { className: "bg-card border border-primary rounded-2xl rounded-bl-md px-4 py-2.5", children: /* @__PURE__ */ jsxs("div", { className: "flex gap-1 items-center", children: [
|
|
1336
|
+
return /* @__PURE__ */ jsx("div", { className: "flex w-full justify-start mb-2", "data-testid": "dm-typing-indicator", children: /* @__PURE__ */ jsx("div", { className: "bg-card border border-primary rounded-2xl rounded-bl-md px-4 py-2.5", children: /* @__PURE__ */ jsxs("div", { className: "flex gap-1 items-center", children: [
|
|
1337
1337
|
/* @__PURE__ */ jsx("span", { className: "w-1.5 h-1.5 rounded-full bg-muted-foreground animate-bounce [animation-delay:0ms]" }),
|
|
1338
1338
|
/* @__PURE__ */ jsx("span", { className: "w-1.5 h-1.5 rounded-full bg-muted-foreground animate-bounce [animation-delay:150ms]" }),
|
|
1339
1339
|
/* @__PURE__ */ jsx("span", { className: "w-1.5 h-1.5 rounded-full bg-muted-foreground animate-bounce [animation-delay:300ms]" })
|
|
@@ -1347,23 +1347,35 @@ var ChatBubble = memo(function ChatBubble2({
|
|
|
1347
1347
|
read,
|
|
1348
1348
|
onDelete,
|
|
1349
1349
|
isLastOfRun = true,
|
|
1350
|
+
senderName,
|
|
1351
|
+
classNames,
|
|
1350
1352
|
renderMessage = (m) => m,
|
|
1351
|
-
formatTimestamp = (t) => t
|
|
1353
|
+
formatTimestamp = (t) => t,
|
|
1354
|
+
"data-testid": testId
|
|
1352
1355
|
}) {
|
|
1353
1356
|
const [isHovered, setIsHovered] = useState(false);
|
|
1354
1357
|
const [isFocused, setIsFocused] = useState(false);
|
|
1355
1358
|
const showDeleteButton = isHovered || isFocused;
|
|
1356
1359
|
if (deleted) {
|
|
1357
|
-
return /* @__PURE__ */ jsx(
|
|
1360
|
+
return /* @__PURE__ */ jsx(
|
|
1361
|
+
"div",
|
|
1362
|
+
{
|
|
1363
|
+
"data-testid": testId,
|
|
1364
|
+
className: `flex w-full ${isSent ? "justify-end" : "justify-start"} mb-2`,
|
|
1365
|
+
children: /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground italic px-3 py-1", children: "Message deleted" })
|
|
1366
|
+
}
|
|
1367
|
+
);
|
|
1358
1368
|
}
|
|
1359
1369
|
const bubbleRadius = cn(
|
|
1360
1370
|
"rounded-2xl",
|
|
1361
|
-
isSent && isLastOfRun && "rounded-br-
|
|
1362
|
-
!isSent && isLastOfRun && "rounded-bl-
|
|
1371
|
+
isSent && isLastOfRun && "rounded-br-sm",
|
|
1372
|
+
!isSent && isLastOfRun && "rounded-bl-sm"
|
|
1363
1373
|
);
|
|
1374
|
+
const bubbleSurface = isSent ? cn("bg-ai-accent-soft text-foreground chat-bubble-sent", classNames?.ownBubble) : cn("border border-border bg-card text-card-foreground", classNames?.peerBubble);
|
|
1364
1375
|
return /* @__PURE__ */ jsxs(
|
|
1365
1376
|
"div",
|
|
1366
1377
|
{
|
|
1378
|
+
"data-testid": testId,
|
|
1367
1379
|
className: cn(
|
|
1368
1380
|
"flex w-full items-end",
|
|
1369
1381
|
isLastOfRun ? "mb-2" : "mb-0.5",
|
|
@@ -1386,41 +1398,23 @@ var ChatBubble = memo(function ChatBubble2({
|
|
|
1386
1398
|
children: /* @__PURE__ */ jsx(Trash2, { className: "w-3.5 h-3.5" })
|
|
1387
1399
|
}
|
|
1388
1400
|
),
|
|
1389
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col max-w-[80%] md:max-w-[60%]", children: /* @__PURE__ */ jsxs(
|
|
1390
|
-
"div",
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
"
|
|
1401
|
-
{
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
children: [
|
|
1407
|
-
/* @__PURE__ */ jsx(
|
|
1408
|
-
"span",
|
|
1409
|
-
{
|
|
1410
|
-
className: cn(
|
|
1411
|
-
"text-[11px] leading-none",
|
|
1412
|
-
isSent ? "text-primary-foreground/70" : "text-muted-foreground"
|
|
1413
|
-
),
|
|
1414
|
-
children: formatTimestamp(timestamp)
|
|
1415
|
-
}
|
|
1416
|
-
),
|
|
1417
|
-
isSent && (read ? /* @__PURE__ */ jsx(CheckCheck, { className: "w-3.5 h-3.5 text-primary-foreground/80 flex-shrink-0" }) : /* @__PURE__ */ jsx(Check, { className: "w-3.5 h-3.5 text-primary-foreground/60 flex-shrink-0" }))
|
|
1418
|
-
]
|
|
1419
|
-
}
|
|
1420
|
-
)
|
|
1421
|
-
]
|
|
1422
|
-
}
|
|
1423
|
-
) }),
|
|
1401
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col max-w-[80%] md:max-w-[60%]", children: /* @__PURE__ */ jsxs("div", { className: cn("px-3.5 py-2 break-words shadow-sm", bubbleRadius, bubbleSurface), children: [
|
|
1402
|
+
/* @__PURE__ */ jsx("div", { className: "text-sm [&_.markdown-content]:space-y-1.5 [&_pre]:max-w-full [&_pre]:overflow-x-auto", children: renderMessage(message) }),
|
|
1403
|
+
isLastOfRun && /* @__PURE__ */ jsxs(
|
|
1404
|
+
"div",
|
|
1405
|
+
{
|
|
1406
|
+
className: cn(
|
|
1407
|
+
"flex items-center gap-1.5 mt-0.5",
|
|
1408
|
+
isSent ? "justify-end" : "justify-start"
|
|
1409
|
+
),
|
|
1410
|
+
children: [
|
|
1411
|
+
senderName && /* @__PURE__ */ jsx("span", { className: "text-[11px] font-medium leading-none opacity-90", children: senderName }),
|
|
1412
|
+
/* @__PURE__ */ jsx("span", { className: "text-[11px] leading-none opacity-70", children: formatTimestamp(timestamp) }),
|
|
1413
|
+
isSent && (read ? /* @__PURE__ */ jsx(CheckCheck, { className: "w-3.5 h-3.5 flex-shrink-0 opacity-80" }) : /* @__PURE__ */ jsx(Check, { className: "w-3.5 h-3.5 flex-shrink-0 opacity-60" }))
|
|
1414
|
+
]
|
|
1415
|
+
}
|
|
1416
|
+
)
|
|
1417
|
+
] }) }),
|
|
1424
1418
|
!isSent && onDelete && /* @__PURE__ */ jsx(
|
|
1425
1419
|
"button",
|
|
1426
1420
|
{
|
|
@@ -5435,88 +5429,207 @@ function ConversationList({
|
|
|
5435
5429
|
selectedPeerId,
|
|
5436
5430
|
onSelect,
|
|
5437
5431
|
classNames,
|
|
5438
|
-
emptyState
|
|
5432
|
+
emptyState,
|
|
5433
|
+
header,
|
|
5434
|
+
className
|
|
5439
5435
|
}) {
|
|
5440
5436
|
return /* @__PURE__ */ jsxs(
|
|
5441
5437
|
"aside",
|
|
5442
5438
|
{
|
|
5443
|
-
className:
|
|
5439
|
+
className: cn(
|
|
5440
|
+
"flex min-h-0 flex-col border-b border-border md:w-80 md:shrink-0 md:border-b-0 md:border-r",
|
|
5441
|
+
className
|
|
5442
|
+
),
|
|
5444
5443
|
"data-testid": "arbi-dm-list",
|
|
5445
5444
|
children: [
|
|
5446
|
-
/* @__PURE__ */ jsxs("div", { className: "border-b border-border px-4 py-3", children: [
|
|
5445
|
+
header === void 0 ? /* @__PURE__ */ jsxs("div", { className: "border-b border-border px-4 py-3", children: [
|
|
5447
5446
|
/* @__PURE__ */ jsx("p", { className: "text-sm font-semibold text-foreground", children: "Conversations" }),
|
|
5448
5447
|
/* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
5449
5448
|
conversations.length,
|
|
5450
5449
|
" ",
|
|
5451
5450
|
conversations.length === 1 ? "colleague" : "colleagues"
|
|
5452
5451
|
] })
|
|
5453
|
-
] }),
|
|
5454
|
-
/* @__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) => {
|
|
5452
|
+
] }) : header,
|
|
5453
|
+
/* @__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) => {
|
|
5455
5454
|
const { peer, lastMessage, unreadCount } = c;
|
|
5455
|
+
const newSection = c.sectionLabel && c.sectionLabel !== conversations[i - 1]?.sectionLabel;
|
|
5456
5456
|
const active = peer.external_id === selectedPeerId;
|
|
5457
|
-
const preview = lastMessage
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
{
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5457
|
+
const preview = lastMessage?.body ?? "No messages yet \u2014 say hello";
|
|
5458
|
+
const unread = unreadCount > 0;
|
|
5459
|
+
const body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5460
|
+
c.leading ?? /* @__PURE__ */ jsx(DmAvatar, { user: peer }),
|
|
5461
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
5462
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
5463
|
+
/* @__PURE__ */ jsx(
|
|
5464
|
+
"span",
|
|
5465
|
+
{
|
|
5466
|
+
className: cn(
|
|
5467
|
+
"truncate text-sm text-foreground",
|
|
5468
|
+
unread ? "font-bold" : "font-semibold"
|
|
5469
|
+
),
|
|
5470
|
+
children: userDisplayName(peer)
|
|
5471
|
+
}
|
|
5472
|
+
),
|
|
5473
|
+
c.statusLabel ? /* @__PURE__ */ jsx(
|
|
5474
|
+
Badge,
|
|
5475
|
+
{
|
|
5476
|
+
variant: "outline",
|
|
5477
|
+
className: "shrink-0 rounded-full px-2 py-0 text-[10px] font-medium text-muted-foreground",
|
|
5478
|
+
children: c.statusLabel
|
|
5479
|
+
}
|
|
5480
|
+
) : unreadCount > 0 ? (
|
|
5481
|
+
// Quiet by default: a filled brand pill with a shadow
|
|
5482
|
+
// shouted louder than the message it was counting.
|
|
5483
|
+
// Enough to catch the eye scanning the list, no more.
|
|
5484
|
+
/* @__PURE__ */ jsx(
|
|
5485
|
+
Badge,
|
|
5486
|
+
{
|
|
5487
|
+
variant: "accent",
|
|
5488
|
+
className: cn(
|
|
5489
|
+
"min-w-[1.125rem] justify-center rounded-full px-1 py-0 text-[10px] font-medium leading-[1.125rem] shadow-none",
|
|
5490
|
+
classNames?.unreadBadge
|
|
5491
|
+
),
|
|
5492
|
+
children: unreadCount
|
|
5493
|
+
}
|
|
5494
|
+
)
|
|
5495
|
+
) : null
|
|
5496
|
+
] }),
|
|
5497
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-1.5", children: [
|
|
5498
|
+
lastMessage?.isMine ? lastMessage.read ? /* @__PURE__ */ jsx(
|
|
5499
|
+
CheckCheck,
|
|
5500
|
+
{
|
|
5501
|
+
className: "size-3.5 shrink-0 text-ai-accent",
|
|
5502
|
+
"aria-label": "Read"
|
|
5503
|
+
}
|
|
5504
|
+
) : /* @__PURE__ */ jsx(
|
|
5505
|
+
Check,
|
|
5506
|
+
{
|
|
5507
|
+
className: "size-3.5 shrink-0 text-muted-foreground",
|
|
5508
|
+
"aria-label": "Sent"
|
|
5509
|
+
}
|
|
5510
|
+
) : null,
|
|
5511
|
+
/* @__PURE__ */ jsx(
|
|
5512
|
+
"p",
|
|
5513
|
+
{
|
|
5514
|
+
className: cn(
|
|
5515
|
+
"min-w-0 flex-1 truncate text-xs",
|
|
5516
|
+
unread ? "font-medium text-foreground" : "text-muted-foreground"
|
|
5517
|
+
),
|
|
5518
|
+
children: c.subtitle ?? preview
|
|
5519
|
+
}
|
|
5520
|
+
),
|
|
5521
|
+
/* @__PURE__ */ jsx("span", { className: "shrink-0 text-[11px] text-muted-foreground", children: lastMessage ? formatRelativeTime(lastMessage.createdAt) : "" })
|
|
5522
|
+
] })
|
|
5523
|
+
] })
|
|
5524
|
+
] });
|
|
5525
|
+
const rowClass = cn(
|
|
5526
|
+
// Each row is its own opaque surface. Left transparent it takes
|
|
5527
|
+
// the panel's colour, and the chips stop reading as cards at all
|
|
5528
|
+
// — which is the whole point of them.
|
|
5529
|
+
"flex w-full items-start gap-3 border-b border-border/60 bg-card px-4 py-3 text-left transition-colors",
|
|
5530
|
+
c.disabled ? "cursor-default" : active ? "bg-ai-accent-soft" : "hover:bg-accent/40"
|
|
5531
|
+
);
|
|
5532
|
+
return /* @__PURE__ */ jsxs("li", { children: [
|
|
5533
|
+
newSection && /* @__PURE__ */ jsx(
|
|
5534
|
+
"p",
|
|
5535
|
+
{
|
|
5536
|
+
className: "bg-muted/40 px-4 py-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",
|
|
5537
|
+
"data-testid": "arbi-dm-section",
|
|
5538
|
+
children: c.sectionLabel
|
|
5539
|
+
}
|
|
5540
|
+
),
|
|
5541
|
+
c.disabled ? /* @__PURE__ */ jsxs(
|
|
5542
|
+
"div",
|
|
5543
|
+
{
|
|
5544
|
+
"data-testid": `arbi-dm-conversation-${peer.external_id}`,
|
|
5545
|
+
className: rowClass,
|
|
5546
|
+
children: [
|
|
5547
|
+
body,
|
|
5548
|
+
c.trailing
|
|
5549
|
+
]
|
|
5550
|
+
}
|
|
5551
|
+
) : /* @__PURE__ */ jsx(
|
|
5552
|
+
"button",
|
|
5553
|
+
{
|
|
5554
|
+
type: "button",
|
|
5555
|
+
onClick: () => onSelect(peer.external_id),
|
|
5556
|
+
"data-testid": `arbi-dm-conversation-${peer.external_id}`,
|
|
5557
|
+
className: rowClass,
|
|
5558
|
+
children: body
|
|
5559
|
+
}
|
|
5560
|
+
)
|
|
5561
|
+
] }, peer.external_id);
|
|
5483
5562
|
}) }) })
|
|
5484
5563
|
]
|
|
5485
5564
|
}
|
|
5486
5565
|
);
|
|
5487
5566
|
}
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5567
|
+
|
|
5568
|
+
// src/directmessages/grouping.ts
|
|
5569
|
+
var RUN_WINDOW_MS = 2 * 60 * 1e3;
|
|
5570
|
+
function dayKey(iso) {
|
|
5571
|
+
const d = new Date(iso);
|
|
5572
|
+
if (Number.isNaN(d.getTime())) return iso;
|
|
5573
|
+
return `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`;
|
|
5574
|
+
}
|
|
5575
|
+
function annotateThread(messages, accessors, runWindowMs = RUN_WINDOW_MS) {
|
|
5576
|
+
const { senderId, createdAt } = accessors;
|
|
5577
|
+
return messages.map((message, i) => {
|
|
5578
|
+
const next = messages[i + 1];
|
|
5579
|
+
const prev = messages[i - 1];
|
|
5580
|
+
const day = dayKey(createdAt(message));
|
|
5581
|
+
const continuesIntoNext = !!next && senderId(next) === senderId(message) && dayKey(createdAt(next)) === day && Date.parse(createdAt(next)) - Date.parse(createdAt(message)) < runWindowMs;
|
|
5582
|
+
return {
|
|
5583
|
+
message,
|
|
5584
|
+
isLastOfRun: !continuesIntoNext,
|
|
5585
|
+
isFirstOfDay: !prev || dayKey(createdAt(prev)) !== day
|
|
5586
|
+
};
|
|
5587
|
+
});
|
|
5588
|
+
}
|
|
5589
|
+
function DateSeparator({ children }) {
|
|
5590
|
+
return /* @__PURE__ */ jsx("div", { className: "my-3 flex justify-center", "data-testid": "dm-date-separator", children: /* @__PURE__ */ jsx("span", { className: "rounded-full bg-background/80 px-2 py-0.5 text-xs text-muted-foreground", children }) });
|
|
5591
|
+
}
|
|
5592
|
+
function MessageBubble2({
|
|
5593
|
+
message,
|
|
5594
|
+
classNames,
|
|
5595
|
+
isLastOfRun = true,
|
|
5596
|
+
onDelete,
|
|
5597
|
+
deleted
|
|
5598
|
+
}) {
|
|
5599
|
+
return /* @__PURE__ */ jsx(
|
|
5600
|
+
ChatBubble,
|
|
5493
5601
|
{
|
|
5494
5602
|
"data-testid": "arbi-dm-message",
|
|
5495
|
-
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
"max-w-[80%] rounded-2xl px-3.5 py-2 text-sm shadow-sm",
|
|
5506
|
-
isMine ? cn("rounded-br-sm bg-accent text-accent-foreground", classNames?.ownBubble) : cn(
|
|
5507
|
-
"rounded-bl-sm border border-border bg-card text-card-foreground",
|
|
5508
|
-
classNames?.peerBubble
|
|
5509
|
-
)
|
|
5510
|
-
),
|
|
5511
|
-
children: message.body
|
|
5512
|
-
}
|
|
5513
|
-
)
|
|
5514
|
-
]
|
|
5603
|
+
message: message.body,
|
|
5604
|
+
timestamp: message.createdAt,
|
|
5605
|
+
isSent: message.isMine,
|
|
5606
|
+
read: message.read,
|
|
5607
|
+
deleted,
|
|
5608
|
+
onDelete,
|
|
5609
|
+
isLastOfRun,
|
|
5610
|
+
senderName: message.isMine ? "You" : userDisplayName(message.sender),
|
|
5611
|
+
classNames,
|
|
5612
|
+
formatTimestamp: formatRelativeTime
|
|
5515
5613
|
}
|
|
5516
5614
|
);
|
|
5517
5615
|
}
|
|
5518
|
-
|
|
5616
|
+
var THREAD_ACCESSORS = {
|
|
5617
|
+
senderId: (m) => m.sender.external_id,
|
|
5618
|
+
createdAt: (m) => m.createdAt
|
|
5619
|
+
};
|
|
5620
|
+
function MessageThread({
|
|
5621
|
+
conversation,
|
|
5622
|
+
classNames,
|
|
5623
|
+
emptyState,
|
|
5624
|
+
formatDay,
|
|
5625
|
+
onDeleteMessage,
|
|
5626
|
+
deletedIds
|
|
5627
|
+
}) {
|
|
5519
5628
|
const bottomRef = useRef(null);
|
|
5629
|
+
const items = useMemo(
|
|
5630
|
+
() => annotateThread(conversation?.messages ?? [], THREAD_ACCESSORS),
|
|
5631
|
+
[conversation?.messages]
|
|
5632
|
+
);
|
|
5520
5633
|
useEffect(() => {
|
|
5521
5634
|
bottomRef.current?.scrollIntoView({ block: "end" });
|
|
5522
5635
|
}, [conversation?.peer.external_id, conversation?.messages.length]);
|
|
@@ -5529,7 +5642,7 @@ function MessageThread({ conversation, classNames, emptyState }) {
|
|
|
5529
5642
|
] })
|
|
5530
5643
|
] }) });
|
|
5531
5644
|
}
|
|
5532
|
-
const { peer
|
|
5645
|
+
const { peer } = conversation;
|
|
5533
5646
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5534
5647
|
/* @__PURE__ */ jsxs("header", { className: "flex items-center gap-3 border-b border-border px-4 py-3", children: [
|
|
5535
5648
|
/* @__PURE__ */ jsx(DmAvatar, { user: peer, className: "size-9" }),
|
|
@@ -5538,20 +5651,42 @@ function MessageThread({ conversation, classNames, emptyState }) {
|
|
|
5538
5651
|
/* @__PURE__ */ jsx("p", { className: "truncate text-xs text-muted-foreground", children: peer.email })
|
|
5539
5652
|
] })
|
|
5540
5653
|
] }),
|
|
5541
|
-
/* @__PURE__ */ jsx(ScrollArea, { className: "min-h-0 flex-1 bg-background", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col
|
|
5542
|
-
|
|
5654
|
+
/* @__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: [
|
|
5655
|
+
items.map(({ message: m, isLastOfRun, isFirstOfDay }) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
5656
|
+
isFirstOfDay && formatDay && /* @__PURE__ */ jsx(DateSeparator, { children: formatDay(m.createdAt) }),
|
|
5657
|
+
/* @__PURE__ */ jsx(
|
|
5658
|
+
MessageBubble2,
|
|
5659
|
+
{
|
|
5660
|
+
message: m,
|
|
5661
|
+
classNames,
|
|
5662
|
+
isLastOfRun,
|
|
5663
|
+
deleted: deletedIds?.has(m.externalId),
|
|
5664
|
+
onDelete: onDeleteMessage ? () => onDeleteMessage(m) : void 0
|
|
5665
|
+
}
|
|
5666
|
+
)
|
|
5667
|
+
] }, m.externalId)),
|
|
5543
5668
|
/* @__PURE__ */ jsx("div", { ref: bottomRef })
|
|
5544
5669
|
] }) })
|
|
5545
5670
|
] });
|
|
5546
5671
|
}
|
|
5547
|
-
function DmComposer({
|
|
5672
|
+
function DmComposer({
|
|
5673
|
+
placeholder,
|
|
5674
|
+
disabled,
|
|
5675
|
+
busy,
|
|
5676
|
+
onSend,
|
|
5677
|
+
error,
|
|
5678
|
+
children,
|
|
5679
|
+
classNames
|
|
5680
|
+
}) {
|
|
5548
5681
|
const [draft, setDraft] = useState("");
|
|
5682
|
+
const inputRef = useRef(null);
|
|
5549
5683
|
const submit = async () => {
|
|
5550
5684
|
const text = draft.trim();
|
|
5551
|
-
if (!text || disabled) return;
|
|
5685
|
+
if (!text || disabled || busy) return;
|
|
5552
5686
|
setDraft("");
|
|
5553
5687
|
try {
|
|
5554
5688
|
await onSend(text);
|
|
5689
|
+
inputRef.current?.focus();
|
|
5555
5690
|
} catch {
|
|
5556
5691
|
setDraft(text);
|
|
5557
5692
|
}
|
|
@@ -5563,10 +5698,12 @@ function DmComposer({ placeholder, disabled, onSend, error, classNames }) {
|
|
|
5563
5698
|
}
|
|
5564
5699
|
};
|
|
5565
5700
|
return /* @__PURE__ */ jsxs("div", { className: "border-t border-border p-3", children: [
|
|
5701
|
+
children,
|
|
5566
5702
|
/* @__PURE__ */ jsxs("div", { className: "flex items-end gap-2", children: [
|
|
5567
5703
|
/* @__PURE__ */ jsx(
|
|
5568
5704
|
Textarea,
|
|
5569
5705
|
{
|
|
5706
|
+
ref: inputRef,
|
|
5570
5707
|
value: draft,
|
|
5571
5708
|
onChange: (e) => setDraft(e.target.value),
|
|
5572
5709
|
onKeyDown,
|
|
@@ -5582,11 +5719,12 @@ function DmComposer({ placeholder, disabled, onSend, error, classNames }) {
|
|
|
5582
5719
|
{
|
|
5583
5720
|
type: "button",
|
|
5584
5721
|
onClick: () => void submit(),
|
|
5585
|
-
disabled: disabled || !draft.trim(),
|
|
5722
|
+
disabled: disabled || busy || !draft.trim(),
|
|
5586
5723
|
className: cn(classNames?.sendButton),
|
|
5587
5724
|
"data-testid": "arbi-dm-send",
|
|
5725
|
+
"aria-label": "Send message",
|
|
5588
5726
|
children: [
|
|
5589
|
-
/* @__PURE__ */ jsx(Send, { className: "size-4" }),
|
|
5727
|
+
busy ? /* @__PURE__ */ jsx(Loader2, { className: "size-4 animate-spin" }) : /* @__PURE__ */ jsx(Send, { className: "size-4" }),
|
|
5590
5728
|
" Send"
|
|
5591
5729
|
]
|
|
5592
5730
|
}
|
|
@@ -6790,6 +6928,6 @@ function DocumentGallery({
|
|
|
6790
6928
|
);
|
|
6791
6929
|
}
|
|
6792
6930
|
|
|
6793
|
-
export { ActivityFeed, AiActionCard, AiAnswer, AppleIcon, ArbiBotHeadIcon, ArbiBotIcon, ArbiChat, ArbiChatPanel, ArbiIcon, ArbiWebSocketProvider, ArtifactCanvas, AudIcon, BASE_COLORS2 as BASE_COLORS, ChatBubble, CitationRenderer, ClaudeIcon, CommandPalette, CommandPaletteProvider, ConversationList, DEFAULT_ASPECT_OPTIONS, DEFAULT_NOTIFY_TONE, DirectMessages, DmAvatar, DmComposer, DocIcon, DocQaPanel, DocSearch, DocumentCard, DocumentCardMenu, DocumentEntity, DocumentGallery, DocumentReview, DocumentTable, ENTITY_MAPPINGS, EmlIcon, EntityIcon, EntityPill, FILE_TYPE_COLORS, FileIcon, FireworksIcon, GeminiIcon, GitHubIcon, GoogleIcon, HtmlIcon, ImageCropModal, ImageCropper, ImgIcon, LinkedInIcon, MessageArtifactCard, MessageBubble2 as MessageBubble, MessageThread, NEUTRAL_GRAY2 as NEUTRAL_GRAY, NotificationBell, OpenAIIcon, PLACEHOLDER_COLOR, PassageCard, PdfIcon, ProjectEntity, ProviderIcon, RagDot, RelevanceDot, SemanticSearch, StatusPill, TAG_TYPE_ICONS, TAG_TYPE_LABELS, TagEntity, Toaster, TxtIcon, TypingIndicator, UserEntity, UserMenu, VISIBILITY_ICONS, VidIcon, VisibilityIcon, XlsIcon, arbiQueryKeys, configureEntityRegistry, configureRagLabels, configureStatusRegistry, cropImage, describeActivity, formatRelativeTime, getEntityColor2 as getEntityColor, getEntityColorStyles, getEntityIcon, getEntityLabel, getNotificationTypeMeta, getStatusVariant, getTagTypeIcon, getTagTypeLabel, getWorkspaceActionText, getWorkspaceColor, getWorkspaceSentPhrase, isWorkspaceNotificationType, notify, parseActivityContent, redlineStats, seedNotifications, selectUnread, textToArtifact, toRedlineMarkdown, useActivity, useAgents, useAiTask, useArbiConnected, useArbiDocumentSync, useArbiUiStore, useArbiWebSocket, useArbiWsContext, useArbiWsMessage, useArbiWsStatus, useArbiWsStore, useArbiWsTask, useArbiWsTasks, useAssistantQuery, useCommandPalette, useConfigs, useConversations, useDeleteAgents, useDirectMessages, useDocuments, useFacts, useHealth, useNotify, useParsedDocument, useProjectInvoices, useProjectUsage, useProjects, useProjectsUsage, useSemanticSearch, useSessions, useTags, useTasks, useThumbnails, useUserUsageToday, useWorkspaceDocs, useWorkspaces, userDisplayName, userInitials };
|
|
6931
|
+
export { ActivityFeed, AiActionCard, AiAnswer, AppleIcon, ArbiBotHeadIcon, ArbiBotIcon, ArbiChat, ArbiChatPanel, ArbiIcon, ArbiWebSocketProvider, ArtifactCanvas, AudIcon, BASE_COLORS2 as BASE_COLORS, ChatBubble, CitationRenderer, ClaudeIcon, CommandPalette, CommandPaletteProvider, ConversationList, DEFAULT_ASPECT_OPTIONS, DEFAULT_NOTIFY_TONE, DateSeparator, DirectMessages, DmAvatar, DmComposer, DocIcon, DocQaPanel, DocSearch, DocumentCard, DocumentCardMenu, DocumentEntity, DocumentGallery, DocumentReview, DocumentTable, ENTITY_MAPPINGS, EmlIcon, EntityIcon, EntityPill, FILE_TYPE_COLORS, FileIcon, FireworksIcon, GeminiIcon, GitHubIcon, GoogleIcon, HtmlIcon, ImageCropModal, ImageCropper, ImgIcon, LinkedInIcon, MessageArtifactCard, MessageBubble2 as MessageBubble, MessageThread, NEUTRAL_GRAY2 as NEUTRAL_GRAY, NotificationBell, OpenAIIcon, PLACEHOLDER_COLOR, PassageCard, PdfIcon, ProjectEntity, ProviderIcon, RUN_WINDOW_MS, RagDot, RelevanceDot, SemanticSearch, StatusPill, TAG_TYPE_ICONS, TAG_TYPE_LABELS, TagEntity, Toaster, TxtIcon, TypingIndicator, UserEntity, UserMenu, VISIBILITY_ICONS, VidIcon, VisibilityIcon, XlsIcon, annotateThread, arbiQueryKeys, configureEntityRegistry, configureRagLabels, configureStatusRegistry, cropImage, dayKey, describeActivity, formatRelativeTime, getEntityColor2 as getEntityColor, getEntityColorStyles, getEntityIcon, getEntityLabel, getNotificationTypeMeta, getStatusVariant, getTagTypeIcon, getTagTypeLabel, getWorkspaceActionText, getWorkspaceColor, getWorkspaceSentPhrase, isWorkspaceNotificationType, notify, parseActivityContent, redlineStats, seedNotifications, selectUnread, textToArtifact, toRedlineMarkdown, useActivity, useAgents, useAiTask, useArbiConnected, useArbiDocumentSync, useArbiUiStore, useArbiWebSocket, useArbiWsContext, useArbiWsMessage, useArbiWsStatus, useArbiWsStore, useArbiWsTask, useArbiWsTasks, useAssistantQuery, useCommandPalette, useConfigs, useConversations, useDeleteAgents, useDirectMessages, useDocuments, useFacts, useHealth, useNotify, useParsedDocument, useProjectInvoices, useProjectUsage, useProjects, useProjectsUsage, useSemanticSearch, useSessions, useTags, useTasks, useThumbnails, useUserUsageToday, useWorkspaceDocs, useWorkspaces, userDisplayName, userInitials };
|
|
6794
6932
|
//# sourceMappingURL=index.js.map
|
|
6795
6933
|
//# sourceMappingURL=index.js.map
|