@celljs/ta-web 4.23.0 → 4.24.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.
Files changed (71) hide show
  1. package/esm/browser/assistant/assistant-chat-list.js +3 -1
  2. package/esm/browser/components/app-shell-state.js +2 -1
  3. package/esm/browser/components/app-view.js +15 -7
  4. package/esm/browser/components/chat-home-util.d.ts +7 -0
  5. package/esm/browser/components/chat-home-util.js +10 -0
  6. package/esm/browser/components/chat-list-util.d.ts +15 -3
  7. package/esm/browser/components/chat-list-util.js +26 -4
  8. package/esm/browser/components/chat-list.js +4 -3
  9. package/esm/browser/components/chat-seen.d.ts +4 -3
  10. package/esm/browser/components/chat-seen.js +6 -5
  11. package/esm/browser/components/chats-dot.d.ts +30 -0
  12. package/esm/browser/components/chats-dot.js +32 -0
  13. package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
  14. package/esm/browser/components/host-view.d.ts +1 -1
  15. package/esm/browser/components/settings-files.d.ts +7 -0
  16. package/esm/browser/components/settings-files.js +61 -0
  17. package/esm/browser/components/settings-more.js +2 -0
  18. package/esm/browser/components/tool-view.js +23 -7
  19. package/esm/browser/extension/web-api-contributions.d.ts +2 -1
  20. package/esm/browser/extension/web-api-partners.d.ts +9 -1
  21. package/esm/browser/extension/web-view-util.d.ts +5 -0
  22. package/esm/browser/extension/web-view-util.js +8 -0
  23. package/esm/browser/i18n/locales.d.ts +10 -1
  24. package/esm/browser/i18n/messages-ja.js +9 -0
  25. package/esm/browser/i18n/messages-zh-tw.js +9 -0
  26. package/esm/browser/i18n/messages.d.ts +9 -0
  27. package/esm/browser/i18n/messages.js +18 -0
  28. package/esm/browser/partners/partners-util.d.ts +6 -0
  29. package/esm/browser/partners/partners-util.js +9 -0
  30. package/esm/browser/style/conversation.d.ts +1 -1
  31. package/esm/browser/style/conversation.js +1 -0
  32. package/esm/browser/style/pages.d.ts +1 -1
  33. package/esm/browser/style/pages.js +8 -0
  34. package/esm/browser/util/process.d.ts +3 -1
  35. package/esm/browser/util/process.js +27 -0
  36. package/lib/browser/assistant/assistant-chat-list.js +3 -1
  37. package/lib/browser/components/app-shell-state.js +2 -1
  38. package/lib/browser/components/app-view.js +15 -7
  39. package/lib/browser/components/chat-home-util.d.ts +7 -0
  40. package/lib/browser/components/chat-home-util.js +10 -0
  41. package/lib/browser/components/chat-list-util.d.ts +15 -3
  42. package/lib/browser/components/chat-list-util.js +26 -4
  43. package/lib/browser/components/chat-list.js +4 -3
  44. package/lib/browser/components/chat-seen.d.ts +4 -3
  45. package/lib/browser/components/chat-seen.js +6 -5
  46. package/lib/browser/components/chats-dot.d.ts +31 -0
  47. package/lib/browser/components/chats-dot.js +68 -0
  48. package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
  49. package/lib/browser/components/host-view.d.ts +1 -1
  50. package/lib/browser/components/settings-files.d.ts +8 -0
  51. package/lib/browser/components/settings-files.js +97 -0
  52. package/lib/browser/components/settings-more.js +2 -0
  53. package/lib/browser/components/tool-view.js +23 -7
  54. package/lib/browser/extension/web-api-contributions.d.ts +2 -1
  55. package/lib/browser/extension/web-api-partners.d.ts +9 -1
  56. package/lib/browser/extension/web-view-util.d.ts +5 -0
  57. package/lib/browser/extension/web-view-util.js +8 -0
  58. package/lib/browser/i18n/locales.d.ts +10 -1
  59. package/lib/browser/i18n/messages-ja.js +9 -0
  60. package/lib/browser/i18n/messages-zh-tw.js +9 -0
  61. package/lib/browser/i18n/messages.d.ts +9 -0
  62. package/lib/browser/i18n/messages.js +18 -0
  63. package/lib/browser/partners/partners-util.d.ts +6 -0
  64. package/lib/browser/partners/partners-util.js +9 -0
  65. package/lib/browser/style/conversation.d.ts +1 -1
  66. package/lib/browser/style/conversation.js +1 -0
  67. package/lib/browser/style/pages.d.ts +1 -1
  68. package/lib/browser/style/pages.js +8 -0
  69. package/lib/browser/util/process.d.ts +3 -1
  70. package/lib/browser/util/process.js +27 -0
  71. package/package.json +7 -7
@@ -76,6 +76,7 @@ function useChatHome(onPicked) {
76
76
  const items = React.useSyncExternalStore(host.home.subscribe, host.home.items, host.home.items);
77
77
  const allPartners = React.useSyncExternalStore(host.partners.subscribe, host.partners.partners, host.partners.partners);
78
78
  const partners = React.useMemo(() => partners_util_1.PartnersUtil.chats(allPartners), [allPartners]);
79
+ const partnerSessions = React.useMemo(() => partners_util_1.PartnersUtil.sessions(allPartners), [allPartners]);
79
80
  // Its preview and whether it works, as one string: the same line stays the same value.
80
81
  const watch = React.useCallback((listener) => { var _a; var _b; return (_b = (_a = view === null || view === void 0 ? void 0 : view.subscribePreview) === null || _a === void 0 ? void 0 : _a.call(view, listener)) !== null && _b !== void 0 ? _b : (() => undefined); }, [view]);
81
82
  const read = () => {
@@ -108,6 +109,7 @@ function useChatHome(onPicked) {
108
109
  },
109
110
  items,
110
111
  partners,
112
+ partnerSessions,
111
113
  shownItem,
112
114
  openItem: entry => {
113
115
  latest.current();
@@ -122,7 +124,7 @@ function useChatHome(onPicked) {
122
124
  },
123
125
  remove: removed => void web_tasks_1.WebTaskUtil.remove(removed, notices, t),
124
126
  };
125
- }, [listed, line, name, shown, view, items, partners, shownItem, tasks, host, state, notices, t]);
127
+ }, [listed, line, name, shown, view, items, partners, partnerSessions, shownItem, tasks, host, state, notices, t]);
126
128
  }
127
129
  /** The list of chats with what the double knows of them: its tasks marked, a conversation to hand it; its home over them. */
128
130
  function AssistantChatList(props) {
@@ -43,6 +43,7 @@ const chat_view_1 = require("../chat/chat-view");
43
43
  const back_stack_1 = require("../device/back-stack");
44
44
  const device_1 = require("../device/device");
45
45
  const web_tasks_1 = require("../extension/web-tasks");
46
+ const web_view_util_1 = require("../extension/web-view-util");
46
47
  const files_protocol_1 = require("../files/files-protocol");
47
48
  const hooks_1 = require("../hooks");
48
49
  const use_t_1 = require("../i18n/use-t");
@@ -236,7 +237,7 @@ function useAppShell() {
236
237
  setSettings(undefined);
237
238
  setTabPage(undefined);
238
239
  };
239
- const tools = [...(hasCards ? [cardsTool] : []), ...extensions.views.filter(candidate => candidate.location === 'panel')];
240
+ const tools = [...(hasCards ? [cardsTool] : []), ...web_view_util_1.WebViewUtil.tools(extensions.views)];
240
241
  const openTool = (id) => (id === app_shell_hooks_1.CARDS_ID ? openCards() : host.openView(id));
241
242
  // The workbench: the tabs open, or the tools that open there.
242
243
  const editors = extensions.editors.length > 0 || tools.length > 0;
@@ -46,7 +46,6 @@ const hooks_1 = require("../hooks");
46
46
  const notices_1 = require("../notices/notices");
47
47
  const shared_link_1 = require("../share/shared-link");
48
48
  const shared_page_1 = require("../share/shared-page");
49
- const workbench_util_1 = require("../workbench-util");
50
49
  const app_contexts_1 = require("./app-contexts");
51
50
  const app_nav_1 = require("./app-nav");
52
51
  const app_shell_hooks_1 = require("./app-shell-hooks");
@@ -54,9 +53,9 @@ const app_shell_state_1 = require("./app-shell-state");
54
53
  const auth_view_1 = require("./auth-view");
55
54
  const board_1 = require("./board");
56
55
  const chat_asks_1 = require("./chat-asks");
57
- const chat_icon_1 = require("./chat-icon");
58
56
  const chat_list_util_1 = require("./chat-list-util");
59
57
  const chat_seen_1 = require("./chat-seen");
58
+ const chats_dot_1 = require("./chats-dot");
60
59
  const connection_bar_1 = require("./connection-bar");
61
60
  const custom_host_1 = require("./custom-host");
62
61
  const device_sign_in_page_1 = require("./device-sign-in-page");
@@ -114,6 +113,20 @@ function AppShell() {
114
113
  // Where Ta's agents read the page to be, and go (docs/design/ta-app-use.md 3): set below as it renders.
115
114
  const screenShell = (0, screen_navigator_1.useScreenNavigator)();
116
115
  const inCall = (0, entry_holds_1.useCallGoingOn)();
116
+ // The chats' tab, and the double's on the rail, have the amber dot while a row of the double's list has one, as a
117
+ // messenger's; what waits for the user to decide is counted there until answered.
118
+ const { listed: listedChats, unseen: chatsUnseen } = (0, chats_dot_1.useChatsDot)({
119
+ sessions: workbench.sessions,
120
+ saved: workbench.saved,
121
+ removed: removedChats,
122
+ pinned: pinnedChats,
123
+ letGo: letGoAsks,
124
+ archiveDays: chatSettings.chatArchiveDays,
125
+ seen: seenChats,
126
+ looking,
127
+ extensions,
128
+ host,
129
+ });
117
130
  if (workbench.status === 'signed-out') {
118
131
  return workbench.leaving ? React.createElement("div", { className: "ta-signin" }) : React.createElement(workbench_view_1.SignIn, { error: workbench.error });
119
132
  }
@@ -252,11 +265,6 @@ function AppShell() {
252
265
  picked();
253
266
  },
254
267
  });
255
- // The chats' tab, and the double's on the rail, have the amber dot of the rows listed while one said something unseen,
256
- // as a messenger's, but those quiet (a call); what waits for the user to decide is counted there until answered.
257
- const listedChats = chat_list_util_1.ChatListUtil.entries(workbench.sessions, workbench.saved, removedChats, undefined, workbench_util_1.WorkbenchUtil.daysAgo(Date.now(), chatSettings.chatArchiveDays), chat_list_util_1.ChatListUtil.keptFiles(workbench.saved, pinnedChats, letGoAsks), chat_icon_1.ChatIconUtil.archiveSince(extensions.chatIcons, Date.now())).listed;
258
- const inFront = looking ? workbench.sessions.find(session => session.sessionId === looking) : undefined;
259
- const chatsUnseen = chat_seen_1.ChatSeenUtil.anyUnseen(chat_icon_1.ChatIconUtil.loud(extensions.chatIcons, listedChats), seenChats, inFront && chat_list_util_1.ChatListUtil.file(inFront));
260
268
  // Dragged away, the dot of the chats: all seen.
261
269
  const seeAllChats = () => state.set(chat_seen_1.SEEN_CHATS, chat_seen_1.ChatSeenUtil.seeAll(state.get(chat_seen_1.SEEN_CHATS), listedChats, Date.now()));
262
270
  // Dragged away, the count of the double: what the conversations ask let go; the double's own tasks wait on.
@@ -16,6 +16,8 @@ export interface ChatHome {
16
16
  * list by their time as any conversation (docs/design/ta-partners.md).
17
17
  */
18
18
  partners: readonly WebPartnerEntry[];
19
+ /** The conversations of pi that are partners' (PartnersUtil.sessions): listed once closed too, seen elsewhere till then. */
20
+ partnerSessions: ReadonlyMap<string, number>;
19
21
  /** The key of the row whose page is in front, as a conversation of the list is (WebExtensionsState.pageFrom). */
20
22
  shownItem?: string;
21
23
  /** Opens a row: a page it shows is shown beside the list (TaWebExtensions.openHome). */
@@ -104,6 +106,11 @@ export declare namespace ChatHomeUtil {
104
106
  };
105
107
  /** It ended after the user last opened it (once the seen were kept): an amber dot, as a conversation's unread. */
106
108
  function unseen(task: WebTaskEntry, seen: ChatSeen): boolean;
109
+ /**
110
+ * Whether a row of the double's list that is no conversation of pi has the amber dot: a row of its home, a
111
+ * conversation with a partner (a group chat, a chat of two), a task that is no conversation.
112
+ */
113
+ function anyUnseen(items: readonly WebHomeEntry[], partners: readonly WebPartnerEntry[], tasks: readonly WebTaskEntry[], seen: ChatSeen): boolean;
107
114
  /** Whether one of `texts` has the query (any case); all match an empty one. */
108
115
  function matches(query: string, ...texts: (string | undefined)[]): boolean;
109
116
  /**
@@ -103,6 +103,16 @@ var ChatHomeUtil;
103
103
  return seen.since > 0 && web_tasks_1.WebTaskUtil.ended(task) && task.endedAt !== undefined && task.endedAt > ((_a = seen.at[seenKey(task)]) !== null && _a !== void 0 ? _a : seen.since);
104
104
  }
105
105
  ChatHomeUtil.unseen = unseen;
106
+ /**
107
+ * Whether a row of the double's list that is no conversation of pi has the amber dot: a row of its home, a
108
+ * conversation with a partner (a group chat, a chat of two), a task that is no conversation.
109
+ */
110
+ function anyUnseen(items, partners, tasks, seen) {
111
+ return (ChatHomeUtil.items(items).some(item => item.unseen) ||
112
+ partners_util_1.PartnersUtil.chats(partners).some(partners_util_1.PartnersUtil.unseen) ||
113
+ ChatHomeUtil.tasks(tasks).rows.some(task => unseen(task, seen)));
114
+ }
115
+ ChatHomeUtil.anyUnseen = anyUnseen;
106
116
  /** Whether one of `texts` has the query (any case); all match an empty one. */
107
117
  function matches(query, ...texts) {
108
118
  const needle = query.trim().toLowerCase();
@@ -5,6 +5,7 @@ import { type StateSpec } from '../state/state-protocol';
5
5
  import { type LetGoAsks } from './chat-asks';
6
6
  import type { ChatHomeRow, ChatTaskRow } from './chat-home-util';
7
7
  import type { ChatFolderIcon } from './chat-icon';
8
+ import { type ChatSeen } from './chat-seen';
8
9
  /** Where a conversation belongs: the directory of the user's own, or the package that opened it. */
9
10
  export interface ChatSource {
10
11
  /** `dir:<cwd>` or `pkg:<package>`. */
@@ -130,14 +131,25 @@ export declare namespace ChatListUtil {
130
131
  pinned: T[];
131
132
  rest: T[];
132
133
  };
134
+ /**
135
+ * Whether a row said something the user has not seen (ChatSeenUtil.unseen): a saved one answers no more, and what
136
+ * a partner's conversation said till it was seen elsewhere (PartnersUtil.sessions) is seen.
137
+ */
138
+ function unseen(session: ChatEntry, seen: ChatSeen, shown?: string, partnerSessions?: ReadonlyMap<string, number>): boolean;
139
+ /**
140
+ * Which saved conversations of a package's group the list has (`entries`): those that fold into a folder of the
141
+ * list (WebChatIcon.folder), and those of partners (an agent's, PartnersUtil.sessions), the double's list having
142
+ * every conversation with a partner. ta serve opens either again with its group and role, from its file.
143
+ */
144
+ function groupListed(folderOf: ((session: TaSavedSessionInfo) => unknown) | undefined, partnerSessions: ReadonlyMap<string, number> | undefined): ((session: TaSavedSessionInfo) => boolean) | undefined;
133
145
  /**
134
146
  * The open sessions and the saved ones, those archived and those taken out apart. A saved conversation of a
135
- * package's group is not listed: its package opens it again, with its role; unless it folds into a folder of the
136
- * list (`folderOf`, WebChatIcon.folder), which opens it as the package does. An open one is always listed,
147
+ * package's group is not listed: its package opens it again, with its role; unless `listed` has it (groupListed:
148
+ * one that folds into a folder of the list, a partner's). An open one is always listed,
137
149
  * however old, and so is one pinned; a saved one not updated `since` is archived (a ta serve of before lists
138
150
  * them with the others), or not updated since what `sooner` says of it (ChatIconUtil.archiveSince).
139
151
  */
140
- function entries(sessions: TaSessionInfo[], saved: TaSavedSessionInfo[], removed: string[], archived?: TaSavedSessionInfo[], since?: number, pinned?: readonly string[], sooner?: (session: TaSavedSessionInfo) => number | undefined, folderOf?: (session: TaSavedSessionInfo) => unknown): {
152
+ function entries(sessions: TaSessionInfo[], saved: TaSavedSessionInfo[], removed: string[], archived?: TaSavedSessionInfo[], since?: number, pinned?: readonly string[], sooner?: (session: TaSavedSessionInfo) => number | undefined, listed?: (session: TaSavedSessionInfo) => unknown): {
141
153
  listed: ChatEntry[];
142
154
  archived: ChatEntry[];
143
155
  removed: ChatEntry[];
@@ -5,6 +5,7 @@ const ta_protocol_1 = require("@celljs/ta-protocol");
5
5
  const state_protocol_1 = require("../state/state-protocol");
6
6
  const message_1 = require("../util/message");
7
7
  const chat_asks_1 = require("./chat-asks");
8
+ const chat_seen_1 = require("./chat-seen");
8
9
  const people_1 = require("./people");
9
10
  const secret_text_1 = require("./secret-text");
10
11
  /** The list by directory or package, else by day; in any browser. */
@@ -180,19 +181,40 @@ var ChatListUtil;
180
181
  return { pinned: rows.filter(row => keys.has(pinKey(row))), rest: rows.filter(row => !keys.has(pinKey(row))) };
181
182
  }
182
183
  ChatListUtil.pinnedApart = pinnedApart;
184
+ /**
185
+ * Whether a row said something the user has not seen (ChatSeenUtil.unseen): a saved one answers no more, and what
186
+ * a partner's conversation said till it was seen elsewhere (PartnersUtil.sessions) is seen.
187
+ */
188
+ function unseen(session, seen, shown, partnerSessions) {
189
+ const at = file(session);
190
+ return chat_seen_1.ChatSeenUtil.unseen({ ...session, isStreaming: isOpen(session) && session.isStreaming }, at, seen, shown, partnerSessions === null || partnerSessions === void 0 ? void 0 : partnerSessions.get(at));
191
+ }
192
+ ChatListUtil.unseen = unseen;
193
+ /**
194
+ * Which saved conversations of a package's group the list has (`entries`): those that fold into a folder of the
195
+ * list (WebChatIcon.folder), and those of partners (an agent's, PartnersUtil.sessions), the double's list having
196
+ * every conversation with a partner. ta serve opens either again with its group and role, from its file.
197
+ */
198
+ function groupListed(folderOf, partnerSessions) {
199
+ if (!folderOf && !(partnerSessions === null || partnerSessions === void 0 ? void 0 : partnerSessions.size)) {
200
+ return undefined;
201
+ }
202
+ return session => !!(folderOf === null || folderOf === void 0 ? void 0 : folderOf(session)) || !!(partnerSessions === null || partnerSessions === void 0 ? void 0 : partnerSessions.has(session.sessionFile));
203
+ }
204
+ ChatListUtil.groupListed = groupListed;
183
205
  /**
184
206
  * The open sessions and the saved ones, those archived and those taken out apart. A saved conversation of a
185
- * package's group is not listed: its package opens it again, with its role; unless it folds into a folder of the
186
- * list (`folderOf`, WebChatIcon.folder), which opens it as the package does. An open one is always listed,
207
+ * package's group is not listed: its package opens it again, with its role; unless `listed` has it (groupListed:
208
+ * one that folds into a folder of the list, a partner's). An open one is always listed,
187
209
  * however old, and so is one pinned; a saved one not updated `since` is archived (a ta serve of before lists
188
210
  * them with the others), or not updated since what `sooner` says of it (ChatIconUtil.archiveSince).
189
211
  */
190
- function entries(sessions, saved, removed, archived = [], since, pinned = [], sooner, folderOf) {
212
+ function entries(sessions, saved, removed, archived = [], since, pinned = [], sooner, listed) {
191
213
  const open = new Set(sessions.map(session => session.sessionFile));
192
214
  const out = new Set(removed);
193
215
  const seen = new Set();
194
216
  const closed = [...saved, ...archived].filter(session => {
195
- if ((session.group && !(folderOf === null || folderOf === void 0 ? void 0 : folderOf(session))) || open.has(session.sessionFile) || seen.has(session.sessionFile)) {
217
+ if ((session.group && !(listed === null || listed === void 0 ? void 0 : listed(session))) || open.has(session.sessionFile) || seen.has(session.sessionFile)) {
196
218
  return false;
197
219
  }
198
220
  seen.add(session.sessionFile);
@@ -53,7 +53,6 @@ const chat_icon_1 = require("./chat-icon");
53
53
  const chat_list_hooks_1 = require("./chat-list-hooks");
54
54
  const chat_list_row_1 = require("./chat-list-row");
55
55
  const chat_list_util_1 = require("./chat-list-util");
56
- const chat_seen_1 = require("./chat-seen");
57
56
  const empty_state_1 = require("./empty-state");
58
57
  const host_tag_1 = require("./host-tag");
59
58
  const icon_1 = require("./icon");
@@ -140,9 +139,11 @@ function ChatList({ sessions, saved, removed: removedFiles, archived: archivedSa
140
139
  const sooner = React.useMemo(() => chat_icon_1.ChatIconUtil.archiveSince(icons.entries, now), [icons, now]);
141
140
  // Those an extension folds into a row of their folder (WebChatIcon.folder), asked again as its icons change.
142
141
  const folderOf = React.useMemo(() => chat_icon_1.ChatIconUtil.folderOf(icons.entries), [icons]);
142
+ const partnerSessions = home === null || home === void 0 ? void 0 : home.partnerSessions; // The agents' conversations, listed once closed too.
143
+ const groupListed = React.useMemo(() => chat_list_util_1.ChatListUtil.groupListed(folderOf, partnerSessions), [folderOf, partnerSessions]);
143
144
  // One that waits for the user is not archived, however old, as one pinned.
144
145
  const kept = React.useMemo(() => chat_list_util_1.ChatListUtil.keptFiles([...saved, ...(archivedSaved !== null && archivedSaved !== void 0 ? archivedSaved : [])], pinned, letGo), [saved, archivedSaved, pinned, letGo]);
145
- const { listed, archived, removed } = React.useMemo(() => chat_list_util_1.ChatListUtil.entries(sessions, saved, removedFiles, archivedSaved, since, kept, sooner, folderOf), [sessions, saved, removedFiles, archivedSaved, since, kept, sooner, folderOf]);
146
+ const { listed, archived, removed } = React.useMemo(() => chat_list_util_1.ChatListUtil.entries(sessions, saved, removedFiles, archivedSaved, since, kept, sooner, groupListed), [sessions, saved, removedFiles, archivedSaved, since, kept, sooner, groupListed]);
146
147
  // A folder pinned holds its archived conversations too, and stays once they all are: a row pinned never goes away.
147
148
  const { held, rest: archivedRest } = React.useMemo(() => chat_list_util_1.ChatListUtil.heldByPinned(archived, folderOf, pinned), [archived, folderOf, pinned]);
148
149
  const sources = React.useMemo(() => chat_list_util_1.ChatListUtil.sources(listed), [listed]);
@@ -199,7 +200,7 @@ function ChatList({ sessions, saved, removed: removedFiles, archived: archivedSa
199
200
  const fold = (key) => onFolded(folded.includes(key) ? folded.filter(other => other !== key) : [...folded, key]);
200
201
  const byKey = React.useMemo(() => new Map([...sources, ...chat_list_util_1.ChatListUtil.sources([...archived, ...removed])].map(candidate => [candidate.key, candidate])), [sources, archived, removed]);
201
202
  const isSelected = (session) => (typeof session === 'string' ? session : chat_list_util_1.ChatListUtil.key(session)) === selected;
202
- const isUnseen = (session) => chat_seen_1.ChatSeenUtil.unseen({ ...session, isStreaming: chat_list_util_1.ChatListUtil.isOpen(session) && session.isStreaming }, chat_list_util_1.ChatListUtil.file(session), seen, inFront);
203
+ const isUnseen = (session) => chat_list_util_1.ChatListUtil.unseen(session, seen, inFront, partnerSessions);
203
204
  // What is folded or not drawn yet still has the conversation shown, and those unseen: the dot of the tab finds them.
204
205
  const stays = (session) => isSelected(session) || isUnseen(session);
205
206
  const taskUnseen = (task) => chat_home_util_1.ChatHomeUtil.unseen(task, seen);
@@ -21,13 +21,14 @@ export declare namespace ChatSeenUtil {
21
21
  function merge(a: ChatSeen, b: ChatSeen): ChatSeen;
22
22
  /**
23
23
  * Whether it said something the user has not seen: it is not answering now, not the one in front, and its
24
- * last message came after the user last saw it at rest (or, never seen, after `since`).
24
+ * last message came after the user last saw it at rest (or, never seen, after `since`), and after `seenElsewhere`
25
+ * (an agent's answers read in a group chat, WebPartnerChat.seenAt).
25
26
  */
26
27
  function unseen(entry: {
27
28
  updatedAt: number;
28
29
  messageCount: number;
29
30
  isStreaming?: boolean;
30
- }, file: string, seen: ChatSeen, shown?: string): boolean;
31
+ }, file: string, seen: ChatSeen, shown?: string, seenElsewhere?: number): boolean;
31
32
  /**
32
33
  * Whether any of the conversations the list shows (ChatListUtil.entries, those listed) said something unseen:
33
34
  * the dot on the tab of the chats. Only those: one the list leaves out (a package's, closed) has no row to find.
@@ -38,7 +39,7 @@ export declare namespace ChatSeenUtil {
38
39
  isStreaming?: boolean;
39
40
  sessionFile?: string;
40
41
  sessionId?: string;
41
- }[], seen: ChatSeen, shown?: string): boolean;
42
+ }[], seen: ChatSeen, shown?: string, elsewhere?: ReadonlyMap<string, number>): boolean;
42
43
  /**
43
44
  * Everything seen at once, as the user drags the dot of the tab away: kept since the latest of now and of what
44
45
  * the conversations said last (the clocks of the page and the computer may differ). One answering goes on, and
@@ -73,26 +73,27 @@ var ChatSeenUtil;
73
73
  ChatSeenUtil.merge = merge;
74
74
  /**
75
75
  * Whether it said something the user has not seen: it is not answering now, not the one in front, and its
76
- * last message came after the user last saw it at rest (or, never seen, after `since`).
76
+ * last message came after the user last saw it at rest (or, never seen, after `since`), and after `seenElsewhere`
77
+ * (an agent's answers read in a group chat, WebPartnerChat.seenAt).
77
78
  */
78
- function unseen(entry, file, seen, shown) {
79
+ function unseen(entry, file, seen, shown, seenElsewhere = 0) {
79
80
  var _a;
80
81
  return (seen.since > 0 &&
81
82
  file !== shown &&
82
83
  !entry.isStreaming &&
83
84
  entry.messageCount > 0 &&
84
- (entry.updatedAt > ((_a = seen.at[file]) !== null && _a !== void 0 ? _a : seen.since) || marked(seen, file)));
85
+ (entry.updatedAt > Math.max((_a = seen.at[file]) !== null && _a !== void 0 ? _a : seen.since, seenElsewhere) || marked(seen, file)));
85
86
  }
86
87
  ChatSeenUtil.unseen = unseen;
87
88
  /**
88
89
  * Whether any of the conversations the list shows (ChatListUtil.entries, those listed) said something unseen:
89
90
  * the dot on the tab of the chats. Only those: one the list leaves out (a package's, closed) has no row to find.
90
91
  */
91
- function anyUnseen(entries, seen, shown) {
92
+ function anyUnseen(entries, seen, shown, elsewhere) {
92
93
  return entries.some(entry => {
93
94
  var _a, _b;
94
95
  const file = (_b = (_a = entry.sessionFile) !== null && _a !== void 0 ? _a : entry.sessionId) !== null && _b !== void 0 ? _b : '';
95
- return !!file && unseen(entry, file, seen, shown);
96
+ return !!file && unseen(entry, file, seen, shown, elsewhere === null || elsewhere === void 0 ? void 0 : elsewhere.get(file));
96
97
  });
97
98
  }
98
99
  ChatSeenUtil.anyUnseen = anyUnseen;
@@ -0,0 +1,31 @@
1
+ import type { TaSavedSessionInfo, TaSessionInfo } from '@celljs/ta-protocol';
2
+ import type { TaWebExtensions, WebExtensionsState } from '../extension/web-extension-protocol';
3
+ import type { LetGoAsks } from './chat-asks';
4
+ import { type ChatEntry } from './chat-list-util';
5
+ import { type ChatSeen } from './chat-seen';
6
+ /** What the dot of the chats reads of the page. */
7
+ export interface ChatsDotInput {
8
+ sessions: readonly TaSessionInfo[];
9
+ saved: readonly TaSavedSessionInfo[];
10
+ removed: string[];
11
+ pinned: readonly string[];
12
+ letGo: LetGoAsks;
13
+ archiveDays: number;
14
+ seen: ChatSeen;
15
+ /** The conversation in front of the user, by its session id. */
16
+ looking?: string;
17
+ extensions: WebExtensionsState;
18
+ host: TaWebExtensions;
19
+ }
20
+ /**
21
+ * The amber dot of the chats' tab and of the double's entry on the rail, on while a row of the double's list has one,
22
+ * as a messenger's: a conversation it lists (those folded into a folder and the agents' too, but those quiet: a call),
23
+ * and, where the list is the double's, a row of its home, a conversation with a partner that is none of pi (a group
24
+ * chat, a chat of two) and a task that is no conversation. `listed`: the conversations it lists, which dragging the dot
25
+ * away sees; a row of the home or a partner's keeps its dot till it is opened, as on its row.
26
+ */
27
+ export declare function useChatsDot(input: ChatsDotInput): {
28
+ listed: ChatEntry[];
29
+ unseen: boolean;
30
+ };
31
+ //# sourceMappingURL=chats-dot.d.ts.map
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.useChatsDot = useChatsDot;
37
+ const React = __importStar(require("react"));
38
+ const partners_util_1 = require("../partners/partners-util");
39
+ const workbench_util_1 = require("../workbench-util");
40
+ const chat_home_util_1 = require("./chat-home-util");
41
+ const chat_icon_1 = require("./chat-icon");
42
+ const chat_list_util_1 = require("./chat-list-util");
43
+ const chat_seen_1 = require("./chat-seen");
44
+ const side_lists_1 = require("./side-lists");
45
+ /**
46
+ * The amber dot of the chats' tab and of the double's entry on the rail, on while a row of the double's list has one,
47
+ * as a messenger's: a conversation it lists (those folded into a folder and the agents' too, but those quiet: a call),
48
+ * and, where the list is the double's, a row of its home, a conversation with a partner that is none of pi (a group
49
+ * chat, a chat of two) and a task that is no conversation. `listed`: the conversations it lists, which dragging the dot
50
+ * away sees; a row of the home or a partner's keeps its dot till it is opened, as on its row.
51
+ */
52
+ function useChatsDot(input) {
53
+ const { sessions, saved, removed, pinned, letGo, archiveDays, seen, looking, extensions, host } = input;
54
+ const tasks = React.useSyncExternalStore(host.tasks.subscribe, host.tasks.tasks, host.tasks.tasks);
55
+ const items = React.useSyncExternalStore(host.home.subscribe, host.home.items, host.home.items);
56
+ const partners = React.useSyncExternalStore(host.partners.subscribe, host.partners.partners, host.partners.partners);
57
+ const doubleList = !side_lists_1.SideListUtil.viewListsDouble(extensions.views);
58
+ const partnerSessions = React.useMemo(() => (doubleList ? partners_util_1.PartnersUtil.sessions(partners) : undefined), [doubleList, partners]);
59
+ const icons = extensions.chatIcons;
60
+ const listed = React.useMemo(() => {
61
+ const now = Date.now();
62
+ return chat_list_util_1.ChatListUtil.entries([...sessions], [...saved], removed, undefined, workbench_util_1.WorkbenchUtil.daysAgo(now, archiveDays), chat_list_util_1.ChatListUtil.keptFiles(saved, pinned, letGo), chat_icon_1.ChatIconUtil.archiveSince(icons, now), chat_list_util_1.ChatListUtil.groupListed(chat_icon_1.ChatIconUtil.folderOf(icons), partnerSessions)).listed;
63
+ }, [sessions, saved, removed, archiveDays, pinned, letGo, icons, partnerSessions]);
64
+ const inFront = looking ? sessions.find(session => session.sessionId === looking) : undefined;
65
+ const said = chat_seen_1.ChatSeenUtil.anyUnseen(chat_icon_1.ChatIconUtil.loud(icons, listed), seen, inFront && chat_list_util_1.ChatListUtil.file(inFront), partnerSessions);
66
+ return { listed, unseen: said || (doubleList && chat_home_util_1.ChatHomeUtil.anyUnseen(items, partners, tasks, seen)) };
67
+ }
68
+ //# sourceMappingURL=chats-dot.js.map