@arbidocs/blocks 0.5.43 → 0.5.45
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 +14 -0
- package/dist/agents/definitions/agentTasks.d.ts +4 -0
- package/dist/agents/definitions/index.d.ts +1 -0
- package/dist/agents/index.cjs +14 -10
- package/dist/agents/index.js +1 -1
- package/dist/calls/index.cjs +73 -696
- package/dist/calls/index.cjs.map +1 -1
- package/dist/calls/index.js +10 -666
- package/dist/calls/index.js.map +1 -1
- package/dist/{chunk-6AJJJ5HR.cjs → chunk-5R256EMF.cjs} +671 -3
- package/dist/chunk-5R256EMF.cjs.map +1 -0
- package/dist/{chunk-E3IEZMRK.cjs → chunk-ET42AFEJ.cjs} +15 -2
- package/dist/chunk-ET42AFEJ.cjs.map +1 -0
- package/dist/{chunk-FOIDBAZB.js → chunk-OQMWTEM2.js} +15 -3
- package/dist/chunk-OQMWTEM2.js.map +1 -0
- package/dist/{chunk-4U4NXFV5.js → chunk-TKTNXFAB.js} +666 -9
- package/dist/chunk-TKTNXFAB.js.map +1 -0
- package/dist/connect/index.cjs +1736 -482
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/index.d.ts +2 -0
- package/dist/connect/index.js +1729 -479
- package/dist/connect/index.js.map +1 -1
- package/dist/connection/ConnectedFilterDropdown.d.ts +6 -0
- package/dist/connection/agents/useConnectedAgentManagement.d.ts +60 -0
- package/dist/connection/conversation/ConnectedConversation.d.ts +7 -9
- package/dist/connection/conversation/ConnectedConversationPage.d.ts +30 -0
- package/dist/connection/conversation/SemanticSearchButton.d.ts +12 -0
- package/dist/connection/files/imports/ConnectedAccountsImport.d.ts +16 -0
- package/dist/connection/files/imports/DriveImportPanel.d.ts +10 -0
- package/dist/connection/files/imports/EmailImportPanel.d.ts +21 -0
- package/dist/connection/files/imports/ImportHandoff.d.ts +24 -0
- package/dist/connection/files/imports/useDriveSyncTrigger.d.ts +11 -0
- package/dist/connection/files/imports/useEmailSyncTrigger.d.ts +11 -0
- package/dist/connection/files/imports/useImportHandoff.d.ts +20 -0
- package/dist/connection/files/index.d.ts +1 -0
- package/dist/index.cjs +14 -10
- package/dist/index.js +1 -1
- package/dist/workflow-canvas/index.cjs +2 -2
- package/dist/workflow-canvas/index.js +1 -1
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +5 -5
- package/dist/chunk-4U4NXFV5.js.map +0 -1
- package/dist/chunk-6AJJJ5HR.cjs.map +0 -1
- package/dist/chunk-E3IEZMRK.cjs.map +0 -1
- package/dist/chunk-FOIDBAZB.js.map +0 -1
|
@@ -4,14 +4,570 @@ import { useConnectedConversations } from './chunk-SYP2A4GQ.js';
|
|
|
4
4
|
import { useConnectedWorkspace } from './chunk-7LN3ISPG.js';
|
|
5
5
|
import { EmptyState } from './chunk-P6GHJSLR.js';
|
|
6
6
|
import { TranscriptLine, transcriptRuns, ProvisionalTranscriptLine } from './chunk-6AMCMKTF.js';
|
|
7
|
-
import { useBlocksEnvironment } from './chunk-QZUZPC4J.js';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { FileText, Loader2, Video, Mic, Pause, Play, Download, Link2, Captions, FileUp, Trash2,
|
|
11
|
-
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription,
|
|
12
|
-
import { jsxs, Fragment
|
|
7
|
+
import { useBlocksEnvironment, requestCalendarComposer } from './chunk-QZUZPC4J.js';
|
|
8
|
+
import { useCallsEnabled, useCanHostCalls, useCallSession, useCreateContact, useWorkspaces, usePeople, usePeopleSearch, useArbi, threadLiveCallId, openCall, startThreadCall, useConversationItems, hasRecordingTranscript, threadTranscriptRef, useRecordingWindows, supersedeLiveTranscript, useSaveToThread, useCall, useWorkspaceUsers, threadTranscriptLines, useCallRecording, useCallRecordings, useRecordingActions, speakerTracks, timelineOf, timelineDurationMs, compositeTrack, compositeFiles, useArbiSessionState, useConversationData, useOpenCallMeetingChat, transcriptSegmentOf, useRevokeCallInviteLink, useCallInviteLinks, meetingChatRefFrom, recordingFiles, playheadAt, partsDue, PLAYBACK_LOOKAHEAD_MS, partKey, fetchPart, standalone, schedulePart } from '@arbidocs/react';
|
|
9
|
+
import { createContext, useState, useEffect, useMemo, useRef, useCallback, useContext } from 'react';
|
|
10
|
+
import { Phone, UserPlus, CalendarPlus, FileText, Loader2, Video, Mic, Pause, Play, Download, Link2, Captions, FileUp, Trash2, Disc, PhoneOff, MessageSquare, AudioLines, CaptionsOff, Mail, X } from 'lucide-react';
|
|
11
|
+
import { Tooltip, TooltipTrigger, Button, cn, TooltipContent, isAgent, Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, Input, DialogFooter, getUserDisplayName, Checkbox } from '@arbidocs/react/ui';
|
|
12
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
13
|
+
import { ArbiApiError, refusalReason } from '@arbidocs/sdk/browser';
|
|
13
14
|
import { downloadBlob } from '@arbidocs/react/document-tools';
|
|
14
15
|
|
|
16
|
+
function StartCallButton(props) {
|
|
17
|
+
const enabled = useCallsEnabled();
|
|
18
|
+
const canHost = useCanHostCalls();
|
|
19
|
+
return enabled && (canHost || props.isLive) ? /* @__PURE__ */ jsx(EnabledStartCallButton, { ...props }) : null;
|
|
20
|
+
}
|
|
21
|
+
function EnabledStartCallButton({
|
|
22
|
+
onStart,
|
|
23
|
+
isLive = false,
|
|
24
|
+
label = "Start call",
|
|
25
|
+
testId = "start-call-button"
|
|
26
|
+
}) {
|
|
27
|
+
const [isStarting, setIsStarting] = useState(false);
|
|
28
|
+
const inCall = useCallSession((s) => s.active !== null);
|
|
29
|
+
const text = inCall ? "Already in a call" : isLive ? "Join call" : label;
|
|
30
|
+
return /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
31
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
32
|
+
Button,
|
|
33
|
+
{
|
|
34
|
+
type: "button",
|
|
35
|
+
variant: "ghost",
|
|
36
|
+
size: "icon",
|
|
37
|
+
"aria-label": isLive ? "Join call" : label,
|
|
38
|
+
"data-testid": testId,
|
|
39
|
+
"data-live": isLive || void 0,
|
|
40
|
+
disabled: isStarting || inCall,
|
|
41
|
+
onClick: () => {
|
|
42
|
+
setIsStarting(true);
|
|
43
|
+
void onStart().finally(() => setIsStarting(false));
|
|
44
|
+
},
|
|
45
|
+
className: cn(
|
|
46
|
+
"text-muted-foreground hover:text-foreground",
|
|
47
|
+
isLive && "text-green-text hover:text-green-text"
|
|
48
|
+
),
|
|
49
|
+
children: /* @__PURE__ */ jsx(Phone, { className: cn("size-5", isLive && "animate-pulse") })
|
|
50
|
+
}
|
|
51
|
+
) }),
|
|
52
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: text }) })
|
|
53
|
+
] });
|
|
54
|
+
}
|
|
55
|
+
var INVITE_LINK_HINT = "will get an invitation to create an ARBI account and join";
|
|
56
|
+
var NO_KEY_REASON = "Cannot receive encrypted calls yet";
|
|
57
|
+
var NO_EMAIL_REASON = "No e-mail address to send a link to";
|
|
58
|
+
function contactName(contact) {
|
|
59
|
+
return contact.card?.name?.trim() || [contact.card?.given_name, contact.card?.family_name].filter(Boolean).join(" ") || (contact.user ? getUserDisplayName(contact.user) : "") || contactEmail(contact) || "Contact";
|
|
60
|
+
}
|
|
61
|
+
function contactEmail(contact) {
|
|
62
|
+
return contact.email ?? contact.user?.email ?? contact.card?.emails?.[0]?.email ?? null;
|
|
63
|
+
}
|
|
64
|
+
function callContactOf(contact) {
|
|
65
|
+
if (!contact.external_id || contact.status === "failed") return null;
|
|
66
|
+
if (contact.user && isAgent(contact.user)) return null;
|
|
67
|
+
return {
|
|
68
|
+
contactExtId: contact.external_id,
|
|
69
|
+
user: contact.user ?? null,
|
|
70
|
+
name: contactName(contact),
|
|
71
|
+
email: contactEmail(contact)
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function userCandidate(user, section, status, contactExtId = null) {
|
|
75
|
+
const ringable = status !== "ring" || !!user.encryption_public_key;
|
|
76
|
+
return {
|
|
77
|
+
id: user.external_id,
|
|
78
|
+
name: getUserDisplayName(user) || user.email,
|
|
79
|
+
email: user.email ?? null,
|
|
80
|
+
section,
|
|
81
|
+
status: ringable ? status : "unavailable",
|
|
82
|
+
reason: ringable ? void 0 : NO_KEY_REASON,
|
|
83
|
+
user,
|
|
84
|
+
contactExtId
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function buildCallCandidates(opts) {
|
|
88
|
+
const seen = /* @__PURE__ */ new Set();
|
|
89
|
+
const out = [];
|
|
90
|
+
const add = (c) => {
|
|
91
|
+
if (seen.has(c.id)) return;
|
|
92
|
+
seen.add(c.id);
|
|
93
|
+
out.push(c);
|
|
94
|
+
};
|
|
95
|
+
const people = (users) => users.filter((u) => !isAgent(u) && u.external_id !== opts.me);
|
|
96
|
+
if (opts.scope !== "contacts") {
|
|
97
|
+
for (const u of people(opts.members)) add(userCandidate(u, "members", "ring"));
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
100
|
+
const contacts = (opts.contacts ?? []).filter((c) => !(c.user && isAgent(c.user)));
|
|
101
|
+
const contactOf = new Map(
|
|
102
|
+
contacts.filter((c) => c.user).map((c) => [c.user.external_id, c.contactExtId])
|
|
103
|
+
);
|
|
104
|
+
for (const u of people(opts.members)) {
|
|
105
|
+
const contactId = contactOf.get(u.external_id) ?? opts.contactIdOf?.(u) ?? null;
|
|
106
|
+
add(userCandidate(u, "members", contactId ? "ring" : "add-contact", contactId));
|
|
107
|
+
}
|
|
108
|
+
for (const c of contacts) {
|
|
109
|
+
if (c.user) {
|
|
110
|
+
if (c.user.external_id === opts.me) continue;
|
|
111
|
+
add(userCandidate(c.user, "contacts", "ring", c.contactExtId));
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const status = c.email ? "invite" : "unavailable";
|
|
115
|
+
add({
|
|
116
|
+
id: c.contactExtId,
|
|
117
|
+
name: c.name,
|
|
118
|
+
email: c.email,
|
|
119
|
+
section: "contacts",
|
|
120
|
+
status,
|
|
121
|
+
reason: c.email ? INVITE_LINK_HINT : NO_EMAIL_REASON,
|
|
122
|
+
user: null,
|
|
123
|
+
contactExtId: c.contactExtId
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return out;
|
|
127
|
+
}
|
|
128
|
+
function isPickable(c) {
|
|
129
|
+
return c.status === "ring" || c.status === "invite";
|
|
130
|
+
}
|
|
131
|
+
function matchesQuery(c, query) {
|
|
132
|
+
const q = query.trim().toLowerCase();
|
|
133
|
+
if (!q) return true;
|
|
134
|
+
return c.name.toLowerCase().includes(q) || (c.email ?? "").toLowerCase().includes(q);
|
|
135
|
+
}
|
|
136
|
+
var EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
137
|
+
var COPY = {
|
|
138
|
+
workspace: {
|
|
139
|
+
title: "Call thread members",
|
|
140
|
+
description: "Only members of this thread\u2019s workspace can join. Pick who to ring \u2014 or nobody, and share the call from the thread.",
|
|
141
|
+
action: "Start call"
|
|
142
|
+
},
|
|
143
|
+
chat: {
|
|
144
|
+
title: "Call the group",
|
|
145
|
+
description: "The people you pick are rung.",
|
|
146
|
+
action: "Start call"
|
|
147
|
+
},
|
|
148
|
+
contacts: {
|
|
149
|
+
title: "New call",
|
|
150
|
+
description: "Your contacts with an ARBI account are rung. Others get an invitation to create an account and join.",
|
|
151
|
+
action: "Start call"
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
function CandidateRow({
|
|
155
|
+
candidate,
|
|
156
|
+
checked,
|
|
157
|
+
onToggle,
|
|
158
|
+
onAddContact,
|
|
159
|
+
adding
|
|
160
|
+
}) {
|
|
161
|
+
const pickable = isPickable(candidate);
|
|
162
|
+
const hint = candidate.status === "invite" ? candidate.reason : candidate.status === "add-contact" ? "Not in your contacts" : void 0;
|
|
163
|
+
const row = /* @__PURE__ */ jsxs(
|
|
164
|
+
"li",
|
|
165
|
+
{
|
|
166
|
+
className: cn(
|
|
167
|
+
"flex items-center gap-3 rounded-md px-2 py-1.5",
|
|
168
|
+
pickable ? "hover:bg-muted" : "opacity-60"
|
|
169
|
+
),
|
|
170
|
+
"data-testid": `call-picker-row-${candidate.id}`,
|
|
171
|
+
"data-status": candidate.status,
|
|
172
|
+
"aria-disabled": !pickable || void 0,
|
|
173
|
+
children: [
|
|
174
|
+
/* @__PURE__ */ jsx(
|
|
175
|
+
Checkbox,
|
|
176
|
+
{
|
|
177
|
+
checked,
|
|
178
|
+
disabled: !pickable,
|
|
179
|
+
onCheckedChange: onToggle,
|
|
180
|
+
"aria-label": `Invite ${candidate.name}`,
|
|
181
|
+
"data-testid": `call-picker-check-${candidate.id}`
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
/* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1", children: [
|
|
185
|
+
/* @__PURE__ */ jsx("span", { className: "block truncate text-sm", children: candidate.name }),
|
|
186
|
+
/* @__PURE__ */ jsxs("span", { className: "block truncate text-xs text-muted-foreground", children: [
|
|
187
|
+
candidate.email,
|
|
188
|
+
hint && /* @__PURE__ */ jsxs("span", { className: "ml-1 inline-flex items-center gap-1", children: [
|
|
189
|
+
candidate.status === "invite" && /* @__PURE__ */ jsx(Mail, { className: "size-3", "aria-hidden": true }),
|
|
190
|
+
candidate.email ? `\xB7 ${hint}` : hint
|
|
191
|
+
] })
|
|
192
|
+
] })
|
|
193
|
+
] }),
|
|
194
|
+
candidate.status === "add-contact" && /* @__PURE__ */ jsxs(
|
|
195
|
+
Button,
|
|
196
|
+
{
|
|
197
|
+
type: "button",
|
|
198
|
+
size: "sm",
|
|
199
|
+
variant: "outline",
|
|
200
|
+
disabled: adding,
|
|
201
|
+
onClick: onAddContact,
|
|
202
|
+
"data-testid": `call-picker-add-${candidate.id}`,
|
|
203
|
+
children: [
|
|
204
|
+
/* @__PURE__ */ jsx(UserPlus, { className: "mr-1 size-3.5" }),
|
|
205
|
+
"Add contact"
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
)
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
if (candidate.status !== "unavailable" || !candidate.reason) return row;
|
|
213
|
+
return /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
214
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: row }),
|
|
215
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: candidate.reason }) })
|
|
216
|
+
] });
|
|
217
|
+
}
|
|
218
|
+
function InviteLinks({ callExtId }) {
|
|
219
|
+
const { notify } = useBlocksEnvironment();
|
|
220
|
+
const revokeLink = useRevokeCallInviteLink(callExtId);
|
|
221
|
+
const { data: invites = [] } = useCallInviteLinks(callExtId);
|
|
222
|
+
const live = invites.filter((i) => !i.revoked_at);
|
|
223
|
+
if (!live.length) return null;
|
|
224
|
+
const revoke = async (id) => {
|
|
225
|
+
try {
|
|
226
|
+
await revokeLink(id);
|
|
227
|
+
} catch (err) {
|
|
228
|
+
notify(err instanceof Error ? err.message : "Could not revoke the link", "error");
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
return /* @__PURE__ */ jsxs("section", { className: "flex flex-col gap-1", "data-testid": "call-picker-invite-links", children: [
|
|
232
|
+
/* @__PURE__ */ jsx("h3", { className: "text-xs font-medium text-muted-foreground", children: "Invitations sent" }),
|
|
233
|
+
/* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-1", children: live.map((invite) => /* @__PURE__ */ jsxs("li", { className: "flex items-center gap-2 text-sm", children: [
|
|
234
|
+
/* @__PURE__ */ jsx(Mail, { className: "size-3.5 text-muted-foreground", "aria-hidden": true }),
|
|
235
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", children: invite.email }),
|
|
236
|
+
invite.used_at && /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "joined" }),
|
|
237
|
+
/* @__PURE__ */ jsxs(
|
|
238
|
+
Button,
|
|
239
|
+
{
|
|
240
|
+
type: "button",
|
|
241
|
+
size: "sm",
|
|
242
|
+
variant: "ghost",
|
|
243
|
+
onClick: () => void revoke(invite.external_id),
|
|
244
|
+
"data-testid": `call-picker-revoke-${invite.external_id}`,
|
|
245
|
+
children: [
|
|
246
|
+
/* @__PURE__ */ jsx(X, { className: "mr-1 size-3.5" }),
|
|
247
|
+
"Revoke"
|
|
248
|
+
]
|
|
249
|
+
}
|
|
250
|
+
)
|
|
251
|
+
] }, invite.external_id)) })
|
|
252
|
+
] });
|
|
253
|
+
}
|
|
254
|
+
function CallPeoplePicker({
|
|
255
|
+
open,
|
|
256
|
+
onOpenChange,
|
|
257
|
+
scope,
|
|
258
|
+
workspaceExtId,
|
|
259
|
+
members: chatMembers = [],
|
|
260
|
+
preselected = [],
|
|
261
|
+
title,
|
|
262
|
+
description,
|
|
263
|
+
actionLabel,
|
|
264
|
+
callExtId,
|
|
265
|
+
onSubmit
|
|
266
|
+
}) {
|
|
267
|
+
const { notify } = useBlocksEnvironment();
|
|
268
|
+
const createContact = useCreateContact();
|
|
269
|
+
const { userId: me, workspaceId: selectedWorkspaceId } = useConnectedWorkspace();
|
|
270
|
+
const { data: workspaces = [] } = useWorkspaces({ enabled: scope !== "chat" });
|
|
271
|
+
const [picked, setPicked] = useState(() => new Set(preselected));
|
|
272
|
+
const [query, setQuery] = useState("");
|
|
273
|
+
const [newEmail, setNewEmail] = useState(null);
|
|
274
|
+
const [newName, setNewName] = useState("");
|
|
275
|
+
const [adding, setAdding] = useState(false);
|
|
276
|
+
const [busy, setBusy] = useState(false);
|
|
277
|
+
const [added, setAdded] = useState([]);
|
|
278
|
+
const { byEmail } = usePeople();
|
|
279
|
+
const { people: hits } = usePeopleSearch(open && scope === "contacts" ? query : "");
|
|
280
|
+
const preselectedKey = preselected.join(",");
|
|
281
|
+
useEffect(() => {
|
|
282
|
+
if (open) setPicked(new Set(preselectedKey ? preselectedKey.split(",") : []));
|
|
283
|
+
}, [open, preselectedKey]);
|
|
284
|
+
const workspaceId = workspaceExtId ?? (scope === "contacts" ? selectedWorkspaceId : null);
|
|
285
|
+
const workspaceMembers = useMemo(
|
|
286
|
+
() => (workspaces.find((w) => w.external_id === workspaceId)?.users ?? []).map((wu) => wu.user),
|
|
287
|
+
[workspaces, workspaceId]
|
|
288
|
+
);
|
|
289
|
+
const candidates = useMemo(() => {
|
|
290
|
+
const found = hits.flatMap(
|
|
291
|
+
(p) => p.contactId ? [{ contactExtId: p.contactId, user: p.user, name: p.name, email: p.email }] : []
|
|
292
|
+
);
|
|
293
|
+
return buildCallCandidates({
|
|
294
|
+
scope,
|
|
295
|
+
members: scope === "chat" ? chatMembers : workspaceMembers,
|
|
296
|
+
contacts: [...added, ...found],
|
|
297
|
+
contactIdOf: (u) => byEmail(u.email)?.contactId ?? null,
|
|
298
|
+
me
|
|
299
|
+
});
|
|
300
|
+
}, [scope, chatMembers, workspaceMembers, hits, added, byEmail, me]);
|
|
301
|
+
const shown = candidates.filter((c) => matchesQuery(c, query));
|
|
302
|
+
const copy = COPY[scope];
|
|
303
|
+
const toggle = (id) => setPicked((prev) => {
|
|
304
|
+
const next = new Set(prev);
|
|
305
|
+
if (next.has(id)) next.delete(id);
|
|
306
|
+
else next.add(id);
|
|
307
|
+
return next;
|
|
308
|
+
});
|
|
309
|
+
const addContact = async (email, name) => {
|
|
310
|
+
setAdding(true);
|
|
311
|
+
try {
|
|
312
|
+
const cardName = name?.trim();
|
|
313
|
+
const contact = await createContact.mutateAsync({
|
|
314
|
+
email,
|
|
315
|
+
invite: true,
|
|
316
|
+
...cardName ? { card: { name: cardName, emails: [{ email }] } } : {}
|
|
317
|
+
});
|
|
318
|
+
if (contact.status === "failed") {
|
|
319
|
+
throw new Error(contact.outcome_detail || "Could not add the contact");
|
|
320
|
+
}
|
|
321
|
+
const added2 = callContactOf(contact);
|
|
322
|
+
if (added2) setAdded((prev) => [...prev, added2]);
|
|
323
|
+
const id = contact.user?.external_id ?? contact.external_id;
|
|
324
|
+
const pickable = contact.user ? !!contact.user.encryption_public_key : !!added2?.email;
|
|
325
|
+
if (id && pickable) setPicked((prev) => new Set(prev).add(id));
|
|
326
|
+
setNewEmail(null);
|
|
327
|
+
setNewName("");
|
|
328
|
+
} catch (err) {
|
|
329
|
+
notify(
|
|
330
|
+
err instanceof ArbiApiError ? refusalReason(err, "Could not add the contact") : err instanceof Error ? err.message : "Could not add the contact",
|
|
331
|
+
"error"
|
|
332
|
+
);
|
|
333
|
+
} finally {
|
|
334
|
+
setAdding(false);
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
const submit = async () => {
|
|
338
|
+
if (busy) return;
|
|
339
|
+
const chosen = candidates.filter((c) => picked.has(c.id) && isPickable(c));
|
|
340
|
+
setBusy(true);
|
|
341
|
+
try {
|
|
342
|
+
await onSubmit({
|
|
343
|
+
ring: chosen.filter((c) => c.status === "ring" && c.user).map((c) => c.user),
|
|
344
|
+
invites: chosen.filter((c) => c.status === "invite" && c.contactExtId).map((c) => ({ contactExtId: c.contactExtId, name: c.name }))
|
|
345
|
+
});
|
|
346
|
+
onOpenChange(false);
|
|
347
|
+
} catch (err) {
|
|
348
|
+
notify(err instanceof Error ? err.message : "Something went wrong", "error");
|
|
349
|
+
} finally {
|
|
350
|
+
setBusy(false);
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
const sections = scope === "contacts" ? [
|
|
354
|
+
{ id: "members", label: "Workspace members" },
|
|
355
|
+
{ id: "contacts", label: "Contacts" }
|
|
356
|
+
] : [{ id: "members", label: scope === "chat" ? "Members" : "Workspace members" }];
|
|
357
|
+
const count = candidates.filter((c) => picked.has(c.id) && isPickable(c)).length;
|
|
358
|
+
return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-md", "data-testid": "call-people-picker", children: [
|
|
359
|
+
/* @__PURE__ */ jsxs(DialogHeader, { children: [
|
|
360
|
+
/* @__PURE__ */ jsx(DialogTitle, { children: title ?? copy.title }),
|
|
361
|
+
/* @__PURE__ */ jsx(DialogDescription, { children: description ?? copy.description })
|
|
362
|
+
] }),
|
|
363
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-col gap-3", children: [
|
|
364
|
+
/* @__PURE__ */ jsx(
|
|
365
|
+
Input,
|
|
366
|
+
{
|
|
367
|
+
placeholder: "Search people",
|
|
368
|
+
value: query,
|
|
369
|
+
onChange: (e) => setQuery(e.target.value),
|
|
370
|
+
"aria-label": "Search people",
|
|
371
|
+
"data-testid": "call-picker-search"
|
|
372
|
+
}
|
|
373
|
+
),
|
|
374
|
+
/* @__PURE__ */ jsxs("div", { className: "max-h-80 overflow-y-auto", children: [
|
|
375
|
+
sections.map((section) => {
|
|
376
|
+
const rows = shown.filter((c) => c.section === section.id);
|
|
377
|
+
if (!rows.length) return null;
|
|
378
|
+
return /* @__PURE__ */ jsxs("section", { className: "mb-2", children: [
|
|
379
|
+
/* @__PURE__ */ jsx("h3", { className: "px-2 pb-1 text-xs font-medium text-muted-foreground", children: section.label }),
|
|
380
|
+
/* @__PURE__ */ jsx("ul", { "data-testid": `call-picker-section-${section.id}`, children: rows.map((c) => /* @__PURE__ */ jsx(
|
|
381
|
+
CandidateRow,
|
|
382
|
+
{
|
|
383
|
+
candidate: c,
|
|
384
|
+
checked: picked.has(c.id),
|
|
385
|
+
onToggle: () => toggle(c.id),
|
|
386
|
+
adding,
|
|
387
|
+
onAddContact: () => c.email && void addContact(c.email)
|
|
388
|
+
},
|
|
389
|
+
c.id
|
|
390
|
+
)) })
|
|
391
|
+
] }, section.id);
|
|
392
|
+
}),
|
|
393
|
+
!shown.length && /* @__PURE__ */ jsx("p", { className: "px-2 py-3 text-sm text-muted-foreground", children: scope === "contacts" && !query.trim() ? "Search your contacts by name or e-mail." : candidates.length ? "Nobody matches." : "Nobody to call here yet." })
|
|
394
|
+
] }),
|
|
395
|
+
scope === "contacts" && (newEmail === null ? /* @__PURE__ */ jsxs(
|
|
396
|
+
Button,
|
|
397
|
+
{
|
|
398
|
+
type: "button",
|
|
399
|
+
variant: "ghost",
|
|
400
|
+
size: "sm",
|
|
401
|
+
className: "self-start",
|
|
402
|
+
onClick: () => setNewEmail(EMAIL_RE.test(query.trim()) ? query.trim() : ""),
|
|
403
|
+
"data-testid": "call-picker-add-contact",
|
|
404
|
+
children: [
|
|
405
|
+
/* @__PURE__ */ jsx(UserPlus, { className: "mr-1 size-4" }),
|
|
406
|
+
"Add contact\u2026"
|
|
407
|
+
]
|
|
408
|
+
}
|
|
409
|
+
) : /* @__PURE__ */ jsxs(
|
|
410
|
+
"form",
|
|
411
|
+
{
|
|
412
|
+
className: "flex flex-wrap items-center gap-2",
|
|
413
|
+
onSubmit: (e) => {
|
|
414
|
+
e.preventDefault();
|
|
415
|
+
if (EMAIL_RE.test(newEmail.trim())) void addContact(newEmail.trim(), newName);
|
|
416
|
+
},
|
|
417
|
+
children: [
|
|
418
|
+
/* @__PURE__ */ jsx(
|
|
419
|
+
Input,
|
|
420
|
+
{
|
|
421
|
+
className: "min-w-[8rem] flex-1",
|
|
422
|
+
placeholder: "Name (optional)",
|
|
423
|
+
value: newName,
|
|
424
|
+
maxLength: 200,
|
|
425
|
+
onChange: (e) => setNewName(e.target.value),
|
|
426
|
+
"aria-label": "New contact's name",
|
|
427
|
+
autoComplete: "off",
|
|
428
|
+
"data-testid": "call-picker-new-name"
|
|
429
|
+
}
|
|
430
|
+
),
|
|
431
|
+
/* @__PURE__ */ jsx(
|
|
432
|
+
Input,
|
|
433
|
+
{
|
|
434
|
+
className: "min-w-[10rem] flex-1",
|
|
435
|
+
type: "email",
|
|
436
|
+
autoFocus: true,
|
|
437
|
+
placeholder: "name@example.com",
|
|
438
|
+
value: newEmail,
|
|
439
|
+
onChange: (e) => setNewEmail(e.target.value),
|
|
440
|
+
"aria-label": "New contact's e-mail",
|
|
441
|
+
"data-testid": "call-picker-new-email"
|
|
442
|
+
}
|
|
443
|
+
),
|
|
444
|
+
/* @__PURE__ */ jsx(
|
|
445
|
+
Button,
|
|
446
|
+
{
|
|
447
|
+
type: "submit",
|
|
448
|
+
size: "sm",
|
|
449
|
+
disabled: adding || !EMAIL_RE.test(newEmail.trim()),
|
|
450
|
+
"data-testid": "call-picker-new-submit",
|
|
451
|
+
children: "Add"
|
|
452
|
+
}
|
|
453
|
+
),
|
|
454
|
+
/* @__PURE__ */ jsx(
|
|
455
|
+
Button,
|
|
456
|
+
{
|
|
457
|
+
type: "button",
|
|
458
|
+
size: "sm",
|
|
459
|
+
variant: "ghost",
|
|
460
|
+
onClick: () => {
|
|
461
|
+
setNewEmail(null);
|
|
462
|
+
setNewName("");
|
|
463
|
+
},
|
|
464
|
+
children: "Cancel"
|
|
465
|
+
}
|
|
466
|
+
)
|
|
467
|
+
]
|
|
468
|
+
}
|
|
469
|
+
)),
|
|
470
|
+
callExtId && scope === "contacts" && /* @__PURE__ */ jsx(InviteLinks, { callExtId }),
|
|
471
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Agents can\u2019t join calls." })
|
|
472
|
+
] }),
|
|
473
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [
|
|
474
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: () => onOpenChange(false), disabled: busy, children: "Cancel" }),
|
|
475
|
+
/* @__PURE__ */ jsx(Button, { onClick: () => void submit(), disabled: busy, "data-testid": "call-picker-submit", children: busy ? "Working\u2026" : `${actionLabel ?? copy.action}${count ? ` (${count})` : ""}` })
|
|
476
|
+
] })
|
|
477
|
+
] }) });
|
|
478
|
+
}
|
|
479
|
+
function ThreadCallButton({
|
|
480
|
+
conversationId
|
|
481
|
+
}) {
|
|
482
|
+
const arbi = useArbi();
|
|
483
|
+
const { data: conversations } = useConnectedConversations();
|
|
484
|
+
const { workspaceId: workspaceExtId } = useConnectedWorkspace();
|
|
485
|
+
const liveCallId = useCallSession((s) => threadLiveCallId(s, conversationId));
|
|
486
|
+
const isLive = liveCallId !== null;
|
|
487
|
+
const canHost = useCanHostCalls();
|
|
488
|
+
const [picking, setPicking] = useState(false);
|
|
489
|
+
const conversation = conversations.find((c) => c.external_id === conversationId);
|
|
490
|
+
if (!conversation?.is_shared) return null;
|
|
491
|
+
const title = conversation.title ?? null;
|
|
492
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
493
|
+
/* @__PURE__ */ jsx(
|
|
494
|
+
StartCallButton,
|
|
495
|
+
{
|
|
496
|
+
onStart: async () => {
|
|
497
|
+
if (liveCallId && !canHost) return openCall(arbi, { callExtId: liveCallId });
|
|
498
|
+
if (isLive) return startThreadCall(arbi, { threadExtId: conversationId, title, ring: [] });
|
|
499
|
+
setPicking(true);
|
|
500
|
+
return true;
|
|
501
|
+
},
|
|
502
|
+
isLive,
|
|
503
|
+
label: "Call thread members",
|
|
504
|
+
testId: "thread-call-button"
|
|
505
|
+
}
|
|
506
|
+
),
|
|
507
|
+
picking && /* @__PURE__ */ jsx(
|
|
508
|
+
CallPeoplePicker,
|
|
509
|
+
{
|
|
510
|
+
open: true,
|
|
511
|
+
onOpenChange: setPicking,
|
|
512
|
+
scope: "workspace",
|
|
513
|
+
workspaceExtId,
|
|
514
|
+
onSubmit: async ({ ring }) => {
|
|
515
|
+
await startThreadCall(arbi, { threadExtId: conversationId, title, ring });
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
)
|
|
519
|
+
] });
|
|
520
|
+
}
|
|
521
|
+
function ScheduleCallButton({
|
|
522
|
+
conversationId,
|
|
523
|
+
peer,
|
|
524
|
+
variant = "icon",
|
|
525
|
+
className
|
|
526
|
+
}) {
|
|
527
|
+
const callsEnabled = useCanHostCalls();
|
|
528
|
+
const { conversations } = useConversationItems();
|
|
529
|
+
const { data: workspaces = [] } = useWorkspaces();
|
|
530
|
+
const { workspaceId: selectedWorkspaceId, userId: me } = useConnectedWorkspace();
|
|
531
|
+
const { openCalendar } = useBlocksEnvironment();
|
|
532
|
+
if (!callsEnabled) return null;
|
|
533
|
+
const open = () => {
|
|
534
|
+
const conversation = conversationId ? conversations?.find((c) => c.external_id === conversationId) : void 0;
|
|
535
|
+
let people = [];
|
|
536
|
+
if (peer) people = [peer];
|
|
537
|
+
else if (conversation?.is_shared) {
|
|
538
|
+
const workspace = workspaces.find((w) => w.external_id === selectedWorkspaceId);
|
|
539
|
+
people = (workspace?.users ?? []).map((wu) => wu.user);
|
|
540
|
+
}
|
|
541
|
+
requestCalendarComposer({
|
|
542
|
+
title: peer ? `Call with ${getUserDisplayName(peer) || peer.email}` : conversation?.title ?? "",
|
|
543
|
+
conversationId: conversationId ?? null,
|
|
544
|
+
attendees: people.filter((u) => !isAgent(u) && u.external_id !== me).map((u) => ({
|
|
545
|
+
email: u.email,
|
|
546
|
+
user_id: u.external_id,
|
|
547
|
+
name: getUserDisplayName(u) || null
|
|
548
|
+
})),
|
|
549
|
+
addCall: true
|
|
550
|
+
});
|
|
551
|
+
openCalendar();
|
|
552
|
+
};
|
|
553
|
+
return /* @__PURE__ */ jsxs(
|
|
554
|
+
Button,
|
|
555
|
+
{
|
|
556
|
+
type: "button",
|
|
557
|
+
variant: "ghost",
|
|
558
|
+
size: variant === "icon" ? "icon" : "sm",
|
|
559
|
+
className: cn(variant === "icon" && "size-8", className),
|
|
560
|
+
onClick: open,
|
|
561
|
+
"aria-label": "Schedule call",
|
|
562
|
+
title: "Schedule call",
|
|
563
|
+
"data-testid": "schedule-call-button",
|
|
564
|
+
children: [
|
|
565
|
+
/* @__PURE__ */ jsx(CalendarPlus, { className: "size-4" }),
|
|
566
|
+
variant === "label" && /* @__PURE__ */ jsx("span", { className: "ml-1.5", children: "Schedule call" })
|
|
567
|
+
]
|
|
568
|
+
}
|
|
569
|
+
);
|
|
570
|
+
}
|
|
15
571
|
function useMeetingThreadMessages(meetingCallExtId, messageHistory) {
|
|
16
572
|
const hasRecTranscript = useMemo(
|
|
17
573
|
() => !!meetingCallExtId && hasRecordingTranscript(messageHistory, threadTranscriptRef),
|
|
@@ -160,6 +716,32 @@ function PickThreadDialog({
|
|
|
160
716
|
] })
|
|
161
717
|
] }) });
|
|
162
718
|
}
|
|
719
|
+
function MeetingThreadTranscriptAction({
|
|
720
|
+
conversationExtId,
|
|
721
|
+
meetingCallExtId,
|
|
722
|
+
title,
|
|
723
|
+
messages
|
|
724
|
+
}) {
|
|
725
|
+
const { data: call } = useCall(meetingCallExtId);
|
|
726
|
+
const { data: workspaceUsers = [] } = useWorkspaceUsers();
|
|
727
|
+
const lines = useMemo(
|
|
728
|
+
() => threadTranscriptLines(messages, (id) => {
|
|
729
|
+
const user = workspaceUsers.find((wu) => wu.user.external_id === id)?.user;
|
|
730
|
+
return user ? getUserDisplayName(user) : null;
|
|
731
|
+
}),
|
|
732
|
+
[messages, workspaceUsers]
|
|
733
|
+
);
|
|
734
|
+
if (!meetingCallExtId || !call?.is_creator) return null;
|
|
735
|
+
return /* @__PURE__ */ jsx(
|
|
736
|
+
SaveTranscriptToThread,
|
|
737
|
+
{
|
|
738
|
+
title,
|
|
739
|
+
lines,
|
|
740
|
+
excludeConversationExtId: conversationExtId,
|
|
741
|
+
iconOnly: true
|
|
742
|
+
}
|
|
743
|
+
);
|
|
744
|
+
}
|
|
163
745
|
function RecordingCard({
|
|
164
746
|
callExtId,
|
|
165
747
|
recordingExtId,
|
|
@@ -762,6 +1344,81 @@ function MixPlayer({
|
|
|
762
1344
|
] })
|
|
763
1345
|
] });
|
|
764
1346
|
}
|
|
1347
|
+
function MeetingThreadRecordingsAction({
|
|
1348
|
+
meetingCallExtId,
|
|
1349
|
+
title,
|
|
1350
|
+
iconOnly = false
|
|
1351
|
+
}) {
|
|
1352
|
+
const [open, setOpen] = useState(false);
|
|
1353
|
+
const pending = usePendingRecording();
|
|
1354
|
+
useEffect(() => {
|
|
1355
|
+
if (pending) setOpen(true);
|
|
1356
|
+
}, [pending]);
|
|
1357
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1358
|
+
/* @__PURE__ */ jsx(
|
|
1359
|
+
HeaderAction,
|
|
1360
|
+
{
|
|
1361
|
+
label: "Recordings",
|
|
1362
|
+
icon: /* @__PURE__ */ jsx(Disc, { className: "size-3.5", "aria-hidden": true }),
|
|
1363
|
+
iconOnly,
|
|
1364
|
+
onClick: () => setOpen(true),
|
|
1365
|
+
testId: "meeting-recordings"
|
|
1366
|
+
}
|
|
1367
|
+
),
|
|
1368
|
+
open && /* @__PURE__ */ jsx(Dialog, { open: true, onOpenChange: (o) => !o && setOpen(false), children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-2xl", "data-testid": "meeting-recordings-dialog", children: [
|
|
1369
|
+
/* @__PURE__ */ jsxs(DialogHeader, { children: [
|
|
1370
|
+
/* @__PURE__ */ jsx(DialogTitle, { children: "Recordings" }),
|
|
1371
|
+
/* @__PURE__ */ jsx(DialogDescription, { children: "Recordings of this meeting, encrypted under the workspace key. Playing or downloading one decrypts it in this browser." })
|
|
1372
|
+
] }),
|
|
1373
|
+
/* @__PURE__ */ jsx(
|
|
1374
|
+
RecordingsList,
|
|
1375
|
+
{
|
|
1376
|
+
callExtId: meetingCallExtId,
|
|
1377
|
+
title,
|
|
1378
|
+
className: "max-h-[60vh] overflow-y-auto"
|
|
1379
|
+
}
|
|
1380
|
+
)
|
|
1381
|
+
] }) })
|
|
1382
|
+
] });
|
|
1383
|
+
}
|
|
1384
|
+
function ConnectedConversationCallActions() {
|
|
1385
|
+
const conversationId = useArbiSessionState((state) => state.conversationId);
|
|
1386
|
+
const { conversations } = useConversationItems();
|
|
1387
|
+
const conversation = conversationId ? conversations.find((c) => c.external_id === conversationId) : void 0;
|
|
1388
|
+
const meetingCallExtId = conversation?.meeting_call_ext_id ?? null;
|
|
1389
|
+
const { messageHistory } = useConversationData();
|
|
1390
|
+
const threadMessages = useMeetingThreadMessages(meetingCallExtId, messageHistory);
|
|
1391
|
+
const meetingMessages = useMemo(
|
|
1392
|
+
() => meetingCallExtId ? threadMessages.map((m) => ({
|
|
1393
|
+
content: m.content,
|
|
1394
|
+
created_at: m.created_at,
|
|
1395
|
+
tools: m.tools ?? m.meta?.tools
|
|
1396
|
+
})) : [],
|
|
1397
|
+
[meetingCallExtId, threadMessages]
|
|
1398
|
+
);
|
|
1399
|
+
if (!conversationId) return null;
|
|
1400
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1401
|
+
/* @__PURE__ */ jsx(ThreadCallButton, { conversationId }),
|
|
1402
|
+
/* @__PURE__ */ jsx(ScheduleCallButton, { conversationId }),
|
|
1403
|
+
meetingCallExtId && /* @__PURE__ */ jsx(
|
|
1404
|
+
MeetingThreadTranscriptAction,
|
|
1405
|
+
{
|
|
1406
|
+
conversationExtId: conversationId,
|
|
1407
|
+
meetingCallExtId,
|
|
1408
|
+
title: conversation?.title,
|
|
1409
|
+
messages: meetingMessages
|
|
1410
|
+
}
|
|
1411
|
+
),
|
|
1412
|
+
meetingCallExtId && /* @__PURE__ */ jsx(
|
|
1413
|
+
MeetingThreadRecordingsAction,
|
|
1414
|
+
{
|
|
1415
|
+
meetingCallExtId,
|
|
1416
|
+
title: conversation?.title,
|
|
1417
|
+
iconOnly: true
|
|
1418
|
+
}
|
|
1419
|
+
)
|
|
1420
|
+
] });
|
|
1421
|
+
}
|
|
765
1422
|
function joinNames(people, name) {
|
|
766
1423
|
const names = people.map(name);
|
|
767
1424
|
return names.length > 4 ? `${names.slice(0, 4).join(", ")} +${names.length - 4}` : names.join(", ");
|
|
@@ -981,6 +1638,6 @@ function threadTranscriptRuns(messages) {
|
|
|
981
1638
|
};
|
|
982
1639
|
}
|
|
983
1640
|
|
|
984
|
-
export { CallConversationEmpty, PickThreadDialog, ProvisionalSpeakers, RecordingCard, RecordingsList, SaveTranscriptToThread, ThreadCallLogCard, TranscriptEntry, TranscriptRunsContext, threadTranscriptRuns, useCallPersonName, useMeetingThreadMessages, useProvisionalSpeakers, useTranscriptRuns };
|
|
985
|
-
//# sourceMappingURL=chunk-
|
|
986
|
-
//# sourceMappingURL=chunk-
|
|
1641
|
+
export { CallConversationEmpty, CallPeoplePicker, ConnectedConversationCallActions, MeetingThreadRecordingsAction, MeetingThreadTranscriptAction, PickThreadDialog, ProvisionalSpeakers, RecordingCard, RecordingsList, SaveTranscriptToThread, ScheduleCallButton, StartCallButton, ThreadCallButton, ThreadCallLogCard, TranscriptEntry, TranscriptRunsContext, buildCallCandidates, callContactOf, isPickable, matchesQuery, threadTranscriptRuns, useCallPersonName, useMeetingThreadMessages, useProvisionalSpeakers, useTranscriptRuns };
|
|
1642
|
+
//# sourceMappingURL=chunk-TKTNXFAB.js.map
|
|
1643
|
+
//# sourceMappingURL=chunk-TKTNXFAB.js.map
|