@celljs/ta-web 4.12.0 → 4.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +1 -1
- package/README.md +1 -1
- package/esm/browser/assistant/assistant-extension.js +14 -0
- package/esm/browser/assistant/assistant-initiative.d.ts +27 -0
- package/esm/browser/assistant/assistant-initiative.js +76 -0
- package/esm/browser/assistant/assistant-task-source.d.ts +7 -0
- package/esm/browser/assistant/assistant-task-source.js +12 -2
- package/esm/browser/assistant/assistant-view.js +5 -4
- package/esm/browser/assistant/assistant.d.ts +5 -0
- package/esm/browser/assistant/assistant.js +25 -6
- package/esm/browser/components/app-nav.d.ts +3 -1
- package/esm/browser/components/app-nav.js +5 -2
- package/esm/browser/components/app-view.js +18 -9
- package/esm/browser/components/asks-badge.d.ts +5 -0
- package/esm/browser/components/asks-badge.js +8 -0
- package/esm/browser/components/chat-asks.d.ts +46 -0
- package/esm/browser/components/chat-asks.js +101 -0
- package/esm/browser/components/chat-list.d.ts +7 -1
- package/esm/browser/components/chat-list.js +46 -17
- package/esm/browser/components/composer-addon-util.d.ts +11 -0
- package/esm/browser/components/composer-addon-util.js +40 -0
- package/esm/browser/components/composer-addons.d.ts +1 -7
- package/esm/browser/components/composer-addons.js +1 -27
- package/esm/browser/components/composer.d.ts +7 -1
- package/esm/browser/components/composer.js +33 -20
- package/esm/browser/components/connection-bar.js +31 -12
- package/esm/browser/components/conversation-scroll-util.d.ts +5 -0
- package/esm/browser/components/conversation-scroll-util.js +18 -0
- package/esm/browser/components/conversation-scroll.d.ts +12 -2
- package/esm/browser/components/conversation-scroll.js +68 -5
- package/esm/browser/components/discover-view.js +5 -1
- package/esm/browser/components/earlier-messages.d.ts +10 -3
- package/esm/browser/components/earlier-messages.js +14 -8
- package/esm/browser/components/folder-picker.d.ts +2 -0
- package/esm/browser/components/folder-picker.js +7 -0
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/markdown.js +4 -2
- package/esm/browser/components/media.js +4 -39
- package/esm/browser/components/mermaid-view.js +45 -3
- package/esm/browser/components/message-footer.d.ts +2 -0
- package/esm/browser/components/message-footer.js +8 -1
- package/esm/browser/components/message-list.d.ts +12 -0
- package/esm/browser/components/message-list.js +156 -25
- package/esm/browser/components/phone-shell.d.ts +7 -2
- package/esm/browser/components/phone-shell.js +7 -3
- package/esm/browser/components/relay-services.d.ts +24 -0
- package/esm/browser/components/relay-services.js +249 -0
- package/esm/browser/components/relay-view.js +17 -1
- package/esm/browser/components/remote-hosts.js +1 -1
- package/esm/browser/components/session-view.js +16 -4
- package/esm/browser/components/settings-controls.js +3 -3
- package/esm/browser/components/settings-parts.js +13 -1
- package/esm/browser/components/ta-avatar.js +6 -0
- package/esm/browser/components/tool-result.d.ts +13 -0
- package/esm/browser/components/tool-result.js +138 -0
- package/esm/browser/components/tool-view.js +5 -15
- package/esm/browser/components/web-composer.js +2 -1
- package/esm/browser/extension/extension-view.d.ts +3 -1
- package/esm/browser/extension/extension-view.js +7 -0
- package/esm/browser/extension/icons.js +9 -1
- package/esm/browser/extension/web-api-components.d.ts +3 -3
- package/esm/browser/extension/web-api-contributions.d.ts +119 -0
- package/esm/browser/extension/web-extension-api.d.ts +23 -46
- package/esm/browser/extension/web-extension-context.d.ts +6 -1
- package/esm/browser/extension/web-extension-context.js +63 -6
- package/esm/browser/extension/web-extension-protocol.d.ts +5 -1
- package/esm/browser/extension/web-extension-protocol.js +1 -0
- package/esm/browser/extension/web-extension-run.d.ts +3 -2
- package/esm/browser/extension/web-extension-run.js +3 -0
- package/esm/browser/extension/web-extensions.d.ts +2 -8
- package/esm/browser/extension/web-extensions.js +9 -35
- package/esm/browser/extension/web-page-list.d.ts +25 -0
- package/esm/browser/extension/web-page-list.js +35 -0
- package/esm/browser/extension/web-session-notices.d.ts +6 -1
- package/esm/browser/extension/web-session-notices.js +30 -4
- package/esm/browser/extension/web-sharing.d.ts +5 -2
- package/esm/browser/extension/web-sharing.js +10 -1
- package/esm/browser/i18n/locales.d.ts +69 -3
- package/esm/browser/i18n/messages.d.ts +68 -2
- package/esm/browser/i18n/messages.js +138 -6
- package/esm/browser/markdown/code-renderers.d.ts +4 -0
- package/esm/browser/markdown/code-renderers.js +4 -0
- package/esm/browser/markdown/lazy.d.ts +8 -0
- package/esm/browser/markdown/lazy.js +35 -0
- package/esm/browser/markdown/mermaid.d.ts +15 -3
- package/esm/browser/markdown/mermaid.js +45 -6
- package/esm/browser/notices/notices-protocol.d.ts +5 -0
- package/esm/browser/notices/notices.d.ts +19 -0
- package/esm/browser/notices/notices.js +85 -2
- package/esm/browser/notices/session-notices.d.ts +5 -2
- package/esm/browser/notices/session-notices.js +10 -1
- package/esm/browser/style/base.d.ts +1 -1
- package/esm/browser/style/base.js +2 -1
- package/esm/browser/style/conversation.d.ts +1 -1
- package/esm/browser/style/conversation.js +51 -0
- package/esm/browser/style/device.js +3 -0
- package/esm/browser/style/layout.d.ts +1 -1
- package/esm/browser/style/layout.js +24 -9
- package/esm/browser/style/pages.d.ts +1 -1
- package/esm/browser/style/pages.js +2 -0
- package/esm/browser/style/phone.d.ts +1 -1
- package/esm/browser/style/phone.js +2 -0
- package/esm/browser/style/shell.d.ts +1 -1
- package/esm/browser/style/shell.js +14 -3
- package/esm/browser/util/desktop.d.ts +18 -1
- package/esm/browser/util/desktop.js +13 -0
- package/esm/browser/util/process.d.ts +26 -1
- package/esm/browser/util/process.js +79 -5
- package/esm/browser/util/progress.d.ts +6 -1
- package/esm/browser/util/progress.js +11 -2
- package/esm/browser/util/scroll-rest.d.ts +10 -0
- package/esm/browser/util/scroll-rest.js +44 -0
- package/esm/browser/util/tool-result.d.ts +32 -0
- package/esm/browser/util/tool-result.js +85 -0
- package/esm/browser/util/tool.js +7 -0
- package/lib/browser/assistant/assistant-extension.js +14 -0
- package/lib/browser/assistant/assistant-initiative.d.ts +28 -0
- package/lib/browser/assistant/assistant-initiative.js +80 -0
- package/lib/browser/assistant/assistant-task-source.d.ts +7 -0
- package/lib/browser/assistant/assistant-task-source.js +12 -2
- package/lib/browser/assistant/assistant-view.js +3 -2
- package/lib/browser/assistant/assistant.d.ts +5 -0
- package/lib/browser/assistant/assistant.js +24 -5
- package/lib/browser/components/app-nav.d.ts +3 -1
- package/lib/browser/components/app-nav.js +5 -2
- package/lib/browser/components/app-view.js +17 -8
- package/lib/browser/components/asks-badge.d.ts +6 -0
- package/lib/browser/components/asks-badge.js +44 -0
- package/lib/browser/components/chat-asks.d.ts +47 -0
- package/lib/browser/components/chat-asks.js +104 -0
- package/lib/browser/components/chat-list.d.ts +7 -1
- package/lib/browser/components/chat-list.js +46 -17
- package/lib/browser/components/composer-addon-util.d.ts +12 -0
- package/lib/browser/components/composer-addon-util.js +76 -0
- package/lib/browser/components/composer-addons.d.ts +1 -7
- package/lib/browser/components/composer-addons.js +2 -29
- package/lib/browser/components/composer.d.ts +7 -1
- package/lib/browser/components/composer.js +33 -19
- package/lib/browser/components/connection-bar.js +30 -11
- package/lib/browser/components/conversation-scroll-util.d.ts +5 -0
- package/lib/browser/components/conversation-scroll-util.js +18 -0
- package/lib/browser/components/conversation-scroll.d.ts +12 -2
- package/lib/browser/components/conversation-scroll.js +68 -5
- package/lib/browser/components/discover-view.js +5 -1
- package/lib/browser/components/earlier-messages.d.ts +10 -3
- package/lib/browser/components/earlier-messages.js +16 -9
- package/lib/browser/components/folder-picker.d.ts +2 -0
- package/lib/browser/components/folder-picker.js +7 -0
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/markdown.js +3 -1
- package/lib/browser/components/media.js +3 -38
- package/lib/browser/components/mermaid-view.js +45 -3
- package/lib/browser/components/message-footer.d.ts +2 -0
- package/lib/browser/components/message-footer.js +8 -0
- package/lib/browser/components/message-list.d.ts +12 -0
- package/lib/browser/components/message-list.js +153 -20
- package/lib/browser/components/phone-shell.d.ts +7 -2
- package/lib/browser/components/phone-shell.js +7 -3
- package/lib/browser/components/relay-services.d.ts +25 -0
- package/lib/browser/components/relay-services.js +286 -0
- package/lib/browser/components/relay-view.js +17 -1
- package/lib/browser/components/remote-hosts.js +1 -1
- package/lib/browser/components/session-view.js +15 -3
- package/lib/browser/components/settings-controls.js +3 -3
- package/lib/browser/components/settings-parts.js +13 -1
- package/lib/browser/components/ta-avatar.js +6 -0
- package/lib/browser/components/tool-result.d.ts +14 -0
- package/lib/browser/components/tool-result.js +175 -0
- package/lib/browser/components/tool-view.js +10 -20
- package/lib/browser/components/web-composer.js +2 -1
- package/lib/browser/extension/extension-view.d.ts +3 -1
- package/lib/browser/extension/extension-view.js +8 -1
- package/lib/browser/extension/icons.js +8 -0
- package/lib/browser/extension/web-api-components.d.ts +3 -3
- package/lib/browser/extension/web-api-contributions.d.ts +119 -0
- package/lib/browser/extension/web-extension-api.d.ts +23 -46
- package/lib/browser/extension/web-extension-context.d.ts +6 -1
- package/lib/browser/extension/web-extension-context.js +63 -6
- package/lib/browser/extension/web-extension-protocol.d.ts +5 -1
- package/lib/browser/extension/web-extension-protocol.js +1 -0
- package/lib/browser/extension/web-extension-run.d.ts +3 -2
- package/lib/browser/extension/web-extension-run.js +3 -0
- package/lib/browser/extension/web-extensions.d.ts +2 -8
- package/lib/browser/extension/web-extensions.js +9 -35
- package/lib/browser/extension/web-page-list.d.ts +26 -0
- package/lib/browser/extension/web-page-list.js +39 -0
- package/lib/browser/extension/web-session-notices.d.ts +6 -1
- package/lib/browser/extension/web-session-notices.js +30 -4
- package/lib/browser/extension/web-sharing.d.ts +5 -2
- package/lib/browser/extension/web-sharing.js +10 -1
- package/lib/browser/i18n/locales.d.ts +69 -3
- package/lib/browser/i18n/messages.d.ts +68 -2
- package/lib/browser/i18n/messages.js +138 -6
- package/lib/browser/markdown/code-renderers.d.ts +4 -0
- package/lib/browser/markdown/code-renderers.js +5 -1
- package/lib/browser/markdown/lazy.d.ts +8 -0
- package/lib/browser/markdown/lazy.js +37 -1
- package/lib/browser/markdown/mermaid.d.ts +15 -3
- package/lib/browser/markdown/mermaid.js +44 -5
- package/lib/browser/notices/notices-protocol.d.ts +5 -0
- package/lib/browser/notices/notices.d.ts +19 -0
- package/lib/browser/notices/notices.js +84 -1
- package/lib/browser/notices/session-notices.d.ts +5 -2
- package/lib/browser/notices/session-notices.js +10 -1
- package/lib/browser/style/base.d.ts +1 -1
- package/lib/browser/style/base.js +2 -1
- package/lib/browser/style/conversation.d.ts +1 -1
- package/lib/browser/style/conversation.js +51 -0
- package/lib/browser/style/device.js +3 -0
- package/lib/browser/style/layout.d.ts +1 -1
- package/lib/browser/style/layout.js +24 -9
- package/lib/browser/style/pages.d.ts +1 -1
- package/lib/browser/style/pages.js +2 -0
- package/lib/browser/style/phone.d.ts +1 -1
- package/lib/browser/style/phone.js +2 -0
- package/lib/browser/style/shell.d.ts +1 -1
- package/lib/browser/style/shell.js +14 -3
- package/lib/browser/util/desktop.d.ts +18 -1
- package/lib/browser/util/desktop.js +13 -0
- package/lib/browser/util/process.d.ts +26 -1
- package/lib/browser/util/process.js +79 -5
- package/lib/browser/util/progress.d.ts +6 -1
- package/lib/browser/util/progress.js +11 -2
- package/lib/browser/util/scroll-rest.d.ts +11 -0
- package/lib/browser/util/scroll-rest.js +47 -0
- package/lib/browser/util/tool-result.d.ts +33 -0
- package/lib/browser/util/tool-result.js +88 -0
- package/lib/browser/util/tool.js +7 -0
- package/package.json +7 -7
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useT } from '../i18n/use-t.js';
|
|
3
|
+
/** How many conversations wait for the user to decide, on the entry of the chats (a tab, the rail): blue, as their ? on the rows. */
|
|
4
|
+
export function AsksBadge({ count }) {
|
|
5
|
+
const t = useT();
|
|
6
|
+
return (React.createElement("span", { className: "ta-asks-badge", role: "img", "aria-label": t('ta.chat.asksCount', { count }) }, count > 99 ? '99+' : count));
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=asks-badge.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { TaAsking, TaSavedSessionInfo, TaSessionInfo } from '@celljs/ta-protocol';
|
|
2
|
+
import type { WebAsk } from '../extension/web-api-contributions.js';
|
|
3
|
+
import type { StateSpec } from '../state/state-protocol.js';
|
|
4
|
+
/**
|
|
5
|
+
* The asks the user let go without answering (`Not now` of a row), by the file of their conversation: when the
|
|
6
|
+
* ask was (TaAsking.at). A later ask of the same conversation waits for them again.
|
|
7
|
+
*/
|
|
8
|
+
export type LetGoAsks = Record<string, number>;
|
|
9
|
+
/** The same on every device: one let go on the phone is let go on the computer too. */
|
|
10
|
+
export declare const LET_GO_ASKS: StateSpec<LetGoAsks>;
|
|
11
|
+
/** What a list reads of a conversation to know whether it waits for the user. */
|
|
12
|
+
export interface AskingEntry {
|
|
13
|
+
sessionFile?: string;
|
|
14
|
+
sessionId?: string;
|
|
15
|
+
asking?: TaAsking;
|
|
16
|
+
/** A dialog of an extension waits for an answer (TaSessionInfo.waiting): only an open session has one. */
|
|
17
|
+
waiting?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Which conversations wait for the user to decide: their last turn asked (TaSessionInfo.asking) and no message of
|
|
21
|
+
* theirs came since, or a dialog waits. Unlike a dot of something unseen, seeing it does not end it; answering does,
|
|
22
|
+
* typed or tapped, or letting it go.
|
|
23
|
+
*/
|
|
24
|
+
export declare namespace ChatAskUtil {
|
|
25
|
+
function parse(value: unknown): LetGoAsks | undefined;
|
|
26
|
+
/** Each let go as late as either page let it go; `a` itself when `b` adds nothing. */
|
|
27
|
+
function merge(a: LetGoAsks, b: LetGoAsks): LetGoAsks;
|
|
28
|
+
/** Lets the ask of the conversation go, as it was asked at `at`. */
|
|
29
|
+
function letGo(before: LetGoAsks, file: string, at: number): LetGoAsks;
|
|
30
|
+
/** What it still asks the user: none once answered or let go. */
|
|
31
|
+
function asking(entry: AskingEntry, letGo: LetGoAsks): TaAsking | undefined;
|
|
32
|
+
/** Whether it waits for the user: it asks, or a dialog of it waits. */
|
|
33
|
+
function waits(entry: AskingEntry, letGo: LetGoAsks): boolean;
|
|
34
|
+
/** How many of the conversations the list shows wait for the user: the count on the tab of the chats. */
|
|
35
|
+
function count(entries: readonly AskingEntry[], letGo: LetGoAsks): number;
|
|
36
|
+
/**
|
|
37
|
+
* The conversations that wait for the user, for extensions (ui.useAsks): the open ones and those saved, but those a
|
|
38
|
+
* package opened for a role of its own and closed (the list leaves them out), the latest ask first.
|
|
39
|
+
*/
|
|
40
|
+
function list(sessions: readonly TaSessionInfo[], saved: readonly TaSavedSessionInfo[], letGo: LetGoAsks): WebAsk[];
|
|
41
|
+
/** Those that wait for the user, a dialog first, then the latest ask first; and the rest, in the order they had. */
|
|
42
|
+
function apart<T extends AskingEntry>(entries: readonly T[], letGo: LetGoAsks): {
|
|
43
|
+
asking: T[];
|
|
44
|
+
rest: T[];
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/** The asks let go remembered at most: past that, the oldest are forgotten, which are long answered. */
|
|
2
|
+
const KEPT = 100;
|
|
3
|
+
/** The same on every device: one let go on the phone is let go on the computer too. */
|
|
4
|
+
export const LET_GO_ASKS = {
|
|
5
|
+
key: 'chat.letGoAsks',
|
|
6
|
+
tier: 'user',
|
|
7
|
+
initial: {},
|
|
8
|
+
parse: value => ChatAskUtil.parse(value),
|
|
9
|
+
merge: (local, remote) => ChatAskUtil.merge(local, remote),
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Which conversations wait for the user to decide: their last turn asked (TaSessionInfo.asking) and no message of
|
|
13
|
+
* theirs came since, or a dialog waits. Unlike a dot of something unseen, seeing it does not end it; answering does,
|
|
14
|
+
* typed or tapped, or letting it go.
|
|
15
|
+
*/
|
|
16
|
+
export var ChatAskUtil;
|
|
17
|
+
(function (ChatAskUtil) {
|
|
18
|
+
function parse(value) {
|
|
19
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
return Object.fromEntries(Object.entries(value).filter(([, at]) => typeof at === 'number'));
|
|
23
|
+
}
|
|
24
|
+
ChatAskUtil.parse = parse;
|
|
25
|
+
/** Each let go as late as either page let it go; `a` itself when `b` adds nothing. */
|
|
26
|
+
function merge(a, b) {
|
|
27
|
+
const later = Object.entries(b).filter(([file, at]) => { var _a; return at > ((_a = a[file]) !== null && _a !== void 0 ? _a : 0); });
|
|
28
|
+
return later.length ? keep({ ...a, ...Object.fromEntries(later) }) : a;
|
|
29
|
+
}
|
|
30
|
+
ChatAskUtil.merge = merge;
|
|
31
|
+
/** Lets the ask of the conversation go, as it was asked at `at`. */
|
|
32
|
+
function letGo(before, file, at) {
|
|
33
|
+
var _a;
|
|
34
|
+
return ((_a = before[file]) !== null && _a !== void 0 ? _a : 0) >= at ? before : keep({ ...before, [file]: at });
|
|
35
|
+
}
|
|
36
|
+
ChatAskUtil.letGo = letGo;
|
|
37
|
+
function keep(letGo) {
|
|
38
|
+
const files = Object.keys(letGo);
|
|
39
|
+
if (files.length <= KEPT) {
|
|
40
|
+
return letGo;
|
|
41
|
+
}
|
|
42
|
+
const kept = files.sort((x, y) => letGo[y] - letGo[x]).slice(0, KEPT);
|
|
43
|
+
return Object.fromEntries(kept.map(file => [file, letGo[file]]));
|
|
44
|
+
}
|
|
45
|
+
function fileOf(entry) {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
return (_b = (_a = entry.sessionFile) !== null && _a !== void 0 ? _a : entry.sessionId) !== null && _b !== void 0 ? _b : '';
|
|
48
|
+
}
|
|
49
|
+
/** What it still asks the user: none once answered or let go. */
|
|
50
|
+
function asking(entry, letGo) {
|
|
51
|
+
var _a;
|
|
52
|
+
const { asking } = entry;
|
|
53
|
+
return asking && asking.at > ((_a = letGo[fileOf(entry)]) !== null && _a !== void 0 ? _a : -1) ? asking : undefined;
|
|
54
|
+
}
|
|
55
|
+
ChatAskUtil.asking = asking;
|
|
56
|
+
/** Whether it waits for the user: it asks, or a dialog of it waits. */
|
|
57
|
+
function waits(entry, letGo) {
|
|
58
|
+
return !!entry.waiting || !!asking(entry, letGo);
|
|
59
|
+
}
|
|
60
|
+
ChatAskUtil.waits = waits;
|
|
61
|
+
/** How many of the conversations the list shows wait for the user: the count on the tab of the chats. */
|
|
62
|
+
function count(entries, letGo) {
|
|
63
|
+
return entries.filter(entry => waits(entry, letGo)).length;
|
|
64
|
+
}
|
|
65
|
+
ChatAskUtil.count = count;
|
|
66
|
+
/**
|
|
67
|
+
* The conversations that wait for the user, for extensions (ui.useAsks): the open ones and those saved, but those a
|
|
68
|
+
* package opened for a role of its own and closed (the list leaves them out), the latest ask first.
|
|
69
|
+
*/
|
|
70
|
+
function list(sessions, saved, letGo) {
|
|
71
|
+
const open = new Set(sessions.map(session => session.sessionFile));
|
|
72
|
+
const closed = saved.filter(session => !session.group && !open.has(session.sessionFile));
|
|
73
|
+
return apart([...sessions, ...closed], letGo).asking.map(entry => {
|
|
74
|
+
var _a, _b;
|
|
75
|
+
var _c;
|
|
76
|
+
const question = (_a = asking(entry, letGo)) === null || _a === void 0 ? void 0 : _a.question;
|
|
77
|
+
return {
|
|
78
|
+
sessionFile: fileOf(entry),
|
|
79
|
+
sessionId: 'sessionId' in entry ? entry.sessionId : undefined,
|
|
80
|
+
cwd: entry.cwd,
|
|
81
|
+
title: entry.sessionName || entry.firstMessage || '',
|
|
82
|
+
...(question && !entry.waiting ? { question } : {}),
|
|
83
|
+
at: (_c = (_b = entry.asking) === null || _b === void 0 ? void 0 : _b.at) !== null && _c !== void 0 ? _c : entry.updatedAt,
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
ChatAskUtil.list = list;
|
|
88
|
+
/** Those that wait for the user, a dialog first, then the latest ask first; and the rest, in the order they had. */
|
|
89
|
+
function apart(entries, letGo) {
|
|
90
|
+
const asking = [];
|
|
91
|
+
const rest = [];
|
|
92
|
+
for (const entry of entries) {
|
|
93
|
+
(waits(entry, letGo) ? asking : rest).push(entry);
|
|
94
|
+
}
|
|
95
|
+
const rank = (entry) => { var _a; var _b; return (entry.waiting ? Number.POSITIVE_INFINITY : ((_b = (_a = entry.asking) === null || _a === void 0 ? void 0 : _a.at) !== null && _b !== void 0 ? _b : 0)); };
|
|
96
|
+
asking.sort((x, y) => rank(y) - rank(x));
|
|
97
|
+
return { asking, rest };
|
|
98
|
+
}
|
|
99
|
+
ChatAskUtil.apart = apart;
|
|
100
|
+
})(ChatAskUtil || (ChatAskUtil = {}));
|
|
101
|
+
//# sourceMappingURL=chat-asks.js.map
|
|
@@ -5,6 +5,7 @@ import type { TaChat } from '../chat/chat-protocol.js';
|
|
|
5
5
|
import type { MessageId } from '../i18n/messages.js';
|
|
6
6
|
import { type Translate } from '../i18n/use-t.js';
|
|
7
7
|
import { type StateSpec } from '../state/state-protocol.js';
|
|
8
|
+
import { type LetGoAsks } from './chat-asks.js';
|
|
8
9
|
import { type ChatSeen } from './chat-seen.js';
|
|
9
10
|
/** Where a conversation belongs: the directory of the user's own, or the package that opened it. */
|
|
10
11
|
export interface ChatSource {
|
|
@@ -61,6 +62,8 @@ export declare namespace ChatListUtil {
|
|
|
61
62
|
function key(entry: ChatEntry): string;
|
|
62
63
|
/** What stays the same as it closes and opens again: its file, else (before it has one) the id of its session. */
|
|
63
64
|
function file(entry: ChatEntry): string;
|
|
65
|
+
/** The files the list keeps however old (ChatListUtil.entries): those pinned, and the saved ones that still ask the user. */
|
|
66
|
+
function keptFiles(saved: readonly TaSavedSessionInfo[], pinned: readonly string[], letGo: LetGoAsks): readonly string[];
|
|
64
67
|
/** Those pinned, and the rest, each in the order it had. */
|
|
65
68
|
function pinnedApart(sessions: ChatEntry[], pinned: readonly string[]): {
|
|
66
69
|
pinned: ChatEntry[];
|
|
@@ -173,6 +176,9 @@ export interface ChatListProps {
|
|
|
173
176
|
looking?: string;
|
|
174
177
|
/** When the user last saw each conversation (useSeenChats): those that said something since have a dot. */
|
|
175
178
|
seen: ChatSeen;
|
|
179
|
+
/** The asks the user let go (LET_GO_ASKS): the others wait for them at the top of the list. */
|
|
180
|
+
letGo: LetGoAsks;
|
|
181
|
+
onLetGo(entry: ChatEntry): void;
|
|
176
182
|
/** As a chat is picked, not once it is shown (it shows at once, while it opens): a drawer closes, a phone slides it in. */
|
|
177
183
|
onPicked(): void;
|
|
178
184
|
/** Under the head: the state of the connection on a phone (ConnectionBanner). */
|
|
@@ -185,4 +191,4 @@ export interface ChatListProps {
|
|
|
185
191
|
* opened or searched, and those taken out last, folded, to put back. However long, it draws the rows of
|
|
186
192
|
* its first screens, and more as it is scrolled to its end.
|
|
187
193
|
*/
|
|
188
|
-
export declare function ChatList({ sessions, saved, removed: removedFiles, archived: archivedSaved, onArchive, foldDays, archiveDays, selected, chat, byDirectory, onByDirectory, folded, onFolded, onPicked, double, notice, pinned, onPinned, looking, seen, }: ChatListProps): React.JSX.Element;
|
|
194
|
+
export declare function ChatList({ sessions, saved, removed: removedFiles, archived: archivedSaved, onArchive, foldDays, archiveDays, selected, chat, byDirectory, onByDirectory, folded, onFolded, onPicked, double, notice, pinned, onPinned, looking, seen, letGo, onLetGo, }: ChatListProps): React.JSX.Element;
|
|
@@ -8,6 +8,7 @@ import { StateUtil } from '../state/state-protocol.js';
|
|
|
8
8
|
import { MessageUtil } from '../util/message.js';
|
|
9
9
|
import { WorkbenchUtil } from '../workbench-util.js';
|
|
10
10
|
import { useBusy } from './busy.js';
|
|
11
|
+
import { ChatAskUtil } from './chat-asks.js';
|
|
11
12
|
import { ChatIconTile, ChatIconUtil, useChatIcon } from './chat-icon.js';
|
|
12
13
|
import { ChatSeenUtil } from './chat-seen.js';
|
|
13
14
|
import { useContextMenu } from './context-menu.js';
|
|
@@ -62,6 +63,12 @@ export var ChatListUtil;
|
|
|
62
63
|
return (_a = entry.sessionFile) !== null && _a !== void 0 ? _a : entry.sessionId;
|
|
63
64
|
}
|
|
64
65
|
ChatListUtil.file = file;
|
|
66
|
+
/** The files the list keeps however old (ChatListUtil.entries): those pinned, and the saved ones that still ask the user. */
|
|
67
|
+
function keptFiles(saved, pinned, letGo) {
|
|
68
|
+
const asking = saved.filter(session => ChatAskUtil.asking(session, letGo)).map(session => session.sessionFile);
|
|
69
|
+
return asking.length ? [...pinned, ...asking] : pinned;
|
|
70
|
+
}
|
|
71
|
+
ChatListUtil.keptFiles = keptFiles;
|
|
65
72
|
/** Those pinned, and the rest, each in the order it had. */
|
|
66
73
|
function pinnedApart(sessions, pinned) {
|
|
67
74
|
const files = new Set(pinned);
|
|
@@ -335,12 +342,19 @@ function ChatState({ streaming, waiting, task }) {
|
|
|
335
342
|
}
|
|
336
343
|
return null;
|
|
337
344
|
}
|
|
338
|
-
/**
|
|
339
|
-
|
|
345
|
+
/**
|
|
346
|
+
* Always there, so that it grows in and goes, the avatar never drawn again; told only while it is on. A conversation
|
|
347
|
+
* that waits for the user to decide has a blue ? instead, over an amber dot: seeing it does not end it, answering does.
|
|
348
|
+
*/
|
|
349
|
+
function ChatDot({ unseen, asks }) {
|
|
340
350
|
const t = useT();
|
|
341
|
-
|
|
351
|
+
if (asks) {
|
|
352
|
+
return (React.createElement("span", { className: "ta-chat-dot ta-on ta-asks", role: "img", "aria-label": t('ta.chat.asking') }, "?"));
|
|
353
|
+
}
|
|
354
|
+
return unseen ? React.createElement("span", { className: "ta-chat-dot ta-on", role: "img", "aria-label": t('ta.chat.unseen') }) : React.createElement("span", { className: "ta-chat-dot" });
|
|
342
355
|
}
|
|
343
|
-
const ChatItem = React.memo(function ChatItem({ session, source, selected, time, compact, actions, restorable, task, doubleName, handable, pinned, unseen, }) {
|
|
356
|
+
const ChatItem = React.memo(function ChatItem({ session, source, selected, time, compact, actions, restorable, task, doubleName, handable, pinned, unseen, asking, }) {
|
|
357
|
+
var _a;
|
|
344
358
|
const t = useT();
|
|
345
359
|
const onSelect = () => actions.open(session);
|
|
346
360
|
const [removing, run] = useBusy();
|
|
@@ -356,6 +370,7 @@ const ChatItem = React.memo(function ChatItem({ session, source, selected, time,
|
|
|
356
370
|
const [menu, openMenu] = useContextMenu();
|
|
357
371
|
const onContextMenu = (event) => openMenu(event, [
|
|
358
372
|
{ label: t('ta.chat.open'), run: onSelect },
|
|
373
|
+
...(asking ? [{ label: t('ta.chat.letGo'), run: () => actions.letGo(session) }] : []),
|
|
359
374
|
...(onPin ? [{ label: t(pinned ? 'ta.chat.unpin' : 'ta.chat.pin'), run: onPin }] : []),
|
|
360
375
|
...(onHand ? [{ label: t('ta.chat.handToDouble'), run: onHand }] : []),
|
|
361
376
|
// What extensions add (Share…) before taking it out, which stays last.
|
|
@@ -375,24 +390,25 @@ const ChatItem = React.memo(function ChatItem({ session, source, selected, time,
|
|
|
375
390
|
// A dialog of it waits for the user: it needs them, it does not answer meanwhile.
|
|
376
391
|
const waiting = ChatListUtil.isOpen(session) && !!session.waiting;
|
|
377
392
|
const streaming = ChatListUtil.isOpen(session) && session.isStreaming && !waiting;
|
|
378
|
-
const
|
|
393
|
+
const asks = waiting || (!!asking && !streaming);
|
|
394
|
+
const mood = asks ? 'attention' : streaming ? 'working' : 'idle';
|
|
379
395
|
const state = React.createElement(ChatState, { streaming: streaming, waiting: waiting, task: task });
|
|
380
396
|
// As in a messaging app, the last thing said; its directory before the first, and on hover in place of its time.
|
|
381
397
|
const said = ChatListUtil.preview(session, title);
|
|
382
398
|
const place = who ? MessageUtil.basename(session.cwd) : source.label;
|
|
383
399
|
const ended = task === 'failed' || task === 'stopped' ? task : undefined;
|
|
384
|
-
return (React.createElement(SwipeRow, { as: "li", className: `ta-chat-row${selected ? ' ta-selected' : ''}${who ? ` ta-chat-${who.kind}` : ''}`, "data-unseen": unseen ? '' : undefined, actions: swipe, overlay: menu, onContextMenu: onContextMenu },
|
|
400
|
+
return (React.createElement(SwipeRow, { as: "li", className: `ta-chat-row${selected ? ' ta-selected' : ''}${who ? ` ta-chat-${who.kind}` : ''}`, "data-unseen": unseen && !asks ? '' : undefined, "data-asks": asks ? '' : undefined, actions: swipe, overlay: menu, onContextMenu: onContextMenu },
|
|
385
401
|
React.createElement("button", { type: "button", className: `ta-chat-item${compact ? ' ta-compact' : ''}${removing ? ' ta-pending' : ''}`, title: `${title}\n${source.title}`, "aria-current": selected ? 'true' : undefined, onClick: onSelect }, compact ? (React.createElement("span", { className: "ta-chat-text" },
|
|
386
402
|
React.createElement("span", { className: "ta-chat-line" },
|
|
387
403
|
who && React.createElement(ChatAvatar, { session: session, source: source, who: who, size: 20, mood: mood }),
|
|
388
404
|
tag,
|
|
389
405
|
React.createElement("span", { className: "ta-chat-title" }, title),
|
|
390
406
|
state,
|
|
391
|
-
React.createElement(
|
|
407
|
+
React.createElement(ChatDot, { unseen: !!unseen, asks: asks }),
|
|
392
408
|
React.createElement("span", { className: "ta-chat-time" }, removing && handheld ? React.createElement("span", { className: "ta-spinner ta-later" }) : time)))) : (React.createElement(React.Fragment, null,
|
|
393
409
|
React.createElement("span", { className: "ta-chat-avatar-box" },
|
|
394
410
|
React.createElement(ChatAvatar, { session: session, source: source, who: who, size: 38, mood: mood }),
|
|
395
|
-
React.createElement(
|
|
411
|
+
React.createElement(ChatDot, { unseen: !!unseen, asks: asks })),
|
|
396
412
|
React.createElement("span", { className: "ta-chat-text" },
|
|
397
413
|
React.createElement("span", { className: "ta-chat-line" },
|
|
398
414
|
tag,
|
|
@@ -408,10 +424,14 @@ const ChatItem = React.memo(function ChatItem({ session, source, selected, time,
|
|
|
408
424
|
"[",
|
|
409
425
|
t('ta.task.waiting'),
|
|
410
426
|
"]"),
|
|
411
|
-
|
|
427
|
+
asks && !waiting && React.createElement("span", { className: "ta-chat-flag ta-waiting" },
|
|
428
|
+
"[",
|
|
429
|
+
t('ta.chat.asking'),
|
|
430
|
+
"]"),
|
|
431
|
+
ended && !streaming && !asks && (React.createElement("span", { className: `ta-chat-flag ta-${ended}` },
|
|
412
432
|
"[",
|
|
413
433
|
t(ended === 'failed' ? 'ta.task.failed' : 'ta.task.stopped'),
|
|
414
|
-
"]")), said !== null &&
|
|
434
|
+
"]")), (_a = (asks && !waiting ? asking : said)) !== null && _a !== void 0 ? _a : (React.createElement("span", { className: "ta-chat-dir" },
|
|
415
435
|
React.createElement(Icon, { icon: Folder, size: 12 }),
|
|
416
436
|
place))),
|
|
417
437
|
streaming && React.createElement("span", { className: "ta-chat-state ta-spinner" })))))),
|
|
@@ -424,7 +444,7 @@ const ChatItem = React.memo(function ChatItem({ session, source, selected, time,
|
|
|
424
444
|
* opened or searched, and those taken out last, folded, to put back. However long, it draws the rows of
|
|
425
445
|
* its first screens, and more as it is scrolled to its end.
|
|
426
446
|
*/
|
|
427
|
-
export function ChatList({ sessions, saved, removed: removedFiles, archived: archivedSaved, onArchive, foldDays, archiveDays, selected, chat, byDirectory, onByDirectory, folded, onFolded, onPicked, double, notice, pinned, onPinned, looking, seen, }) {
|
|
447
|
+
export function ChatList({ sessions, saved, removed: removedFiles, archived: archivedSaved, onArchive, foldDays, archiveDays, selected, chat, byDirectory, onByDirectory, folded, onFolded, onPicked, double, notice, pinned, onPinned, looking, seen, letGo, onLetGo, }) {
|
|
428
448
|
const t = useT();
|
|
429
449
|
const now = useMinute();
|
|
430
450
|
const [query, setQuery] = React.useState('');
|
|
@@ -438,8 +458,8 @@ export function ChatList({ sessions, saved, removed: removedFiles, archived: arc
|
|
|
438
458
|
const pageCount = typeof IntersectionObserver === 'undefined' ? Number.POSITIVE_INFINITY : paged.query === query ? paged.count : CHAT_PAGE;
|
|
439
459
|
// What the rows do reads the props of now, through one object that stays the same: no row is drawn again for it.
|
|
440
460
|
const sessionMenus = React.useContext(SessionMenus);
|
|
441
|
-
const latest = React.useRef({ chat, double, onPicked, t, pinned, onPinned, sessionMenus });
|
|
442
|
-
latest.current = { chat, double, onPicked, t, pinned, onPinned, sessionMenus };
|
|
461
|
+
const latest = React.useRef({ chat, double, onPicked, t, pinned, onPinned, sessionMenus, onLetGo });
|
|
462
|
+
latest.current = { chat, double, onPicked, t, pinned, onPinned, sessionMenus, onLetGo };
|
|
443
463
|
const actions = React.useMemo(() => {
|
|
444
464
|
const pick = (change) => {
|
|
445
465
|
void change;
|
|
@@ -461,6 +481,7 @@ export function ChatList({ sessions, saved, removed: removedFiles, archived: arc
|
|
|
461
481
|
const others = latest.current.pinned.filter(other => other !== file);
|
|
462
482
|
latest.current.onPinned(pin ? [file, ...others] : others);
|
|
463
483
|
},
|
|
484
|
+
letGo: entry => latest.current.onLetGo(entry),
|
|
464
485
|
extensionMenu: (entry, title) => {
|
|
465
486
|
const open = ChatListUtil.isOpen(entry);
|
|
466
487
|
const session = {
|
|
@@ -488,13 +509,16 @@ export function ChatList({ sessions, saved, removed: removedFiles, archived: arc
|
|
|
488
509
|
const icons = React.useContext(ChatIcons);
|
|
489
510
|
// biome-ignore lint/correctness/useExhaustiveDependencies: its bounds move with the day, as `since` does
|
|
490
511
|
const sooner = React.useMemo(() => ChatIconUtil.archiveSince(icons.entries, now), [icons, since]);
|
|
491
|
-
|
|
512
|
+
// One that waits for the user is not archived, however old, as one pinned.
|
|
513
|
+
const kept = React.useMemo(() => ChatListUtil.keptFiles([...saved, ...(archivedSaved !== null && archivedSaved !== void 0 ? archivedSaved : [])], pinned, letGo), [saved, archivedSaved, pinned, letGo]);
|
|
514
|
+
const { listed, archived, removed } = React.useMemo(() => ChatListUtil.entries(sessions, saved, removedFiles, archivedSaved, since, kept, sooner), [sessions, saved, removedFiles, archivedSaved, since, kept, sooner]);
|
|
492
515
|
const sources = React.useMemo(() => ChatListUtil.sources(listed), [listed]);
|
|
493
516
|
// A search finds the archived too.
|
|
494
517
|
const shown = React.useMemo(() => ChatListUtil.filter(searching ? [...listed, ...archived] : listed, query, t), [listed, archived, searching, query, t]);
|
|
495
518
|
const shownRemoved = React.useMemo(() => ChatListUtil.filter(removed, query, t), [removed, query, t]);
|
|
496
|
-
// Those
|
|
497
|
-
const
|
|
519
|
+
// Those that wait for the user to decide are at the very top, then those pinned, whatever their day or directory.
|
|
520
|
+
const asks = React.useMemo(() => (searching ? { asking: [], rest: shown } : ChatAskUtil.apart(shown, letGo)), [shown, letGo, searching]);
|
|
521
|
+
const apart = React.useMemo(() => ChatListUtil.pinnedApart(asks.rest, pinned), [asks.rest, pinned]);
|
|
498
522
|
const lookedAt = looking ? sessions.find(session => session.sessionId === looking) : undefined;
|
|
499
523
|
const inFront = lookedAt && ChatListUtil.file(lookedAt);
|
|
500
524
|
// What a search finds is one list by day, wherever it is.
|
|
@@ -522,7 +546,7 @@ export function ChatList({ sessions, saved, removed: removedFiles, archived: arc
|
|
|
522
546
|
const stays = (session) => isSelected(session) || isUnseen(session);
|
|
523
547
|
const budget = ChatListUtil.budget(pageCount, stays);
|
|
524
548
|
const pinnedFiles = React.useMemo(() => new Set(pinned), [pinned]);
|
|
525
|
-
const item = (session, compact) => (React.createElement(ChatItem, { key: ChatListUtil.key(session), session: session, source: byKey.get(ChatListUtil.sourceKey(session)), selected: ChatListUtil.key(session) === selected, time: ChatListUtil.clock(session.updatedAt, now), compact: compact, actions: actions, task: ChatListUtil.isOpen(session) ? double === null || double === void 0 ? void 0 : double.tasks.get(session.sessionId) : undefined, doubleName: double && ChatListUtil.isDouble(session, double) ? double.name : undefined, handable: !!double && ChatListUtil.isOpen(session) && !session.group && !double.tasks.has(session.sessionId) && !ChatListUtil.isDouble(session, double), pinned: pinnedFiles.has(ChatListUtil.file(session)), unseen: isUnseen(session) }));
|
|
549
|
+
const item = (session, compact) => { var _a; return (React.createElement(ChatItem, { key: ChatListUtil.key(session), session: session, source: byKey.get(ChatListUtil.sourceKey(session)), selected: ChatListUtil.key(session) === selected, time: ChatListUtil.clock(session.updatedAt, now), compact: compact, actions: actions, task: ChatListUtil.isOpen(session) ? double === null || double === void 0 ? void 0 : double.tasks.get(session.sessionId) : undefined, doubleName: double && ChatListUtil.isDouble(session, double) ? double.name : undefined, handable: !!double && ChatListUtil.isOpen(session) && !session.group && !double.tasks.has(session.sessionId) && !ChatListUtil.isDouble(session, double), pinned: pinnedFiles.has(ChatListUtil.file(session)), unseen: isUnseen(session), asking: (_a = ChatAskUtil.asking(session, letGo)) === null || _a === void 0 ? void 0 : _a.question })); };
|
|
526
550
|
// The conversation shown is found in the list, however it came to be shown: out of a search that hides it, and scrolled to.
|
|
527
551
|
const scroller = React.useRef(null);
|
|
528
552
|
const end = React.useRef(null);
|
|
@@ -631,6 +655,11 @@ export function ChatList({ sessions, saved, removed: removedFiles, archived: arc
|
|
|
631
655
|
React.createElement(IconButton, { className: "ta-chats-add", icon: Plus, label: t('ta.chat.new'), onClick: () => pick(chat.draft()) })),
|
|
632
656
|
notice,
|
|
633
657
|
React.createElement("div", { className: "ta-side-scroll", ref: scroller },
|
|
658
|
+
asks.asking.length > 0 && (React.createElement("section", { className: "ta-chat-section ta-chat-asks" },
|
|
659
|
+
React.createElement("div", { className: "ta-chat-section-title" },
|
|
660
|
+
t('ta.chat.asks'),
|
|
661
|
+
React.createElement("span", { className: "ta-chat-asks-count" }, asks.asking.length)),
|
|
662
|
+
React.createElement("ul", { className: "ta-side-list" }, asks.asking.map(session => item(session))))),
|
|
634
663
|
apart.pinned.length > 0 && (React.createElement("section", { className: "ta-chat-section ta-chat-pinned" },
|
|
635
664
|
React.createElement("div", { className: "ta-chat-section-title" }, t('ta.chat.pinned')),
|
|
636
665
|
React.createElement("ul", { className: "ta-side-list" }, apart.pinned.map(session => item(session))))),
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { WebComposerAction, WebConversation } from '../extension/web-extension-api.js';
|
|
3
|
+
import type { WebComposerAddonEntry } from '../extension/web-extension-protocol.js';
|
|
4
|
+
import type { ComposerAction } from './composer-box.js';
|
|
5
|
+
export declare namespace ComposerAddonUtil {
|
|
6
|
+
function action(entry: WebComposerAction): ComposerAction;
|
|
7
|
+
/** An icon given as a component (`ui.icons.Eye`), which React cannot draw as a child, is drawn at 16 pixels. */
|
|
8
|
+
function icon(given: WebComposerAction['icon']): React.ReactNode;
|
|
9
|
+
/** The entries of each addon, a section each; an addon that fails adds none. */
|
|
10
|
+
function actions(addons: readonly WebComposerAddonEntry[], conversation: WebConversation | undefined): ComposerAction[][];
|
|
11
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export var ComposerAddonUtil;
|
|
3
|
+
(function (ComposerAddonUtil) {
|
|
4
|
+
function action(entry) {
|
|
5
|
+
const { items, icon: given, ...rest } = entry;
|
|
6
|
+
const drawn = { ...rest, icon: icon(given) };
|
|
7
|
+
return items ? { ...drawn, items: items.map(action) } : drawn;
|
|
8
|
+
}
|
|
9
|
+
ComposerAddonUtil.action = action;
|
|
10
|
+
/** An icon given as a component (`ui.icons.Eye`), which React cannot draw as a child, is drawn at 16 pixels. */
|
|
11
|
+
function icon(given) {
|
|
12
|
+
const component = typeof given === 'function' || (typeof given === 'object' && given !== null && '$$typeof' in given && !React.isValidElement(given));
|
|
13
|
+
if (component) {
|
|
14
|
+
const Icon = given;
|
|
15
|
+
return React.createElement(Icon, { size: 16 });
|
|
16
|
+
}
|
|
17
|
+
return given;
|
|
18
|
+
}
|
|
19
|
+
ComposerAddonUtil.icon = icon;
|
|
20
|
+
/** The entries of each addon, a section each; an addon that fails adds none. */
|
|
21
|
+
function actions(addons, conversation) {
|
|
22
|
+
if (!conversation) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
return addons.flatMap(({ id, addon }) => {
|
|
26
|
+
var _a;
|
|
27
|
+
var _b;
|
|
28
|
+
try {
|
|
29
|
+
const entries = (_b = (_a = addon.actions) === null || _a === void 0 ? void 0 : _a.call(addon, conversation)) !== null && _b !== void 0 ? _b : [];
|
|
30
|
+
return entries.length > 0 ? [entries.map(action)] : [];
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
console.error(`The composer addon ${id} failed:`, error);
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
ComposerAddonUtil.actions = actions;
|
|
39
|
+
})(ComposerAddonUtil || (ComposerAddonUtil = {}));
|
|
40
|
+
//# sourceMappingURL=composer-addon-util.js.map
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type {
|
|
3
|
-
import type { WebComposerAddonEntry } from '../extension/web-extension-protocol.js';
|
|
2
|
+
import type { WebConversation } from '../extension/web-extension-api.js';
|
|
4
3
|
import type { ComposerAction } from './composer-box.js';
|
|
5
|
-
export declare namespace ComposerAddonUtil {
|
|
6
|
-
function action(entry: WebComposerAction): ComposerAction;
|
|
7
|
-
/** The entries of each addon, a section each; an addon that fails adds none. */
|
|
8
|
-
function actions(addons: readonly WebComposerAddonEntry[], conversation: WebConversation | undefined): ComposerAction[][];
|
|
9
|
-
}
|
|
10
4
|
/**
|
|
11
5
|
* What web extensions add to the message box of a conversation (registerComposerAddon): sections of its +
|
|
12
6
|
* menu, and what each draws above the box, in its own boundary.
|
|
@@ -1,33 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ExtensionBoundary } from '../extension/extension-view.js';
|
|
3
3
|
import { useWebExtensions } from '../hooks.js';
|
|
4
|
-
|
|
5
|
-
(function (ComposerAddonUtil) {
|
|
6
|
-
function action(entry) {
|
|
7
|
-
const { items, ...rest } = entry;
|
|
8
|
-
return items ? { ...rest, items: items.map(action) } : rest;
|
|
9
|
-
}
|
|
10
|
-
ComposerAddonUtil.action = action;
|
|
11
|
-
/** The entries of each addon, a section each; an addon that fails adds none. */
|
|
12
|
-
function actions(addons, conversation) {
|
|
13
|
-
if (!conversation) {
|
|
14
|
-
return [];
|
|
15
|
-
}
|
|
16
|
-
return addons.flatMap(({ id, addon }) => {
|
|
17
|
-
var _a;
|
|
18
|
-
var _b;
|
|
19
|
-
try {
|
|
20
|
-
const entries = (_b = (_a = addon.actions) === null || _a === void 0 ? void 0 : _a.call(addon, conversation)) !== null && _b !== void 0 ? _b : [];
|
|
21
|
-
return entries.length > 0 ? [entries.map(action)] : [];
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
console.error(`The composer addon ${id} failed:`, error);
|
|
25
|
-
return [];
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
ComposerAddonUtil.actions = actions;
|
|
30
|
-
})(ComposerAddonUtil || (ComposerAddonUtil = {}));
|
|
4
|
+
import { ComposerAddonUtil } from './composer-addon-util.js';
|
|
31
5
|
/**
|
|
32
6
|
* What web extensions add to the message box of a conversation (registerComposerAddon): sections of its +
|
|
33
7
|
* menu, and what each draws above the box, in its own boundary.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SessionStore } from '@celljs/ta-client';
|
|
2
2
|
import type { TaServer, TaSlashCommand, TaWorkspaceServer } from '@celljs/ta-protocol';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { type ComposerImage } from '../util/composer.js';
|
|
4
|
+
import { type ComposerImage, type ComposerQueued } from '../util/composer.js';
|
|
5
5
|
import { type ComposerAction, type ComposerBoxHandle } from './composer-box.js';
|
|
6
6
|
import type { TalkPlace } from './held-talk.js';
|
|
7
7
|
import { type StopTiming } from './stop-times.js';
|
|
@@ -48,3 +48,9 @@ export interface ComposerProps {
|
|
|
48
48
|
* and Alt+Enter queues a follow-up; Escape stops it.
|
|
49
49
|
*/
|
|
50
50
|
export declare const Composer: React.ForwardRefExoticComponent<ComposerProps & React.RefAttributes<ComposerBoxHandle>>;
|
|
51
|
+
/** What waits to be sent, tucked on top of the box: as the conversation will show it, the package that sent it apart. */
|
|
52
|
+
export declare function QueuedMessages({ waiting, onTakeBack, onRemove, }: {
|
|
53
|
+
waiting: ComposerQueued[];
|
|
54
|
+
onTakeBack(): void;
|
|
55
|
+
onRemove(entry: ComposerQueued, back: boolean): void;
|
|
56
|
+
}): React.JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Clock3, CornerDownRight,
|
|
1
|
+
import { Clock3, CornerDownRight, PenLine, X } from 'lucide-react';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { AssistantTaskUtil } from '../assistant/assistant-task-util.js';
|
|
4
4
|
import { useDevice } from '../device/device.js';
|
|
@@ -6,12 +6,16 @@ import { useLanguage, useT } from '../i18n/use-t.js';
|
|
|
6
6
|
import { ComposerUtil } from '../util/composer.js';
|
|
7
7
|
import { ComposerBox } from './composer-box.js';
|
|
8
8
|
import { Icon } from './icon.js';
|
|
9
|
+
import { MessageOrigin, userWords } from './message-list.js';
|
|
9
10
|
import { StopClock } from './stop-times.js';
|
|
10
11
|
const FILE_LIMIT = 20;
|
|
11
12
|
const FILE_DELAY_MS = 120;
|
|
12
13
|
const EMPTY_QUEUE = { steering: [], followUp: [] };
|
|
13
14
|
/** What the user said of what waited: not the notes of the tasks that ended, which they did not write. */
|
|
14
|
-
const said = (texts) => texts.filter(text => !AssistantTaskUtil.noteOf(text));
|
|
15
|
+
const said = (texts) => texts.filter(text => !AssistantTaskUtil.noteOf(text)).map(text => words(text).copied);
|
|
16
|
+
/** A waiting message as the user sees it in the conversation: without its context, the package it came from apart. */
|
|
17
|
+
const blocksOf = (text) => [{ type: 'text', text }];
|
|
18
|
+
const words = (text) => userWords(blocksOf(text));
|
|
15
19
|
/** The files for an `@` being typed; a server without file search answers with an error, and the menu says so. */
|
|
16
20
|
function useFiles(workspace, cwd, query) {
|
|
17
21
|
const t = useT();
|
|
@@ -128,29 +132,38 @@ export const Composer = React.forwardRef(function Composer(props, ref) {
|
|
|
128
132
|
server.removeQueued(store.sessionId, entry.kind, entry.index).then(removed => {
|
|
129
133
|
var _a;
|
|
130
134
|
if (removed && back) {
|
|
131
|
-
(_a = box.current) === null || _a === void 0 ? void 0 : _a.setText(ComposerUtil.restore({ steering: [entry.text], followUp: [] }, box.current.text()));
|
|
135
|
+
(_a = box.current) === null || _a === void 0 ? void 0 : _a.setText(ComposerUtil.restore({ steering: said([entry.text]), followUp: [] }, box.current.text()));
|
|
132
136
|
}
|
|
133
137
|
}, onError);
|
|
134
138
|
};
|
|
135
139
|
const waiting = ComposerUtil.queued(queue);
|
|
136
140
|
return (React.createElement(ComposerBox, { ref: box, placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : t(ComposerUtil.placeholderKey(working, touch)), working: working, onStop: stop, onSend: send, commands: listed, onMentionQuery: setQuery, mentions: files, mentionLabel: t('ta.composer.mentionFile'), images: true, recentShots: recentShots, actions: actions, head: head, after: after, voiceSends: voiceSends, talkPlace: talkPlace, onTalkSent: onTalkSent, onListening: onListening, autoFocus: !touch, cwd: cwd, onError: onError, above: React.createElement(React.Fragment, null,
|
|
137
141
|
above,
|
|
138
|
-
waiting.length > 0 &&
|
|
139
|
-
React.createElement("div", { className: "ta-queue-head" },
|
|
140
|
-
React.createElement("span", null, t('ta.composer.queue.count', { count: waiting.length })),
|
|
141
|
-
React.createElement("button", { type: "button", className: "ta-queue-all", onClick: takeBack, title: t('ta.composer.queue.takeBackTitle') }, t('ta.composer.queue.takeBackAll'))),
|
|
142
|
-
waiting.map(entry => {
|
|
143
|
-
const note = AssistantTaskUtil.noteOf(entry.text);
|
|
144
|
-
const text = note ? t('ta.task.ended', { title: note.title, status: t(`ta.task.${note.status}`) }) : entry.text;
|
|
145
|
-
return (React.createElement("div", { key: `${entry.kind}-${entry.index}-${entry.text}`, className: "ta-queue-row" },
|
|
146
|
-
React.createElement("span", { className: "ta-queue-kind", title: t(entry.kind === 'steering' ? 'ta.composer.queue.steering' : 'ta.composer.queue.followUp') },
|
|
147
|
-
React.createElement(Icon, { icon: entry.kind === 'steering' ? CornerDownRight : Clock3, size: 13 })),
|
|
148
|
-
React.createElement("span", { className: "ta-ellipsis ta-queue-text", title: text }, text),
|
|
149
|
-
React.createElement("span", { className: "ta-queue-actions" },
|
|
150
|
-
!note && (React.createElement("button", { type: "button", className: "ta-icon-button", onClick: () => remove(entry, true), title: t('ta.composer.queue.editTitle'), "aria-label": t('ta.composer.queue.editTitle') },
|
|
151
|
-
React.createElement(Icon, { icon: Undo2, size: 13 }))),
|
|
152
|
-
React.createElement("button", { type: "button", className: "ta-icon-button", onClick: () => remove(entry, false), title: t('ta.composer.queue.remove'), "aria-label": t('ta.composer.queue.remove') },
|
|
153
|
-
React.createElement(Icon, { icon: X, size: 13 })))));
|
|
154
|
-
})))) }));
|
|
142
|
+
waiting.length > 0 && React.createElement(QueuedMessages, { waiting: waiting, onTakeBack: takeBack, onRemove: remove })) }));
|
|
155
143
|
});
|
|
144
|
+
/** What waits to be sent, tucked on top of the box: as the conversation will show it, the package that sent it apart. */
|
|
145
|
+
export function QueuedMessages({ waiting, onTakeBack, onRemove, }) {
|
|
146
|
+
const t = useT();
|
|
147
|
+
return (React.createElement("div", { className: "ta-queue", "aria-live": "polite" },
|
|
148
|
+
waiting.length > 1 && (React.createElement("div", { className: "ta-queue-head" },
|
|
149
|
+
React.createElement("span", null, t('ta.composer.queue.count', { count: waiting.length })),
|
|
150
|
+
React.createElement("button", { type: "button", className: "ta-queue-all", onClick: onTakeBack, title: t('ta.composer.queue.takeBackTitle') }, t('ta.composer.queue.takeBackAll')))),
|
|
151
|
+
waiting.map(entry => {
|
|
152
|
+
const note = AssistantTaskUtil.noteOf(entry.text);
|
|
153
|
+
const shown = words(entry.text);
|
|
154
|
+
const text = note ? t('ta.task.ended', { title: note.title, status: t(`ta.task.${note.status}`) }) : shown.text || shown.copied;
|
|
155
|
+
const kind = t(entry.kind === 'steering' ? 'ta.composer.queue.steering' : 'ta.composer.queue.followUp');
|
|
156
|
+
return (React.createElement("div", { key: `${entry.kind}-${entry.index}-${entry.text}`, className: "ta-queue-row" },
|
|
157
|
+
React.createElement("span", { className: "ta-queue-kind", title: kind },
|
|
158
|
+
React.createElement(Icon, { icon: entry.kind === 'steering' ? CornerDownRight : Clock3, size: 13 }),
|
|
159
|
+
React.createElement("span", null, kind)),
|
|
160
|
+
!note && React.createElement(MessageOrigin, { blocks: blocksOf(entry.text) }),
|
|
161
|
+
React.createElement("span", { className: "ta-ellipsis ta-queue-text", title: text }, text),
|
|
162
|
+
React.createElement("span", { className: "ta-queue-actions" },
|
|
163
|
+
!note && (React.createElement("button", { type: "button", className: "ta-icon-button", onClick: () => onRemove(entry, true), title: t('ta.composer.queue.editTitle'), "aria-label": t('ta.composer.queue.editTitle') },
|
|
164
|
+
React.createElement(Icon, { icon: PenLine, size: 13 }))),
|
|
165
|
+
React.createElement("button", { type: "button", className: "ta-icon-button", onClick: () => onRemove(entry, false), title: t('ta.composer.queue.remove'), "aria-label": t('ta.composer.queue.remove') },
|
|
166
|
+
React.createElement(Icon, { icon: X, size: 13 })))));
|
|
167
|
+
})));
|
|
168
|
+
}
|
|
156
169
|
//# sourceMappingURL=composer.js.map
|