@liveblocks/react 3.13.0-vincent3 → 3.13.1-hackathon
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 +7 -7
- package/dist/_private.d.cts +2 -2
- package/dist/_private.d.ts +2 -2
- package/dist/_private.js +1 -1
- package/dist/{chunk-ARSAULLN.cjs → chunk-73OAUQFM.cjs} +2 -2
- package/dist/{chunk-ARSAULLN.cjs.map → chunk-73OAUQFM.cjs.map} +1 -1
- package/dist/{chunk-N6XTID4W.js → chunk-A3DIFDDH.js} +2 -2
- package/dist/{chunk-5I7TKGJB.cjs → chunk-JXNC4PPG.cjs} +462 -53
- package/dist/chunk-JXNC4PPG.cjs.map +1 -0
- package/dist/{chunk-CCOIV25T.js → chunk-VSUKKNOK.js} +426 -17
- package/dist/chunk-VSUKKNOK.js.map +1 -0
- package/dist/index.cjs +10 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/{room-BadENFHi.d.cts → room-CVCL9bCW.d.cts} +231 -108
- package/dist/{room-BadENFHi.d.ts → room-CVCL9bCW.d.ts} +231 -108
- package/dist/suspense.cjs +6 -4
- package/dist/suspense.cjs.map +1 -1
- package/dist/suspense.d.cts +1 -1
- package/dist/suspense.d.ts +1 -1
- package/dist/suspense.js +8 -6
- package/dist/suspense.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-5I7TKGJB.cjs.map +0 -1
- package/dist/chunk-CCOIV25T.js.map +0 -1
- /package/dist/{chunk-N6XTID4W.js.map → chunk-A3DIFDDH.js.map} +0 -0
|
@@ -330,7 +330,7 @@ import {
|
|
|
330
330
|
isStartsWithOperator
|
|
331
331
|
} from "@liveblocks/core";
|
|
332
332
|
function makeThreadsFilter(query, subscriptions) {
|
|
333
|
-
return (thread) => matchesThreadsQuery(thread, query, subscriptions) &&
|
|
333
|
+
return (thread) => matchesThreadsQuery(thread, query, subscriptions) && matchesThreadMetadata(thread, query);
|
|
334
334
|
}
|
|
335
335
|
function matchesThreadsQuery(thread, q, subscriptions) {
|
|
336
336
|
let subscription = void 0;
|
|
@@ -339,7 +339,7 @@ function matchesThreadsQuery(thread, q, subscriptions) {
|
|
|
339
339
|
}
|
|
340
340
|
return (q.resolved === void 0 || thread.resolved === q.resolved) && (q.subscribed === void 0 || q.subscribed === true && subscription !== void 0 || q.subscribed === false && subscription === void 0);
|
|
341
341
|
}
|
|
342
|
-
function
|
|
342
|
+
function matchesThreadMetadata(thread, q) {
|
|
343
343
|
const metadata = thread.metadata;
|
|
344
344
|
return q.metadata === void 0 || Object.entries(q.metadata).every(
|
|
345
345
|
([key, op]) => (
|
|
@@ -512,6 +512,12 @@ function makeAiChatsQueryKey(query) {
|
|
|
512
512
|
function makeInboxNotificationsQueryKey(query) {
|
|
513
513
|
return stableStringify(query ?? {});
|
|
514
514
|
}
|
|
515
|
+
function makeAgentSessionsQueryKey(roomId, options) {
|
|
516
|
+
return stableStringify([roomId, options ?? {}]);
|
|
517
|
+
}
|
|
518
|
+
function makeAgentMessagesQueryKey(roomId, sessionId, options) {
|
|
519
|
+
return stableStringify([roomId, sessionId, options ?? {}]);
|
|
520
|
+
}
|
|
515
521
|
function usify(promise) {
|
|
516
522
|
if ("status" in promise) {
|
|
517
523
|
return promise;
|
|
@@ -978,6 +984,19 @@ var UmbrellaStore = class {
|
|
|
978
984
|
#roomVersionsLastRequestedAtByRoom = /* @__PURE__ */ new Map();
|
|
979
985
|
// Notification Settings
|
|
980
986
|
#notificationSettings;
|
|
987
|
+
// Agent Sessions
|
|
988
|
+
#roomsByRoomId = /* @__PURE__ */ new Map();
|
|
989
|
+
// TODO: the need for this seems wrong, i need to explore if maybe this stuff belongs in in RoomContext and not here
|
|
990
|
+
#agentSessionsByRoomId = /* @__PURE__ */ new Map();
|
|
991
|
+
#agentMessagesBySessionId = /* @__PURE__ */ new Map();
|
|
992
|
+
// Signals for agent sessions and messages to trigger reactivity
|
|
993
|
+
// We use a version counter to track changes
|
|
994
|
+
#agentSessionsSignal = new MutableSignal3({
|
|
995
|
+
version: 0
|
|
996
|
+
});
|
|
997
|
+
#agentMessagesSignal = new MutableSignal3({
|
|
998
|
+
version: 0
|
|
999
|
+
});
|
|
981
1000
|
constructor(client) {
|
|
982
1001
|
this.#client = client[kInternal2].as();
|
|
983
1002
|
this.optimisticUpdates = createStore_forOptimistic(this.#client);
|
|
@@ -1349,6 +1368,94 @@ var UmbrellaStore = class {
|
|
|
1349
1368
|
return { signal, waitUntilLoaded: resource.waitUntilLoaded };
|
|
1350
1369
|
}
|
|
1351
1370
|
);
|
|
1371
|
+
const loadingAgentSessions = new DefaultMap(
|
|
1372
|
+
(queryKey) => {
|
|
1373
|
+
const [roomId, options] = JSON.parse(queryKey);
|
|
1374
|
+
const resource = new PaginatedResource(async (cursor) => {
|
|
1375
|
+
const room = this.#roomsByRoomId.get(roomId);
|
|
1376
|
+
if (!room) {
|
|
1377
|
+
throw new Error(
|
|
1378
|
+
`Room ${roomId} not found. Make sure you're calling useAgentSessions inside a RoomProvider.`
|
|
1379
|
+
);
|
|
1380
|
+
}
|
|
1381
|
+
const typedRoom = room;
|
|
1382
|
+
const result = await typedRoom.fetchAgentSessions({
|
|
1383
|
+
cursor,
|
|
1384
|
+
since: options?.since,
|
|
1385
|
+
metadata: options?.metadata
|
|
1386
|
+
});
|
|
1387
|
+
this.updateAgentSessions(roomId, result.sessions, "list");
|
|
1388
|
+
return result.nextCursor ?? null;
|
|
1389
|
+
});
|
|
1390
|
+
const signal = DerivedSignal.from(
|
|
1391
|
+
resource.signal,
|
|
1392
|
+
this.#agentSessionsSignal,
|
|
1393
|
+
(resourceResult, _signalState) => {
|
|
1394
|
+
if (resourceResult.isLoading || resourceResult.error) {
|
|
1395
|
+
return resourceResult;
|
|
1396
|
+
}
|
|
1397
|
+
const sessionsMap = this.#agentSessionsByRoomId.get(roomId);
|
|
1398
|
+
const sessions = sessionsMap ? Array.from(sessionsMap.values()) : [];
|
|
1399
|
+
const page = resourceResult.data;
|
|
1400
|
+
return {
|
|
1401
|
+
isLoading: false,
|
|
1402
|
+
sessions,
|
|
1403
|
+
hasFetchedAll: page.hasFetchedAll,
|
|
1404
|
+
isFetchingMore: page.isFetchingMore,
|
|
1405
|
+
fetchMoreError: page.fetchMoreError,
|
|
1406
|
+
fetchMore: page.fetchMore
|
|
1407
|
+
};
|
|
1408
|
+
},
|
|
1409
|
+
shallow2
|
|
1410
|
+
);
|
|
1411
|
+
return { signal, waitUntilLoaded: resource.waitUntilLoaded };
|
|
1412
|
+
}
|
|
1413
|
+
);
|
|
1414
|
+
const loadingAgentMessages = new DefaultMap(
|
|
1415
|
+
(queryKey) => {
|
|
1416
|
+
const [roomId, sessionId, options] = JSON.parse(queryKey);
|
|
1417
|
+
const resource = new PaginatedResource(async (cursor) => {
|
|
1418
|
+
const room = this.#roomsByRoomId.get(roomId);
|
|
1419
|
+
if (!room) {
|
|
1420
|
+
throw new Error(
|
|
1421
|
+
`Room ${roomId} not found. Make sure you're calling useAgentSession inside a RoomProvider.`
|
|
1422
|
+
);
|
|
1423
|
+
}
|
|
1424
|
+
const typedRoom = room;
|
|
1425
|
+
const result = await typedRoom.fetchAgentMessages(sessionId, {
|
|
1426
|
+
cursor,
|
|
1427
|
+
limit: options?.limit
|
|
1428
|
+
});
|
|
1429
|
+
this.updateAgentMessages(roomId, sessionId, result.messages, "list");
|
|
1430
|
+
return result.nextCursor ?? null;
|
|
1431
|
+
});
|
|
1432
|
+
const signal = DerivedSignal.from(
|
|
1433
|
+
resource.signal,
|
|
1434
|
+
this.#agentMessagesSignal,
|
|
1435
|
+
(resourceResult, _signalState) => {
|
|
1436
|
+
if (resourceResult.isLoading || resourceResult.error) {
|
|
1437
|
+
return resourceResult;
|
|
1438
|
+
}
|
|
1439
|
+
const messagesMap = this.#agentMessagesBySessionId.get(sessionId);
|
|
1440
|
+
const messages = messagesMap ? Array.from(messagesMap.values()).sort(
|
|
1441
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
1442
|
+
(a, b) => a.timestamp - b.timestamp
|
|
1443
|
+
) : [];
|
|
1444
|
+
const page = resourceResult.data;
|
|
1445
|
+
return {
|
|
1446
|
+
isLoading: false,
|
|
1447
|
+
messages,
|
|
1448
|
+
hasFetchedAll: page.hasFetchedAll,
|
|
1449
|
+
isFetchingMore: page.isFetchingMore,
|
|
1450
|
+
fetchMoreError: page.fetchMoreError,
|
|
1451
|
+
fetchMore: page.fetchMore
|
|
1452
|
+
};
|
|
1453
|
+
},
|
|
1454
|
+
shallow2
|
|
1455
|
+
);
|
|
1456
|
+
return { signal, waitUntilLoaded: resource.waitUntilLoaded };
|
|
1457
|
+
}
|
|
1458
|
+
);
|
|
1352
1459
|
this.outputs = {
|
|
1353
1460
|
threadifications,
|
|
1354
1461
|
threads,
|
|
@@ -1364,7 +1471,9 @@ var UmbrellaStore = class {
|
|
|
1364
1471
|
aiChats,
|
|
1365
1472
|
messagesByChatId,
|
|
1366
1473
|
aiChatById,
|
|
1367
|
-
urlMetadataByUrl
|
|
1474
|
+
urlMetadataByUrl,
|
|
1475
|
+
loadingAgentSessions,
|
|
1476
|
+
loadingAgentMessages
|
|
1368
1477
|
};
|
|
1369
1478
|
autobind(this);
|
|
1370
1479
|
}
|
|
@@ -1519,6 +1628,26 @@ var UmbrellaStore = class {
|
|
|
1519
1628
|
(thread) => applyUpsertComment(thread, editedComment)
|
|
1520
1629
|
);
|
|
1521
1630
|
}
|
|
1631
|
+
editCommentMetadata(threadId, commentId, optimisticId, updatedMetadata, updatedAt) {
|
|
1632
|
+
return this.#updateThread(
|
|
1633
|
+
threadId,
|
|
1634
|
+
optimisticId,
|
|
1635
|
+
(thread) => {
|
|
1636
|
+
const comment = thread.comments.find((c) => c.id === commentId);
|
|
1637
|
+
if (comment === void 0) {
|
|
1638
|
+
return thread;
|
|
1639
|
+
}
|
|
1640
|
+
return {
|
|
1641
|
+
...thread,
|
|
1642
|
+
updatedAt,
|
|
1643
|
+
comments: thread.comments.map(
|
|
1644
|
+
(c) => c.id === commentId ? { ...c, metadata: updatedMetadata } : c
|
|
1645
|
+
)
|
|
1646
|
+
};
|
|
1647
|
+
},
|
|
1648
|
+
updatedAt
|
|
1649
|
+
);
|
|
1650
|
+
}
|
|
1522
1651
|
deleteComment(threadId, optimisticId, commentId, deletedAt) {
|
|
1523
1652
|
return this.#updateThread(
|
|
1524
1653
|
threadId,
|
|
@@ -1565,6 +1694,61 @@ var UmbrellaStore = class {
|
|
|
1565
1694
|
result.subscriptions.deleted
|
|
1566
1695
|
);
|
|
1567
1696
|
}
|
|
1697
|
+
/**
|
|
1698
|
+
* Registers a room instance for agent session fetching.
|
|
1699
|
+
* Called by RoomProvider when it mounts.
|
|
1700
|
+
*/
|
|
1701
|
+
registerRoom(roomId, room) {
|
|
1702
|
+
this.#roomsByRoomId.set(roomId, room);
|
|
1703
|
+
}
|
|
1704
|
+
/**
|
|
1705
|
+
* Unregisters a room instance.
|
|
1706
|
+
* Called by RoomProvider when it unmounts.
|
|
1707
|
+
*/
|
|
1708
|
+
unregisterRoom(roomId) {
|
|
1709
|
+
this.#roomsByRoomId.delete(roomId);
|
|
1710
|
+
this.#agentSessionsByRoomId.delete(roomId);
|
|
1711
|
+
}
|
|
1712
|
+
/**
|
|
1713
|
+
* Updates the agent sessions cache based on WebSocket events.
|
|
1714
|
+
*/
|
|
1715
|
+
updateAgentSessions(roomId, sessions, operation) {
|
|
1716
|
+
let sessionsMap = this.#agentSessionsByRoomId.get(roomId);
|
|
1717
|
+
if (!sessionsMap) {
|
|
1718
|
+
sessionsMap = /* @__PURE__ */ new Map();
|
|
1719
|
+
this.#agentSessionsByRoomId.set(roomId, sessionsMap);
|
|
1720
|
+
}
|
|
1721
|
+
for (const session of sessions) {
|
|
1722
|
+
if (operation === "deleted") {
|
|
1723
|
+
sessionsMap.delete(session.sessionId);
|
|
1724
|
+
} else {
|
|
1725
|
+
sessionsMap.set(session.sessionId, session);
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
this.#agentSessionsSignal.mutate((state) => {
|
|
1729
|
+
state.version++;
|
|
1730
|
+
});
|
|
1731
|
+
}
|
|
1732
|
+
/**
|
|
1733
|
+
* Updates the agent messages cache based on WebSocket events.
|
|
1734
|
+
*/
|
|
1735
|
+
updateAgentMessages(_roomId, sessionId, messages, operation) {
|
|
1736
|
+
let messagesMap = this.#agentMessagesBySessionId.get(sessionId);
|
|
1737
|
+
if (!messagesMap) {
|
|
1738
|
+
messagesMap = /* @__PURE__ */ new Map();
|
|
1739
|
+
this.#agentMessagesBySessionId.set(sessionId, messagesMap);
|
|
1740
|
+
}
|
|
1741
|
+
for (const message of messages) {
|
|
1742
|
+
if (operation === "deleted") {
|
|
1743
|
+
messagesMap.delete(message.id);
|
|
1744
|
+
} else {
|
|
1745
|
+
messagesMap.set(message.id, message);
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
this.#agentMessagesSignal.mutate((state) => {
|
|
1749
|
+
state.version++;
|
|
1750
|
+
});
|
|
1751
|
+
}
|
|
1568
1752
|
async fetchUnreadNotificationsCount(queryKey, signal) {
|
|
1569
1753
|
const query = JSON.parse(queryKey);
|
|
1570
1754
|
const result = await this.#client.getUnreadInboxNotificationsCount({
|
|
@@ -1724,6 +1908,27 @@ function applyOptimisticUpdates_forThreadifications(baseThreadsDB, notifications
|
|
|
1724
1908
|
threadsDB.upsert(applyUpsertComment(thread, optimisticUpdate.comment));
|
|
1725
1909
|
break;
|
|
1726
1910
|
}
|
|
1911
|
+
case "edit-comment-metadata": {
|
|
1912
|
+
const thread = threadsDB.get(optimisticUpdate.threadId);
|
|
1913
|
+
if (thread === void 0) break;
|
|
1914
|
+
if (thread.updatedAt > optimisticUpdate.updatedAt) {
|
|
1915
|
+
break;
|
|
1916
|
+
}
|
|
1917
|
+
const existingComment = thread.comments.find(
|
|
1918
|
+
(c) => c.id === optimisticUpdate.commentId
|
|
1919
|
+
);
|
|
1920
|
+
if (existingComment === void 0) break;
|
|
1921
|
+
threadsDB.upsert(
|
|
1922
|
+
applyUpsertComment(thread, {
|
|
1923
|
+
...existingComment,
|
|
1924
|
+
metadata: {
|
|
1925
|
+
...existingComment.metadata,
|
|
1926
|
+
...optimisticUpdate.metadata
|
|
1927
|
+
}
|
|
1928
|
+
})
|
|
1929
|
+
);
|
|
1930
|
+
break;
|
|
1931
|
+
}
|
|
1727
1932
|
case "delete-comment": {
|
|
1728
1933
|
const thread = threadsDB.get(optimisticUpdate.threadId);
|
|
1729
1934
|
if (thread === void 0) break;
|
|
@@ -1930,7 +2135,20 @@ function applyUpsertComment(thread, comment) {
|
|
|
1930
2135
|
return updatedThread;
|
|
1931
2136
|
}
|
|
1932
2137
|
if (existingComment.deletedAt !== void 0) {
|
|
1933
|
-
|
|
2138
|
+
const updatedComment = {
|
|
2139
|
+
...existingComment,
|
|
2140
|
+
metadata: {
|
|
2141
|
+
...existingComment.metadata,
|
|
2142
|
+
...comment.metadata
|
|
2143
|
+
}
|
|
2144
|
+
};
|
|
2145
|
+
const updatedComments = thread.comments.map(
|
|
2146
|
+
(c) => c.id === comment.id ? updatedComment : c
|
|
2147
|
+
);
|
|
2148
|
+
return {
|
|
2149
|
+
...thread,
|
|
2150
|
+
comments: updatedComments
|
|
2151
|
+
};
|
|
1934
2152
|
}
|
|
1935
2153
|
if (existingComment.editedAt === void 0 || comment.editedAt === void 0 || existingComment.editedAt <= comment.editedAt) {
|
|
1936
2154
|
const updatedComments = thread.comments.map(
|
|
@@ -3521,9 +3739,13 @@ function makeRoomContextBundle(client) {
|
|
|
3521
3739
|
useOthersMapped,
|
|
3522
3740
|
useOthersConnectionIds,
|
|
3523
3741
|
useOther,
|
|
3742
|
+
// prettier-ignore
|
|
3524
3743
|
useMutation,
|
|
3525
3744
|
useThreads,
|
|
3745
|
+
useAgentSessions,
|
|
3746
|
+
useAgentSession,
|
|
3526
3747
|
useSearchComments,
|
|
3748
|
+
// prettier-ignore
|
|
3527
3749
|
useCreateThread,
|
|
3528
3750
|
useDeleteThread,
|
|
3529
3751
|
useEditThreadMetadata,
|
|
@@ -3533,6 +3755,7 @@ function makeRoomContextBundle(client) {
|
|
|
3533
3755
|
useUnsubscribeFromThread,
|
|
3534
3756
|
useCreateComment,
|
|
3535
3757
|
useEditComment,
|
|
3758
|
+
useEditCommentMetadata,
|
|
3536
3759
|
useDeleteComment,
|
|
3537
3760
|
useAddReaction,
|
|
3538
3761
|
useRemoveReaction,
|
|
@@ -3567,8 +3790,12 @@ function makeRoomContextBundle(client) {
|
|
|
3567
3790
|
useOthersMapped: useOthersMappedSuspense,
|
|
3568
3791
|
useOthersConnectionIds: useOthersConnectionIdsSuspense,
|
|
3569
3792
|
useOther: useOtherSuspense,
|
|
3793
|
+
// prettier-ignore
|
|
3570
3794
|
useMutation,
|
|
3571
3795
|
useThreads: useThreadsSuspense,
|
|
3796
|
+
useAgentSessions: useAgentSessionsSuspense,
|
|
3797
|
+
useAgentSession: useAgentSessionSuspense,
|
|
3798
|
+
// prettier-ignore
|
|
3572
3799
|
useCreateThread,
|
|
3573
3800
|
useDeleteThread,
|
|
3574
3801
|
useEditThreadMetadata,
|
|
@@ -3578,6 +3805,7 @@ function makeRoomContextBundle(client) {
|
|
|
3578
3805
|
useUnsubscribeFromThread,
|
|
3579
3806
|
useCreateComment,
|
|
3580
3807
|
useEditComment,
|
|
3808
|
+
useEditCommentMetadata,
|
|
3581
3809
|
useDeleteComment,
|
|
3582
3810
|
useAddReaction,
|
|
3583
3811
|
useRemoveReaction,
|
|
@@ -3683,6 +3911,7 @@ function RoomProviderInner(props) {
|
|
|
3683
3911
|
case ServerMsgCode.COMMENT_REACTION_ADDED:
|
|
3684
3912
|
case ServerMsgCode.COMMENT_REACTION_REMOVED:
|
|
3685
3913
|
case ServerMsgCode.COMMENT_DELETED:
|
|
3914
|
+
case ServerMsgCode.COMMENT_METADATA_UPDATED:
|
|
3686
3915
|
if (!existingThread) break;
|
|
3687
3916
|
store.updateThreadifications(
|
|
3688
3917
|
[thread],
|
|
@@ -3705,6 +3934,41 @@ function RoomProviderInner(props) {
|
|
|
3705
3934
|
(message) => void handleCommentEvent(message)
|
|
3706
3935
|
);
|
|
3707
3936
|
}, [client, room]);
|
|
3937
|
+
useEffect6(() => {
|
|
3938
|
+
const { store } = getRoomExtrasForClient(client);
|
|
3939
|
+
function handleAgentSessionEvent(message) {
|
|
3940
|
+
if (message.type === ServerMsgCode.AGENT_SESSIONS) {
|
|
3941
|
+
const agentSessionsMsg = message;
|
|
3942
|
+
if (agentSessionsMsg.operation !== "list") {
|
|
3943
|
+
store.updateAgentSessions(
|
|
3944
|
+
room.id,
|
|
3945
|
+
agentSessionsMsg.sessions,
|
|
3946
|
+
agentSessionsMsg.operation
|
|
3947
|
+
);
|
|
3948
|
+
}
|
|
3949
|
+
} else if (message.type === ServerMsgCode.AGENT_MESSAGES) {
|
|
3950
|
+
const agentMessagesMsg = message;
|
|
3951
|
+
if (agentMessagesMsg.operation !== "list") {
|
|
3952
|
+
store.updateAgentMessages(
|
|
3953
|
+
room.id,
|
|
3954
|
+
agentMessagesMsg.sessionId,
|
|
3955
|
+
agentMessagesMsg.messages,
|
|
3956
|
+
agentMessagesMsg.operation
|
|
3957
|
+
);
|
|
3958
|
+
}
|
|
3959
|
+
}
|
|
3960
|
+
}
|
|
3961
|
+
return room.events.agentSessions.subscribe(
|
|
3962
|
+
(message) => void handleAgentSessionEvent(message)
|
|
3963
|
+
);
|
|
3964
|
+
}, [client, room]);
|
|
3965
|
+
useEffect6(() => {
|
|
3966
|
+
const { store } = getRoomExtrasForClient(client);
|
|
3967
|
+
store.registerRoom(room.id, room);
|
|
3968
|
+
return () => {
|
|
3969
|
+
store.unregisterRoom(room.id);
|
|
3970
|
+
};
|
|
3971
|
+
}, [client, room]);
|
|
3708
3972
|
useEffect6(() => {
|
|
3709
3973
|
const pair = stableEnterRoom(roomId, frozenProps);
|
|
3710
3974
|
setRoomLeavePair(pair);
|
|
@@ -4030,6 +4294,53 @@ function useThreads(options = {}) {
|
|
|
4030
4294
|
useScrollToCommentOnLoadEffect(scrollOnLoad, result);
|
|
4031
4295
|
return result;
|
|
4032
4296
|
}
|
|
4297
|
+
function useAgentSessions(options) {
|
|
4298
|
+
const room = useRoom();
|
|
4299
|
+
const client = useClient();
|
|
4300
|
+
const { store } = getRoomExtrasForClient(client);
|
|
4301
|
+
const queryKey = makeAgentSessionsQueryKey(room.id, options);
|
|
4302
|
+
const loadableResource = store.outputs.loadingAgentSessions.getOrCreate(queryKey);
|
|
4303
|
+
useEffect6(() => {
|
|
4304
|
+
void loadableResource.waitUntilLoaded();
|
|
4305
|
+
});
|
|
4306
|
+
return useSignal(loadableResource.signal);
|
|
4307
|
+
}
|
|
4308
|
+
function useAgentSession(sessionId, options) {
|
|
4309
|
+
const room = useRoom();
|
|
4310
|
+
const client = useClient();
|
|
4311
|
+
const { store } = getRoomExtrasForClient(client);
|
|
4312
|
+
const queryKey = makeAgentMessagesQueryKey(room.id, sessionId, options);
|
|
4313
|
+
useEffect6(() => {
|
|
4314
|
+
void store.outputs.loadingAgentMessages.getOrCreate(queryKey).waitUntilLoaded();
|
|
4315
|
+
});
|
|
4316
|
+
return useSignal(
|
|
4317
|
+
store.outputs.loadingAgentMessages.getOrCreate(queryKey).signal
|
|
4318
|
+
);
|
|
4319
|
+
}
|
|
4320
|
+
function useAgentSessionsSuspense(options) {
|
|
4321
|
+
ensureNotServerSide();
|
|
4322
|
+
const client = useClient();
|
|
4323
|
+
const room = useRoom();
|
|
4324
|
+
const { store } = getRoomExtrasForClient(client);
|
|
4325
|
+
const queryKey = makeAgentSessionsQueryKey(room.id, options);
|
|
4326
|
+
use(store.outputs.loadingAgentSessions.getOrCreate(queryKey).waitUntilLoaded());
|
|
4327
|
+
const result = useAgentSessions(options);
|
|
4328
|
+
assert2(!result.error, "Did not expect error");
|
|
4329
|
+
assert2(!result.isLoading, "Did not expect loading");
|
|
4330
|
+
return result;
|
|
4331
|
+
}
|
|
4332
|
+
function useAgentSessionSuspense(sessionId, options) {
|
|
4333
|
+
ensureNotServerSide();
|
|
4334
|
+
const client = useClient();
|
|
4335
|
+
const room = useRoom();
|
|
4336
|
+
const { store } = getRoomExtrasForClient(client);
|
|
4337
|
+
const queryKey = makeAgentMessagesQueryKey(room.id, sessionId, options);
|
|
4338
|
+
use(store.outputs.loadingAgentMessages.getOrCreate(queryKey).waitUntilLoaded());
|
|
4339
|
+
const result = useAgentSession(sessionId, options);
|
|
4340
|
+
assert2(!result.error, "Did not expect error");
|
|
4341
|
+
assert2(!result.isLoading, "Did not expect loading");
|
|
4342
|
+
return result;
|
|
4343
|
+
}
|
|
4033
4344
|
function useSearchComments(options) {
|
|
4034
4345
|
const [result, setResult] = useState3({
|
|
4035
4346
|
isLoading: true
|
|
@@ -4090,6 +4401,7 @@ function useCreateRoomThread(roomId) {
|
|
|
4090
4401
|
(options) => {
|
|
4091
4402
|
const body = options.body;
|
|
4092
4403
|
const metadata = options.metadata ?? {};
|
|
4404
|
+
const commentMetadata = options.commentMetadata ?? {};
|
|
4093
4405
|
const attachments = options.attachments;
|
|
4094
4406
|
const threadId = createThreadId();
|
|
4095
4407
|
const commentId = createCommentId();
|
|
@@ -4103,7 +4415,8 @@ function useCreateRoomThread(roomId) {
|
|
|
4103
4415
|
userId: getCurrentUserId(client),
|
|
4104
4416
|
body,
|
|
4105
4417
|
reactions: [],
|
|
4106
|
-
attachments: attachments ?? []
|
|
4418
|
+
attachments: attachments ?? [],
|
|
4419
|
+
metadata: commentMetadata
|
|
4107
4420
|
};
|
|
4108
4421
|
const newThread = {
|
|
4109
4422
|
id: threadId,
|
|
@@ -4128,6 +4441,7 @@ function useCreateRoomThread(roomId) {
|
|
|
4128
4441
|
commentId,
|
|
4129
4442
|
body,
|
|
4130
4443
|
metadata,
|
|
4444
|
+
commentMetadata,
|
|
4131
4445
|
attachmentIds
|
|
4132
4446
|
}).then(
|
|
4133
4447
|
(thread) => {
|
|
@@ -4141,7 +4455,8 @@ function useCreateRoomThread(roomId) {
|
|
|
4141
4455
|
threadId,
|
|
4142
4456
|
commentId,
|
|
4143
4457
|
body,
|
|
4144
|
-
metadata
|
|
4458
|
+
metadata,
|
|
4459
|
+
commentMetadata
|
|
4145
4460
|
},
|
|
4146
4461
|
err
|
|
4147
4462
|
)
|
|
@@ -4224,13 +4539,65 @@ function useEditRoomThreadMetadata(roomId) {
|
|
|
4224
4539
|
[client, roomId]
|
|
4225
4540
|
);
|
|
4226
4541
|
}
|
|
4542
|
+
function useEditCommentMetadata() {
|
|
4543
|
+
return useEditRoomCommentMetadata(useRoom().id);
|
|
4544
|
+
}
|
|
4545
|
+
function useEditRoomCommentMetadata(roomId) {
|
|
4546
|
+
const client = useClient();
|
|
4547
|
+
return useCallback3(
|
|
4548
|
+
(options) => {
|
|
4549
|
+
if (!options.metadata) {
|
|
4550
|
+
return;
|
|
4551
|
+
}
|
|
4552
|
+
const threadId = options.threadId;
|
|
4553
|
+
const commentId = options.commentId;
|
|
4554
|
+
const metadata = options.metadata;
|
|
4555
|
+
const updatedAt = /* @__PURE__ */ new Date();
|
|
4556
|
+
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
4557
|
+
const optimisticId = store.optimisticUpdates.add({
|
|
4558
|
+
type: "edit-comment-metadata",
|
|
4559
|
+
threadId,
|
|
4560
|
+
commentId,
|
|
4561
|
+
metadata,
|
|
4562
|
+
updatedAt
|
|
4563
|
+
});
|
|
4564
|
+
client[kInternal4].httpClient.editCommentMetadata({ roomId, threadId, commentId, metadata }).then(
|
|
4565
|
+
(updatedMetadata) => (
|
|
4566
|
+
// Replace the optimistic update by the real thing
|
|
4567
|
+
store.editCommentMetadata(
|
|
4568
|
+
threadId,
|
|
4569
|
+
commentId,
|
|
4570
|
+
optimisticId,
|
|
4571
|
+
updatedMetadata,
|
|
4572
|
+
updatedAt
|
|
4573
|
+
)
|
|
4574
|
+
),
|
|
4575
|
+
(err) => onMutationFailure(
|
|
4576
|
+
optimisticId,
|
|
4577
|
+
{
|
|
4578
|
+
type: "EDIT_COMMENT_METADATA_ERROR",
|
|
4579
|
+
roomId,
|
|
4580
|
+
threadId,
|
|
4581
|
+
commentId,
|
|
4582
|
+
metadata
|
|
4583
|
+
},
|
|
4584
|
+
err
|
|
4585
|
+
)
|
|
4586
|
+
);
|
|
4587
|
+
},
|
|
4588
|
+
[client, roomId]
|
|
4589
|
+
);
|
|
4590
|
+
}
|
|
4227
4591
|
function useCreateComment() {
|
|
4228
4592
|
return useCreateRoomComment(useRoom().id);
|
|
4229
4593
|
}
|
|
4230
4594
|
function useCreateRoomComment(roomId) {
|
|
4231
4595
|
const client = useClient();
|
|
4232
4596
|
return useCallback3(
|
|
4233
|
-
(
|
|
4597
|
+
(options) => {
|
|
4598
|
+
const { threadId, body } = options;
|
|
4599
|
+
const metadata = options.metadata ?? {};
|
|
4600
|
+
const attachments = options.attachments ?? [];
|
|
4234
4601
|
const commentId = createCommentId();
|
|
4235
4602
|
const createdAt = /* @__PURE__ */ new Date();
|
|
4236
4603
|
const comment = {
|
|
@@ -4242,7 +4609,8 @@ function useCreateRoomComment(roomId) {
|
|
|
4242
4609
|
userId: getCurrentUserId(client),
|
|
4243
4610
|
body,
|
|
4244
4611
|
reactions: [],
|
|
4245
|
-
attachments: attachments ?? []
|
|
4612
|
+
attachments: attachments ?? [],
|
|
4613
|
+
metadata
|
|
4246
4614
|
};
|
|
4247
4615
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
4248
4616
|
const optimisticId = store.optimisticUpdates.add({
|
|
@@ -4250,7 +4618,14 @@ function useCreateRoomComment(roomId) {
|
|
|
4250
4618
|
comment
|
|
4251
4619
|
});
|
|
4252
4620
|
const attachmentIds = attachments?.map((attachment) => attachment.id);
|
|
4253
|
-
client[kInternal4].httpClient.createComment({
|
|
4621
|
+
client[kInternal4].httpClient.createComment({
|
|
4622
|
+
roomId,
|
|
4623
|
+
threadId,
|
|
4624
|
+
commentId,
|
|
4625
|
+
body,
|
|
4626
|
+
metadata,
|
|
4627
|
+
attachmentIds
|
|
4628
|
+
}).then(
|
|
4254
4629
|
(newComment) => {
|
|
4255
4630
|
store.createComment(newComment, optimisticId);
|
|
4256
4631
|
},
|
|
@@ -4261,7 +4636,8 @@ function useCreateRoomComment(roomId) {
|
|
|
4261
4636
|
roomId,
|
|
4262
4637
|
threadId,
|
|
4263
4638
|
commentId,
|
|
4264
|
-
body
|
|
4639
|
+
body,
|
|
4640
|
+
metadata
|
|
4265
4641
|
},
|
|
4266
4642
|
err
|
|
4267
4643
|
)
|
|
@@ -4277,7 +4653,13 @@ function useEditComment() {
|
|
|
4277
4653
|
function useEditRoomComment(roomId) {
|
|
4278
4654
|
const client = useClient();
|
|
4279
4655
|
return useCallback3(
|
|
4280
|
-
({
|
|
4656
|
+
({
|
|
4657
|
+
threadId,
|
|
4658
|
+
commentId,
|
|
4659
|
+
body,
|
|
4660
|
+
attachments,
|
|
4661
|
+
metadata
|
|
4662
|
+
}) => {
|
|
4281
4663
|
const editedAt = /* @__PURE__ */ new Date();
|
|
4282
4664
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
4283
4665
|
const existing = store.outputs.threads.get().getEvenIfDeleted(threadId);
|
|
@@ -4296,23 +4678,42 @@ function useEditRoomComment(roomId) {
|
|
|
4296
4678
|
);
|
|
4297
4679
|
return;
|
|
4298
4680
|
}
|
|
4681
|
+
const updatedMetadata = metadata !== void 0 ? {
|
|
4682
|
+
...comment.metadata,
|
|
4683
|
+
...metadata
|
|
4684
|
+
} : comment.metadata;
|
|
4299
4685
|
const optimisticId = store.optimisticUpdates.add({
|
|
4300
4686
|
type: "edit-comment",
|
|
4301
4687
|
comment: {
|
|
4302
4688
|
...comment,
|
|
4303
4689
|
editedAt,
|
|
4304
4690
|
body,
|
|
4305
|
-
attachments: attachments ?? []
|
|
4691
|
+
attachments: attachments ?? [],
|
|
4692
|
+
metadata: updatedMetadata
|
|
4306
4693
|
}
|
|
4307
4694
|
});
|
|
4308
4695
|
const attachmentIds = attachments?.map((attachment) => attachment.id);
|
|
4309
|
-
client[kInternal4].httpClient.editComment({
|
|
4696
|
+
client[kInternal4].httpClient.editComment({
|
|
4697
|
+
roomId,
|
|
4698
|
+
threadId,
|
|
4699
|
+
commentId,
|
|
4700
|
+
body,
|
|
4701
|
+
attachmentIds,
|
|
4702
|
+
metadata
|
|
4703
|
+
}).then(
|
|
4310
4704
|
(editedComment) => {
|
|
4311
4705
|
store.editComment(threadId, optimisticId, editedComment);
|
|
4312
4706
|
},
|
|
4313
4707
|
(err) => onMutationFailure(
|
|
4314
4708
|
optimisticId,
|
|
4315
|
-
{
|
|
4709
|
+
{
|
|
4710
|
+
type: "EDIT_COMMENT_ERROR",
|
|
4711
|
+
roomId,
|
|
4712
|
+
threadId,
|
|
4713
|
+
commentId,
|
|
4714
|
+
body,
|
|
4715
|
+
metadata: updatedMetadata
|
|
4716
|
+
},
|
|
4316
4717
|
err
|
|
4317
4718
|
)
|
|
4318
4719
|
);
|
|
@@ -4937,11 +5338,16 @@ var _useMutation = useMutation;
|
|
|
4937
5338
|
var _useCreateThread = useCreateThread;
|
|
4938
5339
|
var _useDeleteThread = useDeleteThread;
|
|
4939
5340
|
var _useEditThreadMetadata = useEditThreadMetadata;
|
|
5341
|
+
var _useCreateComment = useCreateComment;
|
|
5342
|
+
var _useEditComment = useEditComment;
|
|
5343
|
+
var _useEditCommentMetadata = useEditCommentMetadata;
|
|
4940
5344
|
var _useEventListener = useEventListener;
|
|
4941
5345
|
var _useMyPresence = useMyPresence;
|
|
4942
5346
|
var _useOthersMapped = useOthersMapped;
|
|
4943
5347
|
var _useOthersMappedSuspense = useOthersMappedSuspense;
|
|
4944
5348
|
var _useThreads = useThreads;
|
|
5349
|
+
var _useAgentSessions = useAgentSessions;
|
|
5350
|
+
var _useAgentSession = useAgentSession;
|
|
4945
5351
|
var _useSearchComments = useSearchComments;
|
|
4946
5352
|
var _useThreadsSuspense = useThreadsSuspense;
|
|
4947
5353
|
var _useRoomSubscriptionSettings = useRoomSubscriptionSettings;
|
|
@@ -5031,9 +5437,7 @@ export {
|
|
|
5031
5437
|
useCreateRoomThread,
|
|
5032
5438
|
useDeleteRoomThread,
|
|
5033
5439
|
useEditRoomThreadMetadata,
|
|
5034
|
-
useCreateComment,
|
|
5035
5440
|
useCreateRoomComment,
|
|
5036
|
-
useEditComment,
|
|
5037
5441
|
useEditRoomComment,
|
|
5038
5442
|
useDeleteComment,
|
|
5039
5443
|
useDeleteRoomComment,
|
|
@@ -5068,11 +5472,16 @@ export {
|
|
|
5068
5472
|
_useCreateThread,
|
|
5069
5473
|
_useDeleteThread,
|
|
5070
5474
|
_useEditThreadMetadata,
|
|
5475
|
+
_useCreateComment,
|
|
5476
|
+
_useEditComment,
|
|
5477
|
+
_useEditCommentMetadata,
|
|
5071
5478
|
_useEventListener,
|
|
5072
5479
|
_useMyPresence,
|
|
5073
5480
|
_useOthersMapped,
|
|
5074
5481
|
_useOthersMappedSuspense,
|
|
5075
5482
|
_useThreads,
|
|
5483
|
+
_useAgentSessions,
|
|
5484
|
+
_useAgentSession,
|
|
5076
5485
|
_useSearchComments,
|
|
5077
5486
|
_useThreadsSuspense,
|
|
5078
5487
|
_useRoomSubscriptionSettings,
|
|
@@ -5090,4 +5499,4 @@ export {
|
|
|
5090
5499
|
_useStorageRoot,
|
|
5091
5500
|
_useUpdateMyPresence
|
|
5092
5501
|
};
|
|
5093
|
-
//# sourceMappingURL=chunk-
|
|
5502
|
+
//# sourceMappingURL=chunk-VSUKKNOK.js.map
|