@arbidocs/react 0.5.145 → 0.5.147

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.
Files changed (82) hide show
  1. package/dist/PdfViewerImpl-DC5K3TYK.cjs +22 -0
  2. package/dist/{PdfViewerImpl-ZVJZ4KNW.cjs.map → PdfViewerImpl-DC5K3TYK.cjs.map} +1 -1
  3. package/dist/{PdfViewerImpl.d-CqnEzQO7.d.ts → PdfViewerImpl.d-DcM6iPY_.d.ts} +6 -1
  4. package/dist/annotations/freeze/index.d.ts +1 -1
  5. package/dist/artifacts/index.cjs +14 -14
  6. package/dist/calls/livekit/index.cjs +48 -48
  7. package/dist/chat/conversation-cache.js +5 -0
  8. package/dist/chat/conversation-cache.js.map +2 -2
  9. package/dist/chat/useConversation.js +10 -5
  10. package/dist/chat/useConversation.js.map +2 -2
  11. package/dist/chat/useConversationActions.js +4 -0
  12. package/dist/chat/useConversationActions.js.map +2 -2
  13. package/dist/chat/useConversationSettings.js +4 -10
  14. package/dist/chat/useConversationSettings.js.map +2 -2
  15. package/dist/{chunk-FE6ZSNZE.cjs → chunk-5FQB5F2F.cjs} +9 -4
  16. package/dist/chunk-5FQB5F2F.cjs.map +1 -0
  17. package/dist/{chunk-4B2GW3AY.cjs → chunk-FK33RWIO.cjs} +3 -3
  18. package/dist/{chunk-4B2GW3AY.cjs.map → chunk-FK33RWIO.cjs.map} +1 -1
  19. package/dist/{chunk-2F24LLVZ.cjs → chunk-MHYTO2EX.cjs} +38 -38
  20. package/dist/{chunk-2F24LLVZ.cjs.map → chunk-MHYTO2EX.cjs.map} +1 -1
  21. package/dist/{chunk-26SZ3DS4.cjs → chunk-MJIXYLI4.cjs} +66 -66
  22. package/dist/{chunk-26SZ3DS4.cjs.map → chunk-MJIXYLI4.cjs.map} +1 -1
  23. package/dist/{chunk-MAOGK7IC.cjs → chunk-PGD4ZWI3.cjs} +3 -3
  24. package/dist/{chunk-MAOGK7IC.cjs.map → chunk-PGD4ZWI3.cjs.map} +1 -1
  25. package/dist/{chunk-ZZZYVNFW.cjs → chunk-VBUEDJMK.cjs} +57 -57
  26. package/dist/{chunk-ZZZYVNFW.cjs.map → chunk-VBUEDJMK.cjs.map} +1 -1
  27. package/dist/{chunk-ICBT2XGF.cjs → chunk-WGCFGA3L.cjs} +3 -3
  28. package/dist/chunk-WGCFGA3L.cjs.map +1 -0
  29. package/dist/{chunk-FDYZA6NO.cjs → chunk-XBY4RLC6.cjs} +4 -4
  30. package/dist/{chunk-FDYZA6NO.cjs.map → chunk-XBY4RLC6.cjs.map} +1 -1
  31. package/dist/{chunk-VO7OWQP6.cjs → chunk-ZFTWH6B6.cjs} +44 -44
  32. package/dist/{chunk-VO7OWQP6.cjs.map → chunk-ZFTWH6B6.cjs.map} +1 -1
  33. package/dist/databases.js +9 -6
  34. package/dist/databases.js.map +2 -2
  35. package/dist/datasets/index.js +25 -21
  36. package/dist/datasets/index.js.map +2 -2
  37. package/dist/datasets/pages.js +208 -0
  38. package/dist/datasets/pages.js.map +7 -0
  39. package/dist/datasets/registry.js.map +2 -2
  40. package/dist/datasets/sources/database.js +21 -23
  41. package/dist/datasets/sources/database.js.map +2 -2
  42. package/dist/document-tools/core.cjs +98 -98
  43. package/dist/document-tools/core.d.ts +2 -2
  44. package/dist/document-tools/index.cjs +100 -100
  45. package/dist/document-tools/index.d.ts +1 -1
  46. package/dist/documents/documents-writes.js +45 -14
  47. package/dist/documents/documents-writes.js.map +2 -2
  48. package/dist/documents/index.js +8 -0
  49. package/dist/documents/index.js.map +2 -2
  50. package/dist/documents/tag-when-processed.js +47 -0
  51. package/dist/documents/tag-when-processed.js.map +7 -0
  52. package/dist/host/config.js.map +1 -1
  53. package/dist/index.cjs +1880 -1583
  54. package/dist/index.cjs.map +1 -1
  55. package/dist/index.d.ts +319 -97
  56. package/dist/index.js +27 -5
  57. package/dist/index.js.map +2 -2
  58. package/dist/notifications/notification-types.js +7 -0
  59. package/dist/notifications/notification-types.js.map +2 -2
  60. package/dist/notifications/server-notifications.js +66 -10
  61. package/dist/notifications/server-notifications.js.map +2 -2
  62. package/dist/{pdf-region-impl-ZG5G2OX2.cjs → pdf-region-impl-J2TVABQU.cjs} +9 -9
  63. package/dist/{pdf-region-impl-ZG5G2OX2.cjs.map → pdf-region-impl-J2TVABQU.cjs.map} +1 -1
  64. package/dist/{query-keys.d-d2M4FAq2.d.ts → query-keys.d-pgq-4jyZ.d.ts} +7 -2
  65. package/dist/query-keys.js +7 -2
  66. package/dist/query-keys.js.map +2 -2
  67. package/dist/table-views.js +166 -0
  68. package/dist/table-views.js.map +7 -0
  69. package/dist/viewers/PdfViewer.cjs +3 -3
  70. package/dist/viewers/PdfViewer.d.ts +2 -2
  71. package/dist/viewers/PdfViewerImpl.js +1 -1
  72. package/dist/viewers/PdfViewerImpl.js.map +2 -2
  73. package/dist/viewers/index.cjs +10 -10
  74. package/dist/viewers/index.d.ts +2 -2
  75. package/package.json +3 -3
  76. package/dist/PdfViewerImpl-ZVJZ4KNW.cjs +0 -22
  77. package/dist/account/table-views.js +0 -16
  78. package/dist/account/table-views.js.map +0 -7
  79. package/dist/chunk-FE6ZSNZE.cjs.map +0 -1
  80. package/dist/chunk-ICBT2XGF.cjs.map +0 -1
  81. package/dist/datasets/store.js +0 -194
  82. package/dist/datasets/store.js.map +0 -7
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/chat/useConversationActions.ts"],
4
- "sourcesContent": ["/**\n * The chat engine's actions on a conversation: send (a turn, or a comment to the people in a\n * thread), branch, retry, stop, and the run-control commands typed while a turn runs. A turn goes\n * through `arbi.assistant.ask`, its frames through the stream handlers, and its state lives in the\n * session (`ArbiSessionState`) and the conversation cache.\n */\n\nimport { flushDocumentForTurn } from './turn-flush'\nimport { pendingChatModelSave } from '../config/config-hooks'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { useQueryClient, type QueryClient } from '@tanstack/react-query'\nimport {\n ArbiApiError,\n STOP_REPEAT_WINDOW_MS,\n getRunToCancel,\n quotaFromStreamError,\n type ConversationResponse as Conversation,\n type ThreadsResponse,\n} from '@arbidocs/sdk/browser'\nimport type { components } from '@arbidocs/client'\nimport { notify } from '../shell'\nimport { arbiQueryKeys } from '../hooks'\nimport { useArbi } from '../useArbi'\nimport { useArbiHost } from '../host/config'\nimport { selectDraft, useArbiSessionStore } from '../session'\nimport type { ArbiSessionStore } from '../session/store'\nimport {\n invalidateConversationLists,\n isConversationShared,\n patchConversation,\n patchConversationList,\n removeConversationFromLists,\n} from '../conversation-list'\nimport {\n allConversationThreads,\n clearLoadingState,\n flushStreamingTokens,\n getThreadsQueryKey,\n updateUserMessageStateInCache,\n} from './conversation-cache'\nimport {\n assistantLabels,\n cachedAssistantMode,\n cachedMentionCandidates,\n isCommentToPeople,\n} from './conversation-mentions'\nimport { useAssistantName } from '../host/assistant-copy'\nimport { hasMessageBody, toMessageMentions, extractMentions } from './mentions'\nimport { takeDocumentForTurn } from './open-document'\nimport { agentChatOwnerOf, creatorOf } from './agent-chat-owner'\nimport { bindThreadDocument, boundDocumentOf } from './thread-binding'\nimport { resolveReplyTarget } from './reply-target'\nimport {\n confirmConversationWorkspace,\n conversationWorkspaceOf,\n watchConversationWorkspaces,\n} from './conversation-workspace'\nimport { useStreamHandlers, type StreamState } from './stream-handlers'\nimport {\n AGENT_CONTROL_COMMANDS,\n cachedQuotaUsedUp,\n disconnectAttachedRun,\n refuseChatWhenOffline,\n waitForResponseId,\n} from './turn-control'\n\ntype MessageInput = components['schemas']['MessageInput']\ntype MessageMention = components['schemas']['MessageMention']\n\n/** How long a dropped turn holds its generating state while the thread is re-read. */\nconst RECONCILE_TIMEOUT_MS = 5000\n\nexport interface SendMessageOptions {\n /** An explicit edit/fork, rather than appending a human message to the shared thread. */\n branch?: boolean\n queuedContinuation?: boolean\n queueOwnerAssistantId?: string\n queuedClientId?: string\n /**\n * Bypasses the normal single-pinned-document tools computation (the chat's documents and its\n * pin, see `buildTurnRequest`) for this one send.\n * The app's general \"pin a document\" feature is deliberately one-at-a-time\n * (`selectFullContextDocument`) \u2014 a pinned TEXT doc's full content goes\n * straight into the AGENT's chat prompt, so more than one at a time risks\n * blowing that context window. Generate image is a different resource\n * entirely: reference images never touch the agent's chat context \u2014 they go\n * to the separate ImageGen model in its own request \u2014 so multiple\n * references (e.g. \"combine these two logos\") don't compound against that\n * budget, even though they still cost real tokens against ImageGen's own\n * call. This lets that caller build its own tools object with every\n * selected reference doc instead of touching the single global pin.\n */\n toolsOverride?: MessageInput['tools']\n /**\n * Send in this conversation and workspace rather than the open ones: a follow-up captured when\n * its turn started (a deferred interjection), sent after the view may have moved on.\n */\n target?: TurnTarget\n}\n\n/** The conversation and workspace a turn belongs to, captured when it starts. */\nexport interface TurnTarget {\n workspaceId: string\n conversationId: string\n}\n\n/**\n * The draft a send leaves behind. A shared chat addresses ARBI again, except after a comment to\n * people: then the box is left empty, which a shared chat reads as a comment to the thread.\n */\nfunction draftAfterSend(\n queryClient: QueryClient,\n session: ArbiSessionStore,\n wasComment: boolean,\n assistantName: string\n): string {\n const shared = isConversationShared(queryClient, session.getState().conversationId)\n return shared && !wasComment ? `@${assistantName} ` : ''\n}\n\n/**\n * A queued follow-up the backend refused before its turn started: mark its bubble failed and\n * take it out of the queue, so it does not sit there as if it were still waiting.\n */\nfunction failQueuedContinuation(\n queryClient: QueryClient,\n session: ArbiSessionStore,\n streamState: {\n conversationId: string\n queuedUserMessageId: string | null\n queueOwnerAssistantId: string | null\n queuedClientId: string | null\n }\n): void {\n if (streamState.queuedUserMessageId) {\n updateUserMessageStateInCache(\n queryClient,\n streamState.conversationId,\n streamState.queuedUserMessageId,\n 'failed',\n false\n )\n }\n if (streamState.queuedClientId) {\n session.removeQueuedMessage(streamState.queuedClientId)\n }\n notify.error('Queued message failed to send')\n}\n\n/** The signed-in user's id, or null before the session is known. */\nfunction signedInUserId(arbi: { user: { identity: () => { externalId: string } | null } }) {\n try {\n return arbi.user.identity()?.externalId ?? null\n } catch {\n return null\n }\n}\n\n/** What the actions act on: the open workspace and conversation, as the session holds them. */\nexport interface ConversationActionsInput {\n selectedWorkspaceId: string | null\n /** The cursor when the view rendered (the stream handlers place a branch against it). */\n parentMessageId: string | null\n /** The open conversation's key (`new` for a new chat). */\n conversationKey: string\n isGenerating: boolean\n lastFailedMessage: string | null\n}\n\n/** The actions on the open conversation. */\nexport function useConversationActions({\n selectedWorkspaceId,\n parentMessageId,\n conversationKey,\n isGenerating,\n lastFailedMessage,\n}: ConversationActionsInput) {\n const queryClient = useQueryClient()\n const session = useArbiSessionStore()\n const currentConversationId = conversationKey === 'new' ? null : conversationKey\n const invalidateUserWorkspaces = useCallback(\n () => void queryClient.invalidateQueries({ queryKey: arbiQueryKeys.workspaces() }),\n [queryClient]\n )\n\n const arbi = useArbi()\n // Each conversation stays in the workspace it was opened in, though the surface switches.\n useState(() => watchConversationWorkspaces(queryClient, session))\n const createHandlers = useStreamHandlers()\n const chatHost = useArbiHost().chat\n const assistantName = useAssistantName()\n const mentionCandidates = useCallback(\n () =>\n cachedMentionCandidates(\n queryClient,\n session.getState().workspaceId,\n signedInUserId(arbi),\n assistantName\n ),\n [queryClient, session, arbi, assistantName]\n )\n // The local stream a Stop is closing. Stop cancels the run on the server before it aborts the\n // stream, so the connection can drop first with a network error that is not an abort.\n const stoppedStreamRef = useRef<AbortController | null>(null)\n // True while a Stop's server cancel is in flight, so a second press does not cancel again.\n const stopInFlightRef = useRef(false)\n // When the last Stop was pressed. A press within STOP_REPEAT_WINDOW_MS of it is a double tap.\n const lastStopAtRef = useRef(0)\n // True while a Retry deletes and resends, so a second press does not do it again.\n const retryInFlightRef = useRef(false)\n // Lets sendMessage resubmit a deferred interjection as a new turn without a\n // self-reference (it is a useCallback that would otherwise close over a stale\n // or not-yet-defined copy of itself). Kept current just below its definition.\n const sendMessageRef = useRef<\n | ((content: string, parentId?: string | null, options?: SendMessageOptions) => Promise<void>)\n | null\n >(null)\n\n /**\n * Shared posts, and posts in a `mentioned` thread, run ARBI only when addressed; posts in an\n * ordinary solo chat address it implicitly.\n */\n const routeMessage = useCallback(\n (content: string, conversationId?: string | null) => {\n const state = session.getState()\n const convId = conversationId === undefined ? state.conversationId : conversationId\n const { newConversationAssistantMode } = state\n const candidates = mentionCandidates()\n const mentioned = extractMentions(content, candidates)\n const assistantMode = cachedAssistantMode(queryClient, convId, newConversationAssistantMode)\n const isComment = isCommentToPeople(queryClient, convId, content, candidates)\n const mentions = toMessageMentions(mentioned) as MessageMention[]\n // A message not taken as a comment addresses ARBI. In an existing `mentioned` thread that is\n // only one that @mentions it; what is left is the first message of a thread not created\n // yet, whose turn creates it in `mentioned` mode.\n if (\n !isComment &&\n assistantMode === 'mentioned' &&\n !mentions.some((m) => m.type === 'assistant')\n ) {\n mentions.push({ type: 'assistant' })\n }\n return {\n mentions,\n assistantMode,\n isComment,\n }\n },\n [queryClient, session, mentionCandidates]\n )\n\n /** Post a comment (no assistant run) and land the thread on it. */\n const postComment = useCallback(\n async (\n content: string,\n parentId: string | null,\n mentions: MessageMention[],\n branch = false\n ) => {\n const convId = session.getState().conversationId\n try {\n const saved = await arbi.conversations.postMessage({\n content,\n mentions,\n // Only an explicit edit creates a branch. Ordinary comments append to the\n // server's latest message, so simultaneous sends stay visible together. Else\n // (nothing yet) start a thread. The mode only applies to a conversation it creates.\n ...(branch && parentId\n ? { previous_message_ext_id: parentId }\n : convId\n ? { conversation_ext_id: convId }\n : {}),\n assistant_mode: 'mentioned',\n })\n const conversationId = saved.conversation_ext_id\n const nowIso = new Date().toISOString()\n if (!convId) {\n // A comment starts the thread without a turn to carry its binding: bind it right after.\n const bindTo = session.getState().newChatDocumentId\n session.moveConversation('new', conversationId)\n if (bindTo) session.setNewChatDocumentId(null)\n patchConversationList(queryClient, session.getState().workspaceId, (old) => [\n {\n external_id: conversationId,\n title: content.slice(0, 40),\n created_by_ext_id: saved.created_by_ext_id,\n updated_by_ext_id: null,\n created_at: nowIso,\n updated_at: nowIso,\n // A mention of someone who cannot see it yet shares it server-side: refetched below.\n is_shared: false,\n message_count: 1,\n last_message_status: 'completed',\n assistant_mode: 'mentioned',\n } as Conversation,\n ...old,\n ])\n if (bindTo)\n bindThreadDocument(arbi, queryClient, conversationId, bindTo).catch(() =>\n notify.error('Could not attach the document to this thread')\n )\n invalidateUserWorkspaces()\n } else {\n patchConversation(queryClient, conversationId, (c) => ({\n ...c,\n message_count: c.message_count + 1,\n updated_at: nowIso,\n }))\n }\n // Mentioning someone shares the conversation on the server, which this cache cannot know.\n if (mentions.some((m) => m.type === 'user')) {\n await invalidateConversationLists(queryClient)\n }\n await queryClient.invalidateQueries({ queryKey: getThreadsQueryKey(conversationId) })\n session.setCursor(saved.external_id)\n } catch (error) {\n notify.error(\n (error instanceof ArbiApiError && error.detail) || 'Failed to post the message'\n )\n // Give the text back rather than lose it.\n if (!selectDraft(session.getState())) session.setDraft(content)\n }\n },\n [arbi, session, queryClient, invalidateUserWorkspaces]\n )\n\n const sendMessage = useCallback(\n async (content: string, requestedParentId?: string | null, options?: SendMessageOptions) => {\n // Never reply to a failed or deleted message: the server refuses it, so every Retry and every\n // new message would fail again. A queued follow-up names the running turn on purpose. With\n // nothing above to reply to, the parent stays: only a fresh conversation could take it.\n const target = options?.target\n const parentId =\n options?.queuedContinuation || !requestedParentId\n ? requestedParentId\n : (resolveReplyTarget(\n queryClient,\n (target ? target.conversationId : session.getState().conversationId) || 'new',\n requestedParentId\n ) ?? requestedParentId)\n const route = routeMessage(content, target?.conversationId)\n if (route.isComment && !options?.queuedContinuation && !target) {\n await postComment(content, parentId ?? null, route.mentions, options?.branch)\n return\n }\n // A model picked just now is still being saved: the turn runs on it, not on the config before.\n const modelSave = pendingChatModelSave(session)\n if (modelSave) await modelSave.catch(() => undefined)\n const state = session.getState()\n const convId = target ? target.conversationId : state.conversationId\n const convKey = convId || 'new'\n // The turn's workspace, captured now: the conversation's own (a docked or scoped chat keeps\n // its conversation across a switch), else the surface's for a new conversation. Named on the\n // request, so neither a switch nor the session's open workspace can move it.\n const turnWorkspaceId =\n target?.workspaceId ?? conversationWorkspaceOf(queryClient, convId) ?? selectedWorkspaceId\n const agentChat = state.newAgentChat\n // An existing conversation's agent: as recorded, else its creator when that is one of the\n // person's own agents (an agent chat runs under the agent's session; the record does not\n // survive a sign-out, or another device).\n let agentExtId = convId\n ? state.agentChatOwners[convId]\n : agentChat?.workspaceId === turnWorkspaceId\n ? agentChat.agentId\n : undefined\n // Only a conversation an agent created is looked up (an ordinary send never waits on it).\n if (convId && !agentExtId && creatorOf(queryClient, convId)?.startsWith('agt-')) {\n agentExtId = await agentChatOwnerOf(queryClient, () => arbi.agents.list(), convId)\n if (agentExtId) session.setAgentChatOwner(convId, agentExtId)\n }\n const queuedContinuation = options?.queuedContinuation === true\n // First message of a brand-new conversation bumps the workspace's\n // conversation_count \u2014 used to tick the \"Ask ARBI\" onboarding step.\n const isNewConversation = !convId\n\n const documentIds = (state.conversationDocuments[convKey] || []).map((doc) => doc.docId)\n // The chat's facts ride every message of it (snapshot semantics, like its documents).\n const factIds = [...(state.conversationFacts[convKey] || [])]\n\n const newConfigId = state.chatModel\n\n // Frontend is the single source of truth for which config a request\n // uses (Option B): send the same config the model selector resolves &\n // displays (see useConversationSettings) \u2014 explicit per-conversation\n // choice (`newConfigId`) wins, otherwise the user's persisted\n // `last_config`, so a selected config (e.g. one with ARTIFACTS_ENABLED)\n // actually drives the chat instead of being silently dropped to an\n // empty config. `newConfigId` alone is insufficient \u2014 it is transient\n // and cleared on every new conversation. Read `last_config` from the\n // shared settings cache by partial key match: openapi-react-query\n // suffixes the query key with request options and the settings hook is\n // token-gated, so the hook value can momentarily be undefined here even\n // though the data is cached app-wide.\n const cachedSettings = queryClient\n .getQueriesData<{ last_config?: string }>({ queryKey: arbiQueryKeys.userSettings() })\n .map(([, data]) => data)\n .find((data) => data?.last_config)\n const lastConfigId = cachedSettings?.last_config\n const resolvedConfigId = newConfigId || (agentExtId ? undefined : lastConfigId)\n\n // PA mode delegates the turn to the personal agent (`buildTurnRequest` prefixes `/pa ` so\n // the backend routes it straight to the delegation stream).\n const isPaMode = !agentExtId && state.paMode\n\n // Drafting mode: the thread's own document is named (a reference, never its content): the one\n // the thread is bound to (started from it, or attached in it), else one made in this thread\n // and open. A document merely open beside a chat is not: a new chat starts unbound. While an\n // earlier version of it is on screen the viewer returns to the live document. For a Word\n // document the server binds the live document: the assistant reads what it needs on demand\n // and edits it as tracked changes. For an html/react artifact it gets the source and a\n // targeted edit tool. PA-mode turns are delegated to a separate agent and never touch\n // artifacts.\n const threadDocumentId = boundDocumentOf(queryClient, { ...state, conversationId: convId })\n const activeArtifactExtId = isPaMode\n ? null\n : takeDocumentForTurn({\n boundDocumentId: threadDocumentId,\n conversationId: convId,\n workspaceId: turnWorkspaceId,\n })\n\n // An editor holding unsaved changes to that document saves them first: ARBI works on what\n // the person sees.\n const flushing = flushDocumentForTurn(activeArtifactExtId)\n if (flushing) await flushing\n\n // A workflow launch can leave structured tools for its one send; consume them here.\n const pendingTools = state.pendingTools\n if (pendingTools) session.setPendingTools(null)\n const toolsOverride = options?.toolsOverride ?? pendingTools ?? undefined\n\n const request = {\n question: content,\n workspaceId: turnWorkspaceId!,\n docIds: documentIds,\n pinnedDocumentId: state.pinnedDocumentId,\n factIds,\n tools: toolsOverride,\n personalAgent: isPaMode,\n activeArtifactExtId,\n // A new chat about a document is bound by its first turn, on the server (every device).\n ...(!convId && threadDocumentId ? { bindDocumentId: threadDocumentId } : {}),\n previousResponseId: parentId,\n agentId: agentExtId,\n model: resolvedConfigId,\n mentions: route.mentions,\n // A brand-new conversation starts in the mode picked in the composer.\n ...(!convId && route.assistantMode === 'mentioned'\n ? { assistantMode: 'mentioned' as const }\n : {}),\n }\n\n const abortController = new AbortController()\n if (!queuedContinuation) {\n session.setConversationGenerating(convKey, true, abortController)\n }\n\n // Optimistically mark this conversation in-progress the instant we start a\n // turn. Without this, Conversation's \"reconcile stale isGenerating\" effect\n // runs on the setConversationGenerating(true) above, sees the conversation\n // list's last_message_status still 'completed' from the PREVIOUS turn (the\n // stream_start patch below only lands ~50ms later), and immediately clears\n // isGenerating \u2014 which race-hid the live status bar on every follow-up\n // turn (first turns were exempt: the new conversation isn't in the list\n // yet). Patching here closes that window. No-op for a brand-new\n // conversation (convKey === 'new' isn't in the list).\n if (!queuedContinuation) {\n patchConversation(queryClient, convKey, { last_message_status: 'in_progress' })\n }\n\n // Mutable stream state \u2014 shared by all SSE handlers via closure\n const streamState: StreamState = {\n conversationId: convKey,\n workspaceId: turnWorkspaceId,\n assistantId: null,\n // 0 = nothing narrated yet, so nothing is owed a reading window.\n lastNarrationSettledAt: 0,\n // True once the model has pivoted to a tool call and not yet resumed\n // prose. Prose arriving while this is set opens a NEW narration, so the\n // one before it closes: paragraph break, and everything above becomes\n // superseded. Item boundaries alone cannot say this \u2014 the backend splits\n // a single sentence across several items.\n pivotedSinceProse: false,\n // Steering that landed too late to steer this turn; resubmitted as a new\n // turn once this one completes (see after the ask below).\n deferredInterjections: [],\n queuedContinuation,\n queuedUserMessageId: null,\n hasStreamStarted: false,\n queuedFailed: false,\n abortController,\n isStopped: () => stoppedStreamRef.current === abortController,\n queueOwnerAssistantId: options?.queueOwnerAssistantId ?? null,\n queuedClientId: options?.queuedClientId ?? null,\n // Set when a create_fact / label_facts tool runs this turn, so the Facts\n // table + label vocabulary refresh on completion (see handleComplete).\n factsTouched: false,\n threadDocumentId,\n // Set by the handlers: the server stored the question / reported its own failure.\n userMessageId: null,\n serverError: null,\n }\n\n // A follow-up sent for another conversation than the one on screen places itself under its own\n // parent, not under the screen's cursor.\n const handlers = createHandlers({\n streamState,\n parentMessageId: target ? (parentId ?? null) : parentMessageId,\n parentId,\n })\n // The server's word on the turn's workspace binds the conversation to it.\n const confirmTurnWorkspace = () => {\n if (streamState.workspaceId)\n confirmConversationWorkspace(\n queryClient,\n streamState.conversationId,\n streamState.workspaceId\n )\n }\n const onUserMessageInWorkspace = handlers.onUserMessage\n handlers.onUserMessage = (message) => {\n onUserMessageInWorkspace(message)\n confirmTurnWorkspace()\n }\n if (agentExtId) {\n const onUserMessage = handlers.onUserMessage\n handlers.onUserMessage = (message) => {\n if (message.conversation_ext_id) {\n session.setAgentChatOwner(message.conversation_ext_id, agentExtId)\n queryClient.invalidateQueries({ queryKey: arbiQueryKeys.agentChats(agentExtId) })\n }\n onUserMessage(message)\n }\n }\n\n const ownsActiveGeneration = () => {\n const activeGeneration = session.getState().generating[streamState.conversationId]\n return (\n activeGeneration?.abortController === abortController ||\n (!!streamState.assistantId &&\n activeGeneration?.streamingAssistantId === streamState.assistantId)\n )\n }\n\n try {\n performance.mark('arbi:send-message:start')\n await arbi.assistant.ask(request, {\n signal: abortController.signal,\n onMessageQueued: handlers.onMessageQueued,\n onUserMessage: handlers.onUserMessage,\n onStreamStart: handlers.onStreamStart,\n onToken: handlers.onToken,\n onMetadata: handlers.onMetadata,\n onError: handlers.onError,\n onComplete: handlers.onComplete,\n // `response.output_item.added` is deliberately NOT consumed: an item\n // opening told us only that SOME block had started, which is exactly the\n // guess this design gave up. Text arrives via onOutputTextDelta and\n // settles via onOutputItemDone.\n onOutputItemDone: handlers.onOutputItemDone,\n onOutputTextDelta: handlers.onOutputTextDelta,\n onUserInputRequest: handlers.onUserInputRequest,\n onProbeAnswer: handlers.onProbeAnswer,\n onDeferredInterjection: handlers.onDeferredInterjection,\n onAgentControlState: handlers.onAgentControlState,\n onArtifact: handlers.onArtifact,\n onMailDraft: handlers.onMailDraft,\n onElapsedTime: handlers.onElapsedTime,\n onContextUpdate: handlers.onContextUpdate,\n onQuotaExceeded: (quota) => chatHost?.onQuotaExceeded?.(quota),\n onWorkspace: (workspaceId) => {\n streamState.workspaceId = workspaceId\n confirmTurnWorkspace()\n },\n })\n // The stream is over: commit the text still waiting for a frame now, while the message is\n // the streamed one. Left buffered, it lands after the thread is re-read and is appended\n // to the answer the server stored.\n flushStreamingTokens(queryClient)\n\n // A steering response has no assistant stream of its own. The backend\n // accepted the queued user message into the active tool loop. Keep it\n // visibly queued until the parent stream emits its interjection step at\n // the actual tool boundary; that event settles the cache entry.\n if (queuedContinuation && !streamState.hasStreamStarted) {\n if (streamState.queuedFailed) failQueuedContinuation(queryClient, session, streamState)\n return\n }\n\n // The server refused the turn before storing anything (a parent that is gone, a model\n // that is down): say the send failed and offer Retry with the question, instead of letting\n // it vanish with nothing in the thread. Re-read the thread in case the server did store it.\n if (\n streamState.serverError &&\n !streamState.userMessageId &&\n !streamState.assistantId &&\n !queuedContinuation\n ) {\n if (ownsActiveGeneration()) {\n session.setConversationError(\n streamState.conversationId,\n streamState.serverError,\n content\n )\n void queryClient.invalidateQueries({\n queryKey: getThreadsQueryKey(streamState.conversationId),\n })\n // Undo the optimistic 'in_progress' set when the send started.\n void invalidateConversationLists(queryClient)\n }\n return\n }\n\n const ownsGeneration = ownsActiveGeneration()\n if (ownsGeneration) {\n session.setConversationGenerating(streamState.conversationId, false, null)\n }\n\n // The user's own generation just consumed AI usage \u2014 refresh the\n // \"\u00A3 used today\" indicator now instead of polling for it.\n queryClient.invalidateQueries({ queryKey: arbiQueryKeys.userUsageToday() })\n\n // Steering that reached the agent too late to steer this turn was\n // deferred by the backend rather than allowed to derail the answer.\n // Now that the turn is done, submit it as a new turn \u2014 threaded off the\n // assistant message that just finished, exactly as if the user had sent\n // it a moment later. Sent as one turn so a burst reads as a single\n // follow-up. Fire-and-forget via the ref so we don't block this turn's\n // completion bookkeeping (and to sidestep the self-reference).\n if (streamState.deferredInterjections.length > 0) {\n const followUp = streamState.deferredInterjections.join('\\n\\n')\n const threadParent = streamState.assistantId\n if (threadParent) {\n session.clearQueuedMessages(threadParent)\n }\n // In the conversation and workspace of the turn it steered, captured now: the view (or\n // the surface's workspace) may have moved on while the turn ran.\n void sendMessageRef.current?.(\n followUp,\n threadParent,\n streamState.workspaceId && streamState.conversationId !== 'new'\n ? {\n target: {\n workspaceId: streamState.workspaceId,\n conversationId: streamState.conversationId,\n },\n }\n : undefined\n )\n }\n\n // The conversations list cache is patched to 'in_progress' on stream\n // start (see the stream handlers). Patch it back to 'completed' here\n // so the Status column / sidebar reflect reality without a refetch.\n if (ownsGeneration) {\n const lastStatus = streamState.serverError ? 'failed' : 'completed'\n patchConversation(queryClient, streamState.conversationId, {\n last_message_status: lastStatus,\n })\n }\n\n // A new conversation changes the workspace's conversation_count \u2014 refresh\n // the workspaces list so onboarding's \"Ask ARBI\" step ticks reactively.\n if (isNewConversation && ownsGeneration) invalidateUserWorkspaces()\n\n if (ownsGeneration) {\n clearLoadingState(queryClient, streamState.conversationId)\n }\n } catch (error) {\n flushStreamingTokens(queryClient)\n const isAbort = error instanceof Error && error.name === 'AbortError'\n // The server stored the turn and only the connection dropped: the run is not over.\n const isDroppedConnection = !streamState.serverError && !isAbort && !streamState.isStopped()\n if (queuedContinuation && !streamState.hasStreamStarted) {\n // The server holds this follow-up in its queue already, and runs it in turn.\n if (isDroppedConnection && streamState.queuedUserMessageId) {\n if (streamState.queuedClientId) {\n session.removeQueuedMessage(streamState.queuedClientId)\n }\n void queryClient.invalidateQueries({\n queryKey: getThreadsQueryKey(streamState.conversationId),\n })\n return\n }\n failQueuedContinuation(queryClient, session, streamState)\n return\n }\n\n if (streamState.isStopped() || isAbort) {\n console.debug('Message sending was aborted by user')\n // The stopped stream leaves its assistant message loading with no stream behind it, and\n // a queued follow-up is not the owner so nothing else clears it. Clear it and re-read the\n // thread: a follow-up the server still runs is attached again, a stopped one shows its end.\n clearLoadingState(queryClient, streamState.conversationId)\n void queryClient.invalidateQueries({\n queryKey: getThreadsQueryKey(streamState.conversationId),\n })\n if (ownsActiveGeneration()) {\n session.setConversationGenerating(streamState.conversationId, false, null)\n patchConversation(queryClient, streamState.conversationId, {\n last_message_status: 'completed',\n })\n }\n return\n }\n\n console.error('Message sending failed:', error)\n if (!ownsActiveGeneration()) return\n\n // A dropped connection after the server stored the question does not end the turn: the\n // run goes on there. Failing it here offered Retry, which deleted the question under the\n // live answer (its answer then landed in the thread with no question) and, if the resend\n // failed too, left the view on the deleted turn. Re-read the thread instead: a running\n // answer is attached again, a failed one shows Retry, a finished one shows its answer.\n // Generation is held until the thread is re-read (or a few seconds pass, offline), so no\n // \"Response Incomplete\" alert offers to delete the question meanwhile.\n if (isDroppedConnection && streamState.userMessageId) {\n let timer: ReturnType<typeof setTimeout> | undefined\n await Promise.race([\n queryClient.invalidateQueries({\n queryKey: getThreadsQueryKey(streamState.conversationId),\n }),\n new Promise((resolve) => {\n timer = setTimeout(resolve, RECONCILE_TIMEOUT_MS)\n }),\n ])\n clearTimeout(timer)\n clearLoadingState(queryClient, streamState.conversationId)\n if (ownsActiveGeneration()) {\n session.setConversationGenerating(streamState.conversationId, false, null)\n }\n void invalidateConversationLists(queryClient)\n return\n }\n\n patchConversation(queryClient, streamState.conversationId, {\n last_message_status: 'failed',\n })\n\n // Open the upgrade modal if either (a) the error string carries\n // LiteLLM's ExceededBudget payload directly, or (b) the project's\n // cached AI usage is used up. Either path beats showing only\n // the conversation's generic error.\n const quota =\n quotaFromStreamError(error) ??\n cachedQuotaUsedUp(queryClient, session.getState().workspaceId)\n if (quota) chatHost?.onQuotaExceeded?.(quota)\n\n session.setConversationError(\n streamState.conversationId,\n error instanceof Error ? error.message : String(error),\n content\n )\n }\n },\n [\n selectedWorkspaceId,\n parentMessageId,\n queryClient,\n session,\n createHandlers,\n chatHost,\n arbi,\n invalidateUserWorkspaces,\n routeMessage,\n postComment,\n ]\n )\n\n // Keep the ref pointing at the latest sendMessage so the deferred-interjection\n // resubmit inside sendMessage always calls the current closure.\n sendMessageRef.current = sendMessage\n\n const handleCreateBranch = useCallback(\n async (parentMessageExtId: string | null, newContent: string) => {\n if (!newContent.trim() || !selectedWorkspaceId) return\n await sendMessage(newContent, parentMessageExtId, { branch: true })\n },\n [selectedWorkspaceId, sendMessage]\n )\n\n const handleSendMessage = useCallback(\n async (options?: SendMessageOptions) => {\n const currentMessage = selectDraft(session.getState()).trim()\n // The draft a shared thread starts with (`@<assistant> `) is not a question yet.\n if (!selectedWorkspaceId || !hasMessageBody(currentMessage, assistantLabels(assistantName)))\n return\n\n // A send consumes the suggested follow-up, whether or not it was used \u2014\n // the next turn's metadata brings a fresh one.\n session.setSuggestedQuery(null)\n\n // Chat runs against the server-side AI \u2014 there's nothing to queue offline.\n // Don't fire a mutation that would just pause and hang; tell the user.\n if (refuseChatWhenOffline()) return\n\n // While a turn is active, only true out-of-band controls use /interject.\n // Ordinary text still goes through the typed query endpoint, whose\n // arbi.message_queued event persists and renders it before the response gate\n // opens. The backend then either steers it into the next tool boundary or\n // starts a normal follow-up turn after the current final answer completes.\n if (isGenerating) {\n const convKey = session.getState().conversationId || 'new'\n const genState = session.getState().generating[convKey]\n const streamingAssistantId = genState?.streamingAssistantId\n\n // In a thread, a message that does not @mention the assistant is a comment between\n // people: post it straight away instead of queueing it into the running turn.\n const route = routeMessage(currentMessage)\n if (route.isComment && streamingAssistantId) {\n session.setDraft(draftAfterSend(queryClient, session, route.isComment, assistantName))\n await postComment(currentMessage, streamingAssistantId, route.mentions)\n return\n }\n\n if (streamingAssistantId) {\n const command = currentMessage.toLowerCase()\n const isPause = command === AGENT_CONTROL_COMMANDS.pause\n const isResume = command === AGENT_CONTROL_COMMANDS.resume\n const isReport =\n command === AGENT_CONTROL_COMMANDS.report ||\n command.startsWith(`${AGENT_CONTROL_COMMANDS.report} `)\n\n session.setDraft(draftAfterSend(queryClient, session, route.isComment, assistantName))\n\n if (isPause) {\n session.setAgentControlState(streamingAssistantId, 'pausing')\n } else if (isResume) {\n session.setAgentControlState(streamingAssistantId, 'resuming')\n } else if (isReport) {\n session.setAgentProbePending(streamingAssistantId, true)\n }\n\n if (isPause || isResume || isReport) {\n await arbi.assistant.interject(streamingAssistantId, currentMessage)\n } else {\n const queuedClientId = `queued-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`\n session.addQueuedMessage(streamingAssistantId, {\n clientId: queuedClientId,\n content: currentMessage,\n serverId: null,\n acknowledged: false,\n createdAt: Date.now(),\n })\n await sendMessage(currentMessage, streamingAssistantId, {\n ...options,\n queuedContinuation: true,\n queueOwnerAssistantId: streamingAssistantId,\n queuedClientId,\n })\n }\n return\n }\n // Keep the draft intact during the brief pre-stream window.\n return\n }\n\n const parentId = session.getState().cursor\n\n session.setDraft(\n draftAfterSend(queryClient, session, routeMessage(currentMessage).isComment, assistantName)\n )\n\n await sendMessage(currentMessage, parentId, options)\n },\n [\n selectedWorkspaceId,\n isGenerating,\n session,\n sendMessage,\n arbi,\n routeMessage,\n postComment,\n queryClient,\n assistantName,\n ]\n )\n\n const handleAbortGeneration = useCallback(async () => {\n // A second press (a double-click) must not stop the run again: it would cancel twice, and\n // once the local abort has landed it would clear the stopped-stream marker, so the stream's\n // error would read as a failed answer.\n const stream = session.getState().generating[conversationKey]\n if (stopInFlightRef.current || stream?.isGenerating === false) return\n // A tap right after a Stop must not stop the follow-up the queue started in the meantime.\n if (Date.now() - lastStopAtRef.current < STOP_REPEAT_WINDOW_MS) return\n lastStopAtRef.current = Date.now()\n stopInFlightRef.current = true\n try {\n // Stop the run on the server first; closing the stream alone leaves it running and\n // its answer would arrive later.\n const controller = stream?.abortController ?? null\n stoppedStreamRef.current = controller\n let streamKey = conversationKey\n let responseId = stream?.streamingAssistantId ?? null\n // Pressed before the stream reported its id: the run already exists on the server, so wait\n // for the id instead of only closing the stream. Further presses meanwhile do nothing.\n if (!responseId && controller) {\n const reported = await waitForResponseId(session, controller)\n if (reported) {\n streamKey = reported.conversationKey\n responseId = reported.responseId\n }\n }\n // In a sub-agent's branch this is the run that delegated it.\n const threads =\n queryClient.getQueryData<ThreadsResponse>(getThreadsQueryKey(streamKey))?.threads ?? []\n const runId = responseId ? getRunToCancel(threads, responseId) : null\n if (runId) {\n try {\n await arbi.assistant.cancel(runId)\n } catch {\n // Still stop here (the run may already have ended); say the server may keep going.\n notify.warning(\n \"Stopped here, but the server didn't confirm: the answer may still appear later.\"\n )\n }\n }\n // The cancel is awaited, and the server starts the next queued follow-up as soon as it lands:\n // that follow-up may already own this conversation's generation state and attach. Only close\n // the stream this Stop belongs to, or the next answer goes silent (\"Working\", no stop square).\n const current = session.getState().generating[streamKey]\n const isStoppedStream = controller\n ? current?.abortController === controller\n : !current?.streamingAssistantId || current.streamingAssistantId === responseId\n if (isStoppedStream) session.abortConversationGeneration(streamKey)\n // A reattached run has no local controller: close its stream too, or it keeps painting. The\n // attach follows this conversation's streaming message (in a sub-agent branch, the branch's\n // reply), not the delegating run that was cancelled, so match it by that id.\n if (responseId) disconnectAttachedRun(streamKey, responseId)\n } finally {\n stopInFlightRef.current = false\n }\n }, [session, arbi, conversationKey, queryClient])\n\n const handleRetryOrphanedMessage = useCallback(\n async (messageContent: string, parentId: string | null, messageExtId: string) => {\n // One retry at a time: the alert's Retry and the composer's retry (or a double click) must\n // not delete and resend twice. Released however the retry ends.\n if (retryInFlightRef.current) return\n // Offline the delete would be paused and the resend refused, leaving neither done.\n if (refuseChatWhenOffline()) return\n retryInFlightRef.current = true\n try {\n // A failed parent (a follow-up the restart sweep failed behind a failed answer) is\n // refused by the server, so the resend goes to the nearest message above it instead.\n const replyTo = currentConversationId\n ? resolveReplyTarget(queryClient, currentConversationId, parentId)\n : parentId\n if (!replyTo && currentConversationId) {\n try {\n await arbi.conversations.delete(currentConversationId)\n removeConversationFromLists(queryClient, currentConversationId)\n session.startNewConversation()\n } catch (error) {\n console.error('Failed to delete conversation with orphaned first message:', error)\n }\n } else if (replyTo) {\n try {\n await arbi.conversations.deleteMessage(messageExtId)\n // The message and its replies are gone from whichever thread held them.\n void queryClient.invalidateQueries(allConversationThreads)\n } catch (error) {\n console.error('Failed to delete orphaned message:', error)\n }\n }\n\n await sendMessage(messageContent, replyTo)\n } finally {\n retryInFlightRef.current = false\n }\n },\n [currentConversationId, arbi, session, sendMessage, queryClient]\n )\n\n const handleRetrySend = useCallback(async () => {\n if (isGenerating || !lastFailedMessage || retryInFlightRef.current) return\n if (refuseChatWhenOffline()) return\n retryInFlightRef.current = true\n try {\n session.clearConversationError(conversationKey)\n // sendMessage replies to the nearest message the server accepts: the view may still point at\n // a turn a Retry deleted, or at a failed answer.\n const parentId = session.getState().cursor\n await sendMessage(lastFailedMessage, parentId)\n } finally {\n retryInFlightRef.current = false\n }\n }, [isGenerating, lastFailedMessage, session, conversationKey, sendMessage])\n\n const clearErrorState = useCallback(() => {\n session.clearConversationError(conversationKey)\n }, [session, conversationKey])\n\n // Clear error state when starting a new conversation\n useEffect(() => {\n if (currentConversationId === null) {\n session.clearConversationError('new')\n }\n }, [currentConversationId, session])\n\n return {\n handleCreateBranch,\n handleSendMessage,\n handleAbortGeneration,\n handleRetrySend,\n handleRetryOrphanedMessage,\n clearErrorState,\n }\n}\n"],
5
- "mappings": "AAOA,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AACrC,SAAS,aAAa,WAAW,QAAQ,gBAAgB;AACzD,SAAS,sBAAwC;AACjD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAEP,SAAS,cAAc;AACvB,SAAS,qBAAqB;AAC9B,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,aAAa,2BAA2B;AAEjD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,wBAAwB;AACjC,SAAS,gBAAgB,mBAAmB,uBAAuB;AACnE,SAAS,2BAA2B;AACpC,SAAS,kBAAkB,iBAAiB;AAC5C,SAAS,oBAAoB,uBAAuB;AACpD,SAAS,0BAA0B;AACnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAA2C;AACpD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP,MAAM,uBAAuB;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AAAA,UAC3D;AAAA,QACF;AAEA,cAAM,YAAY,gBAAgB,OAAO;AAAA,MAC3C,UAAE;AACA,yBAAiB,UAAU;AAAA,MAC7B;AAAA,IACF;AAAA,IACA,CAAC,uBAAuB,MAAM,SAAS,aAAa,WAAW;AAAA,EACjE;AAEA,QAAM,kBAAkB,YAAY,YAAY;AAC9C,QAAI,gBAAgB,CAAC,qBAAqB,iBAAiB,QAAS;AACpE,QAAI,sBAAsB,EAAG;AAC7B,qBAAiB,UAAU;AAC3B,QAAI;AACF,cAAQ,uBAAuB,eAAe;AAG9C,YAAM,WAAW,QAAQ,SAAS,EAAE;AACpC,YAAM,YAAY,mBAAmB,QAAQ;AAAA,IAC/C,UAAE;AACA,uBAAiB,UAAU;AAAA,IAC7B;AAAA,EACF,GAAG,CAAC,cAAc,mBAAmB,SAAS,iBAAiB,WAAW,CAAC;AAE3E,QAAM,kBAAkB,YAAY,MAAM;AACxC,YAAQ,uBAAuB,eAAe;AAAA,EAChD,GAAG,CAAC,SAAS,eAAe,CAAC;AAG7B,YAAU,MAAM;AACd,QAAI,0BAA0B,MAAM;AAClC,cAAQ,uBAAuB,KAAK;AAAA,IACtC;AAAA,EACF,GAAG,CAAC,uBAAuB,OAAO,CAAC;AAEnC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["/**\n * The chat engine's actions on a conversation: send (a turn, or a comment to the people in a\n * thread), branch, retry, stop, and the run-control commands typed while a turn runs. A turn goes\n * through `arbi.assistant.ask`, its frames through the stream handlers, and its state lives in the\n * session (`ArbiSessionState`) and the conversation cache.\n */\n\nimport { flushDocumentForTurn } from './turn-flush'\nimport { pendingChatModelSave } from '../config/config-hooks'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { useQueryClient, type QueryClient } from '@tanstack/react-query'\nimport {\n ArbiApiError,\n STOP_REPEAT_WINDOW_MS,\n getRunToCancel,\n quotaFromStreamError,\n type ConversationResponse as Conversation,\n type ThreadsResponse,\n} from '@arbidocs/sdk/browser'\nimport type { components } from '@arbidocs/client'\nimport { notify } from '../shell'\nimport { arbiQueryKeys } from '../hooks'\nimport { useArbi } from '../useArbi'\nimport { useArbiHost } from '../host/config'\nimport { selectDraft, useArbiSessionStore } from '../session'\nimport type { ArbiSessionStore } from '../session/store'\nimport {\n invalidateConversationLists,\n isConversationShared,\n patchConversation,\n patchConversationList,\n removeConversationFromLists,\n} from '../conversation-list'\nimport {\n allConversationThreads,\n clearLoadingState,\n flushStreamingTokens,\n getThreadsQueryKey,\n isConversationEmpty,\n updateUserMessageStateInCache,\n} from './conversation-cache'\nimport {\n assistantLabels,\n cachedAssistantMode,\n cachedMentionCandidates,\n isCommentToPeople,\n} from './conversation-mentions'\nimport { useAssistantName } from '../host/assistant-copy'\nimport { hasMessageBody, toMessageMentions, extractMentions } from './mentions'\nimport { takeDocumentForTurn } from './open-document'\nimport { agentChatOwnerOf, creatorOf } from './agent-chat-owner'\nimport { bindThreadDocument, boundDocumentOf } from './thread-binding'\nimport { resolveReplyTarget } from './reply-target'\nimport {\n confirmConversationWorkspace,\n conversationWorkspaceOf,\n watchConversationWorkspaces,\n} from './conversation-workspace'\nimport { useStreamHandlers, type StreamState } from './stream-handlers'\nimport {\n AGENT_CONTROL_COMMANDS,\n cachedQuotaUsedUp,\n disconnectAttachedRun,\n refuseChatWhenOffline,\n waitForResponseId,\n} from './turn-control'\n\ntype MessageInput = components['schemas']['MessageInput']\ntype MessageMention = components['schemas']['MessageMention']\n\n/** How long a dropped turn holds its generating state while the thread is re-read. */\nconst RECONCILE_TIMEOUT_MS = 5000\n\nexport interface SendMessageOptions {\n /** An explicit edit/fork, rather than appending a human message to the shared thread. */\n branch?: boolean\n queuedContinuation?: boolean\n queueOwnerAssistantId?: string\n queuedClientId?: string\n /**\n * Bypasses the normal single-pinned-document tools computation (the chat's documents and its\n * pin, see `buildTurnRequest`) for this one send.\n * The app's general \"pin a document\" feature is deliberately one-at-a-time\n * (`selectFullContextDocument`) \u2014 a pinned TEXT doc's full content goes\n * straight into the AGENT's chat prompt, so more than one at a time risks\n * blowing that context window. Generate image is a different resource\n * entirely: reference images never touch the agent's chat context \u2014 they go\n * to the separate ImageGen model in its own request \u2014 so multiple\n * references (e.g. \"combine these two logos\") don't compound against that\n * budget, even though they still cost real tokens against ImageGen's own\n * call. This lets that caller build its own tools object with every\n * selected reference doc instead of touching the single global pin.\n */\n toolsOverride?: MessageInput['tools']\n /**\n * Send in this conversation and workspace rather than the open ones: a follow-up captured when\n * its turn started (a deferred interjection), sent after the view may have moved on.\n */\n target?: TurnTarget\n}\n\n/** The conversation and workspace a turn belongs to, captured when it starts. */\nexport interface TurnTarget {\n workspaceId: string\n conversationId: string\n}\n\n/**\n * The draft a send leaves behind. A shared chat addresses ARBI again, except after a comment to\n * people: then the box is left empty, which a shared chat reads as a comment to the thread.\n */\nfunction draftAfterSend(\n queryClient: QueryClient,\n session: ArbiSessionStore,\n wasComment: boolean,\n assistantName: string\n): string {\n const shared = isConversationShared(queryClient, session.getState().conversationId)\n return shared && !wasComment ? `@${assistantName} ` : ''\n}\n\n/**\n * A queued follow-up the backend refused before its turn started: mark its bubble failed and\n * take it out of the queue, so it does not sit there as if it were still waiting.\n */\nfunction failQueuedContinuation(\n queryClient: QueryClient,\n session: ArbiSessionStore,\n streamState: {\n conversationId: string\n queuedUserMessageId: string | null\n queueOwnerAssistantId: string | null\n queuedClientId: string | null\n }\n): void {\n if (streamState.queuedUserMessageId) {\n updateUserMessageStateInCache(\n queryClient,\n streamState.conversationId,\n streamState.queuedUserMessageId,\n 'failed',\n false\n )\n }\n if (streamState.queuedClientId) {\n session.removeQueuedMessage(streamState.queuedClientId)\n }\n notify.error('Queued message failed to send')\n}\n\n/** The signed-in user's id, or null before the session is known. */\nfunction signedInUserId(arbi: { user: { identity: () => { externalId: string } | null } }) {\n try {\n return arbi.user.identity()?.externalId ?? null\n } catch {\n return null\n }\n}\n\n/** What the actions act on: the open workspace and conversation, as the session holds them. */\nexport interface ConversationActionsInput {\n selectedWorkspaceId: string | null\n /** The cursor when the view rendered (the stream handlers place a branch against it). */\n parentMessageId: string | null\n /** The open conversation's key (`new` for a new chat). */\n conversationKey: string\n isGenerating: boolean\n lastFailedMessage: string | null\n}\n\n/** The actions on the open conversation. */\nexport function useConversationActions({\n selectedWorkspaceId,\n parentMessageId,\n conversationKey,\n isGenerating,\n lastFailedMessage,\n}: ConversationActionsInput) {\n const queryClient = useQueryClient()\n const session = useArbiSessionStore()\n const currentConversationId = conversationKey === 'new' ? null : conversationKey\n const invalidateUserWorkspaces = useCallback(\n () => void queryClient.invalidateQueries({ queryKey: arbiQueryKeys.workspaces() }),\n [queryClient]\n )\n\n const arbi = useArbi()\n // Each conversation stays in the workspace it was opened in, though the surface switches.\n useState(() => watchConversationWorkspaces(queryClient, session))\n const createHandlers = useStreamHandlers()\n const chatHost = useArbiHost().chat\n const assistantName = useAssistantName()\n const mentionCandidates = useCallback(\n () =>\n cachedMentionCandidates(\n queryClient,\n session.getState().workspaceId,\n signedInUserId(arbi),\n assistantName\n ),\n [queryClient, session, arbi, assistantName]\n )\n // The local stream a Stop is closing. Stop cancels the run on the server before it aborts the\n // stream, so the connection can drop first with a network error that is not an abort.\n const stoppedStreamRef = useRef<AbortController | null>(null)\n // True while a Stop's server cancel is in flight, so a second press does not cancel again.\n const stopInFlightRef = useRef(false)\n // When the last Stop was pressed. A press within STOP_REPEAT_WINDOW_MS of it is a double tap.\n const lastStopAtRef = useRef(0)\n // True while a Retry deletes and resends, so a second press does not do it again.\n const retryInFlightRef = useRef(false)\n // Lets sendMessage resubmit a deferred interjection as a new turn without a\n // self-reference (it is a useCallback that would otherwise close over a stale\n // or not-yet-defined copy of itself). Kept current just below its definition.\n const sendMessageRef = useRef<\n | ((content: string, parentId?: string | null, options?: SendMessageOptions) => Promise<void>)\n | null\n >(null)\n\n /**\n * Shared posts, and posts in a `mentioned` thread, run ARBI only when addressed; posts in an\n * ordinary solo chat address it implicitly.\n */\n const routeMessage = useCallback(\n (content: string, conversationId?: string | null) => {\n const state = session.getState()\n const convId = conversationId === undefined ? state.conversationId : conversationId\n const { newConversationAssistantMode } = state\n const candidates = mentionCandidates()\n const mentioned = extractMentions(content, candidates)\n const assistantMode = cachedAssistantMode(queryClient, convId, newConversationAssistantMode)\n const isComment = isCommentToPeople(queryClient, convId, content, candidates)\n const mentions = toMessageMentions(mentioned) as MessageMention[]\n // A message not taken as a comment addresses ARBI. In an existing `mentioned` thread that is\n // only one that @mentions it; what is left is the first message of a thread not created\n // yet, whose turn creates it in `mentioned` mode.\n if (\n !isComment &&\n assistantMode === 'mentioned' &&\n !mentions.some((m) => m.type === 'assistant')\n ) {\n mentions.push({ type: 'assistant' })\n }\n return {\n mentions,\n assistantMode,\n isComment,\n }\n },\n [queryClient, session, mentionCandidates]\n )\n\n /** Post a comment (no assistant run) and land the thread on it. */\n const postComment = useCallback(\n async (\n content: string,\n parentId: string | null,\n mentions: MessageMention[],\n branch = false\n ) => {\n const convId = session.getState().conversationId\n try {\n const saved = await arbi.conversations.postMessage({\n content,\n mentions,\n // Only an explicit edit creates a branch. Ordinary comments append to the\n // server's latest message, so simultaneous sends stay visible together. Else\n // (nothing yet) start a thread. The mode only applies to a conversation it creates.\n ...(branch && parentId\n ? { previous_message_ext_id: parentId }\n : convId\n ? { conversation_ext_id: convId }\n : {}),\n assistant_mode: 'mentioned',\n })\n const conversationId = saved.conversation_ext_id\n const nowIso = new Date().toISOString()\n if (!convId) {\n // A comment starts the thread without a turn to carry its binding: bind it right after.\n const bindTo = session.getState().newChatDocumentId\n session.moveConversation('new', conversationId)\n if (bindTo) session.setNewChatDocumentId(null)\n patchConversationList(queryClient, session.getState().workspaceId, (old) => [\n {\n external_id: conversationId,\n title: content.slice(0, 40),\n created_by_ext_id: saved.created_by_ext_id,\n updated_by_ext_id: null,\n created_at: nowIso,\n updated_at: nowIso,\n // A mention of someone who cannot see it yet shares it server-side: refetched below.\n is_shared: false,\n message_count: 1,\n last_message_status: 'completed',\n assistant_mode: 'mentioned',\n } as Conversation,\n ...old,\n ])\n if (bindTo)\n bindThreadDocument(arbi, queryClient, conversationId, bindTo).catch(() =>\n notify.error('Could not attach the document to this thread')\n )\n invalidateUserWorkspaces()\n } else {\n patchConversation(queryClient, conversationId, (c) => ({\n ...c,\n message_count: c.message_count + 1,\n updated_at: nowIso,\n }))\n }\n // Mentioning someone shares the conversation on the server, which this cache cannot know.\n if (mentions.some((m) => m.type === 'user')) {\n await invalidateConversationLists(queryClient)\n }\n await queryClient.invalidateQueries({ queryKey: getThreadsQueryKey(conversationId) })\n session.setCursor(saved.external_id)\n } catch (error) {\n notify.error(\n (error instanceof ArbiApiError && error.detail) || 'Failed to post the message'\n )\n // Give the text back rather than lose it.\n if (!selectDraft(session.getState())) session.setDraft(content)\n }\n },\n [arbi, session, queryClient, invalidateUserWorkspaces]\n )\n\n const sendMessage = useCallback(\n async (content: string, requestedParentId?: string | null, options?: SendMessageOptions) => {\n // Never reply to a failed or deleted message: the server refuses it, so every Retry and every\n // new message would fail again. A queued follow-up names the running turn on purpose. With\n // nothing above to reply to, the parent stays: only a fresh conversation could take it.\n const target = options?.target\n const parentId =\n options?.queuedContinuation || !requestedParentId\n ? requestedParentId\n : (resolveReplyTarget(\n queryClient,\n (target ? target.conversationId : session.getState().conversationId) || 'new',\n requestedParentId\n ) ?? requestedParentId)\n const route = routeMessage(content, target?.conversationId)\n if (route.isComment && !options?.queuedContinuation && !target) {\n await postComment(content, parentId ?? null, route.mentions, options?.branch)\n return\n }\n // A model picked just now is still being saved: the turn runs on it, not on the config before.\n const modelSave = pendingChatModelSave(session)\n if (modelSave) await modelSave.catch(() => undefined)\n const state = session.getState()\n const convId = target ? target.conversationId : state.conversationId\n const convKey = convId || 'new'\n // The turn's workspace, captured now: the conversation's own (a docked or scoped chat keeps\n // its conversation across a switch), else the surface's for a new conversation. Named on the\n // request, so neither a switch nor the session's open workspace can move it.\n const turnWorkspaceId =\n target?.workspaceId ?? conversationWorkspaceOf(queryClient, convId) ?? selectedWorkspaceId\n const agentChat = state.newAgentChat\n // An existing conversation's agent: as recorded, else its creator when that is one of the\n // person's own agents (an agent chat runs under the agent's session; the record does not\n // survive a sign-out, or another device).\n let agentExtId = convId\n ? state.agentChatOwners[convId]\n : agentChat?.workspaceId === turnWorkspaceId\n ? agentChat.agentId\n : undefined\n // Only a conversation an agent created is looked up (an ordinary send never waits on it).\n if (convId && !agentExtId && creatorOf(queryClient, convId)?.startsWith('agt-')) {\n agentExtId = await agentChatOwnerOf(queryClient, () => arbi.agents.list(), convId)\n if (agentExtId) session.setAgentChatOwner(convId, agentExtId)\n }\n const queuedContinuation = options?.queuedContinuation === true\n // First message of a brand-new conversation bumps the workspace's\n // conversation_count \u2014 used to tick the \"Ask ARBI\" onboarding step.\n const isNewConversation = !convId\n\n const documentIds = (state.conversationDocuments[convKey] || []).map((doc) => doc.docId)\n // The chat's facts ride every message of it (snapshot semantics, like its documents).\n const factIds = [...(state.conversationFacts[convKey] || [])]\n\n const newConfigId = state.chatModel\n\n // Frontend is the single source of truth for which config a request\n // uses (Option B): send the same config the model selector resolves &\n // displays (see useConversationSettings) \u2014 explicit per-conversation\n // choice (`newConfigId`) wins, otherwise the user's persisted\n // `last_config`, so a selected config (e.g. one with ARTIFACTS_ENABLED)\n // actually drives the chat instead of being silently dropped to an\n // empty config. `newConfigId` alone is insufficient \u2014 it is transient\n // and cleared on every new conversation. Read `last_config` from the\n // shared settings cache by partial key match: openapi-react-query\n // suffixes the query key with request options and the settings hook is\n // token-gated, so the hook value can momentarily be undefined here even\n // though the data is cached app-wide.\n const cachedSettings = queryClient\n .getQueriesData<{ last_config?: string }>({ queryKey: arbiQueryKeys.userSettings() })\n .map(([, data]) => data)\n .find((data) => data?.last_config)\n const lastConfigId = cachedSettings?.last_config\n const resolvedConfigId = newConfigId || (agentExtId ? undefined : lastConfigId)\n\n // PA mode delegates the turn to the personal agent (`buildTurnRequest` prefixes `/pa ` so\n // the backend routes it straight to the delegation stream).\n const isPaMode = !agentExtId && state.paMode\n\n // Drafting mode: the thread's own document is named (a reference, never its content): the one\n // the thread is bound to (started from it, or attached in it), else one made in this thread\n // and open. A document merely open beside a chat is not: a new chat starts unbound. While an\n // earlier version of it is on screen the viewer returns to the live document. For a Word\n // document the server binds the live document: the assistant reads what it needs on demand\n // and edits it as tracked changes. For an html/react artifact it gets the source and a\n // targeted edit tool. PA-mode turns are delegated to a separate agent and never touch\n // artifacts.\n const threadDocumentId = boundDocumentOf(queryClient, { ...state, conversationId: convId })\n const activeArtifactExtId = isPaMode\n ? null\n : takeDocumentForTurn({\n boundDocumentId: threadDocumentId,\n conversationId: convId,\n workspaceId: turnWorkspaceId,\n })\n\n // An editor holding unsaved changes to that document saves them first: ARBI works on what\n // the person sees.\n const flushing = flushDocumentForTurn(activeArtifactExtId)\n if (flushing) await flushing\n\n // A workflow launch can leave structured tools for its one send; consume them here.\n const pendingTools = state.pendingTools\n if (pendingTools) session.setPendingTools(null)\n const toolsOverride = options?.toolsOverride ?? pendingTools ?? undefined\n\n const request = {\n question: content,\n workspaceId: turnWorkspaceId!,\n docIds: documentIds,\n pinnedDocumentId: state.pinnedDocumentId,\n factIds,\n tools: toolsOverride,\n personalAgent: isPaMode,\n activeArtifactExtId,\n // A new chat about a document is bound by its first turn, on the server (every device).\n ...(!convId && threadDocumentId ? { bindDocumentId: threadDocumentId } : {}),\n previousResponseId: parentId,\n // The first turn of an existing conversation with no message yet (a task's thread) runs in\n // it: without its id the server starts a new conversation for the turn.\n ...(convId && !parentId && !options?.branch && isConversationEmpty(queryClient, convId)\n ? { conversationId: convId }\n : {}),\n agentId: agentExtId,\n model: resolvedConfigId,\n mentions: route.mentions,\n // A brand-new conversation starts in the mode picked in the composer.\n ...(!convId && route.assistantMode === 'mentioned'\n ? { assistantMode: 'mentioned' as const }\n : {}),\n }\n\n const abortController = new AbortController()\n if (!queuedContinuation) {\n session.setConversationGenerating(convKey, true, abortController)\n }\n\n // Optimistically mark this conversation in-progress the instant we start a\n // turn. Without this, Conversation's \"reconcile stale isGenerating\" effect\n // runs on the setConversationGenerating(true) above, sees the conversation\n // list's last_message_status still 'completed' from the PREVIOUS turn (the\n // stream_start patch below only lands ~50ms later), and immediately clears\n // isGenerating \u2014 which race-hid the live status bar on every follow-up\n // turn (first turns were exempt: the new conversation isn't in the list\n // yet). Patching here closes that window. No-op for a brand-new\n // conversation (convKey === 'new' isn't in the list).\n if (!queuedContinuation) {\n patchConversation(queryClient, convKey, { last_message_status: 'in_progress' })\n }\n\n // Mutable stream state \u2014 shared by all SSE handlers via closure\n const streamState: StreamState = {\n conversationId: convKey,\n workspaceId: turnWorkspaceId,\n assistantId: null,\n // 0 = nothing narrated yet, so nothing is owed a reading window.\n lastNarrationSettledAt: 0,\n // True once the model has pivoted to a tool call and not yet resumed\n // prose. Prose arriving while this is set opens a NEW narration, so the\n // one before it closes: paragraph break, and everything above becomes\n // superseded. Item boundaries alone cannot say this \u2014 the backend splits\n // a single sentence across several items.\n pivotedSinceProse: false,\n // Steering that landed too late to steer this turn; resubmitted as a new\n // turn once this one completes (see after the ask below).\n deferredInterjections: [],\n queuedContinuation,\n queuedUserMessageId: null,\n hasStreamStarted: false,\n queuedFailed: false,\n abortController,\n isStopped: () => stoppedStreamRef.current === abortController,\n queueOwnerAssistantId: options?.queueOwnerAssistantId ?? null,\n queuedClientId: options?.queuedClientId ?? null,\n // Set when a create_fact / label_facts tool runs this turn, so the Facts\n // table + label vocabulary refresh on completion (see handleComplete).\n factsTouched: false,\n threadDocumentId,\n // Set by the handlers: the server stored the question / reported its own failure.\n userMessageId: null,\n serverError: null,\n }\n\n // A follow-up sent for another conversation than the one on screen places itself under its own\n // parent, not under the screen's cursor.\n const handlers = createHandlers({\n streamState,\n parentMessageId: target ? (parentId ?? null) : parentMessageId,\n parentId,\n })\n // The server's word on the turn's workspace binds the conversation to it.\n const confirmTurnWorkspace = () => {\n if (streamState.workspaceId)\n confirmConversationWorkspace(\n queryClient,\n streamState.conversationId,\n streamState.workspaceId\n )\n }\n const onUserMessageInWorkspace = handlers.onUserMessage\n handlers.onUserMessage = (message) => {\n onUserMessageInWorkspace(message)\n confirmTurnWorkspace()\n }\n if (agentExtId) {\n const onUserMessage = handlers.onUserMessage\n handlers.onUserMessage = (message) => {\n if (message.conversation_ext_id) {\n session.setAgentChatOwner(message.conversation_ext_id, agentExtId)\n queryClient.invalidateQueries({ queryKey: arbiQueryKeys.agentChats(agentExtId) })\n }\n onUserMessage(message)\n }\n }\n\n const ownsActiveGeneration = () => {\n const activeGeneration = session.getState().generating[streamState.conversationId]\n return (\n activeGeneration?.abortController === abortController ||\n (!!streamState.assistantId &&\n activeGeneration?.streamingAssistantId === streamState.assistantId)\n )\n }\n\n try {\n performance.mark('arbi:send-message:start')\n await arbi.assistant.ask(request, {\n signal: abortController.signal,\n onMessageQueued: handlers.onMessageQueued,\n onUserMessage: handlers.onUserMessage,\n onStreamStart: handlers.onStreamStart,\n onToken: handlers.onToken,\n onMetadata: handlers.onMetadata,\n onError: handlers.onError,\n onComplete: handlers.onComplete,\n // `response.output_item.added` is deliberately NOT consumed: an item\n // opening told us only that SOME block had started, which is exactly the\n // guess this design gave up. Text arrives via onOutputTextDelta and\n // settles via onOutputItemDone.\n onOutputItemDone: handlers.onOutputItemDone,\n onOutputTextDelta: handlers.onOutputTextDelta,\n onUserInputRequest: handlers.onUserInputRequest,\n onProbeAnswer: handlers.onProbeAnswer,\n onDeferredInterjection: handlers.onDeferredInterjection,\n onAgentControlState: handlers.onAgentControlState,\n onArtifact: handlers.onArtifact,\n onMailDraft: handlers.onMailDraft,\n onElapsedTime: handlers.onElapsedTime,\n onContextUpdate: handlers.onContextUpdate,\n onQuotaExceeded: (quota) => chatHost?.onQuotaExceeded?.(quota),\n onWorkspace: (workspaceId) => {\n streamState.workspaceId = workspaceId\n confirmTurnWorkspace()\n },\n })\n // The stream is over: commit the text still waiting for a frame now, while the message is\n // the streamed one. Left buffered, it lands after the thread is re-read and is appended\n // to the answer the server stored.\n flushStreamingTokens(queryClient)\n\n // A steering response has no assistant stream of its own. The backend\n // accepted the queued user message into the active tool loop. Keep it\n // visibly queued until the parent stream emits its interjection step at\n // the actual tool boundary; that event settles the cache entry.\n if (queuedContinuation && !streamState.hasStreamStarted) {\n if (streamState.queuedFailed) failQueuedContinuation(queryClient, session, streamState)\n return\n }\n\n // The server refused the turn before storing anything (a parent that is gone, a model\n // that is down): say the send failed and offer Retry with the question, instead of letting\n // it vanish with nothing in the thread. Re-read the thread in case the server did store it.\n if (\n streamState.serverError &&\n !streamState.userMessageId &&\n !streamState.assistantId &&\n !queuedContinuation\n ) {\n if (ownsActiveGeneration()) {\n session.setConversationError(\n streamState.conversationId,\n streamState.serverError,\n content\n )\n void queryClient.invalidateQueries({\n queryKey: getThreadsQueryKey(streamState.conversationId),\n })\n // Undo the optimistic 'in_progress' set when the send started.\n void invalidateConversationLists(queryClient)\n }\n return\n }\n\n const ownsGeneration = ownsActiveGeneration()\n if (ownsGeneration) {\n session.setConversationGenerating(streamState.conversationId, false, null)\n }\n\n // The user's own generation just consumed AI usage \u2014 refresh the\n // \"\u00A3 used today\" indicator now instead of polling for it.\n queryClient.invalidateQueries({ queryKey: arbiQueryKeys.userUsageToday() })\n\n // Steering that reached the agent too late to steer this turn was\n // deferred by the backend rather than allowed to derail the answer.\n // Now that the turn is done, submit it as a new turn \u2014 threaded off the\n // assistant message that just finished, exactly as if the user had sent\n // it a moment later. Sent as one turn so a burst reads as a single\n // follow-up. Fire-and-forget via the ref so we don't block this turn's\n // completion bookkeeping (and to sidestep the self-reference).\n if (streamState.deferredInterjections.length > 0) {\n const followUp = streamState.deferredInterjections.join('\\n\\n')\n const threadParent = streamState.assistantId\n if (threadParent) {\n session.clearQueuedMessages(threadParent)\n }\n // In the conversation and workspace of the turn it steered, captured now: the view (or\n // the surface's workspace) may have moved on while the turn ran.\n void sendMessageRef.current?.(\n followUp,\n threadParent,\n streamState.workspaceId && streamState.conversationId !== 'new'\n ? {\n target: {\n workspaceId: streamState.workspaceId,\n conversationId: streamState.conversationId,\n },\n }\n : undefined\n )\n }\n\n // The conversations list cache is patched to 'in_progress' on stream\n // start (see the stream handlers). Patch it back to 'completed' here\n // so the Status column / sidebar reflect reality without a refetch.\n if (ownsGeneration) {\n const lastStatus = streamState.serverError ? 'failed' : 'completed'\n patchConversation(queryClient, streamState.conversationId, {\n last_message_status: lastStatus,\n })\n }\n\n // A new conversation changes the workspace's conversation_count \u2014 refresh\n // the workspaces list so onboarding's \"Ask ARBI\" step ticks reactively.\n if (isNewConversation && ownsGeneration) invalidateUserWorkspaces()\n\n if (ownsGeneration) {\n clearLoadingState(queryClient, streamState.conversationId)\n }\n } catch (error) {\n flushStreamingTokens(queryClient)\n const isAbort = error instanceof Error && error.name === 'AbortError'\n // The server stored the turn and only the connection dropped: the run is not over.\n const isDroppedConnection = !streamState.serverError && !isAbort && !streamState.isStopped()\n if (queuedContinuation && !streamState.hasStreamStarted) {\n // The server holds this follow-up in its queue already, and runs it in turn.\n if (isDroppedConnection && streamState.queuedUserMessageId) {\n if (streamState.queuedClientId) {\n session.removeQueuedMessage(streamState.queuedClientId)\n }\n void queryClient.invalidateQueries({\n queryKey: getThreadsQueryKey(streamState.conversationId),\n })\n return\n }\n failQueuedContinuation(queryClient, session, streamState)\n return\n }\n\n if (streamState.isStopped() || isAbort) {\n console.debug('Message sending was aborted by user')\n // The stopped stream leaves its assistant message loading with no stream behind it, and\n // a queued follow-up is not the owner so nothing else clears it. Clear it and re-read the\n // thread: a follow-up the server still runs is attached again, a stopped one shows its end.\n clearLoadingState(queryClient, streamState.conversationId)\n void queryClient.invalidateQueries({\n queryKey: getThreadsQueryKey(streamState.conversationId),\n })\n if (ownsActiveGeneration()) {\n session.setConversationGenerating(streamState.conversationId, false, null)\n patchConversation(queryClient, streamState.conversationId, {\n last_message_status: 'completed',\n })\n }\n return\n }\n\n console.error('Message sending failed:', error)\n if (!ownsActiveGeneration()) return\n\n // A dropped connection after the server stored the question does not end the turn: the\n // run goes on there. Failing it here offered Retry, which deleted the question under the\n // live answer (its answer then landed in the thread with no question) and, if the resend\n // failed too, left the view on the deleted turn. Re-read the thread instead: a running\n // answer is attached again, a failed one shows Retry, a finished one shows its answer.\n // Generation is held until the thread is re-read (or a few seconds pass, offline), so no\n // \"Response Incomplete\" alert offers to delete the question meanwhile.\n if (isDroppedConnection && streamState.userMessageId) {\n let timer: ReturnType<typeof setTimeout> | undefined\n await Promise.race([\n queryClient.invalidateQueries({\n queryKey: getThreadsQueryKey(streamState.conversationId),\n }),\n new Promise((resolve) => {\n timer = setTimeout(resolve, RECONCILE_TIMEOUT_MS)\n }),\n ])\n clearTimeout(timer)\n clearLoadingState(queryClient, streamState.conversationId)\n if (ownsActiveGeneration()) {\n session.setConversationGenerating(streamState.conversationId, false, null)\n }\n void invalidateConversationLists(queryClient)\n return\n }\n\n patchConversation(queryClient, streamState.conversationId, {\n last_message_status: 'failed',\n })\n\n // Open the upgrade modal if either (a) the error string carries\n // LiteLLM's ExceededBudget payload directly, or (b) the project's\n // cached AI usage is used up. Either path beats showing only\n // the conversation's generic error.\n const quota =\n quotaFromStreamError(error) ??\n cachedQuotaUsedUp(queryClient, session.getState().workspaceId)\n if (quota) chatHost?.onQuotaExceeded?.(quota)\n\n session.setConversationError(\n streamState.conversationId,\n error instanceof Error ? error.message : String(error),\n content\n )\n }\n },\n [\n selectedWorkspaceId,\n parentMessageId,\n queryClient,\n session,\n createHandlers,\n chatHost,\n arbi,\n invalidateUserWorkspaces,\n routeMessage,\n postComment,\n ]\n )\n\n // Keep the ref pointing at the latest sendMessage so the deferred-interjection\n // resubmit inside sendMessage always calls the current closure.\n sendMessageRef.current = sendMessage\n\n const handleCreateBranch = useCallback(\n async (parentMessageExtId: string | null, newContent: string) => {\n if (!newContent.trim() || !selectedWorkspaceId) return\n await sendMessage(newContent, parentMessageExtId, { branch: true })\n },\n [selectedWorkspaceId, sendMessage]\n )\n\n const handleSendMessage = useCallback(\n async (options?: SendMessageOptions) => {\n const currentMessage = selectDraft(session.getState()).trim()\n // The draft a shared thread starts with (`@<assistant> `) is not a question yet.\n if (!selectedWorkspaceId || !hasMessageBody(currentMessage, assistantLabels(assistantName)))\n return\n\n // A send consumes the suggested follow-up, whether or not it was used \u2014\n // the next turn's metadata brings a fresh one.\n session.setSuggestedQuery(null)\n\n // Chat runs against the server-side AI \u2014 there's nothing to queue offline.\n // Don't fire a mutation that would just pause and hang; tell the user.\n if (refuseChatWhenOffline()) return\n\n // While a turn is active, only true out-of-band controls use /interject.\n // Ordinary text still goes through the typed query endpoint, whose\n // arbi.message_queued event persists and renders it before the response gate\n // opens. The backend then either steers it into the next tool boundary or\n // starts a normal follow-up turn after the current final answer completes.\n if (isGenerating) {\n const convKey = session.getState().conversationId || 'new'\n const genState = session.getState().generating[convKey]\n const streamingAssistantId = genState?.streamingAssistantId\n\n // In a thread, a message that does not @mention the assistant is a comment between\n // people: post it straight away instead of queueing it into the running turn.\n const route = routeMessage(currentMessage)\n if (route.isComment && streamingAssistantId) {\n session.setDraft(draftAfterSend(queryClient, session, route.isComment, assistantName))\n await postComment(currentMessage, streamingAssistantId, route.mentions)\n return\n }\n\n if (streamingAssistantId) {\n const command = currentMessage.toLowerCase()\n const isPause = command === AGENT_CONTROL_COMMANDS.pause\n const isResume = command === AGENT_CONTROL_COMMANDS.resume\n const isReport =\n command === AGENT_CONTROL_COMMANDS.report ||\n command.startsWith(`${AGENT_CONTROL_COMMANDS.report} `)\n\n session.setDraft(draftAfterSend(queryClient, session, route.isComment, assistantName))\n\n if (isPause) {\n session.setAgentControlState(streamingAssistantId, 'pausing')\n } else if (isResume) {\n session.setAgentControlState(streamingAssistantId, 'resuming')\n } else if (isReport) {\n session.setAgentProbePending(streamingAssistantId, true)\n }\n\n if (isPause || isResume || isReport) {\n await arbi.assistant.interject(streamingAssistantId, currentMessage)\n } else {\n const queuedClientId = `queued-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`\n session.addQueuedMessage(streamingAssistantId, {\n clientId: queuedClientId,\n content: currentMessage,\n serverId: null,\n acknowledged: false,\n createdAt: Date.now(),\n })\n await sendMessage(currentMessage, streamingAssistantId, {\n ...options,\n queuedContinuation: true,\n queueOwnerAssistantId: streamingAssistantId,\n queuedClientId,\n })\n }\n return\n }\n // Keep the draft intact during the brief pre-stream window.\n return\n }\n\n const parentId = session.getState().cursor\n\n session.setDraft(\n draftAfterSend(queryClient, session, routeMessage(currentMessage).isComment, assistantName)\n )\n\n await sendMessage(currentMessage, parentId, options)\n },\n [\n selectedWorkspaceId,\n isGenerating,\n session,\n sendMessage,\n arbi,\n routeMessage,\n postComment,\n queryClient,\n assistantName,\n ]\n )\n\n const handleAbortGeneration = useCallback(async () => {\n // A second press (a double-click) must not stop the run again: it would cancel twice, and\n // once the local abort has landed it would clear the stopped-stream marker, so the stream's\n // error would read as a failed answer.\n const stream = session.getState().generating[conversationKey]\n if (stopInFlightRef.current || stream?.isGenerating === false) return\n // A tap right after a Stop must not stop the follow-up the queue started in the meantime.\n if (Date.now() - lastStopAtRef.current < STOP_REPEAT_WINDOW_MS) return\n lastStopAtRef.current = Date.now()\n stopInFlightRef.current = true\n try {\n // Stop the run on the server first; closing the stream alone leaves it running and\n // its answer would arrive later.\n const controller = stream?.abortController ?? null\n stoppedStreamRef.current = controller\n let streamKey = conversationKey\n let responseId = stream?.streamingAssistantId ?? null\n // Pressed before the stream reported its id: the run already exists on the server, so wait\n // for the id instead of only closing the stream. Further presses meanwhile do nothing.\n if (!responseId && controller) {\n const reported = await waitForResponseId(session, controller)\n if (reported) {\n streamKey = reported.conversationKey\n responseId = reported.responseId\n }\n }\n // In a sub-agent's branch this is the run that delegated it.\n const threads =\n queryClient.getQueryData<ThreadsResponse>(getThreadsQueryKey(streamKey))?.threads ?? []\n const runId = responseId ? getRunToCancel(threads, responseId) : null\n if (runId) {\n try {\n await arbi.assistant.cancel(runId)\n } catch {\n // Still stop here (the run may already have ended); say the server may keep going.\n notify.warning(\n \"Stopped here, but the server didn't confirm: the answer may still appear later.\"\n )\n }\n }\n // The cancel is awaited, and the server starts the next queued follow-up as soon as it lands:\n // that follow-up may already own this conversation's generation state and attach. Only close\n // the stream this Stop belongs to, or the next answer goes silent (\"Working\", no stop square).\n const current = session.getState().generating[streamKey]\n const isStoppedStream = controller\n ? current?.abortController === controller\n : !current?.streamingAssistantId || current.streamingAssistantId === responseId\n if (isStoppedStream) session.abortConversationGeneration(streamKey)\n // A reattached run has no local controller: close its stream too, or it keeps painting. The\n // attach follows this conversation's streaming message (in a sub-agent branch, the branch's\n // reply), not the delegating run that was cancelled, so match it by that id.\n if (responseId) disconnectAttachedRun(streamKey, responseId)\n } finally {\n stopInFlightRef.current = false\n }\n }, [session, arbi, conversationKey, queryClient])\n\n const handleRetryOrphanedMessage = useCallback(\n async (messageContent: string, parentId: string | null, messageExtId: string) => {\n // One retry at a time: the alert's Retry and the composer's retry (or a double click) must\n // not delete and resend twice. Released however the retry ends.\n if (retryInFlightRef.current) return\n // Offline the delete would be paused and the resend refused, leaving neither done.\n if (refuseChatWhenOffline()) return\n retryInFlightRef.current = true\n try {\n // A failed parent (a follow-up the restart sweep failed behind a failed answer) is\n // refused by the server, so the resend goes to the nearest message above it instead.\n const replyTo = currentConversationId\n ? resolveReplyTarget(queryClient, currentConversationId, parentId)\n : parentId\n if (!replyTo && currentConversationId) {\n try {\n await arbi.conversations.delete(currentConversationId)\n removeConversationFromLists(queryClient, currentConversationId)\n session.startNewConversation()\n } catch (error) {\n console.error('Failed to delete conversation with orphaned first message:', error)\n }\n } else if (replyTo) {\n try {\n await arbi.conversations.deleteMessage(messageExtId)\n // The message and its replies are gone from whichever thread held them.\n void queryClient.invalidateQueries(allConversationThreads)\n } catch (error) {\n console.error('Failed to delete orphaned message:', error)\n }\n }\n\n await sendMessage(messageContent, replyTo)\n } finally {\n retryInFlightRef.current = false\n }\n },\n [currentConversationId, arbi, session, sendMessage, queryClient]\n )\n\n const handleRetrySend = useCallback(async () => {\n if (isGenerating || !lastFailedMessage || retryInFlightRef.current) return\n if (refuseChatWhenOffline()) return\n retryInFlightRef.current = true\n try {\n session.clearConversationError(conversationKey)\n // sendMessage replies to the nearest message the server accepts: the view may still point at\n // a turn a Retry deleted, or at a failed answer.\n const parentId = session.getState().cursor\n await sendMessage(lastFailedMessage, parentId)\n } finally {\n retryInFlightRef.current = false\n }\n }, [isGenerating, lastFailedMessage, session, conversationKey, sendMessage])\n\n const clearErrorState = useCallback(() => {\n session.clearConversationError(conversationKey)\n }, [session, conversationKey])\n\n // Clear error state when starting a new conversation\n useEffect(() => {\n if (currentConversationId === null) {\n session.clearConversationError('new')\n }\n }, [currentConversationId, session])\n\n return {\n handleCreateBranch,\n handleSendMessage,\n handleAbortGeneration,\n handleRetrySend,\n handleRetryOrphanedMessage,\n clearErrorState,\n }\n}\n"],
5
+ "mappings": "AAOA,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AACrC,SAAS,aAAa,WAAW,QAAQ,gBAAgB;AACzD,SAAS,sBAAwC;AACjD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAEP,SAAS,cAAc;AACvB,SAAS,qBAAqB;AAC9B,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,aAAa,2BAA2B;AAEjD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,wBAAwB;AACjC,SAAS,gBAAgB,mBAAmB,uBAAuB;AACnE,SAAS,2BAA2B;AACpC,SAAS,kBAAkB,iBAAiB;AAC5C,SAAS,oBAAoB,uBAAuB;AACpD,SAAS,0BAA0B;AACnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,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B;AAAA,UAC/B,SAAS,OAAO;AACd,oBAAQ,MAAM,8DAA8D,KAAK;AAAA,UACnF;AAAA,QACF,WAAW,SAAS;AAClB,cAAI;AACF,kBAAM,KAAK,cAAc,cAAc,YAAY;AAEnD,iBAAK,YAAY,kBAAkB,sBAAsB;AAAA,UAC3D,SAAS,OAAO;AACd,oBAAQ,MAAM,sCAAsC,KAAK;AAAA,UAC3D;AAAA,QACF;AAEA,cAAM,YAAY,gBAAgB,OAAO;AAAA,MAC3C,UAAE;AACA,yBAAiB,UAAU;AAAA,MAC7B;AAAA,IACF;AAAA,IACA,CAAC,uBAAuB,MAAM,SAAS,aAAa,WAAW;AAAA,EACjE;AAEA,QAAM,kBAAkB,YAAY,YAAY;AAC9C,QAAI,gBAAgB,CAAC,qBAAqB,iBAAiB,QAAS;AACpE,QAAI,sBAAsB,EAAG;AAC7B,qBAAiB,UAAU;AAC3B,QAAI;AACF,cAAQ,uBAAuB,eAAe;AAG9C,YAAM,WAAW,QAAQ,SAAS,EAAE;AACpC,YAAM,YAAY,mBAAmB,QAAQ;AAAA,IAC/C,UAAE;AACA,uBAAiB,UAAU;AAAA,IAC7B;AAAA,EACF,GAAG,CAAC,cAAc,mBAAmB,SAAS,iBAAiB,WAAW,CAAC;AAE3E,QAAM,kBAAkB,YAAY,MAAM;AACxC,YAAQ,uBAAuB,eAAe;AAAA,EAChD,GAAG,CAAC,SAAS,eAAe,CAAC;AAG7B,YAAU,MAAM;AACd,QAAI,0BAA0B,MAAM;AAClC,cAAQ,uBAAuB,KAAK;AAAA,IACtC;AAAA,EACF,GAAG,CAAC,uBAAuB,OAAO,CAAC;AAEnC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -39,15 +39,10 @@ function useConversationSettings() {
39
39
  if (trimmed === conversation?.title) return;
40
40
  update.mutate({ conversationId, patch: { title: trimmed } });
41
41
  }, [conversationId, isOwner, title, conversation?.title, update]);
42
- const setShared = useCallback(
43
- (shared) => {
44
- if (!conversationId || !isOwner || isShared === shared) return;
45
- update.mutate({ conversationId, patch: { shared } });
46
- },
47
- [conversationId, isOwner, isShared, update]
48
- );
49
- const share = useCallback(() => setShared(true), [setShared]);
50
- const unshare = useCallback(() => setShared(false), [setShared]);
42
+ const share = useCallback(() => {
43
+ if (!conversationId || !isOwner || isShared) return;
44
+ update.mutate({ conversationId, patch: { shared: true } });
45
+ }, [conversationId, isOwner, isShared, update]);
51
46
  const resetToDefaults = useCallback(async () => {
52
47
  try {
53
48
  const { data } = await refetchSystemDefaults();
@@ -68,7 +63,6 @@ function useConversationSettings() {
68
63
  isSharing: pending !== void 0 && "shared" in pending,
69
64
  saveTitle,
70
65
  share,
71
- unshare,
72
66
  resetToDefaults
73
67
  };
74
68
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/chat/useConversationSettings.ts"],
4
- "sourcesContent": ["/**\n * The open conversation's settings: its title and sharing (one PATCH of the conversation, which\n * the server resolves from the conversation's own workspace), and the model its next turn runs on.\n * The views are `ConnectedConversationSettings` in `@arbidocs/blocks`.\n */\n\nimport { useCallback, useEffect, useState } from 'react'\nimport { useConfig } from '../hooks'\nimport { useUserSettings } from '../account/settings'\nimport { isFullConfig } from '../config/config-hooks'\nimport { useArbiSessionState, useArbiSessionStore } from '../session'\nimport { useArbiSession } from '../session/signed-in'\nimport { useConversationItems, useUpdateConversation } from '../workforce'\nimport { resolveConfigModel } from './config-model'\nimport { useConversationData } from './useConversationData'\n\n/** Longest title the server keeps. */\nconst TITLE_MAX = 50\n\nexport function useConversationSettings() {\n const session = useArbiSessionStore()\n const conversationId = useArbiSessionState((s) => s.conversationId)\n const chatModel = useArbiSessionState((s) => s.chatModel)\n const parentMessageId = useArbiSessionState((s) => s.cursor)\n const currentUser = useArbiSession().user\n\n const { messageHistory } = useConversationData()\n const { conversations } = useConversationItems()\n const { data: userSettings } = useUserSettings()\n\n // The config the next turn runs on: the one picked, else the parent message's, else the user's\n // last saved one, else the system default.\n const parentMessage = messageHistory?.find((m) => m.external_id === parentMessageId)\n const configToLoad =\n chatModel || parentMessage?.config_ext_id || userSettings?.last_config || 'default'\n const { data: activeConfig } = useConfig(configToLoad)\n const { refetch: refetchSystemDefaults } = useConfig('default')\n\n const conversation = conversations.find((c) => c.external_id === conversationId)\n const isOwner = !!conversation && conversation.created_by_ext_id === currentUser?.external_id\n const isShared = conversation?.is_shared ?? false\n\n const [title, setTitle] = useState('')\n useEffect(() => {\n setTitle(conversation?.title || '')\n }, [conversation?.title])\n\n // The picker shows the model of the config the next turn runs on.\n useEffect(() => {\n if (isFullConfig(activeConfig)) session.setChatModelName(resolveConfigModel(activeConfig))\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeConfig, configToLoad])\n\n // Rename, share and unshare are all the one PATCH; which is in flight shows in its body.\n const update = useUpdateConversation()\n const pending = update.isPending ? update.variables?.patch : undefined\n\n const saveTitle = useCallback(() => {\n const trimmed = title.trim()\n if (!conversationId || !isOwner || !trimmed || trimmed.length > TITLE_MAX) return\n // Leaving the field without a change sends nothing.\n if (trimmed === conversation?.title) return\n update.mutate({ conversationId, patch: { title: trimmed } })\n }, [conversationId, isOwner, title, conversation?.title, update])\n\n const setShared = useCallback(\n (shared: boolean) => {\n if (!conversationId || !isOwner || isShared === shared) return\n update.mutate({ conversationId, patch: { shared } })\n },\n [conversationId, isOwner, isShared, update]\n )\n const share = useCallback(() => setShared(true), [setShared])\n const unshare = useCallback(() => setShared(false), [setShared])\n\n /** Back to the system default config: the picked one is dropped. */\n const resetToDefaults = useCallback(async () => {\n try {\n const { data } = await refetchSystemDefaults()\n session.setChatModel(undefined)\n if (isFullConfig(data)) session.setChatModelName(resolveConfigModel(data))\n } catch (error) {\n console.error('Failed to reset to system defaults:', error)\n }\n }, [refetchSystemDefaults, session])\n\n return {\n /** No message yet: nothing to title or share. */\n isNewConversation: !parentMessageId,\n title,\n setTitle,\n isOwner,\n isShared,\n isSavingTitle: pending !== undefined && 'title' in pending,\n isSharing: pending !== undefined && 'shared' in pending,\n saveTitle,\n share,\n unshare,\n resetToDefaults,\n }\n}\n"],
5
- "mappings": "AAMA,SAAS,aAAa,WAAW,gBAAgB;AACjD,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB,2BAA2B;AACzD,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB,6BAA6B;AAC5D,SAAS,0BAA0B;AACnC,SAAS,2BAA2B;AAGpC,MAAM,YAAY;AAEX,SAAS,0BAA0B;AACxC,QAAM,UAAU,oBAAoB;AACpC,QAAM,iBAAiB,oBAAoB,CAAC,MAAM,EAAE,cAAc;AAClE,QAAM,YAAY,oBAAoB,CAAC,MAAM,EAAE,SAAS;AACxD,QAAM,kBAAkB,oBAAoB,CAAC,MAAM,EAAE,MAAM;AAC3D,QAAM,cAAc,eAAe,EAAE;AAErC,QAAM,EAAE,eAAe,IAAI,oBAAoB;AAC/C,QAAM,EAAE,cAAc,IAAI,qBAAqB;AAC/C,QAAM,EAAE,MAAM,aAAa,IAAI,gBAAgB;AAI/C,QAAM,gBAAgB,gBAAgB,KAAK,CAAC,MAAM,EAAE,gBAAgB,eAAe;AACnF,QAAM,eACJ,aAAa,eAAe,iBAAiB,cAAc,eAAe;AAC5E,QAAM,EAAE,MAAM,aAAa,IAAI,UAAU,YAAY;AACrD,QAAM,EAAE,SAAS,sBAAsB,IAAI,UAAU,SAAS;AAE9D,QAAM,eAAe,cAAc,KAAK,CAAC,MAAM,EAAE,gBAAgB,cAAc;AAC/E,QAAM,UAAU,CAAC,CAAC,gBAAgB,aAAa,sBAAsB,aAAa;AAClF,QAAM,WAAW,cAAc,aAAa;AAE5C,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,EAAE;AACrC,YAAU,MAAM;AACd,aAAS,cAAc,SAAS,EAAE;AAAA,EACpC,G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mB,CAAC;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,eAAe,YAAY,UAAa,WAAW;AAAA,IACnD,WAAW,YAAY,UAAa,YAAY;AAAA,IAChD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["/**\n * The open conversation's settings: its title and sharing (one PATCH of the conversation, which\n * the server resolves from the conversation's own workspace), and the model its next turn runs on.\n * The views are `ConnectedConversationSettings` in `@arbidocs/blocks`.\n */\n\nimport { useCallback, useEffect, useState } from 'react'\nimport { useConfig } from '../hooks'\nimport { useUserSettings } from '../account/settings'\nimport { isFullConfig } from '../config/config-hooks'\nimport { useArbiSessionState, useArbiSessionStore } from '../session'\nimport { useArbiSession } from '../session/signed-in'\nimport { useConversationItems, useUpdateConversation } from '../workforce'\nimport { resolveConfigModel } from './config-model'\nimport { useConversationData } from './useConversationData'\n\n/** Longest title the server keeps. */\nconst TITLE_MAX = 50\n\nexport function useConversationSettings() {\n const session = useArbiSessionStore()\n const conversationId = useArbiSessionState((s) => s.conversationId)\n const chatModel = useArbiSessionState((s) => s.chatModel)\n const parentMessageId = useArbiSessionState((s) => s.cursor)\n const currentUser = useArbiSession().user\n\n const { messageHistory } = useConversationData()\n const { conversations } = useConversationItems()\n const { data: userSettings } = useUserSettings()\n\n // The config the next turn runs on: the one picked, else the parent message's, else the user's\n // last saved one, else the system default.\n const parentMessage = messageHistory?.find((m) => m.external_id === parentMessageId)\n const configToLoad =\n chatModel || parentMessage?.config_ext_id || userSettings?.last_config || 'default'\n const { data: activeConfig } = useConfig(configToLoad)\n const { refetch: refetchSystemDefaults } = useConfig('default')\n\n const conversation = conversations.find((c) => c.external_id === conversationId)\n const isOwner = !!conversation && conversation.created_by_ext_id === currentUser?.external_id\n const isShared = conversation?.is_shared ?? false\n\n const [title, setTitle] = useState('')\n useEffect(() => {\n setTitle(conversation?.title || '')\n }, [conversation?.title])\n\n // The picker shows the model of the config the next turn runs on.\n useEffect(() => {\n if (isFullConfig(activeConfig)) session.setChatModelName(resolveConfigModel(activeConfig))\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeConfig, configToLoad])\n\n // Rename and share are the one PATCH; which is in flight shows in its body. Sharing is one-way:\n // nothing here makes a shared conversation private again (the server refuses it).\n const update = useUpdateConversation()\n const pending = update.isPending ? update.variables?.patch : undefined\n\n const saveTitle = useCallback(() => {\n const trimmed = title.trim()\n if (!conversationId || !isOwner || !trimmed || trimmed.length > TITLE_MAX) return\n // Leaving the field without a change sends nothing.\n if (trimmed === conversation?.title) return\n update.mutate({ conversationId, patch: { title: trimmed } })\n }, [conversationId, isOwner, title, conversation?.title, update])\n\n const share = useCallback(() => {\n if (!conversationId || !isOwner || isShared) return\n update.mutate({ conversationId, patch: { shared: true } })\n }, [conversationId, isOwner, isShared, update])\n\n /** Back to the system default config: the picked one is dropped. */\n const resetToDefaults = useCallback(async () => {\n try {\n const { data } = await refetchSystemDefaults()\n session.setChatModel(undefined)\n if (isFullConfig(data)) session.setChatModelName(resolveConfigModel(data))\n } catch (error) {\n console.error('Failed to reset to system defaults:', error)\n }\n }, [refetchSystemDefaults, session])\n\n return {\n /** No message yet: nothing to title or share. */\n isNewConversation: !parentMessageId,\n title,\n setTitle,\n isOwner,\n isShared,\n isSavingTitle: pending !== undefined && 'title' in pending,\n isSharing: pending !== undefined && 'shared' in pending,\n saveTitle,\n share,\n resetToDefaults,\n }\n}\n"],
5
+ "mappings": "AAMA,SAAS,aAAa,WAAW,gBAAgB;AACjD,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB,2BAA2B;AACzD,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB,6BAA6B;AAC5D,SAAS,0BAA0B;AACnC,SAAS,2BAA2B;AAGpC,MAAM,YAAY;AAEX,SAAS,0BAA0B;AACxC,QAAM,UAAU,oBAAoB;AACpC,QAAM,iBAAiB,oBAAoB,CAA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AA,EAC7D,GAAG,CAAC,gBAAgB,SAAS,OAAO,cAAc,OAAO,MAAM,CAAC;AAEhE,QAAM,QAAQ,YAAY,MAAM;AAC9B,QAAI,CAAC,kBAAkB,CAAC,WAAW,SAAU;AAC7C,WAAO,OAAO,EAAE,gBAAgB,OAAO,EAAE,QAAQ,KAAK,EAAE,CAAC;AAAA,EAC3D,GAAG,CAAC,gBAAgB,SAAS,UAAU,MAAM,CAAC;AAG9C,QAAM,kBAAkB,YAAY,YAAY;AAC9C,QAAI;AACF,YAAM,EAAE,KAAK,IAAI,MAAM,sBAAsB;AAC7C,cAAQ,aAAa,MAAS;AAC9B,UAAI,aAAa,IAAI,EAAG,SAAQ,iBAAiB,mBAAmB,IAAI,CAAC;AAAA,IAC3E,SAAS,OAAO;AACd,cAAQ,MAAM,uCAAuC,KAAK;AAAA,IAC5D;AAAA,EACF,GAAG,CAAC,uBAAuB,OAAO,CAAC;AAEnC,SAAO;AAAA;AAAA,IAEL,mBAAmB,CAAC;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,eAAe,YAAY,UAAa,WAAW;AAAA,IACnD,WAAW,YAAY,UAAa,YAAY;AAAA,IAChD;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -176,8 +176,13 @@ var arbiQueryKeys = {
176
176
  * `['arbi', 'databases', 'rows', workspaceId, databaseId, params]`.
177
177
  */
178
178
  databaseRows: (workspaceId, databaseId, params) => workspaceId === void 0 ? ["arbi", "databases", "rows"] : params === void 0 ? ["arbi", "databases", "rows", workspaceId, databaseId ?? ""] : ["arbi", "databases", "rows", workspaceId, databaseId ?? "", params],
179
- /** The saved dashboards of a store's scope (the user's own, or a workspace's database). */
180
- dashboards: (scope) => ["arbi", "dashboards", scope],
179
+ /** A workspace's pages; no id: every workspace's. */
180
+ pages: (workspaceId) => workspaceId === void 0 ? ["arbi", "pages"] : ["arbi", "pages", workspaceId],
181
+ /**
182
+ * Saved table views a workspace's session sees: of one table (a database id or `documents`);
183
+ * no target: every table's; no workspace: every workspace's.
184
+ */
185
+ tableViews: (workspaceId, target) => workspaceId === void 0 ? ["arbi", "table-views"] : target === void 0 ? ["arbi", "table-views", workspaceId] : ["arbi", "table-views", workspaceId, target],
181
186
  /** A database's rows grouped and measured (a chart); no workspace: every database's. */
182
187
  databaseAggregate: (workspaceId, databaseId, request) => workspaceId === void 0 ? ["arbi", "databases", "aggregate"] : ["arbi", "databases", "aggregate", workspaceId, databaseId ?? "", request ?? {}],
183
188
  // ── Configs, health ─────────────────────────────────────────────────────────────────────────
@@ -362,5 +367,5 @@ exports.mailQueryKeys = mailQueryKeys;
362
367
  exports.useArbi = useArbi;
363
368
  exports.useArbiHost = useArbiHost;
364
369
  exports.useDeploymentDomain = useDeploymentDomain;
365
- //# sourceMappingURL=chunk-FE6ZSNZE.cjs.map
366
- //# sourceMappingURL=chunk-FE6ZSNZE.cjs.map
370
+ //# sourceMappingURL=chunk-5FQB5F2F.cjs.map
371
+ //# sourceMappingURL=chunk-5FQB5F2F.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/host/config.ts","../src/useArbi.ts","../src/query-keys.ts"],"names":["useContext","ArbiHostContext"],"mappings":";;;;;AA4HO,SAAS,WAAA,GAA8B;AAC5C,EAAA,OAAOA,iBAAWC,iCAAe,CAAA;AACnC;;;ACvHO,SAAS,OAAA,GAAgB;AAC9B,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,WAAA,EAAY;AAC7B,EAAA,IAAI,CAAC,IAAA,EAAM;AACT,IAAA,MAAM,IAAI,MAAM,0DAA0D,CAAA;AAAA,EAC5E;AACA,EAAA,OAAO,IAAA;AACT;AAOO,SAAS,mBAAA,GAA0C;AACxD,EAAA,OAAO,WAAA,EAAY,CAAE,IAAA,EAAM,mBAAA,EAAoB;AACjD;;;ACNO,IAAM,aAAA,GAAgB;AAAA,EAC3B,UAAA,EAAY,MAAM,CAAC,MAAA,EAAQ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AU,QAAQ,CAAA;AAAA;AAAA,EAEvD,SAAA,EAAW,MAAM,CAAC,MAAA,EAAQ,QAAQ,QAAQ,CAAA;AAAA,EAC1C,QAAQ,CAAC,SAAA,EAA+B,UAAA,EAAsB,SAAA,KAC5D,CAAC,MAAA,EAAQ,MAAA,EAAQ,QAAA,EAAU,SAAA,EAAW,WAAW,IAAA,CAAK,GAAG,GAAG,SAAA,CAAU,IAAA,CAAK,GAAG,CAAC,CAAA;AAAA;AAAA;AAAA,EAGjF,YAAA,EAAc,MAAM,CAAC,MAAA,EAAQ,oBAAoB,CAAA;AAAA;AAAA,EAEjD,QAAA,EAAU,MAAM,CAAC,MAAA,EAAQ,QAAQ,UAAU,CAAA;AAAA;AAAA,EAE3C,YAAA,EAAc,CAAC,SAAA,EAA+B,OAAA,KAC5C,CAAC,MAAA,EAAQ,MAAA,EAAQ,eAAA,EAAiB,SAAA,EAAW,OAAO,CAAA;AAAA,EACtD,cAAA,EAAgB,CAAC,SAAA,EAAmB,SAAA,EAAmB,YAAA,KACrD,CAAC,MAAA,EAAQ,MAAA,EAAQ,iBAAA,EAAmB,SAAA,EAAW,SAAA,EAAW,YAAY;AAC1E;AAMO,IAAM,mBAAmB,CAC9B,WAAA,EACA,SACA,IAAA,KAEA,OAAA,KAAY,SACP,CAAC,MAAA,EAAQ,eAAA,EAAiB,WAAW,IACrC,CAAC,MAAA,EAAQ,iBAAiB,WAAA,EAAa,OAAA,EAAS,QAAQ,KAAK;AAG7D,SAAS,eAAA,CAAgB,UAA8B,MAAA,EAAqC;AACjG,EAAA,OAAO,MAAA,CAAO,MAAM,CAAC,IAAA,EAAM,MAAM,QAAA,CAAS,CAAC,MAAM,IAAI,CAAA;AACvD","file":"chunk-5FQB5F2F.cjs","sourcesContent":["/**\n * What a host hands the `@arbidocs/react` hooks, as one configuration (`<ArbiHost config>`). Every\n * field is optional: without one the hooks use their own default. `@arbidocs/blocks` extends it\n * with the blocks domains (environment, billing, viewer, …).\n *\n * A field whose value lives in the host's state is a hook (`use…`), called by the hooks and kits\n * that need it, so the configuration itself stays one stable object for the host's life.\n */\n\nimport { useContext } from 'react'\nimport type { Arbi } from '@arbidocs/sdk/browser'\nimport type { AccountClient } from '../account/client'\nimport type { CalendarSupport } from '../calendar/support'\nimport type { MeetingChatRef } from '../calls/meeting-chat'\nimport type { ActiveCall } from '../calls/session'\nimport type { ArbiChatHost } from '../chat/host'\nimport type { DocumentsSupport } from '../documents/support'\nimport type { MailClient } from '../mail/client'\nimport type { ArbiSessionStore } from '../session/store'\nimport type { DictateContextValue } from '../ui/DictateContext'\nimport type { EntityVocabulary } from '../entities/vocabulary'\nimport type { ArbiHostConnection } from './ArbiHost'\nimport type { ArbiFeatures } from './features'\nimport { ArbiHostContext } from './context'\nimport type { DashboardsHost } from '../datasets/registry'\n\n/** The mail client, and whether mail is on for the signed-in user. */\nexport interface MailHost {\n client: MailClient\n /**\n * Whether mail reads run (signed in and entitled), and the server session the mailbox is\n * unlocked for: unlocking runs again when it changes (`null`: none yet, nothing is unlocked).\n * Absent: on, for one session.\n */\n useStatus?: () => { enabled: boolean; sessionKey: string | null }\n /**\n * The mail waiting in this device's Outbox (written offline), by status, while `enabled` (Mail\n * switched on); the offline status counts it as waiting work. Absent: no Outbox.\n */\n useOutbox?: (enabled: boolean) => ReadonlyArray<{ status: string }>\n /** The Outbox's folder, opened through `openMail({ folder })`. */\n outboxFolder?: string\n}\n\n/** The account client of the settings kits, and whether account reads run (signed in). */\nexport interface AccountHost {\n client: AccountClient\n /** Absent: always. */\n useEnabled?: () => boolean\n}\n\n/** Where the call panel goes in the host's layout. */\nexport type CallSlotMode = 'docked' | 'main'\n\n/** What the calls need from the host: navigation and layout are the host's. */\nexport interface CallsHost {\n /**\n * Show a call's meeting chat: an end-to-end chat, or a workspace meeting thread. Absent: the\n * in-call \"Open meeting chat\" does nothing.\n */\n openMeetingChat?: (ref: MeetingChatRef) => void\n /**\n * Once connected, show the call's conversation (its chat and live transcript) beside the call.\n * Absent: nothing is shown.\n */\n showConversation?: (call: ActiveCall) => void | Promise<void>\n /**\n * The element whose box the shown call fills: the right-hand dock, or (a webinar's audience) the\n * main area. The host claims its slot while `shown` and calls `onLost` when another panel takes\n * it (the call then minimises). Absent: the call floats at the right edge.\n */\n useSlot?: (mode: CallSlotMode, shown: boolean, onLost: () => void) => HTMLElement | null\n}\n\nexport interface ArbiHostConfig {\n /**\n * The SDK on the signed-in session. A host with its own login passes one on its session\n * (`new Arbi({ url, session })`); a blocks-only site gets one from `defaultHost`. A new instance (a\n * new session, a newly opened workspace) re-renders every hook.\n */\n arbi?: Arbi\n /** The session state the kits share. Absent: an in-memory one per top-level host. */\n session?: ArbiSessionStore\n /** Live processing, uploads and the host's document actions. Absent: the package's own. */\n documents?: DocumentsSupport\n /** The calendar kept on this device and account OAuth. Absent: online only, the user's connectors. */\n calendar?: CalendarSupport\n /** Absent: mail on the `arbi` session. */\n mail?: MailHost\n /** Absent: the account on the `arbi` session. */\n account?: AccountHost\n /** Absent: calls open no meeting chat from the room. */\n calls?: CallsHost\n /**\n * The parts of the product the user switches on or off, and where each switch is kept (the user's\n * settings, or this device), read with `useFeature(name)`. The call UI also follows the `calls`\n * feature, on top of the server's calls config. Absent, or a feature not listed: on.\n */\n features?: ArbiFeatures\n /** Dictation for every `dictate` field. Absent: no mic button. */\n dictate?: DictateContextValue\n /** The sign-in layer of a blocks-only site (`defaultHost` in `@arbidocs/blocks/connect`). */\n connection?: ArbiHostConnection\n /** Where the chat engine's side effects go (documents shown, mail drafts, used-up quota). */\n chat?: ArbiChatHost\n /**\n * The site's words for the entities (`{ PROJECT: 'Matter' }`), read by every kit through\n * `getEntityLabel`. Absent: the registry's (\"Project\", \"Workspace\", \"Thread\", …).\n */\n vocabulary?: EntityVocabulary\n /**\n * What the site calls its assistant where people address it: the `@<name>` offered in a chat's\n * mention menu, the draft a shared thread starts with, and the name a message is routed to the\n * assistant on. Absent: \"ARBI\".\n */\n assistantName?: string\n /**\n * Charts and dashboards: more data sources (an external feed, a source relabelled in the site's\n * words). Pages themselves are the workspace's (`/v1/pages`). Absent: the built-in sources.\n */\n dashboards?: DashboardsHost\n}\n\n/** The host configuration in scope (`{}` outside an `<ArbiHost>`). */\nexport function useArbiHost(): ArbiHostConfig {\n return useContext(ArbiHostContext) as ArbiHostConfig\n}\n","/**\n * The `Arbi` of the host configuration (`<ArbiHost config={{ arbi }}>`).\n */\n\nimport type { Arbi } from '@arbidocs/sdk/browser'\nimport { useArbiHost } from './host/config'\n\nexport function useArbi(): Arbi {\n const { arbi } = useArbiHost()\n if (!arbi) {\n throw new Error('useArbi() needs an <ArbiHost> whose config has an `arbi`')\n }\n return arbi\n}\n\n/**\n * The deployment domain the user's keys are derived for, as the host's `Arbi` computes it\n * (`deploymentDomain`, else the API URL's hostname). `undefined` without one. The document tools\n * default their `deploymentDomain` (needed for e-signing) to it.\n */\nexport function useDeploymentDomain(): string | undefined {\n return useArbiHost().arbi?.getDeploymentDomain()\n}\n","/**\n * The one query-key factory of the ARBI front end: every React Query key and mutation key the\n * packages and the app use is built here, under `['arbi', …]`. Literal key arrays anywhere else\n * fail the `arbi/query-keys-from-factory` lint rule and `query-keys.guard.test.ts`, so a key can't\n * drift from the queries it names (a stale literal reads or invalidates nothing, silently).\n *\n * Dependency-free on purpose (types only): e2e helpers import it and pass keys into the page.\n */\n\nimport type {\n CalendarWindow,\n ListEventsParams,\n OverlayLayerName,\n RoomQuery,\n} from '@arbidocs/sdk/browser'\n\nexport const arbiQueryKeys = {\n fileShares: () => ['arbi', 'fileShares'] as const,\n fileShare: (id: string) => ['arbi', 'fileShare', id] as const,\n fileSharePdf: (id: string, status?: string) => ['arbi', 'fileSharePdf', id, status] as const,\n workspaces: () => ['arbi', 'workspaces'] as const,\n /** Every workspace's member list: what a workspace switch drops. */\n allWorkspaceUsers: () => ['arbi', 'workspaceUsers'] as const,\n workspaceUsers: (workspaceId: string) => ['arbi', 'workspaceUsers', workspaceId] as const,\n /** Every workspace's documents list: the prefix a write patches when it does not know the workspace. */\n allDocuments: () => ['arbi', 'documents'] as const,\n documents: (workspaceId: string) => ['arbi', 'documents', workspaceId] as const,\n /** One document (a viewer's); writes keep it current next to the list. */\n document: (docId: string) => ['arbi', 'document', docId] as const,\n documentsById: (docIds: string[]) =>\n ['arbi', 'documentsById', [...docIds].sort().join(',')] as const,\n /** Every workspace's near-duplicate pairs. */\n allSimilarDocuments: () => ['arbi', 'similarDocuments'] as const,\n similarDocuments: (workspaceId: string, threshold: number) =>\n ['arbi', 'similarDocuments', workspaceId, threshold] as const,\n /** Every version list: the prefix a new version invalidates. */\n allDocumentVersions: () => ['arbi', 'documentVersions'] as const,\n documentVersions: (docId: string) => ['arbi', 'documentVersions', docId] as const,\n conversations: (workspaceId: string) => ['arbi', 'conversations', workspaceId] as const,\n /** Every workspace's conversation list (and threads): the prefix a conversation write invalidates. */\n allConversations: () => ['arbi', 'conversations'] as const,\n /** A conversation's threads, under the conversations prefix (ids are unique across workspaces). */\n conversationThreads: (conversationId: string) =>\n ['arbi', 'conversations', conversationId, 'threads'] as const,\n /** One stored message with everything the server keeps on it (its trace and metadata). */\n messageDetails: (messageId: string) => ['arbi', 'messageDetails', messageId] as const,\n /** The backend's built-in slash commands. */\n assistantCommands: () => ['arbi', 'assistantCommands'] as const,\n /** Every workspace's tags (lists, tables and kinds): what a cross-workspace change refreshes. */\n allTags: () => ['arbi', 'tags'] as const,\n tags: (workspaceId: string) => ['arbi', 'tags', workspaceId] as const,\n /** Under the workspace's tags: the kinds' fields (refreshed with the tags). */\n tagKinds: (workspaceId: string) => ['arbi', 'tags', workspaceId, 'kinds'] as const,\n /** Every filtered list (a table of tags): what a tag write refreshes, the whole list aside. */\n tagLists: (workspaceId: string) => ['arbi', 'tags', workspaceId, 'list'] as const,\n /** Under the workspace's tags: a tag, doctag or fact write that invalidates `tags` refreshes it. */\n tagList: (workspaceId: string, query: string) =>\n ['arbi', 'tags', workspaceId, 'list', query] as const,\n /** A kind's fields, under the workspace's tags. */\n tagKind: (workspaceId: string, kind: string) =>\n ['arbi', 'tags', workspaceId, 'kind', kind] as const,\n /** A task's history, under the conversations prefix: every conversation write refreshes it. */\n conversationActivity: (conversationId: string) =>\n ['arbi', 'conversations', conversationId, 'activity'] as const,\n thumbnails: (docIds: string[]) => ['arbi', 'thumbnails', [...docIds].sort().join(',')] as const,\n /** Every stage of a document's parsed content. */\n parsedDocument: (docId: string) => ['arbi', 'parsedDoc', docId] as const,\n parsedDoc: (docId: string, stage: string) => ['arbi', 'parsedDoc', docId, stage] as const,\n agents: () => ['arbi', 'agents'] as const,\n sessions: () => ['arbi', 'sessions'] as const,\n health: () => ['arbi', 'health'] as const,\n workflows: () => ['arbi', 'workflows'] as const,\n /** Under `workflows()`: a workflow write or run refreshes its runs too. */\n workflowRuns: (workflowId: string) => ['arbi', 'workflows', workflowId, 'runs'] as const,\n /** Every workspace's facts: the prefix a fact write invalidates. */\n allFacts: () => ['arbi', 'facts'] as const,\n facts: (workspaceId: string) => ['arbi', 'facts', workspaceId] as const,\n configs: () => ['arbi', 'configs'] as const,\n activity: () => ['arbi', 'activity'] as const,\n /** Every transfer query (jobs, lists, plans): what a finished job refreshes. */\n allWorkspaceTransfers: () => ['arbi', 'workspaceTransfers'] as const,\n /** The caller's recent transfer jobs out of a workspace. */\n workspaceTransfers: (workspaceId: string) =>\n ['arbi', 'workspaceTransfers', 'list', workspaceId] as const,\n /** One transfer job's progress. */\n workspaceTransfer: (transferId: string) =>\n ['arbi', 'workspaceTransfers', 'job', transferId] as const,\n /** What a scope (serialised) would take in a workspace, for a mode. */\n workspaceTransferPlan: (workspaceId: string, scope: string, mode: string) =>\n ['arbi', 'workspaceTransfers', 'plan', workspaceId, scope, mode] as const,\n /**\n * A workspace's activity feed (all its pages), read `limit` entries a page (absent: the server's\n * default): each page size is its own entry, under the workspace's key.\n */\n workspaceActivity: (workspaceId: string, limit?: number) =>\n limit === undefined\n ? (['arbi', 'workspaceActivity', workspaceId] as const)\n : (['arbi', 'workspaceActivity', workspaceId, limit] as const),\n projects: () => ['arbi', 'projects'] as const,\n projectUsage: (projectExtId: string, monthsBack: number) =>\n ['arbi', 'projectUsage', projectExtId, monthsBack] as const,\n projectConversationUsage: (projectExtId: string, monthsBack: number) =>\n ['arbi', 'projectUsage', projectExtId, 'byConversation', monthsBack] as const,\n projectInvoices: (projectExtId: string) => ['arbi', 'projectInvoices', projectExtId] as const,\n /** The plans and add-ons on sale. */\n products: () => ['arbi', 'products'] as const,\n /** Prices of a purchase or a change (quotes, previews); nothing is bought. */\n billingQuotes: () => ['arbi', 'billingQuote'] as const,\n userUsageToday: () => ['arbi', 'userUsageToday'] as const,\n currentUser: () => ['arbi', 'currentUser'] as const,\n firmPool: () => ['arbi', 'firmPool'] as const,\n contacts: () => ['arbi', 'contacts'] as const,\n /** Every chat query (the list and each open thread). */\n chats: () => ['arbi', 'chats'] as const,\n /** My chats, raw (titles and last messages are ciphertext), most recently active first. */\n chatList: () => ['arbi', 'chats', 'list'] as const,\n /** One thread's loaded messages, decrypted, oldest first (`ChatThreadData`). */\n chatThread: (chatExtId: string) => ['arbi', 'chats', 'thread', chatExtId] as const,\n /** My own agent's progress on my last message to it (`agent_dm_status`), per agent. */\n agentDmStatus: (agentExtId: string) => ['arbi', 'chats', 'agentStatus', agentExtId] as const,\n /** The paid features this person may use (`/v1/user/entitlements`). */\n entitlements: () => ['arbi', 'entitlements'] as const,\n skills: () => ['arbi', 'skills'] as const,\n /** A skill's main file (SKILL.md), as text. */\n skillSource: (docExtId: string) => ['arbi', 'skills', 'source', docExtId] as const,\n /** An agent's pinned config; `undefined` = the library default config. */\n agentConfig: (agentExtId?: string) => ['arbi', 'agentConfig', agentExtId ?? 'default'] as const,\n agentWorkspaces: (agentExtId: string) => ['arbi', 'agentWorkspaces', agentExtId] as const,\n /** An agent's own login, polled while its controls are open. */\n agentSession: (agentExtId: string) => ['arbi', 'agentSession', agentExtId] as const,\n agentChats: (agentExtId: string) => ['arbi', 'agentChats', agentExtId] as const,\n authorizeLimits: () => ['arbi', 'authorizeLimits'] as const,\n mcpTools: () => ['arbi', 'mcpTools'] as const,\n models: () => ['arbi', 'models'] as const,\n availableModels: () => ['arbi', 'availableModels'] as const,\n /** The workspace Assistant's brief. */\n assistantBrief: (workspaceId: string) => ['arbi', 'assistantBrief', workspaceId] as const,\n /** Whether the workspace Assistant is waiting, working or idle. */\n assistantStatus: (workspaceId: string) => ['arbi', 'assistantStatus', workspaceId] as const,\n /** What the workspace Assistant did with each arrival. */\n assistantArrivals: (workspaceId: string) => ['arbi', 'assistantArrivals', workspaceId] as const,\n modelConnections: (userId?: string) => ['arbi', 'modelConnections', userId] as const,\n directModelUsage: (userId?: string) => ['arbi', 'directModelUsage', userId] as const,\n /** The signed-in user's own profile (name, picture, email). */\n profile: () => ['arbi', 'profile'] as const,\n identity: () => ['arbi', 'identity'] as const,\n /** The signed-in user's settings record (notification preferences, flags). */\n userSettings: () => ['arbi', 'userSettings'] as const,\n /** Every notification list: the prefix a delete, a read receipt or an arrival invalidates. */\n allSupportTickets: () => ['arbi', 'support'] as const,\n supportTickets: () => ['arbi', 'support', 'tickets'] as const,\n supportTicket: (id: number) => ['arbi', 'support', 'tickets', id] as const,\n allNotifications: () => ['arbi', 'notifications'] as const,\n /** The newest `limit` notifications, received and sent. */\n notifications: (limit: number) => ['arbi', 'notifications', limit] as const,\n /** The documents a workspace may use as its Word house template. */\n houseTemplateCandidates: (workspaceId: string) =>\n ['arbi', 'houseTemplateCandidates', workspaceId] as const,\n // ── Storage, archive ────────────────────────────────────────────────────────────────────────\n /** Every storage view (projects, items, names, Recently deleted): what a restore or delete refreshes. */\n storage: () => ['arbi', 'storage'] as const,\n /** What each project stores; no params: every such list. */\n storageProjects: (params?: object) =>\n params === undefined\n ? (['arbi', 'storage', 'projects'] as const)\n : (['arbi', 'storage', 'projects', params] as const),\n /** The largest items stored; no params: every such list. */\n storageItems: (params?: object) =>\n params === undefined\n ? (['arbi', 'storage', 'items'] as const)\n : (['arbi', 'storage', 'items', params] as const),\n /** Decrypted document names of storage items. */\n storageItemNames: (params?: object) =>\n params === undefined\n ? (['arbi', 'storage', 'names'] as const)\n : (['arbi', 'storage', 'names', params] as const),\n /** The deployment's storage day by day. */\n storageSnapshots: (params?: object) =>\n params === undefined\n ? (['arbi', 'storage', 'snapshots'] as const)\n : (['arbi', 'storage', 'snapshots', params] as const),\n /** A workspace's Recently deleted documents; no id: every workspace's. */\n workspaceTrash: (workspaceId?: string) =>\n workspaceId === undefined\n ? (['arbi', 'storage', 'workspaceTrash'] as const)\n : (['arbi', 'storage', 'workspaceTrash', workspaceId] as const),\n /** A workspace's archive state; no id: every workspace's. */\n workspaceArchive: (workspaceId?: string) =>\n workspaceId === undefined\n ? (['arbi', 'workspaceArchive'] as const)\n : (['arbi', 'workspaceArchive', workspaceId] as const),\n // ── Databases ───────────────────────────────────────────────────────────────────────────────\n // Every key below names its workspace right after its kind: a list read in one workspace is never\n // served, or overwritten, in another (the list is the session's open workspace on the server).\n /** Every database query of every workspace (what a write or a switch refreshes). */\n databases: () => ['arbi', 'databases'] as const,\n /** A workspace's databases; no id: every workspace's. */\n databaseList: (workspaceId?: string) =>\n workspaceId === undefined\n ? (['arbi', 'databases', 'list'] as const)\n : (['arbi', 'databases', 'list', workspaceId] as const),\n /** One database of a workspace; no workspace: every one read. */\n database: (workspaceId?: string, databaseId?: string) =>\n workspaceId === undefined\n ? (['arbi', 'databases', 'one'] as const)\n : (['arbi', 'databases', 'one', workspaceId, databaseId ?? ''] as const),\n /**\n * A database's rows (a search); no workspace: every database's, no params: every search of one.\n * `['arbi', 'databases', 'rows', workspaceId, databaseId, params]`.\n */\n databaseRows: (workspaceId?: string, databaseId?: string, params?: object) =>\n workspaceId === undefined\n ? (['arbi', 'databases', 'rows'] as const)\n : params === undefined\n ? (['arbi', 'databases', 'rows', workspaceId, databaseId ?? ''] as const)\n : (['arbi', 'databases', 'rows', workspaceId, databaseId ?? '', params] as const),\n /** A workspace's pages; no id: every workspace's. */\n pages: (workspaceId?: string) =>\n workspaceId === undefined\n ? (['arbi', 'pages'] as const)\n : (['arbi', 'pages', workspaceId] as const),\n /**\n * Saved table views a workspace's session sees: of one table (a database id or `documents`);\n * no target: every table's; no workspace: every workspace's.\n */\n tableViews: (workspaceId?: string, target?: string) =>\n workspaceId === undefined\n ? (['arbi', 'table-views'] as const)\n : target === undefined\n ? (['arbi', 'table-views', workspaceId] as const)\n : (['arbi', 'table-views', workspaceId, target] as const),\n /** A database's rows grouped and measured (a chart); no workspace: every database's. */\n databaseAggregate: (workspaceId?: string, databaseId?: string, request?: object) =>\n workspaceId === undefined\n ? (['arbi', 'databases', 'aggregate'] as const)\n : (['arbi', 'databases', 'aggregate', workspaceId, databaseId ?? '', request ?? {}] as const),\n // ── Configs, health ─────────────────────────────────────────────────────────────────────────\n /** Under `configs()`: the saved configuration versions. */\n configVersions: () => ['arbi', 'configs', 'versions'] as const,\n /** Under `configs()`: the JSON schema of every config model. */\n configSchema: () => ['arbi', 'configs', 'schema'] as const,\n /** Under `configs()`: one configuration. */\n config: (configId: string) => ['arbi', 'configs', 'one', configId] as const,\n /** The remote model providers' health. */\n remoteModels: () => ['arbi', 'remoteModels'] as const,\n // ── Conversations ───────────────────────────────────────────────────────────────────────────\n /** Under the conversations prefix: what a parked run waits for the owner to allow. */\n conversationPendingAuth: (conversationId: string) =>\n ['arbi', 'conversations', conversationId, 'pending-auth'] as const,\n // ── Document tools ──────────────────────────────────────────────────────────────────────────\n /** Signatures on a document (a version); no id: every document's. */\n documentSignatures: (docId?: string, version?: number | null) =>\n docId === undefined\n ? (['arbi', 'documentSignatures'] as const)\n : (['arbi', 'documentSignatures', docId, version ?? null] as const),\n /** The certificate of a signature reference. */\n signatureVerification: (reference: string) =>\n ['arbi', 'signatureVerification', reference] as const,\n /** Every signature request list: what a request write refreshes. */\n signatureRequests: () => ['arbi', 'signatureRequests'] as const,\n signatureRequestsForDocument: (docId: string) =>\n ['arbi', 'signatureRequests', 'document', docId] as const,\n /** Who may sign in a workspace; no id: every workspace's. */\n signatureCandidates: (workspaceId?: string) =>\n workspaceId === undefined\n ? (['arbi', 'signatureRequests', 'candidates'] as const)\n : (['arbi', 'signatureRequests', 'candidates', workspaceId] as const),\n /** The user's saved (informal) signature. */\n savedSignature: () => ['arbi', 'savedSignature'] as const,\n /** An html/react artifact's source. */\n artifactSource: (docId: string) => ['arbi', 'artifactSource', docId] as const,\n /** An artifact's text, under its parsed content (refreshed with it). */\n artifactText: (docId: string) => ['arbi', 'parsedDoc', docId, 'marker', 'artifact-text'] as const,\n /** An image document's bytes as an object URL. */\n assetImage: (docId: string) => ['arbi', 'assetImage', docId] as const,\n // ── Misc ────────────────────────────────────────────────────────────────────────────────────\n /** An agent config's model tier (the builder's badge). */\n agentConfigModel: (configId: string) => ['arbi', 'agentConfigModel', configId] as const,\n /** Under `billingQuotes()`: the price of a plan change. */\n billingPreview: (projectExtId: string, change: unknown) =>\n ['arbi', 'billingQuote', 'preview', projectExtId, change] as const,\n billingPlanQuote: (projectExtId: string | null, body: unknown) =>\n ['arbi', 'billingQuote', 'plan', projectExtId, body] as const,\n billingAddonQuote: (projectExtId: string, kind: string) =>\n ['arbi', 'billingQuote', 'addon', projectExtId, kind] as const,\n /** Under `contacts()`: a search of the people one can reach. */\n contactSearch: (term: string) => ['arbi', 'contacts', 'search', term] as const,\n /** Under the workspace's facts: a filtered list. */\n factList: (workspaceId: string, filter: unknown) =>\n ['arbi', 'facts', workspaceId, filter] as const,\n /**\n * Under `skills()`: a workspace's list, hidden ones included or not. Without a marketplace the\n * server lists the open workspace's skills, so the list is kept per workspace.\n */\n skillList: (workspaceId: string, includeHidden: boolean) =>\n ['arbi', 'skills', 'list', workspaceId, includeHidden] as const,\n /** Under the project's events: one kind, one page size. */\n projectEventList: (projectExtId: string, kind: string, limit: number | 'default') =>\n ['arbi', 'projects', projectExtId, 'events', kind, limit] as const,\n /** The documents pinned for offline reading on this device. */\n offlineDocuments: () => ['arbi', 'offlineDocuments'] as const,\n /** Notifications of one kind for a deployment's user (polled). */\n typedNotifications: (kind: string, apiUrl: string, userId: string | undefined) =>\n ['arbi', 'typedNotifications', kind, apiUrl, userId ?? ''] as const,\n}\n\n/**\n * Keys of the mutations a host may need to follow (its own caches outside these hooks), e.g. with\n * a `MutationCache` subscription: a workflow run creates a task in the host's own task list.\n */\nexport const arbiMutationKeys = {\n /** A member's role changed. */\n setWorkspaceMemberRoles: () => ['arbi', 'workspaces', 'roles'] as const,\n runWorkflow: () => ['arbi', 'workflows', 'run'] as const,\n updateTagKindSchema: () => ['arbi', 'tags', 'kinds', 'update'] as const,\n createTag: () => ['arbi', 'tags', 'create'] as const,\n updateTag: () => ['arbi', 'tags', 'update'] as const,\n deleteTag: () => ['arbi', 'tags', 'delete'] as const,\n extractEntities: () => ['arbi', 'tags', 'entities', 'extract'] as const,\n updateDocuments: () => ['arbi', 'documents', 'update'] as const,\n deleteDocuments: () => ['arbi', 'documents', 'delete'] as const,\n uploadDocuments: () => ['arbi', 'documents', 'upload'] as const,\n uploadUrls: () => ['arbi', 'documents', 'uploadUrls'] as const,\n assignDocTags: () => ['arbi', 'doctags', 'assign'] as const,\n removeDocTags: () => ['arbi', 'doctags', 'remove'] as const,\n updateDocTag: () => ['arbi', 'doctags', 'update'] as const,\n generateDocTags: () => ['arbi', 'doctags', 'generate'] as const,\n /** Members added to or removed from a workspace (leaving included). */\n workspaceMembership: () => ['arbi', 'workspaces', 'members'] as const,\n /** A chat turn being sent (the app's send pipeline). */\n sendMessage: () => ['arbi', 'conversations', 'send'] as const,\n}\n\n/**\n * Query keys of the calendar hooks, all under `['arbi', 'calendar']`. The calendar is the user's,\n * not a workspace's; only the overlays carry the open workspace.\n */\nexport const calendarQueryKeys = {\n all: () => ['arbi', 'calendar'] as const,\n settings: () => ['arbi', 'calendar', 'settings'] as const,\n calendars: () => ['arbi', 'calendar', 'calendars'] as const,\n /** Every event list: the prefix an event write invalidates. */\n events: () => ['arbi', 'calendar', 'events'] as const,\n eventList: (p: ListEventsParams) =>\n [\n 'arbi',\n 'calendar',\n 'events',\n { start: p.start, end: p.end, calendars: p.calendars?.join(',') ?? null },\n ] as const,\n /** Every single event read. */\n eventDetails: () => ['arbi', 'calendar', 'event'] as const,\n event: (id: string, recurrenceId?: string | null) =>\n ['arbi', 'calendar', 'event', id, recurrenceId ?? null] as const,\n shares: (calId: string) => ['arbi', 'calendar', 'shares', calId] as const,\n invitations: () => ['arbi', 'calendar', 'invitations'] as const,\n holidayCountries: () => ['arbi', 'calendar', 'holiday-countries'] as const,\n allRooms: () => ['arbi', 'calendar', 'rooms'] as const,\n rooms: (q: RoomQuery) => ['arbi', 'calendar', 'rooms', q] as const,\n freebusy: (attendees: string[], start: string, end: string) =>\n ['arbi', 'calendar', 'freebusy', attendees.join(','), start, end] as const,\n allLookups: () => ['arbi', 'calendar', 'lookup'] as const,\n lookup: (uid: string) => ['arbi', 'calendar', 'lookup', uid] as const,\n overlays: (workspaceId: string | null, w?: CalendarWindow, layers?: OverlayLayerName[]) =>\n [\n 'arbi',\n 'calendar',\n 'overlays',\n workspaceId,\n w ? { start: w.start, end: w.end, layers: layers?.join(',') } : null,\n ] as const,\n accounts: () => ['arbi', 'calendar', 'accounts'] as const,\n caldavProfiles: () => ['arbi', 'calendar', 'caldav-profiles'] as const,\n bookingPages: () => ['arbi', 'calendar', 'booking-pages'] as const,\n /** The offline outbox (writes made offline, not yet sent). */\n outbox: () => ['arbi', 'calendar', 'outbox'] as const,\n}\n\n/** Query keys of the call hooks, all under `['arbi', 'calls']`. Calls are the user's, not a workspace's. */\nexport const callQueryKeys = {\n all: () => ['arbi', 'calls'] as const,\n config: () => ['arbi', 'calls', 'config'] as const,\n call: (callExtId: string) => ['arbi', 'calls', 'call', callExtId] as const,\n /** Everything about a call's recordings: the prefix a recording event invalidates. */\n recordingsOf: (callExtId: string) => ['arbi', 'calls', 'recordings', callExtId] as const,\n recordings: (callExtId: string) => ['arbi', 'calls', 'recordings', callExtId, 'list'] as const,\n recording: (callExtId: string, recordingExtId: string) =>\n ['arbi', 'calls', 'recordings', callExtId, 'one', recordingExtId] as const,\n inviteLinks: (callExtId: string) => ['arbi', 'calls', 'invite-links', callExtId] as const,\n}\n\nexport const connectorQueryKeys = {\n all: () => ['arbi', 'connectors'] as const,\n catalog: () => ['arbi', 'connectors', 'catalog'] as const,\n mine: () => ['arbi', 'connectors', 'mine'] as const,\n mailboxFolders: (vendor: string) => ['arbi', 'connectors', 'folders', vendor] as const,\n mailboxSyncProgress: (vendor: string, workspaceExtId: string) =>\n ['arbi', 'connectors', 'sync-progress', vendor, workspaceExtId] as const,\n allMailboxSyncProgress: () => ['arbi', 'connectors', 'sync-progress'] as const,\n driveFolders: (vendor: string) => ['arbi', 'connectors', 'drive-folders', vendor] as const,\n driveFolderChildren: (vendor: string, itemId: string) =>\n ['arbi', 'connectors', 'drive-folder-children', vendor, itemId] as const,\n driveFolderDocCount: (vendor: string, itemId: string) =>\n ['arbi', 'connectors', 'drive-folder-doc-count', vendor, itemId] as const,\n driveSyncEstimate: (vendor: string) =>\n ['arbi', 'connectors', 'drive-sync-estimate', vendor] as const,\n driveSyncProgress: (vendor: string) =>\n ['arbi', 'connectors', 'drive-sync-progress', vendor] as const,\n allDriveSyncProgress: () => ['arbi', 'connectors', 'drive-sync-progress'] as const,\n slack: () => ['arbi', 'connectors', 'slack'] as const,\n}\n\nexport const mailQueryKeys = {\n all: () => ['arbi', 'mail'] as const,\n policy: () => ['arbi', 'mail', 'policy'] as const,\n accounts: () => ['arbi', 'mail', 'accounts'] as const,\n unlock: (accountId: string | undefined, sessionKey: string | null) =>\n ['arbi', 'mail', 'unlock', accountId, sessionKey ?? ''] as const,\n allFolders: () => ['arbi', 'mail', 'folders'] as const,\n folders: (accountId: string | undefined) => ['arbi', 'mail', 'folders', accountId] as const,\n allMessages: () => ['arbi', 'mail', 'messages'] as const,\n messages: (\n accountId: string | undefined,\n folderId: string | undefined,\n query: string,\n cursor: string | null\n ) => ['arbi', 'mail', 'messages', accountId, folderId, query, cursor] as const,\n message: (accountId: string | undefined, messageId: string | null | undefined) =>\n ['arbi', 'mail', 'message', accountId, messageId] as const,\n /** Every conversation list: the prefix a flag or move patches or refreshes. */\n allConversations: () => ['arbi', 'mail', 'conversations'] as const,\n conversations: (\n accountId: string | undefined,\n folderId: string | undefined,\n query: string,\n cursor: string | null\n ) => ['arbi', 'mail', 'conversations', accountId, folderId, query, cursor] as const,\n /** Every thread read of an account. */\n accountThreads: (accountId: string) => ['arbi', 'mail', 'thread', accountId] as const,\n thread: (\n accountId: string | undefined,\n threadId: string | null | undefined,\n folderId: string | undefined\n ) => ['arbi', 'mail', 'thread', accountId, threadId, folderId] as const,\n /** Where the ARBI mailbox files mail (folders and conversations, per workspace). */\n nativeFiling: () => ['arbi', 'mail', 'filing', 'native'] as const,\n /** Every filing lookup: refreshed after mail is added to a workspace or a rule is stopped. */\n allFiling: () => ['arbi', 'mail', 'filing'] as const,\n filing: (accountId: string | undefined, messageIds: string[], threadIds: string[]) =>\n ['arbi', 'mail', 'filing', accountId, messageIds.join(' '), threadIds.join(' ')] as const,\n /** The key the user's client keys older native mail with: outside the `['arbi', 'mail']` prefix, so\n * refreshing mail never fetches it again. */\n threadSecret: () => ['arbi', 'mail-thread-secret'] as const,\n /** The projects an email's AI work can be billed to. */\n projects: () => ['arbi', 'mail', 'projects'] as const,\n /** A saved draft prepared for editing. */\n draftCompose: (accountId: string | undefined, draftId: string | undefined) =>\n ['arbi', 'mail', 'draft-compose', accountId, draftId] as const,\n attachmentText: (accountId: string, messageId: string, attachmentId: string) =>\n ['arbi', 'mail', 'attachment-text', accountId, messageId, attachmentId] as const,\n}\n\n/** `pdf`: the document as a PDF; `original`: the stored file (an image, a recording, a sheet). */\nexport type DocumentBytesKind = 'pdf' | 'original'\n\n/** Every version and kind of a document's bytes: the prefix a new version invalidates. */\nexport const documentBytesKey = (\n documentRef: string,\n version?: number | null,\n kind?: DocumentBytesKind\n) =>\n version === undefined\n ? (['arbi', 'documentBytes', documentRef] as const)\n : (['arbi', 'documentBytes', documentRef, version, kind ?? 'pdf'] as const)\n\n/** Whether `queryKey` lies under `prefix` (a factory key): React Query's own prefix match. */\nexport function isUnderQueryKey(queryKey: readonly unknown[], prefix: readonly unknown[]): boolean {\n return prefix.every((part, i) => queryKey[i] === part)\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  var chunkT5FZICXN_cjs = require('./chunk-T5FZICXN.cjs');
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
5
 
6
- var pdfViewerChunk = chunkT5FZICXN_cjs.lazyChunk(() => import('./PdfViewerImpl-ZVJZ4KNW.cjs'));
6
+ var pdfViewerChunk = chunkT5FZICXN_cjs.lazyChunk(() => import('./PdfViewerImpl-DC5K3TYK.cjs'));
7
7
  var PdfViewer = chunkT5FZICXN_cjs.lazyComponent(
8
8
  pdfViewerChunk,
9
9
  (m) => m.PdfViewer,
@@ -19,5 +19,5 @@ var PdfViewer = chunkT5FZICXN_cjs.lazyComponent(
19
19
 
20
20
  exports.PdfViewer = PdfViewer;
21
21
  exports.pdfViewerChunk = pdfViewerChunk;
22
- //# sourceMappingURL=chunk-4B2GW3AY.cjs.map
23
- //# sourceMappingURL=chunk-4B2GW3AY.cjs.map
22
+ //# sourceMappingURL=chunk-FK33RWIO.cjs.map
23
+ //# sourceMappingURL=chunk-FK33RWIO.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/viewers/PdfViewer.tsx"],"names":["lazyChunk","lazyComponent","jsx"],"mappings":";;;;;AAUO,IAAM,cAAA,GAAiBA,2BAAA,CAAU,MAAM,OAAO,8BAAiB,CAAC;AAEhE,IAAM,SAAA,GAA2CC,+BAAA;AAAA,EACtD,cAAA;AAAA,EACA,CAAC,MAAM,CAAA,CAAE,SAAA;AAAA,EACT,sBACEC,cAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAU,yCAAA;AAAA,MACV,WAAA,EAAU,aAAA;AAAA,MACV,WAAA,EAAU;AAAA;AAAA;AAGhB","file":"chunk-4B2GW3AY.cjs","sourcesContent":["/**\n * `PdfViewer`: a PDF rendered with pdf.js. The PDF engine is large, so it lives in its own chunk,\n * loaded the first time a PDF renders (`pdfViewerChunk`); meanwhile a blank page area.\n */\nimport type { ComponentType } from 'react'\nimport { lazyChunk, lazyComponent } from '../lazy-chunk'\nimport type { PdfViewerProps } from './PdfViewerImpl'\n\nexport type { PdfViewerAssets, PdfViewerProps } from './PdfViewerImpl'\n\nexport const pdfViewerChunk = lazyChunk(() => import('./PdfViewerImpl'))\n\nexport const PdfViewer: ComponentType<PdfViewerProps> = lazyComponent(\n pdfViewerChunk,\n (m) => m.PdfViewer,\n () => (\n <div\n className=\"h-full w-full animate-pulse bg-muted/40\"\n data-slot=\"pdf-loading\"\n aria-busy=\"true\"\n />\n )\n)\n"]}
1
+ {"version":3,"sources":["../src/viewers/PdfViewer.tsx"],"names":["lazyChunk","lazyComponent","jsx"],"mappings":";;;;;AAUO,IAAM,cAAA,GAAiBA,2BAAA,CAAU,MAAM,OAAO,8BAAiB,CAAC;AAEhE,IAAM,SAAA,GAA2CC,+BAAA;AAAA,EACtD,cAAA;AAAA,EACA,CAAC,MAAM,CAAA,CAAE,SAAA;AAAA,EACT,sBACEC,cAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAU,yCAAA;AAAA,MACV,WAAA,EAAU,aAAA;AAAA,MACV,WAAA,EAAU;AAAA;AAAA;AAGhB","file":"chunk-FK33RWIO.cjs","sourcesContent":["/**\n * `PdfViewer`: a PDF rendered with pdf.js. The PDF engine is large, so it lives in its own chunk,\n * loaded the first time a PDF renders (`pdfViewerChunk`); meanwhile a blank page area.\n */\nimport type { ComponentType } from 'react'\nimport { lazyChunk, lazyComponent } from '../lazy-chunk'\nimport type { PdfViewerProps } from './PdfViewerImpl'\n\nexport type { PdfViewerAssets, PdfViewerProps } from './PdfViewerImpl'\n\nexport const pdfViewerChunk = lazyChunk(() => import('./PdfViewerImpl'))\n\nexport const PdfViewer: ComponentType<PdfViewerProps> = lazyComponent(\n pdfViewerChunk,\n (m) => m.PdfViewer,\n () => (\n <div\n className=\"h-full w-full animate-pulse bg-muted/40\"\n data-slot=\"pdf-loading\"\n aria-busy=\"true\"\n />\n )\n)\n"]}