@arbidocs/blocks 0.5.178 → 0.5.180
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/{ConnectedCallDock-53JEGRVT.cjs → ConnectedCallDock-PNZNWPOP.cjs} +4 -4
- package/dist/{ConnectedCallDock-53JEGRVT.cjs.map → ConnectedCallDock-PNZNWPOP.cjs.map} +1 -1
- package/dist/{ConnectedCallRoom-DRIDU6Q6.cjs → ConnectedCallRoom-WGL2RNNC.cjs} +4 -4
- package/dist/{ConnectedCallRoom-DRIDU6Q6.cjs.map → ConnectedCallRoom-WGL2RNNC.cjs.map} +1 -1
- package/dist/{avatar-renderer-4OYU4ZD2.cjs → avatar-renderer-F6RDFIJR.cjs} +100 -81
- package/dist/avatar-renderer-F6RDFIJR.cjs.map +1 -0
- package/dist/avatar-wireframe-LM2NL4EY.cjs +55 -0
- package/dist/avatar-wireframe-LM2NL4EY.cjs.map +1 -0
- package/dist/calls/connected/avatar-materials.d.ts +12 -0
- package/dist/calls/connected/avatar-materials.js +79 -0
- package/dist/calls/connected/avatar-materials.js.map +7 -0
- package/dist/calls/connected/avatar-renderer.d.ts +5 -2
- package/dist/calls/connected/avatar-renderer.js +29 -57
- package/dist/calls/connected/avatar-renderer.js.map +2 -2
- package/dist/calls/index.cjs +2 -2
- package/dist/{chunk-KQYFJXR5.cjs → chunk-7UPGJZOJ.cjs} +3 -3
- package/dist/{chunk-KQYFJXR5.cjs.map → chunk-7UPGJZOJ.cjs.map} +1 -1
- package/dist/connect/index.cjs +41 -38
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connection/messenger/ConnectedChatThread.js +5 -1
- package/dist/connection/messenger/ConnectedChatThread.js.map +2 -2
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +5 -5
- package/record/SKILL.md +16 -0
- package/record/render-take.py +36 -17
- package/dist/avatar-renderer-4OYU4ZD2.cjs.map +0 -1
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
ConversationDrafts
|
|
8
8
|
} from "../panels/ConversationPresentation.js";
|
|
9
9
|
import { DmAgentProgress } from "./DmAgentProgress.js";
|
|
10
|
+
import { OwnedAgentCallButton } from "../../calls/connected/OwnedAgentCallButton.js";
|
|
10
11
|
import { Fragment as Fragment2, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
11
12
|
import {
|
|
12
13
|
ChatBubble,
|
|
@@ -447,7 +448,10 @@ function ConnectedChatThread({
|
|
|
447
448
|
{
|
|
448
449
|
draftRef: composerDraft,
|
|
449
450
|
appearance: floating ? "floating" : "standard",
|
|
450
|
-
actions: floating ?
|
|
451
|
+
actions: floating ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
452
|
+
isAgentChat && peerId && /* @__PURE__ */ jsx(OwnedAgentCallButton, { agentId: peerId }),
|
|
453
|
+
floatingControls
|
|
454
|
+
] }) : void 0,
|
|
451
455
|
placeholder: floating ? `Ask ${peer?.given_name || "Assistant"}\u2026` : "Type a message\u2026",
|
|
452
456
|
allowAttachments: !isAgentChat && !floating,
|
|
453
457
|
disabled: !chat && !peerId,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/connection/messenger/ConnectedChatThread.tsx"],
|
|
4
|
-
"sourcesContent": ["import { FloatingAssistantIdentity } from '../../shell/floating-assistant-context'\n/**\n * One open chat thread \u2014 direct (a person, a self-chat, or my personal agent), group or meeting.\n *\n * Container-agnostic: a messenger frames it. Every message is end-to-end encrypted under the chat\n * key (`arbi.chats`); files are encrypted with their own keys and travel in a manifest under the\n * same chat key. A chat has no assistant \u2014 the one exception is the direct chat with my own agent\n * (the PA chat), which runs in the agent\u2019s Home workspace and records browsing changes as\n * context-only notes. A host draws more kinds of message (a call's) with `host.ThreadHistory`.\n */\n\nimport {\n useFloatingConversation,\n FloatingConversationControls,\n ConversationDrafts,\n} from '../panels/ConversationPresentation'\nimport { DmAgentProgress } from './DmAgentProgress'\nimport { Fragment, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react'\nimport {\n ChatBubble,\n DateSeparator,\n DmComposer,\n annotateThread,\n myChatId,\n setOpenChat,\n useAgentDmStatus,\n useArbi,\n useArbiSessionState,\n useChatPost,\n useChatThread,\n useDeleteChatMessage,\n useMarkChatRead,\n useDmFileShares,\n useNotifications,\n userDisplayName,\n useWorkspaces,\n type ChatResponse,\n type ChatThreadMessage,\n type DmFileShareEntry,\n type DmUser,\n} from '@arbidocs/react'\nimport { formatFriendlyDate } from '@arbidocs/react/ui'\nimport {\n MessageAuthor,\n MessageRoot,\n MessageContent,\n MessageBubble,\n MessageBody,\n} from '../../chat/Message'\nimport { CompactChatContext } from '../../chat/CompactChatContext'\nimport { chats } from '@arbidocs/sdk/browser'\nimport { DmAccessRequestBanner, DmThreadFrame } from '../../collaboration/direct-messages/DmParts'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { ChatAttachmentList } from './ChatAttachments'\nimport { ConnectedChatMessageBody } from './ConnectedChatMessageBody'\nimport { DmFileShareCard } from './DmFileShareCard'\nimport { placeThreadEntries, type PlacedThreadEntry } from './thread-entries'\nimport { renderMessengerUser } from './messengerUser'\nimport type { ChatHistoryProps, ChatThreadItem, MessengerHost } from './types'\n\nexport interface ConnectedChatThreadProps {\n /** The chat to show; null for a peer never messaged (the direct chat is created on send). */\n chat: ChatResponse | null\n /** The other party of a direct chat (myself for a self-chat); unset for a group. */\n peer?: DmUser | null\n host?: MessengerHost\n /** Called after a message is sent. */\n onMessageSent?: () => void\n}\n\nconst THREAD_ACCESSORS = {\n senderId: (m: ChatThreadMessage) => m.sender_ext_id ?? '',\n createdAt: (m: ChatThreadMessage) => m.created_at,\n}\n\n/** Don't hand the user `TypeError: Failed to fetch`; our own messages pass through. */\nfunction sendErrorText(err: unknown): string {\n const raw = err instanceof Error ? err.message : ''\n const isNetworkError =\n !raw || /failed to fetch|networkerror|load failed|network request failed/i.test(raw)\n return isNetworkError ? 'Couldn\u2019t send \u2014 check your connection and try again.' : raw\n}\n\n/** Day separators: \"Today\", \"Yesterday\", \"Mar 3\". */\nfunction defaultFormatDay(iso: string): string {\n const raw = formatFriendlyDate(iso, false)\n return raw.charAt(0).toUpperCase() + raw.slice(1)\n}\n\n/** A thread is pinned to its newest message unless the reader scrolled up. */\nconst NEAR_BOTTOM_PX = 80\n\nexport function ConnectedChatThread({\n chat,\n peer,\n host = {},\n onMessageSent,\n}: ConnectedChatThreadProps) {\n const floating = useFloatingConversation()\n const setAssistantIdentity = useContext(FloatingAssistantIdentity)\n const floatingControls = useContext(FloatingConversationControls)\n const arbi = useArbi()\n const { notify } = useBlocksEnvironment()\n const me = myChatId(arbi)\n const drafts = useContext(ConversationDrafts)\n if (drafts && drafts.owner !== me) {\n drafts.entries.clear()\n drafts.owner = me\n }\n const draftKey = peer?.external_id ?? chat?.external_id ?? 'new'\n if (drafts && !drafts.entries.has(draftKey)) drafts.entries.set(draftKey, { current: null })\n const composerDraft = drafts?.entries.get(draftKey)\n\n const selectedWorkspaceId = useArbiSessionState((s) => s.workspaceId)\n const { data: workspaces = [] } = useWorkspaces()\n const workspaceName =\n workspaces.find((workspace) => workspace.external_id === selectedWorkspaceId)?.name ??\n selectedWorkspaceId\n const formatTime = host.formatTime ?? formatFriendlyDate\n const formatDay = host.formatDay ?? defaultFormatDay\n // Personal Assistant chat: the workspace my agent acts in must be usable on this session (its\n // key deposited), without switching to it.\n const prepareAgentWorkspace = useCallback(\n (workspaceId: string) =>\n arbi.workspaces.open(workspaceId).then(\n () => true,\n () => false\n ),\n [arbi]\n )\n\n const isGroup = !!chat && chat.kind !== 'direct'\n const peerId = isGroup ? null : (peer?.external_id ?? null)\n const isAgentChat = !!peerId?.startsWith('agt-')\n\n const { messages, hasMore, isLoading, loadOlder, loadingOlder } = useChatThread(chat)\n const postToChat = useChatPost()\n const deleteChatMessage = useDeleteChatMessage()\n const markRead = useMarkChatRead()\n const [isSending, setIsSending] = useState(false)\n const [sendError, setSendError] = useState<string | null>(null)\n const [awaitingAgentReply, setAwaitingAgentReply] = useState(false)\n const historyRef = useRef<HTMLDivElement>(null)\n\n // A chat created on first send is held here until the caller passes it in.\n const chatRef = useRef<ChatResponse | null>(chat)\n chatRef.current = chat ?? chatRef.current\n\n const membersById = useMemo(() => {\n const map = new Map<string, DmUser>()\n for (const m of chat?.members ?? []) map.set(m.user.external_id, m.user)\n if (peer) map.set(peer.external_id, peer)\n return map\n }, [chat, peer])\n\n // While open: new messages in this chat don't count as unread, and the watermark follows.\n useEffect(() => {\n if (!chat) return\n setOpenChat(chat.external_id)\n return () => setOpenChat(null)\n }, [chat?.external_id]) // eslint-disable-line react-hooks/exhaustive-deps\n\n const newest = messages[messages.length - 1]\n const myReadAt = chat?.members.find((m) => m.user.external_id === me)?.last_read_at\n useEffect(() => {\n if (!chat || !newest || newest.optimistic) return\n const unread =\n chat.unread_count > 0 ||\n (newest.sender_ext_id !== me &&\n (!myReadAt || Date.parse(myReadAt) < Date.parse(newest.created_at)))\n if (!unread) return\n void markRead(chat, newest.external_id)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [chat?.external_id, chat?.unread_count, newest?.external_id])\n\n // Personal agent progress, keyed by the agent.\n const agentDmStatus = useAgentDmStatus(isAgentChat ? peerId : null)\n useEffect(() => {\n if (agentDmStatus?.status === 'done' || agentDmStatus?.status === 'failed') {\n setAwaitingAgentReply(false)\n }\n }, [agentDmStatus])\n useEffect(() => {\n if (awaitingAgentReply && newest && newest.sender_ext_id === peerId) {\n setAwaitingAgentReply(false)\n }\n }, [newest, awaitingAgentReply, peerId])\n const agentWorking =\n awaitingAgentReply || agentDmStatus?.status === 'working' || agentDmStatus?.status === 'queued'\n useEffect(() => {\n setAssistantIdentity?.(peer?.given_name || 'Assistant', agentWorking)\n }, [setAssistantIdentity, peer?.given_name, agentWorking])\n\n // Keep the newest message in view \u2014 also once an image above it has decrypted and grown the\n // thread \u2014 unless the reader has scrolled up.\n const pinnedToBottom = useRef(true)\n const viewport = () =>\n historyRef.current?.querySelector<HTMLElement>('[data-radix-scroll-area-viewport]') ?? null\n const scrollToNewest = useCallback(() => {\n const el = viewport()\n if (el) el.scrollTop = el.scrollHeight\n }, [])\n useEffect(() => {\n pinnedToBottom.current = true\n requestAnimationFrame(scrollToNewest)\n }, [newest?.external_id, scrollToNewest])\n useEffect(() => {\n const el = viewport()\n if (!el) return\n const onScroll = () => {\n pinnedToBottom.current = el.scrollHeight - el.scrollTop - el.clientHeight < NEAR_BOTTOM_PX\n }\n el.addEventListener('scroll', onScroll, { passive: true })\n return () => el.removeEventListener('scroll', onScroll)\n }, [isLoading])\n const onContentLoad = () => {\n if (pinnedToBottom.current) scrollToNewest()\n }\n\n /** Post to the open chat, or to the direct chat with `peer` (created on first send). */\n const post = useCallback(\n async (text: string, files: File[], contextOnly = false, workspace?: string) => {\n const { chat: posted } = await postToChat(\n { chat: chatRef.current, peerExtId: peerId },\n { text, files, contextOnly, ...(workspace ? { workspaceExtId: workspace } : {}) }\n )\n chatRef.current = posted\n },\n [postToChat, peerId]\n )\n\n const contextQueue = useRef<Promise<unknown>>(Promise.resolve())\n\n const handleSend = useCallback(\n async (textToSend: string, files: File[] = []) => {\n if (!textToSend && files.length === 0) return\n setIsSending(true)\n setSendError(null)\n try {\n let workspace: string | undefined\n if (isAgentChat) {\n await contextQueue.current\n if (selectedWorkspaceId) {\n if (!(await prepareAgentWorkspace(selectedWorkspaceId)))\n throw new Error('Could not open the viewed workspace')\n workspace = selectedWorkspaceId\n }\n }\n await post(textToSend, files, false, workspace)\n if (isAgentChat) setAwaitingAgentReply(true)\n onMessageSent?.()\n } catch (err) {\n console.error('[chat] Error sending message:', err)\n setSendError(sendErrorText(err))\n // Rethrow so the composer puts the text back.\n throw err\n } finally {\n setIsSending(false)\n }\n },\n [isAgentChat, selectedWorkspaceId, prepareAgentWorkspace, post, onMessageSent]\n )\n\n // Navigation is context only: the DM master stays in the agent\u2019s Home workspace.\n const lastWorkspace = useRef<{ peer: string; workspace: string } | null>(null)\n useEffect(() => {\n if (!isAgentChat || !peerId || !selectedWorkspaceId || !me) return\n const previous = lastWorkspace.current\n lastWorkspace.current = { peer: peerId, workspace: selectedWorkspaceId }\n if (!previous || previous.peer !== peerId || previous.workspace === selectedWorkspaceId) return\n const workspace = selectedWorkspaceId\n const text = `Now viewing workspace ${workspaceName} (${workspace}).`\n contextQueue.current = contextQueue.current\n .catch(() => undefined)\n .then(async () => {\n if (!(await prepareAgentWorkspace(workspace)))\n throw new Error('Could not open the viewed workspace')\n await post(text, [], true, workspace)\n })\n .catch(() =>\n setSendError(\n 'Could not record the browsing change. Your agent conversation remains in its Home workspace.'\n )\n )\n }, [isAgentChat, peerId, selectedWorkspaceId, workspaceName, me, prepareAgentWorkspace, post])\n\n // The server keeps a deleted message as a tombstone; the cache shows it as one at once.\n const deleteMessage = useCallback(\n async (messageId: string) => {\n const target = chatRef.current\n if (!target || messageId.startsWith('optimistic-')) return\n try {\n await deleteChatMessage(target.external_id, messageId)\n } catch (error) {\n console.error('[chat] Failed to delete message:', error)\n notify('Failed to delete message', 'error')\n }\n },\n [deleteChatMessage, notify]\n )\n\n // An incoming, still-pending workspace access request FROM this peer \u2014 shown as a banner at\n // the top of the thread. Review hands it to the host.\n const { data: allNotifications = [] } = useNotifications()\n const pendingAccessRequest = useMemo(() => {\n if (!peerId || !me || !host.onReviewAccessRequest) return null\n return (\n allNotifications.find(\n (n) =>\n n.type === 'workspace_access_request' &&\n n.sender.external_id === peerId &&\n n.recipient.external_id === me\n ) ?? null\n )\n }, [allNotifications, peerId, me, host.onReviewAccessRequest])\n\n // The files shared between us, each a card in the timeline at its latest event (where its news\n // is), interleaved with the messages. A direct chat with a person only.\n const fileShares = useDmFileShares(isGroup ? null : peer)\n const placement = useMemo(\n () => placeThreadEntries(annotateThread(messages, THREAD_ACCESSORS), fileShares.entries),\n [messages, fileShares.entries]\n )\n const items = placement.items\n // Start at the latest outgoing query: an old reply must not look like a reply to a new query.\n const lastQueryIndex = items.findLastIndex(\n (item) => item.message.sender_ext_id === me && !item.message.context_only\n )\n const lastReplyIndex = items.findLastIndex(\n (item, index) =>\n index > lastQueryIndex &&\n item.message.sender_ext_id !== me &&\n !item.message.context_only &&\n item.message.kind !== 'system'\n )\n const visibleFloatingItems = new Set(\n [lastQueryIndex, lastReplyIndex].filter((index) => index >= 0)\n )\n const memberById = useCallback(\n (id: string | null | undefined) => (id ? membersById.get(id) : undefined),\n [membersById]\n )\n const senderName = useCallback(\n (id: string | null | undefined) => {\n const user = memberById(id)\n return user ? userDisplayName(user) : 'Former member'\n },\n [memberById]\n )\n\n // Someone else's message starts a run (gets their pill) unless the item before it is a typed\n // message from the same person on the same day.\n const startsPeerRun = (i: number) => {\n const previous = items[i - 1]\n return (\n !previous ||\n items[i].isFirstOfDay ||\n previous.message.sender_ext_id !== items[i].message.sender_ext_id\n )\n }\n const renderItem = ({ message: msg, isLastOfRun, isFirstOfDay }: ChatThreadItem, i: number) => {\n const isSent = msg.sender_ext_id === me\n // The server's tombstone of a deleted message (no content to decrypt or show).\n const deleted = !!msg.deleted\n if (msg.context_only) {\n return (\n <DateSeparator key={msg.external_id}>\n {deleted ? 'Workspace note deleted' : msg.content}\n </DateSeparator>\n )\n }\n if (msg.kind === 'system' && !deleted) {\n return <DateSeparator key={msg.external_id}>{msg.content}</DateSeparator>\n }\n // A call, recording or transcript line, for a host that does not draw them itself: one line.\n if (msg.kind !== 'text' && msg.kind !== 'system') {\n // A deleted transcript line is not part of the record (it may be stored again).\n if (deleted && chats.isTranscriptMessage(msg)) return null\n if (!deleted)\n return <DateSeparator key={msg.external_id}>{chats.chatMessagePreview(msg)}</DateSeparator>\n }\n if (isAgentChat && floating && !deleted) {\n const role = isSent ? 'user' : 'assistant'\n return (\n <CompactChatContext.Provider key={msg.external_id} value={floating}>\n <MessageRoot\n role={role}\n messageId={msg.external_id}\n id={msg.external_id}\n data-testid=\"dm-message\"\n className=\"items-start gap-2 px-3 py-2\"\n >\n <span data-testid=\"compact-chat-avatar\" className=\"mt-1.5 shrink-0\">\n {renderMessengerUser(memberById(msg.sender_ext_id) ?? null, 'small-avatar')}\n </span>\n <MessageContent\n role={role}\n messageId={msg.external_id}\n align=\"start\"\n className=\"min-w-0 flex-1\"\n >\n <MessageBubble\n role={role}\n messageId={msg.external_id}\n participantTint={isSent ? undefined : 'var(--color-primary)'}\n className=\"max-w-full\"\n >\n <MessageBody messageId={msg.external_id}>\n {floating && isSent && lastReplyIndex > i ? (\n <div className=\"truncate\" title={msg.content ?? ''}>\n {msg.content}\n </div>\n ) : (\n <ConnectedChatMessageBody\n text={msg.content ?? ''}\n workspaceId={msg.workspace_ext_id ?? null}\n compact={floating && !isSent}\n />\n )}\n </MessageBody>\n </MessageBubble>\n </MessageContent>\n </MessageRoot>\n </CompactChatContext.Provider>\n )\n }\n return (\n <Fragment key={msg.external_id}>\n {!floating && isFirstOfDay && <DateSeparator>{formatDay(msg.created_at)}</DateSeparator>}\n {chat?.kind === 'group' && !isSent && startsPeerRun(i) && (\n <MessageAuthor>\n {renderMessengerUser(memberById(msg.sender_ext_id) ?? null, 'author')}\n </MessageAuthor>\n )}\n <ChatBubble\n appearance={floating ? 'floating' : 'standard'}\n compact={floating && isSent && lastReplyIndex > i}\n id={msg.external_id}\n data-testid=\"dm-message\"\n message={msg.content || ''}\n renderMessage={(text) => (\n <ConnectedChatMessageBody\n text={text}\n workspaceId={msg.workspace_ext_id ?? null}\n compact={floating && !isSent}\n />\n )}\n formatTimestamp={formatTime}\n attachments={\n msg.attachmentFiles?.length || msg.attachmentsError ? (\n <ChatAttachmentList files={msg.attachmentFiles ?? []} error={msg.attachmentsError} />\n ) : undefined\n }\n timestamp={msg.created_at}\n avatar={\n floating\n ? undefined\n : renderMessengerUser(memberById(msg.sender_ext_id) ?? null, 'small-avatar')\n }\n senderName={\n memberById(msg.sender_ext_id)\n ? userDisplayName(memberById(msg.sender_ext_id)!)\n : 'Former member'\n }\n isSent={isSent}\n deleted={deleted}\n read={!!chat && !msg.optimistic && chats.readByOthers(chat, me, msg)}\n isLastOfRun={isLastOfRun}\n onDelete={\n floating || deleted || !isSent ? undefined : () => void deleteMessage(msg.external_id)\n }\n />\n </Fragment>\n )\n }\n\n const renderEntries = (placed: readonly PlacedThreadEntry<DmFileShareEntry>[] = []) =>\n placed.map(({ entry, isFirstOfDay }) => (\n <Fragment key={entry.shareId}>\n {isFirstOfDay && entry.at && <DateSeparator>{formatDay(entry.at)}</DateSeparator>}\n <DmFileShareCard\n entry={entry}\n share={fileShares.shareById.get(entry.shareId)}\n loaded={fileShares.loaded}\n failed={fileShares.failed}\n time={entry.at ? formatTime(entry.at) : undefined}\n />\n </Fragment>\n ))\n const renderEntriesBefore = (index: number) => renderEntries(placement.before.get(index))\n const entriesAfter = renderEntries(placement.after)\n\n const loadOlderButton = hasMore ? (\n <button\n type=\"button\"\n onClick={() => void loadOlder()}\n disabled={loadingOlder}\n className=\"mx-auto my-2 block rounded-full border px-3 py-1 text-xs text-muted-foreground hover:bg-muted disabled:opacity-60\"\n >\n {loadingOlder ? 'Loading\u2026' : 'Load earlier messages'}\n </button>\n ) : null\n\n const historyProps: ChatHistoryProps = {\n chat,\n messages,\n items,\n renderItem,\n renderEntriesBefore,\n entriesAfter,\n loadOlder: loadOlderButton,\n memberById,\n senderName,\n myExtId: me,\n formatTime,\n formatDay,\n }\n const History = floating ? undefined : host.ThreadHistory\n\n return (\n <DmThreadFrame\n floating={floating}\n accessBanner={\n pendingAccessRequest ? (\n <DmAccessRequestBanner\n compact={floating}\n name={peer?.given_name ?? 'They'}\n onReview={() => host.onReviewAccessRequest?.(pendingAccessRequest)}\n />\n ) : undefined\n }\n hasRecipient={!!chat || !!peerId}\n historyRef={historyRef}\n isLoading={isLoading}\n // A call's chat is never the generic empty state: its history says what the call is doing.\n isEmpty={\n messages.length === 0 && fileShares.entries.length === 0 && !(History && chat?.call_ext_id)\n }\n history={\n <div onLoadCapture={onContentLoad} className={floating ? 'space-y-0' : undefined}>\n {History ? (\n <History {...historyProps} />\n ) : (\n <>\n {!floating && loadOlderButton}\n {items.map(\n (item, i) =>\n (!floating || visibleFloatingItems.has(i)) && (\n <Fragment key={item.message.external_id}>\n {!floating && renderEntriesBefore(i)}\n {renderItem(item, i)}\n </Fragment>\n )\n )}\n {!floating && entriesAfter}\n </>\n )}\n {agentWorking && (\n <DmAgentProgress\n compact={floating}\n status={agentDmStatus}\n startedAt={Date.parse(\n [...messages].reverse().find((message) => message.sender_ext_id === me)\n ?.created_at ?? ''\n )}\n onOpenThread={host.openAgentThread}\n />\n )}\n {!agentWorking && agentDmStatus?.status === 'failed' && (\n <p role=\"status\" className=\"px-3 text-sm text-muted-foreground\">\n The agent couldn\u2019t finish this message. Please try again.\n </p>\n )}\n </div>\n }\n composer={\n <div className={floating ? 'pointer-events-auto' : undefined}>\n {isAgentChat && !floating && (\n <p className=\"px-3 pb-1 text-xs text-muted-foreground\">\n Conversation: {peer?.given_name || 'Assistant'} Home\n {workspaceName ? ` \u00B7 Viewing: ${workspaceName}` : ''}\n </p>\n )}\n <DmComposer\n draftRef={composerDraft}\n appearance={floating ? 'floating' : 'standard'}\n actions={floating ? floatingControls : undefined}\n placeholder={floating ? `Ask ${peer?.given_name || 'Assistant'}\u2026` : 'Type a message\u2026'}\n /* Agents read the text of a message only, so files are offered to people. */\n allowAttachments={!isAgentChat && !floating}\n disabled={!chat && !peerId}\n busy={isSending}\n onSend={handleSend}\n error={sendError}\n />\n </div>\n }\n />\n )\n}\n"],
|
|
5
|
-
"mappings": ";AA8WQ,SAiLI,UAjLJ,KAmBE,YAnBF;AA9WR,SAAS,iCAAiC;AAW1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAChC,SAAS,YAAAA,WAAU,aAAa,YAAY,WAAW,SAAS,QAAQ,gBAAgB;AACxF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;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AA,SAEJ;AAAA,MAEF,UACE,qBAAC,SAAI,WAAW,WAAW,wBAAwB,QAChD;AAAA,uBAAe,CAAC,YACf,qBAAC,OAAE,WAAU,2CAA0C;AAAA;AAAA,UACtC,MAAM,cAAc;AAAA,UAAY;AAAA,UAC9C,gBAAgB,kBAAe,aAAa,KAAK;AAAA,WACpD;AAAA,QAEF;AAAA,UAAC;AAAA;AAAA,YACC,UAAU;AAAA,YACV,YAAY,WAAW,aAAa;AAAA,YACpC,SAAS,WAAW,mBAAmB;AAAA,YACvC,aAAa,WAAW,OAAO,MAAM,cAAc,WAAW,WAAM;AAAA,YAEpE,kBAAkB,CAAC,eAAe,CAAC;AAAA,YACnC,UAAU,CAAC,QAAQ,CAAC;AAAA,YACpB,MAAM;AAAA,YACN,QAAQ;AAAA,YACR,OAAO;AAAA;AAAA,QACT;AAAA,SACF;AAAA;AAAA,EAEJ;AAEJ;",
|
|
4
|
+
"sourcesContent": ["import { FloatingAssistantIdentity } from '../../shell/floating-assistant-context'\n/**\n * One open chat thread \u2014 direct (a person, a self-chat, or my personal agent), group or meeting.\n *\n * Container-agnostic: a messenger frames it. Every message is end-to-end encrypted under the chat\n * key (`arbi.chats`); files are encrypted with their own keys and travel in a manifest under the\n * same chat key. A chat has no assistant \u2014 the one exception is the direct chat with my own agent\n * (the PA chat), which runs in the agent\u2019s Home workspace and records browsing changes as\n * context-only notes. A host draws more kinds of message (a call's) with `host.ThreadHistory`.\n */\n\nimport {\n useFloatingConversation,\n FloatingConversationControls,\n ConversationDrafts,\n} from '../panels/ConversationPresentation'\nimport { DmAgentProgress } from './DmAgentProgress'\nimport { OwnedAgentCallButton } from '../../calls/connected/OwnedAgentCallButton'\nimport { Fragment, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react'\nimport {\n ChatBubble,\n DateSeparator,\n DmComposer,\n annotateThread,\n myChatId,\n setOpenChat,\n useAgentDmStatus,\n useArbi,\n useArbiSessionState,\n useChatPost,\n useChatThread,\n useDeleteChatMessage,\n useMarkChatRead,\n useDmFileShares,\n useNotifications,\n userDisplayName,\n useWorkspaces,\n type ChatResponse,\n type ChatThreadMessage,\n type DmFileShareEntry,\n type DmUser,\n} from '@arbidocs/react'\nimport { formatFriendlyDate } from '@arbidocs/react/ui'\nimport {\n MessageAuthor,\n MessageRoot,\n MessageContent,\n MessageBubble,\n MessageBody,\n} from '../../chat/Message'\nimport { CompactChatContext } from '../../chat/CompactChatContext'\nimport { chats } from '@arbidocs/sdk/browser'\nimport { DmAccessRequestBanner, DmThreadFrame } from '../../collaboration/direct-messages/DmParts'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { ChatAttachmentList } from './ChatAttachments'\nimport { ConnectedChatMessageBody } from './ConnectedChatMessageBody'\nimport { DmFileShareCard } from './DmFileShareCard'\nimport { placeThreadEntries, type PlacedThreadEntry } from './thread-entries'\nimport { renderMessengerUser } from './messengerUser'\nimport type { ChatHistoryProps, ChatThreadItem, MessengerHost } from './types'\n\nexport interface ConnectedChatThreadProps {\n /** The chat to show; null for a peer never messaged (the direct chat is created on send). */\n chat: ChatResponse | null\n /** The other party of a direct chat (myself for a self-chat); unset for a group. */\n peer?: DmUser | null\n host?: MessengerHost\n /** Called after a message is sent. */\n onMessageSent?: () => void\n}\n\nconst THREAD_ACCESSORS = {\n senderId: (m: ChatThreadMessage) => m.sender_ext_id ?? '',\n createdAt: (m: ChatThreadMessage) => m.created_at,\n}\n\n/** Don't hand the user `TypeError: Failed to fetch`; our own messages pass through. */\nfunction sendErrorText(err: unknown): string {\n const raw = err instanceof Error ? err.message : ''\n const isNetworkError =\n !raw || /failed to fetch|networkerror|load failed|network request failed/i.test(raw)\n return isNetworkError ? 'Couldn\u2019t send \u2014 check your connection and try again.' : raw\n}\n\n/** Day separators: \"Today\", \"Yesterday\", \"Mar 3\". */\nfunction defaultFormatDay(iso: string): string {\n const raw = formatFriendlyDate(iso, false)\n return raw.charAt(0).toUpperCase() + raw.slice(1)\n}\n\n/** A thread is pinned to its newest message unless the reader scrolled up. */\nconst NEAR_BOTTOM_PX = 80\n\nexport function ConnectedChatThread({\n chat,\n peer,\n host = {},\n onMessageSent,\n}: ConnectedChatThreadProps) {\n const floating = useFloatingConversation()\n const setAssistantIdentity = useContext(FloatingAssistantIdentity)\n const floatingControls = useContext(FloatingConversationControls)\n const arbi = useArbi()\n const { notify } = useBlocksEnvironment()\n const me = myChatId(arbi)\n const drafts = useContext(ConversationDrafts)\n if (drafts && drafts.owner !== me) {\n drafts.entries.clear()\n drafts.owner = me\n }\n const draftKey = peer?.external_id ?? chat?.external_id ?? 'new'\n if (drafts && !drafts.entries.has(draftKey)) drafts.entries.set(draftKey, { current: null })\n const composerDraft = drafts?.entries.get(draftKey)\n\n const selectedWorkspaceId = useArbiSessionState((s) => s.workspaceId)\n const { data: workspaces = [] } = useWorkspaces()\n const workspaceName =\n workspaces.find((workspace) => workspace.external_id === selectedWorkspaceId)?.name ??\n selectedWorkspaceId\n const formatTime = host.formatTime ?? formatFriendlyDate\n const formatDay = host.formatDay ?? defaultFormatDay\n // Personal Assistant chat: the workspace my agent acts in must be usable on this session (its\n // key deposited), without switching to it.\n const prepareAgentWorkspace = useCallback(\n (workspaceId: string) =>\n arbi.workspaces.open(workspaceId).then(\n () => true,\n () => false\n ),\n [arbi]\n )\n\n const isGroup = !!chat && chat.kind !== 'direct'\n const peerId = isGroup ? null : (peer?.external_id ?? null)\n const isAgentChat = !!peerId?.startsWith('agt-')\n\n const { messages, hasMore, isLoading, loadOlder, loadingOlder } = useChatThread(chat)\n const postToChat = useChatPost()\n const deleteChatMessage = useDeleteChatMessage()\n const markRead = useMarkChatRead()\n const [isSending, setIsSending] = useState(false)\n const [sendError, setSendError] = useState<string | null>(null)\n const [awaitingAgentReply, setAwaitingAgentReply] = useState(false)\n const historyRef = useRef<HTMLDivElement>(null)\n\n // A chat created on first send is held here until the caller passes it in.\n const chatRef = useRef<ChatResponse | null>(chat)\n chatRef.current = chat ?? chatRef.current\n\n const membersById = useMemo(() => {\n const map = new Map<string, DmUser>()\n for (const m of chat?.members ?? []) map.set(m.user.external_id, m.user)\n if (peer) map.set(peer.external_id, peer)\n return map\n }, [chat, peer])\n\n // While open: new messages in this chat don't count as unread, and the watermark follows.\n useEffect(() => {\n if (!chat) return\n setOpenChat(chat.external_id)\n return () => setOpenChat(null)\n }, [chat?.external_id]) // eslint-disable-line react-hooks/exhaustive-deps\n\n const newest = messages[messages.length - 1]\n const myReadAt = chat?.members.find((m) => m.user.external_id === me)?.last_read_at\n useEffect(() => {\n if (!chat || !newest || newest.optimistic) return\n const unread =\n chat.unread_count > 0 ||\n (newest.sender_ext_id !== me &&\n (!myReadAt || Date.parse(myReadAt) < Date.parse(newest.created_at)))\n if (!unread) return\n void markRead(chat, newest.external_id)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [chat?.external_id, chat?.unread_count, newest?.external_id])\n\n // Personal agent progress, keyed by the agent.\n const agentDmStatus = useAgentDmStatus(isAgentChat ? peerId : null)\n useEffect(() => {\n if (agentDmStatus?.status === 'done' || agentDmStatus?.status === 'failed') {\n setAwaitingAgentReply(false)\n }\n }, [agentDmStatus])\n useEffect(() => {\n if (awaitingAgentReply && newest && newest.sender_ext_id === peerId) {\n setAwaitingAgentReply(false)\n }\n }, [newest, awaitingAgentReply, peerId])\n const agentWorking =\n awaitingAgentReply || agentDmStatus?.status === 'working' || agentDmStatus?.status === 'queued'\n useEffect(() => {\n setAssistantIdentity?.(peer?.given_name || 'Assistant', agentWorking)\n }, [setAssistantIdentity, peer?.given_name, agentWorking])\n\n // Keep the newest message in view \u2014 also once an image above it has decrypted and grown the\n // thread \u2014 unless the reader has scrolled up.\n const pinnedToBottom = useRef(true)\n const viewport = () =>\n historyRef.current?.querySelector<HTMLElement>('[data-radix-scroll-area-viewport]') ?? null\n const scrollToNewest = useCallback(() => {\n const el = viewport()\n if (el) el.scrollTop = el.scrollHeight\n }, [])\n useEffect(() => {\n pinnedToBottom.current = true\n requestAnimationFrame(scrollToNewest)\n }, [newest?.external_id, scrollToNewest])\n useEffect(() => {\n const el = viewport()\n if (!el) return\n const onScroll = () => {\n pinnedToBottom.current = el.scrollHeight - el.scrollTop - el.clientHeight < NEAR_BOTTOM_PX\n }\n el.addEventListener('scroll', onScroll, { passive: true })\n return () => el.removeEventListener('scroll', onScroll)\n }, [isLoading])\n const onContentLoad = () => {\n if (pinnedToBottom.current) scrollToNewest()\n }\n\n /** Post to the open chat, or to the direct chat with `peer` (created on first send). */\n const post = useCallback(\n async (text: string, files: File[], contextOnly = false, workspace?: string) => {\n const { chat: posted } = await postToChat(\n { chat: chatRef.current, peerExtId: peerId },\n { text, files, contextOnly, ...(workspace ? { workspaceExtId: workspace } : {}) }\n )\n chatRef.current = posted\n },\n [postToChat, peerId]\n )\n\n const contextQueue = useRef<Promise<unknown>>(Promise.resolve())\n\n const handleSend = useCallback(\n async (textToSend: string, files: File[] = []) => {\n if (!textToSend && files.length === 0) return\n setIsSending(true)\n setSendError(null)\n try {\n let workspace: string | undefined\n if (isAgentChat) {\n await contextQueue.current\n if (selectedWorkspaceId) {\n if (!(await prepareAgentWorkspace(selectedWorkspaceId)))\n throw new Error('Could not open the viewed workspace')\n workspace = selectedWorkspaceId\n }\n }\n await post(textToSend, files, false, workspace)\n if (isAgentChat) setAwaitingAgentReply(true)\n onMessageSent?.()\n } catch (err) {\n console.error('[chat] Error sending message:', err)\n setSendError(sendErrorText(err))\n // Rethrow so the composer puts the text back.\n throw err\n } finally {\n setIsSending(false)\n }\n },\n [isAgentChat, selectedWorkspaceId, prepareAgentWorkspace, post, onMessageSent]\n )\n\n // Navigation is context only: the DM master stays in the agent\u2019s Home workspace.\n const lastWorkspace = useRef<{ peer: string; workspace: string } | null>(null)\n useEffect(() => {\n if (!isAgentChat || !peerId || !selectedWorkspaceId || !me) return\n const previous = lastWorkspace.current\n lastWorkspace.current = { peer: peerId, workspace: selectedWorkspaceId }\n if (!previous || previous.peer !== peerId || previous.workspace === selectedWorkspaceId) return\n const workspace = selectedWorkspaceId\n const text = `Now viewing workspace ${workspaceName} (${workspace}).`\n contextQueue.current = contextQueue.current\n .catch(() => undefined)\n .then(async () => {\n if (!(await prepareAgentWorkspace(workspace)))\n throw new Error('Could not open the viewed workspace')\n await post(text, [], true, workspace)\n })\n .catch(() =>\n setSendError(\n 'Could not record the browsing change. Your agent conversation remains in its Home workspace.'\n )\n )\n }, [isAgentChat, peerId, selectedWorkspaceId, workspaceName, me, prepareAgentWorkspace, post])\n\n // The server keeps a deleted message as a tombstone; the cache shows it as one at once.\n const deleteMessage = useCallback(\n async (messageId: string) => {\n const target = chatRef.current\n if (!target || messageId.startsWith('optimistic-')) return\n try {\n await deleteChatMessage(target.external_id, messageId)\n } catch (error) {\n console.error('[chat] Failed to delete message:', error)\n notify('Failed to delete message', 'error')\n }\n },\n [deleteChatMessage, notify]\n )\n\n // An incoming, still-pending workspace access request FROM this peer \u2014 shown as a banner at\n // the top of the thread. Review hands it to the host.\n const { data: allNotifications = [] } = useNotifications()\n const pendingAccessRequest = useMemo(() => {\n if (!peerId || !me || !host.onReviewAccessRequest) return null\n return (\n allNotifications.find(\n (n) =>\n n.type === 'workspace_access_request' &&\n n.sender.external_id === peerId &&\n n.recipient.external_id === me\n ) ?? null\n )\n }, [allNotifications, peerId, me, host.onReviewAccessRequest])\n\n // The files shared between us, each a card in the timeline at its latest event (where its news\n // is), interleaved with the messages. A direct chat with a person only.\n const fileShares = useDmFileShares(isGroup ? null : peer)\n const placement = useMemo(\n () => placeThreadEntries(annotateThread(messages, THREAD_ACCESSORS), fileShares.entries),\n [messages, fileShares.entries]\n )\n const items = placement.items\n // Start at the latest outgoing query: an old reply must not look like a reply to a new query.\n const lastQueryIndex = items.findLastIndex(\n (item) => item.message.sender_ext_id === me && !item.message.context_only\n )\n const lastReplyIndex = items.findLastIndex(\n (item, index) =>\n index > lastQueryIndex &&\n item.message.sender_ext_id !== me &&\n !item.message.context_only &&\n item.message.kind !== 'system'\n )\n const visibleFloatingItems = new Set(\n [lastQueryIndex, lastReplyIndex].filter((index) => index >= 0)\n )\n const memberById = useCallback(\n (id: string | null | undefined) => (id ? membersById.get(id) : undefined),\n [membersById]\n )\n const senderName = useCallback(\n (id: string | null | undefined) => {\n const user = memberById(id)\n return user ? userDisplayName(user) : 'Former member'\n },\n [memberById]\n )\n\n // Someone else's message starts a run (gets their pill) unless the item before it is a typed\n // message from the same person on the same day.\n const startsPeerRun = (i: number) => {\n const previous = items[i - 1]\n return (\n !previous ||\n items[i].isFirstOfDay ||\n previous.message.sender_ext_id !== items[i].message.sender_ext_id\n )\n }\n const renderItem = ({ message: msg, isLastOfRun, isFirstOfDay }: ChatThreadItem, i: number) => {\n const isSent = msg.sender_ext_id === me\n // The server's tombstone of a deleted message (no content to decrypt or show).\n const deleted = !!msg.deleted\n if (msg.context_only) {\n return (\n <DateSeparator key={msg.external_id}>\n {deleted ? 'Workspace note deleted' : msg.content}\n </DateSeparator>\n )\n }\n if (msg.kind === 'system' && !deleted) {\n return <DateSeparator key={msg.external_id}>{msg.content}</DateSeparator>\n }\n // A call, recording or transcript line, for a host that does not draw them itself: one line.\n if (msg.kind !== 'text' && msg.kind !== 'system') {\n // A deleted transcript line is not part of the record (it may be stored again).\n if (deleted && chats.isTranscriptMessage(msg)) return null\n if (!deleted)\n return <DateSeparator key={msg.external_id}>{chats.chatMessagePreview(msg)}</DateSeparator>\n }\n if (isAgentChat && floating && !deleted) {\n const role = isSent ? 'user' : 'assistant'\n return (\n <CompactChatContext.Provider key={msg.external_id} value={floating}>\n <MessageRoot\n role={role}\n messageId={msg.external_id}\n id={msg.external_id}\n data-testid=\"dm-message\"\n className=\"items-start gap-2 px-3 py-2\"\n >\n <span data-testid=\"compact-chat-avatar\" className=\"mt-1.5 shrink-0\">\n {renderMessengerUser(memberById(msg.sender_ext_id) ?? null, 'small-avatar')}\n </span>\n <MessageContent\n role={role}\n messageId={msg.external_id}\n align=\"start\"\n className=\"min-w-0 flex-1\"\n >\n <MessageBubble\n role={role}\n messageId={msg.external_id}\n participantTint={isSent ? undefined : 'var(--color-primary)'}\n className=\"max-w-full\"\n >\n <MessageBody messageId={msg.external_id}>\n {floating && isSent && lastReplyIndex > i ? (\n <div className=\"truncate\" title={msg.content ?? ''}>\n {msg.content}\n </div>\n ) : (\n <ConnectedChatMessageBody\n text={msg.content ?? ''}\n workspaceId={msg.workspace_ext_id ?? null}\n compact={floating && !isSent}\n />\n )}\n </MessageBody>\n </MessageBubble>\n </MessageContent>\n </MessageRoot>\n </CompactChatContext.Provider>\n )\n }\n return (\n <Fragment key={msg.external_id}>\n {!floating && isFirstOfDay && <DateSeparator>{formatDay(msg.created_at)}</DateSeparator>}\n {chat?.kind === 'group' && !isSent && startsPeerRun(i) && (\n <MessageAuthor>\n {renderMessengerUser(memberById(msg.sender_ext_id) ?? null, 'author')}\n </MessageAuthor>\n )}\n <ChatBubble\n appearance={floating ? 'floating' : 'standard'}\n compact={floating && isSent && lastReplyIndex > i}\n id={msg.external_id}\n data-testid=\"dm-message\"\n message={msg.content || ''}\n renderMessage={(text) => (\n <ConnectedChatMessageBody\n text={text}\n workspaceId={msg.workspace_ext_id ?? null}\n compact={floating && !isSent}\n />\n )}\n formatTimestamp={formatTime}\n attachments={\n msg.attachmentFiles?.length || msg.attachmentsError ? (\n <ChatAttachmentList files={msg.attachmentFiles ?? []} error={msg.attachmentsError} />\n ) : undefined\n }\n timestamp={msg.created_at}\n avatar={\n floating\n ? undefined\n : renderMessengerUser(memberById(msg.sender_ext_id) ?? null, 'small-avatar')\n }\n senderName={\n memberById(msg.sender_ext_id)\n ? userDisplayName(memberById(msg.sender_ext_id)!)\n : 'Former member'\n }\n isSent={isSent}\n deleted={deleted}\n read={!!chat && !msg.optimistic && chats.readByOthers(chat, me, msg)}\n isLastOfRun={isLastOfRun}\n onDelete={\n floating || deleted || !isSent ? undefined : () => void deleteMessage(msg.external_id)\n }\n />\n </Fragment>\n )\n }\n\n const renderEntries = (placed: readonly PlacedThreadEntry<DmFileShareEntry>[] = []) =>\n placed.map(({ entry, isFirstOfDay }) => (\n <Fragment key={entry.shareId}>\n {isFirstOfDay && entry.at && <DateSeparator>{formatDay(entry.at)}</DateSeparator>}\n <DmFileShareCard\n entry={entry}\n share={fileShares.shareById.get(entry.shareId)}\n loaded={fileShares.loaded}\n failed={fileShares.failed}\n time={entry.at ? formatTime(entry.at) : undefined}\n />\n </Fragment>\n ))\n const renderEntriesBefore = (index: number) => renderEntries(placement.before.get(index))\n const entriesAfter = renderEntries(placement.after)\n\n const loadOlderButton = hasMore ? (\n <button\n type=\"button\"\n onClick={() => void loadOlder()}\n disabled={loadingOlder}\n className=\"mx-auto my-2 block rounded-full border px-3 py-1 text-xs text-muted-foreground hover:bg-muted disabled:opacity-60\"\n >\n {loadingOlder ? 'Loading\u2026' : 'Load earlier messages'}\n </button>\n ) : null\n\n const historyProps: ChatHistoryProps = {\n chat,\n messages,\n items,\n renderItem,\n renderEntriesBefore,\n entriesAfter,\n loadOlder: loadOlderButton,\n memberById,\n senderName,\n myExtId: me,\n formatTime,\n formatDay,\n }\n const History = floating ? undefined : host.ThreadHistory\n\n return (\n <DmThreadFrame\n floating={floating}\n accessBanner={\n pendingAccessRequest ? (\n <DmAccessRequestBanner\n compact={floating}\n name={peer?.given_name ?? 'They'}\n onReview={() => host.onReviewAccessRequest?.(pendingAccessRequest)}\n />\n ) : undefined\n }\n hasRecipient={!!chat || !!peerId}\n historyRef={historyRef}\n isLoading={isLoading}\n // A call's chat is never the generic empty state: its history says what the call is doing.\n isEmpty={\n messages.length === 0 && fileShares.entries.length === 0 && !(History && chat?.call_ext_id)\n }\n history={\n <div onLoadCapture={onContentLoad} className={floating ? 'space-y-0' : undefined}>\n {History ? (\n <History {...historyProps} />\n ) : (\n <>\n {!floating && loadOlderButton}\n {items.map(\n (item, i) =>\n (!floating || visibleFloatingItems.has(i)) && (\n <Fragment key={item.message.external_id}>\n {!floating && renderEntriesBefore(i)}\n {renderItem(item, i)}\n </Fragment>\n )\n )}\n {!floating && entriesAfter}\n </>\n )}\n {agentWorking && (\n <DmAgentProgress\n compact={floating}\n status={agentDmStatus}\n startedAt={Date.parse(\n [...messages].reverse().find((message) => message.sender_ext_id === me)\n ?.created_at ?? ''\n )}\n onOpenThread={host.openAgentThread}\n />\n )}\n {!agentWorking && agentDmStatus?.status === 'failed' && (\n <p role=\"status\" className=\"px-3 text-sm text-muted-foreground\">\n The agent couldn\u2019t finish this message. Please try again.\n </p>\n )}\n </div>\n }\n composer={\n <div className={floating ? 'pointer-events-auto' : undefined}>\n {isAgentChat && !floating && (\n <p className=\"px-3 pb-1 text-xs text-muted-foreground\">\n Conversation: {peer?.given_name || 'Assistant'} Home\n {workspaceName ? ` \u00B7 Viewing: ${workspaceName}` : ''}\n </p>\n )}\n <DmComposer\n draftRef={composerDraft}\n appearance={floating ? 'floating' : 'standard'}\n actions={\n floating ? (\n <>\n {isAgentChat && peerId && <OwnedAgentCallButton agentId={peerId} />}\n {floatingControls}\n </>\n ) : undefined\n }\n placeholder={floating ? `Ask ${peer?.given_name || 'Assistant'}\u2026` : 'Type a message\u2026'}\n /* Agents read the text of a message only, so files are offered to people. */\n allowAttachments={!isAgentChat && !floating}\n disabled={!chat && !peerId}\n busy={isSending}\n onSend={handleSend}\n error={sendError}\n />\n </div>\n }\n />\n )\n}\n"],
|
|
5
|
+
"mappings": ";AA+WQ,SAiLI,UAjLJ,KAmBE,YAnBF;AA/WR,SAAS,iCAAiC;AAW1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AACrC,SAAS,YAAAA,WAAU,aAAa,YAAY,WAAW,SAAS,QAAQ,gBAAgB;AACxF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA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AA0C;AAAA;AAAA,UACtC,MAAM,cAAc;AAAA,UAAY;AAAA,UAC9C,gBAAgB,kBAAe,aAAa,KAAK;AAAA,WACpD;AAAA,QAEF;AAAA,UAAC;AAAA;AAAA,YACC,UAAU;AAAA,YACV,YAAY,WAAW,aAAa;AAAA,YACpC,SACE,WACE,iCACG;AAAA,6BAAe,UAAU,oBAAC,wBAAqB,SAAS,QAAQ;AAAA,cAChE;AAAA,eACH,IACE;AAAA,YAEN,aAAa,WAAW,OAAO,MAAM,cAAc,WAAW,WAAM;AAAA,YAEpE,kBAAkB,CAAC,eAAe,CAAC;AAAA,YACnC,UAAU,CAAC,QAAQ,CAAC;AAAA,YACpB,MAAM;AAAA,YACN,QAAQ;AAAA,YACR,OAAO;AAAA;AAAA,QACT;AAAA,SACF;AAAA;AAAA,EAEJ;AAEJ;",
|
|
6
6
|
"names": ["Fragment"]
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arbidocs/coedit",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.180",
|
|
4
4
|
"description": "Real-time collaboration for the ARBI native DOCX editor: a Yjs mirror of the canonical OOXML package, session, and server runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arbidocs/blocks",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.180",
|
|
4
4
|
"description": "Composable, domain-neutral UI blocks for ARBI apps, organised by capability (retrieval, facts, agents, workspaces, citations, collaboration) plus shell, theme and site primitives, on top of @arbidocs/react.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -356,9 +356,9 @@
|
|
|
356
356
|
"custom-site:test:e2e": "playwright test -c examples/custom-site/playwright.config.ts"
|
|
357
357
|
},
|
|
358
358
|
"dependencies": {
|
|
359
|
-
"@arbidocs/client": "0.5.
|
|
360
|
-
"@arbidocs/coedit": "0.5.
|
|
361
|
-
"@arbidocs/sdk": "0.5.
|
|
359
|
+
"@arbidocs/client": "0.5.180",
|
|
360
|
+
"@arbidocs/coedit": "0.5.180",
|
|
361
|
+
"@arbidocs/sdk": "0.5.180",
|
|
362
362
|
"@auth0/auth0-react": "^2.19.0",
|
|
363
363
|
"@dnd-kit/core": "^6.3.1",
|
|
364
364
|
"@dnd-kit/sortable": "^10.0.0",
|
|
@@ -411,7 +411,7 @@
|
|
|
411
411
|
"y-protocols": "^1.0.6"
|
|
412
412
|
},
|
|
413
413
|
"peerDependencies": {
|
|
414
|
-
"@arbidocs/react": "0.5.
|
|
414
|
+
"@arbidocs/react": "0.5.180",
|
|
415
415
|
"@lexical/html": "0.35.0",
|
|
416
416
|
"@lexical/link": "0.35.0",
|
|
417
417
|
"@lexical/list": "0.35.0",
|
package/record/SKILL.md
CHANGED
|
@@ -124,3 +124,19 @@ viewport, `workers: 1`, a long `timeout`; the edit scales 1600x900 to 1080p.
|
|
|
124
124
|
(`cover`), the accent rule and kicker, the caption bar (`ink`), the cursor colour.
|
|
125
125
|
- **The camera.** Zoom at most `maxZoom` (default 1.8), picture-in-picture for long typing; turn
|
|
126
126
|
either off per story in `cine.take` (`zoom: false`, `pip: false`) rather than per render.
|
|
127
|
+
|
|
128
|
+
## Audio and captured video clocks
|
|
129
|
+
|
|
130
|
+
A browser's captured video timestamps can differ from the take/audio clock by hundreds of
|
|
131
|
+
milliseconds. For an export with recorded audio, render with `--timeline-clock take`: the studio
|
|
132
|
+
uses its recorded timecode/sync anchors to sample the original captured frames on the take clock.
|
|
133
|
+
Attach the original continuous audio using its measured AudioContext capture offset, then apply
|
|
134
|
+
identical cuts to both streams. `scripts/finish-assistant-call.cjs` selects this mode automatically
|
|
135
|
+
and refuses a video-clock plan for remuxing. The plan records its master clock and source anchors.
|
|
136
|
+
The voice is never stretched, resynthesized or manually shifted to fit lips.
|
|
137
|
+
|
|
138
|
+
For latency evidence retain every conversational pause (`--head 9999 --min 9999`), preserve the
|
|
139
|
+
original take, and measure visible motion against its recorded clock. A wait interval must never
|
|
140
|
+
include somebody speaking. Screenshots taken during a video must be full-page: an element
|
|
141
|
+
screenshot can temporarily change Chromium's screencast clip and corrupt frames; crop saved frames
|
|
142
|
+
only after capture. Review both source and final frames plus audio before delivery.
|
package/record/render-take.py
CHANGED
|
@@ -46,6 +46,9 @@ import tempfile
|
|
|
46
46
|
import cv2
|
|
47
47
|
import numpy as np
|
|
48
48
|
|
|
49
|
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
50
|
+
from recording_clock import RecordingClock, retimed_frames, uncut_time
|
|
51
|
+
|
|
49
52
|
FPS = 25
|
|
50
53
|
W, H = 1920, 1080
|
|
51
54
|
INK_BGR = (26, 16, 8) # brand ink #08101a, for letterboxing a take of another shape
|
|
@@ -644,6 +647,8 @@ def main():
|
|
|
644
647
|
ap.add_argument("out")
|
|
645
648
|
ap.add_argument("--waits")
|
|
646
649
|
ap.add_argument("--focus")
|
|
650
|
+
ap.add_argument("--timeline-clock", choices=["video", "take"], default="video",
|
|
651
|
+
help="take retimes original frames to recorded wall-clock anchors; preserves natural audio")
|
|
647
652
|
ap.add_argument("--no-zoom", action="store_true")
|
|
648
653
|
ap.add_argument("--no-pip", action="store_true")
|
|
649
654
|
ap.add_argument("--max-zoom", type=float)
|
|
@@ -658,6 +663,7 @@ def main():
|
|
|
658
663
|
args = ap.parse_args()
|
|
659
664
|
|
|
660
665
|
sw, sh, duration = probe(args.src)
|
|
666
|
+
captured_duration = duration
|
|
661
667
|
waits = []
|
|
662
668
|
if args.waits and os.path.exists(args.waits):
|
|
663
669
|
data = json.load(open(args.waits))
|
|
@@ -692,16 +698,16 @@ def main():
|
|
|
692
698
|
else:
|
|
693
699
|
print(f"take {duration:.1f} s, clock offset {offset:+.2f} s")
|
|
694
700
|
|
|
701
|
+
measured_clock = RecordingClock(*clock) if clock else RecordingClock([0.0], [offset])
|
|
702
|
+
if args.timeline_clock == "take":
|
|
703
|
+
if clock is None and (tl.get("sync") is None or at is None):
|
|
704
|
+
sys.exit("Take-clock audio export requires recorded timecode or a sync marker")
|
|
705
|
+
duration = measured_clock.take_at(captured_duration)
|
|
706
|
+
|
|
695
707
|
def v(t):
|
|
696
708
|
if t is None:
|
|
697
709
|
return None
|
|
698
|
-
if
|
|
699
|
-
return t + offset
|
|
700
|
-
if t <= tt[0]:
|
|
701
|
-
return vt[0] + (t - tt[0])
|
|
702
|
-
if t >= tt[-1]:
|
|
703
|
-
return vt[-1] + (t - tt[-1])
|
|
704
|
-
return float(np.interp(t, tt, vt))
|
|
710
|
+
return t if args.timeline_clock == "take" else measured_clock.video_at(t)
|
|
705
711
|
|
|
706
712
|
# 2. Cuts, on the video's clock.
|
|
707
713
|
cuts = []
|
|
@@ -892,9 +898,11 @@ def main():
|
|
|
892
898
|
|
|
893
899
|
# 6. Frames: decode the cut take, draw the camera, the inset and the callouts, encode.
|
|
894
900
|
select = "+".join(f"between(t,{a:.3f},{b:.3f})" for a, b, _ in cuts) or "0"
|
|
901
|
+
frame_selection = (f"fps={FPS}," if args.timeline_clock == "take" else
|
|
902
|
+
f"select='not({select})',setpts=N/({FPS}*TB),")
|
|
895
903
|
dec = subprocess.Popen(
|
|
896
904
|
["ffmpeg", "-v", "error", "-i", args.src, "-an", "-vf",
|
|
897
|
-
|
|
905
|
+
frame_selection +
|
|
898
906
|
f"scale={W}:{H}:force_original_aspect_ratio=decrease:flags=lanczos,pad={W}:{H}:(ow-iw)/2:(oh-ih)/2:color=0x08101a",
|
|
899
907
|
"-r", str(FPS), "-f", "rawvideo", "-pix_fmt", "bgr24", "-"], stdout=subprocess.PIPE)
|
|
900
908
|
enc = subprocess.Popen(
|
|
@@ -904,15 +912,21 @@ def main():
|
|
|
904
912
|
stdin=subprocess.PIPE)
|
|
905
913
|
parchment = np.array([230, 239, 243], np.float32)
|
|
906
914
|
frame_bytes = W * H * 3
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
915
|
+
def legacy_frames():
|
|
916
|
+
n = 0
|
|
917
|
+
while True:
|
|
918
|
+
buf = dec.stdout.read(frame_bytes)
|
|
919
|
+
if len(buf) < frame_bytes:
|
|
920
|
+
break
|
|
921
|
+
t = n / FPS
|
|
922
|
+
n += 1
|
|
923
|
+
if t <= total + 0.5:
|
|
924
|
+
yield t, buf
|
|
925
|
+
|
|
926
|
+
frames = (retimed_frames(dec.stdout, frame_bytes, total, FPS,
|
|
927
|
+
lambda t: measured_clock.video_at(uncut_time(t, cuts)))
|
|
928
|
+
if args.timeline_clock == "take" else legacy_frames())
|
|
929
|
+
for t, buf in frames:
|
|
916
930
|
frame = np.frombuffer(buf, np.uint8).reshape(H, W, 3)
|
|
917
931
|
touched = False
|
|
918
932
|
if timecode:
|
|
@@ -949,12 +963,17 @@ def main():
|
|
|
949
963
|
blend(frame, inset, inner * a, px_, py_ + dy)
|
|
950
964
|
enc.stdin.write(frame.tobytes() if touched else buf)
|
|
951
965
|
enc.stdin.close()
|
|
966
|
+
while dec.stdout.read(frame_bytes):
|
|
967
|
+
pass # Drain any source tail excluded by the closing card without buffering it.
|
|
952
968
|
dec.wait()
|
|
953
969
|
if enc.wait() != 0:
|
|
954
970
|
sys.exit("ffmpeg could not encode the video")
|
|
955
971
|
|
|
956
972
|
# 7. The plan beside the video, and stills of each effect for a check.
|
|
957
973
|
plan = {
|
|
974
|
+
"timeline_clock": args.timeline_clock, "timeline_duration": duration,
|
|
975
|
+
"captured_duration": captured_duration,
|
|
976
|
+
"clock_anchors": {"take": measured_clock.take, "video": measured_clock.video},
|
|
958
977
|
"duration": total, "offset": offset, "cuts": [(a, b, w) for a, b, w in cuts],
|
|
959
978
|
"shots": [{"in": s_["in"], "out": s_["out"], "labels": [k_["label"] for k_ in s_["keys"]],
|
|
960
979
|
"zoom": round(W / min(k_["rect"][2] for k_ in s_["keys"]), 2)} for s_ in shots],
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/calls/connected/avatar-framing.ts","../src/calls/connected/avatar-wireframe.ts","../src/calls/connected/avatar-renderer.ts"],"names":["THREE","MeshoptSimplifier","THREE2","GLTFLoader","THREE3","OrbitControls"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,IAAM,kBAAA,GAAqB,KAAK,EAAA,GAAK,CAAA;AAGrC,SAAS,WAAA,CACd,MAAA,EACA,QAAA,EACA,QAAA,EACA;AACA,EAAA,MAAM,SAAS,IAAUA,iBAAA,CAAA,IAAA;AAAA,IACvB,IAAUA,iBAAA,CAAA,OAAA,CAAQ,GAAG,QAAA,CAAS,aAAa,GAAG,CAAA;AAAA,IAC9C,IAAUA,iBAAA,CAAA,OAAA,CAAQ,GAAG,QAAA,CAAS,aAAa,GAAG;AAAA,GAChD;AACA,EAAA,MAAM,IAAA,GAAO,MAAA,CAAO,OAAA,CAAQ,IAAUA,iBAAA,CAAA,OAAA,EAAS,CAAA,EAC7C,MAAA,GAAS,MAAA,CAAO,SAAA,CAAU,IAAUA,iBAAA,CAAA,OAAA,EAAS,CAAA;AAC/C,EAAA,MAAM,IAAA,GAAO,IAAUA,iBAAA,CAAA,OAAA,CAAQ,GAAG,SAAS,UAAU,CAAA,EACnD,UAAA,GAAa,QAAA,CAAS,UAAA,GAAa,IAAA;AACrC,EAAA,IAAI,QAAQ,QAAA,CAAS,KAAA,EACnB,SAAS,CAAA,EACT,MAAA,GAAS,GACT,MAAA,GAAS,CAAA;AACX,EAAA,MAAM,UAA2B,EAAC;AAClC,EAAA,KAAA,MAAW,KAAK,CAAC,MAAA,CAAO,IAAI,CAAA,EAAG,MAAA,CAAO,IAAI,CAAC,CAAA;AACzC,IAAA,KAAA,MAAW,KAAK,CAAC,MAAA,CAAO,IAAI,CAAA,EAAG,MAAA,CAAO,IAAI,CAAC,CAAA;AACzC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A,IAAK,KAAA,CAAM,OAAA,CAAQ,IAAA,CAAK,QAAQ,IAAI,IAAA,CAAK,QAAA,GAAW,CAAC,IAAA,CAAK,QAAQ,CAAA;AAC3E,UAAA,SAAA,CAAU,IAAI,CAAC,CAAA;AAAA,MACnB;AAAA,IACF,CAAC,CAAA;AACD,IAAA,KAAA,MAAW,QAAA,IAAY,UAAA,EAAY,QAAA,CAAS,OAAA,EAAQ;AACpD,IAAA,KAAA,MAAW,QAAA,IAAY,SAAA,EAAW,QAAA,CAAS,OAAA,EAAQ;AACnD,IAAA,QAAA,CAAS,OAAA,EAAQ;AACjB,IAAA,QAAA,CAAS,WAAW,MAAA,EAAO;AAAA,EAC7B,CAAA;AACF","file":"avatar-renderer-4OYU4ZD2.cjs","sourcesContent":["import * as THREE from 'three'\nimport type { OrbitControls } from 'three/addons/controls/OrbitControls.js'\n\nexport interface HeadClearance {\n conservative: { min: [number, number, number]; max: [number, number, number] }\n cropY: number\n baseCenter: [number, number, number]\n baseRadius: number\n}\n\nexport const PROJECTION_MAX_YAW = Math.PI / 6\n\n/** Fit once to the protected animated portrait; mouth movement never changes the camera. */\nexport function frameAvatar(\n camera: THREE.PerspectiveCamera,\n controls: OrbitControls,\n measured: HeadClearance\n) {\n const bounds = new THREE.Box3(\n new THREE.Vector3(...measured.conservative.min),\n new THREE.Vector3(...measured.conservative.max)\n )\n const size = bounds.getSize(new THREE.Vector3()),\n center = bounds.getCenter(new THREE.Vector3())\n const base = new THREE.Vector3(...measured.baseCenter),\n ringRadius = measured.baseRadius * 1.05\n let ringY = measured.cropY,\n radius = 0,\n focusY = 0,\n focusZ = 0\n const corners: THREE.Vector3[] = []\n for (const x of [bounds.min.x, bounds.max.x])\n for (const y of [bounds.min.y, bounds.max.y])\n for (const z of [bounds.min.z, bounds.max.z]) corners.push(new THREE.Vector3(x, y, z))\n const setView = (degrees: number) => {\n const angle = THREE.MathUtils.degToRad(degrees)\n camera.position.set(\n center.x + radius * Math.sin(angle),\n focusY,\n focusZ + radius * Math.cos(angle)\n )\n controls.target.set(center.x, focusY, focusZ)\n controls.update()\n camera.updateMatrixWorld(true)\n }\n for (let iteration = 0; iteration < 100; iteration++) {\n const fit = bounds.clone()\n fit.min.y = ringY\n fit.expandByPoint(\n new THREE.Vector3(base.x - ringRadius * 1.093, ringY, base.z - ringRadius * 1.093)\n )\n fit.expandByPoint(\n new THREE.Vector3(base.x + ringRadius * 1.093, ringY, base.z + ringRadius * 1.093)\n )\n const fitSize = fit.getSize(new THREE.Vector3())\n const focus = fit.getCenter(new THREE.Vector3())\n focusY = focus.y\n focusZ = focus.z\n // Fit the portrait's box rather than its sphere: a sphere wastes most of a short call tile.\n radius =\n (Math.max(fitSize.y, fitSize.x / Math.min(camera.aspect, 1)) /\n (2 * Math.tan(THREE.MathUtils.degToRad(camera.getEffectiveFOV() / 2))) +\n fitSize.z / 2) *\n 1.14\n const clear = [0, 15, THREE.MathUtils.radToDeg(PROJECTION_MAX_YAW)].every((angle) => {\n setView(angle)\n const bottom = Math.max(...corners.map((p) => (1 - p.clone().project(camera).y) * 540))\n const ringTop = Math.min(\n ...Array.from({ length: 128 }, (_, i) => {\n const a = (i / 128) * Math.PI * 2\n return (\n (1 -\n new THREE.Vector3(\n base.x + ringRadius * 1.093 * Math.cos(a),\n ringY,\n base.z + ringRadius * 1.093 * Math.sin(a)\n ).project(camera).y) *\n 540\n )\n })\n )\n return ringTop - bottom >= 12\n })\n if (clear) break\n ringY -= size.y * 0.01\n if (iteration === 99) throw new Error('Cannot frame the avatar safely')\n }\n setView(0)\n return { cropY: measured.cropY, ringRadius, ringY, base, radius, setView }\n}\n","import * as THREE from 'three'\nimport { MeshoptSimplifier } from 'meshoptimizer/simplifier'\n\n/** Meshoptimizer's index-only LOD keeps native morph deltas and skinning buffers unchanged.\n * Call tiles need fewer visible edges than the full-resolution stock research preview.\n * https://github.com/zeux/meshoptimizer/blob/master/js/README.md#simplifier\n */\nexport async function projectionGeometry(source: THREE.BufferGeometry) {\n await MeshoptSimplifier.ready\n const position = source.getAttribute('position')\n const positions = new Float32Array(position.count * 3)\n for (let i = 0; i < position.count; i++) {\n positions.set([position.getX(i), position.getY(i), position.getZ(i)], i * 3)\n }\n const original = source.index\n ? Uint32Array.from(source.index.array)\n : Uint32Array.from({ length: position.count }, (_, i) => i)\n const target = Math.min(original.length, 4500 * 3)\n const [indices, error] = MeshoptSimplifier.simplify(original, positions, 3, target, 0.01, [\n 'LockBorder',\n 'Regularize',\n ])\n const geometry = new THREE.BufferGeometry()\n for (const [name, attribute] of Object.entries(source.attributes))\n geometry.setAttribute(name, attribute)\n geometry.morphAttributes = source.morphAttributes\n geometry.morphTargetsRelative = source.morphTargetsRelative\n geometry.setIndex(new THREE.BufferAttribute(indices, 1))\n geometry.boundingBox = source.boundingBox?.clone() ?? null\n geometry.boundingSphere = source.boundingSphere?.clone() ?? null\n geometry.userData = { sourceTriangles: original.length / 3, triangles: indices.length / 3, error }\n return geometry\n}\n","import * as THREE from 'three'\nimport { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js'\nimport { OrbitControls } from 'three/addons/controls/OrbitControls.js'\nimport type { CallMediaPlayer } from '@arbidocs/react/calls'\nimport { frameAvatar, PROJECTION_MAX_YAW, type HeadClearance } from './avatar-framing'\nimport { projectionGeometry } from './avatar-wireframe'\n\ninterface BlinkRecipe {\n times: number[]\n values: number[]\n}\nexport interface AvatarAssets {\n model: ArrayBuffer\n clearance: HeadClearance\n blinks: BlinkRecipe\n}\n\n/** The approved stock rigs and wire materials, with their original morph deltas. */\nexport async function createAvatarRenderer(\n host: HTMLElement,\n assets: AvatarAssets,\n player: () => CallMediaPlayer | undefined\n) {\n const gltf = await new GLTFLoader().parseAsync(assets.model, '')\n const meshes: THREE.Mesh[] = []\n gltf.scene.traverse((item) => {\n if (item instanceof THREE.Mesh) meshes.push(item)\n })\n const projections = new Map<THREE.Mesh, THREE.BufferGeometry>()\n for (const mesh of meshes)\n if (mesh.name.toLowerCase().includes('head'))\n projections.set(mesh, await projectionGeometry(mesh.geometry))\n const renderer = new THREE.WebGLRenderer({\n antialias: true,\n alpha: false,\n preserveDrawingBuffer: true,\n })\n renderer.domElement.dataset.callVideo = 'true'\n renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.5))\n renderer.localClippingEnabled = true\n renderer.toneMapping = THREE.ACESFilmicToneMapping\n renderer.domElement.setAttribute('aria-label', 'Assistant 3D projection. Drag to rotate.')\n host.append(renderer.domElement)\n const scene = new THREE.Scene()\n scene.background = new THREE.Color('#020713')\n const initialBox = host.getBoundingClientRect()\n const camera = new THREE.PerspectiveCamera(\n 34,\n initialBox.width / initialBox.height || 1,\n 0.01,\n 10\n )\n const controls = new OrbitControls(camera, renderer.domElement)\n controls.enableDamping = true\n controls.enablePan = false\n controls.enableZoom = false\n controls.rotateSpeed = 0.25\n controls.minPolarAngle = Math.PI / 2 - 0.15\n controls.maxPolarAngle = Math.PI / 2 + 0.15\n controls.minAzimuthAngle = -PROJECTION_MAX_YAW\n controls.maxAzimuthAngle = PROJECTION_MAX_YAW\n scene.add(new THREE.HemisphereLight(0x3388cf, 0x02050b, 0.6))\n for (const [color, intensity, position] of [\n [0x67d6ff, 1.8, [0.5, 2, 0.8]],\n [0x005fff, 2, [-0.4, 1.9, -0.3]],\n ] as const) {\n const light = new THREE.DirectionalLight(color, intensity)\n light.position.set(position[0], position[1], position[2])\n scene.add(light)\n }\n const root = gltf.scene\n scene.add(root)\n const framing = frameAvatar(camera, controls, assets.clearance)\n const reportView = () => {\n const angle = controls.getAzimuthalAngle()\n renderer.domElement.dataset.viewYaw = Math.abs(angle) < 0.0001 ? '0.0000' : angle.toFixed(4)\n }\n controls.addEventListener('change', reportView)\n reportView()\n controls.minDistance = framing.radius * 0.75\n controls.maxDistance = framing.radius * 2.5\n const clippingPlanes = [new THREE.Plane(new THREE.Vector3(0, 1, 0), -framing.cropY)]\n const surface = new THREE.MeshBasicMaterial({\n colorWrite: false,\n polygonOffset: true,\n polygonOffsetFactor: 1,\n polygonOffsetUnits: 1,\n clippingPlanes,\n })\n const wire = new THREE.MeshBasicMaterial({\n color: 0x33cfff,\n toneMapped: false,\n wireframe: true,\n transparent: true,\n opacity: 0.65,\n depthWrite: false,\n blending: THREE.NormalBlending,\n clippingPlanes,\n })\n const eye = new THREE.MeshStandardMaterial({\n color: 0x041b2c,\n emissive: 0x04344c,\n emissiveIntensity: 0.2,\n roughness: 0.25,\n metalness: 0.3,\n clippingPlanes,\n })\n const inside = new THREE.MeshStandardMaterial({\n color: 0x00233c,\n emissive: 0x002344,\n emissiveIntensity: 0.25,\n roughness: 0.8,\n clippingPlanes,\n })\n const originalMaterials = new Set<THREE.Material>()\n const originalGeometries = new Set<THREE.BufferGeometry>()\n for (const mesh of meshes) {\n originalGeometries.add(mesh.geometry)\n for (const material of Array.isArray(mesh.material) ? mesh.material : [mesh.material])\n originalMaterials.add(material)\n const name = mesh.name.toLowerCase()\n if (['eyelashes', 'tearline', 'lens', 'cornea'].some((part) => name.includes(part))) {\n mesh.visible = false\n continue\n }\n mesh.frustumCulled = false\n if (name.includes('head')) {\n mesh.geometry = projections.get(mesh)!\n mesh.material = surface\n const overlay = mesh.clone(false)\n overlay.material = wire\n overlay.morphTargetInfluences = mesh.morphTargetInfluences\n if (mesh instanceof THREE.SkinnedMesh && overlay instanceof THREE.SkinnedMesh)\n overlay.bind(mesh.skeleton, mesh.bindMatrix)\n overlay.renderOrder = 2\n mesh.parent!.add(overlay)\n } else mesh.material = name.includes('choroid') ? eye : inside\n }\n for (const [inner, outer, opacity] of [\n [0.99, 1, 0.32],\n [1.09, 1.093, 0.16],\n ]) {\n const ring = new THREE.Mesh(\n new THREE.RingGeometry(framing.ringRadius * inner, framing.ringRadius * outer, 128),\n new THREE.MeshBasicMaterial({\n color: 0x1d8fce,\n side: THREE.DoubleSide,\n transparent: true,\n opacity,\n })\n )\n ring.rotation.x = -Math.PI / 2\n ring.position.set(framing.base.x, framing.ringY, framing.base.z)\n scene.add(ring)\n }\n let previousAspect = camera.aspect\n const resize = () => {\n const { width, height } = host.getBoundingClientRect()\n if (!width || !height) return\n const aspect = width / height\n camera.position\n .sub(controls.target)\n .multiplyScalar(Math.min(previousAspect, 1) / Math.min(aspect, 1))\n .add(controls.target)\n previousAspect = aspect\n camera.aspect = aspect\n camera.updateProjectionMatrix()\n renderer.setSize(width, height)\n }\n const observer = new ResizeObserver(resize)\n observer.observe(host)\n resize()\n let blinkIndex = 0\n renderer.setAnimationLoop((time) => {\n const stream = player(),\n values = stream?.sample()\n const names = new Map(stream?.names.map((name, index) => [name, index]) ?? [])\n const blinkTime = (time / 1000) % assets.blinks.times.at(-1)!\n if (assets.blinks.times[blinkIndex] > blinkTime) blinkIndex = 0\n while (\n blinkIndex + 1 < assets.blinks.times.length &&\n assets.blinks.times[blinkIndex + 1] <= blinkTime\n )\n blinkIndex++\n const next = Math.min(blinkIndex + 1, assets.blinks.times.length - 1)\n const span = assets.blinks.times[next] - assets.blinks.times[blinkIndex]\n const blink = THREE.MathUtils.lerp(\n assets.blinks.values[blinkIndex],\n assets.blinks.values[next],\n span ? (blinkTime - assets.blinks.times[blinkIndex]) / span : 0\n )\n for (const mesh of meshes) {\n if (!mesh.visible || !mesh.morphTargetDictionary || !mesh.morphTargetInfluences) continue\n for (const [name, index] of Object.entries(mesh.morphTargetDictionary)) {\n const source = names.get(name)\n mesh.morphTargetInfluences[index] = name.startsWith('eyeBlink')\n ? blink\n : name.startsWith('eyeLook')\n ? 0\n : source !== undefined && values\n ? values[source]\n : 0\n }\n }\n controls.update()\n renderer.render(scene, camera)\n })\n return () => {\n observer.disconnect()\n renderer.setAnimationLoop(null)\n controls.dispose()\n const geometries = new Set<THREE.BufferGeometry>(originalGeometries),\n materials = new Set<THREE.Material>(originalMaterials)\n scene.traverse((item) => {\n if (item instanceof THREE.Mesh) {\n geometries.add(item.geometry)\n for (const m of Array.isArray(item.material) ? item.material : [item.material])\n materials.add(m)\n }\n })\n for (const geometry of geometries) geometry.dispose()\n for (const material of materials) material.dispose()\n renderer.dispose()\n renderer.domElement.remove()\n }\n}\n"]}
|