@celljs/ta-web 4.11.0 → 4.13.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.
- 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 +10 -6
- package/esm/browser/assistant/assistant.d.ts +5 -0
- package/esm/browser/assistant/assistant.js +25 -6
- package/esm/browser/chat/chat-view.js +6 -5
- 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 +26 -13
- 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-box.d.ts +1 -0
- package/esm/browser/components/composer-box.js +50 -28
- package/esm/browser/components/composer.d.ts +10 -1
- package/esm/browser/components/composer.js +61 -22
- package/esm/browser/components/connection-bar.js +31 -12
- package/esm/browser/components/conversation-scroll-hooks.d.ts +16 -0
- package/esm/browser/components/conversation-scroll-hooks.js +98 -0
- package/esm/browser/components/conversation-scroll-util.d.ts +35 -0
- package/esm/browser/components/conversation-scroll-util.js +74 -0
- package/esm/browser/components/conversation-scroll.d.ts +57 -33
- package/esm/browser/components/conversation-scroll.js +188 -123
- 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/face.d.ts +24 -0
- package/esm/browser/components/face.js +42 -0
- 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 +25 -11
- package/esm/browser/components/mermaid-view.js +45 -3
- package/esm/browser/components/message-actions.js +1 -0
- package/esm/browser/components/message-footer.d.ts +4 -0
- package/esm/browser/components/message-footer.js +8 -1
- package/esm/browser/components/message-list.d.ts +15 -1
- package/esm/browser/components/message-list.js +204 -41
- package/esm/browser/components/phone-shell.d.ts +7 -2
- package/esm/browser/components/phone-shell.js +9 -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.d.ts +3 -1
- package/esm/browser/components/session-view.js +23 -7
- package/esm/browser/components/settings-controls.js +3 -3
- package/esm/browser/components/settings-parts.js +13 -1
- package/esm/browser/components/stop-times.d.ts +47 -0
- package/esm/browser/components/stop-times.js +81 -0
- 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/use-stop-times.d.ts +3 -0
- package/esm/browser/components/use-stop-times.js +17 -0
- package/esm/browser/components/web-composer.js +2 -1
- package/esm/browser/device/photo-picker.d.ts +14 -0
- package/esm/browser/device/photo-picker.js +48 -0
- package/esm/browser/device/row-swipe.d.ts +2 -0
- package/esm/browser/device/row-swipe.js +8 -2
- package/esm/browser/device/sheet-swipe.d.ts +1 -1
- package/esm/browser/device/sheet-swipe.js +17 -3
- 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 +10 -1
- package/esm/browser/extension/web-api-components.d.ts +21 -3
- package/esm/browser/extension/web-api-contributions.d.ts +128 -0
- package/esm/browser/extension/web-extension-api.d.ts +45 -48
- package/esm/browser/extension/web-extension-context.d.ts +6 -1
- package/esm/browser/extension/web-extension-context.js +72 -7
- package/esm/browser/extension/web-extension-protocol.d.ts +18 -2
- package/esm/browser/extension/web-extension-protocol.js +2 -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 +12 -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 +77 -1
- package/esm/browser/i18n/messages.d.ts +76 -0
- package/esm/browser/i18n/messages.js +154 -2
- package/esm/browser/links/links-protocol.d.ts +2 -0
- package/esm/browser/links/links.d.ts +7 -2
- package/esm/browser/links/links.js +16 -9
- 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 +53 -0
- package/esm/browser/style/device.js +3 -0
- package/esm/browser/style/layout.d.ts +1 -1
- package/esm/browser/style/layout.js +27 -9
- package/esm/browser/style/pages.d.ts +1 -1
- package/esm/browser/style/pages.js +5 -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 +16 -3
- package/esm/browser/style/surfaces.d.ts +1 -1
- package/esm/browser/style/surfaces.js +19 -0
- package/esm/browser/util/desktop.d.ts +18 -1
- package/esm/browser/util/desktop.js +13 -0
- package/esm/browser/util/frame.d.ts +2 -0
- package/esm/browser/util/frame.js +2 -0
- package/esm/browser/util/process.d.ts +69 -2
- package/esm/browser/util/process.js +163 -8
- 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 +8 -4
- package/lib/browser/assistant/assistant.d.ts +5 -0
- package/lib/browser/assistant/assistant.js +24 -5
- package/lib/browser/chat/chat-view.js +6 -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 +25 -12
- 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-box.d.ts +1 -0
- package/lib/browser/components/composer-box.js +48 -26
- package/lib/browser/components/composer.d.ts +10 -1
- package/lib/browser/components/composer.js +61 -21
- package/lib/browser/components/connection-bar.js +30 -11
- package/lib/browser/components/conversation-scroll-hooks.d.ts +17 -0
- package/lib/browser/components/conversation-scroll-hooks.js +135 -0
- package/lib/browser/components/conversation-scroll-util.d.ts +36 -0
- package/lib/browser/components/conversation-scroll-util.js +78 -0
- package/lib/browser/components/conversation-scroll.d.ts +57 -33
- package/lib/browser/components/conversation-scroll.js +189 -158
- 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/face.d.ts +25 -0
- package/lib/browser/components/face.js +79 -0
- 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 +24 -10
- package/lib/browser/components/mermaid-view.js +45 -3
- package/lib/browser/components/message-actions.js +1 -0
- package/lib/browser/components/message-footer.d.ts +4 -0
- package/lib/browser/components/message-footer.js +8 -0
- package/lib/browser/components/message-list.d.ts +15 -1
- package/lib/browser/components/message-list.js +200 -35
- package/lib/browser/components/phone-shell.d.ts +7 -2
- package/lib/browser/components/phone-shell.js +9 -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.d.ts +3 -1
- package/lib/browser/components/session-view.js +23 -7
- package/lib/browser/components/settings-controls.js +3 -3
- package/lib/browser/components/settings-parts.js +13 -1
- package/lib/browser/components/stop-times.d.ts +48 -0
- package/lib/browser/components/stop-times.js +85 -0
- 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/use-stop-times.d.ts +4 -0
- package/lib/browser/components/use-stop-times.js +53 -0
- package/lib/browser/components/web-composer.js +2 -1
- package/lib/browser/device/photo-picker.d.ts +15 -0
- package/lib/browser/device/photo-picker.js +51 -0
- package/lib/browser/device/row-swipe.d.ts +2 -0
- package/lib/browser/device/row-swipe.js +8 -2
- package/lib/browser/device/sheet-swipe.d.ts +1 -1
- package/lib/browser/device/sheet-swipe.js +17 -3
- 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 +9 -0
- package/lib/browser/extension/web-api-components.d.ts +21 -3
- package/lib/browser/extension/web-api-contributions.d.ts +128 -0
- package/lib/browser/extension/web-extension-api.d.ts +45 -48
- package/lib/browser/extension/web-extension-context.d.ts +6 -1
- package/lib/browser/extension/web-extension-context.js +73 -8
- package/lib/browser/extension/web-extension-protocol.d.ts +18 -2
- package/lib/browser/extension/web-extension-protocol.js +2 -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 +12 -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 +77 -1
- package/lib/browser/i18n/messages.d.ts +76 -0
- package/lib/browser/i18n/messages.js +154 -2
- package/lib/browser/links/links-protocol.d.ts +2 -0
- package/lib/browser/links/links.d.ts +7 -2
- package/lib/browser/links/links.js +16 -9
- 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 +53 -0
- package/lib/browser/style/device.js +3 -0
- package/lib/browser/style/layout.d.ts +1 -1
- package/lib/browser/style/layout.js +27 -9
- package/lib/browser/style/pages.d.ts +1 -1
- package/lib/browser/style/pages.js +5 -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 +16 -3
- package/lib/browser/style/surfaces.d.ts +1 -1
- package/lib/browser/style/surfaces.js +19 -0
- package/lib/browser/util/desktop.d.ts +18 -1
- package/lib/browser/util/desktop.js +13 -0
- package/lib/browser/util/frame.d.ts +2 -0
- package/lib/browser/util/frame.js +2 -0
- package/lib/browser/util/process.d.ts +69 -2
- package/lib/browser/util/process.js +165 -9
- 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,249 @@
|
|
|
1
|
+
import { TaPackageTextUtil } from '@celljs/ta-protocol';
|
|
2
|
+
import { Cloud, Database, FileJson, Folder, GitBranch, HardDrive, Plus, Server, ShieldCheck, Trash2 } from 'lucide-react';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useNotices, useWorkbench } from '../hooks.js';
|
|
5
|
+
import { useLanguage, useT } from '../i18n/use-t.js';
|
|
6
|
+
import { Icon, IconButton } from './icon.js';
|
|
7
|
+
import { Row } from './settings-controls.js';
|
|
8
|
+
/** The features that go through a relay, in the order the settings list them. */
|
|
9
|
+
const FEATURES = ['devices', 'share', 'rooms', 'sync'];
|
|
10
|
+
export var RelayServicesUtil;
|
|
11
|
+
(function (RelayServicesUtil) {
|
|
12
|
+
/** What a service is called: the official relay, its name, else its host or its folder. */
|
|
13
|
+
function label(service, t) {
|
|
14
|
+
var _a, _b, _c;
|
|
15
|
+
// A folder by its last part: where it is shows under it.
|
|
16
|
+
const short = service.type === 'folder' ? ((_a = service.path) !== null && _a !== void 0 ? _a : '').split('/').filter(Boolean).pop() : undefined;
|
|
17
|
+
return service.builtin ? t('ta.relays.official') : ((_c = (_b = service.name) !== null && _b !== void 0 ? _b : short) !== null && _c !== void 0 ? _c : where(service));
|
|
18
|
+
}
|
|
19
|
+
RelayServicesUtil.label = label;
|
|
20
|
+
/** Where a service is: a relay's host, a folder's path, where a store of a package is (a host, a bucket). */
|
|
21
|
+
function where(service) {
|
|
22
|
+
var _a, _b, _c;
|
|
23
|
+
if (service.type === 'folder') {
|
|
24
|
+
return (_a = service.path) !== null && _a !== void 0 ? _a : '';
|
|
25
|
+
}
|
|
26
|
+
if (service.type !== 'ta-relay') {
|
|
27
|
+
return (_b = service.where) !== null && _b !== void 0 ? _b : service.type;
|
|
28
|
+
}
|
|
29
|
+
return ((_c = service.url) !== null && _c !== void 0 ? _c : '').replace(/^https?:\/\//, '');
|
|
30
|
+
}
|
|
31
|
+
RelayServicesUtil.where = where;
|
|
32
|
+
/** Whether a service can carry a feature: all can but a folder and a store, which only sync uses. */
|
|
33
|
+
function serves(service, feature) {
|
|
34
|
+
return !service.only || service.only.includes(feature);
|
|
35
|
+
}
|
|
36
|
+
RelayServicesUtil.serves = serves;
|
|
37
|
+
/** The icon of a service: the official relay, a relay, a folder, a store by the icon its package gave its type. */
|
|
38
|
+
function icon(service, types = []) {
|
|
39
|
+
var _a;
|
|
40
|
+
if (service.type === 'folder') {
|
|
41
|
+
return Folder;
|
|
42
|
+
}
|
|
43
|
+
if (service.type === 'ta-relay') {
|
|
44
|
+
return service.builtin ? ShieldCheck : Server;
|
|
45
|
+
}
|
|
46
|
+
return iconNamed((_a = types.find(each => each.type === service.type)) === null || _a === void 0 ? void 0 : _a.icon);
|
|
47
|
+
}
|
|
48
|
+
RelayServicesUtil.icon = icon;
|
|
49
|
+
function iconNamed(name) {
|
|
50
|
+
return name === 'Database' ? Database : name === 'GitBranch' ? GitBranch : name === 'HardDrive' ? HardDrive : name === 'Server' ? Server : Cloud;
|
|
51
|
+
}
|
|
52
|
+
RelayServicesUtil.iconNamed = iconNamed;
|
|
53
|
+
/** What a relay shows under its name: where it is, whether it answers, what it keeps. */
|
|
54
|
+
function line(service, probe, t) {
|
|
55
|
+
var _a, _b;
|
|
56
|
+
const host = where(service);
|
|
57
|
+
if (service.type === 'folder') {
|
|
58
|
+
return probe && !probe.online ? `${host} · ${(_a = probe.error) !== null && _a !== void 0 ? _a : t('ta.relays.offline')}` : `${host} · ${t('ta.relays.folderOnly')}`;
|
|
59
|
+
}
|
|
60
|
+
if (service.type !== 'ta-relay') {
|
|
61
|
+
if (service.unavailable) {
|
|
62
|
+
return `${service.type} · ${t('ta.relays.unavailable')}`;
|
|
63
|
+
}
|
|
64
|
+
if (probe && !probe.online) {
|
|
65
|
+
return `${host} · ${(_b = probe.error) !== null && _b !== void 0 ? _b : t('ta.relays.offline')}`;
|
|
66
|
+
}
|
|
67
|
+
return [host, (probe === null || probe === void 0 ? void 0 : probe.ms) !== undefined ? t('ta.relays.online', { ms: probe.ms }) : undefined, t('ta.relays.storeOnly')].filter(Boolean).join(' · ');
|
|
68
|
+
}
|
|
69
|
+
if (!probe) {
|
|
70
|
+
return host;
|
|
71
|
+
}
|
|
72
|
+
if (!probe.online) {
|
|
73
|
+
return `${host} · ${t('ta.relays.offline')}`;
|
|
74
|
+
}
|
|
75
|
+
const parts = [host, probe.ms !== undefined ? t('ta.relays.online', { ms: probe.ms }) : t('ta.relays.onlineNoTime')];
|
|
76
|
+
if (probe.persistent === false) {
|
|
77
|
+
parts.push(t('ta.relays.memory'));
|
|
78
|
+
}
|
|
79
|
+
if (probe.limits && !probe.legacy) {
|
|
80
|
+
parts.push(t('ta.relays.limits', { members: probe.limits.hubMembers, state: Math.round(probe.limits.hubStateBytes / 1024 / 1024) }));
|
|
81
|
+
}
|
|
82
|
+
return parts.join(' · ');
|
|
83
|
+
}
|
|
84
|
+
RelayServicesUtil.line = line;
|
|
85
|
+
})(RelayServicesUtil || (RelayServicesUtil = {}));
|
|
86
|
+
/**
|
|
87
|
+
* The relays of relays.json (docs/design/ta-relays.md) and which one each feature uses: phones that reach this
|
|
88
|
+
* computer, links that share, rooms and playing together, sync of the user's computers. A relay is the official one,
|
|
89
|
+
* one on the user's own Cloudflare or `ta relay` behind HTTPS; it reads none of what goes through it. What a feature
|
|
90
|
+
* made before (a device, a room, a link) stays on its relay when the choice changes.
|
|
91
|
+
*/
|
|
92
|
+
export function RelayServices() {
|
|
93
|
+
var _a, _b;
|
|
94
|
+
const t = useT();
|
|
95
|
+
const [workbench, bench] = useWorkbench();
|
|
96
|
+
const [, notices] = useNotices();
|
|
97
|
+
const [relays, setRelays] = React.useState();
|
|
98
|
+
const [probes, setProbes] = React.useState({});
|
|
99
|
+
const [url, setUrl] = React.useState('');
|
|
100
|
+
const [busy, setBusy] = React.useState();
|
|
101
|
+
const [form, setForm] = React.useState();
|
|
102
|
+
const language = useLanguage();
|
|
103
|
+
const read = React.useCallback(async () => {
|
|
104
|
+
const listed = await bench.relay.listRelays();
|
|
105
|
+
setRelays(listed);
|
|
106
|
+
return listed;
|
|
107
|
+
}, [bench]);
|
|
108
|
+
React.useEffect(() => {
|
|
109
|
+
if (workbench.status !== 'online') {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
let gone = false;
|
|
113
|
+
read()
|
|
114
|
+
.then(listed => {
|
|
115
|
+
for (const relay of listed.relays) {
|
|
116
|
+
void bench.relay.probeRelay(relay.id).then(probe => !gone && setProbes(before => ({ ...before, [relay.id]: probe })));
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
.catch(() => undefined);
|
|
120
|
+
return () => {
|
|
121
|
+
gone = true;
|
|
122
|
+
};
|
|
123
|
+
}, [workbench.status, bench, read]);
|
|
124
|
+
const run = async (key, action) => {
|
|
125
|
+
setBusy(key);
|
|
126
|
+
try {
|
|
127
|
+
await action();
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
notices.error(error);
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
setBusy(undefined);
|
|
134
|
+
await read().catch(() => undefined);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
/** An address adds a relay, a path (`/…`, `~/…`) a folder. */
|
|
138
|
+
const add = (text = url, name) => run('add', async () => {
|
|
139
|
+
const value = text.trim();
|
|
140
|
+
const id = /^[/~]/.test(value) ? await bench.relay.addFolder(value, name) : await bench.relay.addRelay(value);
|
|
141
|
+
setUrl('');
|
|
142
|
+
const probe = await bench.relay.probeRelay(id);
|
|
143
|
+
setProbes(before => ({ ...before, [id]: probe }));
|
|
144
|
+
});
|
|
145
|
+
/** A drive found here: its folder added, and sync goes there. */
|
|
146
|
+
const takeDrive = (drive) => run(`drive:${drive.path}`, async () => {
|
|
147
|
+
const id = await bench.relay.addFolder(drive.path, drive.name);
|
|
148
|
+
setRelays(await bench.relay.chooseRelay('sync', id));
|
|
149
|
+
const probe = await bench.relay.probeRelay(id);
|
|
150
|
+
setProbes(before => ({ ...before, [id]: probe }));
|
|
151
|
+
});
|
|
152
|
+
/** A store just added: sync goes there. */
|
|
153
|
+
const stored = async (id) => {
|
|
154
|
+
setRelays(await bench.relay.chooseRelay('sync', id));
|
|
155
|
+
setForm(undefined);
|
|
156
|
+
const probe = await bench.relay.probeRelay(id);
|
|
157
|
+
setProbes(before => ({ ...before, [id]: probe }));
|
|
158
|
+
};
|
|
159
|
+
if (!relays) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
const used = new Set(Object.values(relays.use));
|
|
163
|
+
const types = (_a = relays.types) !== null && _a !== void 0 ? _a : [];
|
|
164
|
+
return (React.createElement(React.Fragment, null,
|
|
165
|
+
relays.error && React.createElement(Row, { label: t('ta.relays.broken'), description: relays.error }),
|
|
166
|
+
FEATURES.map(feature => { var _a; return (React.createElement(Row, { key: feature, label: t(`ta.relays.feature.${feature}`), description: t(`ta.relays.feature.${feature}Hint`) },
|
|
167
|
+
React.createElement("select", { className: "ta-input ta-select", "aria-label": t(`ta.relays.feature.${feature}`), disabled: busy !== undefined, value: (_a = relays.use[feature]) !== null && _a !== void 0 ? _a : '', onChange: event => void run(feature, async () => setRelays(await bench.relay.chooseRelay(feature, event.target.value || null))) }, relays.relays
|
|
168
|
+
.filter(relay => RelayServicesUtil.serves(relay, feature) || relays.use[feature] === relay.id)
|
|
169
|
+
.map(relay => (React.createElement("option", { key: relay.id, value: relay.id }, RelayServicesUtil.label(relay, t))))))); }),
|
|
170
|
+
relays.relays.map(relay => { var _a; return (React.createElement(Row, { key: relay.id, icon: RelayServicesUtil.icon(relay, types), label: RelayServicesUtil.label(relay, t), description: React.createElement("span", { className: "ta-remote-state" },
|
|
171
|
+
React.createElement("span", { className: `ta-remote-light${((_a = probes[relay.id]) === null || _a === void 0 ? void 0 : _a.online) ? ' ta-on' : ''}` }),
|
|
172
|
+
RelayServicesUtil.line(relay, probes[relay.id], t)) }, !relay.builtin && relay.id !== 'relay-json' && !used.has(relay.id) && (React.createElement(IconButton, { icon: Trash2, label: t('ta.relays.remove', { name: RelayServicesUtil.label(relay, t) }), disabled: busy !== undefined, onClick: () => void run(relay.id, () => bench.relay.removeRelay(relay.id)) })))); }),
|
|
173
|
+
((_b = relays.drives) !== null && _b !== void 0 ? _b : []).map(drive => (React.createElement(Row, { key: drive.path, icon: Cloud, label: t('ta.relays.drive', { name: drive.name }), description: t('ta.relays.driveHint', { path: drive.path }) },
|
|
174
|
+
React.createElement("button", { type: "button", className: `ta-button${busy === `drive:${drive.path}` ? ' ta-busy' : ''}`, disabled: busy !== undefined, onClick: () => void takeDrive(drive) },
|
|
175
|
+
busy === `drive:${drive.path}` && React.createElement("span", { className: "ta-spinner ta-busy-mark" }),
|
|
176
|
+
React.createElement("span", null, t('ta.relays.driveUse')))))),
|
|
177
|
+
types.map(type => {
|
|
178
|
+
var _a;
|
|
179
|
+
const title = (_a = TaPackageTextUtil.pick(type.title, language)) !== null && _a !== void 0 ? _a : type.type;
|
|
180
|
+
const open = form === type.type;
|
|
181
|
+
return (React.createElement(React.Fragment, { key: `type:${type.type}` },
|
|
182
|
+
React.createElement(Row, { icon: RelayServicesUtil.iconNamed(type.icon), label: t('ta.relays.storeType', { name: title }), description: TaPackageTextUtil.pick(type.hint, language) }, !open && (React.createElement("button", { type: "button", className: "ta-button", disabled: busy !== undefined, onClick: () => setForm(type.type) }, t('ta.relays.storeOpen')))),
|
|
183
|
+
open && (React.createElement(Row, { label: "", stacked: true },
|
|
184
|
+
React.createElement(StoreForm, { type: type, title: title, close: () => setForm(undefined), added: stored })))));
|
|
185
|
+
}),
|
|
186
|
+
React.createElement(Row, { label: t('ta.relays.add'), description: t('ta.relays.addHint'), stacked: true },
|
|
187
|
+
React.createElement("form", { className: "ta-trusted-add", onSubmit: event => {
|
|
188
|
+
event.preventDefault();
|
|
189
|
+
void add();
|
|
190
|
+
} },
|
|
191
|
+
React.createElement("input", { className: "ta-input", value: url, placeholder: t('ta.relays.addPlaceholder'), "aria-label": t('ta.relays.add'), spellCheck: false, onChange: event => setUrl(event.target.value) }),
|
|
192
|
+
React.createElement("button", { type: "submit", className: `ta-button${busy === 'add' ? ' ta-busy' : ''}`, disabled: !url.trim() || busy !== undefined },
|
|
193
|
+
busy === 'add' ? React.createElement("span", { className: "ta-spinner ta-busy-mark" }) : React.createElement(Icon, { icon: Plus, size: 14 }),
|
|
194
|
+
" ",
|
|
195
|
+
t('ta.relays.addButton')))),
|
|
196
|
+
React.createElement(Row, { icon: FileJson, label: t('ta.relays.file'), description: React.createElement("span", { className: "ta-path" }, relays.file) })));
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* The form of a type of service a package registered (WebDAV, S3, git): its fields as the package said, secrets as
|
|
200
|
+
* passwords, and a name. Ta tries the store before it adds it; then sync goes there.
|
|
201
|
+
*/
|
|
202
|
+
function StoreForm({ type, title, close, added }) {
|
|
203
|
+
const t = useT();
|
|
204
|
+
const language = useLanguage();
|
|
205
|
+
const [, bench] = useWorkbench();
|
|
206
|
+
const [, notices] = useNotices();
|
|
207
|
+
const [values, setValues] = React.useState({});
|
|
208
|
+
const [name, setName] = React.useState('');
|
|
209
|
+
const [busy, setBusy] = React.useState(false);
|
|
210
|
+
const missing = type.options.some(option => { var _a; return !option.optional && !((_a = values[option.key]) === null || _a === void 0 ? void 0 : _a.trim()); });
|
|
211
|
+
const submit = async () => {
|
|
212
|
+
setBusy(true);
|
|
213
|
+
try {
|
|
214
|
+
const given = Object.fromEntries(Object.entries(values).map(([key, value]) => [key, value.trim()]));
|
|
215
|
+
await added(await bench.relay.addStore(type.type, given, name.trim() || title));
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
notices.error(error);
|
|
219
|
+
}
|
|
220
|
+
finally {
|
|
221
|
+
setBusy(false);
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
return (React.createElement("form", { className: "ta-store-form", onSubmit: event => {
|
|
225
|
+
event.preventDefault();
|
|
226
|
+
void submit();
|
|
227
|
+
} },
|
|
228
|
+
type.options.map(option => { var _a, _b; return (React.createElement("label", { key: option.key, className: "ta-store-field" },
|
|
229
|
+
React.createElement("span", { className: "ta-store-field-label" }, (_a = TaPackageTextUtil.pick(option.label, language)) !== null && _a !== void 0 ? _a : option.key,
|
|
230
|
+
option.optional && React.createElement("span", { className: "ta-store-field-optional" }, t('ta.relays.optional'))),
|
|
231
|
+
React.createElement("input", { className: "ta-input", type: option.secret ? 'password' : 'text', autoComplete: option.secret ? 'new-password' : 'off', spellCheck: false, placeholder: option.placeholder, value: (_b = values[option.key]) !== null && _b !== void 0 ? _b : '', onChange: event => {
|
|
232
|
+
const value = event.target.value;
|
|
233
|
+
setValues(before => ({ ...before, [option.key]: value }));
|
|
234
|
+
} }))); }),
|
|
235
|
+
React.createElement("label", { className: "ta-store-field" },
|
|
236
|
+
React.createElement("span", { className: "ta-store-field-label" },
|
|
237
|
+
t('ta.relays.storeName'),
|
|
238
|
+
React.createElement("span", { className: "ta-store-field-optional" }, t('ta.relays.optional'))),
|
|
239
|
+
React.createElement("input", { className: "ta-input", value: name, placeholder: title, spellCheck: false, onChange: event => setName(event.target.value) })),
|
|
240
|
+
React.createElement("p", { className: "ta-store-form-note" },
|
|
241
|
+
React.createElement(Icon, { icon: ShieldCheck, size: 13 }),
|
|
242
|
+
React.createElement("span", null, t('ta.relays.storeNote'))),
|
|
243
|
+
React.createElement("div", { className: "ta-store-form-actions" },
|
|
244
|
+
React.createElement("button", { type: "button", className: "ta-button", disabled: busy, onClick: close }, t('ta.cancel')),
|
|
245
|
+
React.createElement("button", { type: "submit", className: `ta-button ta-primary${busy ? ' ta-busy' : ''}`, disabled: missing || busy },
|
|
246
|
+
busy && React.createElement("span", { className: "ta-spinner ta-busy-mark" }),
|
|
247
|
+
React.createElement("span", null, t('ta.relays.storeAdd'))))));
|
|
248
|
+
}
|
|
249
|
+
//# sourceMappingURL=relay-services.js.map
|
|
@@ -7,6 +7,7 @@ import { BusyMark } from './busy.js';
|
|
|
7
7
|
import { Icon, IconButton } from './icon.js';
|
|
8
8
|
import { Picture } from './picture.js';
|
|
9
9
|
import { QrView } from './qr-view.js';
|
|
10
|
+
import { Switch } from './settings-controls.js';
|
|
10
11
|
/** A phone and this computer, a relay between them, and a lock on what goes through. */
|
|
11
12
|
function RelayPicture() {
|
|
12
13
|
return (React.createElement(Picture, { width: 240, height: 72, frame: false, className: "ta-relay-pic" },
|
|
@@ -76,6 +77,16 @@ export function RelayDialog({ onClose }) {
|
|
|
76
77
|
load();
|
|
77
78
|
}
|
|
78
79
|
};
|
|
80
|
+
const keepAwake = async (on) => {
|
|
81
|
+
try {
|
|
82
|
+
await bench.relay.setKeepAwake(on);
|
|
83
|
+
setInfo(before => before && { ...before, keepAwake: on });
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
notices.error(error);
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
79
90
|
const relayHost = ((_b = (_a = info === null || info === void 0 ? void 0 : info.relay) !== null && _a !== void 0 ? _a : info === null || info === void 0 ? void 0 : info.defaultRelay) !== null && _b !== void 0 ? _b : '').replace(/^https?:\/\//, '');
|
|
80
91
|
return createPortal(React.createElement("div", { className: "ta-modal-scrim" },
|
|
81
92
|
React.createElement("button", { type: "button", className: "ta-overlay-close", "aria-label": t('ta.close'), tabIndex: -1, onClick: onClose }),
|
|
@@ -109,6 +120,11 @@ export function RelayDialog({ onClose }) {
|
|
|
109
120
|
React.createElement(Icon, { icon: Smartphone, size: 16 }),
|
|
110
121
|
React.createElement("span", { className: "ta-auth-name" }, device.name),
|
|
111
122
|
React.createElement("span", { className: "ta-auth-note" }, new Date(device.createdAt).toLocaleDateString()),
|
|
112
|
-
React.createElement(IconButton, { icon: Trash2, label: t('ta.relay.unpair'), busy: unpairing === device.id, onClick: () => void unpair(device) }))))))
|
|
123
|
+
React.createElement(IconButton, { icon: Trash2, label: t('ta.relay.unpair'), busy: unpairing === device.id, onClick: () => void unpair(device) })))))),
|
|
124
|
+
(info === null || info === void 0 ? void 0 : info.keepAwake) !== undefined && (React.createElement("div", { className: "ta-relay-awake" },
|
|
125
|
+
React.createElement("span", { className: "ta-relay-awake-text" },
|
|
126
|
+
React.createElement("span", null, t('ta.relay.keepAwake')),
|
|
127
|
+
React.createElement("span", { className: "ta-auth-note" }, t('ta.relay.keepAwakeHint'))),
|
|
128
|
+
React.createElement(Switch, { checked: info.keepAwake, label: t('ta.relay.keepAwake'), onChange: keepAwake }))))), document.body);
|
|
113
129
|
}
|
|
114
130
|
//# sourceMappingURL=relay-view.js.map
|
|
@@ -71,7 +71,7 @@ export function RemoteHosts() {
|
|
|
71
71
|
" ",
|
|
72
72
|
t('ta.remote.add')))),
|
|
73
73
|
hosts.length === 0 && React.createElement(EmptyRow, { picture: React.createElement(RemotePicture, null), title: t('ta.remote.none'), hint: t('ta.remote.noneHint') }),
|
|
74
|
-
hosts.map(host => (React.createElement(Row, { key: host.host, label: host.host, description: React.createElement("span", { className: "ta-remote-state" },
|
|
74
|
+
hosts.map(host => (React.createElement(Row, { key: host.host, label: RemoteHostsUtil.breakable(host.host), description: React.createElement("span", { className: "ta-remote-state" },
|
|
75
75
|
React.createElement("span", { className: `ta-remote-light${host.connected ? ' ta-on' : ''}` }),
|
|
76
76
|
[
|
|
77
77
|
t(host.connected ? 'ta.remote.connected' : 'ta.remote.disconnected'),
|
|
@@ -14,6 +14,8 @@ export interface SessionViewProps {
|
|
|
14
14
|
trailing?: React.ReactNode;
|
|
15
15
|
/** Instead of the hint of an empty conversation. */
|
|
16
16
|
empty?: React.ReactNode;
|
|
17
|
+
/** Over the message box and what comes and goes over it: a row that opens and closes by itself (the connection on a phone). */
|
|
18
|
+
notice?: React.ReactNode;
|
|
17
19
|
aboveComposer?: React.ReactNode;
|
|
18
20
|
belowComposer?: React.ReactNode;
|
|
19
21
|
/** In the box at the start: the message a fork left out. */
|
|
@@ -21,4 +23,4 @@ export interface SessionViewProps {
|
|
|
21
23
|
/** In a narrow column, as a tab of the workbench: no bar on top. */
|
|
22
24
|
compact?: boolean;
|
|
23
25
|
}
|
|
24
|
-
export declare function SessionView({ store, server, workspace, info, onClosed, onActivity, leading, trailing, empty, aboveComposer, belowComposer, draftText, compact, }: SessionViewProps): React.JSX.Element;
|
|
26
|
+
export declare function SessionView({ store, server, workspace, info, onClosed, onActivity, leading, trailing, empty, notice, aboveComposer, belowComposer, draftText, compact, }: SessionViewProps): React.JSX.Element;
|
|
@@ -3,13 +3,16 @@ import { ArrowDown } from 'lucide-react';
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { useKeyboardDismiss } from '../device/device.js';
|
|
5
5
|
import { TaFiles } from '../files/files-protocol.js';
|
|
6
|
-
import { useNotices, useOpenLink, useSessionState, useSettings, useSettingsServer } from '../hooks.js';
|
|
6
|
+
import { useNotices, useOpenLink, usePersisted, useSessionState, useSettings, useSettingsServer } from '../hooks.js';
|
|
7
7
|
import { useT } from '../i18n/use-t.js';
|
|
8
|
+
import { CodeReply } from '../markdown/code-renderers.js';
|
|
8
9
|
import { MessageUtil } from '../util/message.js';
|
|
9
10
|
import { TerminalText } from '../util/terminal-text.js';
|
|
11
|
+
import { ChatAskUtil, LET_GO_ASKS } from './chat-asks.js';
|
|
10
12
|
import { Composer } from './composer.js';
|
|
11
13
|
import { useComposerAddons } from './composer-addons.js';
|
|
12
|
-
import { SCROLL_SKIP
|
|
14
|
+
import { SCROLL_SKIP } from './conversation-scroll.js';
|
|
15
|
+
import { useAwayFromBottom, useConversationScroll } from './conversation-scroll-hooks.js';
|
|
13
16
|
import { DialogView } from './dialog-view.js';
|
|
14
17
|
import { useAsked, useEarlierMessages, useRowWindow } from './earlier-messages.js';
|
|
15
18
|
import { GrowBox } from './grow-box.js';
|
|
@@ -20,6 +23,7 @@ import { MessageActions } from './message-footer.js';
|
|
|
20
23
|
import { ConversationSession, MessageImages, MessageList } from './message-list.js';
|
|
21
24
|
import { useSessionSettings } from './session-settings.js';
|
|
22
25
|
import { TerminalArt } from './terminal-art.js';
|
|
26
|
+
import { useStopTimes } from './use-stop-times.js';
|
|
23
27
|
/**
|
|
24
28
|
* What the extensions of the session say with `notify` goes to the notices of the page; what was said before it
|
|
25
29
|
* opened stays quiet. A picture in it (a QR code to sign in) is drawn, and stays until the next notice of the
|
|
@@ -67,7 +71,7 @@ function StatusChip({ text }) {
|
|
|
67
71
|
segment.tone && React.createElement("span", { className: `ta-status ta-status-${segment.tone}` }),
|
|
68
72
|
segment.text)))));
|
|
69
73
|
}
|
|
70
|
-
export function SessionView({ store, server, workspace, info, onClosed, onActivity, leading, trailing, empty, aboveComposer, belowComposer, draftText, compact = false, }) {
|
|
74
|
+
export function SessionView({ store, server, workspace, info, onClosed, onActivity, leading, trailing, empty, notice, aboveComposer, belowComposer, draftText, compact = false, }) {
|
|
71
75
|
var _a;
|
|
72
76
|
const t = useT();
|
|
73
77
|
const state = useSessionState(store);
|
|
@@ -78,8 +82,12 @@ export function SessionView({ store, server, workspace, info, onClosed, onActivi
|
|
|
78
82
|
const rows = useRowWindow();
|
|
79
83
|
useEarlierMessages(store, state, scroller, rows);
|
|
80
84
|
const [away, toBottom] = useAwayFromBottom(scroller);
|
|
85
|
+
// Scrolled up while the conversation waits for the user to decide: the way down says so, to the choice at its end.
|
|
86
|
+
const [letGo] = usePersisted(LET_GO_ASKS);
|
|
87
|
+
const asking = !state.working && info ? ChatAskUtil.asking(info, letGo) : undefined;
|
|
81
88
|
useKeyboardDismiss(scroller);
|
|
82
89
|
const fail = (cause) => notices.error(cause);
|
|
90
|
+
const stopTimed = useStopTimes(store.sessionId, 'chat');
|
|
83
91
|
useSessionNotices(store, state.notices);
|
|
84
92
|
const { settings, actions } = useSessionSettings(server, useSettingsServer(), store, state.working, t, fail);
|
|
85
93
|
const composer = React.useRef(null);
|
|
@@ -122,6 +130,8 @@ export function SessionView({ store, server, workspace, info, onClosed, onActivi
|
|
|
122
130
|
const addons = useComposerAddons(conversation);
|
|
123
131
|
const outbox = React.useMemo(() => ({ resend: id => void store.resend(id), discard: id => store.discard(id) }), [store]);
|
|
124
132
|
const images = React.useCallback((timestamp, index) => server.getMessageImage(store.sessionId, timestamp, index), [server, store]);
|
|
133
|
+
// A choice in a card of a reply answers this conversation, wherever it is shown, not the one in front.
|
|
134
|
+
const reply = React.useCallback((text) => store.prompt(text, { streamingBehavior: 'followUp' }).then(() => undefined), [store]);
|
|
125
135
|
return (React.createElement("section", { className: `ta-session ${compact ? 'ta-session-compact' : ''}` },
|
|
126
136
|
!compact && (React.createElement("header", { className: "ta-session-header" },
|
|
127
137
|
leading,
|
|
@@ -139,16 +149,22 @@ export function SessionView({ store, server, workspace, info, onClosed, onActivi
|
|
|
139
149
|
React.createElement(FileUrls.Provider, { value: fileUrl },
|
|
140
150
|
React.createElement(OpenLink.Provider, { value: openLink },
|
|
141
151
|
React.createElement(MessageImages.Provider, { value: images },
|
|
142
|
-
React.createElement(
|
|
152
|
+
React.createElement(CodeReply.Provider, { value: reply },
|
|
153
|
+
React.createElement(MessageList, { state: state, outbox: outbox, rows: rows }))))))))),
|
|
143
154
|
React.createElement("div", { className: "ta-bottom" },
|
|
144
|
-
away &&
|
|
145
|
-
React.createElement(
|
|
155
|
+
away &&
|
|
156
|
+
(asking ? (React.createElement("button", { type: "button", className: "ta-to-bottom ta-to-ask", title: t('ta.chat.toAsk', { question: asking.question }), onClick: toBottom },
|
|
157
|
+
React.createElement("span", { className: "ta-to-ask-mark", "aria-hidden": "true" }, "?"),
|
|
158
|
+
React.createElement("span", null, t('ta.chat.asking')),
|
|
159
|
+
React.createElement(ArrowDown, { size: 14 }))) : (React.createElement("button", { type: "button", className: "ta-to-bottom", "aria-label": t('ta.session.toBottom'), title: t('ta.session.toBottom'), onClick: toBottom },
|
|
160
|
+
React.createElement(ArrowDown, { size: 18 })))),
|
|
161
|
+
notice,
|
|
146
162
|
React.createElement(GrowBox, null,
|
|
147
163
|
dialog && React.createElement(DialogView, { key: dialog.id, request: dialog, respond: response => store.respondUi(response).catch(fail) }),
|
|
148
164
|
aboveComposer,
|
|
149
165
|
widgetsAt('aboveEditor'),
|
|
150
166
|
addons.above),
|
|
151
|
-
React.createElement(Composer, { ref: composer, store: store, server: server, workspace: workspace, working: state.working, commands: settings.commands, cwd: info === null || info === void 0 ? void 0 : info.cwd, actions: [actions, ...addons.actions], recentShots: recentShots, onError: fail }),
|
|
167
|
+
React.createElement(Composer, { ref: composer, store: store, server: server, workspace: workspace, working: state.working, commands: settings.commands, cwd: info === null || info === void 0 ? void 0 : info.cwd, actions: [actions, ...addons.actions], recentShots: recentShots, onStopTimed: stopTimed, onError: fail }),
|
|
152
168
|
belowComposer,
|
|
153
169
|
widgetsAt('belowEditor'),
|
|
154
170
|
statuses.length > 0 && (React.createElement("div", { className: "ta-statusline" }, statuses.map(([key, text]) => (React.createElement(StatusChip, { key: key, text: text }))))))));
|
|
@@ -29,9 +29,9 @@ export function Row({ label, icon, description, stacked, modified, children }) {
|
|
|
29
29
|
return (React.createElement("div", { className: `ta-setting-row${stacked ? ' ta-stacked' : ''}${modified ? ' ta-modified' : ''}` },
|
|
30
30
|
icon && (React.createElement("span", { className: "ta-setting-icon", "aria-hidden": "true" },
|
|
31
31
|
React.createElement(Icon, { icon: icon, size: 16 }))),
|
|
32
|
-
React.createElement("div", { className: "ta-setting-text" },
|
|
33
|
-
React.createElement("span", { className: "ta-setting-label" }, label),
|
|
34
|
-
description && React.createElement("span", { className: "ta-setting-description" }, description)),
|
|
32
|
+
(label || description) && (React.createElement("div", { className: "ta-setting-text" },
|
|
33
|
+
label && React.createElement("span", { className: "ta-setting-label" }, label),
|
|
34
|
+
description && React.createElement("span", { className: "ta-setting-description" }, description))),
|
|
35
35
|
children && React.createElement("div", { className: "ta-setting-control" }, children)));
|
|
36
36
|
}
|
|
37
37
|
/** A list of the settings with nothing in it yet: a quiet line in the middle of the row. */
|
|
@@ -17,6 +17,7 @@ import { EnvironmentSettings, useGateway } from './environment-view.js';
|
|
|
17
17
|
import { Icon, IconButton } from './icon.js';
|
|
18
18
|
import { useLaunchRows } from './launch-settings.js';
|
|
19
19
|
import { SettingsModelPicker } from './model-picker.js';
|
|
20
|
+
import { RelayServices } from './relay-services.js';
|
|
20
21
|
import { RemoteHosts } from './remote-hosts.js';
|
|
21
22
|
import { EmptyRow, Keys, Row, row, Segmented, Switch } from './settings-controls.js';
|
|
22
23
|
import { TrustedDomains } from './trusted-domains.js';
|
|
@@ -271,6 +272,17 @@ export function useParts(scope, onScope, onClose, onDialog) {
|
|
|
271
272
|
icon: Server,
|
|
272
273
|
rows: [row('remote', [t('ta.remote.title'), t('ta.remote.description'), 'ssh'], React.createElement(RemoteHosts, null))],
|
|
273
274
|
},
|
|
275
|
+
// Behind a gateway the relays are the gateway's business, not the tenant's.
|
|
276
|
+
...(gateway.info
|
|
277
|
+
? []
|
|
278
|
+
: [
|
|
279
|
+
{
|
|
280
|
+
id: 'relays',
|
|
281
|
+
title: t('ta.relays.title'),
|
|
282
|
+
icon: RefreshCw,
|
|
283
|
+
rows: [row('relays', [t('ta.relays.title'), t('ta.relays.addHint'), 'relay', 'relays.json'], React.createElement(RelayServices, null))],
|
|
284
|
+
},
|
|
285
|
+
]),
|
|
274
286
|
...(touch
|
|
275
287
|
? []
|
|
276
288
|
: [
|
|
@@ -345,7 +357,7 @@ function extensionSection({ id, section }) {
|
|
|
345
357
|
const label = WebLabelUtil.text(item.label);
|
|
346
358
|
const description = item.description === undefined ? undefined : WebLabelUtil.text(item.description);
|
|
347
359
|
const Control = item.render;
|
|
348
|
-
return row(`${id}/${item.key}`, [label, description, title], React.createElement(Row, { label: label, description: description, stacked: item.stacked },
|
|
360
|
+
return row(`${id}/${item.key}`, [label, description, title, item.search === undefined ? undefined : WebLabelUtil.text(item.search)], React.createElement(Row, { label: label, description: description, stacked: item.stacked },
|
|
349
361
|
React.createElement(ExtensionBoundary, { name: title, resetKey: Control },
|
|
350
362
|
React.createElement(Control, null))));
|
|
351
363
|
}),
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { StateSpec } from '../state/state-protocol.js';
|
|
2
|
+
/** How long the stop of a run took, as the box that pressed it saw it (Composer.onStopTimed). */
|
|
3
|
+
export interface StopTiming {
|
|
4
|
+
/** When it was pressed (`Date.now()` of the device). */
|
|
5
|
+
at: number;
|
|
6
|
+
/** From the press until the computer answered the stop (TaServer.abort): there and back, and the run winding down. */
|
|
7
|
+
answered?: number;
|
|
8
|
+
/** From the press until the run was seen ended (`working` false). */
|
|
9
|
+
ended?: number;
|
|
10
|
+
/** The stop failed (the connection lost): the button came back. */
|
|
11
|
+
failed?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** One stop, kept: where it was pressed, and how long each part took. */
|
|
14
|
+
export interface StopTime extends StopTiming {
|
|
15
|
+
/** The first 8 characters of the session's id, as the line of `ta serve` that says how long it took there. */
|
|
16
|
+
session: string;
|
|
17
|
+
view: 'chat' | 'double';
|
|
18
|
+
device: 'phone' | 'tablet' | 'desktop';
|
|
19
|
+
/** Through the relay (a computer paired) or straight to its ta serve. */
|
|
20
|
+
link: 'relay' | 'direct';
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The last stops of every device, on the computer (the data of @celljs/ta-web, `stop.times`), to find where a slow
|
|
24
|
+
* stop spent its time: with the line `ta serve: stopped <session> in <ms>` of serve.log, what the run took to end on
|
|
25
|
+
* the computer; the rest of `answered` is the way there and back.
|
|
26
|
+
*/
|
|
27
|
+
export declare const STOP_TIMES: StateSpec<StopTime[]>;
|
|
28
|
+
export declare namespace StopTimeUtil {
|
|
29
|
+
function parse(value: unknown): StopTime[] | undefined;
|
|
30
|
+
/** The stops of both, each once, by when they were pressed; `a` itself when `b` adds nothing. */
|
|
31
|
+
function merge(a: StopTime[], b: StopTime[]): StopTime[];
|
|
32
|
+
function add(times: StopTime[], time: StopTime): StopTime[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The timing of one stop, from the press: told (`StopTiming`) by whichever of the answer of the computer and the
|
|
36
|
+
* end of the run comes last; the answer comes after the end, which the computer tells first. A failed stop is told
|
|
37
|
+
* at its answer, without an end. Once told, nothing more.
|
|
38
|
+
*/
|
|
39
|
+
export declare class StopClock {
|
|
40
|
+
protected readonly start: number;
|
|
41
|
+
protected readonly timing: StopTiming;
|
|
42
|
+
protected told: boolean;
|
|
43
|
+
constructor(start: number, at: number);
|
|
44
|
+
answered(now: number, failed?: boolean): StopTiming | undefined;
|
|
45
|
+
ended(now: number): StopTiming | undefined;
|
|
46
|
+
protected tell(): StopTiming | undefined;
|
|
47
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/** The stops kept at most: the latest. */
|
|
2
|
+
const KEPT = 30;
|
|
3
|
+
/**
|
|
4
|
+
* The last stops of every device, on the computer (the data of @celljs/ta-web, `stop.times`), to find where a slow
|
|
5
|
+
* stop spent its time: with the line `ta serve: stopped <session> in <ms>` of serve.log, what the run took to end on
|
|
6
|
+
* the computer; the rest of `answered` is the way there and back.
|
|
7
|
+
*/
|
|
8
|
+
export const STOP_TIMES = {
|
|
9
|
+
key: 'stop.times',
|
|
10
|
+
tier: 'user',
|
|
11
|
+
initial: [],
|
|
12
|
+
parse: value => StopTimeUtil.parse(value),
|
|
13
|
+
merge: (local, remote) => StopTimeUtil.merge(local, remote),
|
|
14
|
+
};
|
|
15
|
+
export var StopTimeUtil;
|
|
16
|
+
(function (StopTimeUtil) {
|
|
17
|
+
const VIEWS = ['chat', 'double'];
|
|
18
|
+
const DEVICES = ['phone', 'tablet', 'desktop'];
|
|
19
|
+
const LINKS = ['relay', 'direct'];
|
|
20
|
+
function parse(value) {
|
|
21
|
+
if (!Array.isArray(value)) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
return value.filter((time) => !!time &&
|
|
25
|
+
typeof time.at === 'number' &&
|
|
26
|
+
typeof time.session === 'string' &&
|
|
27
|
+
VIEWS.includes(time.view) &&
|
|
28
|
+
DEVICES.includes(time.device) &&
|
|
29
|
+
LINKS.includes(time.link));
|
|
30
|
+
}
|
|
31
|
+
StopTimeUtil.parse = parse;
|
|
32
|
+
/** The stops of both, each once, by when they were pressed; `a` itself when `b` adds nothing. */
|
|
33
|
+
function merge(a, b) {
|
|
34
|
+
const keys = new Set(a.map(key));
|
|
35
|
+
const added = b.filter(time => !keys.has(key(time)));
|
|
36
|
+
return added.length ? [...a, ...added].sort((x, y) => x.at - y.at).slice(-KEPT) : a;
|
|
37
|
+
}
|
|
38
|
+
StopTimeUtil.merge = merge;
|
|
39
|
+
function add(times, time) {
|
|
40
|
+
return merge(times, [time]);
|
|
41
|
+
}
|
|
42
|
+
StopTimeUtil.add = add;
|
|
43
|
+
function key(time) {
|
|
44
|
+
return `${time.at}|${time.session}`;
|
|
45
|
+
}
|
|
46
|
+
})(StopTimeUtil || (StopTimeUtil = {}));
|
|
47
|
+
/**
|
|
48
|
+
* The timing of one stop, from the press: told (`StopTiming`) by whichever of the answer of the computer and the
|
|
49
|
+
* end of the run comes last; the answer comes after the end, which the computer tells first. A failed stop is told
|
|
50
|
+
* at its answer, without an end. Once told, nothing more.
|
|
51
|
+
*/
|
|
52
|
+
export class StopClock {
|
|
53
|
+
constructor(start, at) {
|
|
54
|
+
this.start = start;
|
|
55
|
+
this.told = false;
|
|
56
|
+
this.timing = { at };
|
|
57
|
+
}
|
|
58
|
+
answered(now, failed = false) {
|
|
59
|
+
if (this.timing.answered === undefined) {
|
|
60
|
+
this.timing.answered = Math.round(now - this.start);
|
|
61
|
+
if (failed) {
|
|
62
|
+
this.timing.failed = true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return this.tell();
|
|
66
|
+
}
|
|
67
|
+
ended(now) {
|
|
68
|
+
if (this.timing.ended === undefined && !this.timing.failed) {
|
|
69
|
+
this.timing.ended = Math.round(now - this.start);
|
|
70
|
+
}
|
|
71
|
+
return this.tell();
|
|
72
|
+
}
|
|
73
|
+
tell() {
|
|
74
|
+
if (this.told || this.timing.answered === undefined || (this.timing.ended === undefined && !this.timing.failed)) {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
this.told = true;
|
|
78
|
+
return { ...this.timing };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=stop-times.js.map
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { AVATAR_VIEWBOX, DinoAvatar, frame, headAt } from '../avatar/dino-avatar.js';
|
|
3
3
|
import { DinoMotion, POKE } from '../avatar/dino-motion.js';
|
|
4
4
|
import { DinoSpecies } from '../avatar/dino-species.js';
|
|
5
|
+
import { ScrollRest } from '../util/scroll-rest.js';
|
|
5
6
|
let next = 0;
|
|
6
7
|
/** How long a change of mood takes to blend into the new motion, in seconds. */
|
|
7
8
|
const BLEND = 0.45;
|
|
@@ -122,6 +123,11 @@ function tick(now) {
|
|
|
122
123
|
}
|
|
123
124
|
return;
|
|
124
125
|
}
|
|
126
|
+
// Still while the page scrolls: a frame of a fling is the scroll's.
|
|
127
|
+
if (ScrollRest.moving(now)) {
|
|
128
|
+
loop = requestAnimationFrame(tick);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
125
131
|
// Read where they all are first, then draw them all, so the page is laid out once a frame.
|
|
126
132
|
for (const player of players) {
|
|
127
133
|
player.box = player.visible && pointer ? player.svg.getBoundingClientRect() : undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ToolOutput } from '../util/message.js';
|
|
3
|
+
/** What a command printed, its last lines; the earlier ones open from above. */
|
|
4
|
+
export declare function Output({ text, className }: {
|
|
5
|
+
text: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
}): React.JSX.Element;
|
|
8
|
+
/**
|
|
9
|
+
* What a call of another agent's tool did, under its line (`agent_tool` of @celljs/ta-agents): the whole command,
|
|
10
|
+
* what it returned read as a person reads it, and the script of a code mode call behind a button. None: nothing to show,
|
|
11
|
+
* and the line does not open (the calls of a script return to the script).
|
|
12
|
+
*/
|
|
13
|
+
export declare function agentToolDetails(args: Record<string, unknown>, output: ToolOutput | undefined): React.ReactNode;
|