@arbidocs/react 0.4.168 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -2916,7 +2916,9 @@ declare function useSignedInSession(session: SessionManager | null): ArbiSignedI
2916
2916
  * 4. the conversations and tags `/open` returned seed their lists, then the selection is
2917
2917
  * committed (`workspaceId`, `workspaceStatus: 'open'`).
2918
2918
  *
2919
- * Concurrent switches (A, then B, then C in quick succession): only the last one commits.
2919
+ * Concurrent switches (A, then B, then C in quick succession): only the last one commits, and the
2920
+ * SDK runs the opens one at a time with the latest request winning, so the server session ends in
2921
+ * the last one too. `settled` waits out the switches in flight.
2920
2922
  */
2921
2923
 
2922
2924
  /** The server refused to open an archived workspace (423 `workspace_archived`). */
@@ -2943,6 +2945,11 @@ interface UseSwitchWorkspaceResult {
2943
2945
  * False when there is none, it could not be opened, or a switch overtook it.
2944
2946
  */
2945
2947
  openSelectedWorkspace: () => Promise<boolean>;
2948
+ /**
2949
+ * Resolves once no switch is in flight: the selection is then committed (or back to where it
2950
+ * was), so reading it says which workspace the session is in.
2951
+ */
2952
+ settled: () => Promise<void>;
2946
2953
  }
2947
2954
  /** What a workspace switch runs on. */
2948
2955
  interface WorkspaceSwitchContext {
package/dist/index.d.ts CHANGED
@@ -2916,7 +2916,9 @@ declare function useSignedInSession(session: SessionManager | null): ArbiSignedI
2916
2916
  * 4. the conversations and tags `/open` returned seed their lists, then the selection is
2917
2917
  * committed (`workspaceId`, `workspaceStatus: 'open'`).
2918
2918
  *
2919
- * Concurrent switches (A, then B, then C in quick succession): only the last one commits.
2919
+ * Concurrent switches (A, then B, then C in quick succession): only the last one commits, and the
2920
+ * SDK runs the opens one at a time with the latest request winning, so the server session ends in
2921
+ * the last one too. `settled` waits out the switches in flight.
2920
2922
  */
2921
2923
 
2922
2924
  /** The server refused to open an archived workspace (423 `workspace_archived`). */
@@ -2943,6 +2945,11 @@ interface UseSwitchWorkspaceResult {
2943
2945
  * False when there is none, it could not be opened, or a switch overtook it.
2944
2946
  */
2945
2947
  openSelectedWorkspace: () => Promise<boolean>;
2948
+ /**
2949
+ * Resolves once no switch is in flight: the selection is then committed (or back to where it
2950
+ * was), so reading it says which workspace the session is in.
2951
+ */
2952
+ settled: () => Promise<void>;
2946
2953
  }
2947
2954
  /** What a workspace switch runs on. */
2948
2955
  interface WorkspaceSwitchContext {
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { invalidateConversationLists, patchConversation, invalidateConversationDetails, addConversationToList, findConversation, isConversationShared, isKnownSoloConversation, patchConversationList, removeConversationFromLists, ArbiWsContext, useArbiWsContext, useAccountClient, applyChatEvent, myChatId, upsertChat, appendToThread, dropFromThread, deleteChatMessage, removeChat, cachedChats } from './chunk-H3LMKO3T.js';
2
- export { AUDIENCE_CHOICES, CALL_CAPTION_TOPIC, CALL_CHAT_MAX_CHARS, CALL_CHAT_TOPIC, CALL_MODERATION_TOPIC, CALL_RECORDING_TOPIC, CALL_TRANSCRIPTION_TOPIC, CALL_WEBINAR_TOPIC, CAPTION_MAX_CHARS, COMPOSITE_AUDIO_BITS_PER_SECOND, COMPOSITE_VIDEO_BITS_PER_SECOND, DEFAULT_JOIN_CHOICES, EMPTY_CALL_SESSION, EXPORT_SAMPLE_RATE, HISTORY_LIMIT, LIVE_SEGMENTER, MAX_AVATAR_FILE_BYTES, MUTED_DEDUPE_MS, PLAYBACK_LOOKAHEAD_MS, READ_ONLY_MEETING_TEXT, RECORDING_CHUNK_MS, RECORDING_SEGMENTER, SEGMENT_FRAME_MS, SEGMENT_ID_PATTERN, SEGMENT_PRE_ROLL_MS, SHORT_PIECE_MERGE_GAP_MS, SPEAKER_AUDIO_BITS_PER_SECOND, TrackUploader, UPLOAD_ATTEMPTS, UPLOAD_BACKOFF_MS, acceptRing, addConversationToList, appendToThread, applyAgentDmStatus, applyCallEvent, applyChatEvent, applyChatMessage, applyChatRead, applyChatUpdated, arbiAccountClient, buildMeetingChatBody, cachedChat, cachedChats, callLink, callMemberKeys, callSession, chatByExtId, chatHasLiveCall, chatLiveCallId, chatTranscriptRef, clearMeetingChatCache, clearTrackUploaders, clockTime, compositeFiles, compositeTrack, conversationKeyForCall, createMutedNotifier, createTrackCutter, cutAtPauses, declineRing, decodeCallChatPacket, decodeCaptionPacket, decodeMono16k, decryptPart, encodeCallChatPacket, encodeCaptionPacket, encodeWav, encryptPart, ensureMeetingChat, entitlementRefusal, extensionFor, fetchPart, fileSafe, findConversation, floatToWav, formatTranscriptMarkdown, getOpenChat, hasRecordingTranscript, invalidateCall, invalidateConversationDetails, invalidateConversationLists, isConversationListKey, isConversationShared, isKnownSoloConversation, isRecordingOver, isRecordingSegmentId, isRetryable, isWorkspaceGuestOf, joinFromPreJoin, knownMeetingChat, loadMeetingHistory, markRejoining, meetingChatRefFrom, meetingRefForCall, mergeChatLines, mutedNoticeFromEvent, mutedNoticeFromPacket, mutedNoticeText, myChatId, newPacketId, newSegmentId, newTrackKey, nextSeqAfter, onCallEvent, openCall, openQuestion, openRecording, parseWebinarPacket, partKey, partOffsetMs, partsDue, patchConversation, patchConversationList, persistMeetingMessage, persistTranscriptSegment, playheadAt, postRecordingDocsToThread, postTranscriptToThread, recordingFiles, recordingWindowsOf, rejoinAsAudience, removeChat, removeConversationFromLists, resetCallSession, resolveMeetingChat, saveRecordingFilesToThread, schedulePart, sealQuestionText, setOpenChat, sortTranscriptMessages, sortedParts, speakerTracks, speakerWav, splitIntoFiles, standalone, startChatCall, startContactsCall, startDmCall, startThreadCall, startsMediaFile, storeTranscriptSegment, stripSpeakerPrefix, supersedeLiveTranscript, supersededTranscriptLines, threadHasLiveCall, threadLiveCallId, threadTranscriptLines, threadTranscriptRef, threadTranscriptText, timelineDurationMs, timelineOf, toProfileView, trackUploaderFor, transcribeRecording, transcriptPersistRole, transcriptSegmentOf, unwrapTrackKey, upsertChat, useAccountClient, useArbiWsContext, useAvatarCrop, useCall, useCallInviteLinks, useCallLiveUpdates, useCallRecording, useCallRecordings, useCallSession, useCallTranscriptionAvailable, useCallsConfig, useCallsEnabled, useCanHostCalls, useEntitlements, useIsEntitled, useMeetingReadOnly, useNameEditor, useOpenCallMeetingChat, useProfile, useRecordingActions, useRecordingWindows, useRevokeCallInviteLink, useSaveToThread, useServerCallsEnabled, useUpdateProfile, wrapTrackKey, writeSamples } from './chunk-H3LMKO3T.js';
3
- import { settledByRows, isStaleTaskUpdate, replayableTagMutations, patchDocuments, setCachedDocument, adjustTagCounts, patchCachedDocument, forgetDocuments, getCachedDocuments, refreshDocuments, FINISHED_DOCUMENT_STATUSES, useSimilarDocuments, SIMILARITY_THRESHOLD, useDocuments, finishEntityExtraction } from './chunk-3NVSUYUV.js';
4
- export { DOCUMENTS_FIRST_PAGE_MEASURE, DOCUMENTS_FIRST_PAGE_SIZE, DOCUMENTS_PAGE_SIZE, FINISHED_DOCUMENT_STATUSES, IN_FLIGHT_DOCUMENT_STATUSES, SIMILARITY_THRESHOLD, adjustTagCounts, dropTagFromCachedDocuments, finishEntityExtraction, forgetDocuments, getCachedDocuments, invalidateTagData, invalidateTagTables, isDocumentsLoading, isRowNewer, isStaleTaskUpdate, patchCachedDocument, patchDocuments, patchWorkspaceTags, refreshDocuments, resolveDocumentStatus, setCachedDocument, settledByRows, startEntityExtraction, stopDocumentsLoading, subscribeDocumentRows, upsertDocuments, useCreateTag, useDeleteTag, useDocument, useDocuments, useDocumentsById, useDocumentsLoading, useEntityExtractionDocIds, useExtractEntities, useInvalidateTagData, useIsCreatingTag, useSetTagValues, useSimilarDocuments, useTagKindSchema, useUpdateTag, useUpdateTagKindSchema } from './chunk-3NVSUYUV.js';
5
- import { useArbiSessionState, useConversations, useArbiSession, useWorkspaces, useConfig, useArbiSessionStore, useAvailableModels, useParsedDocument, useTags, selectDraft, useConversationThreads, createArbiSessionStore, useAgents, useAssistantQuery, useActivity, queuedMessages, MIN_QUEUED_MESSAGE_VISIBILITY_MS } from './chunk-MJNZLWJD.js';
6
- export { DEFAULT_DOCUMENT_VIEWER_STATE, EMPTY_SESSION_STATE, MAX_THREAD_TABS, MIN_QUEUED_MESSAGE_VISIBILITY_MS, PROJECT_CREATION_DENIED_REASON, agentControl, clearSealedDrafts, conversationKey, createArbiSessionStore, createSealedDraftStorage, isUsageMetered, nextViewingDocument, queuedMessages, selectDraft, selectIsGenerating, selectViewingDocumentId, threadTabId, useActivity, useAgents, useArbiSession, useArbiSessionState, useArbiSessionStore, useAssistantQuery, useAvailableModels, useBuiltinCommands, useCanCreateProjects, useConfig, useConfigs, useConversationThreads, useConversations, useCurrentUser, useDeleteAgents, useDocumentVersionList, useFirmPool, useHealth, useMessageDetails, useParsedDocument, useProjectInvoices, useProjectUsage, useProjects, useProjectsUsage, useSignedInSession, useTags, useThumbnails, useTopUpFirmPool, useUserUsageToday, useWorkspaceActivity, useWorkspaces } from './chunk-MJNZLWJD.js';
1
+ import { invalidateConversationLists, patchConversation, invalidateConversationDetails, addConversationToList, findConversation, isConversationShared, isKnownSoloConversation, patchConversationList, removeConversationFromLists, ArbiWsContext, useArbiWsContext, useAccountClient, applyChatEvent, myChatId, upsertChat, appendToThread, dropFromThread, deleteChatMessage, removeChat, cachedChats } from './chunk-SNUNLXFE.js';
2
+ export { AUDIENCE_CHOICES, CALL_CAPTION_TOPIC, CALL_CHAT_MAX_CHARS, CALL_CHAT_TOPIC, CALL_MODERATION_TOPIC, CALL_RECORDING_TOPIC, CALL_TRANSCRIPTION_TOPIC, CALL_WEBINAR_TOPIC, CAPTION_MAX_CHARS, COMPOSITE_AUDIO_BITS_PER_SECOND, COMPOSITE_VIDEO_BITS_PER_SECOND, DEFAULT_JOIN_CHOICES, EMPTY_CALL_SESSION, EXPORT_SAMPLE_RATE, HISTORY_LIMIT, LIVE_SEGMENTER, MAX_AVATAR_FILE_BYTES, MUTED_DEDUPE_MS, PLAYBACK_LOOKAHEAD_MS, READ_ONLY_MEETING_TEXT, RECORDING_CHUNK_MS, RECORDING_SEGMENTER, SEGMENT_FRAME_MS, SEGMENT_ID_PATTERN, SEGMENT_PRE_ROLL_MS, SHORT_PIECE_MERGE_GAP_MS, SPEAKER_AUDIO_BITS_PER_SECOND, TrackUploader, UPLOAD_ATTEMPTS, UPLOAD_BACKOFF_MS, acceptRing, addConversationToList, appendToThread, applyAgentDmStatus, applyCallEvent, applyChatEvent, applyChatMessage, applyChatRead, applyChatUpdated, arbiAccountClient, buildMeetingChatBody, cachedChat, cachedChats, callLink, callMemberKeys, callSession, chatByExtId, chatHasLiveCall, chatLiveCallId, chatTranscriptRef, clearMeetingChatCache, clearTrackUploaders, clockTime, compositeFiles, compositeTrack, conversationKeyForCall, createMutedNotifier, createTrackCutter, cutAtPauses, declineRing, decodeCallChatPacket, decodeCaptionPacket, decodeMono16k, decryptPart, encodeCallChatPacket, encodeCaptionPacket, encodeWav, encryptPart, ensureMeetingChat, entitlementRefusal, extensionFor, fetchPart, fileSafe, findConversation, floatToWav, formatTranscriptMarkdown, getOpenChat, hasRecordingTranscript, invalidateCall, invalidateConversationDetails, invalidateConversationLists, isConversationListKey, isConversationShared, isKnownSoloConversation, isRecordingOver, isRecordingSegmentId, isRetryable, isWorkspaceGuestOf, joinFromPreJoin, knownMeetingChat, loadMeetingHistory, markRejoining, meetingChatRefFrom, meetingRefForCall, mergeChatLines, mutedNoticeFromEvent, mutedNoticeFromPacket, mutedNoticeText, myChatId, newPacketId, newSegmentId, newTrackKey, nextSeqAfter, onCallEvent, openCall, openQuestion, openRecording, parseWebinarPacket, partKey, partOffsetMs, partsDue, patchConversation, patchConversationList, persistMeetingMessage, persistTranscriptSegment, playheadAt, postRecordingDocsToThread, postTranscriptToThread, recordingFiles, recordingWindowsOf, rejoinAsAudience, removeChat, removeConversationFromLists, resetCallSession, resolveMeetingChat, saveRecordingFilesToThread, schedulePart, sealQuestionText, setOpenChat, sortTranscriptMessages, sortedParts, speakerTracks, speakerWav, splitIntoFiles, standalone, startChatCall, startContactsCall, startDmCall, startThreadCall, startsMediaFile, storeTranscriptSegment, stripSpeakerPrefix, supersedeLiveTranscript, supersededTranscriptLines, threadHasLiveCall, threadLiveCallId, threadTranscriptLines, threadTranscriptRef, threadTranscriptText, timelineDurationMs, timelineOf, toProfileView, trackUploaderFor, transcribeRecording, transcriptPersistRole, transcriptSegmentOf, unwrapTrackKey, upsertChat, useAccountClient, useArbiWsContext, useAvatarCrop, useCall, useCallInviteLinks, useCallLiveUpdates, useCallRecording, useCallRecordings, useCallSession, useCallTranscriptionAvailable, useCallsConfig, useCallsEnabled, useCanHostCalls, useEntitlements, useIsEntitled, useMeetingReadOnly, useNameEditor, useOpenCallMeetingChat, useProfile, useRecordingActions, useRecordingWindows, useRevokeCallInviteLink, useSaveToThread, useServerCallsEnabled, useUpdateProfile, wrapTrackKey, writeSamples } from './chunk-SNUNLXFE.js';
3
+ import { settledByRows, isStaleTaskUpdate, replayableTagMutations, patchDocuments, setCachedDocument, adjustTagCounts, patchCachedDocument, forgetDocuments, getCachedDocuments, refreshDocuments, FINISHED_DOCUMENT_STATUSES, useSimilarDocuments, SIMILARITY_THRESHOLD, useDocuments, finishEntityExtraction } from './chunk-6YLK5AGS.js';
4
+ export { DOCUMENTS_FIRST_PAGE_MEASURE, DOCUMENTS_FIRST_PAGE_SIZE, DOCUMENTS_PAGE_SIZE, FINISHED_DOCUMENT_STATUSES, IN_FLIGHT_DOCUMENT_STATUSES, SIMILARITY_THRESHOLD, adjustTagCounts, dropTagFromCachedDocuments, finishEntityExtraction, forgetDocuments, getCachedDocuments, invalidateTagData, invalidateTagTables, isDocumentsLoading, isRowNewer, isStaleTaskUpdate, patchCachedDocument, patchDocuments, patchWorkspaceTags, refreshDocuments, resolveDocumentStatus, setCachedDocument, settledByRows, startEntityExtraction, stopDocumentsLoading, subscribeDocumentRows, upsertDocuments, useCreateTag, useDeleteTag, useDocument, useDocuments, useDocumentsById, useDocumentsLoading, useEntityExtractionDocIds, useExtractEntities, useInvalidateTagData, useIsCreatingTag, useSetTagValues, useSimilarDocuments, useTagKindSchema, useUpdateTag, useUpdateTagKindSchema } from './chunk-6YLK5AGS.js';
5
+ import { useArbiSessionState, useConversations, useArbiSession, useWorkspaces, useConfig, useArbiSessionStore, useAvailableModels, useParsedDocument, useTags, selectDraft, useConversationThreads, createArbiSessionStore, useAgents, useAssistantQuery, useActivity, queuedMessages, MIN_QUEUED_MESSAGE_VISIBILITY_MS } from './chunk-EOFEAME5.js';
6
+ export { DEFAULT_DOCUMENT_VIEWER_STATE, EMPTY_SESSION_STATE, MAX_THREAD_TABS, MIN_QUEUED_MESSAGE_VISIBILITY_MS, PROJECT_CREATION_DENIED_REASON, agentControl, clearSealedDrafts, conversationKey, createArbiSessionStore, createSealedDraftStorage, isUsageMetered, nextViewingDocument, queuedMessages, selectDraft, selectIsGenerating, selectViewingDocumentId, threadTabId, useActivity, useAgents, useArbiSession, useArbiSessionState, useArbiSessionStore, useAssistantQuery, useAvailableModels, useBuiltinCommands, useCanCreateProjects, useConfig, useConfigs, useConversationThreads, useConversations, useCurrentUser, useDeleteAgents, useDocumentVersionList, useFirmPool, useHealth, useMessageDetails, useParsedDocument, useProjectInvoices, useProjectUsage, useProjects, useProjectsUsage, useSignedInSession, useTags, useThumbnails, useTopUpFirmPool, useUserUsageToday, useWorkspaceActivity, useWorkspaces } from './chunk-EOFEAME5.js';
7
7
  import { ArbiHost, extractMentions, toMessageMentions, takeOpenDocumentForTurn, hasMessageBody, createSearchSession, clearSearchSession, formatRelativeTime } from './chunk-DGMK3EUN.js';
8
8
  export { MENTION_HREF_PREFIX, NotificationBell, Toaster, clearSearchSession, createSearchSession, extractMentions, filterMentionCandidates, findMentionQuery, formatRelativeTime, hasMessageBody, insertMention, linkMentions, mentionFromHref, persistSearchSession, requestSearch, savedDocumentIdFor, sharedSearchSession, takeOpenDocumentForTurn, takePendingSearch, toMessageMentions, useOpenDocumentId, useRegisterOpenDocument } from './chunk-DGMK3EUN.js';
9
9
  import { notify } from './chunk-5HDC43MF.js';
@@ -36,7 +36,7 @@ export { useArbi, useArbiHost, useDeploymentDomain } from './chunk-KGCGA452.js';
36
36
  export { useHostConfigRecord } from './chunk-CPZ36AQS.js';
37
37
  import React, { memo, useState, createContext, useMemo, useCallback, useEffect, useRef, useLayoutEffect, useId, useSyncExternalStore, useContext, Fragment as Fragment$1 } from 'react';
38
38
  import { useQueryClient, useMutation, useQuery, onlineManager, keepPreviousData, useQueries, partialMatchKey } from '@tanstack/react-query';
39
- import { documents, doctags, houseTemplates, STOP_ID_WAIT_MS, resolveCitations, summarizeCitations, createIndexAssigner, reduceOutputItem, findReplyTarget, ArbiApiError, quotaFromStreamError, STOP_REPEAT_WINDOW_MS, getRunToCancel, pickMainThread, extractDocumentIdsFromMessages, extractFactIdsFromMessages, hydrateAgentSteps, getSubagentBranchRecord, getRunToAttach, settings, isConnectorVendorVisible, ACCOUNT_VENDOR, searchChunks, chats, formatFileSize, connectWithReconnect, identityErrorCode } from '@arbidocs/sdk/browser';
39
+ import { documents, doctags, houseTemplates, STOP_ID_WAIT_MS, resolveCitations, summarizeCitations, createIndexAssigner, reduceOutputItem, findReplyTarget, ArbiApiError, quotaFromStreamError, STOP_REPEAT_WINDOW_MS, getRunToCancel, pickMainThread, extractDocumentIdsFromMessages, extractFactIdsFromMessages, hydrateAgentSteps, getSubagentBranchRecord, getRunToAttach, settings, isConnectorVendorVisible, ACCOUNT_VENDOR, searchChunks, chats, formatFileSize, connectWithReconnect, ArbiWorkspaceSupersededError, identityErrorCode } from '@arbidocs/sdk/browser';
40
40
  export { ACCOUNT_VENDOR, Arbi, ArbiError, DEFAULT_AI_USD_PER_GBP, DRIVE_SYNC_VENDORS, GOOGLE_VENDORS, IMANAGE_VENDORS, MAILBOX_SYNC_VENDORS, MAX_RETRIEVE_DOC_IDS, MICROSOFT_VENDORS, PublicBookingError, SHAREPOINT_VENDORS, bookPublicSlot, cancelPublicBooking, connectErrorMessage, formatGbp, formatGbpPerMillionTokens, getPublicBookingPage, isConnectorVendorVisible, isDriveSyncVendor, isMailboxSyncVendor, isSharePointVendor, usdToGbp } from '@arbidocs/sdk/browser';
41
41
  import { create } from 'zustand';
42
42
  import { Link, Trash2, CheckCheck, Check, MoreHorizontal, SquarePen, Pencil, Download, X, Mic, Pause, Play, Square, Loader2, RotateCcw, Sparkles, Camera, Circle, AlertTriangle, ShieldCheck, Copy, FileText, GitCompareArrows, Search, CornerDownLeft, Send, Tags, Info, Activity, HardDrive, Gauge, Gift, PartyPopper, UserPlus, UserCheck, Reply, PenLine, AtSign, MessageCircleMore, FileX2, FileCheck2, FolderPlus, SquareArrowOutUpRight, MessagesSquare, Paperclip, ArrowRight, Image as Image$1, AppWindow } from 'lucide-react';
@@ -1246,8 +1246,7 @@ function useWorkspaceUsers(workspaceId, options) {
1246
1246
  enabled: !!workspace && (options?.enabled ?? arbi.hasWorkspace),
1247
1247
  queryFn: async () => {
1248
1248
  await options?.beforeFetch?.();
1249
- if (arbi.getWorkspaceId() !== workspace) throw new Error("The selected workspace changed.");
1250
- return arbi.workspaces.listUsers();
1249
+ return arbi.readInWorkspace(workspace, () => arbi.workspaces.listUsers());
1251
1250
  },
1252
1251
  staleTime: MEMBERS_STALE_MS
1253
1252
  });
@@ -5796,12 +5795,22 @@ function isWorkspaceArchivedError(error) {
5796
5795
  var archivedWorkspaceMessage = (name) => `"${name}" is archived. Its owner can unarchive it from the workspace list.`;
5797
5796
  var listedWorkspace = (queryClient, workspaceId) => queryClient.getQueryData(arbiQueryKeys.workspaces())?.find((w) => w.external_id === workspaceId);
5798
5797
  var switchEpoch = 0;
5798
+ var switching = /* @__PURE__ */ new Set();
5799
+ async function switchesSettled() {
5800
+ while (switching.size > 0) await Promise.allSettled([...switching]);
5801
+ }
5799
5802
  function createWorkspaceSwitch({
5800
5803
  arbi,
5801
5804
  session,
5802
5805
  queryClient
5803
5806
  }) {
5804
- const switchWorkspace = async (target) => {
5807
+ const switchWorkspace = (target) => {
5808
+ const run = runSwitch(target);
5809
+ switching.add(run);
5810
+ void run.finally(() => switching.delete(run));
5811
+ return run;
5812
+ };
5813
+ const runSwitch = async (target) => {
5805
5814
  const { workspaceId: previousId, workspaceStatus } = session.getState();
5806
5815
  const isSame = previousId === target.id;
5807
5816
  if (isSame && workspaceStatus === "open") return true;
@@ -5831,8 +5840,12 @@ function createWorkspaceSwitch({
5831
5840
  try {
5832
5841
  opened = await arbi().selectWorkspace(target.id);
5833
5842
  } catch (error) {
5834
- console.error("[switchWorkspace] /open failed:", error);
5835
- if (epoch === switchEpoch) {
5843
+ const superseded = error instanceof ArbiWorkspaceSupersededError;
5844
+ if (!superseded) console.error("[switchWorkspace] /open failed:", error);
5845
+ if (superseded && epoch === switchEpoch) {
5846
+ if (previousId) session.setWorkspaceId(previousId);
5847
+ session.setWorkspaceStatus("closed");
5848
+ } else if (epoch === switchEpoch) {
5836
5849
  if (previousId) session.setWorkspaceId(previousId);
5837
5850
  session.setWorkspaceStatus("closed");
5838
5851
  if (isWorkspaceArchivedError(error)) {
@@ -5866,7 +5879,9 @@ function createWorkspaceSwitch({
5866
5879
  try {
5867
5880
  opened = await arbi().selectWorkspace(workspaceId);
5868
5881
  } catch (error) {
5869
- console.error("[openSelectedWorkspace] /open failed:", error);
5882
+ if (!(error instanceof ArbiWorkspaceSupersededError)) {
5883
+ console.error("[openSelectedWorkspace] /open failed:", error);
5884
+ }
5870
5885
  return false;
5871
5886
  }
5872
5887
  if (epoch !== switchEpoch || session.getState().workspaceId !== workspaceId) return false;
@@ -5875,7 +5890,7 @@ function createWorkspaceSwitch({
5875
5890
  session.setWorkspaceStatus("open");
5876
5891
  return true;
5877
5892
  };
5878
- return { switchWorkspace, clearWorkspace, openSelectedWorkspace };
5893
+ return { switchWorkspace, clearWorkspace, openSelectedWorkspace, settled: switchesSettled };
5879
5894
  }
5880
5895
  function useSwitchWorkspace() {
5881
5896
  const arbi = useArbi();
@@ -6275,7 +6290,7 @@ function useFacts(workspaceId, options) {
6275
6290
  const workspace = workspaceId ?? (arbi.hasWorkspace ? arbi.getWorkspaceId() : "");
6276
6291
  return useQuery({
6277
6292
  queryKey: arbiQueryKeys.factList(workspace, filter),
6278
- queryFn: () => arbi.facts.list(filter),
6293
+ queryFn: () => arbi.readInWorkspace(workspace, () => arbi.facts.list(filter)),
6279
6294
  enabled: enabled && !!workspace && arbi.hasWorkspace,
6280
6295
  staleTime: 3e4
6281
6296
  });