@celljs/ta-web 4.26.0 → 4.27.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.
@@ -30,15 +30,17 @@ export declare function ChatDoubleItem({ home, counts, unseen, now }: {
30
30
  * or unpinned as a folder is. What it opens shows as a conversation of the list does, the row selected while its page
31
31
  * or the conversation it stands for is in front.
32
32
  */
33
- export declare function ChatHomeItem({ row, time, home, selected, pinned, onPin, }: {
33
+ export declare const ChatHomeItem: React.MemoExoticComponent<({ row, time, shown, openItem, selected, pinned, onPin, }: {
34
34
  row: ChatHomeRow;
35
35
  time: string;
36
- home: ChatHome;
36
+ /** Its page is in front (ChatHome.shownItem). */
37
+ shown: boolean;
38
+ openItem: ChatHome['openItem'];
37
39
  /** The conversation it stands for is shown (WebHomeItem.sessionFile). */
38
40
  selected: boolean;
39
41
  pinned: boolean;
40
- onPin(pinned: boolean): void;
41
- }): React.JSX.Element;
42
+ onPin(key: string, pinned: boolean): void;
43
+ }) => React.JSX.Element>;
42
44
  /** What a row of a task does to the double's home: marks it seen, deletes it. */
43
45
  export type ChatTaskHome = Pick<ChatHome, 'look' | 'remove'>;
44
46
  /**
@@ -47,7 +47,7 @@ export function ChatDoubleItem({ home, counts, unseen, now }) {
47
47
  * or unpinned as a folder is. What it opens shows as a conversation of the list does, the row selected while its page
48
48
  * or the conversation it stands for is in front.
49
49
  */
50
- export function ChatHomeItem({ row, time, home, selected, pinned, onPin, }) {
50
+ export const ChatHomeItem = React.memo(function ChatHomeItem({ row, time, shown, openItem, selected, pinned, onPin, }) {
51
51
  var _a;
52
52
  const t = useT();
53
53
  const [menu, openMenu] = useContextMenu();
@@ -55,20 +55,20 @@ export function ChatHomeItem({ row, time, home, selected, pinned, onPin, }) {
55
55
  const { item, partner } = row;
56
56
  if (partner) {
57
57
  // A partner's conversation: the row the partners draw it with.
58
- const opens = () => home.openItem(item);
59
- return React.createElement(PartnerRow, { partner: partner, time: time, selected: home.shownItem === partner.key, open: opens, pinned: pinned, onPin: onPin });
58
+ const opens = () => openItem(item);
59
+ return React.createElement(PartnerRow, { partner: partner, time: time, selected: shown, open: opens, pinned: pinned, onPin: pin => onPin(row.key, pin) });
60
60
  }
61
61
  const Glyph = item.icon;
62
62
  const Own = item.face;
63
63
  const open = () => {
64
64
  setOpening(true);
65
65
  void Promise.resolve()
66
- .then(() => home.openItem(item))
66
+ .then(() => openItem(item))
67
67
  .catch(error => console.error(`A row of the home of ${item.extension} failed:`, error))
68
68
  .finally(() => setOpening(false));
69
69
  };
70
- const pin = { label: t(pinned ? 'ta.chat.unpin' : 'ta.chat.pin'), run: () => onPin(!pinned) };
71
- const current = selected || home.shownItem === item.key;
70
+ const pin = { label: t(pinned ? 'ta.chat.unpin' : 'ta.chat.pin'), run: () => onPin(row.key, !pinned) };
71
+ const current = selected || shown;
72
72
  return (React.createElement(SwipeRow, { as: "li", className: `ta-chat-row ta-chat-home-item${current ? ' ta-selected' : ''}`, "data-row": row.key, "data-unseen": item.unseen ? '' : undefined, actions: [{ key: 'pin', ...pin }], overlay: menu, onContextMenu: event => openMenu(event, ContextMenuUtil.sections([{ label: t('ta.chat.open'), run: open }], [pin])) },
73
73
  React.createElement("button", { type: "button", className: "ta-chat-item", title: item.title, "aria-current": current ? 'true' : undefined, onClick: open },
74
74
  React.createElement("span", { className: "ta-chat-avatar-box" },
@@ -76,7 +76,7 @@ export function ChatHomeItem({ row, time, home, selected, pinned, onPin, }) {
76
76
  React.createElement(Own, { size: 38 }))) : (React.createElement("span", { className: "ta-chat-avatar ta-chat-icon", style: { background: `var(--ta-tint-${item.tone})`, color: `var(--ta-tint-ink-${item.tone})`, width: 38, height: 38 }, "aria-hidden": "true" }, opening ? React.createElement("span", { className: "ta-spinner" }) : React.createElement(Glyph, { size: 18, strokeWidth: 1.8 }))),
77
77
  React.createElement(ChatDot, { unseen: !!item.unseen, asks: false })),
78
78
  React.createElement(RowText, { title: item.title, time: time, line: (_a = item.detail) !== null && _a !== void 0 ? _a : '', unseen: item.unseen }))));
79
- }
79
+ });
80
80
  /**
81
81
  * A task of the double that is no conversation (a team), or one that waits for the user: who does it, what it is at,
82
82
  * when; a blue ? while it waits, an amber dot once it ended unseen. It opens in the main area, its conversation or its
@@ -25,15 +25,19 @@ export var ChatIconUtil;
25
25
  }
26
26
  let memo = remembered.get(entries);
27
27
  if ((memo === null || memo === void 0 ? void 0 : memo.generation) !== generation) {
28
- memo = { generation, found: new Map() };
28
+ memo = { generation, found: new Map(), byChat: new WeakMap() };
29
29
  remembered.set(entries, memo);
30
30
  }
31
- const key = `${(_a = chat.group) !== null && _a !== void 0 ? _a : ''}\n${chat.cwd}\n${(_b = chat.sessionFile) !== null && _b !== void 0 ? _b : ''}`;
32
- if (memo.found.has(key)) {
33
- return memo.found.get(key);
31
+ // The same info of a conversation, asked again by each list and dot as they draw: found without a key made.
32
+ if (memo.byChat.has(chat)) {
33
+ return memo.byChat.get(chat);
34
34
  }
35
- const found = ask(entries, { sessionFile: chat.sessionFile, cwd: chat.cwd, ...(chat.group ? { group: chat.group } : {}) });
35
+ const key = `${(_a = chat.group) !== null && _a !== void 0 ? _a : ''}\n${chat.cwd}\n${(_b = chat.sessionFile) !== null && _b !== void 0 ? _b : ''}`;
36
+ const found = memo.found.has(key)
37
+ ? memo.found.get(key)
38
+ : ask(entries, { sessionFile: chat.sessionFile, cwd: chat.cwd, ...(chat.group ? { group: chat.group } : {}) });
36
39
  memo.found.set(key, found);
40
+ memo.byChat.set(chat, found);
37
41
  return found;
38
42
  }
39
43
  ChatIconUtil.find = find;
@@ -33,10 +33,20 @@ page: string): void;
33
33
  /** A conversation that comes to the top, is pinned or let go slides to its place in the list and in a folder opened, as the others make room. */
34
34
  export declare function useChatListMotion(list: React.RefObject<HTMLElement | null>, folder: React.RefObject<HTMLElement | null>): void;
35
35
  /**
36
- * What the rows of tasks do (ChatTaskItem), the same function and object however often the list draws: a row draws
37
- * again as its task does, not as the list or the page around it does.
36
+ * What the rows do (ChatTaskItem, ChatHomeItem, ChatFolderItem), the same functions and object however often the list
37
+ * draws: a row draws again as what it shows does, not as the list or the page around it does.
38
38
  */
39
- export declare function useTaskRows(onPicked: () => void, home: ChatHome | undefined): {
40
- picked: () => void;
39
+ export declare function useRowCalls(given: {
40
+ onPicked(): void;
41
+ home: ChatHome | undefined;
42
+ openFolder(key: string, archived?: boolean): void;
43
+ pinned: readonly string[];
44
+ onPinned(pinned: string[]): void;
45
+ }): {
46
+ picked(): void;
41
47
  taskHome: ChatTaskHome;
48
+ openItem: ChatHome['openItem'];
49
+ openFolder(key: string, archived?: boolean): void;
50
+ /** Pins or unpins a conversation's file or a folder's key: the last pinned first, as several may be. */
51
+ pinKey(key: string, pin: boolean): void;
42
52
  };
@@ -85,18 +85,24 @@ export function useChatListMotion(list, folder) {
85
85
  useListMotion(folder);
86
86
  }
87
87
  /**
88
- * What the rows of tasks do (ChatTaskItem), the same function and object however often the list draws: a row draws
89
- * again as its task does, not as the list or the page around it does.
88
+ * What the rows do (ChatTaskItem, ChatHomeItem, ChatFolderItem), the same functions and object however often the list
89
+ * draws: a row draws again as what it shows does, not as the list or the page around it does.
90
90
  */
91
- export function useTaskRows(onPicked, home) {
92
- const latest = React.useRef({ onPicked, home });
93
- latest.current = { onPicked, home };
91
+ export function useRowCalls(given) {
92
+ const latest = React.useRef(given);
93
+ latest.current = given;
94
94
  return React.useMemo(() => ({
95
+ pinKey: (key, pin) => {
96
+ const others = latest.current.pinned.filter(other => other !== key);
97
+ latest.current.onPinned(pin ? [key, ...others] : others);
98
+ },
95
99
  picked: () => latest.current.onPicked(),
96
100
  taskHome: {
97
101
  look: (key, at) => { var _a; return (_a = latest.current.home) === null || _a === void 0 ? void 0 : _a.look(key, at); },
98
102
  remove: tasks => { var _a; return (_a = latest.current.home) === null || _a === void 0 ? void 0 : _a.remove(tasks); },
99
103
  },
104
+ openItem: entry => { var _a; var _b; return (_b = (_a = latest.current.home) === null || _a === void 0 ? void 0 : _a.openItem(entry)) !== null && _b !== void 0 ? _b : Promise.resolve(); },
105
+ openFolder: (key, archived) => latest.current.openFolder(key, archived),
100
106
  }), []);
101
107
  }
102
108
  //# sourceMappingURL=chat-list-hooks.js.map
@@ -80,7 +80,7 @@ export declare function ChatDot({ unseen, asks, onSee }: {
80
80
  * of it with what it said; a dot while one of them said something unseen, a spinner while one works. It opens the folder,
81
81
  * and is pinned as a conversation is: from its menu, or a swipe to the left on a phone.
82
82
  */
83
- export declare function ChatFolderItem({ folder, time, selected, unseen, pinned, onOpen, onPin, actions, }: {
83
+ interface ChatFolderProps {
84
84
  folder: ChatFolder;
85
85
  time: string;
86
86
  /** The conversation shown is in it. */
@@ -88,9 +88,12 @@ export declare function ChatFolderItem({ folder, time, selected, unseen, pinned,
88
88
  /** Those of it that said something unseen: its dot, which dragged away sees them all. */
89
89
  unseen: ChatEntry[];
90
90
  pinned: boolean;
91
- onOpen(): void;
92
- onPin(pinned: boolean): void;
91
+ /** It is of the archive. */
92
+ archived?: boolean;
93
+ onOpen(key: string, archived?: boolean): void;
94
+ onPin(key: string, pinned: boolean): void;
93
95
  actions: ChatRowActions;
94
- }): React.JSX.Element;
96
+ }
97
+ export declare const ChatFolderItem: React.MemoExoticComponent<({ folder, time, selected, unseen, pinned, archived, onOpen, onPin, actions, }: ChatFolderProps) => React.JSX.Element>;
95
98
  export declare const ChatItem: React.MemoExoticComponent<({ session, source, selected, time, compact, actions, restorable, task, doubleName, handable, pinned, unseen, asking, draft, }: ItemProps) => React.JSX.Element>;
96
99
  export {};
@@ -71,12 +71,23 @@ export function ChatDot({ unseen, asks, onSee }) {
71
71
  }
72
72
  return (React.createElement(UnseenDrop, { className: unseen ? 'ta-chat-dot ta-on' : 'ta-chat-dot', label: unseen ? t('ta.chat.unseen') : undefined, onDismiss: unseen ? onSee : undefined }));
73
73
  }
74
- /**
75
- * The row of a folder (WebChatIcon.folder), as a messenger folds its subscriptions: its icon, its title, and the latest
76
- * of it with what it said; a dot while one of them said something unseen, a spinner while one works. It opens the folder,
77
- * and is pinned as a conversation is: from its menu, or a swipe to the left on a phone.
78
- */
79
- export function ChatFolderItem({ folder, time, selected, unseen, pinned, onOpen, onPin, actions, }) {
74
+ /** Folders are made again as any conversation changes: one draws again only when what it shows of them does. */
75
+ function sameFolder(a, b) {
76
+ const same = (x, y) => x.length === y.length && x.every((one, i) => one === y[i]);
77
+ return (a.time === b.time &&
78
+ a.selected === b.selected &&
79
+ a.pinned === b.pinned &&
80
+ a.archived === b.archived &&
81
+ a.onOpen === b.onOpen &&
82
+ a.onPin === b.onPin &&
83
+ a.actions === b.actions &&
84
+ same(a.unseen, b.unseen) &&
85
+ a.folder.key === b.folder.key &&
86
+ a.folder.title === b.folder.title &&
87
+ a.folder.icon === b.folder.icon &&
88
+ same(a.folder.sessions, b.folder.sessions));
89
+ }
90
+ export const ChatFolderItem = React.memo(function ChatFolderItem({ folder, time, selected, unseen, pinned, archived, onOpen, onPin, actions, }) {
80
91
  const t = useT();
81
92
  const onSee = () => {
82
93
  for (const session of unseen) {
@@ -88,10 +99,11 @@ export function ChatFolderItem({ folder, time, selected, unseen, pinned, onOpen,
88
99
  const shown = ChatListUtil.preview(latest, latestTitle);
89
100
  const said = shown && SecretTextUtil.plain(t, shown);
90
101
  const working = folder.sessions.some(session => ChatListUtil.isOpen(session) && session.isStreaming);
91
- const pin = { label: t(pinned ? 'ta.chat.unpin' : 'ta.chat.pin'), run: () => onPin(!pinned) };
102
+ const pin = { label: t(pinned ? 'ta.chat.unpin' : 'ta.chat.pin'), run: () => onPin(folder.key, !pinned) };
103
+ const open = () => onOpen(folder.key, archived);
92
104
  const [menu, openMenu] = useContextMenu();
93
- return (React.createElement(SwipeRow, { as: "li", className: `ta-chat-row ta-chat-folder${selected ? ' ta-selected' : ''}`, "data-row": folder.key, "data-unseen": unseen.length > 0 ? '' : undefined, actions: [{ key: 'pin', ...pin }], overlay: menu, onContextMenu: event => openMenu(event, ContextMenuUtil.sections([{ label: t('ta.chat.open'), run: onOpen }], [pin])) },
94
- React.createElement("button", { type: "button", className: "ta-chat-item", title: `${folder.title} (${folder.sessions.length})`, "aria-current": selected ? 'true' : undefined, onClick: onOpen },
105
+ return (React.createElement(SwipeRow, { as: "li", className: `ta-chat-row ta-chat-folder${selected ? ' ta-selected' : ''}`, "data-row": folder.key, "data-unseen": unseen.length > 0 ? '' : undefined, actions: [{ key: 'pin', ...pin }], overlay: menu, onContextMenu: event => openMenu(event, ContextMenuUtil.sections([{ label: t('ta.chat.open'), run: open }], [pin])) },
106
+ React.createElement("button", { type: "button", className: "ta-chat-item", title: `${folder.title} (${folder.sessions.length})`, "aria-current": selected ? 'true' : undefined, onClick: open },
95
107
  React.createElement("span", { className: "ta-chat-avatar-box" },
96
108
  React.createElement(ChatIconTile, { found: folder.icon, size: 38 }),
97
109
  React.createElement(ChatDot, { unseen: unseen.length > 0, asks: false, onSee: onSee })),
@@ -102,7 +114,7 @@ export function ChatFolderItem({ folder, time, selected, unseen, pinned, onOpen,
102
114
  React.createElement("span", { className: "ta-chat-line" },
103
115
  React.createElement("span", { className: `ta-chat-sub${unseen.length > 0 ? ' ta-unseen' : ''}` }, said ? t('ta.chat.folderLatest', { title: latestTitle, said }) : latestTitle),
104
116
  working && React.createElement("span", { className: "ta-chat-state ta-spinner" }))))));
105
- }
117
+ }, sameFolder);
106
118
  export const ChatItem = React.memo(function ChatItem({ session, source, selected, time, compact, actions, restorable, task, doubleName, handable, pinned, unseen, asking, draft, }) {
107
119
  var _a;
108
120
  const t = useT();
@@ -14,7 +14,7 @@ import { ChatBusyUtil } from './chat-busy.js';
14
14
  import { ChatHomeItem, ChatHomeTop, ChatTaskItem } from './chat-home.js';
15
15
  import { ChatHomeUtil } from './chat-home-util.js';
16
16
  import { ChatIconTile, ChatIconUtil } from './chat-icon.js';
17
- import { useChatListMotion, useMinute, useOfferPins, usePageEnd, useReadArchive, useTaskRows } from './chat-list-hooks.js';
17
+ import { useChatListMotion, useMinute, useOfferPins, usePageEnd, useReadArchive, useRowCalls } from './chat-list-hooks.js';
18
18
  import { ChatFolderItem, ChatItem } from './chat-list-row.js';
19
19
  import { CHAT_PAGE, ChatListUtil } from './chat-list-util.js';
20
20
  import { EmptyState } from './empty-state.js';
@@ -52,12 +52,7 @@ export function ChatList({ sessions, saved, removed: removedFiles, archived: arc
52
52
  const sessionMenus = React.useContext(SessionMenus);
53
53
  const latest = React.useRef({ chat, double, onPicked, t, pinned, onPinned, sessionMenus, onLetGo, onUnseen });
54
54
  latest.current = { chat, double, onPicked, t, pinned, onPinned, sessionMenus, onLetGo, onUnseen };
55
- const { picked, taskHome } = useTaskRows(onPicked, home);
56
- // The last pinned first, as several may be: a conversation's file, a folder's key.
57
- const pinKey = React.useCallback((key, pin) => {
58
- const others = latest.current.pinned.filter(other => other !== key);
59
- latest.current.onPinned(pin ? [key, ...others] : others);
60
- }, []);
55
+ const { picked, taskHome, openItem, openFolder: opensFolder, pinKey } = useRowCalls({ onPicked, home, openFolder, pinned, onPinned });
61
56
  const actions = React.useMemo(() => {
62
57
  const pick = (change) => {
63
58
  void change;
@@ -234,7 +229,7 @@ export function ChatList({ sessions, saved, removed: removedFiles, archived: arc
234
229
  });
235
230
  // Into a folder from the top of its list, and back where the list was left.
236
231
  const listScroll = React.useRef(0);
237
- const openFolder = (key, archived) => {
232
+ function openFolder(key, archived) {
238
233
  var _a;
239
234
  var _b;
240
235
  listScroll.current = (_b = (_a = scroller.current) === null || _a === void 0 ? void 0 : _a.scrollTop) !== null && _b !== void 0 ? _b : 0;
@@ -244,7 +239,7 @@ export function ChatList({ sessions, saved, removed: removedFiles, archived: arc
244
239
  if (!archivedSaved && pinned.includes(key)) {
245
240
  readArchive();
246
241
  }
247
- };
242
+ }
248
243
  const closeFolder = () => {
249
244
  setFolderShown(current => (handheld && current ? { ...current, open: false } : undefined));
250
245
  setQuery('');
@@ -269,9 +264,9 @@ export function ChatList({ sessions, saved, removed: removedFiles, archived: arc
269
264
  setFolderShown(undefined);
270
265
  }
271
266
  }, [folderShown, folder]);
272
- const folderItem = (row, archived) => (React.createElement(ChatFolderItem, { key: row.key, folder: row, time: ChatListUtil.clock(row.updatedAt, now), selected: row.sessions.some(isSelected), unseen: row.sessions.filter(isUnseen), pinned: pinnedKeys.has(row.key), onOpen: () => openFolder(row.key, archived), onPin: pin => pinKey(row.key, pin), actions: actions }));
267
+ const folderItem = (row, archived) => (React.createElement(ChatFolderItem, { key: row.key, folder: row, time: ChatListUtil.clock(row.updatedAt, now), selected: row.sessions.some(isSelected), unseen: row.sessions.filter(isUnseen), pinned: pinnedKeys.has(row.key), archived: archived, onOpen: opensFolder, onPin: pinKey, actions: actions }));
273
268
  const taskItem = (row) => home && (React.createElement(ChatTaskItem, { key: row.key, task: row.task, home: taskHome, unseen: taskUnseen(row.task), time: ChatListUtil.clock(row.updatedAt, now), onPicked: picked }));
274
- const homeItem = (row) => { var _a; return home && (React.createElement(ChatHomeItem, { key: row.key, row: row, time: row.updatedAt ? ChatListUtil.clock(row.updatedAt, now) : '', home: home, selected: !!row.item.sessionFile && isSelected((_a = byFile.get(row.item.sessionFile)) !== null && _a !== void 0 ? _a : row.item.sessionFile), pinned: pinnedKeys.has(row.key), onPin: pin => pinKey(row.key, pin) })); };
269
+ const homeItem = (row) => { var _a; var _b, _c; return home && (React.createElement(ChatHomeItem, { key: row.key, row: row, time: row.updatedAt ? ChatListUtil.clock(row.updatedAt, now) : '', shown: home.shownItem === ((_b = (_a = row.partner) === null || _a === void 0 ? void 0 : _a.key) !== null && _b !== void 0 ? _b : row.item.key), openItem: openItem, selected: !!row.item.sessionFile && isSelected((_c = byFile.get(row.item.sessionFile)) !== null && _c !== void 0 ? _c : row.item.sessionFile), pinned: pinnedKeys.has(row.key), onPin: pinKey })); };
275
270
  const rowItem = (row, compact) => ChatListUtil.isFolder(row) ? folderItem(row) : ChatListUtil.isTask(row) ? taskItem(row) : ChatListUtil.isHome(row) ? homeItem(row) : item(row, compact);
276
271
  // The conversation shown is found in the list, however it came to be shown: out of a search that hides it, and scrolled to.
277
272
  const scroller = React.useRef(null);
@@ -10,12 +10,16 @@ const BLEND = 0.45;
10
10
  const FOLLOW = 0.18;
11
11
  /** From how many pixels on a ta is drawn in full detail. */
12
12
  const FINE = 48;
13
+ /** How often where a ta is on the page is read again for it to look at the pointer, in milliseconds: reading it lays the page out. */
14
+ const BOX_MS = 200;
13
15
  /** The whole dinosaur's viewBox: its left and top edge, and its width. */
14
16
  const WHOLE = [-8, -8, 272];
15
17
  export const DinoLook = React.createContext({ species: DinoSpecies.DEFAULT, gait: 'walk' });
16
18
  /** One loop of animation frames for every ta on the page; only those on screen move, and none when motion is reduced. */
17
19
  const players = new Set();
18
20
  let loop = 0;
21
+ /** Counts the frames: a small ta (of a row, a few dozen pixels) moves every other one, which nobody can tell at its size. */
22
+ let frames = 0;
19
23
  let watcher;
20
24
  /** Where the mouse is on the page; undefined when it is off the page or the device has none. */
21
25
  let pointer;
@@ -80,10 +84,20 @@ function draw(player, now) {
80
84
  player.pose = pose;
81
85
  const f = frame(pose, player.fine, player.species);
82
86
  const svg = player.svg;
87
+ // Drawn sixty times a second for each ta on screen: its parts are looked up once, until its markup changes.
88
+ if (player.partsOf !== svg.firstChild) {
89
+ player.parts.clear();
90
+ player.partsOf = svg.firstChild;
91
+ }
83
92
  const set = (part, name, value) => {
84
- const element = svg.querySelector(`.ta-dino-${part}`);
85
- if (element && element.getAttribute(name) !== value) {
86
- element.setAttribute(name, value);
93
+ let found = player.parts.get(part);
94
+ if (!found) {
95
+ found = { element: svg.querySelector(`.ta-dino-${part}`), values: new Map() };
96
+ player.parts.set(part, found);
97
+ }
98
+ if (found.element && found.values.get(name) !== value) {
99
+ found.values.set(name, value);
100
+ found.element.setAttribute(name, value);
87
101
  }
88
102
  };
89
103
  set('skin', 'd', f.skin);
@@ -125,15 +139,27 @@ function tick(now) {
125
139
  }
126
140
  // Still while the page scrolls: a frame of a fling is the scroll's.
127
141
  if (ScrollRest.moving(now)) {
142
+ // Where they are is read again once it rests.
143
+ for (const player of players) {
144
+ player.box = undefined;
145
+ }
128
146
  loop = requestAnimationFrame(tick);
129
147
  return;
130
148
  }
131
- // Read where they all are first, then draw them all, so the page is laid out once a frame.
149
+ // Read where they all are first, then draw them all, so the page is laid out once a frame at most; and
150
+ // only now and then, as reading it lays out what the page changed since (a list drawn again, a reply).
132
151
  for (const player of players) {
133
- player.box = player.visible && pointer ? player.svg.getBoundingClientRect() : undefined;
152
+ if (!player.visible || !pointer) {
153
+ player.box = undefined;
154
+ }
155
+ else if (!player.box || now - player.boxedAt >= BOX_MS) {
156
+ player.box = player.svg.getBoundingClientRect();
157
+ player.boxedAt = now;
158
+ }
134
159
  }
160
+ frames++;
135
161
  for (const player of players) {
136
- if (player.visible) {
162
+ if (player.visible && (player.fine || frames % 2 === 0)) {
137
163
  draw(player, now);
138
164
  }
139
165
  }
@@ -223,6 +249,8 @@ function usePlayer(svg, { mood, size, roam, species, gait, face }) {
223
249
  look: { x: 0, y: 0, weight: 0 },
224
250
  last: now,
225
251
  poked: -Infinity,
252
+ boxedAt: -Infinity,
253
+ parts: new Map(),
226
254
  };
227
255
  }, [mood, roam, size, species, gait, face]);
228
256
  React.useEffect(() => {
@@ -12,6 +12,8 @@ export declare namespace HostUtil {
12
12
  const KEY = "ta.hosts";
13
13
  /** The list kept, without what is not a host (kept by hand, or by an older version). */
14
14
  function read(text: string | null | undefined): HostList;
15
+ /** An entry of the computer `account` of the account other than `id`: one scanned before it joined, or a Ta in the cloud reached by its gateway. */
16
+ function other(list: HostList, id: string, account: string): SavedHost | undefined;
15
17
  /** `id` signed in to with `credential`, now in use: a new one goes last, one known keeps its place and name. */
16
18
  function use(list: HostList, id: string, credential: Credential, now: number, server?: SavedHost['server']): HostList;
17
19
  /**
@@ -16,11 +16,30 @@ export var HostUtil;
16
16
  catch (_a) {
17
17
  kept = undefined;
18
18
  }
19
- const hosts = Array.isArray(kept === null || kept === void 0 ? void 0 : kept.hosts) ? kept.hosts.map(host).filter((one) => one !== undefined) : [];
20
- const current = hosts.some(one => one.id === (kept === null || kept === void 0 ? void 0 : kept.current)) ? kept === null || kept === void 0 ? void 0 : kept.current : undefined;
21
- return { current, hosts };
19
+ const all = Array.isArray(kept === null || kept === void 0 ? void 0 : kept.hosts) ? kept.hosts.map(host).filter((one) => one !== undefined) : [];
20
+ const current = all.some(one => one.id === (kept === null || kept === void 0 ? void 0 : kept.current)) ? kept === null || kept === void 0 ? void 0 : kept.current : undefined;
21
+ return { current, hosts: oneEach(all, current) };
22
22
  }
23
23
  HostUtil.read = read;
24
+ /**
25
+ * A computer of the account is one entry: of two kept for it (scanned, then brought by the account, by a version
26
+ * before), the one in use, else the one used last.
27
+ */
28
+ function oneEach(hosts, current) {
29
+ const chosen = new Map();
30
+ for (const one of hosts) {
31
+ const other = one.account ? chosen.get(one.account) : undefined;
32
+ if (one.account && (!other || (other.id !== current && (one.id === current || one.usedAt > other.usedAt)))) {
33
+ chosen.set(one.account, one);
34
+ }
35
+ }
36
+ return hosts.filter(one => !one.account || chosen.get(one.account) === one);
37
+ }
38
+ /** An entry of the computer `account` of the account other than `id`: one scanned before it joined, or a Ta in the cloud reached by its gateway. */
39
+ function other(list, id, account) {
40
+ return list.hosts.find(one => one.account === account && one.id !== id);
41
+ }
42
+ HostUtil.other = other;
24
43
  function host(value) {
25
44
  const kept = value;
26
45
  const credential = kept && typeof kept === 'object' ? readCredential(kept.credential) : undefined;
@@ -30,12 +30,12 @@ export class WorkbenchHosts extends WorkbenchLists {
30
30
  * used at once when none is.
31
31
  */
32
32
  async addAccountHost(link, account) {
33
- // One reached directly already (a Ta in the cloud, by its gateway): not a second entry through the relay.
34
- if (this.list.hosts.some(one => one.account === account && 'token' in one.credential)) {
35
- return;
36
- }
37
33
  const credential = WorkbenchUtil.credential(link);
38
34
  const id = WorkbenchUtil.serverOf(credential, pageHost());
35
+ // Kept already another way (scanned before it joined the account, a Ta in the cloud by its gateway): not a second entry.
36
+ if (HostUtil.other(this.list, id, account)) {
37
+ return;
38
+ }
39
39
  if (this.current.status === 'signed-out' && !this.list.current) {
40
40
  this.keepHosts(HostUtil.keep(this.list, id, credential, account, Date.now()));
41
41
  await this.signIn(credential);
@@ -44,6 +44,10 @@ export class WorkbenchHosts extends WorkbenchLists {
44
44
  this.keepHosts(HostUtil.keep(this.list, id, credential, account, Date.now()));
45
45
  }
46
46
  markAccountHost(hostId, account) {
47
+ // The way the account brought to the same computer before: the one scanned and in use is kept alone.
48
+ for (let other = HostUtil.other(this.list, hostId, account); other; other = HostUtil.other(this.list, hostId, account)) {
49
+ this.drop(other.id);
50
+ }
47
51
  this.keepHosts({ ...this.list, hosts: this.list.hosts.map(one => (one.id === hostId ? { ...one, account } : one)) });
48
52
  }
49
53
  /** The computers the account brought: those of `account`, or all of them when the device left the account. */
@@ -1,5 +1,5 @@
1
1
  import { SessionStore, type SessionStoreOptions, type TaConnection } from '@celljs/ta-client';
2
- import type { TaSessionInfo } from '@celljs/ta-protocol';
2
+ import { type TaSavedSessionInfo, type TaSessionInfo } from '@celljs/ta-protocol';
3
3
  import type { WorkbenchState } from './workbench-protocol.js';
4
4
  import { WorkbenchServices } from './workbench-services.js';
5
5
  /** The lists of the sessions of the computer, open, saved and archived, read and kept on the device. */
@@ -14,6 +14,16 @@ export declare abstract class WorkbenchLists extends WorkbenchServices {
14
14
  protected archivedSince?: number;
15
15
  /** Counts the lists of open sessions the server told: a read of the lists begun before one does not undo it. */
16
16
  protected pushes: number;
17
+ /**
18
+ * The saved conversations as last read, with the version the server gave them (listSavedSessionChanges) and
19
+ * the connection they were read on: the next read is of what changed since. Unset for a Ta service of before.
20
+ */
21
+ protected savedRead?: {
22
+ connection: TaConnection | undefined;
23
+ version: string;
24
+ list: TaSavedSessionInfo[];
25
+ };
26
+ protected savedChanges: boolean;
17
27
  listOpened(info: TaSessionInfo): void;
18
28
  /**
19
29
  * One read of the lists at a time: asked again meanwhile, one more follows it for all who asked, so that
@@ -21,6 +31,11 @@ export declare abstract class WorkbenchLists extends WorkbenchServices {
21
31
  */
22
32
  refresh(): Promise<void>;
23
33
  protected readLists(): Promise<void>;
34
+ /**
35
+ * The saved conversations updated `since`: only what changed since the last read comes, not hundreds of them
36
+ * each time a conversation opens or the lists are read again.
37
+ */
38
+ protected readSaved(since: number | undefined): Promise<TaSavedSessionInfo[]>;
24
39
  setArchiveDays(days: number): void;
25
40
  readArchived(): Promise<void>;
26
41
  createStore(sessionId: string, options?: SessionStoreOptions): SessionStore;
@@ -1,4 +1,5 @@
1
1
  import { SessionStore, TaRemoteError } from '@celljs/ta-client';
2
+ import { TaSavedSessionUtil } from '@celljs/ta-protocol';
2
3
  import { DEFAULT_SETTINGS } from './settings/settings-protocol.js';
3
4
  import { WorkbenchServices } from './workbench-services.js';
4
5
  import { PAGE_BYTES, storage, WorkbenchUtil } from './workbench-util.js';
@@ -10,6 +11,7 @@ export class WorkbenchLists extends WorkbenchServices {
10
11
  this.archiveDays = DEFAULT_SETTINGS.chatArchiveDays;
11
12
  /** Counts the lists of open sessions the server told: a read of the lists begun before one does not undo it. */
12
13
  this.pushes = 0;
14
+ this.savedChanges = true;
13
15
  }
14
16
  listOpened(info) {
15
17
  if (this.current.sessions.some(session => session.sessionId === info.sessionId)) {
@@ -40,6 +42,7 @@ export class WorkbenchLists extends WorkbenchServices {
40
42
  return this.refreshAgain;
41
43
  }
42
44
  async readLists() {
45
+ var _a;
43
46
  const pushes = this.pushes;
44
47
  // A ta serve of before has no saved sessions to list: its list stays the open ones. The default
45
48
  // directory comes along, as another device may have changed it. The archived are left out: a list
@@ -47,23 +50,55 @@ export class WorkbenchLists extends WorkbenchServices {
47
50
  const since = WorkbenchUtil.daysAgo(Date.now(), this.archiveDays);
48
51
  const [sessions, saved, server] = await Promise.all([
49
52
  this.server.listSessions(),
50
- this.server.listSavedSessions(since === undefined ? undefined : { since }).catch(() => []),
53
+ this.readSaved(since).catch(() => []),
51
54
  this.server.getServerInfo().catch(() => this.current.server),
52
55
  ]);
53
56
  // A ta serve of before lists them all.
54
- const recent = since === undefined ? saved : saved.filter(session => session.updatedAt >= since);
57
+ const recent = since === undefined || saved.every(session => session.updatedAt >= since) ? saved : saved.filter(session => session.updatedAt >= since);
55
58
  // Read every few seconds and mostly the same: what shows them is not drawn again for nothing. A list
56
59
  // the server told meanwhile is newer than this one, read before it.
57
60
  this.update({
58
61
  sessions: pushes === this.pushes ? WorkbenchUtil.same(this.current.sessions, WorkbenchUtil.sorted(sessions)) : this.current.sessions,
59
- saved: WorkbenchUtil.same(this.current.saved, recent),
62
+ saved: recent === this.current.saved ? recent : WorkbenchUtil.same(this.current.saved, recent),
60
63
  server: WorkbenchUtil.same(this.current.server, server),
61
64
  });
65
+ if (((_a = this.savedRead) === null || _a === void 0 ? void 0 : _a.list) === saved) {
66
+ // Unchanged next time, the list shown is not compared again.
67
+ this.savedRead.list = this.current.saved;
68
+ }
62
69
  // A day later, those that just grew old are in the archive read, not lost between the two lists.
63
70
  if (this.current.archived && this.archivedSince !== since) {
64
71
  void this.readArchived().catch(() => undefined);
65
72
  }
66
73
  }
74
+ /**
75
+ * The saved conversations updated `since`: only what changed since the last read comes, not hundreds of them
76
+ * each time a conversation opens or the lists are read again.
77
+ */
78
+ async readSaved(since) {
79
+ var _a;
80
+ var _b;
81
+ const query = since === undefined ? undefined : { since };
82
+ const connection = this.connection;
83
+ if (this.savedChanges) {
84
+ try {
85
+ const before = ((_a = this.savedRead) === null || _a === void 0 ? void 0 : _a.connection) === connection ? this.savedRead : undefined;
86
+ const changes = await this.server.listSavedSessionChanges(query, before === null || before === void 0 ? void 0 : before.version);
87
+ const unchanged = before && !changes.whole && changes.version === before.version;
88
+ const list = unchanged ? before.list : TaSavedSessionUtil.apply((_b = before === null || before === void 0 ? void 0 : before.list) !== null && _b !== void 0 ? _b : [], changes);
89
+ this.savedRead = { connection, version: changes.version, list };
90
+ return list;
91
+ }
92
+ catch (error) {
93
+ if (!TaRemoteError.isMethodNotFound(error)) {
94
+ throw error;
95
+ }
96
+ this.savedChanges = false;
97
+ this.savedRead = undefined;
98
+ }
99
+ }
100
+ return this.server.listSavedSessions(query);
101
+ }
67
102
  setArchiveDays(days) {
68
103
  if (days === this.archiveDays) {
69
104
  return;
@@ -30,15 +30,17 @@ export declare function ChatDoubleItem({ home, counts, unseen, now }: {
30
30
  * or unpinned as a folder is. What it opens shows as a conversation of the list does, the row selected while its page
31
31
  * or the conversation it stands for is in front.
32
32
  */
33
- export declare function ChatHomeItem({ row, time, home, selected, pinned, onPin, }: {
33
+ export declare const ChatHomeItem: React.MemoExoticComponent<({ row, time, shown, openItem, selected, pinned, onPin, }: {
34
34
  row: ChatHomeRow;
35
35
  time: string;
36
- home: ChatHome;
36
+ /** Its page is in front (ChatHome.shownItem). */
37
+ shown: boolean;
38
+ openItem: ChatHome['openItem'];
37
39
  /** The conversation it stands for is shown (WebHomeItem.sessionFile). */
38
40
  selected: boolean;
39
41
  pinned: boolean;
40
- onPin(pinned: boolean): void;
41
- }): React.JSX.Element;
42
+ onPin(key: string, pinned: boolean): void;
43
+ }) => React.JSX.Element>;
42
44
  /** What a row of a task does to the double's home: marks it seen, deletes it. */
43
45
  export type ChatTaskHome = Pick<ChatHome, 'look' | 'remove'>;
44
46
  /**
@@ -33,10 +33,9 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ChatTaskItem = void 0;
36
+ exports.ChatTaskItem = exports.ChatHomeItem = void 0;
37
37
  exports.RowText = RowText;
38
38
  exports.ChatDoubleItem = ChatDoubleItem;
39
- exports.ChatHomeItem = ChatHomeItem;
40
39
  exports.ChatHomeTop = ChatHomeTop;
41
40
  const React = __importStar(require("react"));
42
41
  const task_views_1 = require("../assistant/task-views");
@@ -87,7 +86,7 @@ function ChatDoubleItem({ home, counts, unseen, now }) {
87
86
  * or unpinned as a folder is. What it opens shows as a conversation of the list does, the row selected while its page
88
87
  * or the conversation it stands for is in front.
89
88
  */
90
- function ChatHomeItem({ row, time, home, selected, pinned, onPin, }) {
89
+ exports.ChatHomeItem = React.memo(function ChatHomeItem({ row, time, shown, openItem, selected, pinned, onPin, }) {
91
90
  var _a;
92
91
  const t = (0, use_t_1.useT)();
93
92
  const [menu, openMenu] = (0, context_menu_1.useContextMenu)();
@@ -95,20 +94,20 @@ function ChatHomeItem({ row, time, home, selected, pinned, onPin, }) {
95
94
  const { item, partner } = row;
96
95
  if (partner) {
97
96
  // A partner's conversation: the row the partners draw it with.
98
- const opens = () => home.openItem(item);
99
- return React.createElement(partner_row_1.PartnerRow, { partner: partner, time: time, selected: home.shownItem === partner.key, open: opens, pinned: pinned, onPin: onPin });
97
+ const opens = () => openItem(item);
98
+ return React.createElement(partner_row_1.PartnerRow, { partner: partner, time: time, selected: shown, open: opens, pinned: pinned, onPin: pin => onPin(row.key, pin) });
100
99
  }
101
100
  const Glyph = item.icon;
102
101
  const Own = item.face;
103
102
  const open = () => {
104
103
  setOpening(true);
105
104
  void Promise.resolve()
106
- .then(() => home.openItem(item))
105
+ .then(() => openItem(item))
107
106
  .catch(error => console.error(`A row of the home of ${item.extension} failed:`, error))
108
107
  .finally(() => setOpening(false));
109
108
  };
110
- const pin = { label: t(pinned ? 'ta.chat.unpin' : 'ta.chat.pin'), run: () => onPin(!pinned) };
111
- const current = selected || home.shownItem === item.key;
109
+ const pin = { label: t(pinned ? 'ta.chat.unpin' : 'ta.chat.pin'), run: () => onPin(row.key, !pinned) };
110
+ const current = selected || shown;
112
111
  return (React.createElement(swipe_row_1.SwipeRow, { as: "li", className: `ta-chat-row ta-chat-home-item${current ? ' ta-selected' : ''}`, "data-row": row.key, "data-unseen": item.unseen ? '' : undefined, actions: [{ key: 'pin', ...pin }], overlay: menu, onContextMenu: event => openMenu(event, context_menu_1.ContextMenuUtil.sections([{ label: t('ta.chat.open'), run: open }], [pin])) },
113
112
  React.createElement("button", { type: "button", className: "ta-chat-item", title: item.title, "aria-current": current ? 'true' : undefined, onClick: open },
114
113
  React.createElement("span", { className: "ta-chat-avatar-box" },
@@ -116,7 +115,7 @@ function ChatHomeItem({ row, time, home, selected, pinned, onPin, }) {
116
115
  React.createElement(Own, { size: 38 }))) : (React.createElement("span", { className: "ta-chat-avatar ta-chat-icon", style: { background: `var(--ta-tint-${item.tone})`, color: `var(--ta-tint-ink-${item.tone})`, width: 38, height: 38 }, "aria-hidden": "true" }, opening ? React.createElement("span", { className: "ta-spinner" }) : React.createElement(Glyph, { size: 18, strokeWidth: 1.8 }))),
117
116
  React.createElement(chat_list_row_1.ChatDot, { unseen: !!item.unseen, asks: false })),
118
117
  React.createElement(RowText, { title: item.title, time: time, line: (_a = item.detail) !== null && _a !== void 0 ? _a : '', unseen: item.unseen }))));
119
- }
118
+ });
120
119
  /**
121
120
  * A task of the double that is no conversation (a team), or one that waits for the user: who does it, what it is at,
122
121
  * when; a blue ? while it waits, an amber dot once it ended unseen. It opens in the main area, its conversation or its
@@ -64,15 +64,19 @@ var ChatIconUtil;
64
64
  }
65
65
  let memo = remembered.get(entries);
66
66
  if ((memo === null || memo === void 0 ? void 0 : memo.generation) !== generation) {
67
- memo = { generation, found: new Map() };
67
+ memo = { generation, found: new Map(), byChat: new WeakMap() };
68
68
  remembered.set(entries, memo);
69
69
  }
70
- const key = `${(_a = chat.group) !== null && _a !== void 0 ? _a : ''}\n${chat.cwd}\n${(_b = chat.sessionFile) !== null && _b !== void 0 ? _b : ''}`;
71
- if (memo.found.has(key)) {
72
- return memo.found.get(key);
70
+ // The same info of a conversation, asked again by each list and dot as they draw: found without a key made.
71
+ if (memo.byChat.has(chat)) {
72
+ return memo.byChat.get(chat);
73
73
  }
74
- const found = ask(entries, { sessionFile: chat.sessionFile, cwd: chat.cwd, ...(chat.group ? { group: chat.group } : {}) });
74
+ const key = `${(_a = chat.group) !== null && _a !== void 0 ? _a : ''}\n${chat.cwd}\n${(_b = chat.sessionFile) !== null && _b !== void 0 ? _b : ''}`;
75
+ const found = memo.found.has(key)
76
+ ? memo.found.get(key)
77
+ : ask(entries, { sessionFile: chat.sessionFile, cwd: chat.cwd, ...(chat.group ? { group: chat.group } : {}) });
75
78
  memo.found.set(key, found);
79
+ memo.byChat.set(chat, found);
76
80
  return found;
77
81
  }
78
82
  ChatIconUtil.find = find;
@@ -33,11 +33,21 @@ page: string): void;
33
33
  /** A conversation that comes to the top, is pinned or let go slides to its place in the list and in a folder opened, as the others make room. */
34
34
  export declare function useChatListMotion(list: React.RefObject<HTMLElement | null>, folder: React.RefObject<HTMLElement | null>): void;
35
35
  /**
36
- * What the rows of tasks do (ChatTaskItem), the same function and object however often the list draws: a row draws
37
- * again as its task does, not as the list or the page around it does.
36
+ * What the rows do (ChatTaskItem, ChatHomeItem, ChatFolderItem), the same functions and object however often the list
37
+ * draws: a row draws again as what it shows does, not as the list or the page around it does.
38
38
  */
39
- export declare function useTaskRows(onPicked: () => void, home: ChatHome | undefined): {
40
- picked: () => void;
39
+ export declare function useRowCalls(given: {
40
+ onPicked(): void;
41
+ home: ChatHome | undefined;
42
+ openFolder(key: string, archived?: boolean): void;
43
+ pinned: readonly string[];
44
+ onPinned(pinned: string[]): void;
45
+ }): {
46
+ picked(): void;
41
47
  taskHome: ChatTaskHome;
48
+ openItem: ChatHome['openItem'];
49
+ openFolder(key: string, archived?: boolean): void;
50
+ /** Pins or unpins a conversation's file or a folder's key: the last pinned first, as several may be. */
51
+ pinKey(key: string, pin: boolean): void;
42
52
  };
43
53
  //# sourceMappingURL=chat-list-hooks.d.ts.map
@@ -38,7 +38,7 @@ exports.useReadArchive = useReadArchive;
38
38
  exports.useMinute = useMinute;
39
39
  exports.usePageEnd = usePageEnd;
40
40
  exports.useChatListMotion = useChatListMotion;
41
- exports.useTaskRows = useTaskRows;
41
+ exports.useRowCalls = useRowCalls;
42
42
  const react_1 = require("@celljs/react");
43
43
  const React = __importStar(require("react"));
44
44
  const state_protocol_1 = require("../state/state-protocol");
@@ -126,18 +126,24 @@ function useChatListMotion(list, folder) {
126
126
  (0, list_motion_1.useListMotion)(folder);
127
127
  }
128
128
  /**
129
- * What the rows of tasks do (ChatTaskItem), the same function and object however often the list draws: a row draws
130
- * again as its task does, not as the list or the page around it does.
129
+ * What the rows do (ChatTaskItem, ChatHomeItem, ChatFolderItem), the same functions and object however often the list
130
+ * draws: a row draws again as what it shows does, not as the list or the page around it does.
131
131
  */
132
- function useTaskRows(onPicked, home) {
133
- const latest = React.useRef({ onPicked, home });
134
- latest.current = { onPicked, home };
132
+ function useRowCalls(given) {
133
+ const latest = React.useRef(given);
134
+ latest.current = given;
135
135
  return React.useMemo(() => ({
136
+ pinKey: (key, pin) => {
137
+ const others = latest.current.pinned.filter(other => other !== key);
138
+ latest.current.onPinned(pin ? [key, ...others] : others);
139
+ },
136
140
  picked: () => latest.current.onPicked(),
137
141
  taskHome: {
138
142
  look: (key, at) => { var _a; return (_a = latest.current.home) === null || _a === void 0 ? void 0 : _a.look(key, at); },
139
143
  remove: tasks => { var _a; return (_a = latest.current.home) === null || _a === void 0 ? void 0 : _a.remove(tasks); },
140
144
  },
145
+ openItem: entry => { var _a; var _b; return (_b = (_a = latest.current.home) === null || _a === void 0 ? void 0 : _a.openItem(entry)) !== null && _b !== void 0 ? _b : Promise.resolve(); },
146
+ openFolder: (key, archived) => latest.current.openFolder(key, archived),
141
147
  }), []);
142
148
  }
143
149
  //# sourceMappingURL=chat-list-hooks.js.map
@@ -80,7 +80,7 @@ export declare function ChatDot({ unseen, asks, onSee }: {
80
80
  * of it with what it said; a dot while one of them said something unseen, a spinner while one works. It opens the folder,
81
81
  * and is pinned as a conversation is: from its menu, or a swipe to the left on a phone.
82
82
  */
83
- export declare function ChatFolderItem({ folder, time, selected, unseen, pinned, onOpen, onPin, actions, }: {
83
+ interface ChatFolderProps {
84
84
  folder: ChatFolder;
85
85
  time: string;
86
86
  /** The conversation shown is in it. */
@@ -88,10 +88,13 @@ export declare function ChatFolderItem({ folder, time, selected, unseen, pinned,
88
88
  /** Those of it that said something unseen: its dot, which dragged away sees them all. */
89
89
  unseen: ChatEntry[];
90
90
  pinned: boolean;
91
- onOpen(): void;
92
- onPin(pinned: boolean): void;
91
+ /** It is of the archive. */
92
+ archived?: boolean;
93
+ onOpen(key: string, archived?: boolean): void;
94
+ onPin(key: string, pinned: boolean): void;
93
95
  actions: ChatRowActions;
94
- }): React.JSX.Element;
96
+ }
97
+ export declare const ChatFolderItem: React.MemoExoticComponent<({ folder, time, selected, unseen, pinned, archived, onOpen, onPin, actions, }: ChatFolderProps) => React.JSX.Element>;
95
98
  export declare const ChatItem: React.MemoExoticComponent<({ session, source, selected, time, compact, actions, restorable, task, doubleName, handable, pinned, unseen, asking, draft, }: ItemProps) => React.JSX.Element>;
96
99
  export {};
97
100
  //# sourceMappingURL=chat-list-row.d.ts.map
@@ -33,10 +33,9 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ChatItem = void 0;
36
+ exports.ChatItem = exports.ChatFolderItem = void 0;
37
37
  exports.ChatAvatar = ChatAvatar;
38
38
  exports.ChatDot = ChatDot;
39
- exports.ChatFolderItem = ChatFolderItem;
40
39
  const lucide_react_1 = require("lucide-react");
41
40
  const React = __importStar(require("react"));
42
41
  const device_1 = require("../device/device");
@@ -110,12 +109,23 @@ function ChatDot({ unseen, asks, onSee }) {
110
109
  }
111
110
  return (React.createElement(unseen_drop_1.UnseenDrop, { className: unseen ? 'ta-chat-dot ta-on' : 'ta-chat-dot', label: unseen ? t('ta.chat.unseen') : undefined, onDismiss: unseen ? onSee : undefined }));
112
111
  }
113
- /**
114
- * The row of a folder (WebChatIcon.folder), as a messenger folds its subscriptions: its icon, its title, and the latest
115
- * of it with what it said; a dot while one of them said something unseen, a spinner while one works. It opens the folder,
116
- * and is pinned as a conversation is: from its menu, or a swipe to the left on a phone.
117
- */
118
- function ChatFolderItem({ folder, time, selected, unseen, pinned, onOpen, onPin, actions, }) {
112
+ /** Folders are made again as any conversation changes: one draws again only when what it shows of them does. */
113
+ function sameFolder(a, b) {
114
+ const same = (x, y) => x.length === y.length && x.every((one, i) => one === y[i]);
115
+ return (a.time === b.time &&
116
+ a.selected === b.selected &&
117
+ a.pinned === b.pinned &&
118
+ a.archived === b.archived &&
119
+ a.onOpen === b.onOpen &&
120
+ a.onPin === b.onPin &&
121
+ a.actions === b.actions &&
122
+ same(a.unseen, b.unseen) &&
123
+ a.folder.key === b.folder.key &&
124
+ a.folder.title === b.folder.title &&
125
+ a.folder.icon === b.folder.icon &&
126
+ same(a.folder.sessions, b.folder.sessions));
127
+ }
128
+ exports.ChatFolderItem = React.memo(function ChatFolderItem({ folder, time, selected, unseen, pinned, archived, onOpen, onPin, actions, }) {
119
129
  const t = (0, use_t_1.useT)();
120
130
  const onSee = () => {
121
131
  for (const session of unseen) {
@@ -127,10 +137,11 @@ function ChatFolderItem({ folder, time, selected, unseen, pinned, onOpen, onPin,
127
137
  const shown = chat_list_util_1.ChatListUtil.preview(latest, latestTitle);
128
138
  const said = shown && secret_text_1.SecretTextUtil.plain(t, shown);
129
139
  const working = folder.sessions.some(session => chat_list_util_1.ChatListUtil.isOpen(session) && session.isStreaming);
130
- const pin = { label: t(pinned ? 'ta.chat.unpin' : 'ta.chat.pin'), run: () => onPin(!pinned) };
140
+ const pin = { label: t(pinned ? 'ta.chat.unpin' : 'ta.chat.pin'), run: () => onPin(folder.key, !pinned) };
141
+ const open = () => onOpen(folder.key, archived);
131
142
  const [menu, openMenu] = (0, context_menu_1.useContextMenu)();
132
- return (React.createElement(swipe_row_1.SwipeRow, { as: "li", className: `ta-chat-row ta-chat-folder${selected ? ' ta-selected' : ''}`, "data-row": folder.key, "data-unseen": unseen.length > 0 ? '' : undefined, actions: [{ key: 'pin', ...pin }], overlay: menu, onContextMenu: event => openMenu(event, context_menu_1.ContextMenuUtil.sections([{ label: t('ta.chat.open'), run: onOpen }], [pin])) },
133
- React.createElement("button", { type: "button", className: "ta-chat-item", title: `${folder.title} (${folder.sessions.length})`, "aria-current": selected ? 'true' : undefined, onClick: onOpen },
143
+ return (React.createElement(swipe_row_1.SwipeRow, { as: "li", className: `ta-chat-row ta-chat-folder${selected ? ' ta-selected' : ''}`, "data-row": folder.key, "data-unseen": unseen.length > 0 ? '' : undefined, actions: [{ key: 'pin', ...pin }], overlay: menu, onContextMenu: event => openMenu(event, context_menu_1.ContextMenuUtil.sections([{ label: t('ta.chat.open'), run: open }], [pin])) },
144
+ React.createElement("button", { type: "button", className: "ta-chat-item", title: `${folder.title} (${folder.sessions.length})`, "aria-current": selected ? 'true' : undefined, onClick: open },
134
145
  React.createElement("span", { className: "ta-chat-avatar-box" },
135
146
  React.createElement(chat_icon_1.ChatIconTile, { found: folder.icon, size: 38 }),
136
147
  React.createElement(ChatDot, { unseen: unseen.length > 0, asks: false, onSee: onSee })),
@@ -141,7 +152,7 @@ function ChatFolderItem({ folder, time, selected, unseen, pinned, onOpen, onPin,
141
152
  React.createElement("span", { className: "ta-chat-line" },
142
153
  React.createElement("span", { className: `ta-chat-sub${unseen.length > 0 ? ' ta-unseen' : ''}` }, said ? t('ta.chat.folderLatest', { title: latestTitle, said }) : latestTitle),
143
154
  working && React.createElement("span", { className: "ta-chat-state ta-spinner" }))))));
144
- }
155
+ }, sameFolder);
145
156
  exports.ChatItem = React.memo(function ChatItem({ session, source, selected, time, compact, actions, restorable, task, doubleName, handable, pinned, unseen, asking, draft, }) {
146
157
  var _a;
147
158
  const t = (0, use_t_1.useT)();
@@ -88,12 +88,7 @@ function ChatList({ sessions, saved, removed: removedFiles, archived: archivedSa
88
88
  const sessionMenus = React.useContext(extension_view_1.SessionMenus);
89
89
  const latest = React.useRef({ chat, double, onPicked, t, pinned, onPinned, sessionMenus, onLetGo, onUnseen });
90
90
  latest.current = { chat, double, onPicked, t, pinned, onPinned, sessionMenus, onLetGo, onUnseen };
91
- const { picked, taskHome } = (0, chat_list_hooks_1.useTaskRows)(onPicked, home);
92
- // The last pinned first, as several may be: a conversation's file, a folder's key.
93
- const pinKey = React.useCallback((key, pin) => {
94
- const others = latest.current.pinned.filter(other => other !== key);
95
- latest.current.onPinned(pin ? [key, ...others] : others);
96
- }, []);
91
+ const { picked, taskHome, openItem, openFolder: opensFolder, pinKey } = (0, chat_list_hooks_1.useRowCalls)({ onPicked, home, openFolder, pinned, onPinned });
97
92
  const actions = React.useMemo(() => {
98
93
  const pick = (change) => {
99
94
  void change;
@@ -270,7 +265,7 @@ function ChatList({ sessions, saved, removed: removedFiles, archived: archivedSa
270
265
  });
271
266
  // Into a folder from the top of its list, and back where the list was left.
272
267
  const listScroll = React.useRef(0);
273
- const openFolder = (key, archived) => {
268
+ function openFolder(key, archived) {
274
269
  var _a;
275
270
  var _b;
276
271
  listScroll.current = (_b = (_a = scroller.current) === null || _a === void 0 ? void 0 : _a.scrollTop) !== null && _b !== void 0 ? _b : 0;
@@ -280,7 +275,7 @@ function ChatList({ sessions, saved, removed: removedFiles, archived: archivedSa
280
275
  if (!archivedSaved && pinned.includes(key)) {
281
276
  readArchive();
282
277
  }
283
- };
278
+ }
284
279
  const closeFolder = () => {
285
280
  setFolderShown(current => (handheld && current ? { ...current, open: false } : undefined));
286
281
  setQuery('');
@@ -305,9 +300,9 @@ function ChatList({ sessions, saved, removed: removedFiles, archived: archivedSa
305
300
  setFolderShown(undefined);
306
301
  }
307
302
  }, [folderShown, folder]);
308
- const folderItem = (row, archived) => (React.createElement(chat_list_row_1.ChatFolderItem, { key: row.key, folder: row, time: chat_list_util_1.ChatListUtil.clock(row.updatedAt, now), selected: row.sessions.some(isSelected), unseen: row.sessions.filter(isUnseen), pinned: pinnedKeys.has(row.key), onOpen: () => openFolder(row.key, archived), onPin: pin => pinKey(row.key, pin), actions: actions }));
303
+ const folderItem = (row, archived) => (React.createElement(chat_list_row_1.ChatFolderItem, { key: row.key, folder: row, time: chat_list_util_1.ChatListUtil.clock(row.updatedAt, now), selected: row.sessions.some(isSelected), unseen: row.sessions.filter(isUnseen), pinned: pinnedKeys.has(row.key), archived: archived, onOpen: opensFolder, onPin: pinKey, actions: actions }));
309
304
  const taskItem = (row) => home && (React.createElement(chat_home_1.ChatTaskItem, { key: row.key, task: row.task, home: taskHome, unseen: taskUnseen(row.task), time: chat_list_util_1.ChatListUtil.clock(row.updatedAt, now), onPicked: picked }));
310
- const homeItem = (row) => { var _a; return home && (React.createElement(chat_home_1.ChatHomeItem, { key: row.key, row: row, time: row.updatedAt ? chat_list_util_1.ChatListUtil.clock(row.updatedAt, now) : '', home: home, selected: !!row.item.sessionFile && isSelected((_a = byFile.get(row.item.sessionFile)) !== null && _a !== void 0 ? _a : row.item.sessionFile), pinned: pinnedKeys.has(row.key), onPin: pin => pinKey(row.key, pin) })); };
305
+ const homeItem = (row) => { var _a; var _b, _c; return home && (React.createElement(chat_home_1.ChatHomeItem, { key: row.key, row: row, time: row.updatedAt ? chat_list_util_1.ChatListUtil.clock(row.updatedAt, now) : '', shown: home.shownItem === ((_b = (_a = row.partner) === null || _a === void 0 ? void 0 : _a.key) !== null && _b !== void 0 ? _b : row.item.key), openItem: openItem, selected: !!row.item.sessionFile && isSelected((_c = byFile.get(row.item.sessionFile)) !== null && _c !== void 0 ? _c : row.item.sessionFile), pinned: pinnedKeys.has(row.key), onPin: pinKey })); };
311
306
  const rowItem = (row, compact) => chat_list_util_1.ChatListUtil.isFolder(row) ? folderItem(row) : chat_list_util_1.ChatListUtil.isTask(row) ? taskItem(row) : chat_list_util_1.ChatListUtil.isHome(row) ? homeItem(row) : item(row, compact);
312
307
  // The conversation shown is found in the list, however it came to be shown: out of a search that hides it, and scrolled to.
313
308
  const scroller = React.useRef(null);
@@ -48,12 +48,16 @@ const BLEND = 0.45;
48
48
  const FOLLOW = 0.18;
49
49
  /** From how many pixels on a ta is drawn in full detail. */
50
50
  const FINE = 48;
51
+ /** How often where a ta is on the page is read again for it to look at the pointer, in milliseconds: reading it lays the page out. */
52
+ const BOX_MS = 200;
51
53
  /** The whole dinosaur's viewBox: its left and top edge, and its width. */
52
54
  const WHOLE = [-8, -8, 272];
53
55
  exports.DinoLook = React.createContext({ species: dino_species_1.DinoSpecies.DEFAULT, gait: 'walk' });
54
56
  /** One loop of animation frames for every ta on the page; only those on screen move, and none when motion is reduced. */
55
57
  const players = new Set();
56
58
  let loop = 0;
59
+ /** Counts the frames: a small ta (of a row, a few dozen pixels) moves every other one, which nobody can tell at its size. */
60
+ let frames = 0;
57
61
  let watcher;
58
62
  /** Where the mouse is on the page; undefined when it is off the page or the device has none. */
59
63
  let pointer;
@@ -118,10 +122,20 @@ function draw(player, now) {
118
122
  player.pose = pose;
119
123
  const f = (0, dino_avatar_1.frame)(pose, player.fine, player.species);
120
124
  const svg = player.svg;
125
+ // Drawn sixty times a second for each ta on screen: its parts are looked up once, until its markup changes.
126
+ if (player.partsOf !== svg.firstChild) {
127
+ player.parts.clear();
128
+ player.partsOf = svg.firstChild;
129
+ }
121
130
  const set = (part, name, value) => {
122
- const element = svg.querySelector(`.ta-dino-${part}`);
123
- if (element && element.getAttribute(name) !== value) {
124
- element.setAttribute(name, value);
131
+ let found = player.parts.get(part);
132
+ if (!found) {
133
+ found = { element: svg.querySelector(`.ta-dino-${part}`), values: new Map() };
134
+ player.parts.set(part, found);
135
+ }
136
+ if (found.element && found.values.get(name) !== value) {
137
+ found.values.set(name, value);
138
+ found.element.setAttribute(name, value);
125
139
  }
126
140
  };
127
141
  set('skin', 'd', f.skin);
@@ -163,15 +177,27 @@ function tick(now) {
163
177
  }
164
178
  // Still while the page scrolls: a frame of a fling is the scroll's.
165
179
  if (scroll_rest_1.ScrollRest.moving(now)) {
180
+ // Where they are is read again once it rests.
181
+ for (const player of players) {
182
+ player.box = undefined;
183
+ }
166
184
  loop = requestAnimationFrame(tick);
167
185
  return;
168
186
  }
169
- // Read where they all are first, then draw them all, so the page is laid out once a frame.
187
+ // Read where they all are first, then draw them all, so the page is laid out once a frame at most; and
188
+ // only now and then, as reading it lays out what the page changed since (a list drawn again, a reply).
170
189
  for (const player of players) {
171
- player.box = player.visible && pointer ? player.svg.getBoundingClientRect() : undefined;
190
+ if (!player.visible || !pointer) {
191
+ player.box = undefined;
192
+ }
193
+ else if (!player.box || now - player.boxedAt >= BOX_MS) {
194
+ player.box = player.svg.getBoundingClientRect();
195
+ player.boxedAt = now;
196
+ }
172
197
  }
198
+ frames++;
173
199
  for (const player of players) {
174
- if (player.visible) {
200
+ if (player.visible && (player.fine || frames % 2 === 0)) {
175
201
  draw(player, now);
176
202
  }
177
203
  }
@@ -261,6 +287,8 @@ function usePlayer(svg, { mood, size, roam, species, gait, face }) {
261
287
  look: { x: 0, y: 0, weight: 0 },
262
288
  last: now,
263
289
  poked: -Infinity,
290
+ boxedAt: -Infinity,
291
+ parts: new Map(),
264
292
  };
265
293
  }, [mood, roam, size, species, gait, face]);
266
294
  React.useEffect(() => {
@@ -12,6 +12,8 @@ export declare namespace HostUtil {
12
12
  const KEY = "ta.hosts";
13
13
  /** The list kept, without what is not a host (kept by hand, or by an older version). */
14
14
  function read(text: string | null | undefined): HostList;
15
+ /** An entry of the computer `account` of the account other than `id`: one scanned before it joined, or a Ta in the cloud reached by its gateway. */
16
+ function other(list: HostList, id: string, account: string): SavedHost | undefined;
15
17
  /** `id` signed in to with `credential`, now in use: a new one goes last, one known keeps its place and name. */
16
18
  function use(list: HostList, id: string, credential: Credential, now: number, server?: SavedHost['server']): HostList;
17
19
  /**
@@ -19,11 +19,30 @@ var HostUtil;
19
19
  catch (_a) {
20
20
  kept = undefined;
21
21
  }
22
- const hosts = Array.isArray(kept === null || kept === void 0 ? void 0 : kept.hosts) ? kept.hosts.map(host).filter((one) => one !== undefined) : [];
23
- const current = hosts.some(one => one.id === (kept === null || kept === void 0 ? void 0 : kept.current)) ? kept === null || kept === void 0 ? void 0 : kept.current : undefined;
24
- return { current, hosts };
22
+ const all = Array.isArray(kept === null || kept === void 0 ? void 0 : kept.hosts) ? kept.hosts.map(host).filter((one) => one !== undefined) : [];
23
+ const current = all.some(one => one.id === (kept === null || kept === void 0 ? void 0 : kept.current)) ? kept === null || kept === void 0 ? void 0 : kept.current : undefined;
24
+ return { current, hosts: oneEach(all, current) };
25
25
  }
26
26
  HostUtil.read = read;
27
+ /**
28
+ * A computer of the account is one entry: of two kept for it (scanned, then brought by the account, by a version
29
+ * before), the one in use, else the one used last.
30
+ */
31
+ function oneEach(hosts, current) {
32
+ const chosen = new Map();
33
+ for (const one of hosts) {
34
+ const other = one.account ? chosen.get(one.account) : undefined;
35
+ if (one.account && (!other || (other.id !== current && (one.id === current || one.usedAt > other.usedAt)))) {
36
+ chosen.set(one.account, one);
37
+ }
38
+ }
39
+ return hosts.filter(one => !one.account || chosen.get(one.account) === one);
40
+ }
41
+ /** An entry of the computer `account` of the account other than `id`: one scanned before it joined, or a Ta in the cloud reached by its gateway. */
42
+ function other(list, id, account) {
43
+ return list.hosts.find(one => one.account === account && one.id !== id);
44
+ }
45
+ HostUtil.other = other;
27
46
  function host(value) {
28
47
  const kept = value;
29
48
  const credential = kept && typeof kept === 'object' ? readCredential(kept.credential) : undefined;
@@ -33,12 +33,12 @@ class WorkbenchHosts extends workbench_lists_1.WorkbenchLists {
33
33
  * used at once when none is.
34
34
  */
35
35
  async addAccountHost(link, account) {
36
- // One reached directly already (a Ta in the cloud, by its gateway): not a second entry through the relay.
37
- if (this.list.hosts.some(one => one.account === account && 'token' in one.credential)) {
38
- return;
39
- }
40
36
  const credential = workbench_util_1.WorkbenchUtil.credential(link);
41
37
  const id = workbench_util_1.WorkbenchUtil.serverOf(credential, (0, workbench_util_1.pageHost)());
38
+ // Kept already another way (scanned before it joined the account, a Ta in the cloud by its gateway): not a second entry.
39
+ if (hosts_1.HostUtil.other(this.list, id, account)) {
40
+ return;
41
+ }
42
42
  if (this.current.status === 'signed-out' && !this.list.current) {
43
43
  this.keepHosts(hosts_1.HostUtil.keep(this.list, id, credential, account, Date.now()));
44
44
  await this.signIn(credential);
@@ -47,6 +47,10 @@ class WorkbenchHosts extends workbench_lists_1.WorkbenchLists {
47
47
  this.keepHosts(hosts_1.HostUtil.keep(this.list, id, credential, account, Date.now()));
48
48
  }
49
49
  markAccountHost(hostId, account) {
50
+ // The way the account brought to the same computer before: the one scanned and in use is kept alone.
51
+ for (let other = hosts_1.HostUtil.other(this.list, hostId, account); other; other = hosts_1.HostUtil.other(this.list, hostId, account)) {
52
+ this.drop(other.id);
53
+ }
50
54
  this.keepHosts({ ...this.list, hosts: this.list.hosts.map(one => (one.id === hostId ? { ...one, account } : one)) });
51
55
  }
52
56
  /** The computers the account brought: those of `account`, or all of them when the device left the account. */
@@ -1,5 +1,5 @@
1
1
  import { SessionStore, type SessionStoreOptions, type TaConnection } from '@celljs/ta-client';
2
- import type { TaSessionInfo } from '@celljs/ta-protocol';
2
+ import { type TaSavedSessionInfo, type TaSessionInfo } from '@celljs/ta-protocol';
3
3
  import type { WorkbenchState } from './workbench-protocol';
4
4
  import { WorkbenchServices } from './workbench-services';
5
5
  /** The lists of the sessions of the computer, open, saved and archived, read and kept on the device. */
@@ -14,6 +14,16 @@ export declare abstract class WorkbenchLists extends WorkbenchServices {
14
14
  protected archivedSince?: number;
15
15
  /** Counts the lists of open sessions the server told: a read of the lists begun before one does not undo it. */
16
16
  protected pushes: number;
17
+ /**
18
+ * The saved conversations as last read, with the version the server gave them (listSavedSessionChanges) and
19
+ * the connection they were read on: the next read is of what changed since. Unset for a Ta service of before.
20
+ */
21
+ protected savedRead?: {
22
+ connection: TaConnection | undefined;
23
+ version: string;
24
+ list: TaSavedSessionInfo[];
25
+ };
26
+ protected savedChanges: boolean;
17
27
  listOpened(info: TaSessionInfo): void;
18
28
  /**
19
29
  * One read of the lists at a time: asked again meanwhile, one more follows it for all who asked, so that
@@ -21,6 +31,11 @@ export declare abstract class WorkbenchLists extends WorkbenchServices {
21
31
  */
22
32
  refresh(): Promise<void>;
23
33
  protected readLists(): Promise<void>;
34
+ /**
35
+ * The saved conversations updated `since`: only what changed since the last read comes, not hundreds of them
36
+ * each time a conversation opens or the lists are read again.
37
+ */
38
+ protected readSaved(since: number | undefined): Promise<TaSavedSessionInfo[]>;
24
39
  setArchiveDays(days: number): void;
25
40
  readArchived(): Promise<void>;
26
41
  createStore(sessionId: string, options?: SessionStoreOptions): SessionStore;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WorkbenchLists = void 0;
4
4
  const ta_client_1 = require("@celljs/ta-client");
5
+ const ta_protocol_1 = require("@celljs/ta-protocol");
5
6
  const settings_protocol_1 = require("./settings/settings-protocol");
6
7
  const workbench_services_1 = require("./workbench-services");
7
8
  const workbench_util_1 = require("./workbench-util");
@@ -13,6 +14,7 @@ class WorkbenchLists extends workbench_services_1.WorkbenchServices {
13
14
  this.archiveDays = settings_protocol_1.DEFAULT_SETTINGS.chatArchiveDays;
14
15
  /** Counts the lists of open sessions the server told: a read of the lists begun before one does not undo it. */
15
16
  this.pushes = 0;
17
+ this.savedChanges = true;
16
18
  }
17
19
  listOpened(info) {
18
20
  if (this.current.sessions.some(session => session.sessionId === info.sessionId)) {
@@ -43,6 +45,7 @@ class WorkbenchLists extends workbench_services_1.WorkbenchServices {
43
45
  return this.refreshAgain;
44
46
  }
45
47
  async readLists() {
48
+ var _a;
46
49
  const pushes = this.pushes;
47
50
  // A ta serve of before has no saved sessions to list: its list stays the open ones. The default
48
51
  // directory comes along, as another device may have changed it. The archived are left out: a list
@@ -50,23 +53,55 @@ class WorkbenchLists extends workbench_services_1.WorkbenchServices {
50
53
  const since = workbench_util_1.WorkbenchUtil.daysAgo(Date.now(), this.archiveDays);
51
54
  const [sessions, saved, server] = await Promise.all([
52
55
  this.server.listSessions(),
53
- this.server.listSavedSessions(since === undefined ? undefined : { since }).catch(() => []),
56
+ this.readSaved(since).catch(() => []),
54
57
  this.server.getServerInfo().catch(() => this.current.server),
55
58
  ]);
56
59
  // A ta serve of before lists them all.
57
- const recent = since === undefined ? saved : saved.filter(session => session.updatedAt >= since);
60
+ const recent = since === undefined || saved.every(session => session.updatedAt >= since) ? saved : saved.filter(session => session.updatedAt >= since);
58
61
  // Read every few seconds and mostly the same: what shows them is not drawn again for nothing. A list
59
62
  // the server told meanwhile is newer than this one, read before it.
60
63
  this.update({
61
64
  sessions: pushes === this.pushes ? workbench_util_1.WorkbenchUtil.same(this.current.sessions, workbench_util_1.WorkbenchUtil.sorted(sessions)) : this.current.sessions,
62
- saved: workbench_util_1.WorkbenchUtil.same(this.current.saved, recent),
65
+ saved: recent === this.current.saved ? recent : workbench_util_1.WorkbenchUtil.same(this.current.saved, recent),
63
66
  server: workbench_util_1.WorkbenchUtil.same(this.current.server, server),
64
67
  });
68
+ if (((_a = this.savedRead) === null || _a === void 0 ? void 0 : _a.list) === saved) {
69
+ // Unchanged next time, the list shown is not compared again.
70
+ this.savedRead.list = this.current.saved;
71
+ }
65
72
  // A day later, those that just grew old are in the archive read, not lost between the two lists.
66
73
  if (this.current.archived && this.archivedSince !== since) {
67
74
  void this.readArchived().catch(() => undefined);
68
75
  }
69
76
  }
77
+ /**
78
+ * The saved conversations updated `since`: only what changed since the last read comes, not hundreds of them
79
+ * each time a conversation opens or the lists are read again.
80
+ */
81
+ async readSaved(since) {
82
+ var _a;
83
+ var _b;
84
+ const query = since === undefined ? undefined : { since };
85
+ const connection = this.connection;
86
+ if (this.savedChanges) {
87
+ try {
88
+ const before = ((_a = this.savedRead) === null || _a === void 0 ? void 0 : _a.connection) === connection ? this.savedRead : undefined;
89
+ const changes = await this.server.listSavedSessionChanges(query, before === null || before === void 0 ? void 0 : before.version);
90
+ const unchanged = before && !changes.whole && changes.version === before.version;
91
+ const list = unchanged ? before.list : ta_protocol_1.TaSavedSessionUtil.apply((_b = before === null || before === void 0 ? void 0 : before.list) !== null && _b !== void 0 ? _b : [], changes);
92
+ this.savedRead = { connection, version: changes.version, list };
93
+ return list;
94
+ }
95
+ catch (error) {
96
+ if (!ta_client_1.TaRemoteError.isMethodNotFound(error)) {
97
+ throw error;
98
+ }
99
+ this.savedChanges = false;
100
+ this.savedRead = undefined;
101
+ }
102
+ }
103
+ return this.server.listSavedSessions(query);
104
+ }
70
105
  setArchiveDays(days) {
71
106
  if (days === this.archiveDays) {
72
107
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-web",
3
- "version": "4.26.0",
3
+ "version": "4.27.0",
4
4
  "description": "The web client of ta serve: sessions, streaming messages, tool runs with diffs, and dialogs",
5
5
  "keywords": [
6
6
  "cell-component"
@@ -33,12 +33,12 @@
33
33
  "watch": "tsc -b -w --preserveWatchOutput"
34
34
  },
35
35
  "dependencies": {
36
- "@celljs/core": "4.26.0",
37
- "@celljs/react": "4.26.0",
38
- "@celljs/ta-client": "4.26.0",
39
- "@celljs/ta-protocol": "4.26.0",
40
- "@celljs/ta-relay": "4.26.0",
41
- "@celljs/widget": "4.26.0",
36
+ "@celljs/core": "4.27.0",
37
+ "@celljs/react": "4.27.0",
38
+ "@celljs/ta-client": "4.27.0",
39
+ "@celljs/ta-protocol": "4.27.0",
40
+ "@celljs/ta-relay": "4.27.0",
41
+ "@celljs/widget": "4.27.0",
42
42
  "@types/three": "^0.187.0",
43
43
  "@xterm/addon-fit": "^0.11.0",
44
44
  "@xterm/addon-unicode11": "^0.9.0",