@celljs/ta-web 4.25.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.
Files changed (123) hide show
  1. package/esm/browser/account/account-side.js +3 -1
  2. package/esm/browser/assistant/assistant-task-source.js +3 -1
  3. package/esm/browser/assistant/assistant-thread.d.ts +5 -2
  4. package/esm/browser/assistant/assistant-thread.js +70 -46
  5. package/esm/browser/assistant/assistant-view.js +9 -3
  6. package/esm/browser/components/account-menu.d.ts +2 -1
  7. package/esm/browser/components/account-menu.js +7 -2
  8. package/esm/browser/components/app-nav.js +5 -5
  9. package/esm/browser/components/chat-asks.js +16 -1
  10. package/esm/browser/components/chat-home.d.ts +13 -6
  11. package/esm/browser/components/chat-home.js +9 -9
  12. package/esm/browser/components/chat-icon.d.ts +6 -1
  13. package/esm/browser/components/chat-icon.js +49 -4
  14. package/esm/browser/components/chat-list-hooks.d.ts +20 -0
  15. package/esm/browser/components/chat-list-hooks.js +21 -0
  16. package/esm/browser/components/chat-list-row.d.ts +7 -4
  17. package/esm/browser/components/chat-list-row.js +22 -10
  18. package/esm/browser/components/chat-list.js +11 -18
  19. package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
  20. package/esm/browser/components/composer-addon-util.d.ts +5 -0
  21. package/esm/browser/components/composer-addon-util.js +17 -0
  22. package/esm/browser/components/composer-addons.d.ts +3 -1
  23. package/esm/browser/components/composer-addons.js +5 -2
  24. package/esm/browser/components/editor-area.js +2 -2
  25. package/esm/browser/components/host-view.d.ts +1 -1
  26. package/esm/browser/components/message-footer.d.ts +2 -2
  27. package/esm/browser/components/message-footer.js +2 -2
  28. package/esm/browser/components/message-list.d.ts +12 -0
  29. package/esm/browser/components/message-list.js +31 -18
  30. package/esm/browser/components/nav-places.d.ts +2 -1
  31. package/esm/browser/components/nav-places.js +3 -2
  32. package/esm/browser/components/serve-restart.d.ts +11 -2
  33. package/esm/browser/components/serve-restart.js +64 -3
  34. package/esm/browser/components/session-view.js +3 -2
  35. package/esm/browser/components/settings-more.js +7 -4
  36. package/esm/browser/components/ta-avatar.js +34 -6
  37. package/esm/browser/extension/extension-view.d.ts +8 -0
  38. package/esm/browser/extension/extension-view.js +12 -1
  39. package/esm/browser/extension/icons.js +10 -1
  40. package/esm/browser/extension/web-api-contributions.d.ts +15 -2
  41. package/esm/browser/extension/web-api-partners.d.ts +6 -0
  42. package/esm/browser/extension/web-home.js +8 -0
  43. package/esm/browser/hosts.d.ts +2 -0
  44. package/esm/browser/hosts.js +22 -3
  45. package/esm/browser/i18n/locales.d.ts +8 -1
  46. package/esm/browser/i18n/messages-ja.js +7 -0
  47. package/esm/browser/i18n/messages-zh-tw.js +7 -0
  48. package/esm/browser/i18n/messages.d.ts +7 -0
  49. package/esm/browser/i18n/messages.js +14 -0
  50. package/esm/browser/style/conversation-column.d.ts +1 -1
  51. package/esm/browser/style/conversation-column.js +2 -2
  52. package/esm/browser/style/shell.d.ts +1 -1
  53. package/esm/browser/style/shell.js +7 -4
  54. package/esm/browser/style/tasks.d.ts +1 -1
  55. package/esm/browser/style/tasks.js +1 -1
  56. package/esm/browser/workbench-hosts.js +8 -4
  57. package/esm/browser/workbench-lists.d.ts +16 -1
  58. package/esm/browser/workbench-lists.js +38 -3
  59. package/esm/browser/workbench-protocol.d.ts +5 -0
  60. package/esm/browser/workbench.d.ts +1 -0
  61. package/esm/browser/workbench.js +20 -0
  62. package/lib/browser/account/account-side.js +3 -1
  63. package/lib/browser/assistant/assistant-task-source.js +3 -1
  64. package/lib/browser/assistant/assistant-thread.d.ts +5 -2
  65. package/lib/browser/assistant/assistant-thread.js +70 -46
  66. package/lib/browser/assistant/assistant-view.js +8 -2
  67. package/lib/browser/components/account-menu.d.ts +2 -1
  68. package/lib/browser/components/account-menu.js +6 -1
  69. package/lib/browser/components/app-nav.js +4 -4
  70. package/lib/browser/components/chat-asks.js +16 -1
  71. package/lib/browser/components/chat-home.d.ts +13 -6
  72. package/lib/browser/components/chat-home.js +10 -11
  73. package/lib/browser/components/chat-icon.d.ts +6 -1
  74. package/lib/browser/components/chat-icon.js +49 -4
  75. package/lib/browser/components/chat-list-hooks.d.ts +20 -0
  76. package/lib/browser/components/chat-list-hooks.js +22 -0
  77. package/lib/browser/components/chat-list-row.d.ts +7 -4
  78. package/lib/browser/components/chat-list-row.js +23 -12
  79. package/lib/browser/components/chat-list.js +10 -17
  80. package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
  81. package/lib/browser/components/composer-addon-util.d.ts +5 -0
  82. package/lib/browser/components/composer-addon-util.js +17 -0
  83. package/lib/browser/components/composer-addons.d.ts +3 -1
  84. package/lib/browser/components/composer-addons.js +5 -2
  85. package/lib/browser/components/editor-area.js +1 -1
  86. package/lib/browser/components/host-view.d.ts +1 -1
  87. package/lib/browser/components/message-footer.d.ts +2 -2
  88. package/lib/browser/components/message-footer.js +3 -4
  89. package/lib/browser/components/message-list.d.ts +12 -0
  90. package/lib/browser/components/message-list.js +32 -18
  91. package/lib/browser/components/nav-places.d.ts +2 -1
  92. package/lib/browser/components/nav-places.js +3 -2
  93. package/lib/browser/components/serve-restart.d.ts +11 -2
  94. package/lib/browser/components/serve-restart.js +64 -3
  95. package/lib/browser/components/session-view.js +3 -2
  96. package/lib/browser/components/settings-more.js +7 -4
  97. package/lib/browser/components/ta-avatar.js +34 -6
  98. package/lib/browser/extension/extension-view.d.ts +8 -0
  99. package/lib/browser/extension/extension-view.js +12 -0
  100. package/lib/browser/extension/icons.js +9 -0
  101. package/lib/browser/extension/web-api-contributions.d.ts +15 -2
  102. package/lib/browser/extension/web-api-partners.d.ts +6 -0
  103. package/lib/browser/extension/web-home.js +8 -0
  104. package/lib/browser/hosts.d.ts +2 -0
  105. package/lib/browser/hosts.js +22 -3
  106. package/lib/browser/i18n/locales.d.ts +8 -1
  107. package/lib/browser/i18n/messages-ja.js +7 -0
  108. package/lib/browser/i18n/messages-zh-tw.js +7 -0
  109. package/lib/browser/i18n/messages.d.ts +7 -0
  110. package/lib/browser/i18n/messages.js +14 -0
  111. package/lib/browser/style/conversation-column.d.ts +1 -1
  112. package/lib/browser/style/conversation-column.js +2 -2
  113. package/lib/browser/style/shell.d.ts +1 -1
  114. package/lib/browser/style/shell.js +7 -4
  115. package/lib/browser/style/tasks.d.ts +1 -1
  116. package/lib/browser/style/tasks.js +1 -1
  117. package/lib/browser/workbench-hosts.js +8 -4
  118. package/lib/browser/workbench-lists.d.ts +16 -1
  119. package/lib/browser/workbench-lists.js +38 -3
  120. package/lib/browser/workbench-protocol.d.ts +5 -0
  121. package/lib/browser/workbench.d.ts +1 -0
  122. package/lib/browser/workbench.js +20 -0
  123. package/package.json +7 -7
@@ -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;
@@ -175,6 +175,11 @@ export interface TaWorkbench {
175
175
  * page is connected again, when it loads again if it was of the build before.
176
176
  */
177
177
  restartServer(): Promise<void>;
178
+ /**
179
+ * Installs the newer version published (TaServerInfo.release), then restarts Ta to it (restartServer) where Ta can
180
+ * restart itself; else the server read again tells of it installed (TaServerInfo.update). Fails as the install did.
181
+ */
182
+ installRelease(): Promise<void>;
178
183
  /**
179
184
  * A store of a session on this connection; the caller attaches and detaches it. It can be made before
180
185
  * there is a connection, to show a conversation kept on the device (SessionStoreOptions.initial): it is
@@ -41,6 +41,7 @@ export declare class TaWorkbenchImpl extends WorkbenchHosts implements TaWorkben
41
41
  protected readonly listeners: Set<(state: WorkbenchState) => void>;
42
42
  get state(): WorkbenchState;
43
43
  restartServer(): Promise<void>;
44
+ installRelease(): Promise<void>;
44
45
  /** A restart that failed, or did not come back: no longer waited for. */
45
46
  protected restarted(): void;
46
47
  /**
@@ -94,6 +94,26 @@ let TaWorkbenchImpl = class TaWorkbenchImpl extends WorkbenchHosts {
94
94
  throw error;
95
95
  }
96
96
  }
97
+ async installRelease() {
98
+ var _a;
99
+ const read = async () => {
100
+ const server = await this.server.getServerInfo();
101
+ this.update({ server: WorkbenchUtil.same(this.current.server, server) });
102
+ return server;
103
+ };
104
+ const installing = this.server.installRelease();
105
+ // Each page of the owner sees it installing, this one too.
106
+ await read().catch(() => undefined);
107
+ try {
108
+ await installing;
109
+ }
110
+ finally {
111
+ await read().catch(() => undefined);
112
+ }
113
+ if (((_a = this.current.server) === null || _a === void 0 ? void 0 : _a.update) && this.current.server.restartable && !this.current.server.member) {
114
+ await this.restartServer();
115
+ }
116
+ }
97
117
  /** A restart that failed, or did not come back: no longer waited for. */
98
118
  restarted() {
99
119
  if (this.restart) {
@@ -93,7 +93,9 @@ function useAccountInfo(side, every = 3000) {
93
93
  return;
94
94
  }
95
95
  let live = true;
96
- const read = () => side.read().then(next => live && setInfo(next), (error) => live && setFailed(error));
96
+ const read = () => side.read().then(
97
+ // Mostly the same as before: what shows it is not drawn again every few seconds for nothing.
98
+ next => live && setInfo(previous => workbench_util_1.WorkbenchUtil.same(previous, next)), (error) => live && setFailed(error));
97
99
  void read();
98
100
  const timer = setInterval(() => document.visibilityState !== 'hidden' && void read(), every);
99
101
  return () => {
@@ -107,8 +107,10 @@ class AssistantTaskSource {
107
107
  const index = at + waiting.length;
108
108
  const state = (_a = this.stores.get(task.id)) === null || _a === void 0 ? void 0 : _a.store.state;
109
109
  const status = this.status(task, state);
110
- const detail = this.detail(task, status, state);
111
110
  const before = this.shown.get(task.id);
111
+ // What a task that ended said stays what it said: not read out of its result again each time the lists change.
112
+ const ended = !!before && before.task === task && before.status === status && status !== 'waiting' && task.status !== 'running';
113
+ const detail = ended ? before.detail : this.detail(task, status, state);
112
114
  const shown = before && before.task === task && before.status === status && before.detail === detail
113
115
  ? before
114
116
  : { task, status, detail, entry: this.entry(task, status, detail) };
@@ -1,5 +1,6 @@
1
1
  import type { SessionState } from '@celljs/ta-client';
2
2
  import * as React from 'react';
3
+ import type { RowWindow } from '../components/earlier-messages';
3
4
  import type { WebCodeRendererProps } from '../extension/web-api-contributions';
4
5
  import type { WebTaskEntry } from '../extension/web-extension-api';
5
6
  import type { Translate } from '../i18n/use-t';
@@ -14,10 +15,12 @@ interface AssistantThreadProps {
14
15
  tasks: readonly WebTaskEntry[];
15
16
  /** The file of this conversation. */
16
17
  origin?: string;
18
+ /** Only its latest rows are drawn, more as the view nears them (useEarlierMessages). */
19
+ rows?: RowWindow;
17
20
  onTask(id: string): void;
18
21
  t: Translate;
19
22
  }
20
- /** The double's conversation, as the home of the double shows it. */
21
- export declare function AssistantThread({ state, reply, tasks, origin, onTask, t }: AssistantThreadProps): React.JSX.Element;
23
+ /** The double's conversation, as the home of the double shows it: drawn as any conversation is (MessageList), a row at a time. */
24
+ export declare const AssistantThread: React.MemoExoticComponent<({ state, reply, tasks, origin, rows, onTask, t }: AssistantThreadProps) => React.JSX.Element>;
22
25
  export {};
23
26
  //# sourceMappingURL=assistant-thread.d.ts.map
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.AssistantThread = AssistantThread;
36
+ exports.AssistantThread = void 0;
37
37
  const ta_protocol_1 = require("@celljs/ta-protocol");
38
38
  const lucide_react_1 = require("lucide-react");
39
39
  const React = __importStar(require("react"));
@@ -81,8 +81,61 @@ function DoubleUserMessage({ message, blocks }) {
81
81
  React.createElement(message_footer_1.UserFooter, { message: message, text: copied }),
82
82
  menu));
83
83
  }
84
- /** The double's conversation, as the home of the double shows it. */
85
- function AssistantThread({ state, reply, tasks, origin, onTask, t }) {
84
+ /** A row of the double's conversation: a turn of it, or what the user (or a task reporting back) said. */
85
+ function DoubleRowView({ item, tools, mood, status, latest, started, onTask, t }) {
86
+ var _a, _b;
87
+ if (item.kind === 'turn') {
88
+ const results = message_1.MessageUtil.results(item.messages);
89
+ const { errorMessage } = ((_a = item.last) !== null && _a !== void 0 ? _a : {});
90
+ const stopReason = message_1.MessageUtil.stopReason(item.last);
91
+ return (React.createElement(DoubleTurn, { item: item, latest: latest },
92
+ React.createElement(message_steps_1.Process, { steps: item.steps, active: item.active, results: results, tools: tools, leading: React.createElement(message_list_1.TurnAvatar, { mood: mood }), status: status }),
93
+ React.createElement(task_views_1.TaskCards, { tasks: started }),
94
+ item.reply.map((text, index) => (React.createElement(markdown_1.Markdown, { key: index, text: text, streaming: item.active && index === item.reply.length - 1 }))),
95
+ !item.active && stopReason === 'error' && errorMessage && React.createElement(callout_1.Callout, { level: "error" }, errorMessage)));
96
+ }
97
+ const { role } = item.message;
98
+ if (role === 'custom') {
99
+ return React.createElement(extension_view_1.CustomMessage, { message: item.message });
100
+ }
101
+ if (role !== 'user') {
102
+ return null;
103
+ }
104
+ const blocks = message_1.MessageUtil.blocks(item.message);
105
+ const text = message_1.MessageUtil.text(blocks).trim();
106
+ const note = assistant_task_util_1.AssistantTaskUtil.noteOf(text);
107
+ if (note) {
108
+ // A note of a new id is for the double only: the user sees the task under its id in the lists.
109
+ const line = assistant_task_util_1.AssistantTaskUtil.noteLine(note, t);
110
+ const status = note.status;
111
+ return line ? (React.createElement("button", { type: "button", className: "ta-task-update", onClick: () => onTask(note.id) },
112
+ React.createElement("span", { className: `ta-status ta-status-${(_b = TASK_DOTS[status]) !== null && _b !== void 0 ? _b : 'done'}` }),
113
+ React.createElement("span", { className: "ta-task-update-text" }, line),
114
+ React.createElement(icon_1.Icon, { icon: lucide_react_1.ChevronRight, size: 13, className: "ta-task-update-chevron" }))) : null;
115
+ }
116
+ if (ta_protocol_1.TaMessageSource.isNotice(text)) {
117
+ return React.createElement(message_user_1.NoticeMessage, { message: item.message });
118
+ }
119
+ return React.createElement(DoubleUserMessage, { message: item.message, blocks: blocks });
120
+ }
121
+ function sameTasks(a, b) {
122
+ return a.length === b.length && a.every((task, index) => task === b[index]);
123
+ }
124
+ /**
125
+ * A row draws again only when one of its messages changed (the store replaces only those), the tasks it handed out
126
+ * did, or, while the double is at it, a tool run did; not as the page around it draws, nor as the user types.
127
+ */
128
+ const DoubleRow = React.memo(DoubleRowView, (previous, next) => previous.mood === next.mood &&
129
+ previous.status === next.status &&
130
+ previous.latest === next.latest &&
131
+ previous.t === next.t &&
132
+ previous.onTask === next.onTask &&
133
+ sameTasks(previous.started, next.started) &&
134
+ process_1.ProcessUtil.same(previous.item, next.item) &&
135
+ (next.item.kind === 'message' || !next.item.active || previous.tools === next.tools));
136
+ const NO_TASKS = [];
137
+ /** The double's conversation, as the home of the double shows it: drawn as any conversation is (MessageList), a row at a time. */
138
+ exports.AssistantThread = React.memo(function AssistantThread({ state, reply, tasks, origin, rows, onTask, t }) {
86
139
  const renderers = React.useContext(extension_view_1.MessageRenderers);
87
140
  const items = React.useMemo(() => process_1.ProcessUtil.items(state.messages, state.working, state.start, renderers, state.head), [state.messages, state.working, state.start, renderers, state.head]);
88
141
  const starts = React.useMemo(() => process_1.ProcessUtil.starts(items), [items]);
@@ -90,6 +143,7 @@ function AssistantThread({ state, reply, tasks, origin, onTask, t }) {
90
143
  // A turn's cards know what the user said after it: a choice they asked for is made (message-list.tsx).
91
144
  const answers = React.useMemo(() => process_1.ProcessUtil.answers(items, message => (0, message_user_1.userWords)(message_1.MessageUtil.blocks(message)).copied), [items]);
92
145
  const own = React.useMemo(() => tasks.filter(task => task.origin && task.origin === origin), [tasks, origin]);
146
+ const shown = (0, message_list_1.useThreadRows)(items, rows);
93
147
  let lastTurn = items.length - 1;
94
148
  while (lastTurn >= 0 && items[lastTurn].kind !== 'turn') {
95
149
  lastTurn--;
@@ -100,49 +154,19 @@ function AssistantThread({ state, reply, tasks, origin, onTask, t }) {
100
154
  const onHead = status && (0, message_list_1.quiet)(last);
101
155
  // The cards of the tasks the last turn handed out come after its steps.
102
156
  const inSteps = (0, message_list_1.endsInSteps)(last) && !web_tasks_1.WebTaskUtil.startedIn(own, origin, starts[items.length - 1], Number.POSITIVE_INFINITY).length;
103
- const row = (item, index) => {
104
- var _a, _b, _c;
105
- if (item.kind === 'turn') {
106
- const results = message_1.MessageUtil.results(item.messages);
107
- const { errorMessage } = ((_a = item.last) !== null && _a !== void 0 ? _a : {});
108
- const stopReason = message_1.MessageUtil.stopReason(item.last);
109
- const mood = process_1.ProcessUtil.mood(item, index === lastTurn, waiting);
110
- const started = web_tasks_1.WebTaskUtil.startedIn(own, origin, starts[index], (_b = starts[index + 1]) !== null && _b !== void 0 ? _b : Number.POSITIVE_INFINITY);
111
- return (React.createElement(code_renderers_1.CodeAnswer.Provider, { key: item.key, value: answers[index] },
112
- React.createElement(DoubleTurn, { item: item, latest: index === lastTurn },
113
- React.createElement(message_steps_1.Process, { steps: item.steps, active: item.active, results: results, tools: state.tools, leading: React.createElement(message_list_1.TurnAvatar, { mood: mood }), status: onHead && item === last ? status : undefined }),
114
- React.createElement(task_views_1.TaskCards, { tasks: started }),
115
- item.reply.map((text, index) => (React.createElement(markdown_1.Markdown, { key: index, text: text, streaming: item.active && index === item.reply.length - 1 }))),
116
- !item.active && stopReason === 'error' && errorMessage && React.createElement(callout_1.Callout, { level: "error" }, errorMessage))));
117
- }
118
- const { role } = item.message;
119
- if (role === 'custom') {
120
- return React.createElement(extension_view_1.CustomMessage, { key: item.key, message: item.message });
121
- }
122
- if (role !== 'user') {
123
- return null;
124
- }
125
- const blocks = message_1.MessageUtil.blocks(item.message);
126
- const text = message_1.MessageUtil.text(blocks).trim();
127
- const note = assistant_task_util_1.AssistantTaskUtil.noteOf(text);
128
- if (note) {
129
- // A note of a new id is for the double only: the user sees the task under its id in the lists.
130
- const line = assistant_task_util_1.AssistantTaskUtil.noteLine(note, t);
131
- const status = note.status;
132
- return line ? (React.createElement("button", { key: item.key, type: "button", className: "ta-task-update", onClick: () => onTask(note.id) },
133
- React.createElement("span", { className: `ta-status ta-status-${(_c = TASK_DOTS[status]) !== null && _c !== void 0 ? _c : 'done'}` }),
134
- React.createElement("span", { className: "ta-task-update-text" }, line),
135
- React.createElement(icon_1.Icon, { icon: lucide_react_1.ChevronRight, size: 13, className: "ta-task-update-chevron" }))) : null;
136
- }
137
- if (ta_protocol_1.TaMessageSource.isNotice(text)) {
138
- return React.createElement(message_user_1.NoticeMessage, { key: item.key, message: item.message });
139
- }
140
- return React.createElement(DoubleUserMessage, { key: item.key, message: item.message, blocks: blocks });
141
- };
142
157
  return (React.createElement(code_renderers_1.CodeReply.Provider, { value: reply },
143
- items.map((item, index) => (React.createElement(React.Fragment, { key: item.key },
144
- breaks[index] !== undefined && React.createElement(message_footer_1.TimeBreak, { timestamp: breaks[index] }),
145
- row(item, index)))),
158
+ items.map((item, index) => {
159
+ var _a;
160
+ if (index < shown.from) {
161
+ return null;
162
+ }
163
+ const turn = item.kind === 'turn';
164
+ const started = turn ? web_tasks_1.WebTaskUtil.startedIn(own, origin, starts[index], (_a = starts[index + 1]) !== null && _a !== void 0 ? _a : Number.POSITIVE_INFINITY) : NO_TASKS;
165
+ return (React.createElement("div", { key: item.key, "data-row": item.key, className: shown.className(index) },
166
+ breaks[index] !== undefined && React.createElement(message_footer_1.TimeBreak, { timestamp: breaks[index] }),
167
+ React.createElement(code_renderers_1.CodeAnswer.Provider, { value: answers[index] },
168
+ React.createElement(DoubleRow, { item: item, tools: state.tools, mood: turn ? process_1.ProcessUtil.mood(item, index === lastTurn, waiting) : 'idle', status: onHead && item === last ? status : undefined, latest: index === lastTurn, started: started, onTask: onTask, t: t }))));
169
+ }),
146
170
  status && !onHead && React.createElement("div", { className: `ta-run-line ${inSteps ? 'ta-run-steps' : ''}` }, status)));
147
- }
171
+ });
148
172
  //# sourceMappingURL=assistant-thread.js.map
@@ -212,7 +212,13 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
212
212
  // What the user said; a task that reports back stays where it comes in.
213
213
  const asked = (0, earlier_messages_1.useAsked)(state, saidByUser);
214
214
  const scroller = (0, conversation_scroll_hooks_1.useConversationScroll)(asked);
215
- (0, earlier_messages_1.useEarlierMessages)(store, state, scroller);
215
+ // A long conversation draws its latest rows, more as the view nears them, as any conversation does (session-view.tsx).
216
+ const rows = (0, earlier_messages_1.useRowWindow)();
217
+ (0, earlier_messages_1.useEarlierMessages)(store, state, scroller, rows);
218
+ // The same function as the page draws again each second (its mood): the rows of the thread do not draw for it.
219
+ const taskOpened = React.useRef(onTask);
220
+ taskOpened.current = onTask;
221
+ const openTask = React.useCallback((id) => taskOpened.current(id), []);
216
222
  const say = (message) => {
217
223
  hush();
218
224
  return assistant.say(message);
@@ -337,7 +343,7 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
337
343
  React.createElement(hero_cards_1.HeroSteps, { steps: STEPS }),
338
344
  React.createElement(hero_cards_1.HeroCards, { suggestions: SUGGESTIONS, onPick: send }))) : (React.createElement(message_footer_1.MessageActions.Provider, { value: messageActions },
339
345
  React.createElement(message_images_1.MessageImages.Provider, { value: images },
340
- React.createElement(assistant_thread_1.AssistantThread, { state: state, reply: answerCard, tasks: allTasks, origin: assistant.sessionFile, onTask: onTask, t: t })))))),
346
+ React.createElement(assistant_thread_1.AssistantThread, { state: state, reply: answerCard, tasks: allTasks, origin: assistant.sessionFile, rows: rows, onTask: openTask, t: t })))))),
341
347
  React.createElement("div", { className: "ta-composer-area" },
342
348
  React.createElement("div", { className: "ta-chat-col" },
343
349
  asks.map(ask => (React.createElement("div", { key: ask.id, className: "ta-attention" },
@@ -25,7 +25,8 @@ export interface AccountEntry {
25
25
  }
26
26
  /**
27
27
  * The entries of the account and of the settings, in groups: the settings, the packages and the keys; the model
28
- * accounts, the default directory and the phone; the theme and the language; about, and signing out.
28
+ * accounts, the default directory and the phone; the theme and the language; the pages of extensions that are the
29
+ * user's own (WebView.group `me`: their feedback), about, and signing out.
29
30
  */
30
31
  export declare function useAccountEntries(onSettings: (section?: SettingsSection) => void, onDialog: (dialog: AccountDialog) => void): AccountEntry[][];
31
32
  /** What the entries of the account open over the page. */
@@ -44,6 +44,7 @@ const React = __importStar(require("react"));
44
44
  const account_side_1 = require("../account/account-side");
45
45
  const device_account_1 = require("../account/device-account");
46
46
  const device_1 = require("../device/device");
47
+ const web_extension_protocol_1 = require("../extension/web-extension-protocol");
47
48
  const hooks_1 = require("../hooks");
48
49
  const hosts_1 = require("../hosts");
49
50
  const use_t_1 = require("../i18n/use-t");
@@ -71,7 +72,8 @@ const LANGUAGES = [
71
72
  ];
72
73
  /**
73
74
  * The entries of the account and of the settings, in groups: the settings, the packages and the keys; the model
74
- * accounts, the default directory and the phone; the theme and the language; about, and signing out.
75
+ * accounts, the default directory and the phone; the theme and the language; the pages of extensions that are the
76
+ * user's own (WebView.group `me`: their feedback), about, and signing out.
75
77
  */
76
78
  function useAccountEntries(onSettings, onDialog) {
77
79
  const t = (0, use_t_1.useT)();
@@ -89,6 +91,8 @@ function useAccountEntries(onSettings, onDialog) {
89
91
  const { info } = (0, account_side_1.useAccountInfo)(side, 15000);
90
92
  const signedIn = Boolean(info === null || info === void 0 ? void 0 : info.account);
91
93
  const app = workbench_util_1.WorkbenchUtil.isApp();
94
+ const [{ views }, extensions] = (0, hooks_1.useWebExtensions)();
95
+ const own = views.filter(view => view.group === 'me' && view.location === 'page');
92
96
  // Signed in, out of the account (its computers go, those connected by a code stay); else out of the computer in use.
93
97
  const signOut = async () => {
94
98
  if (!signedIn || !side) {
@@ -157,6 +161,7 @@ function useAccountEntries(onSettings, onDialog) {
157
161
  entry('restart', restartTa.update ? t('ta.update.restartTo', { version: serve_restart_1.ServeRestartUtil.label(restartTa.update) }) : t('ta.restart'), lucide_react_1.RotateCw, () => void restartTa.restart()),
158
162
  ]
159
163
  : []),
164
+ ...own.map(view => { var _a; return entry(`page:${view.id}`, web_extension_protocol_1.WebLabelUtil.text(view.title), ((_a = view.icon) !== null && _a !== void 0 ? _a : lucide_react_1.Info), () => void extensions.showView(view.id)); }),
160
165
  entry('about', t('ta.manage.about'), lucide_react_1.Info, () => onSettings('about')),
161
166
  // As WeChat's: the account in use kept, with its computers, to come back to in one tap (docs/design/ta-me.md 4).
162
167
  ...(app && signedIn ? [entry('switchAccount', t('ta.account.switchSignIn'), lucide_react_1.ArrowLeftRight, () => { var _a; return (_a = device_account_1.DeviceAccount.current()) === null || _a === void 0 ? void 0 : _a.switchAccount(); })] : []),
@@ -147,11 +147,11 @@ function SidebarView({ view }) {
147
147
  return (React.createElement("section", { className: "ta-side-view", "aria-label": title, "data-arrived": arrived ? '' : undefined },
148
148
  React.createElement("header", { className: "ta-chats-head" }, Head ? (React.createElement("div", { className: "ta-side-view-head" },
149
149
  React.createElement(extension_view_1.ExtensionBoundary, { key: view.id, name: title, resetKey: Head },
150
- React.createElement(Head, null)))) : (React.createElement("span", { className: "ta-chats-title" }, title))),
150
+ React.createElement(extension_view_1.ExtensionPart, { component: Head })))) : (React.createElement("span", { className: "ta-chats-title" }, title))),
151
151
  React.createElement(connection_bar_1.ConnectionBanner, null),
152
152
  React.createElement("div", { className: "ta-side-view-body" },
153
153
  React.createElement(extension_view_1.ExtensionBoundary, { key: view.id, name: title, resetKey: View },
154
- React.createElement(View, null)))));
154
+ React.createElement(extension_view_1.ExtensionPart, { component: View })))));
155
155
  }
156
156
  /**
157
157
  * A page of a web extension in the main area: its head (`leading` first: the menu, or back), then the page. While
@@ -167,11 +167,11 @@ function PageView({ view, leading }) {
167
167
  pushed ? React.createElement(icon_1.IconButton, { icon: lucide_react_1.ChevronLeft, label: t('ta.back'), onClick: () => pushed.close() }) : leading,
168
168
  view.head ? (React.createElement("div", { className: "ta-main-head-view" },
169
169
  React.createElement(extension_view_1.ExtensionBoundary, { key: view.id, name: title, resetKey: view.head },
170
- React.createElement(view.head, null)))) : (React.createElement("div", { className: "ta-main-title" },
170
+ React.createElement(extension_view_1.ExtensionPart, { component: view.head })))) : (React.createElement("div", { className: "ta-main-title" },
171
171
  React.createElement("span", null, title))),
172
172
  React.createElement(workbench_toggle_1.WorkbenchToggle, null)),
173
173
  React.createElement("div", { className: "ta-page-body" },
174
174
  React.createElement(extension_view_1.ExtensionBoundary, { key: view.id, name: title, resetKey: View },
175
- React.createElement(View, null)))));
175
+ React.createElement(extension_view_1.ExtensionPart, { component: View })))));
176
176
  }
177
177
  //# sourceMappingURL=app-nav.js.map
@@ -71,9 +71,24 @@ var ChatAskUtil;
71
71
  function entryOf(sessions, saved, session) {
72
72
  const { sessionId, sessionFile } = session;
73
73
  const open = sessions.find(each => each.sessionId === sessionId || (!!sessionFile && each.sessionFile === sessionFile));
74
- return open !== null && open !== void 0 ? open : (sessionFile ? saved.find(each => each.sessionFile === sessionFile) : undefined);
74
+ return open !== null && open !== void 0 ? open : (sessionFile ? byFile(saved).get(sessionFile) : undefined);
75
75
  }
76
76
  ChatAskUtil.entryOf = entryOf;
77
+ /** The saved ones by their file, made once for a list: asked of every task as the lists draw, of hundreds. */
78
+ const indexed = new WeakMap();
79
+ function byFile(saved) {
80
+ let index = indexed.get(saved);
81
+ if (!index) {
82
+ index = new Map();
83
+ for (const each of saved) {
84
+ if (!index.has(each.sessionFile)) {
85
+ index.set(each.sessionFile, each);
86
+ }
87
+ }
88
+ indexed.set(saved, index);
89
+ }
90
+ return index;
91
+ }
77
92
  /** Whether it waits for the user: it asks, or a dialog of it waits. */
78
93
  function waits(entry, letGo) {
79
94
  return !!entry.waiting || !!asking(entry, letGo);
@@ -30,15 +30,19 @@ 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>;
44
+ /** What a row of a task does to the double's home: marks it seen, deletes it. */
45
+ export type ChatTaskHome = Pick<ChatHome, 'look' | 'remove'>;
42
46
  /**
43
47
  * 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,
44
48
  * when; a blue ? while it waits, an amber dot once it ended unseen. It opens in the main area, its conversation or its
@@ -46,7 +50,8 @@ export declare function ChatHomeItem({ row, time, home, selected, pinned, onPin,
46
50
  */
47
51
  export declare const ChatTaskItem: React.MemoExoticComponent<({ task, home, unseen, time, onPicked, }: {
48
52
  task: WebTaskEntry;
49
- home: ChatHome;
53
+ /** What it does to the double's home: one that stays the same (ChatList), for the row not to draw again for nothing. */
54
+ home: ChatTaskHome;
50
55
  unseen: boolean;
51
56
  time: string;
52
57
  /** As it opens in the main area: a drawer closes, a phone slides it in (ChatListProps.onPicked). */
@@ -56,8 +61,10 @@ export declare const ChatTaskItem: React.MemoExoticComponent<({ task, home, unse
56
61
  * The top of the double's list: its card (`double`, unless a search leaves it out), then what waits for the user to
57
62
  * decide, above the conversations. The rows extensions add are rows of the list, pinned at first (ChatListUtil.offerPins).
58
63
  */
59
- export declare function ChatHomeTop({ home, double, waiting, counts, unseen, now, onPicked, }: {
64
+ export declare function ChatHomeTop({ home, taskHome, double, waiting, counts, unseen, now, onPicked, }: {
60
65
  home: ChatHome;
66
+ /** The same, for the rows of what waits for the user (ChatTaskItem). */
67
+ taskHome: ChatTaskHome;
61
68
  double: boolean;
62
69
  waiting: readonly WebTaskEntry[];
63
70
  counts: ChatHomeCounts;
@@ -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
@@ -160,7 +159,7 @@ exports.ChatTaskItem = React.memo(function ChatTaskItem({ task, home, unseen, ti
160
159
  * The top of the double's list: its card (`double`, unless a search leaves it out), then what waits for the user to
161
160
  * decide, above the conversations. The rows extensions add are rows of the list, pinned at first (ChatListUtil.offerPins).
162
161
  */
163
- function ChatHomeTop({ home, double, waiting, counts, unseen, now, onPicked, }) {
162
+ function ChatHomeTop({ home, taskHome, double, waiting, counts, unseen, now, onPicked, }) {
164
163
  const t = (0, use_t_1.useT)();
165
164
  return (React.createElement(React.Fragment, null,
166
165
  double && (React.createElement("section", { className: "ta-chat-section ta-chat-home" },
@@ -168,6 +167,6 @@ function ChatHomeTop({ home, double, waiting, counts, unseen, now, onPicked, })
168
167
  React.createElement(ChatDoubleItem, { home: home, counts: counts, unseen: unseen, now: now })))),
169
168
  waiting.length > 0 && (React.createElement("section", { className: "ta-chat-section ta-chat-decide" },
170
169
  React.createElement("div", { className: "ta-chat-section-title" }, t('ta.home.decide')),
171
- React.createElement("ul", { className: "ta-side-list" }, waiting.map(task => (React.createElement(exports.ChatTaskItem, { key: task.key, task: task, home: home, unseen: false, time: chat_list_util_1.ChatListUtil.clock(task.startedAt, now), onPicked: onPicked }))))))));
170
+ React.createElement("ul", { className: "ta-side-list" }, waiting.map(task => (React.createElement(exports.ChatTaskItem, { key: task.key, task: task, home: taskHome, unseen: false, time: chat_list_util_1.ChatListUtil.clock(task.startedAt, now), onPicked: onPicked }))))))));
172
171
  }
173
172
  //# sourceMappingURL=chat-home.js.map
@@ -11,7 +11,12 @@ export type ChatFolderIcon = FoundChatIcon & {
11
11
  };
12
12
  /** The icons web extensions give conversations of theirs (WebExtensionAPI.registerChatIcon). */
13
13
  export declare namespace ChatIconUtil {
14
- /** The icon of the first extension that gives one, with its tint; an extension that throws gives none. */
14
+ /** An extension said its icons changed, or the language did: they are asked again. */
15
+ function changed(): void;
16
+ /**
17
+ * The icon of the first extension that gives one, with its tint; an extension that throws gives none. Asked once
18
+ * for a conversation (what WebChat has of it) until the icons change: the lists ask it of hundreds as they draw.
19
+ */
15
20
  function find(entries: readonly WebChatIconEntry[], chat: WebChat): FoundChatIcon | undefined;
16
21
  /**
17
22
  * Since when a conversation an extension archives sooner (WebChatIcon.archiveMinutes, archiveDays) stays listed,