@adminide-stack/yantra-mobile 12.0.53-alpha.1 → 12.0.53-alpha.12
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/lib/components/KeyboardComposerDock.js +55 -12
- package/lib/components/KeyboardComposerDock.js.map +1 -1
- package/lib/components/NavigationHeader/NavigationHeader.js +3 -1
- package/lib/components/NavigationHeader/NavigationHeader.js.map +1 -1
- package/lib/features/apps/AppsCatalog.js +1 -1
- package/lib/features/apps/AppsCatalog.js.map +1 -1
- package/lib/features/attachments/ComposerAttachMenu.js +189 -0
- package/lib/features/attachments/ComposerAttachMenu.js.map +1 -0
- package/lib/features/attachments/useImageAttachments.js +23 -15
- package/lib/features/attachments/useImageAttachments.js.map +1 -1
- package/lib/features/canvas/canvasBoardsSnapshot.js +45 -0
- package/lib/features/canvas/canvasBoardsSnapshot.js.map +1 -0
- package/lib/features/canvas/nativeViewerRegistry.js +9 -1
- package/lib/features/canvas/nativeViewerRegistry.js.map +1 -1
- package/lib/features/chat/ChatTranscript.js +7 -0
- package/lib/features/chat/ChatTranscript.js.map +1 -1
- package/lib/features/chat/chatHistorySnapshot.js +103 -0
- package/lib/features/chat/chatHistorySnapshot.js.map +1 -0
- package/lib/graphql/typePolicies.js +139 -0
- package/lib/graphql/typePolicies.js.map +1 -0
- package/lib/hooks/useCdecliChannel.js +63 -7
- package/lib/hooks/useCdecliChannel.js.map +1 -1
- package/lib/hooks/useChatApi.js +232 -26
- package/lib/hooks/useChatApi.js.map +1 -1
- package/lib/hooks/useChatStream.js +105 -36
- package/lib/hooks/useChatStream.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/module.js +5 -2
- package/lib/module.js.map +1 -1
- package/lib/screens/CanvasBoard/index.js +1 -1
- package/lib/screens/CanvasBoard/index.js.map +1 -1
- package/lib/screens/Chat/index.js +8 -38
- package/lib/screens/Chat/index.js.map +1 -1
- package/lib/screens/Home/HomeScreen.js +18 -31
- package/lib/screens/Home/HomeScreen.js.map +1 -1
- package/lib/screens/Home/components/CanvasPrewarm.js +3 -2
- package/lib/screens/Home/components/CanvasPrewarm.js.map +1 -1
- package/lib/screens/Home/components/ChatHistoryLanding.js +60 -12
- package/lib/screens/Home/components/ChatHistoryLanding.js.map +1 -1
- package/lib/state/chatThreadMerge.js +76 -2
- package/lib/state/chatThreadMerge.js.map +1 -1
- package/package.json +4 -4
package/lib/hooks/useChatApi.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {useApolloClient}from'@apollo/client/index.js';import {SortEnum,RoomType,PostTypeEnum,AiAgentMessageRole}from'common';import {useGetChannelsByUserWithLastMessageQuery,useMessagesQuery,useAddChannelMutation,useSendMessagesMutation,MessagesDocument,GetChannelsByUserWithLastMessageDocument}from'common/graphql';import {useMemo,useCallback}from'react';import {v4}from'uuid';import {isAttachedCaption,historyAttachmentTitle,attachmentsFromUserContent}from'../features/attachments/historyAttachmentLabel.js';var __defProp = Object.defineProperty;
|
|
1
|
+
import {useApolloClient}from'@apollo/client/index.js';import {SortEnum,RoomType,PostTypeEnum,AiAgentMessageRole}from'common';import {useGetChannelsByUserWithLastMessageQuery,useMessagesQuery,useAddChannelMutation,useSendMessagesMutation,OnChatMessageAddedDocument,MessagesDocument,GetChannelsByUserWithLastMessageDocument}from'common/graphql';import {useMemo,useCallback,useEffect}from'react';import {v4}from'uuid';import {isAttachedCaption,historyAttachmentTitle,attachmentsFromUserContent}from'../features/attachments/historyAttachmentLabel.js';import {stripAskUser}from'../features/chat/askUser.js';import {parseToolActivity}from'../features/chat/toolActivity.js';var __defProp = Object.defineProperty;
|
|
2
2
|
var __defProps = Object.defineProperties;
|
|
3
3
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -81,11 +81,7 @@ function getThreadMessagesQueryVariables(sessionId) {
|
|
|
81
81
|
return {
|
|
82
82
|
channelId: sessionId,
|
|
83
83
|
limit: MESSAGES_PAGE_LIMIT,
|
|
84
|
-
skip: 0
|
|
85
|
-
sort: {
|
|
86
|
-
key: "createdAt",
|
|
87
|
-
value: SortEnum.Asc
|
|
88
|
-
}
|
|
84
|
+
skip: 0
|
|
89
85
|
};
|
|
90
86
|
}
|
|
91
87
|
function getChatHistoryMessagesQueryVariables(accountUserId, options) {
|
|
@@ -148,6 +144,7 @@ function useChatHistorySessionsFromMessages(accountUserId, options) {
|
|
|
148
144
|
// Later visits read the cache — no repeated network hit.
|
|
149
145
|
fetchPolicy: "cache-first",
|
|
150
146
|
nextFetchPolicy: "cache-first",
|
|
147
|
+
returnPartialData: true,
|
|
151
148
|
context: {
|
|
152
149
|
cacheKey: "new-chat-history-messages"
|
|
153
150
|
}
|
|
@@ -214,7 +211,7 @@ function cleanMessageText(raw) {
|
|
|
214
211
|
return raw.replace(ACTIVE_CONNECTORS_PREFIX_RE, "").replace(/\s+/g, " ").trim();
|
|
215
212
|
}
|
|
216
213
|
function isTransientHistoryText(text) {
|
|
217
|
-
const t = cleanMessageText(text);
|
|
214
|
+
const t = cleanHistoryPreview(text) || cleanMessageText(text);
|
|
218
215
|
if (!t) return true;
|
|
219
216
|
if (/^thinking[.…]*$/i.test(t)) return true;
|
|
220
217
|
if (/^let me check on that requested skill/i.test(t)) return true;
|
|
@@ -231,10 +228,14 @@ function looksLikeAssistantReply(text, role) {
|
|
|
231
228
|
return false;
|
|
232
229
|
}
|
|
233
230
|
function cleanHistoryPreview(raw) {
|
|
234
|
-
|
|
231
|
+
const withoutAsk = stripAskUser(raw);
|
|
232
|
+
const {
|
|
233
|
+
text: withoutTools
|
|
234
|
+
} = parseToolActivity(withoutAsk, false);
|
|
235
|
+
let t = cleanMessageText(withoutTools);
|
|
235
236
|
t = t.replace(/^(thinking[.…]*\s*)+/i, "").trim();
|
|
236
237
|
t = t.replace(/^let me check on that requested skill[^\n.!?]*[.!?-]?\s*/i, "").trim();
|
|
237
|
-
t = t.replace(/^(
|
|
238
|
+
t = t.replace(/^(?:[⚙🔧⚙️⚠][^\n]*\n)+\s*/gu, "").trim();
|
|
238
239
|
return t;
|
|
239
240
|
}
|
|
240
241
|
function buildSessionFromChannel(channel) {
|
|
@@ -297,26 +298,151 @@ function chatHistorySessionsFromChannels(data) {
|
|
|
297
298
|
return channels.filter((c) => Boolean(c == null ? void 0 : c.id) && (!(c == null ? void 0 : c.type) || c.type === RoomType.Aiassistant)).map((c) => buildSessionFromChannel(c)).filter((row) => row !== null).sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime());
|
|
298
299
|
}
|
|
299
300
|
const rememberedHistoryTitles = /* @__PURE__ */ new Map();
|
|
301
|
+
const rememberedHistoryListeners = /* @__PURE__ */ new Set();
|
|
302
|
+
function subscribeRememberedHistory(listener) {
|
|
303
|
+
rememberedHistoryListeners.add(listener);
|
|
304
|
+
return () => {
|
|
305
|
+
rememberedHistoryListeners.delete(listener);
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
function mergeRememberedHistory(channelId, patch, notify = true) {
|
|
309
|
+
var _a, _b;
|
|
310
|
+
const existing = (_a = rememberedHistoryTitles.get(channelId)) != null ? _a : {};
|
|
311
|
+
const next = {
|
|
312
|
+
title: patch.title || existing.title,
|
|
313
|
+
preview: patch.preview || existing.preview,
|
|
314
|
+
isAttachment: (_b = patch.isAttachment) != null ? _b : existing.isAttachment,
|
|
315
|
+
running: patch.running !== void 0 ? patch.running : existing.running
|
|
316
|
+
};
|
|
317
|
+
rememberedHistoryTitles.set(channelId, next);
|
|
318
|
+
if (notify && (next.title !== existing.title || next.preview !== existing.preview || next.running !== existing.running)) {
|
|
319
|
+
rememberedHistoryListeners.forEach((fn) => fn());
|
|
320
|
+
}
|
|
321
|
+
return next;
|
|
322
|
+
}
|
|
300
323
|
function rememberHistoryTitle(session) {
|
|
301
|
-
var _a;
|
|
302
|
-
|
|
303
|
-
const title = (_a = session.title) == null ? void 0 : _a.trim();
|
|
304
|
-
if (
|
|
305
|
-
|
|
306
|
-
|
|
324
|
+
var _a, _b;
|
|
325
|
+
const existing = rememberedHistoryTitles.get(session.channelId);
|
|
326
|
+
const title = session.isPlaceholder || /^new chat$/i.test(session.title) ? "" : (_a = session.title) == null ? void 0 : _a.trim();
|
|
327
|
+
if (existing == null ? void 0 : existing.running) {
|
|
328
|
+
if (title && !isTransientHistoryText(title)) {
|
|
329
|
+
mergeRememberedHistory(session.channelId, {
|
|
330
|
+
title
|
|
331
|
+
}, false);
|
|
332
|
+
}
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
const preview = ((_b = session.preview) == null ? void 0 : _b.trim()) && !isTransientHistoryText(session.preview) ? session.preview.trim() : "";
|
|
336
|
+
if (title && isTransientHistoryText(title) && !preview) return;
|
|
337
|
+
if (!title && !preview) return;
|
|
338
|
+
mergeRememberedHistory(session.channelId, __spreadProps(__spreadValues(__spreadValues({}, title && !isTransientHistoryText(title) ? {
|
|
339
|
+
title
|
|
340
|
+
} : {}), preview ? {
|
|
341
|
+
preview
|
|
342
|
+
} : {}), {
|
|
307
343
|
isAttachment: session.isAttachment
|
|
344
|
+
}), false);
|
|
345
|
+
}
|
|
346
|
+
function deriveHistoryTitleFromPrompt(rawPrompt) {
|
|
347
|
+
const cleaned = cleanMessageText(rawPrompt);
|
|
348
|
+
if (!cleaned || isTransientHistoryText(cleaned) || /^new chat$/i.test(cleaned)) return "";
|
|
349
|
+
if (cleaned.length <= 64) return cleaned;
|
|
350
|
+
return `${cleaned.slice(0, 64).trim()}...`;
|
|
351
|
+
}
|
|
352
|
+
function patchChannelHistoryTitle(client, channelId, rawPrompt) {
|
|
353
|
+
const cleaned = deriveHistoryTitleFromPrompt(rawPrompt);
|
|
354
|
+
if (!channelId || !cleaned) return;
|
|
355
|
+
mergeRememberedHistory(channelId, {
|
|
356
|
+
title: cleaned,
|
|
357
|
+
isAttachment: isAttachedCaption(cleaned)
|
|
358
|
+
});
|
|
359
|
+
const channelCacheId = client.cache.identify({
|
|
360
|
+
__typename: "Channel",
|
|
361
|
+
id: channelId
|
|
362
|
+
});
|
|
363
|
+
if (!channelCacheId) return;
|
|
364
|
+
try {
|
|
365
|
+
client.cache.modify({
|
|
366
|
+
id: channelCacheId,
|
|
367
|
+
fields: {
|
|
368
|
+
title(existing) {
|
|
369
|
+
return cleanChannelTitle(existing) ? existing : cleaned;
|
|
370
|
+
}
|
|
371
|
+
// Do not touch updatedAt here. Bumping it on open/hydrate moves the
|
|
372
|
+
// row to TODAY / "now". Activity time is only written when the user
|
|
373
|
+
// actually sends (touchChannelHistoryUpdatedAt).
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
} catch (err) {
|
|
377
|
+
console.warn("[useChatApi] patchChannelHistoryTitle failed:", err);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
function touchChannelHistoryUpdatedAt(client, channelId) {
|
|
381
|
+
if (!channelId) return;
|
|
382
|
+
const channelCacheId = client.cache.identify({
|
|
383
|
+
__typename: "Channel",
|
|
384
|
+
id: channelId
|
|
385
|
+
});
|
|
386
|
+
if (!channelCacheId) return;
|
|
387
|
+
try {
|
|
388
|
+
client.cache.modify({
|
|
389
|
+
id: channelCacheId,
|
|
390
|
+
fields: {
|
|
391
|
+
updatedAt() {
|
|
392
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
} catch (err) {
|
|
397
|
+
console.warn("[useChatApi] touchChannelHistoryUpdatedAt failed:", err);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
function patchChannelHistoryPreview(channelId, rawPreview) {
|
|
401
|
+
var _a, _b;
|
|
402
|
+
if (!channelId) return;
|
|
403
|
+
const preview = cleanHistoryPreview(rawPreview);
|
|
404
|
+
if (!preview || isTransientHistoryText(preview) || isAttachedCaption(preview)) return;
|
|
405
|
+
const title = (_b = (_a = rememberedHistoryTitles.get(channelId)) == null ? void 0 : _a.title) != null ? _b : "";
|
|
406
|
+
if (title && preview === title) return;
|
|
407
|
+
mergeRememberedHistory(channelId, {
|
|
408
|
+
preview
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
function markChannelHistoryRunning(channelId, rawPreview) {
|
|
412
|
+
if (!channelId) return;
|
|
413
|
+
const preview = rawPreview ? cleanHistoryPreview(rawPreview) : "";
|
|
414
|
+
const usable = preview && !isTransientHistoryText(preview) && !isAttachedCaption(preview) ? preview : void 0;
|
|
415
|
+
mergeRememberedHistory(channelId, __spreadValues({
|
|
416
|
+
running: true
|
|
417
|
+
}, usable ? {
|
|
418
|
+
preview: usable
|
|
419
|
+
} : {}));
|
|
420
|
+
}
|
|
421
|
+
function clearChannelHistoryRunning(channelId) {
|
|
422
|
+
if (!channelId) return;
|
|
423
|
+
const existing = rememberedHistoryTitles.get(channelId);
|
|
424
|
+
if (!(existing == null ? void 0 : existing.running)) return;
|
|
425
|
+
mergeRememberedHistory(channelId, {
|
|
426
|
+
running: false
|
|
308
427
|
});
|
|
309
428
|
}
|
|
310
429
|
function applyRememberedHistoryTitles(rows) {
|
|
311
430
|
return rows.map((row) => {
|
|
431
|
+
var _a;
|
|
312
432
|
rememberHistoryTitle(row);
|
|
313
|
-
if (!row.isPlaceholder && !/^new chat$/i.test(row.title)) return row;
|
|
314
433
|
const mem = rememberedHistoryTitles.get(row.channelId);
|
|
315
434
|
if (!mem) return row;
|
|
435
|
+
const titleMissing = row.isPlaceholder || /^new chat$/i.test(row.title);
|
|
436
|
+
const previewMissing = !((_a = row.preview) == null ? void 0 : _a.trim());
|
|
437
|
+
const nextTitle = titleMissing && mem.title ? mem.title : row.title;
|
|
438
|
+
const livePreview = mem.running && mem.preview && mem.preview !== nextTitle ? mem.preview : previewMissing && mem.preview && mem.preview !== nextTitle ? mem.preview : row.preview;
|
|
439
|
+
if (!titleMissing && !previewMissing && !mem.running) return row;
|
|
316
440
|
return __spreadProps(__spreadValues({}, row), {
|
|
317
|
-
title:
|
|
318
|
-
|
|
319
|
-
|
|
441
|
+
title: nextTitle,
|
|
442
|
+
preview: livePreview,
|
|
443
|
+
isPlaceholder: titleMissing && mem.title ? false : row.isPlaceholder,
|
|
444
|
+
isAttachment: mem.isAttachment || row.isAttachment,
|
|
445
|
+
isRunning: Boolean(mem.running)
|
|
320
446
|
});
|
|
321
447
|
});
|
|
322
448
|
}
|
|
@@ -366,6 +492,7 @@ function useChatHistorySessionsFromChannels(orgName, options) {
|
|
|
366
492
|
// / createChannel cache writes, not per-visit network hits.
|
|
367
493
|
fetchPolicy: "cache-first",
|
|
368
494
|
nextFetchPolicy: "cache-first",
|
|
495
|
+
returnPartialData: true,
|
|
369
496
|
context: {
|
|
370
497
|
cacheKey: "chat-history-channels-list"
|
|
371
498
|
}
|
|
@@ -382,6 +509,11 @@ function useChatHistorySessionsFromChannels(orgName, options) {
|
|
|
382
509
|
sourceChannelCount
|
|
383
510
|
};
|
|
384
511
|
}
|
|
512
|
+
function usePrefetchChatHistory(orgName) {
|
|
513
|
+
return useChatHistorySessionsFromChannels(orgName, {
|
|
514
|
+
skip: !orgName
|
|
515
|
+
});
|
|
516
|
+
}
|
|
385
517
|
function stripModelCostHeader(content) {
|
|
386
518
|
const normalized = content.replace(/\r\n/g, "\n");
|
|
387
519
|
return normalized.replace(/^\s*(?:[^\w\n]+\s*)?[a-z0-9][a-z0-9._-]*\s*\(\s*\$[\d.]+\s*\/\s*MTok\s+in\s*\)\s*\n+/i, "");
|
|
@@ -483,19 +615,23 @@ function mapPostToChatMessageUI(post, fallbackChannelId) {
|
|
|
483
615
|
};
|
|
484
616
|
}
|
|
485
617
|
function useChatMessages(sessionId, options) {
|
|
618
|
+
const client = useApolloClient();
|
|
486
619
|
const {
|
|
487
620
|
data,
|
|
488
621
|
loading,
|
|
489
622
|
error,
|
|
490
|
-
refetch
|
|
623
|
+
refetch,
|
|
624
|
+
subscribeToMore
|
|
491
625
|
} = useMessagesQuery({
|
|
492
626
|
variables: sessionId ? getThreadMessagesQueryVariables(sessionId) : void 0,
|
|
493
627
|
skip: !sessionId || (void 0 ),
|
|
494
|
-
// cache
|
|
495
|
-
//
|
|
496
|
-
//
|
|
497
|
-
fetchPolicy: "cache-
|
|
628
|
+
// Same as browser: paint cache immediately, then hit the network so a thread
|
|
629
|
+
// opened from history is not stuck on a cache-first snapshot that only has
|
|
630
|
+
// the latest user post (assistant replies persist after the first query).
|
|
631
|
+
fetchPolicy: "cache-and-network",
|
|
498
632
|
nextFetchPolicy: "cache-first",
|
|
633
|
+
errorPolicy: "all",
|
|
634
|
+
notifyOnNetworkStatusChange: true,
|
|
499
635
|
/**
|
|
500
636
|
* Cache key is per-channel so switching sessions doesn't read another channel's response.
|
|
501
637
|
* Keeping this as a constant ('messages-list') used to cause cross-session bleed in the
|
|
@@ -505,12 +641,77 @@ function useChatMessages(sessionId, options) {
|
|
|
505
641
|
cacheKey: sessionId ? `messages-list:${sessionId}` : "messages-list"
|
|
506
642
|
}
|
|
507
643
|
});
|
|
644
|
+
useEffect(() => {
|
|
645
|
+
if (!sessionId || (void 0 )) return;
|
|
646
|
+
const unsubscribe = subscribeToMore({
|
|
647
|
+
document: OnChatMessageAddedDocument,
|
|
648
|
+
variables: {
|
|
649
|
+
channelId: sessionId
|
|
650
|
+
},
|
|
651
|
+
updateQuery: (prev, {
|
|
652
|
+
subscriptionData
|
|
653
|
+
}) => {
|
|
654
|
+
var _a, _b, _c, _d, _e;
|
|
655
|
+
const post = (_a = subscriptionData == null ? void 0 : subscriptionData.data) == null ? void 0 : _a.chatMessageAdded;
|
|
656
|
+
if (!(post == null ? void 0 : post.id)) return prev;
|
|
657
|
+
if (!(prev == null ? void 0 : prev.messages)) return prev;
|
|
658
|
+
const existing = (_b = prev.messages.data) != null ? _b : [];
|
|
659
|
+
const idx = existing.findIndex((row) => (row == null ? void 0 : row.id) === post.id);
|
|
660
|
+
let nextData;
|
|
661
|
+
let nextTotal;
|
|
662
|
+
if (idx >= 0) {
|
|
663
|
+
nextData = [...existing.slice(0, idx), post, ...existing.slice(idx + 1)];
|
|
664
|
+
nextTotal = (_c = prev.messages.totalCount) != null ? _c : existing.length;
|
|
665
|
+
} else {
|
|
666
|
+
nextData = [...existing, post];
|
|
667
|
+
nextTotal = ((_d = prev.messages.totalCount) != null ? _d : existing.length) + 1;
|
|
668
|
+
const parentId = (_e = post.parentId) != null ? _e : null;
|
|
669
|
+
if (parentId) {
|
|
670
|
+
nextData = nextData.map((root) => {
|
|
671
|
+
var _a2, _b2, _c2, _d2, _e2, _f, _g;
|
|
672
|
+
if ((root == null ? void 0 : root.id) !== parentId) return root;
|
|
673
|
+
const replies = (_b2 = (_a2 = root.replies) == null ? void 0 : _a2.data) != null ? _b2 : [];
|
|
674
|
+
if (replies.some((reply) => (reply == null ? void 0 : reply.id) === post.id)) return root;
|
|
675
|
+
return __spreadProps(__spreadValues({}, root), {
|
|
676
|
+
replies: __spreadProps(__spreadValues({}, (_c2 = root.replies) != null ? _c2 : {}), {
|
|
677
|
+
__typename: (_e2 = (_d2 = root.replies) == null ? void 0 : _d2.__typename) != null ? _e2 : "Messages",
|
|
678
|
+
data: [...replies, post],
|
|
679
|
+
totalCount: ((_g = (_f = root.replies) == null ? void 0 : _f.totalCount) != null ? _g : replies.length) + 1
|
|
680
|
+
})
|
|
681
|
+
});
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
const seen = /* @__PURE__ */ new Set();
|
|
686
|
+
nextData = nextData.filter((row) => {
|
|
687
|
+
if (!(row == null ? void 0 : row.id) || seen.has(row.id)) return false;
|
|
688
|
+
seen.add(row.id);
|
|
689
|
+
return true;
|
|
690
|
+
});
|
|
691
|
+
return __spreadProps(__spreadValues({}, prev), {
|
|
692
|
+
messages: __spreadProps(__spreadValues({}, prev.messages), {
|
|
693
|
+
data: nextData,
|
|
694
|
+
totalCount: nextTotal
|
|
695
|
+
})
|
|
696
|
+
});
|
|
697
|
+
},
|
|
698
|
+
onError: (err) => {
|
|
699
|
+
console.error("[useChatMessages] subscribeToMore error:", err);
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
return () => unsubscribe();
|
|
703
|
+
}, [sessionId, void 0 , subscribeToMore, client]);
|
|
508
704
|
const messagesLoaded = data !== void 0;
|
|
509
705
|
const messages = useMemo(() => {
|
|
510
706
|
var _a, _b;
|
|
511
707
|
if (!sessionId) return [];
|
|
512
708
|
const rows = (_b = (_a = data == null ? void 0 : data.messages) == null ? void 0 : _a.data) != null ? _b : [];
|
|
513
|
-
|
|
709
|
+
const ownRows = rows.filter((post) => {
|
|
710
|
+
var _a2;
|
|
711
|
+
const postChannelId = (_a2 = post == null ? void 0 : post.channel) == null ? void 0 : _a2.id;
|
|
712
|
+
return !postChannelId || postChannelId === sessionId;
|
|
713
|
+
});
|
|
714
|
+
return flattenPostsWithReplies(ownRows, sessionId);
|
|
514
715
|
}, [data, sessionId]);
|
|
515
716
|
return {
|
|
516
717
|
messages,
|
|
@@ -768,13 +969,18 @@ function useChatMutations() {
|
|
|
768
969
|
}
|
|
769
970
|
};
|
|
770
971
|
}, [client, sendMessagesMutation]);
|
|
972
|
+
const patchChannelTitle = useCallback((channelId, rawPrompt, bumpActivity = false) => {
|
|
973
|
+
patchChannelHistoryTitle(client, channelId, rawPrompt);
|
|
974
|
+
if (bumpActivity) touchChannelHistoryUpdatedAt(client, channelId);
|
|
975
|
+
}, [client]);
|
|
771
976
|
return {
|
|
772
977
|
createChannel,
|
|
773
978
|
createSession: createChannel,
|
|
774
979
|
saveMessages,
|
|
980
|
+
patchChannelTitle,
|
|
775
981
|
loading: {
|
|
776
982
|
create: createChannelLoading,
|
|
777
983
|
saveMessages: sendMessagesLoading
|
|
778
984
|
}
|
|
779
985
|
};
|
|
780
|
-
}export{AI_ASSISTANT_CHANNELS_QUERY_VARS,HISTORY_PAGE_SIZE,HISTORY_QUERY_BASE,buildSessionFromChannel,chatHistorySessionsFromChannels,chatHistorySessionsFromMessages,enrichHistorySessionsWithUserPrompts,getChatHistoryChannelRefetchQueries,getChatHistoryMessagesQueryVariables,getHistoryChannelsQueryVariables,useChatHistorySessionsFromChannels,useChatHistorySessionsFromMessages,useChatMessages,useChatMutations};//# sourceMappingURL=useChatApi.js.map
|
|
986
|
+
}export{AI_ASSISTANT_CHANNELS_QUERY_VARS,HISTORY_PAGE_SIZE,HISTORY_QUERY_BASE,buildSessionFromChannel,chatHistorySessionsFromChannels,chatHistorySessionsFromMessages,clearChannelHistoryRunning,enrichHistorySessionsWithUserPrompts,getChatHistoryChannelRefetchQueries,getChatHistoryMessagesQueryVariables,getHistoryChannelsQueryVariables,markChannelHistoryRunning,patchChannelHistoryPreview,patchChannelHistoryTitle,subscribeRememberedHistory,touchChannelHistoryUpdatedAt,useChatHistorySessionsFromChannels,useChatHistorySessionsFromMessages,useChatMessages,useChatMutations,usePrefetchChatHistory};//# sourceMappingURL=useChatApi.js.map
|