@celljs/ta-web 4.9.1 → 4.10.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 +4 -3
- package/README.md +4 -3
- package/esm/browser/assistant/assistant-chat-list.js +8 -2
- package/esm/browser/assistant/assistant-extension.d.ts +8 -1
- package/esm/browser/assistant/assistant-extension.js +20 -0
- package/esm/browser/assistant/assistant-protocol.d.ts +3 -1
- package/esm/browser/assistant/assistant-task-util.d.ts +2 -0
- package/esm/browser/assistant/assistant-task-util.js +5 -3
- package/esm/browser/assistant/assistant-view.js +81 -56
- package/esm/browser/assistant/assistant.d.ts +10 -1
- package/esm/browser/assistant/assistant.js +44 -5
- package/esm/browser/chat/chat-packages.d.ts +39 -0
- package/esm/browser/chat/chat-packages.js +70 -0
- package/esm/browser/chat/chat-protocol.d.ts +23 -1
- package/esm/browser/chat/chat-stores.d.ts +59 -0
- package/esm/browser/chat/chat-stores.js +121 -0
- package/esm/browser/chat/chat-util.d.ts +17 -0
- package/esm/browser/chat/chat-util.js +61 -0
- package/esm/browser/chat/chat-view.js +33 -12
- package/esm/browser/chat/chat.d.ts +31 -39
- package/esm/browser/chat/chat.js +226 -175
- package/esm/browser/components/app-nav.d.ts +6 -3
- package/esm/browser/components/app-nav.js +19 -10
- package/esm/browser/components/app-shell-hooks.d.ts +2 -2
- package/esm/browser/components/app-shell-hooks.js +7 -3
- package/esm/browser/components/app-view.js +75 -21
- package/esm/browser/components/chat-list.d.ts +20 -2
- package/esm/browser/components/chat-list.js +138 -22
- package/esm/browser/components/composer-box.d.ts +5 -5
- package/esm/browser/components/composer-box.js +111 -4
- package/esm/browser/components/composer.d.ts +7 -0
- package/esm/browser/components/composer.js +5 -4
- package/esm/browser/components/connection-bar.js +50 -17
- package/esm/browser/components/context-menu.d.ts +30 -4
- package/esm/browser/components/context-menu.js +199 -37
- package/esm/browser/components/conversation-scroll.d.ts +129 -6
- package/esm/browser/components/conversation-scroll.js +429 -109
- package/esm/browser/components/earlier-messages.d.ts +2 -1
- package/esm/browser/components/earlier-messages.js +2 -17
- package/esm/browser/components/editor-area.d.ts +3 -1
- package/esm/browser/components/editor-area.js +6 -5
- package/esm/browser/components/empty-pictures.d.ts +0 -2
- package/esm/browser/components/empty-pictures.js +0 -16
- package/esm/browser/components/folder-picker.d.ts +5 -2
- package/esm/browser/components/folder-picker.js +26 -8
- package/esm/browser/components/held-talk.d.ts +28 -0
- package/esm/browser/components/held-talk.js +76 -0
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/icon.d.ts +2 -2
- package/esm/browser/components/icon.js +5 -6
- package/esm/browser/components/image-viewer.d.ts +124 -0
- package/esm/browser/components/image-viewer.js +397 -0
- package/esm/browser/components/lightbox.d.ts +11 -0
- package/esm/browser/components/lightbox.js +24 -0
- package/esm/browser/components/markdown.d.ts +6 -2
- package/esm/browser/components/markdown.js +24 -10
- package/esm/browser/components/media.js +1 -10
- package/esm/browser/components/message-footer.d.ts +16 -2
- package/esm/browser/components/message-footer.js +29 -12
- package/esm/browser/components/message-list.d.ts +24 -3
- package/esm/browser/components/message-list.js +149 -20
- package/esm/browser/components/message-menu.d.ts +3 -1
- package/esm/browser/components/message-menu.js +18 -3
- package/esm/browser/components/nav-places.d.ts +16 -1
- package/esm/browser/components/nav-places.js +12 -3
- package/esm/browser/components/phone-shell.d.ts +4 -1
- package/esm/browser/components/phone-shell.js +3 -1
- package/esm/browser/components/run-status.js +3 -3
- package/esm/browser/components/session-settings.d.ts +6 -0
- package/esm/browser/components/session-settings.js +14 -1
- package/esm/browser/components/session-view.js +8 -4
- package/esm/browser/components/settings-parts.d.ts +2 -2
- package/esm/browser/components/settings-parts.js +24 -1
- package/esm/browser/components/swipe-row.d.ts +2 -2
- package/esm/browser/components/swipe-row.js +7 -3
- package/esm/browser/components/tool-view.js +14 -12
- package/esm/browser/components/voice-button.d.ts +1 -1
- package/esm/browser/components/voice-button.js +1 -1
- package/esm/browser/components/voice-talk.d.ts +43 -0
- package/esm/browser/components/voice-talk.js +222 -0
- package/esm/browser/device/device.d.ts +3 -0
- package/esm/browser/device/device.js +11 -1
- package/esm/browser/device/hold.d.ts +42 -0
- package/esm/browser/device/hold.js +136 -0
- package/esm/browser/device/launch-screen.d.ts +1 -1
- package/esm/browser/device/launch-screen.js +1 -1
- package/esm/browser/device/long-press.d.ts +2 -0
- package/esm/browser/device/long-press.js +16 -1
- package/esm/browser/device/pull-down.d.ts +4 -2
- package/esm/browser/device/pull-down.js +64 -76
- package/esm/browser/device/row-swipe.d.ts +35 -10
- package/esm/browser/device/row-swipe.js +149 -71
- package/esm/browser/device/shake-undo.d.ts +16 -0
- package/esm/browser/device/shake-undo.js +59 -0
- package/esm/browser/device/sheet-swipe.d.ts +118 -18
- package/esm/browser/device/sheet-swipe.js +406 -107
- package/esm/browser/extension/web-extension-api.d.ts +97 -1
- package/esm/browser/extension/web-extension-code.d.ts +6 -0
- package/esm/browser/extension/web-extension-code.js +24 -0
- package/esm/browser/extension/web-extension-protocol.d.ts +23 -1
- package/esm/browser/extension/web-extension-protocol.js +8 -0
- package/esm/browser/extension/web-extensions.d.ts +14 -1
- package/esm/browser/extension/web-extensions.js +122 -23
- package/esm/browser/files/files-protocol.d.ts +25 -0
- package/esm/browser/files/files-protocol.js +2 -0
- package/esm/browser/files/files.d.ts +35 -0
- package/esm/browser/files/files.js +119 -0
- package/esm/browser/i18n/locales.d.ts +24 -2
- package/esm/browser/i18n/messages.d.ts +23 -1
- package/esm/browser/i18n/messages.js +48 -4
- package/esm/browser/index.d.ts +6 -0
- package/esm/browser/index.js +6 -0
- package/esm/browser/notices/notices-protocol.d.ts +9 -1
- package/esm/browser/notices/notices.d.ts +2 -0
- package/esm/browser/notices/notices.js +20 -10
- package/esm/browser/offline/device-values.d.ts +55 -0
- package/esm/browser/offline/device-values.js +142 -0
- package/esm/browser/offline/kept-chats-protocol.d.ts +17 -0
- package/esm/browser/offline/kept-chats-protocol.js +2 -0
- package/esm/browser/offline/kept-chats.d.ts +47 -0
- package/esm/browser/offline/kept-chats.js +146 -0
- package/esm/browser/offline/offline-reads.d.ts +44 -0
- package/esm/browser/offline/offline-reads.js +107 -0
- package/esm/browser/settings/settings-protocol.d.ts +2 -0
- package/esm/browser/settings/settings-protocol.js +2 -0
- package/esm/browser/style/conversation.d.ts +1 -1
- package/esm/browser/style/conversation.js +57 -17
- package/esm/browser/style/device.js +27 -4
- package/esm/browser/style/layout.d.ts +1 -1
- package/esm/browser/style/layout.js +67 -15
- package/esm/browser/style/pages.d.ts +1 -1
- package/esm/browser/style/pages.js +2 -1
- package/esm/browser/style/shell.d.ts +1 -1
- package/esm/browser/style/shell.js +46 -3
- package/esm/browser/util/frame.d.ts +5 -4
- package/esm/browser/util/frame.js +5 -4
- package/esm/browser/util/markdown.d.ts +18 -1
- package/esm/browser/util/markdown.js +119 -5
- package/esm/browser/util/process.d.ts +21 -0
- package/esm/browser/util/process.js +45 -1
- package/esm/browser/util/voice.d.ts +5 -2
- package/esm/browser/util/voice.js +6 -3
- package/esm/browser/util/zoom.d.ts +46 -0
- package/esm/browser/util/zoom.js +96 -0
- package/esm/browser/workbench-calls.d.ts +59 -0
- package/esm/browser/workbench-calls.js +141 -0
- package/esm/browser/workbench-protocol.d.ts +5 -1
- package/esm/browser/workbench-util.d.ts +7 -0
- package/esm/browser/workbench-util.js +9 -2
- package/esm/browser/workbench.d.ts +14 -5
- package/esm/browser/workbench.js +51 -31
- package/lib/browser/assistant/assistant-chat-list.js +8 -2
- package/lib/browser/assistant/assistant-extension.d.ts +8 -1
- package/lib/browser/assistant/assistant-extension.js +20 -0
- package/lib/browser/assistant/assistant-protocol.d.ts +3 -1
- package/lib/browser/assistant/assistant-task-util.d.ts +2 -0
- package/lib/browser/assistant/assistant-task-util.js +5 -3
- package/lib/browser/assistant/assistant-view.js +78 -53
- package/lib/browser/assistant/assistant.d.ts +10 -1
- package/lib/browser/assistant/assistant.js +44 -5
- package/lib/browser/chat/chat-packages.d.ts +40 -0
- package/lib/browser/chat/chat-packages.js +74 -0
- package/lib/browser/chat/chat-protocol.d.ts +23 -1
- package/lib/browser/chat/chat-stores.d.ts +60 -0
- package/lib/browser/chat/chat-stores.js +125 -0
- package/lib/browser/chat/chat-util.d.ts +18 -0
- package/lib/browser/chat/chat-util.js +64 -0
- package/lib/browser/chat/chat-view.js +33 -12
- package/lib/browser/chat/chat.d.ts +31 -39
- package/lib/browser/chat/chat.js +227 -176
- package/lib/browser/components/app-nav.d.ts +6 -3
- package/lib/browser/components/app-nav.js +17 -8
- package/lib/browser/components/app-shell-hooks.d.ts +2 -2
- package/lib/browser/components/app-shell-hooks.js +7 -3
- package/lib/browser/components/app-view.js +74 -20
- package/lib/browser/components/chat-list.d.ts +20 -2
- package/lib/browser/components/chat-list.js +137 -21
- package/lib/browser/components/composer-box.d.ts +5 -5
- package/lib/browser/components/composer-box.js +111 -4
- package/lib/browser/components/composer.d.ts +7 -0
- package/lib/browser/components/composer.js +5 -4
- package/lib/browser/components/connection-bar.js +48 -15
- package/lib/browser/components/context-menu.d.ts +30 -4
- package/lib/browser/components/context-menu.js +198 -36
- package/lib/browser/components/conversation-scroll.d.ts +129 -6
- package/lib/browser/components/conversation-scroll.js +431 -110
- package/lib/browser/components/earlier-messages.d.ts +2 -1
- package/lib/browser/components/earlier-messages.js +2 -17
- package/lib/browser/components/editor-area.d.ts +3 -1
- package/lib/browser/components/editor-area.js +5 -4
- package/lib/browser/components/empty-pictures.d.ts +0 -2
- package/lib/browser/components/empty-pictures.js +0 -17
- package/lib/browser/components/folder-picker.d.ts +5 -2
- package/lib/browser/components/folder-picker.js +26 -8
- package/lib/browser/components/held-talk.d.ts +29 -0
- package/lib/browser/components/held-talk.js +79 -0
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/icon.d.ts +2 -2
- package/lib/browser/components/icon.js +7 -6
- package/lib/browser/components/image-viewer.d.ts +125 -0
- package/lib/browser/components/image-viewer.js +435 -0
- package/lib/browser/components/lightbox.d.ts +12 -0
- package/lib/browser/components/lightbox.js +60 -0
- package/lib/browser/components/markdown.d.ts +6 -2
- package/lib/browser/components/markdown.js +24 -10
- package/lib/browser/components/media.js +2 -11
- package/lib/browser/components/message-footer.d.ts +16 -2
- package/lib/browser/components/message-footer.js +31 -12
- package/lib/browser/components/message-list.d.ts +24 -3
- package/lib/browser/components/message-list.js +146 -16
- package/lib/browser/components/message-menu.d.ts +3 -1
- package/lib/browser/components/message-menu.js +17 -2
- package/lib/browser/components/nav-places.d.ts +16 -1
- package/lib/browser/components/nav-places.js +13 -3
- package/lib/browser/components/phone-shell.d.ts +4 -1
- package/lib/browser/components/phone-shell.js +3 -1
- package/lib/browser/components/run-status.js +3 -3
- package/lib/browser/components/session-settings.d.ts +6 -0
- package/lib/browser/components/session-settings.js +14 -1
- package/lib/browser/components/session-view.js +7 -3
- package/lib/browser/components/settings-parts.d.ts +2 -2
- package/lib/browser/components/settings-parts.js +24 -1
- package/lib/browser/components/swipe-row.d.ts +2 -2
- package/lib/browser/components/swipe-row.js +7 -3
- package/lib/browser/components/tool-view.js +14 -12
- package/lib/browser/components/voice-button.d.ts +1 -1
- package/lib/browser/components/voice-button.js +1 -1
- package/lib/browser/components/voice-talk.d.ts +44 -0
- package/lib/browser/components/voice-talk.js +260 -0
- package/lib/browser/device/device.d.ts +3 -0
- package/lib/browser/device/device.js +11 -1
- package/lib/browser/device/hold.d.ts +43 -0
- package/lib/browser/device/hold.js +173 -0
- package/lib/browser/device/launch-screen.d.ts +1 -1
- package/lib/browser/device/launch-screen.js +1 -1
- package/lib/browser/device/long-press.d.ts +2 -0
- package/lib/browser/device/long-press.js +16 -1
- package/lib/browser/device/pull-down.d.ts +4 -2
- package/lib/browser/device/pull-down.js +63 -75
- package/lib/browser/device/row-swipe.d.ts +35 -10
- package/lib/browser/device/row-swipe.js +148 -70
- package/lib/browser/device/shake-undo.d.ts +17 -0
- package/lib/browser/device/shake-undo.js +63 -0
- package/lib/browser/device/sheet-swipe.d.ts +118 -18
- package/lib/browser/device/sheet-swipe.js +410 -108
- package/lib/browser/extension/web-extension-api.d.ts +97 -1
- package/lib/browser/extension/web-extension-code.d.ts +6 -0
- package/lib/browser/extension/web-extension-code.js +24 -0
- package/lib/browser/extension/web-extension-protocol.d.ts +23 -1
- package/lib/browser/extension/web-extension-protocol.js +9 -1
- package/lib/browser/extension/web-extensions.d.ts +14 -1
- package/lib/browser/extension/web-extensions.js +120 -21
- package/lib/browser/files/files-protocol.d.ts +26 -0
- package/lib/browser/files/files-protocol.js +5 -0
- package/lib/browser/files/files.d.ts +36 -0
- package/lib/browser/files/files.js +122 -0
- package/lib/browser/i18n/locales.d.ts +24 -2
- package/lib/browser/i18n/messages.d.ts +23 -1
- package/lib/browser/i18n/messages.js +48 -4
- package/lib/browser/index.d.ts +6 -0
- package/lib/browser/index.js +6 -0
- package/lib/browser/notices/notices-protocol.d.ts +9 -1
- package/lib/browser/notices/notices.d.ts +2 -0
- package/lib/browser/notices/notices.js +20 -10
- package/lib/browser/offline/device-values.d.ts +56 -0
- package/lib/browser/offline/device-values.js +148 -0
- package/lib/browser/offline/kept-chats-protocol.d.ts +18 -0
- package/lib/browser/offline/kept-chats-protocol.js +5 -0
- package/lib/browser/offline/kept-chats.d.ts +48 -0
- package/lib/browser/offline/kept-chats.js +149 -0
- package/lib/browser/offline/offline-reads.d.ts +45 -0
- package/lib/browser/offline/offline-reads.js +111 -0
- package/lib/browser/settings/settings-protocol.d.ts +2 -0
- package/lib/browser/settings/settings-protocol.js +2 -0
- package/lib/browser/style/conversation.d.ts +1 -1
- package/lib/browser/style/conversation.js +57 -17
- package/lib/browser/style/device.js +27 -4
- package/lib/browser/style/layout.d.ts +1 -1
- package/lib/browser/style/layout.js +67 -15
- package/lib/browser/style/pages.d.ts +1 -1
- package/lib/browser/style/pages.js +2 -1
- package/lib/browser/style/shell.d.ts +1 -1
- package/lib/browser/style/shell.js +46 -3
- package/lib/browser/util/frame.d.ts +5 -4
- package/lib/browser/util/frame.js +5 -4
- package/lib/browser/util/markdown.d.ts +18 -1
- package/lib/browser/util/markdown.js +119 -5
- package/lib/browser/util/process.d.ts +21 -0
- package/lib/browser/util/process.js +46 -2
- package/lib/browser/util/voice.d.ts +5 -2
- package/lib/browser/util/voice.js +6 -3
- package/lib/browser/util/zoom.d.ts +47 -0
- package/lib/browser/util/zoom.js +99 -0
- package/lib/browser/workbench-calls.d.ts +60 -0
- package/lib/browser/workbench-calls.js +145 -0
- package/lib/browser/workbench-protocol.d.ts +5 -1
- package/lib/browser/workbench-util.d.ts +7 -0
- package/lib/browser/workbench-util.js +10 -3
- package/lib/browser/workbench.d.ts +14 -5
- package/lib/browser/workbench.js +51 -31
- package/package.json +10 -10
- package/public/launch.svg +46 -42
|
@@ -9,6 +9,13 @@ export declare const PROBE_MS = 15000;
|
|
|
9
9
|
* the first tries to connect again are within it, so a short drop shows nothing.
|
|
10
10
|
*/
|
|
11
11
|
export declare const GRACE_MS = 2500;
|
|
12
|
+
/**
|
|
13
|
+
* While the page connects, how long a call that reads waits for the connection before it answers as it did
|
|
14
|
+
* last time (OfflineReads): through a relay the page is mostly online within it, and gets what is new.
|
|
15
|
+
*/
|
|
16
|
+
export declare const KEPT_AFTER_MS = 1000;
|
|
17
|
+
/** How long a call of a conversation waits for a connection the page never had, as TaConnection's `waitForOpenMs`. */
|
|
18
|
+
export declare const STORE_WAIT_MS = 5000;
|
|
12
19
|
/** How long the page shows which computer it switches to before it loads again for it. */
|
|
13
20
|
export declare const SWITCH_MS = 160;
|
|
14
21
|
export interface KeptLists {
|
|
@@ -14,10 +14,17 @@ const RETRY_DELAYS_MS = [1000, 2000, 4000, 8000];
|
|
|
14
14
|
export const GRACE_MS = 2500;
|
|
15
15
|
/**
|
|
16
16
|
* The lists of the last time, of the ta serve they were of: the next start shows them at once while it
|
|
17
|
-
* connects, as a phone's app shows its chats before it is online. They are small
|
|
18
|
-
* are
|
|
17
|
+
* connects, as a phone's app shows its chats before it is online. They are small, and read before the
|
|
18
|
+
* first frame; the conversations and what web extensions read are kept in IndexedDB (offline/).
|
|
19
19
|
*/
|
|
20
20
|
const LISTS_KEY = 'ta.lists';
|
|
21
|
+
/**
|
|
22
|
+
* While the page connects, how long a call that reads waits for the connection before it answers as it did
|
|
23
|
+
* last time (OfflineReads): through a relay the page is mostly online within it, and gets what is new.
|
|
24
|
+
*/
|
|
25
|
+
export const KEPT_AFTER_MS = 1000;
|
|
26
|
+
/** How long a call of a conversation waits for a connection the page never had, as TaConnection's `waitForOpenMs`. */
|
|
27
|
+
export const STORE_WAIT_MS = 5000;
|
|
21
28
|
/** How long the page shows which computer it switches to before it loads again for it. */
|
|
22
29
|
export const SWITCH_MS = 160;
|
|
23
30
|
/** A conversation opens with about this much of its latest messages, its earlier ones loaded as much at a time when scrolled to. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SessionStore, type SessionStoreOptions, TaConnection } from '@celljs/ta-client';
|
|
2
2
|
import { type TaAccessServer, type TaAuthEvent, type TaAuthServer, type TaGatewayServer, type TaPackageServer, type TaRelayServer, type TaRemoteEvent, type TaRemoteServer, type TaServer, type TaServerInfo, type TaSettingsServer, type TaTerminalServer, type TaWorkspaceServer } from '@celljs/ta-protocol';
|
|
3
3
|
import { type HostList } from './hosts.js';
|
|
4
|
+
import { WorkbenchCalls } from './workbench-calls.js';
|
|
4
5
|
import { type Credential, TaWorkbench, type WorkbenchState } from './workbench-protocol.js';
|
|
5
6
|
import { type ServiceName } from './workbench-util.js';
|
|
6
7
|
export declare class TaWorkbenchImpl implements TaWorkbench {
|
|
@@ -16,13 +17,20 @@ export declare class TaWorkbenchImpl implements TaWorkbench {
|
|
|
16
17
|
protected graceMs: number;
|
|
17
18
|
/** The ta serve of the sign-in of now, whose lists are kept as they change. */
|
|
18
19
|
protected listsOf?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The calls of the services and of the stores, to the connection of the time; answered from the device
|
|
22
|
+
* while offline, for the computer in use from the start (web extensions started from the device read
|
|
23
|
+
* before the page connects).
|
|
24
|
+
*/
|
|
25
|
+
protected readonly calls: WorkbenchCalls;
|
|
19
26
|
/** Those waiting for the connection (`connected`): `resolve` once online, `reject` once signed out. */
|
|
20
|
-
protected readonly beforeConnection: Map<ServiceName, object>;
|
|
21
27
|
protected readonly connectedWaiters: Set<{
|
|
22
28
|
resolve(): void;
|
|
23
29
|
reject(error: Error): void;
|
|
24
30
|
}>;
|
|
25
31
|
protected waking: boolean;
|
|
32
|
+
protected refreshing?: Promise<void>;
|
|
33
|
+
protected refreshAgain?: Promise<void>;
|
|
26
34
|
/** Counts sign-ins and sign-outs: an attempt of an earlier one does nothing when it ends. */
|
|
27
35
|
protected generation: number;
|
|
28
36
|
protected readonly listeners: Set<(state: WorkbenchState) => void>;
|
|
@@ -41,10 +49,6 @@ export declare class TaWorkbenchImpl implements TaWorkbench {
|
|
|
41
49
|
get gateway(): TaGatewayServer;
|
|
42
50
|
get relay(): TaRelayServer;
|
|
43
51
|
get remote(): TaRemoteServer;
|
|
44
|
-
/**
|
|
45
|
-
* A service of the connection; before there is one (the lists of the last time show meanwhile), its
|
|
46
|
-
* calls wait for it, and fail if the page signs out instead.
|
|
47
|
-
*/
|
|
48
52
|
protected service<K extends ServiceName>(name: K): TaConnection[K];
|
|
49
53
|
protected signedIn(): TaConnection;
|
|
50
54
|
onTerminalData(listener: (terminalId: string, data: string, exitCode?: number) => void): () => void;
|
|
@@ -84,7 +88,12 @@ export declare class TaWorkbenchImpl implements TaWorkbench {
|
|
|
84
88
|
signOut(): void;
|
|
85
89
|
connected(): Promise<void>;
|
|
86
90
|
reconnect(): void;
|
|
91
|
+
/**
|
|
92
|
+
* One read of the lists at a time: asked again meanwhile, one more follows it for all who asked, so that
|
|
93
|
+
* reads on a slow network do not pile up.
|
|
94
|
+
*/
|
|
87
95
|
refresh(): Promise<void>;
|
|
96
|
+
protected readLists(): Promise<void>;
|
|
88
97
|
createStore(sessionId: string, options?: SessionStoreOptions): SessionStore;
|
|
89
98
|
/** The prompts of ssh that wait for an answer, from now and those already there. */
|
|
90
99
|
protected watchRemote(connection: TaConnection): Promise<void>;
|
package/esm/browser/workbench.js
CHANGED
|
@@ -9,7 +9,9 @@ import { SessionStore, TaConnection } from '@celljs/ta-client';
|
|
|
9
9
|
import { TA_WEBSOCKET_PATH, TaErrorCode, } from '@celljs/ta-protocol';
|
|
10
10
|
import { RelaySocket } from '@celljs/ta-relay';
|
|
11
11
|
import { HostUtil } from './hosts.js';
|
|
12
|
+
import { deviceValues, OfflineKeys } from './offline/device-values.js';
|
|
12
13
|
import { StateUtil } from './state/state-protocol.js';
|
|
14
|
+
import { WorkbenchCalls } from './workbench-calls.js';
|
|
13
15
|
import { TaWorkbench } from './workbench-protocol.js';
|
|
14
16
|
import { GRACE_MS, PAGE_BYTES, PROBE_MS, pageHost, SWITCH_MS, storage, WorkbenchError, WorkbenchUtil, } from './workbench-util.js';
|
|
15
17
|
let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
@@ -18,8 +20,23 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
18
20
|
this.current = { status: 'connecting', hosts: this.list.hosts, host: this.list.current, sessions: [], saved: [] };
|
|
19
21
|
this.attempts = 0;
|
|
20
22
|
this.graceMs = GRACE_MS;
|
|
23
|
+
/**
|
|
24
|
+
* The calls of the services and of the stores, to the connection of the time; answered from the device
|
|
25
|
+
* while offline, for the computer in use from the start (web extensions started from the device read
|
|
26
|
+
* before the page connects).
|
|
27
|
+
*/
|
|
28
|
+
this.calls = new WorkbenchCalls({
|
|
29
|
+
status: () => this.current.status,
|
|
30
|
+
connection: () => this.connection,
|
|
31
|
+
connected: () => this.connected(),
|
|
32
|
+
subscribe: listener => this.subscribe(listener),
|
|
33
|
+
dataChanged: (name, keys, cwd) => {
|
|
34
|
+
for (const listener of this.extensionDataListeners) {
|
|
35
|
+
listener(name, keys, cwd);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
}, this.list.current);
|
|
21
39
|
/** Those waiting for the connection (`connected`): `resolve` once online, `reject` once signed out. */
|
|
22
|
-
this.beforeConnection = new Map();
|
|
23
40
|
this.connectedWaiters = new Set();
|
|
24
41
|
this.waking = false;
|
|
25
42
|
/** Counts sign-ins and sign-outs: an attempt of an earlier one does nothing when it ends. */
|
|
@@ -63,32 +80,8 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
63
80
|
get remote() {
|
|
64
81
|
return this.service('remote');
|
|
65
82
|
}
|
|
66
|
-
/**
|
|
67
|
-
* A service of the connection; before there is one (the lists of the last time show meanwhile), its
|
|
68
|
-
* calls wait for it, and fail if the page signs out instead.
|
|
69
|
-
*/
|
|
70
83
|
service(name) {
|
|
71
|
-
|
|
72
|
-
return this.connection[name];
|
|
73
|
-
}
|
|
74
|
-
// The same each time, as the connection's are: what is given it is not drawn again for nothing.
|
|
75
|
-
const known = this.beforeConnection.get(name);
|
|
76
|
-
if (known) {
|
|
77
|
-
return known;
|
|
78
|
-
}
|
|
79
|
-
const service = new Proxy({}, {
|
|
80
|
-
get: (_target, method) =>
|
|
81
|
-
// Not a promise itself.
|
|
82
|
-
method === 'then'
|
|
83
|
-
? undefined
|
|
84
|
-
: async (...params) => {
|
|
85
|
-
await this.connected();
|
|
86
|
-
const real = this.signedIn()[name];
|
|
87
|
-
return real[method](...params);
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
this.beforeConnection.set(name, service);
|
|
91
|
-
return service;
|
|
84
|
+
return this.calls.service(name);
|
|
92
85
|
}
|
|
93
86
|
signedIn() {
|
|
94
87
|
if (!this.connection) {
|
|
@@ -220,6 +213,7 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
220
213
|
if (kept) {
|
|
221
214
|
StateUtil.forgetHost(kept, hostId);
|
|
222
215
|
}
|
|
216
|
+
void OfflineKeys.forget(deviceValues(), hostId);
|
|
223
217
|
if (this.listsOf === hostId) {
|
|
224
218
|
this.listsOf = undefined;
|
|
225
219
|
}
|
|
@@ -244,6 +238,7 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
244
238
|
if (of !== this.listsOf) {
|
|
245
239
|
// Another ta serve: its lists of the last time, or none, rather than those of the one before.
|
|
246
240
|
this.listsOf = of;
|
|
241
|
+
this.calls.reads.use(of);
|
|
247
242
|
this.update({ server: undefined, sessions: [], saved: [], ...WorkbenchUtil.readLists((_c = (_b = storage()) === null || _b === void 0 ? void 0 : _b.getItem(WorkbenchUtil.listsKey(of))) !== null && _c !== void 0 ? _c : null, of) });
|
|
248
243
|
}
|
|
249
244
|
this.update({ status: 'connecting', error: undefined });
|
|
@@ -315,6 +310,11 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
315
310
|
void this.watchRemote(connection);
|
|
316
311
|
});
|
|
317
312
|
void this.watchRemote(connection);
|
|
313
|
+
if ('pairing' in credential) {
|
|
314
|
+
// Through a relay the computer has let the page in once the socket is open, and no gateway is behind
|
|
315
|
+
// it: the calls of the page go now, with the one that reads who it is, not a round trip after it.
|
|
316
|
+
this.update({ status: 'online', error: undefined, retryAt: undefined });
|
|
317
|
+
}
|
|
318
318
|
let server;
|
|
319
319
|
try {
|
|
320
320
|
server = await connection.server.getServerInfo();
|
|
@@ -387,7 +387,27 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
387
387
|
(_a = this.connection) === null || _a === void 0 ? void 0 : _a.reconnect();
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
|
-
|
|
390
|
+
/**
|
|
391
|
+
* One read of the lists at a time: asked again meanwhile, one more follows it for all who asked, so that
|
|
392
|
+
* reads on a slow network do not pile up.
|
|
393
|
+
*/
|
|
394
|
+
refresh() {
|
|
395
|
+
var _a;
|
|
396
|
+
if (!this.refreshing) {
|
|
397
|
+
this.refreshing = this.readLists().finally(() => {
|
|
398
|
+
this.refreshing = undefined;
|
|
399
|
+
});
|
|
400
|
+
return this.refreshing;
|
|
401
|
+
}
|
|
402
|
+
(_a = this.refreshAgain) !== null && _a !== void 0 ? _a : (this.refreshAgain = this.refreshing
|
|
403
|
+
.catch(() => undefined)
|
|
404
|
+
.then(() => {
|
|
405
|
+
this.refreshAgain = undefined;
|
|
406
|
+
return this.refresh();
|
|
407
|
+
}));
|
|
408
|
+
return this.refreshAgain;
|
|
409
|
+
}
|
|
410
|
+
async readLists() {
|
|
391
411
|
// A ta serve of before has no saved sessions to list: its list stays the open ones. The default
|
|
392
412
|
// directory comes along, as another device may have changed it.
|
|
393
413
|
const [sessions, saved, server] = await Promise.all([
|
|
@@ -404,10 +424,7 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
404
424
|
});
|
|
405
425
|
}
|
|
406
426
|
createStore(sessionId, options) {
|
|
407
|
-
|
|
408
|
-
throw new Error('Not signed in to ta serve.');
|
|
409
|
-
}
|
|
410
|
-
return new SessionStore(this.connection, sessionId, { pageBytes: PAGE_BYTES, ...options });
|
|
427
|
+
return new SessionStore(this.calls.link, sessionId, { pageBytes: PAGE_BYTES, ...options });
|
|
411
428
|
}
|
|
412
429
|
/** The prompts of ssh that wait for an answer, from now and those already there. */
|
|
413
430
|
async watchRemote(connection) {
|
|
@@ -496,6 +513,9 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
496
513
|
if (this.listsOf && (next.sessions !== before.sessions || next.saved !== before.saved || next.server !== before.server)) {
|
|
497
514
|
this.keepLists(this.listsOf);
|
|
498
515
|
}
|
|
516
|
+
if (before.status !== 'online') {
|
|
517
|
+
this.calls.online();
|
|
518
|
+
}
|
|
499
519
|
}
|
|
500
520
|
}
|
|
501
521
|
keepLists(of) {
|
|
@@ -38,18 +38,24 @@ const React = __importStar(require("react"));
|
|
|
38
38
|
const chat_list_1 = require("../components/chat-list");
|
|
39
39
|
const connection_bar_1 = require("../components/connection-bar");
|
|
40
40
|
const hooks_1 = require("../hooks");
|
|
41
|
+
const use_t_1 = require("../i18n/use-t");
|
|
41
42
|
const assistant_hooks_1 = require("./assistant-hooks");
|
|
42
43
|
/** The list of chats with what the double knows of them: its tasks marked, a conversation to hand it. */
|
|
43
44
|
function AssistantChatList(props) {
|
|
44
45
|
var _a;
|
|
45
46
|
const [{ tasks, ready }, assistant] = (0, assistant_hooks_1.useAssistant)();
|
|
46
47
|
const [, notices] = (0, hooks_1.useNotices)();
|
|
48
|
+
const t = (0, use_t_1.useT)();
|
|
49
|
+
const name = assistant.name || t('ta.builtin.assistant');
|
|
47
50
|
const session = ready ? (_a = assistant.store()) === null || _a === void 0 ? void 0 : _a.sessionId : undefined;
|
|
51
|
+
const { sessionFile } = assistant;
|
|
48
52
|
const double = React.useMemo(() => ({
|
|
49
|
-
tasks: new
|
|
53
|
+
tasks: new Map(tasks.filter(task => !task.takenOver).map(task => [task.sessionId, task.status])),
|
|
50
54
|
session,
|
|
55
|
+
sessionFile,
|
|
56
|
+
name,
|
|
51
57
|
hand: (info, title) => void assistant.adopt({ sessionId: info.sessionId, title, cwd: info.cwd }).catch(error => notices.error(error)),
|
|
52
|
-
}), [tasks, session, assistant, notices]);
|
|
58
|
+
}), [tasks, session, sessionFile, name, assistant, notices]);
|
|
53
59
|
return React.createElement(chat_list_1.ChatList, { ...props, double: double, notice: React.createElement(connection_bar_1.ConnectionBanner, null) });
|
|
54
60
|
}
|
|
55
61
|
//# sourceMappingURL=assistant-chat-list.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WebExtensionAPI, WebExtensionFactory, WebMenuItem } from '../extension/web-extension-api';
|
|
1
|
+
import type { WebExtensionAPI, WebExtensionFactory, WebMenuItem, WebViewPreview } from '../extension/web-extension-api';
|
|
2
2
|
import { BuiltinWebExtension } from '../extension/web-extension-protocol';
|
|
3
3
|
import { TaSettings } from '../settings/settings-protocol';
|
|
4
4
|
import { TaState } from '../state/state-protocol';
|
|
@@ -17,6 +17,13 @@ export declare class AssistantWebExtension implements BuiltinWebExtension {
|
|
|
17
17
|
protected readonly persisted: TaState;
|
|
18
18
|
protected readonly workbench: TaWorkbench;
|
|
19
19
|
protected readonly settings: TaSettings;
|
|
20
|
+
/**
|
|
21
|
+
* What the double said last, as the list of chats shows a conversation: from the open sessions, else the
|
|
22
|
+
* saved ones. A note of a task the double reads is not something said to the user: none then.
|
|
23
|
+
*/
|
|
24
|
+
protected preview(): WebViewPreview | undefined;
|
|
25
|
+
/** The double answers in its own conversation now. */
|
|
26
|
+
protected busy(): boolean;
|
|
20
27
|
readonly activate: WebExtensionFactory;
|
|
21
28
|
/** The … of the page: stop, start over; its name, its look, its system prompt, the default directory its tasks open in; the conversation as a file. */
|
|
22
29
|
protected menu(pi: WebExtensionAPI): WebMenuItem[][];
|
|
@@ -139,6 +139,9 @@ let AssistantWebExtension = class AssistantWebExtension {
|
|
|
139
139
|
icon: lucide_react_1.Bot,
|
|
140
140
|
render: () => React.createElement(assistant_view_1.AssistantPanel, { onTask: openTask }),
|
|
141
141
|
menu: () => this.menu(pi),
|
|
142
|
+
preview: () => this.preview(),
|
|
143
|
+
busy: () => this.busy(),
|
|
144
|
+
subscribe: listener => this.workbench.subscribe(() => listener()),
|
|
142
145
|
});
|
|
143
146
|
registerPage();
|
|
144
147
|
pi.registerView('tasks-card', {
|
|
@@ -186,6 +189,23 @@ let AssistantWebExtension = class AssistantWebExtension {
|
|
|
186
189
|
};
|
|
187
190
|
};
|
|
188
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* What the double said last, as the list of chats shows a conversation: from the open sessions, else the
|
|
194
|
+
* saved ones. A note of a task the double reads is not something said to the user: none then.
|
|
195
|
+
*/
|
|
196
|
+
preview() {
|
|
197
|
+
var _a;
|
|
198
|
+
const file = this.assistant.sessionFile;
|
|
199
|
+
const { sessions, saved } = this.workbench.state;
|
|
200
|
+
const session = file ? ((_a = sessions.find(each => each.sessionFile === file)) !== null && _a !== void 0 ? _a : saved.find(each => each.sessionFile === file)) : undefined;
|
|
201
|
+
const text = session === null || session === void 0 ? void 0 : session.lastMessage;
|
|
202
|
+
return text && !text.startsWith('<task_') ? { text, at: session.updatedAt } : undefined;
|
|
203
|
+
}
|
|
204
|
+
/** The double answers in its own conversation now. */
|
|
205
|
+
busy() {
|
|
206
|
+
const file = this.assistant.sessionFile;
|
|
207
|
+
return !!file && this.workbench.state.sessions.some(each => each.sessionFile === file && each.isStreaming);
|
|
208
|
+
}
|
|
189
209
|
/** The … of the page: stop, start over; its name, its look, its system prompt, the default directory its tasks open in; the conversation as a file. */
|
|
190
210
|
menu(pi) {
|
|
191
211
|
var _a;
|
|
@@ -58,8 +58,10 @@ export interface TaAssistant {
|
|
|
58
58
|
warm(): Promise<void>;
|
|
59
59
|
/** Reads the tasks kept, for the lists, without opening the conversation. */
|
|
60
60
|
loadTasks(): Promise<void>;
|
|
61
|
-
/** The conversation with ta. */
|
|
61
|
+
/** The conversation with ta; before it opens, it as this device kept it (`showKept`), if it did. */
|
|
62
62
|
store(): SessionStore | undefined;
|
|
63
|
+
/** Before the conversation opens, and without the computer: shows it as this device last saw it. */
|
|
64
|
+
showKept(): Promise<void>;
|
|
63
65
|
taskStore(taskId: string): SessionStore | undefined;
|
|
64
66
|
/**
|
|
65
67
|
* The session of a task to show: the one followed, else its conversation opened again from its file (a
|
|
@@ -13,6 +13,8 @@ export declare namespace AssistantTaskUtil {
|
|
|
13
13
|
/**
|
|
14
14
|
* The tasks of both lists, each in its newer copy (the higher `rev`; the server's, `theirs`, when
|
|
15
15
|
* both are as new, so that the pages end with the same), in the order they started; the last MAX_TASKS.
|
|
16
|
+
* A task taken off the list in either stays off: a page that changed it meanwhile, as often, does not
|
|
17
|
+
* bring it back.
|
|
16
18
|
*/
|
|
17
19
|
function merge(ours: readonly AssistantTask[], theirs: readonly AssistantTask[]): AssistantTask[];
|
|
18
20
|
/** The tasks the lists show. */
|
|
@@ -20,6 +20,8 @@ var AssistantTaskUtil;
|
|
|
20
20
|
/**
|
|
21
21
|
* The tasks of both lists, each in its newer copy (the higher `rev`; the server's, `theirs`, when
|
|
22
22
|
* both are as new, so that the pages end with the same), in the order they started; the last MAX_TASKS.
|
|
23
|
+
* A task taken off the list in either stays off: a page that changed it meanwhile, as often, does not
|
|
24
|
+
* bring it back.
|
|
23
25
|
*/
|
|
24
26
|
function merge(ours, theirs) {
|
|
25
27
|
var _a, _b;
|
|
@@ -29,9 +31,9 @@ var AssistantTaskUtil;
|
|
|
29
31
|
}
|
|
30
32
|
for (const task of theirs) {
|
|
31
33
|
const mine = byId.get(task.id);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
34
|
+
const newer = !mine || ((_a = task.rev) !== null && _a !== void 0 ? _a : 0) >= ((_b = mine.rev) !== null && _b !== void 0 ? _b : 0) ? task : mine;
|
|
35
|
+
const removed = !!(task.removed || (mine === null || mine === void 0 ? void 0 : mine.removed));
|
|
36
|
+
byId.set(task.id, removed && !newer.removed ? { ...newer, removed } : newer);
|
|
35
37
|
}
|
|
36
38
|
return [...byId.values()].sort((a, b) => number(a.id) - number(b.id) || a.startedAt - b.startedAt).slice(-exports.MAX_TASKS);
|
|
37
39
|
}
|
|
@@ -41,6 +41,7 @@ const React = __importStar(require("react"));
|
|
|
41
41
|
const callout_1 = require("../components/callout");
|
|
42
42
|
const composer_1 = require("../components/composer");
|
|
43
43
|
const composer_addons_1 = require("../components/composer-addons");
|
|
44
|
+
const connection_bar_1 = require("../components/connection-bar");
|
|
44
45
|
const conversation_scroll_1 = require("../components/conversation-scroll");
|
|
45
46
|
const dialog_view_1 = require("../components/dialog-view");
|
|
46
47
|
const earlier_messages_1 = require("../components/earlier-messages");
|
|
@@ -123,37 +124,33 @@ function lastReply(messages, start) {
|
|
|
123
124
|
}
|
|
124
125
|
return undefined;
|
|
125
126
|
}
|
|
126
|
-
/** When an item of the conversation began: its first message; one still empty (a turn about to come), when the one before did. */
|
|
127
|
-
function startsOf(items) {
|
|
128
|
-
let last = Number.NEGATIVE_INFINITY;
|
|
129
|
-
return items.map(item => {
|
|
130
|
-
const first = item.kind === 'turn' ? item.messages[0] : item.message;
|
|
131
|
-
const at = first === null || first === void 0 ? void 0 : first.timestamp;
|
|
132
|
-
last = typeof at === 'number' ? at : last;
|
|
133
|
-
return last;
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
127
|
/** A turn of the double: held, it opens the same menu as a turn of a conversation (message-menu.tsx). */
|
|
137
|
-
function DoubleTurn({ item, children }) {
|
|
128
|
+
function DoubleTurn({ item, latest, children }) {
|
|
138
129
|
const reply = item.reply.join('\n\n').trim();
|
|
139
|
-
const [menu, onContextMenu] = (0, message_menu_1.useMessageMenu)({
|
|
130
|
+
const [menu, onContextMenu] = (0, message_menu_1.useMessageMenu)({
|
|
131
|
+
kind: 'turn',
|
|
132
|
+
last: item.active ? undefined : item.last,
|
|
133
|
+
reply: item.active ? '' : reply,
|
|
134
|
+
messages: item.messages,
|
|
135
|
+
});
|
|
140
136
|
return (React.createElement("div", { className: `ta-msg-ta ${item.active ? 'ta-turn-live' : ''}`, onContextMenu: onContextMenu },
|
|
141
137
|
children,
|
|
142
|
-
!item.active && React.createElement(message_footer_1.TurnFooter, { messages: item.messages, last: item.last, reply: reply }),
|
|
138
|
+
!item.active && React.createElement(message_footer_1.TurnFooter, { messages: item.messages, last: item.last, reply: reply, latest: latest }),
|
|
143
139
|
menu));
|
|
144
140
|
}
|
|
145
141
|
/** What the user said to the double: held, the same menu as a message of a conversation. */
|
|
146
142
|
function DoubleUserMessage({ message, blocks, text }) {
|
|
147
143
|
const [menu, onContextMenu] = (0, message_menu_1.useMessageMenu)({ kind: 'user', message, text });
|
|
148
144
|
return (React.createElement("div", { className: `ta-msg-user ${conversation_scroll_1.ASK_CLASS}`, onContextMenu: onContextMenu },
|
|
149
|
-
React.createElement(message_list_1.
|
|
150
|
-
text && React.createElement("div", { className: "ta-msg-bubble" }, text),
|
|
145
|
+
React.createElement(message_list_1.UserSaid, { blocks: blocks, text: text, bubble: "ta-msg-bubble" }),
|
|
151
146
|
React.createElement(message_footer_1.UserFooter, { message: message, text: text }),
|
|
152
147
|
menu));
|
|
153
148
|
}
|
|
154
149
|
function Conversation({ state, tasks, origin, onTask, t }) {
|
|
155
150
|
const items = React.useMemo(() => process_1.ProcessUtil.items(state.messages, state.working, state.start), [state.messages, state.working, state.start]);
|
|
156
|
-
const starts = React.useMemo(() =>
|
|
151
|
+
const starts = React.useMemo(() => process_1.ProcessUtil.starts(items), [items]);
|
|
152
|
+
const renderers = React.useContext(extension_view_1.MessageRenderers);
|
|
153
|
+
const breaks = React.useMemo(() => process_1.ProcessUtil.timeBreaks(starts, index => process_1.ProcessUtil.shown(items[index], renderers)), [starts, items, renderers]);
|
|
157
154
|
const own = React.useMemo(() => tasks.filter(task => task.origin && task.origin === origin), [tasks, origin]);
|
|
158
155
|
let lastTurn = items.length - 1;
|
|
159
156
|
while (lastTurn >= 0 && items[lastTurn].kind !== 'turn') {
|
|
@@ -163,40 +160,43 @@ function Conversation({ state, tasks, origin, onTask, t }) {
|
|
|
163
160
|
const last = items[items.length - 1];
|
|
164
161
|
const status = state.working || state.compacting ? React.createElement(run_status_1.RunStatus, { state: state }) : undefined;
|
|
165
162
|
const onHead = status && (0, message_list_1.quiet)(last);
|
|
163
|
+
const row = (item, index) => {
|
|
164
|
+
var _a, _b;
|
|
165
|
+
if (item.kind === 'turn') {
|
|
166
|
+
const results = message_1.MessageUtil.results(item.messages);
|
|
167
|
+
const { errorMessage } = ((_a = item.last) !== null && _a !== void 0 ? _a : {});
|
|
168
|
+
const stopReason = message_1.MessageUtil.stopReason(item.last);
|
|
169
|
+
const mood = process_1.ProcessUtil.mood(item, index === lastTurn, waiting);
|
|
170
|
+
const started = web_tasks_1.WebTaskUtil.startedIn(own, origin, starts[index], (_b = starts[index + 1]) !== null && _b !== void 0 ? _b : Number.POSITIVE_INFINITY);
|
|
171
|
+
return (React.createElement(DoubleTurn, { key: item.key, item: item, latest: index === lastTurn },
|
|
172
|
+
React.createElement(message_list_1.Process, { steps: item.steps, active: item.active, results: results, tools: state.tools, leading: React.createElement(message_list_1.TurnAvatar, { mood: mood }), status: onHead && item === last ? status : undefined }),
|
|
173
|
+
React.createElement(task_views_1.TaskCards, { tasks: started }),
|
|
174
|
+
item.reply.map((text, index) => (React.createElement(markdown_1.Markdown, { key: index, text: text, streaming: item.active && index === item.reply.length - 1 }))),
|
|
175
|
+
!item.active && stopReason === 'error' && errorMessage && React.createElement(callout_1.Callout, { level: "error" }, errorMessage)));
|
|
176
|
+
}
|
|
177
|
+
const { role } = item.message;
|
|
178
|
+
if (role === 'custom') {
|
|
179
|
+
return React.createElement(extension_view_1.CustomMessage, { key: item.key, message: item.message });
|
|
180
|
+
}
|
|
181
|
+
if (role !== 'user') {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
const blocks = message_1.MessageUtil.blocks(item.message);
|
|
185
|
+
const text = message_1.MessageUtil.text(blocks).trim();
|
|
186
|
+
const update = TASK_UPDATE.exec(text);
|
|
187
|
+
if (update) {
|
|
188
|
+
const status = update[3];
|
|
189
|
+
return (React.createElement("button", { key: item.key, type: "button", className: "ta-task-update", onClick: () => onTask(update[1]) },
|
|
190
|
+
React.createElement("span", { className: `ta-status ta-status-${assistant_tasks_1.TASK_DOTS[status]}` }),
|
|
191
|
+
React.createElement("span", { className: "ta-task-update-text" }, t('ta.task.ended', { title: update[2], status: t(`ta.task.${status}`) })),
|
|
192
|
+
React.createElement(icon_1.Icon, { icon: lucide_react_1.ChevronRight, size: 13, className: "ta-task-update-chevron" })));
|
|
193
|
+
}
|
|
194
|
+
return React.createElement(DoubleUserMessage, { key: item.key, message: item.message, blocks: blocks, text: text });
|
|
195
|
+
};
|
|
166
196
|
return (React.createElement(React.Fragment, null,
|
|
167
|
-
items.map((item, index) => {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const results = message_1.MessageUtil.results(item.messages);
|
|
171
|
-
const { errorMessage } = ((_a = item.last) !== null && _a !== void 0 ? _a : {});
|
|
172
|
-
const stopReason = message_1.MessageUtil.stopReason(item.last);
|
|
173
|
-
const mood = process_1.ProcessUtil.mood(item, index === lastTurn, waiting);
|
|
174
|
-
const started = web_tasks_1.WebTaskUtil.startedIn(own, origin, starts[index], (_b = starts[index + 1]) !== null && _b !== void 0 ? _b : Number.POSITIVE_INFINITY);
|
|
175
|
-
return (React.createElement(DoubleTurn, { key: item.key, item: item },
|
|
176
|
-
React.createElement(message_list_1.Process, { steps: item.steps, active: item.active, results: results, tools: state.tools, leading: React.createElement(message_list_1.TurnAvatar, { mood: mood }), status: onHead && item === last ? status : undefined }),
|
|
177
|
-
React.createElement(task_views_1.TaskCards, { tasks: started }),
|
|
178
|
-
item.reply.map((text, index) => (React.createElement(markdown_1.Markdown, { key: index, text: text }))),
|
|
179
|
-
!item.active && stopReason === 'error' && errorMessage && React.createElement(callout_1.Callout, { level: "error" }, errorMessage)));
|
|
180
|
-
}
|
|
181
|
-
const { role } = item.message;
|
|
182
|
-
if (role === 'custom') {
|
|
183
|
-
return React.createElement(extension_view_1.CustomMessage, { key: item.key, message: item.message });
|
|
184
|
-
}
|
|
185
|
-
if (role !== 'user') {
|
|
186
|
-
return null;
|
|
187
|
-
}
|
|
188
|
-
const blocks = message_1.MessageUtil.blocks(item.message);
|
|
189
|
-
const text = message_1.MessageUtil.text(blocks).trim();
|
|
190
|
-
const update = TASK_UPDATE.exec(text);
|
|
191
|
-
if (update) {
|
|
192
|
-
const status = update[3];
|
|
193
|
-
return (React.createElement("button", { key: item.key, type: "button", className: "ta-task-update", onClick: () => onTask(update[1]) },
|
|
194
|
-
React.createElement("span", { className: `ta-status ta-status-${assistant_tasks_1.TASK_DOTS[status]}` }),
|
|
195
|
-
React.createElement("span", { className: "ta-task-update-text" }, t('ta.task.ended', { title: update[2], status: t(`ta.task.${status}`) })),
|
|
196
|
-
React.createElement(icon_1.Icon, { icon: lucide_react_1.ChevronRight, size: 13, className: "ta-task-update-chevron" })));
|
|
197
|
-
}
|
|
198
|
-
return React.createElement(DoubleUserMessage, { key: item.key, message: item.message, blocks: blocks, text: text });
|
|
199
|
-
}),
|
|
197
|
+
items.map((item, index) => (React.createElement(React.Fragment, { key: item.key },
|
|
198
|
+
breaks[index] !== undefined && React.createElement(message_footer_1.TimeBreak, { timestamp: breaks[index] }),
|
|
199
|
+
row(item, index)))),
|
|
200
200
|
status && !onHead && React.createElement("div", { className: "ta-run-line" }, status)));
|
|
201
201
|
}
|
|
202
202
|
function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
|
|
@@ -215,7 +215,7 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
|
|
|
215
215
|
const [, notices] = (0, hooks_1.useNotices)();
|
|
216
216
|
const spoken = React.useRef(undefined);
|
|
217
217
|
const box = React.useRef(null);
|
|
218
|
-
const { speak, confirmTasks } = settingsState.settings;
|
|
218
|
+
const { speak, speakTalk, confirmTasks } = settingsState.settings;
|
|
219
219
|
const [name] = (0, hooks_1.usePersisted)(assistant_state_1.ASSISTANT_NAME_STATE);
|
|
220
220
|
const attentions = [
|
|
221
221
|
...state.pendingUi.map(request => ({ source: 'ta', store, request })),
|
|
@@ -238,6 +238,10 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
|
|
|
238
238
|
});
|
|
239
239
|
React.useEffect(() => onMood(mood), [mood, onMood]);
|
|
240
240
|
const reply = lastReply(state.messages, state.start);
|
|
241
|
+
// Said to it by voice, held (its box, or its entry of the navigation): what it answers is heard once, as a
|
|
242
|
+
// conversation by voice, where the user asked for it (Settings.speakTalk, off at first: a reply read out loud
|
|
243
|
+
// where the user only wanted to type by voice is awkward).
|
|
244
|
+
const aloud = React.useRef(false);
|
|
241
245
|
// Reads a new reply out once the run has settled; what was said before the page opened stays quiet.
|
|
242
246
|
React.useEffect(() => {
|
|
243
247
|
if (state.working || !reply || spoken.current === reply.index) {
|
|
@@ -245,7 +249,11 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
|
|
|
245
249
|
}
|
|
246
250
|
const first = spoken.current === undefined;
|
|
247
251
|
spoken.current = reply.index;
|
|
248
|
-
|
|
252
|
+
const audible = voice_1.Voice.canSpeak();
|
|
253
|
+
// A conversation by voice is heard even as the first reply the page shows.
|
|
254
|
+
const answerAloud = aloud.current && audible;
|
|
255
|
+
aloud.current = false;
|
|
256
|
+
if (answerAloud || (!first && speak && audible)) {
|
|
249
257
|
setSpeaking(true);
|
|
250
258
|
voice_1.Voice.speak(reply.text, settingsState.language, () => setSpeaking(false));
|
|
251
259
|
}
|
|
@@ -314,6 +322,17 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
|
|
|
314
322
|
},
|
|
315
323
|
]
|
|
316
324
|
: []),
|
|
325
|
+
...(voice_1.Voice.canSpeak() && voice_1.Voice.canListen()
|
|
326
|
+
? [
|
|
327
|
+
{
|
|
328
|
+
key: 'speakTalk',
|
|
329
|
+
label: t('ta.settings.speakTalk'),
|
|
330
|
+
icon: React.createElement(icon_1.Icon, { icon: lucide_react_1.Mic, size: 16 }),
|
|
331
|
+
detail: t(speakTalk ? 'ta.on' : 'ta.off'),
|
|
332
|
+
run: () => settings.update({ speakTalk: !speakTalk }),
|
|
333
|
+
},
|
|
334
|
+
]
|
|
335
|
+
: []),
|
|
317
336
|
{
|
|
318
337
|
key: 'confirm',
|
|
319
338
|
label: t('ta.assistant.confirmOn'),
|
|
@@ -350,8 +369,11 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
|
|
|
350
369
|
attentions.map(({ source, store: from, request }) => (React.createElement("div", { key: request.id, className: "ta-attention" },
|
|
351
370
|
React.createElement("div", { className: "ta-attention-source" }, source),
|
|
352
371
|
React.createElement(dialog_view_1.DialogView, { request: request, respond: response => from.respondUi(response).catch(() => undefined) })))),
|
|
372
|
+
React.createElement(connection_bar_1.ConnectionBanner, null),
|
|
353
373
|
addons.above,
|
|
354
|
-
React.createElement(composer_1.Composer, { ref: box, store: store, server: bench.server, workspace: bench.workspace, working: state.working, commands: session.settings.commands, cwd: cwd, placeholder: t('ta.assistant.placeholder'), actions: actions, onSending: hush, onError: fail, voiceSends: true,
|
|
374
|
+
React.createElement(composer_1.Composer, { ref: box, store: store, server: bench.server, workspace: bench.workspace, working: state.working, commands: session.settings.commands, cwd: cwd, placeholder: t('ta.assistant.placeholder'), actions: actions, onSending: hush, onError: fail, voiceSends: true, talkPlace: "double", onTalkSent: () => {
|
|
375
|
+
aloud.current = speakTalk;
|
|
376
|
+
}, onListening: on => {
|
|
355
377
|
setListening(on);
|
|
356
378
|
if (on) {
|
|
357
379
|
hush();
|
|
@@ -369,6 +391,9 @@ function AssistantPanel({ onTask }) {
|
|
|
369
391
|
const [mood, setMood] = React.useState('idle');
|
|
370
392
|
const [name] = (0, hooks_1.usePersisted)(assistant_state_1.ASSISTANT_NAME_STATE);
|
|
371
393
|
const taskStates = (0, assistant_hooks_1.useTaskStates)(assistant, state.tasks);
|
|
394
|
+
React.useEffect(() => {
|
|
395
|
+
void assistant.showKept();
|
|
396
|
+
}, [assistant]);
|
|
372
397
|
React.useEffect(() => {
|
|
373
398
|
if (workbench.status === 'online') {
|
|
374
399
|
void assistant.start();
|
|
@@ -396,7 +421,7 @@ function AssistantPanel({ onTask }) {
|
|
|
396
421
|
React.createElement(task_views_1.TasksChip, { tasks: allTasks, onOpen: openTasks }),
|
|
397
422
|
React.createElement(workbench_toggle_1.WorkbenchToggle, null)),
|
|
398
423
|
React.createElement("div", { className: "ta-assistant-body" },
|
|
399
|
-
React.createElement("div", { className: "ta-assistant-chat" }, store ? (React.createElement(Chat, { store: store, tasks: state.tasks, taskStates: taskStates, onTask: openTask, onMood: setMood, onTasks: openTasks })) : (React.createElement("div", { className: "ta-empty" }, state.error ? (React.createElement(callout_1.Callout, { level: "error" }, state.error)) : (React.createElement(React.Fragment, null,
|
|
424
|
+
React.createElement("div", { className: "ta-assistant-chat" }, store ? (React.createElement(Chat, { store: store, tasks: state.tasks, taskStates: taskStates, onTask: openTask, onMood: setMood, onTasks: openTasks })) : (React.createElement("div", { className: "ta-empty" }, state.error ? (React.createElement(callout_1.Callout, { level: "error" }, state.error)) : workbench.offlineShown ? (React.createElement("span", { className: "ta-muted" }, t('ta.assistant.offline'))) : (React.createElement(React.Fragment, null,
|
|
400
425
|
React.createElement("span", { className: "ta-spinner" }),
|
|
401
426
|
" ",
|
|
402
427
|
t('ta.assistant.waking'))))))))));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ClientTool, type SessionState, type SessionStore } from '@celljs/ta-client';
|
|
2
2
|
import { type TaPromptInput, type TaServer, type TaSessionInfo } from '@celljs/ta-protocol';
|
|
3
|
+
import { TaKeptChats } from '../offline/kept-chats-protocol';
|
|
3
4
|
import { type Settings, TaSettings } from '../settings/settings-protocol';
|
|
4
5
|
import { TaState } from '../state/state-protocol';
|
|
5
6
|
import { TaWorkbench } from '../workbench-protocol';
|
|
@@ -15,8 +16,13 @@ export declare class TaAssistantImpl implements TaAssistant {
|
|
|
15
16
|
protected readonly workbench: TaWorkbench;
|
|
16
17
|
protected readonly persisted: TaState;
|
|
17
18
|
protected readonly settings: TaSettings;
|
|
19
|
+
protected readonly kept: TaKeptChats;
|
|
18
20
|
protected current: AssistantState;
|
|
19
21
|
protected assistant?: SessionStore;
|
|
22
|
+
/** Until the conversation is open (and while the computer cannot be reached): it as this device kept it. */
|
|
23
|
+
protected preview?: SessionStore;
|
|
24
|
+
/** Stops keeping the conversation on the device. */
|
|
25
|
+
protected unkeep?: () => void;
|
|
20
26
|
/** The directory of the conversation with ta, set when it opened: pi's `/new` keeps it. */
|
|
21
27
|
protected cwd?: string;
|
|
22
28
|
protected readonly taskStores: Map<string, SessionStore>;
|
|
@@ -53,6 +59,7 @@ export declare class TaAssistantImpl implements TaAssistant {
|
|
|
53
59
|
start(): Promise<void>;
|
|
54
60
|
warm(): Promise<void>;
|
|
55
61
|
store(): SessionStore | undefined;
|
|
62
|
+
showKept(): Promise<void>;
|
|
56
63
|
loadTasks(): Promise<void>;
|
|
57
64
|
/** The tasks other pages change, and the connection: back online (the service restarted, say), what runs is followed again. */
|
|
58
65
|
protected watchTasks(): void;
|
|
@@ -93,6 +100,8 @@ export declare class TaAssistantImpl implements TaAssistant {
|
|
|
93
100
|
protected reopen(store: SessionStore): Promise<void>;
|
|
94
101
|
stop(): Promise<void>;
|
|
95
102
|
restart(): Promise<void>;
|
|
103
|
+
/** Keeps the conversation on the device as it changes, under its file of the time (`restart` gives it another). */
|
|
104
|
+
protected keep(store: SessionStore): void;
|
|
96
105
|
/** The role of ta, whether it asks first, and what the user added to it. */
|
|
97
106
|
protected systemPrompt(): string;
|
|
98
107
|
/** Asking first or not is in the role: the conversation opens again with it, once the double is not at work. */
|