@liveblocks/react 3.8.0-tiptap1 → 3.8.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/_private.cjs CHANGED
@@ -25,7 +25,7 @@
25
25
 
26
26
 
27
27
 
28
- var _chunk4GCS3365cjs = require('./chunk-4GCS3365.cjs');
28
+ var _chunkIQBSX6NScjs = require('./chunk-IQBSX6NS.cjs');
29
29
 
30
30
  // src/lib/use-layout-effect.ts
31
31
  var _react = require('react');
@@ -50,7 +50,7 @@ function selectorFor_useGroup(state) {
50
50
  };
51
51
  }
52
52
  function useGroup(groupId) {
53
- const client = _chunk4GCS3365cjs.useClient.call(void 0, );
53
+ const client = _chunkIQBSX6NScjs.useClient.call(void 0, );
54
54
  const store = client[_core.kInternal].httpClient.groupsStore;
55
55
  const getGroupState = _react.useCallback.call(void 0,
56
56
  () => store.getItemState(groupId),
@@ -59,7 +59,7 @@ function useGroup(groupId) {
59
59
  _react.useEffect.call(void 0, () => {
60
60
  void store.enqueue(groupId);
61
61
  }, [store, groupId]);
62
- return _chunk4GCS3365cjs.useSyncExternalStoreWithSelector.call(void 0,
62
+ return _chunkIQBSX6NScjs.useSyncExternalStoreWithSelector.call(void 0,
63
63
  store.subscribe,
64
64
  getGroupState,
65
65
  getGroupState,
@@ -80,8 +80,8 @@ function normalizeMentionSuggestions(suggestions) {
80
80
  function useMentionSuggestions(roomId, search) {
81
81
  const [mentionSuggestions, setMentionSuggestions] = _react.useState.call(void 0, );
82
82
  const lastInvokedAt = _react.useRef.call(void 0, );
83
- const resolveMentionSuggestions = _chunk4GCS3365cjs.useResolveMentionSuggestions.call(void 0, );
84
- const mentionSuggestionsCache = _chunk4GCS3365cjs.useMentionSuggestionsCache.call(void 0, );
83
+ const resolveMentionSuggestions = _chunkIQBSX6NScjs.useResolveMentionSuggestions.call(void 0, );
84
+ const mentionSuggestionsCache = _chunkIQBSX6NScjs.useMentionSuggestionsCache.call(void 0, );
85
85
  _react.useEffect.call(void 0, () => {
86
86
  if (search === void 0 || !resolveMentionSuggestions) {
87
87
  return;
@@ -136,7 +136,7 @@ function useMentionSuggestions(roomId, search) {
136
136
 
137
137
 
138
138
  function useSyncSource() {
139
- const client = _chunk4GCS3365cjs.useClient.call(void 0, );
139
+ const client = _chunkIQBSX6NScjs.useClient.call(void 0, );
140
140
  const createSyncSource = client[_core.kInternal].createSyncSource;
141
141
  const [syncSource, setSyncSource] = _react.useState.call(void 0, );
142
142
  _react.useEffect.call(void 0, () => {
@@ -176,5 +176,5 @@ function useSyncSource() {
176
176
 
177
177
 
178
178
 
179
- exports.getUmbrellaStoreForClient = _chunk4GCS3365cjs.getUmbrellaStoreForClient; exports.useAddRoomCommentReaction = _chunk4GCS3365cjs.useAddRoomCommentReaction; exports.useClientOrNull = _chunk4GCS3365cjs.useClientOrNull; exports.useCreateRoomComment = _chunk4GCS3365cjs.useCreateRoomComment; exports.useCreateRoomThread = _chunk4GCS3365cjs.useCreateRoomThread; exports.useCreateTextMention = _chunk4GCS3365cjs.useCreateTextMention; exports.useDeleteRoomComment = _chunk4GCS3365cjs.useDeleteRoomComment; exports.useDeleteRoomThread = _chunk4GCS3365cjs.useDeleteRoomThread; exports.useDeleteTextMention = _chunk4GCS3365cjs.useDeleteTextMention; exports.useEditRoomComment = _chunk4GCS3365cjs.useEditRoomComment; exports.useEditRoomThreadMetadata = _chunk4GCS3365cjs.useEditRoomThreadMetadata; exports.useGroup = useGroup; exports.useLatest = _chunk4GCS3365cjs.useLatest; exports.useLayoutEffect = useLayoutEffect; exports.useMarkRoomThreadAsRead = _chunk4GCS3365cjs.useMarkRoomThreadAsRead; exports.useMarkRoomThreadAsResolved = _chunk4GCS3365cjs.useMarkRoomThreadAsResolved; exports.useMarkRoomThreadAsUnresolved = _chunk4GCS3365cjs.useMarkRoomThreadAsUnresolved; exports.useMentionSuggestions = useMentionSuggestions; exports.useMentionSuggestionsCache = _chunk4GCS3365cjs.useMentionSuggestionsCache; exports.useRemoveRoomCommentReaction = _chunk4GCS3365cjs.useRemoveRoomCommentReaction; exports.useReportTextEditor = _chunk4GCS3365cjs.useReportTextEditor; exports.useResolveMentionSuggestions = _chunk4GCS3365cjs.useResolveMentionSuggestions; exports.useRoomAttachmentUrl = _chunk4GCS3365cjs.useRoomAttachmentUrl; exports.useRoomPermissions = _chunk4GCS3365cjs.useRoomPermissions; exports.useRoomThreadSubscription = _chunk4GCS3365cjs.useRoomThreadSubscription; exports.useSignal = _chunk4GCS3365cjs.useSignal; exports.useSyncExternalStoreWithSelector = _chunk4GCS3365cjs.useSyncExternalStoreWithSelector; exports.useSyncSource = useSyncSource; exports.useYjsProvider = _chunk4GCS3365cjs.useYjsProvider;
179
+ exports.getUmbrellaStoreForClient = _chunkIQBSX6NScjs.getUmbrellaStoreForClient; exports.useAddRoomCommentReaction = _chunkIQBSX6NScjs.useAddRoomCommentReaction; exports.useClientOrNull = _chunkIQBSX6NScjs.useClientOrNull; exports.useCreateRoomComment = _chunkIQBSX6NScjs.useCreateRoomComment; exports.useCreateRoomThread = _chunkIQBSX6NScjs.useCreateRoomThread; exports.useCreateTextMention = _chunkIQBSX6NScjs.useCreateTextMention; exports.useDeleteRoomComment = _chunkIQBSX6NScjs.useDeleteRoomComment; exports.useDeleteRoomThread = _chunkIQBSX6NScjs.useDeleteRoomThread; exports.useDeleteTextMention = _chunkIQBSX6NScjs.useDeleteTextMention; exports.useEditRoomComment = _chunkIQBSX6NScjs.useEditRoomComment; exports.useEditRoomThreadMetadata = _chunkIQBSX6NScjs.useEditRoomThreadMetadata; exports.useGroup = useGroup; exports.useLatest = _chunkIQBSX6NScjs.useLatest; exports.useLayoutEffect = useLayoutEffect; exports.useMarkRoomThreadAsRead = _chunkIQBSX6NScjs.useMarkRoomThreadAsRead; exports.useMarkRoomThreadAsResolved = _chunkIQBSX6NScjs.useMarkRoomThreadAsResolved; exports.useMarkRoomThreadAsUnresolved = _chunkIQBSX6NScjs.useMarkRoomThreadAsUnresolved; exports.useMentionSuggestions = useMentionSuggestions; exports.useMentionSuggestionsCache = _chunkIQBSX6NScjs.useMentionSuggestionsCache; exports.useRemoveRoomCommentReaction = _chunkIQBSX6NScjs.useRemoveRoomCommentReaction; exports.useReportTextEditor = _chunkIQBSX6NScjs.useReportTextEditor; exports.useResolveMentionSuggestions = _chunkIQBSX6NScjs.useResolveMentionSuggestions; exports.useRoomAttachmentUrl = _chunkIQBSX6NScjs.useRoomAttachmentUrl; exports.useRoomPermissions = _chunkIQBSX6NScjs.useRoomPermissions; exports.useRoomThreadSubscription = _chunkIQBSX6NScjs.useRoomThreadSubscription; exports.useSignal = _chunkIQBSX6NScjs.useSignal; exports.useSyncExternalStoreWithSelector = _chunkIQBSX6NScjs.useSyncExternalStoreWithSelector; exports.useSyncSource = useSyncSource; exports.useYjsProvider = _chunkIQBSX6NScjs.useYjsProvider;
180
180
  //# sourceMappingURL=_private.cjs.map
@@ -1,5 +1,5 @@
1
- import { G as GroupAsyncResult } from './room-BtcL74U0.cjs';
2
- export { g as getUmbrellaStoreForClient, a as useAddRoomCommentReaction, u as useClientOrNull, b as useCreateRoomComment, c as useCreateRoomThread, d as useCreateTextMention, e as useDeleteRoomComment, f as useDeleteRoomThread, h as useDeleteTextMention, i as useEditRoomComment, j as useEditRoomThreadMetadata, k as useMarkRoomThreadAsRead, l as useMarkRoomThreadAsResolved, m as useMarkRoomThreadAsUnresolved, n as useMentionSuggestionsCache, o as useRemoveRoomCommentReaction, p as useReportTextEditor, q as useResolveMentionSuggestions, r as useRoomAttachmentUrl, s as useRoomPermissions, t as useRoomThreadSubscription, v as useYjsProvider } from './room-BtcL74U0.cjs';
1
+ import { G as GroupAsyncResult } from './room-C97RX2dB.cjs';
2
+ export { g as getUmbrellaStoreForClient, a as useAddRoomCommentReaction, u as useClientOrNull, b as useCreateRoomComment, c as useCreateRoomThread, d as useCreateTextMention, e as useDeleteRoomComment, f as useDeleteRoomThread, h as useDeleteTextMention, i as useEditRoomComment, j as useEditRoomThreadMetadata, k as useMarkRoomThreadAsRead, l as useMarkRoomThreadAsResolved, m as useMarkRoomThreadAsUnresolved, n as useMentionSuggestionsCache, o as useRemoveRoomCommentReaction, p as useReportTextEditor, q as useResolveMentionSuggestions, r as useRoomAttachmentUrl, s as useRoomPermissions, t as useRoomThreadSubscription, v as useYjsProvider } from './room-C97RX2dB.cjs';
3
3
  import { MutableRefObject, useEffect } from 'react';
4
4
  import { MentionData, ISignal, SyncSource } from '@liveblocks/core';
5
5
  import '@liveblocks/client';
@@ -1,5 +1,5 @@
1
- import { G as GroupAsyncResult } from './room-BtcL74U0.js';
2
- export { g as getUmbrellaStoreForClient, a as useAddRoomCommentReaction, u as useClientOrNull, b as useCreateRoomComment, c as useCreateRoomThread, d as useCreateTextMention, e as useDeleteRoomComment, f as useDeleteRoomThread, h as useDeleteTextMention, i as useEditRoomComment, j as useEditRoomThreadMetadata, k as useMarkRoomThreadAsRead, l as useMarkRoomThreadAsResolved, m as useMarkRoomThreadAsUnresolved, n as useMentionSuggestionsCache, o as useRemoveRoomCommentReaction, p as useReportTextEditor, q as useResolveMentionSuggestions, r as useRoomAttachmentUrl, s as useRoomPermissions, t as useRoomThreadSubscription, v as useYjsProvider } from './room-BtcL74U0.js';
1
+ import { G as GroupAsyncResult } from './room-C97RX2dB.js';
2
+ export { g as getUmbrellaStoreForClient, a as useAddRoomCommentReaction, u as useClientOrNull, b as useCreateRoomComment, c as useCreateRoomThread, d as useCreateTextMention, e as useDeleteRoomComment, f as useDeleteRoomThread, h as useDeleteTextMention, i as useEditRoomComment, j as useEditRoomThreadMetadata, k as useMarkRoomThreadAsRead, l as useMarkRoomThreadAsResolved, m as useMarkRoomThreadAsUnresolved, n as useMentionSuggestionsCache, o as useRemoveRoomCommentReaction, p as useReportTextEditor, q as useResolveMentionSuggestions, r as useRoomAttachmentUrl, s as useRoomPermissions, t as useRoomThreadSubscription, v as useYjsProvider } from './room-C97RX2dB.js';
3
3
  import { MutableRefObject, useEffect } from 'react';
4
4
  import { MentionData, ISignal, SyncSource } from '@liveblocks/core';
5
5
  import '@liveblocks/client';
package/dist/_private.js CHANGED
@@ -25,7 +25,7 @@ import {
25
25
  useSignal,
26
26
  useSyncExternalStoreWithSelector,
27
27
  useYjsProvider
28
- } from "./chunk-OKYUUXNY.js";
28
+ } from "./chunk-2R44HQCN.js";
29
29
 
30
30
  // src/lib/use-layout-effect.ts
31
31
  import { useEffect, useLayoutEffect as useOriginalLayoutEffect } from "react";
@@ -172,6 +172,7 @@ import {
172
172
  assert,
173
173
  console as console2,
174
174
  createClient,
175
+ DefaultMap as DefaultMap2,
175
176
  HttpError,
176
177
  kInternal as kInternal3,
177
178
  makePoller,
@@ -216,21 +217,6 @@ function ASYNC_OK(fieldOrData, data) {
216
217
  }
217
218
  }
218
219
 
219
- // src/lib/itertools.ts
220
- function find(it, predicate) {
221
- for (const item of it) {
222
- if (predicate(item)) return item;
223
- }
224
- return void 0;
225
- }
226
- function count(it, predicate) {
227
- let total = 0;
228
- for (const item of it) {
229
- if (predicate(item)) total++;
230
- }
231
- return total;
232
- }
233
-
234
220
  // src/lib/ssr.ts
235
221
  function ensureNotServerSide() {
236
222
  if (typeof window === "undefined") {
@@ -324,8 +310,16 @@ function autobind(self) {
324
310
  } while ((obj = Reflect.getPrototypeOf(obj)) && obj !== Object.prototype);
325
311
  }
326
312
 
313
+ // src/lib/itertools.ts
314
+ function find(it, predicate) {
315
+ for (const item of it) {
316
+ if (predicate(item)) return item;
317
+ }
318
+ return void 0;
319
+ }
320
+
327
321
  // src/lib/querying.ts
328
- import { isStartsWithOperator } from "@liveblocks/core";
322
+ import { isNumberOperator, isStartsWithOperator } from "@liveblocks/core";
329
323
  function makeThreadsFilter(query) {
330
324
  return (thread) => matchesThreadsQuery(thread, query) && matchesMetadata(thread, query);
331
325
  }
@@ -347,10 +341,15 @@ function matchesOperator(value, op) {
347
341
  return value === void 0;
348
342
  } else if (isStartsWithOperator(op)) {
349
343
  return typeof value === "string" && value.startsWith(op.startsWith);
344
+ } else if (isNumberOperator(op)) {
345
+ return typeof value === "number" && matchesNumberOperator(value, op);
350
346
  } else {
351
347
  return value === op;
352
348
  }
353
349
  }
350
+ function matchesNumberOperator(value, op) {
351
+ return (op.lt === void 0 || value < op.lt) && (op.gt === void 0 || value > op.gt) && (op.lte === void 0 || value <= op.lte) && (op.gte === void 0 || value >= op.gte);
352
+ }
354
353
  function makeInboxNotificationsFilter(query) {
355
354
  return (inboxNotification) => matchesInboxNotificationsQuery(inboxNotification, query);
356
355
  }
@@ -722,6 +721,21 @@ function createStore_forNotifications() {
722
721
  upsert
723
722
  };
724
723
  }
724
+ function createStore_forUnreadNotificationsCount() {
725
+ const baseSignal = new MutableSignal3(
726
+ /* @__PURE__ */ new Map()
727
+ );
728
+ function update(queryKey, count) {
729
+ baseSignal.mutate((lut) => {
730
+ lut.set(queryKey, count);
731
+ });
732
+ }
733
+ return {
734
+ signal: DerivedSignal.from(baseSignal, (c) => Object.fromEntries(c)),
735
+ // Mutations
736
+ update
737
+ };
738
+ }
725
739
  function createStore_forSubscriptions(updates, threads) {
726
740
  const baseSignal = new MutableSignal3(/* @__PURE__ */ new Map());
727
741
  function applyDelta(newSubscriptions, deletedSubscriptions) {
@@ -911,6 +925,7 @@ var UmbrellaStore = class {
911
925
  roomSubscriptionSettings;
912
926
  // prettier-ignore
913
927
  historyVersions;
928
+ unreadNotificationsCount;
914
929
  permissionHints;
915
930
  notificationSettings;
916
931
  optimisticUpdates;
@@ -958,6 +973,7 @@ var UmbrellaStore = class {
958
973
  this.optimisticUpdates.signal
959
974
  );
960
975
  this.historyVersions = createStore_forHistoryVersions();
976
+ this.unreadNotificationsCount = createStore_forUnreadNotificationsCount();
961
977
  const threadifications = DerivedSignal.from(
962
978
  this.threads.signal,
963
979
  this.notifications.signal,
@@ -1114,6 +1130,35 @@ var UmbrellaStore = class {
1114
1130
  };
1115
1131
  }
1116
1132
  );
1133
+ const unreadNotificationsCount = new DefaultMap(
1134
+ (queryKey) => {
1135
+ const query = JSON.parse(queryKey);
1136
+ const resource = new SinglePageResource(async () => {
1137
+ const result = await this.#client.getUnreadInboxNotificationsCount({
1138
+ query
1139
+ });
1140
+ this.unreadNotificationsCount.update(queryKey, result);
1141
+ });
1142
+ const signal = DerivedSignal.from(
1143
+ () => {
1144
+ const result = resource.get();
1145
+ if (result.isLoading || result.error) {
1146
+ return result;
1147
+ } else {
1148
+ return ASYNC_OK(
1149
+ "count",
1150
+ nn(this.unreadNotificationsCount.signal.get()[queryKey])
1151
+ );
1152
+ }
1153
+ },
1154
+ shallow
1155
+ );
1156
+ return {
1157
+ signal,
1158
+ waitUntilLoaded: resource.waitUntilLoaded
1159
+ };
1160
+ }
1161
+ );
1117
1162
  const roomSubscriptionSettingsByRoomId = new DefaultMap(
1118
1163
  (roomId) => {
1119
1164
  const resource = new SinglePageResource(async () => {
@@ -1262,6 +1307,7 @@ var UmbrellaStore = class {
1262
1307
  loadingUserThreads,
1263
1308
  notifications,
1264
1309
  loadingNotifications,
1310
+ unreadNotificationsCount,
1265
1311
  roomSubscriptionSettingsByRoomId,
1266
1312
  versionsByRoomId,
1267
1313
  notificationSettings,
@@ -1469,6 +1515,14 @@ var UmbrellaStore = class {
1469
1515
  result.subscriptions.deleted
1470
1516
  );
1471
1517
  }
1518
+ async fetchUnreadNotificationsCount(queryKey, signal) {
1519
+ const query = JSON.parse(queryKey);
1520
+ const result = await this.#client.getUnreadInboxNotificationsCount({
1521
+ query,
1522
+ signal
1523
+ });
1524
+ this.unreadNotificationsCount.update(queryKey, result);
1525
+ }
1472
1526
  async fetchRoomThreadsDeltaUpdate(roomId, signal) {
1473
1527
  const lastRequestedAt = this.#roomThreadsLastRequestedAtByRoom.get(roomId);
1474
1528
  if (lastRequestedAt === void 0) {
@@ -1983,16 +2037,10 @@ var _umbrellaStores = /* @__PURE__ */ new WeakMap();
1983
2037
  var _extras = /* @__PURE__ */ new WeakMap();
1984
2038
  var _bundles = /* @__PURE__ */ new WeakMap();
1985
2039
  function selectorFor_useUnreadInboxNotificationsCount(result) {
1986
- if (!result.inboxNotifications) {
2040
+ if (!("count" in result) || result.count === void 0) {
1987
2041
  return result;
1988
2042
  }
1989
- return ASYNC_OK(
1990
- "count",
1991
- count(
1992
- result.inboxNotifications,
1993
- (n) => n.readAt === null || n.readAt < n.notifiedAt
1994
- )
1995
- );
2043
+ return ASYNC_OK("count", result.count);
1996
2044
  }
1997
2045
  function selectorFor_useUser(state, userId) {
1998
2046
  if (state === void 0 || state?.isLoading) {
@@ -2091,6 +2139,22 @@ function makeLiveblocksExtrasForClient(client) {
2091
2139
  config.NOTIFICATIONS_POLL_INTERVAL,
2092
2140
  { maxStaleTimeMs: config.NOTIFICATIONS_MAX_STALE_TIME }
2093
2141
  );
2142
+ const unreadNotificationsCountPollersByQueryKey = new DefaultMap2(
2143
+ (queryKey) => makePoller(
2144
+ async (signal) => {
2145
+ try {
2146
+ return await store.fetchUnreadNotificationsCount(queryKey, signal);
2147
+ } catch (err) {
2148
+ console2.warn(
2149
+ `Polling unread inbox notifications countfailed: ${String(err)}`
2150
+ );
2151
+ throw err;
2152
+ }
2153
+ },
2154
+ config.NOTIFICATIONS_POLL_INTERVAL,
2155
+ { maxStaleTimeMs: config.NOTIFICATIONS_MAX_STALE_TIME }
2156
+ )
2157
+ );
2094
2158
  const userThreadsPoller = makePoller(
2095
2159
  async (signal) => {
2096
2160
  try {
@@ -2121,7 +2185,8 @@ function makeLiveblocksExtrasForClient(client) {
2121
2185
  store,
2122
2186
  notificationsPoller,
2123
2187
  userThreadsPoller,
2124
- notificationSettingsPoller
2188
+ notificationSettingsPoller,
2189
+ unreadNotificationsCountPollersByQueryKey
2125
2190
  };
2126
2191
  }
2127
2192
  function makeLiveblocksContextBundle(client) {
@@ -2151,6 +2216,7 @@ function makeLiveblocksContextBundle(client) {
2151
2216
  useAiChats,
2152
2217
  useAiChat,
2153
2218
  useAiChatMessages,
2219
+ useAiChatStatus,
2154
2220
  useCreateAiChat,
2155
2221
  useDeleteAiChat,
2156
2222
  useSendAiMessage,
@@ -2170,6 +2236,7 @@ function makeLiveblocksContextBundle(client) {
2170
2236
  useAiChats: useAiChatsSuspense,
2171
2237
  useAiChat: useAiChatSuspense,
2172
2238
  useAiChatMessages: useAiChatMessagesSuspense,
2239
+ useAiChatStatus,
2173
2240
  useCreateAiChat,
2174
2241
  useDeleteAiChat,
2175
2242
  useSendAiMessage,
@@ -2223,11 +2290,31 @@ function useInboxNotificationsSuspense_withClient(client, options) {
2223
2290
  return result;
2224
2291
  }
2225
2292
  function useUnreadInboxNotificationsCount_withClient(client, options) {
2226
- return useInboxNotifications_withClient(
2227
- client,
2293
+ const { store, unreadNotificationsCountPollersByQueryKey: pollers } = getLiveblocksExtrasForClient(client);
2294
+ const queryKey = makeInboxNotificationsQueryKey(options?.query);
2295
+ const poller = pollers.getOrCreate(queryKey);
2296
+ useEffect4(
2297
+ () => void store.outputs.unreadNotificationsCount.getOrCreate(queryKey).waitUntilLoaded()
2298
+ // NOTE: Deliberately *not* using a dependency array here!
2299
+ //
2300
+ // It is important to call waitUntil on *every* render.
2301
+ // This is harmless though, on most renders, except:
2302
+ // 1. The very first render, in which case we'll want to trigger the initial page fetch.
2303
+ // 2. All other subsequent renders now "just" return the same promise (a quick operation).
2304
+ // 3. If ever the promise would fail, then after 5 seconds it would reset, and on the very
2305
+ // *next* render after that, a *new* fetch/promise will get created.
2306
+ );
2307
+ useEffect4(() => {
2308
+ poller.inc();
2309
+ poller.pollNowIfStale();
2310
+ return () => {
2311
+ poller.dec();
2312
+ };
2313
+ }, [poller]);
2314
+ return useSignal(
2315
+ store.outputs.unreadNotificationsCount.getOrCreate(queryKey).signal,
2228
2316
  selectorFor_useUnreadInboxNotificationsCount,
2229
- shallow3,
2230
- options
2317
+ shallow3
2231
2318
  );
2232
2319
  }
2233
2320
  function useUnreadInboxNotificationsCountSuspense_withClient(client, options) {
@@ -2235,7 +2322,7 @@ function useUnreadInboxNotificationsCountSuspense_withClient(client, options) {
2235
2322
  const store = getLiveblocksExtrasForClient(client).store;
2236
2323
  const queryKey = makeInboxNotificationsQueryKey(options?.query);
2237
2324
  use(
2238
- store.outputs.loadingNotifications.getOrCreate(queryKey).waitUntilLoaded()
2325
+ store.outputs.unreadNotificationsCount.getOrCreate(queryKey).waitUntilLoaded()
2239
2326
  );
2240
2327
  const result = useUnreadInboxNotificationsCount_withClient(client, options);
2241
2328
  assert(!result.isLoading, "Did not expect loading");
@@ -2245,7 +2332,7 @@ function useUnreadInboxNotificationsCountSuspense_withClient(client, options) {
2245
2332
  function useMarkInboxNotificationAsRead_withClient(client) {
2246
2333
  return useCallback2(
2247
2334
  (inboxNotificationId) => {
2248
- const { store } = getLiveblocksExtrasForClient(client);
2335
+ const { store, unreadNotificationsCountPollersByQueryKey } = getLiveblocksExtrasForClient(client);
2249
2336
  const readAt = /* @__PURE__ */ new Date();
2250
2337
  const optimisticId = store.optimisticUpdates.add({
2251
2338
  type: "mark-inbox-notification-as-read",
@@ -2259,6 +2346,10 @@ function useMarkInboxNotificationAsRead_withClient(client) {
2259
2346
  readAt,
2260
2347
  optimisticId
2261
2348
  );
2349
+ for (const poller of unreadNotificationsCountPollersByQueryKey.values()) {
2350
+ poller.markAsStale();
2351
+ poller.pollNowIfStale();
2352
+ }
2262
2353
  },
2263
2354
  (err) => {
2264
2355
  store.optimisticUpdates.remove(optimisticId);
@@ -2277,7 +2368,7 @@ function useMarkInboxNotificationAsRead_withClient(client) {
2277
2368
  }
2278
2369
  function useMarkAllInboxNotificationsAsRead_withClient(client) {
2279
2370
  return useCallback2(() => {
2280
- const { store } = getLiveblocksExtrasForClient(client);
2371
+ const { store, unreadNotificationsCountPollersByQueryKey } = getLiveblocksExtrasForClient(client);
2281
2372
  const readAt = /* @__PURE__ */ new Date();
2282
2373
  const optimisticId = store.optimisticUpdates.add({
2283
2374
  type: "mark-all-inbox-notifications-as-read",
@@ -2286,6 +2377,10 @@ function useMarkAllInboxNotificationsAsRead_withClient(client) {
2286
2377
  client.markAllInboxNotificationsAsRead().then(
2287
2378
  () => {
2288
2379
  store.markAllInboxNotificationsRead(optimisticId, readAt);
2380
+ for (const poller of unreadNotificationsCountPollersByQueryKey.values()) {
2381
+ poller.markAsStale();
2382
+ poller.pollNowIfStale();
2383
+ }
2289
2384
  },
2290
2385
  (err) => {
2291
2386
  store.optimisticUpdates.remove(optimisticId);
@@ -2301,7 +2396,7 @@ function useMarkAllInboxNotificationsAsRead_withClient(client) {
2301
2396
  function useDeleteInboxNotification_withClient(client) {
2302
2397
  return useCallback2(
2303
2398
  (inboxNotificationId) => {
2304
- const { store } = getLiveblocksExtrasForClient(client);
2399
+ const { store, unreadNotificationsCountPollersByQueryKey } = getLiveblocksExtrasForClient(client);
2305
2400
  const deletedAt = /* @__PURE__ */ new Date();
2306
2401
  const optimisticId = store.optimisticUpdates.add({
2307
2402
  type: "delete-inbox-notification",
@@ -2311,6 +2406,10 @@ function useDeleteInboxNotification_withClient(client) {
2311
2406
  client.deleteInboxNotification(inboxNotificationId).then(
2312
2407
  () => {
2313
2408
  store.deleteInboxNotification(inboxNotificationId, optimisticId);
2409
+ for (const poller of unreadNotificationsCountPollersByQueryKey.values()) {
2410
+ poller.markAsStale();
2411
+ poller.pollNowIfStale();
2412
+ }
2314
2413
  },
2315
2414
  (err) => {
2316
2415
  store.optimisticUpdates.remove(optimisticId);
@@ -2326,7 +2425,7 @@ function useDeleteInboxNotification_withClient(client) {
2326
2425
  }
2327
2426
  function useDeleteAllInboxNotifications_withClient(client) {
2328
2427
  return useCallback2(() => {
2329
- const { store } = getLiveblocksExtrasForClient(client);
2428
+ const { store, unreadNotificationsCountPollersByQueryKey } = getLiveblocksExtrasForClient(client);
2330
2429
  const deletedAt = /* @__PURE__ */ new Date();
2331
2430
  const optimisticId = store.optimisticUpdates.add({
2332
2431
  type: "delete-all-inbox-notifications",
@@ -2335,6 +2434,10 @@ function useDeleteAllInboxNotifications_withClient(client) {
2335
2434
  client.deleteAllInboxNotifications().then(
2336
2435
  () => {
2337
2436
  store.deleteAllInboxNotifications(optimisticId);
2437
+ for (const poller of unreadNotificationsCountPollersByQueryKey.values()) {
2438
+ poller.markAsStale();
2439
+ poller.pollNowIfStale();
2440
+ }
2338
2441
  },
2339
2442
  (err) => {
2340
2443
  store.optimisticUpdates.remove(optimisticId);
@@ -2746,6 +2849,43 @@ function useDeleteAiChat() {
2746
2849
  [client]
2747
2850
  );
2748
2851
  }
2852
+ var LOADING = Object.freeze({ status: "loading" });
2853
+ var IDLE = Object.freeze({ status: "idle" });
2854
+ function useAiChatStatus(chatId, branchId) {
2855
+ const client = useClient();
2856
+ const store = getUmbrellaStoreForClient(client);
2857
+ useEnsureAiConnection(client);
2858
+ useEffect4(
2859
+ () => void store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(branchId ?? null).waitUntilLoaded()
2860
+ );
2861
+ return useSignal(
2862
+ // Signal
2863
+ store.outputs.messagesByChatId.getOrCreate(chatId).getOrCreate(branchId ?? null).signal,
2864
+ // Selector
2865
+ (result) => {
2866
+ if (result.isLoading) return LOADING;
2867
+ if (result.error) return IDLE;
2868
+ const messages = result.messages;
2869
+ const lastMessage = messages[messages.length - 1];
2870
+ if (lastMessage?.role !== "assistant") return IDLE;
2871
+ if (lastMessage.status !== "generating" && lastMessage.status !== "awaiting-tool")
2872
+ return IDLE;
2873
+ const contentSoFar = lastMessage.contentSoFar;
2874
+ const lastPart = contentSoFar[contentSoFar.length - 1];
2875
+ if (lastPart?.type === "tool-invocation") {
2876
+ return {
2877
+ status: "generating",
2878
+ partType: "tool-invocation",
2879
+ toolName: lastPart.name
2880
+ };
2881
+ } else {
2882
+ return { status: "generating", partType: lastPart?.type };
2883
+ }
2884
+ },
2885
+ // Consider { status: "generating", partType: "text" } and { status: "generating", partType: "text" } equal
2886
+ shallow3
2887
+ );
2888
+ }
2749
2889
  function useSendAiMessage(chatId, options) {
2750
2890
  const client = useClient();
2751
2891
  return useCallback2(
@@ -3064,7 +3204,7 @@ import {
3064
3204
  console as console3,
3065
3205
  createCommentId,
3066
3206
  createThreadId,
3067
- DefaultMap as DefaultMap2,
3207
+ DefaultMap as DefaultMap3,
3068
3208
  errorIf,
3069
3209
  getSubscriptionKey as getSubscriptionKey2,
3070
3210
  HttpError as HttpError2,
@@ -3198,7 +3338,7 @@ function makeRoomExtrasForClient(client) {
3198
3338
  throw innerError;
3199
3339
  }
3200
3340
  }
3201
- const threadsPollersByRoomId = new DefaultMap2(
3341
+ const threadsPollersByRoomId = new DefaultMap3(
3202
3342
  (roomId) => makePoller2(
3203
3343
  async (signal) => {
3204
3344
  try {
@@ -3212,7 +3352,7 @@ function makeRoomExtrasForClient(client) {
3212
3352
  { maxStaleTimeMs: config.ROOM_THREADS_MAX_STALE_TIME }
3213
3353
  )
3214
3354
  );
3215
- const versionsPollersByRoomId = new DefaultMap2(
3355
+ const versionsPollersByRoomId = new DefaultMap3(
3216
3356
  (roomId) => makePoller2(
3217
3357
  async (signal) => {
3218
3358
  try {
@@ -3226,7 +3366,7 @@ function makeRoomExtrasForClient(client) {
3226
3366
  { maxStaleTimeMs: config.HISTORY_VERSIONS_MAX_STALE_TIME }
3227
3367
  )
3228
3368
  );
3229
- const roomSubscriptionSettingsPollersByRoomId = new DefaultMap2(
3369
+ const roomSubscriptionSettingsPollersByRoomId = new DefaultMap3(
3230
3370
  (roomId) => makePoller2(
3231
3371
  async (signal) => {
3232
3372
  try {
@@ -4692,6 +4832,7 @@ export {
4692
4832
  getUmbrellaStoreForClient,
4693
4833
  useCreateAiChat,
4694
4834
  useDeleteAiChat,
4835
+ useAiChatStatus,
4695
4836
  useSendAiMessage,
4696
4837
  LiveblocksProvider,
4697
4838
  createLiveblocksContext,
@@ -4798,4 +4939,4 @@ export {
4798
4939
  _useStorageRoot,
4799
4940
  _useUpdateMyPresence
4800
4941
  };
4801
- //# sourceMappingURL=chunk-OKYUUXNY.js.map
4942
+ //# sourceMappingURL=chunk-2R44HQCN.js.map