@arbidocs/react 0.5.162 → 0.5.164

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1303,6 +1303,8 @@ function clearUserInputRequest(queryClient, conversationId, messageId) {
1303
1303
  }
1304
1304
  );
1305
1305
  }
1306
+
1307
+ // src/chat/conversation-mentions.ts
1306
1308
  var ASSISTANT_MENTION_LABEL = "ARBI";
1307
1309
  function assistantLabels(assistantName = ASSISTANT_MENTION_LABEL) {
1308
1310
  return assistantName.toLowerCase() === ASSISTANT_MENTION_LABEL.toLowerCase() ? [assistantName] : [assistantName, ASSISTANT_MENTION_LABEL];
@@ -1328,6 +1330,15 @@ function cachedMentionCandidates(queryClient, workspaceId, currentUserId, assist
1328
1330
  const aliases = assistantLabels(assistantName).slice(1).map((label) => ({ id: "assistant", kind: "assistant", label }));
1329
1331
  return [...buildMentionCandidates(users, currentUserId, assistantName), ...aliases];
1330
1332
  }
1333
+ async function cacheAssistantMode(queryClient, conversationId, mode) {
1334
+ const queryKey = getThreadsQueryKey(conversationId);
1335
+ await queryClient.cancelQueries({ queryKey });
1336
+ queryClient.setQueryData(
1337
+ queryKey,
1338
+ (old) => old ? { ...old, assistant_mode: mode } : old
1339
+ );
1340
+ void queryClient.invalidateQueries({ queryKey });
1341
+ }
1331
1342
  function cachedAssistantMode(queryClient, conversationId, newMode) {
1332
1343
  if (!conversationId) return newMode;
1333
1344
  const threads = queryClient.getQueriesData(allConversationThreads).map(([, data]) => data).find((data) => data?.conversation_ext_id === conversationId);
@@ -5919,11 +5930,7 @@ function useConversation(options = {}) {
5919
5930
  setHistoryError(null);
5920
5931
  try {
5921
5932
  await arbi.conversations.setAssistantMode(conversationId, mode);
5922
- queryClient.setQueryData(
5923
- getThreadsQueryKey(conversationId),
5924
- (old) => old ? { ...old, assistant_mode: mode } : old
5925
- );
5926
- void queryClient.invalidateQueries({ queryKey: getThreadsQueryKey(conversationId) });
5933
+ await cacheAssistantMode(queryClient, conversationId, mode);
5927
5934
  void (agentId ? agentHistory.refetch() : ordinaryHistory.refetch());
5928
5935
  } catch (e) {
5929
5936
  setHistoryError(messageOf(e, "The assistant mode could not be changed."));
@@ -21222,6 +21229,7 @@ exports.buildMentionCandidates = buildMentionCandidates;
21222
21229
  exports.buildPendingFirstTurn = buildPendingFirstTurn;
21223
21230
  exports.buildPendingSyncItem = buildPendingSyncItem;
21224
21231
  exports.buildWorkspaceArchive = buildWorkspaceArchive;
21232
+ exports.cacheAssistantMode = cacheAssistantMode;
21225
21233
  exports.cacheThreadBinding = cacheThreadBinding;
21226
21234
  exports.cachedAssistantMode = cachedAssistantMode;
21227
21235
  exports.cachedMentionCandidates = cachedMentionCandidates;