@celljs/ta-web 4.25.0 → 4.26.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 (107) 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 +7 -2
  11. package/esm/browser/components/chat-home.js +2 -2
  12. package/esm/browser/components/chat-icon.d.ts +6 -1
  13. package/esm/browser/components/chat-icon.js +45 -4
  14. package/esm/browser/components/chat-list-hooks.d.ts +10 -0
  15. package/esm/browser/components/chat-list-hooks.js +15 -0
  16. package/esm/browser/components/chat-list.js +7 -9
  17. package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
  18. package/esm/browser/components/composer-addon-util.d.ts +5 -0
  19. package/esm/browser/components/composer-addon-util.js +17 -0
  20. package/esm/browser/components/composer-addons.d.ts +3 -1
  21. package/esm/browser/components/composer-addons.js +5 -2
  22. package/esm/browser/components/editor-area.js +2 -2
  23. package/esm/browser/components/host-view.d.ts +1 -1
  24. package/esm/browser/components/message-footer.d.ts +2 -2
  25. package/esm/browser/components/message-footer.js +2 -2
  26. package/esm/browser/components/message-list.d.ts +12 -0
  27. package/esm/browser/components/message-list.js +31 -18
  28. package/esm/browser/components/nav-places.d.ts +2 -1
  29. package/esm/browser/components/nav-places.js +3 -2
  30. package/esm/browser/components/serve-restart.d.ts +11 -2
  31. package/esm/browser/components/serve-restart.js +64 -3
  32. package/esm/browser/components/session-view.js +3 -2
  33. package/esm/browser/components/settings-more.js +7 -4
  34. package/esm/browser/extension/extension-view.d.ts +8 -0
  35. package/esm/browser/extension/extension-view.js +12 -1
  36. package/esm/browser/extension/icons.js +10 -1
  37. package/esm/browser/extension/web-api-contributions.d.ts +15 -2
  38. package/esm/browser/extension/web-api-partners.d.ts +6 -0
  39. package/esm/browser/extension/web-home.js +8 -0
  40. package/esm/browser/i18n/locales.d.ts +8 -1
  41. package/esm/browser/i18n/messages-ja.js +7 -0
  42. package/esm/browser/i18n/messages-zh-tw.js +7 -0
  43. package/esm/browser/i18n/messages.d.ts +7 -0
  44. package/esm/browser/i18n/messages.js +14 -0
  45. package/esm/browser/style/conversation-column.d.ts +1 -1
  46. package/esm/browser/style/conversation-column.js +2 -2
  47. package/esm/browser/style/shell.d.ts +1 -1
  48. package/esm/browser/style/shell.js +7 -4
  49. package/esm/browser/style/tasks.d.ts +1 -1
  50. package/esm/browser/style/tasks.js +1 -1
  51. package/esm/browser/workbench-protocol.d.ts +5 -0
  52. package/esm/browser/workbench.d.ts +1 -0
  53. package/esm/browser/workbench.js +20 -0
  54. package/lib/browser/account/account-side.js +3 -1
  55. package/lib/browser/assistant/assistant-task-source.js +3 -1
  56. package/lib/browser/assistant/assistant-thread.d.ts +5 -2
  57. package/lib/browser/assistant/assistant-thread.js +70 -46
  58. package/lib/browser/assistant/assistant-view.js +8 -2
  59. package/lib/browser/components/account-menu.d.ts +2 -1
  60. package/lib/browser/components/account-menu.js +6 -1
  61. package/lib/browser/components/app-nav.js +4 -4
  62. package/lib/browser/components/chat-asks.js +16 -1
  63. package/lib/browser/components/chat-home.d.ts +7 -2
  64. package/lib/browser/components/chat-home.js +2 -2
  65. package/lib/browser/components/chat-icon.d.ts +6 -1
  66. package/lib/browser/components/chat-icon.js +45 -4
  67. package/lib/browser/components/chat-list-hooks.d.ts +10 -0
  68. package/lib/browser/components/chat-list-hooks.js +16 -0
  69. package/lib/browser/components/chat-list.js +6 -8
  70. package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
  71. package/lib/browser/components/composer-addon-util.d.ts +5 -0
  72. package/lib/browser/components/composer-addon-util.js +17 -0
  73. package/lib/browser/components/composer-addons.d.ts +3 -1
  74. package/lib/browser/components/composer-addons.js +5 -2
  75. package/lib/browser/components/editor-area.js +1 -1
  76. package/lib/browser/components/host-view.d.ts +1 -1
  77. package/lib/browser/components/message-footer.d.ts +2 -2
  78. package/lib/browser/components/message-footer.js +3 -4
  79. package/lib/browser/components/message-list.d.ts +12 -0
  80. package/lib/browser/components/message-list.js +32 -18
  81. package/lib/browser/components/nav-places.d.ts +2 -1
  82. package/lib/browser/components/nav-places.js +3 -2
  83. package/lib/browser/components/serve-restart.d.ts +11 -2
  84. package/lib/browser/components/serve-restart.js +64 -3
  85. package/lib/browser/components/session-view.js +3 -2
  86. package/lib/browser/components/settings-more.js +7 -4
  87. package/lib/browser/extension/extension-view.d.ts +8 -0
  88. package/lib/browser/extension/extension-view.js +12 -0
  89. package/lib/browser/extension/icons.js +9 -0
  90. package/lib/browser/extension/web-api-contributions.d.ts +15 -2
  91. package/lib/browser/extension/web-api-partners.d.ts +6 -0
  92. package/lib/browser/extension/web-home.js +8 -0
  93. package/lib/browser/i18n/locales.d.ts +8 -1
  94. package/lib/browser/i18n/messages-ja.js +7 -0
  95. package/lib/browser/i18n/messages-zh-tw.js +7 -0
  96. package/lib/browser/i18n/messages.d.ts +7 -0
  97. package/lib/browser/i18n/messages.js +14 -0
  98. package/lib/browser/style/conversation-column.d.ts +1 -1
  99. package/lib/browser/style/conversation-column.js +2 -2
  100. package/lib/browser/style/shell.d.ts +1 -1
  101. package/lib/browser/style/shell.js +7 -4
  102. package/lib/browser/style/tasks.d.ts +1 -1
  103. package/lib/browser/style/tasks.js +1 -1
  104. package/lib/browser/workbench-protocol.d.ts +5 -0
  105. package/lib/browser/workbench.d.ts +1 -0
  106. package/lib/browser/workbench.js +20 -0
  107. package/package.json +7 -7
@@ -56,7 +56,9 @@ export function useAccountInfo(side, every = 3000) {
56
56
  return;
57
57
  }
58
58
  let live = true;
59
- const read = () => side.read().then(next => live && setInfo(next), (error) => live && setFailed(error));
59
+ const read = () => side.read().then(
60
+ // Mostly the same as before: what shows it is not drawn again every few seconds for nothing.
61
+ next => live && setInfo(previous => WorkbenchUtil.same(previous, next)), (error) => live && setFailed(error));
60
62
  void read();
61
63
  const timer = setInterval(() => document.visibilityState !== 'hidden' && void read(), every);
62
64
  return () => {
@@ -102,8 +102,10 @@ export class AssistantTaskSource {
102
102
  const index = at + waiting.length;
103
103
  const state = (_a = this.stores.get(task.id)) === null || _a === void 0 ? void 0 : _a.store.state;
104
104
  const status = this.status(task, state);
105
- const detail = this.detail(task, status, state);
106
105
  const before = this.shown.get(task.id);
106
+ // What a task that ended said stays what it said: not read out of its result again each time the lists change.
107
+ const ended = !!before && before.task === task && before.status === status && status !== 'waiting' && task.status !== 'running';
108
+ const detail = ended ? before.detail : this.detail(task, status, state);
107
109
  const shown = before && before.task === task && before.status === status && before.detail === detail
108
110
  ? before
109
111
  : { 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.js';
3
4
  import type { WebCodeRendererProps } from '../extension/web-api-contributions.js';
4
5
  import type { WebTaskEntry } from '../extension/web-extension-api.js';
5
6
  import type { Translate } from '../i18n/use-t.js';
@@ -14,9 +15,11 @@ 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 {};
@@ -6,7 +6,7 @@ import { ASK_CLASS } from '../components/conversation-scroll-util.js';
6
6
  import { Icon } from '../components/icon.js';
7
7
  import { Markdown } from '../components/markdown.js';
8
8
  import { TimeBreak, TurnFooter, UserFooter } from '../components/message-footer.js';
9
- import { endsInSteps, quiet, TurnAvatar } from '../components/message-list.js';
9
+ import { endsInSteps, quiet, TurnAvatar, useThreadRows } from '../components/message-list.js';
10
10
  import { useMessageMenu } from '../components/message-menu.js';
11
11
  import { Process } from '../components/message-steps.js';
12
12
  import { NoticeMessage, SkillUse, UserMarks, UserSaid, userWords } from '../components/message-user.js';
@@ -45,8 +45,61 @@ function DoubleUserMessage({ message, blocks }) {
45
45
  React.createElement(UserFooter, { message: message, text: copied }),
46
46
  menu));
47
47
  }
48
- /** The double's conversation, as the home of the double shows it. */
49
- export function AssistantThread({ state, reply, tasks, origin, onTask, t }) {
48
+ /** A row of the double's conversation: a turn of it, or what the user (or a task reporting back) said. */
49
+ function DoubleRowView({ item, tools, mood, status, latest, started, onTask, t }) {
50
+ var _a, _b;
51
+ if (item.kind === 'turn') {
52
+ const results = MessageUtil.results(item.messages);
53
+ const { errorMessage } = ((_a = item.last) !== null && _a !== void 0 ? _a : {});
54
+ const stopReason = MessageUtil.stopReason(item.last);
55
+ return (React.createElement(DoubleTurn, { item: item, latest: latest },
56
+ React.createElement(Process, { steps: item.steps, active: item.active, results: results, tools: tools, leading: React.createElement(TurnAvatar, { mood: mood }), status: status }),
57
+ React.createElement(TaskCards, { tasks: started }),
58
+ item.reply.map((text, index) => (React.createElement(Markdown, { key: index, text: text, streaming: item.active && index === item.reply.length - 1 }))),
59
+ !item.active && stopReason === 'error' && errorMessage && React.createElement(Callout, { level: "error" }, errorMessage)));
60
+ }
61
+ const { role } = item.message;
62
+ if (role === 'custom') {
63
+ return React.createElement(CustomMessage, { message: item.message });
64
+ }
65
+ if (role !== 'user') {
66
+ return null;
67
+ }
68
+ const blocks = MessageUtil.blocks(item.message);
69
+ const text = MessageUtil.text(blocks).trim();
70
+ const note = AssistantTaskUtil.noteOf(text);
71
+ if (note) {
72
+ // A note of a new id is for the double only: the user sees the task under its id in the lists.
73
+ const line = AssistantTaskUtil.noteLine(note, t);
74
+ const status = note.status;
75
+ return line ? (React.createElement("button", { type: "button", className: "ta-task-update", onClick: () => onTask(note.id) },
76
+ React.createElement("span", { className: `ta-status ta-status-${(_b = TASK_DOTS[status]) !== null && _b !== void 0 ? _b : 'done'}` }),
77
+ React.createElement("span", { className: "ta-task-update-text" }, line),
78
+ React.createElement(Icon, { icon: ChevronRight, size: 13, className: "ta-task-update-chevron" }))) : null;
79
+ }
80
+ if (TaMessageSource.isNotice(text)) {
81
+ return React.createElement(NoticeMessage, { message: item.message });
82
+ }
83
+ return React.createElement(DoubleUserMessage, { message: item.message, blocks: blocks });
84
+ }
85
+ function sameTasks(a, b) {
86
+ return a.length === b.length && a.every((task, index) => task === b[index]);
87
+ }
88
+ /**
89
+ * A row draws again only when one of its messages changed (the store replaces only those), the tasks it handed out
90
+ * did, or, while the double is at it, a tool run did; not as the page around it draws, nor as the user types.
91
+ */
92
+ const DoubleRow = React.memo(DoubleRowView, (previous, next) => previous.mood === next.mood &&
93
+ previous.status === next.status &&
94
+ previous.latest === next.latest &&
95
+ previous.t === next.t &&
96
+ previous.onTask === next.onTask &&
97
+ sameTasks(previous.started, next.started) &&
98
+ ProcessUtil.same(previous.item, next.item) &&
99
+ (next.item.kind === 'message' || !next.item.active || previous.tools === next.tools));
100
+ const NO_TASKS = [];
101
+ /** The double's conversation, as the home of the double shows it: drawn as any conversation is (MessageList), a row at a time. */
102
+ export const AssistantThread = React.memo(function AssistantThread({ state, reply, tasks, origin, rows, onTask, t }) {
50
103
  const renderers = React.useContext(MessageRenderers);
51
104
  const items = React.useMemo(() => ProcessUtil.items(state.messages, state.working, state.start, renderers, state.head), [state.messages, state.working, state.start, renderers, state.head]);
52
105
  const starts = React.useMemo(() => ProcessUtil.starts(items), [items]);
@@ -54,6 +107,7 @@ export function AssistantThread({ state, reply, tasks, origin, onTask, t }) {
54
107
  // A turn's cards know what the user said after it: a choice they asked for is made (message-list.tsx).
55
108
  const answers = React.useMemo(() => ProcessUtil.answers(items, message => userWords(MessageUtil.blocks(message)).copied), [items]);
56
109
  const own = React.useMemo(() => tasks.filter(task => task.origin && task.origin === origin), [tasks, origin]);
110
+ const shown = useThreadRows(items, rows);
57
111
  let lastTurn = items.length - 1;
58
112
  while (lastTurn >= 0 && items[lastTurn].kind !== 'turn') {
59
113
  lastTurn--;
@@ -64,49 +118,19 @@ export function AssistantThread({ state, reply, tasks, origin, onTask, t }) {
64
118
  const onHead = status && quiet(last);
65
119
  // The cards of the tasks the last turn handed out come after its steps.
66
120
  const inSteps = endsInSteps(last) && !WebTaskUtil.startedIn(own, origin, starts[items.length - 1], Number.POSITIVE_INFINITY).length;
67
- const row = (item, index) => {
68
- var _a, _b, _c;
69
- if (item.kind === 'turn') {
70
- const results = MessageUtil.results(item.messages);
71
- const { errorMessage } = ((_a = item.last) !== null && _a !== void 0 ? _a : {});
72
- const stopReason = MessageUtil.stopReason(item.last);
73
- const mood = ProcessUtil.mood(item, index === lastTurn, waiting);
74
- const started = WebTaskUtil.startedIn(own, origin, starts[index], (_b = starts[index + 1]) !== null && _b !== void 0 ? _b : Number.POSITIVE_INFINITY);
75
- return (React.createElement(CodeAnswer.Provider, { key: item.key, value: answers[index] },
76
- React.createElement(DoubleTurn, { item: item, latest: index === lastTurn },
77
- React.createElement(Process, { steps: item.steps, active: item.active, results: results, tools: state.tools, leading: React.createElement(TurnAvatar, { mood: mood }), status: onHead && item === last ? status : undefined }),
78
- React.createElement(TaskCards, { tasks: started }),
79
- item.reply.map((text, index) => (React.createElement(Markdown, { key: index, text: text, streaming: item.active && index === item.reply.length - 1 }))),
80
- !item.active && stopReason === 'error' && errorMessage && React.createElement(Callout, { level: "error" }, errorMessage))));
81
- }
82
- const { role } = item.message;
83
- if (role === 'custom') {
84
- return React.createElement(CustomMessage, { key: item.key, message: item.message });
85
- }
86
- if (role !== 'user') {
87
- return null;
88
- }
89
- const blocks = MessageUtil.blocks(item.message);
90
- const text = MessageUtil.text(blocks).trim();
91
- const note = AssistantTaskUtil.noteOf(text);
92
- if (note) {
93
- // A note of a new id is for the double only: the user sees the task under its id in the lists.
94
- const line = AssistantTaskUtil.noteLine(note, t);
95
- const status = note.status;
96
- return line ? (React.createElement("button", { key: item.key, type: "button", className: "ta-task-update", onClick: () => onTask(note.id) },
97
- React.createElement("span", { className: `ta-status ta-status-${(_c = TASK_DOTS[status]) !== null && _c !== void 0 ? _c : 'done'}` }),
98
- React.createElement("span", { className: "ta-task-update-text" }, line),
99
- React.createElement(Icon, { icon: ChevronRight, size: 13, className: "ta-task-update-chevron" }))) : null;
100
- }
101
- if (TaMessageSource.isNotice(text)) {
102
- return React.createElement(NoticeMessage, { key: item.key, message: item.message });
103
- }
104
- return React.createElement(DoubleUserMessage, { key: item.key, message: item.message, blocks: blocks });
105
- };
106
121
  return (React.createElement(CodeReply.Provider, { value: reply },
107
- items.map((item, index) => (React.createElement(React.Fragment, { key: item.key },
108
- breaks[index] !== undefined && React.createElement(TimeBreak, { timestamp: breaks[index] }),
109
- row(item, index)))),
122
+ items.map((item, index) => {
123
+ var _a;
124
+ if (index < shown.from) {
125
+ return null;
126
+ }
127
+ const turn = item.kind === 'turn';
128
+ const started = turn ? WebTaskUtil.startedIn(own, origin, starts[index], (_a = starts[index + 1]) !== null && _a !== void 0 ? _a : Number.POSITIVE_INFINITY) : NO_TASKS;
129
+ return (React.createElement("div", { key: item.key, "data-row": item.key, className: shown.className(index) },
130
+ breaks[index] !== undefined && React.createElement(TimeBreak, { timestamp: breaks[index] }),
131
+ React.createElement(CodeAnswer.Provider, { value: answers[index] },
132
+ React.createElement(DoubleRow, { item: item, tools: state.tools, mood: turn ? ProcessUtil.mood(item, index === lastTurn, waiting) : 'idle', status: onHead && item === last ? status : undefined, latest: index === lastTurn, started: started, onTask: onTask, t: t }))));
133
+ }),
110
134
  status && !onHead && React.createElement("div", { className: `ta-run-line ${inSteps ? 'ta-run-steps' : ''}` }, status)));
111
- }
135
+ });
112
136
  //# sourceMappingURL=assistant-thread.js.map
@@ -7,7 +7,7 @@ import { useComposerAddons } from '../components/composer-addons.js';
7
7
  import { ConnectionBanner } from '../components/connection-bar.js';
8
8
  import { useConversationScroll } from '../components/conversation-scroll-hooks.js';
9
9
  import { DialogView } from '../components/dialog-view.js';
10
- import { isAsk, useAsked, useEarlierMessages } from '../components/earlier-messages.js';
10
+ import { isAsk, useAsked, useEarlierMessages, useRowWindow } from '../components/earlier-messages.js';
11
11
  import { HeroCards, HeroSteps } from '../components/hero-cards.js';
12
12
  import { Icon } from '../components/icon.js';
13
13
  import { Loading } from '../components/loading.js';
@@ -171,7 +171,13 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
171
171
  // What the user said; a task that reports back stays where it comes in.
172
172
  const asked = useAsked(state, saidByUser);
173
173
  const scroller = useConversationScroll(asked);
174
- useEarlierMessages(store, state, scroller);
174
+ // A long conversation draws its latest rows, more as the view nears them, as any conversation does (session-view.tsx).
175
+ const rows = useRowWindow();
176
+ useEarlierMessages(store, state, scroller, rows);
177
+ // The same function as the page draws again each second (its mood): the rows of the thread do not draw for it.
178
+ const taskOpened = React.useRef(onTask);
179
+ taskOpened.current = onTask;
180
+ const openTask = React.useCallback((id) => taskOpened.current(id), []);
175
181
  const say = (message) => {
176
182
  hush();
177
183
  return assistant.say(message);
@@ -296,7 +302,7 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
296
302
  React.createElement(HeroSteps, { steps: STEPS }),
297
303
  React.createElement(HeroCards, { suggestions: SUGGESTIONS, onPick: send }))) : (React.createElement(MessageActions.Provider, { value: messageActions },
298
304
  React.createElement(MessageImages.Provider, { value: images },
299
- React.createElement(AssistantThread, { state: state, reply: answerCard, tasks: allTasks, origin: assistant.sessionFile, onTask: onTask, t: t })))))),
305
+ React.createElement(AssistantThread, { state: state, reply: answerCard, tasks: allTasks, origin: assistant.sessionFile, rows: rows, onTask: openTask, t: t })))))),
300
306
  React.createElement("div", { className: "ta-composer-area" },
301
307
  React.createElement("div", { className: "ta-chat-col" },
302
308
  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. */
@@ -4,7 +4,8 @@ import * as React from 'react';
4
4
  import { useAccountInfo, useAccountSide } from '../account/account-side.js';
5
5
  import { DeviceAccount } from '../account/device-account.js';
6
6
  import { useDevice } from '../device/device.js';
7
- import { useNotices, usePersisted, usePwa, useSettings, useWorkbench } from '../hooks.js';
7
+ import { WebLabelUtil } from '../extension/web-extension-protocol.js';
8
+ import { useNotices, usePersisted, usePwa, useSettings, useWebExtensions, useWorkbench } from '../hooks.js';
8
9
  import { HostUtil } from '../hosts.js';
9
10
  import { useT } from '../i18n/use-t.js';
10
11
  import { WorkbenchUtil } from '../workbench-util.js';
@@ -31,7 +32,8 @@ const LANGUAGES = [
31
32
  ];
32
33
  /**
33
34
  * The entries of the account and of the settings, in groups: the settings, the packages and the keys; the model
34
- * accounts, the default directory and the phone; the theme and the language; about, and signing out.
35
+ * accounts, the default directory and the phone; the theme and the language; the pages of extensions that are the
36
+ * user's own (WebView.group `me`: their feedback), about, and signing out.
35
37
  */
36
38
  export function useAccountEntries(onSettings, onDialog) {
37
39
  const t = useT();
@@ -49,6 +51,8 @@ export function useAccountEntries(onSettings, onDialog) {
49
51
  const { info } = useAccountInfo(side, 15000);
50
52
  const signedIn = Boolean(info === null || info === void 0 ? void 0 : info.account);
51
53
  const app = WorkbenchUtil.isApp();
54
+ const [{ views }, extensions] = useWebExtensions();
55
+ const own = views.filter(view => view.group === 'me' && view.location === 'page');
52
56
  // Signed in, out of the account (its computers go, those connected by a code stay); else out of the computer in use.
53
57
  const signOut = async () => {
54
58
  if (!signedIn || !side) {
@@ -117,6 +121,7 @@ export function useAccountEntries(onSettings, onDialog) {
117
121
  entry('restart', restartTa.update ? t('ta.update.restartTo', { version: ServeRestartUtil.label(restartTa.update) }) : t('ta.restart'), RotateCw, () => void restartTa.restart()),
118
122
  ]
119
123
  : []),
124
+ ...own.map(view => { var _a; return entry(`page:${view.id}`, WebLabelUtil.text(view.title), ((_a = view.icon) !== null && _a !== void 0 ? _a : Info), () => void extensions.showView(view.id)); }),
120
125
  entry('about', t('ta.manage.about'), Info, () => onSettings('about')),
121
126
  // As WeChat's: the account in use kept, with its computers, to come back to in one tap (docs/design/ta-me.md 4).
122
127
  ...(app && signedIn ? [entry('switchAccount', t('ta.account.switchSignIn'), ArrowLeftRight, () => { var _a; return (_a = DeviceAccount.current()) === null || _a === void 0 ? void 0 : _a.switchAccount(); })] : []),
@@ -2,7 +2,7 @@ import { ChevronLeft, Compass, Grip, LayoutDashboard, PanelTop } from 'lucide-re
2
2
  import * as React from 'react';
3
3
  import { useDevice } from '../device/device.js';
4
4
  import { useHeld } from '../device/hold.js';
5
- import { ExtensionBoundary } from '../extension/extension-view.js';
5
+ import { ExtensionBoundary, ExtensionPart } from '../extension/extension-view.js';
6
6
  import { WebLabelUtil } from '../extension/web-extension-protocol.js';
7
7
  import { useSettings, useWebExtensions, useWorkbench } from '../hooks.js';
8
8
  import { useT } from '../i18n/use-t.js';
@@ -108,11 +108,11 @@ export function SidebarView({ view }) {
108
108
  return (React.createElement("section", { className: "ta-side-view", "aria-label": title, "data-arrived": arrived ? '' : undefined },
109
109
  React.createElement("header", { className: "ta-chats-head" }, Head ? (React.createElement("div", { className: "ta-side-view-head" },
110
110
  React.createElement(ExtensionBoundary, { key: view.id, name: title, resetKey: Head },
111
- React.createElement(Head, null)))) : (React.createElement("span", { className: "ta-chats-title" }, title))),
111
+ React.createElement(ExtensionPart, { component: Head })))) : (React.createElement("span", { className: "ta-chats-title" }, title))),
112
112
  React.createElement(ConnectionBanner, null),
113
113
  React.createElement("div", { className: "ta-side-view-body" },
114
114
  React.createElement(ExtensionBoundary, { key: view.id, name: title, resetKey: View },
115
- React.createElement(View, null)))));
115
+ React.createElement(ExtensionPart, { component: View })))));
116
116
  }
117
117
  /**
118
118
  * A page of a web extension in the main area: its head (`leading` first: the menu, or back), then the page. While
@@ -128,11 +128,11 @@ export function PageView({ view, leading }) {
128
128
  pushed ? React.createElement(IconButton, { icon: ChevronLeft, label: t('ta.back'), onClick: () => pushed.close() }) : leading,
129
129
  view.head ? (React.createElement("div", { className: "ta-main-head-view" },
130
130
  React.createElement(ExtensionBoundary, { key: view.id, name: title, resetKey: view.head },
131
- React.createElement(view.head, null)))) : (React.createElement("div", { className: "ta-main-title" },
131
+ React.createElement(ExtensionPart, { component: view.head })))) : (React.createElement("div", { className: "ta-main-title" },
132
132
  React.createElement("span", null, title))),
133
133
  React.createElement(WorkbenchToggle, null)),
134
134
  React.createElement("div", { className: "ta-page-body" },
135
135
  React.createElement(ExtensionBoundary, { key: view.id, name: title, resetKey: View },
136
- React.createElement(View, null)))));
136
+ React.createElement(ExtensionPart, { component: View })))));
137
137
  }
138
138
  //# sourceMappingURL=app-nav.js.map
@@ -68,9 +68,24 @@ export var ChatAskUtil;
68
68
  function entryOf(sessions, saved, session) {
69
69
  const { sessionId, sessionFile } = session;
70
70
  const open = sessions.find(each => each.sessionId === sessionId || (!!sessionFile && each.sessionFile === sessionFile));
71
- return open !== null && open !== void 0 ? open : (sessionFile ? saved.find(each => each.sessionFile === sessionFile) : undefined);
71
+ return open !== null && open !== void 0 ? open : (sessionFile ? byFile(saved).get(sessionFile) : undefined);
72
72
  }
73
73
  ChatAskUtil.entryOf = entryOf;
74
+ /** The saved ones by their file, made once for a list: asked of every task as the lists draw, of hundreds. */
75
+ const indexed = new WeakMap();
76
+ function byFile(saved) {
77
+ let index = indexed.get(saved);
78
+ if (!index) {
79
+ index = new Map();
80
+ for (const each of saved) {
81
+ if (!index.has(each.sessionFile)) {
82
+ index.set(each.sessionFile, each);
83
+ }
84
+ }
85
+ indexed.set(saved, index);
86
+ }
87
+ return index;
88
+ }
74
89
  /** Whether it waits for the user: it asks, or a dialog of it waits. */
75
90
  function waits(entry, letGo) {
76
91
  return !!entry.waiting || !!asking(entry, letGo);
@@ -39,6 +39,8 @@ export declare function ChatHomeItem({ row, time, home, selected, pinned, onPin,
39
39
  pinned: boolean;
40
40
  onPin(pinned: boolean): void;
41
41
  }): React.JSX.Element;
42
+ /** What a row of a task does to the double's home: marks it seen, deletes it. */
43
+ export type ChatTaskHome = Pick<ChatHome, 'look' | 'remove'>;
42
44
  /**
43
45
  * 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
46
  * 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 +48,8 @@ export declare function ChatHomeItem({ row, time, home, selected, pinned, onPin,
46
48
  */
47
49
  export declare const ChatTaskItem: React.MemoExoticComponent<({ task, home, unseen, time, onPicked, }: {
48
50
  task: WebTaskEntry;
49
- home: ChatHome;
51
+ /** What it does to the double's home: one that stays the same (ChatList), for the row not to draw again for nothing. */
52
+ home: ChatTaskHome;
50
53
  unseen: boolean;
51
54
  time: string;
52
55
  /** As it opens in the main area: a drawer closes, a phone slides it in (ChatListProps.onPicked). */
@@ -56,8 +59,10 @@ export declare const ChatTaskItem: React.MemoExoticComponent<({ task, home, unse
56
59
  * The top of the double's list: its card (`double`, unless a search leaves it out), then what waits for the user to
57
60
  * decide, above the conversations. The rows extensions add are rows of the list, pinned at first (ChatListUtil.offerPins).
58
61
  */
59
- export declare function ChatHomeTop({ home, double, waiting, counts, unseen, now, onPicked, }: {
62
+ export declare function ChatHomeTop({ home, taskHome, double, waiting, counts, unseen, now, onPicked, }: {
60
63
  home: ChatHome;
64
+ /** The same, for the rows of what waits for the user (ChatTaskItem). */
65
+ taskHome: ChatTaskHome;
61
66
  double: boolean;
62
67
  waiting: readonly WebTaskEntry[];
63
68
  counts: ChatHomeCounts;
@@ -120,7 +120,7 @@ export const ChatTaskItem = React.memo(function ChatTaskItem({ task, home, unsee
120
120
  * The top of the double's list: its card (`double`, unless a search leaves it out), then what waits for the user to
121
121
  * decide, above the conversations. The rows extensions add are rows of the list, pinned at first (ChatListUtil.offerPins).
122
122
  */
123
- export function ChatHomeTop({ home, double, waiting, counts, unseen, now, onPicked, }) {
123
+ export function ChatHomeTop({ home, taskHome, double, waiting, counts, unseen, now, onPicked, }) {
124
124
  const t = useT();
125
125
  return (React.createElement(React.Fragment, null,
126
126
  double && (React.createElement("section", { className: "ta-chat-section ta-chat-home" },
@@ -128,6 +128,6 @@ export function ChatHomeTop({ home, double, waiting, counts, unseen, now, onPick
128
128
  React.createElement(ChatDoubleItem, { home: home, counts: counts, unseen: unseen, now: now })))),
129
129
  waiting.length > 0 && (React.createElement("section", { className: "ta-chat-section ta-chat-decide" },
130
130
  React.createElement("div", { className: "ta-chat-section-title" }, t('ta.home.decide')),
131
- React.createElement("ul", { className: "ta-side-list" }, waiting.map(task => (React.createElement(ChatTaskItem, { key: task.key, task: task, home: home, unseen: false, time: ChatListUtil.clock(task.startedAt, now), onPicked: onPicked }))))))));
131
+ React.createElement("ul", { className: "ta-side-list" }, waiting.map(task => (React.createElement(ChatTaskItem, { key: task.key, task: task, home: taskHome, unseen: false, time: ChatListUtil.clock(task.startedAt, now), onPicked: onPicked }))))))));
132
132
  }
133
133
  //# 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,
@@ -1,12 +1,43 @@
1
1
  import * as React from 'react';
2
2
  import { ChatIcons } from '../extension/extension-view.js';
3
+ import { useLanguage } from '../i18n/use-t.js';
3
4
  import { WorkbenchUtil } from '../workbench-util.js';
4
5
  import { LauncherSearchUtil } from './launcher-search-util.js';
5
6
  /** The icons web extensions give conversations of theirs (WebExtensionAPI.registerChatIcon). */
6
7
  export var ChatIconUtil;
7
8
  (function (ChatIconUtil) {
8
- /** The icon of the first extension that gives one, with its tint; an extension that throws gives none. */
9
+ /** Counts what extensions said changed of their icons (ChatIconsProvider): what `find` remembered from before is asked again. */
10
+ let generation = 0;
11
+ const remembered = new WeakMap();
12
+ /** An extension said its icons changed, or the language did: they are asked again. */
13
+ function changed() {
14
+ generation++;
15
+ }
16
+ ChatIconUtil.changed = changed;
17
+ /**
18
+ * The icon of the first extension that gives one, with its tint; an extension that throws gives none. Asked once
19
+ * for a conversation (what WebChat has of it) until the icons change: the lists ask it of hundreds as they draw.
20
+ */
9
21
  function find(entries, chat) {
22
+ var _a, _b;
23
+ if (entries.length === 0) {
24
+ return undefined;
25
+ }
26
+ let memo = remembered.get(entries);
27
+ if ((memo === null || memo === void 0 ? void 0 : memo.generation) !== generation) {
28
+ memo = { generation, found: new Map() };
29
+ remembered.set(entries, memo);
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);
34
+ }
35
+ const found = ask(entries, { sessionFile: chat.sessionFile, cwd: chat.cwd, ...(chat.group ? { group: chat.group } : {}) });
36
+ memo.found.set(key, found);
37
+ return found;
38
+ }
39
+ ChatIconUtil.find = find;
40
+ function ask(entries, chat) {
10
41
  var _a;
11
42
  for (const { extension, source } of entries) {
12
43
  try {
@@ -30,7 +61,6 @@ export var ChatIconUtil;
30
61
  }
31
62
  return undefined;
32
63
  }
33
- ChatIconUtil.find = find;
34
64
  /**
35
65
  * Since when a conversation an extension archives sooner (WebChatIcon.archiveMinutes, archiveDays) stays listed,
36
66
  * for ChatListUtil.entries; none without extensions that give icons.
@@ -68,8 +98,18 @@ export var ChatIconUtil;
68
98
  /** Gives the lists the icons of the extensions, and draws their rows again when an extension says they changed. */
69
99
  export function ChatIconsProvider({ entries, children }) {
70
100
  const [version, setVersion] = React.useState(0);
101
+ // What an icon says (the name of its folder) may be in the language of the page.
102
+ const language = useLanguage();
103
+ const languageShown = React.useRef(language);
104
+ if (languageShown.current !== language) {
105
+ languageShown.current = language;
106
+ ChatIconUtil.changed();
107
+ }
71
108
  React.useEffect(() => {
72
- const changed = () => setVersion(count => count + 1);
109
+ const changed = () => {
110
+ ChatIconUtil.changed();
111
+ setVersion(count => count + 1);
112
+ };
73
113
  const stops = entries.map(({ source }) => {
74
114
  var _a;
75
115
  try {
@@ -85,7 +125,8 @@ export function ChatIconsProvider({ entries, children }) {
85
125
  }
86
126
  };
87
127
  }, [entries]);
88
- const value = React.useMemo(() => ({ entries: [...entries], version }), [entries, version]);
128
+ // biome-ignore lint/correctness/useExhaustiveDependencies: a new language is a new value, what the icons say read again
129
+ const value = React.useMemo(() => ({ entries: [...entries], version }), [entries, version, language]);
89
130
  return React.createElement(ChatIcons.Provider, { value: value }, children);
90
131
  }
91
132
  /** The icon of a conversation, when an extension gives it one. */
@@ -1,5 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import type { WebChat, WebHomeEntry } from '../extension/web-extension-api.js';
3
+ import type { ChatTaskHome } from './chat-home.js';
4
+ import { type ChatHome } from './chat-home-util.js';
3
5
  import type { ChatFolderIcon } from './chat-icon.js';
4
6
  import { type ChatEntry } from './chat-list-util.js';
5
7
  /**
@@ -30,3 +32,11 @@ export declare function usePageEnd(more: boolean, root: React.RefObject<HTMLElem
30
32
  page: string): void;
31
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. */
32
34
  export declare function useChatListMotion(list: React.RefObject<HTMLElement | null>, folder: React.RefObject<HTMLElement | null>): void;
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.
38
+ */
39
+ export declare function useTaskRows(onPicked: () => void, home: ChatHome | undefined): {
40
+ picked: () => void;
41
+ taskHome: ChatTaskHome;
42
+ };
@@ -84,4 +84,19 @@ export function useChatListMotion(list, folder) {
84
84
  useListMotion(list);
85
85
  useListMotion(folder);
86
86
  }
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.
90
+ */
91
+ export function useTaskRows(onPicked, home) {
92
+ const latest = React.useRef({ onPicked, home });
93
+ latest.current = { onPicked, home };
94
+ return React.useMemo(() => ({
95
+ picked: () => latest.current.onPicked(),
96
+ taskHome: {
97
+ look: (key, at) => { var _a; return (_a = latest.current.home) === null || _a === void 0 ? void 0 : _a.look(key, at); },
98
+ remove: tasks => { var _a; return (_a = latest.current.home) === null || _a === void 0 ? void 0 : _a.remove(tasks); },
99
+ },
100
+ }), []);
101
+ }
87
102
  //# sourceMappingURL=chat-list-hooks.js.map
@@ -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 } from './chat-list-hooks.js';
17
+ import { useChatListMotion, useMinute, useOfferPins, usePageEnd, useReadArchive, useTaskRows } 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,6 +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);
55
56
  // The last pinned first, as several may be: a conversation's file, a folder's key.
56
57
  const pinKey = React.useCallback((key, pin) => {
57
58
  const others = latest.current.pinned.filter(other => other !== key);
@@ -88,11 +89,8 @@ export function ChatList({ sessions, saved, removed: removedFiles, archived: arc
88
89
  },
89
90
  };
90
91
  }, [pinKey]);
91
- // A failure is a notice of the chat.
92
- const pick = (change) => {
93
- void change;
94
- onPicked();
95
- };
92
+ // A failure is a notice of the chat: what it changes goes on without the list.
93
+ const pick = (_change) => onPicked();
96
94
  // Worked out again only when the conversations or the search change, not as the minute or the selection does.
97
95
  // The bounds of the archive and of the fold move once a day.
98
96
  const searching = !!query.trim();
@@ -272,7 +270,7 @@ export function ChatList({ sessions, saved, removed: removedFiles, archived: arc
272
270
  }
273
271
  }, [folderShown, folder]);
274
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 }));
275
- const taskItem = (row) => home && (React.createElement(ChatTaskItem, { key: row.key, task: row.task, home: home, unseen: taskUnseen(row.task), time: ChatListUtil.clock(row.updatedAt, now), onPicked: onPicked }));
273
+ 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 }));
276
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) })); };
277
275
  const rowItem = (row, compact) => ChatListUtil.isFolder(row) ? folderItem(row) : ChatListUtil.isTask(row) ? taskItem(row) : ChatListUtil.isHome(row) ? homeItem(row) : item(row, compact);
278
276
  // The conversation shown is found in the list, however it came to be shown: out of a search that hides it, and scrolled to.
@@ -425,10 +423,10 @@ export function ChatList({ sessions, saved, removed: removedFiles, archived: arc
425
423
  // The double's card and the rows under it, then what waits for the user: above all the rest.
426
424
  const homeWaiting = homeTasks ? homeTasks.waiting.filter(task => ChatHomeUtil.matches(query, task.title, task.detail)) : [];
427
425
  const doubleEntry = home && double ? listed.find(entry => ChatListUtil.isDouble(entry, double)) : undefined;
428
- const homeTop = home && (React.createElement(ChatHomeTop, { home: home, double: ChatHomeUtil.matches(query, home.double.name), waiting: homeWaiting, counts: ChatHomeUtil.counts(home.tasks, task => {
426
+ const homeTop = home && (React.createElement(ChatHomeTop, { home: home, taskHome: taskHome, double: ChatHomeUtil.matches(query, home.double.name), waiting: homeWaiting, counts: ChatHomeUtil.counts(home.tasks, task => {
429
427
  const entry = task.session ? byFile.get(task.session) : undefined;
430
428
  return entry ? isUnseen(entry) : !task.session && taskUnseen(task);
431
- }), unseen: !!doubleEntry && isUnseen(doubleEntry), now: now, onPicked: onPicked }));
429
+ }), unseen: !!doubleEntry && isUnseen(doubleEntry), now: now, onPicked: picked }));
432
430
  const nothingFound = shown.length === 0 && taskRows.length === 0 && homeRows.length === 0;
433
431
  const listContent = busy ? (busyContent) : (React.createElement(React.Fragment, null,
434
432
  homeTop,