@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
package/lib/browser/chat/chat.js
CHANGED
|
@@ -9,68 +9,52 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.TaChatImpl =
|
|
12
|
+
exports.TaChatImpl = void 0;
|
|
13
13
|
const core_1 = require("@celljs/core");
|
|
14
|
+
const ta_client_1 = require("@celljs/ta-client");
|
|
14
15
|
const ta_protocol_1 = require("@celljs/ta-protocol");
|
|
15
16
|
const web_extension_protocol_1 = require("../extension/web-extension-protocol");
|
|
16
17
|
const notices_protocol_1 = require("../notices/notices-protocol");
|
|
18
|
+
const kept_chats_protocol_1 = require("../offline/kept-chats-protocol");
|
|
17
19
|
const state_protocol_1 = require("../state/state-protocol");
|
|
18
20
|
const frame_1 = require("../util/frame");
|
|
19
21
|
const workbench_protocol_1 = require("../workbench-protocol");
|
|
22
|
+
const chat_packages_1 = require("./chat-packages");
|
|
20
23
|
const chat_protocol_1 = require("./chat-protocol");
|
|
21
|
-
const
|
|
24
|
+
const chat_stores_1 = require("./chat-stores");
|
|
25
|
+
const chat_util_1 = require("./chat-util");
|
|
22
26
|
/** The file of the conversation shown last, in any browser: the page opens it again. */
|
|
23
27
|
const FILE = { key: 'chat.file', tier: 'user', initial: '', parse: state_protocol_1.StateUtil.string };
|
|
24
28
|
/** That conversation is of a package's group: the page shows it again only while it is open, as its package opens it with a role of its own. */
|
|
25
29
|
const GROUPED = { key: 'chat.grouped', tier: 'user', initial: false, parse: state_protocol_1.StateUtil.boolean };
|
|
26
|
-
/** The model the user picked for the last new conversation. */
|
|
27
|
-
const MODEL = { key: 'chat.model', tier: 'user', initial: '', parse: state_protocol_1.StateUtil.string };
|
|
28
|
-
/** A file in a directory of packages: `extensions/<name>/...`, of the user or a project. */
|
|
29
|
-
const PACKAGE_FILE = /(^|[\\/])extensions[\\/][^\\/]+[\\/]/;
|
|
30
|
-
var ChatUtil;
|
|
31
|
-
(function (ChatUtil) {
|
|
32
|
-
function toolNames(tools) {
|
|
33
|
-
return tools
|
|
34
|
-
.map(tool => tool.name)
|
|
35
|
-
.sort()
|
|
36
|
-
.join(',');
|
|
37
|
-
}
|
|
38
|
-
ChatUtil.toolNames = toolNames;
|
|
39
|
-
/** Ids of the runs of `write` and `edit` in a directory of packages that are not in `seen`. */
|
|
40
|
-
function packageEdits(state, seen) {
|
|
41
|
-
return Object.entries(state.tools)
|
|
42
|
-
.filter(([id, run]) => {
|
|
43
|
-
var _a;
|
|
44
|
-
const path = (_a = run.args) === null || _a === void 0 ? void 0 : _a.path;
|
|
45
|
-
return !seen.has(id) && (run.toolName === 'write' || run.toolName === 'edit') && typeof path === 'string' && PACKAGE_FILE.test(path);
|
|
46
|
-
})
|
|
47
|
-
.map(([id]) => id);
|
|
48
|
-
}
|
|
49
|
-
ChatUtil.packageEdits = packageEdits;
|
|
50
|
-
function message(error) {
|
|
51
|
-
return error instanceof Error ? error.message : String(error);
|
|
52
|
-
}
|
|
53
|
-
ChatUtil.message = message;
|
|
54
|
-
})(ChatUtil || (exports.ChatUtil = ChatUtil = {}));
|
|
55
30
|
let TaChatImpl = class TaChatImpl {
|
|
56
31
|
constructor() {
|
|
57
32
|
this.current = {};
|
|
58
33
|
this.listeners = new Set();
|
|
59
34
|
/** One change of the conversation shown at a time. */
|
|
60
35
|
this.queue = Promise.resolve();
|
|
61
|
-
/** The tools of the conversations this page opened, by session: only those are opened again when the tools change. */
|
|
62
|
-
this.opened = new Map();
|
|
63
|
-
this.seenEdits = new Set();
|
|
64
36
|
this.unfollow = [];
|
|
65
37
|
this.watching = false;
|
|
66
|
-
/** A web extension changed packages during a run: its end loads them again. */
|
|
67
|
-
this.reloadPending = false;
|
|
68
38
|
/** Sessions shown while still on their way, counted for their keys. */
|
|
69
39
|
this.coming = 0;
|
|
70
|
-
/**
|
|
71
|
-
this.
|
|
72
|
-
|
|
73
|
-
|
|
40
|
+
/** Stop was pressed while the new conversation opened: its run stops once it is there. */
|
|
41
|
+
this.stopping = false;
|
|
42
|
+
}
|
|
43
|
+
/** The packages of the conversation shown, loaded again after a run that changed them. */
|
|
44
|
+
get packages() {
|
|
45
|
+
var _a;
|
|
46
|
+
(_a = this.madePackages) !== null && _a !== void 0 ? _a : (this.madePackages = new chat_packages_1.ChatPackages(this.extensions, this.workbench, this.stores, {
|
|
47
|
+
shown: () => this.current.store,
|
|
48
|
+
enqueue: change => this.enqueue(change),
|
|
49
|
+
reopen: store => this.reopen(store),
|
|
50
|
+
}));
|
|
51
|
+
return this.madePackages;
|
|
52
|
+
}
|
|
53
|
+
/** The sessions and stores of the conversations, made once the services are in. */
|
|
54
|
+
get stores() {
|
|
55
|
+
var _a;
|
|
56
|
+
(_a = this.madeStores) !== null && _a !== void 0 ? _a : (this.madeStores = new chat_stores_1.ChatStores(this.workbench, this.kept, this.extensions));
|
|
57
|
+
return this.madeStores;
|
|
74
58
|
}
|
|
75
59
|
get state() {
|
|
76
60
|
return this.current;
|
|
@@ -87,7 +71,7 @@ let TaChatImpl = class TaChatImpl {
|
|
|
87
71
|
this.workbench.subscribe(state => {
|
|
88
72
|
this.followDefault();
|
|
89
73
|
if (state.status === 'signed-out') {
|
|
90
|
-
this.recent.clear();
|
|
74
|
+
this.stores.recent.clear();
|
|
91
75
|
if (this.current.store) {
|
|
92
76
|
this.leave(false);
|
|
93
77
|
}
|
|
@@ -99,10 +83,14 @@ let TaChatImpl = class TaChatImpl {
|
|
|
99
83
|
}
|
|
100
84
|
await this.extensions.refresh();
|
|
101
85
|
await this.workbench.refresh();
|
|
86
|
+
// Something picked meanwhile (shown from the device before the connection) stays.
|
|
87
|
+
if (this.current.store || this.current.draft || this.wanted) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
102
90
|
const file = (await this.persisted.load(FILE)) || undefined;
|
|
103
91
|
const open = file && this.workbench.state.sessions.find(session => session.sessionFile === file);
|
|
104
92
|
const reopen = file && !(await this.persisted.load(GROUPED)) && !(await this.persisted.load(chat_protocol_1.REMOVED_CHATS)).includes(file);
|
|
105
|
-
const sessionId = open ? open.sessionId : reopen ? await this.open({ sessionFile: file }).catch(() => undefined) : undefined;
|
|
93
|
+
const sessionId = open ? open.sessionId : reopen ? await this.stores.open({ sessionFile: file }).catch(() => undefined) : undefined;
|
|
106
94
|
if (sessionId) {
|
|
107
95
|
await this.attach(sessionId);
|
|
108
96
|
}
|
|
@@ -136,25 +124,106 @@ let TaChatImpl = class TaChatImpl {
|
|
|
136
124
|
}
|
|
137
125
|
}
|
|
138
126
|
setDraftModel(model) {
|
|
127
|
+
// Of this new conversation only: the next starts on the default model of the settings again.
|
|
139
128
|
if (this.current.draft && this.current.draft.model !== model) {
|
|
140
|
-
this.persisted.set(MODEL, model !== null && model !== void 0 ? model : '');
|
|
141
129
|
this.update({ draft: { ...this.current.draft, model } });
|
|
142
130
|
}
|
|
143
131
|
}
|
|
144
132
|
submit(message, images) {
|
|
133
|
+
const { draft } = this.current;
|
|
134
|
+
if ((draft === null || draft === void 0 ? void 0 : draft.sending) && !draft.sending.failed) {
|
|
135
|
+
// Typed while the conversation opens: it follows the first message, once there is a conversation.
|
|
136
|
+
const next = this.queue.then(async () => {
|
|
137
|
+
var _a, _b;
|
|
138
|
+
var _c;
|
|
139
|
+
const { store, draft } = this.current;
|
|
140
|
+
if (!store) {
|
|
141
|
+
// The conversation did not open: the message goes back in the box.
|
|
142
|
+
throw ((_a = draft === null || draft === void 0 ? void 0 : draft.sending) === null || _a === void 0 ? void 0 : _a.heldAt) && !draft.sending.failed
|
|
143
|
+
? ta_client_1.TaRemoteError.notConnected()
|
|
144
|
+
: new Error((_c = (_b = draft === null || draft === void 0 ? void 0 : draft.sending) === null || _b === void 0 ? void 0 : _b.failed) !== null && _c !== void 0 ? _c : 'The conversation did not open.');
|
|
145
|
+
}
|
|
146
|
+
await store.send(message, { images, streamingBehavior: 'followUp' });
|
|
147
|
+
});
|
|
148
|
+
this.queue = next.catch(() => undefined);
|
|
149
|
+
return next;
|
|
150
|
+
}
|
|
151
|
+
if (draft) {
|
|
152
|
+
// What was sent shows at once, with Ta at work, while the conversation opens.
|
|
153
|
+
this.stopping = false;
|
|
154
|
+
this.update({ draft: { ...draft, sending: { message, images } } });
|
|
155
|
+
}
|
|
156
|
+
return this.openDraft();
|
|
157
|
+
}
|
|
158
|
+
/** Opens the new conversation with its first message (`ChatDraft.sending`). */
|
|
159
|
+
openDraft() {
|
|
145
160
|
const next = this.queue.then(async () => {
|
|
146
|
-
var _a;
|
|
147
161
|
const { draft } = this.current;
|
|
148
|
-
if (!draft) {
|
|
162
|
+
if (!(draft === null || draft === void 0 ? void 0 : draft.sending)) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const { message, images } = draft.sending;
|
|
166
|
+
let sessionId;
|
|
167
|
+
try {
|
|
168
|
+
sessionId = await this.stores.open({ cwd: draft.cwd, model: draft.model });
|
|
169
|
+
// Sent with the attach, not after it: one round trip less before Ta starts. A failure to send
|
|
170
|
+
// stays on the message in the conversation.
|
|
171
|
+
await this.attach(sessionId, store => store.send(message, { images }));
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
// No conversation: the message stays, marked, to send again; for a lost connection, once it is back.
|
|
175
|
+
const failed = this.current.draft;
|
|
176
|
+
if ((failed === null || failed === void 0 ? void 0 : failed.sending) && !(chat_util_1.ChatUtil.lost(error) && this.holdDraft(failed.sending))) {
|
|
177
|
+
this.update({ draft: { ...failed, sending: { ...failed.sending, failed: chat_util_1.ChatUtil.message(error) } } });
|
|
178
|
+
}
|
|
149
179
|
return;
|
|
150
180
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
181
|
+
if (this.stopping) {
|
|
182
|
+
this.stopping = false;
|
|
183
|
+
await this.workbench.server.abort(sessionId).catch(error => void this.notices.error(error));
|
|
184
|
+
}
|
|
154
185
|
});
|
|
155
186
|
this.queue = next.catch(() => undefined);
|
|
156
187
|
return next;
|
|
157
188
|
}
|
|
189
|
+
/** Keeps the first message on its way while the connection is lost, and opens it once it is back; false past HOLD_MS. */
|
|
190
|
+
holdDraft(sending) {
|
|
191
|
+
var _a;
|
|
192
|
+
const heldAt = (_a = sending.heldAt) !== null && _a !== void 0 ? _a : Date.now();
|
|
193
|
+
const draft = this.current.draft;
|
|
194
|
+
if (!draft || Date.now() - heldAt >= ta_client_1.HOLD_MS) {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
const held = { ...sending, heldAt };
|
|
198
|
+
this.update({ draft: { ...draft, sending: held } });
|
|
199
|
+
const still = () => { var _a; return ((_a = this.current.draft) === null || _a === void 0 ? void 0 : _a.sending) === held; };
|
|
200
|
+
setTimeout(() => {
|
|
201
|
+
const now = this.current.draft;
|
|
202
|
+
if (now && still()) {
|
|
203
|
+
this.update({ draft: { ...now, sending: { ...held, failed: ta_client_1.TaRemoteError.NOT_CONNECTED } } });
|
|
204
|
+
}
|
|
205
|
+
}, heldAt + ta_client_1.HOLD_MS - Date.now());
|
|
206
|
+
void this.workbench.connected().then(() => (still() ? this.openDraft() : undefined), () => undefined);
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
resendDraft() {
|
|
210
|
+
var _a;
|
|
211
|
+
const sending = (_a = this.current.draft) === null || _a === void 0 ? void 0 : _a.sending;
|
|
212
|
+
return (sending === null || sending === void 0 ? void 0 : sending.failed) ? this.submit(sending.message, sending.images) : Promise.resolve();
|
|
213
|
+
}
|
|
214
|
+
discardDraft() {
|
|
215
|
+
var _a;
|
|
216
|
+
const { draft } = this.current;
|
|
217
|
+
if ((_a = draft === null || draft === void 0 ? void 0 : draft.sending) === null || _a === void 0 ? void 0 : _a.failed) {
|
|
218
|
+
this.update({ draft: { ...draft, sending: undefined } });
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
stopDraft() {
|
|
222
|
+
var _a;
|
|
223
|
+
if ((_a = this.current.draft) === null || _a === void 0 ? void 0 : _a.sending) {
|
|
224
|
+
this.stopping = true;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
158
227
|
show(session, opening) {
|
|
159
228
|
var _a;
|
|
160
229
|
if (typeof session !== 'string') {
|
|
@@ -165,18 +234,22 @@ let TaChatImpl = class TaChatImpl {
|
|
|
165
234
|
const switching = ((_a = this.current.store) === null || _a === void 0 ? void 0 : _a.sessionId) !== sessionId;
|
|
166
235
|
if (switching) {
|
|
167
236
|
this.update({ pending: sessionId, opening });
|
|
237
|
+
void this.showKept(sessionId, opening === null || opening === void 0 ? void 0 : opening.sessionFile);
|
|
168
238
|
}
|
|
169
239
|
return this.enqueue(async () => {
|
|
170
|
-
var _a;
|
|
171
240
|
// Picked in the lists of the last time, before the connection: it opens once there is one.
|
|
172
241
|
await this.workbench.connected();
|
|
173
242
|
if (switching) {
|
|
174
243
|
// The list marks it and the conversation's place says it opens before the conversation is drawn.
|
|
175
244
|
await frame_1.FrameUtil.painted();
|
|
176
245
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
246
|
+
const wanted = () => this.wanted === sessionId;
|
|
247
|
+
await chat_util_1.ChatUtil.untilConnected(async () => {
|
|
248
|
+
const { store } = this.current;
|
|
249
|
+
if (wanted() && ((store === null || store === void 0 ? void 0 : store.sessionId) !== sessionId || !this.stores.isAttached(store))) {
|
|
250
|
+
await this.attach(sessionId, undefined, opening === null || opening === void 0 ? void 0 : opening.sessionFile).catch(error => this.reopenClosed(sessionId, error));
|
|
251
|
+
}
|
|
252
|
+
}, () => this.workbench.connected(), wanted);
|
|
180
253
|
}).finally(() => {
|
|
181
254
|
if (this.current.pending === sessionId) {
|
|
182
255
|
this.update({ pending: undefined, opening: undefined });
|
|
@@ -188,6 +261,9 @@ let TaChatImpl = class TaChatImpl {
|
|
|
188
261
|
const key = `coming ${++this.coming}`;
|
|
189
262
|
this.wanted = key;
|
|
190
263
|
this.update({ pending: key, opening });
|
|
264
|
+
if (opening === null || opening === void 0 ? void 0 : opening.sessionFile) {
|
|
265
|
+
void this.showKept(key, opening.sessionFile);
|
|
266
|
+
}
|
|
191
267
|
try {
|
|
192
268
|
const sessionId = await session;
|
|
193
269
|
if (this.wanted === key) {
|
|
@@ -204,17 +280,21 @@ let TaChatImpl = class TaChatImpl {
|
|
|
204
280
|
this.wanted = sessionFile;
|
|
205
281
|
this.restore(sessionFile);
|
|
206
282
|
// The list marks it at once by its file, the key of a saved conversation.
|
|
207
|
-
this.
|
|
283
|
+
const saved = this.workbench.state.saved.find(session => session.sessionFile === sessionFile);
|
|
284
|
+
this.update({ pending: sessionFile, opening: saved && { title: saved.sessionName, cwd: saved.cwd, sessionFile } });
|
|
285
|
+
void this.showKept(sessionFile, sessionFile);
|
|
208
286
|
return this.enqueue(async () => {
|
|
209
|
-
var _a;
|
|
210
287
|
await this.workbench.connected();
|
|
211
288
|
await frame_1.FrameUtil.painted();
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
289
|
+
const wanted = () => this.wanted === sessionFile;
|
|
290
|
+
await chat_util_1.ChatUtil.untilConnected(async () => {
|
|
291
|
+
const open = this.stores.openOf(sessionFile);
|
|
292
|
+
const { store } = this.current;
|
|
293
|
+
if (!wanted() || (open && (store === null || store === void 0 ? void 0 : store.sessionId) === open.sessionId && this.stores.isAttached(store))) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
await this.attach(open ? open.sessionId : await this.stores.open({ sessionFile, cwd: saved === null || saved === void 0 ? void 0 : saved.cwd }), undefined, sessionFile);
|
|
297
|
+
}, () => this.workbench.connected(), wanted);
|
|
218
298
|
}).finally(() => {
|
|
219
299
|
if (this.current.pending === sessionFile) {
|
|
220
300
|
this.update({ pending: undefined, opening: undefined });
|
|
@@ -238,8 +318,8 @@ let TaChatImpl = class TaChatImpl {
|
|
|
238
318
|
}
|
|
239
319
|
}
|
|
240
320
|
async openBeside(options) {
|
|
241
|
-
const sessionId = await this.open(options);
|
|
242
|
-
const store = this.
|
|
321
|
+
const sessionId = await this.stores.open(options);
|
|
322
|
+
const store = this.stores.create(sessionId);
|
|
243
323
|
await store.attach();
|
|
244
324
|
await this.workbench.refresh();
|
|
245
325
|
return store;
|
|
@@ -250,8 +330,8 @@ let TaChatImpl = class TaChatImpl {
|
|
|
250
330
|
var _a;
|
|
251
331
|
await this.workbench.connected();
|
|
252
332
|
await this.workbench.server.closeSession(sessionId);
|
|
253
|
-
this.
|
|
254
|
-
this.recent.drop(sessionId);
|
|
333
|
+
this.stores.closed(sessionId);
|
|
334
|
+
this.stores.recent.drop(sessionId);
|
|
255
335
|
if (((_a = this.current.store) === null || _a === void 0 ? void 0 : _a.sessionId) === sessionId) {
|
|
256
336
|
await this.replace();
|
|
257
337
|
}
|
|
@@ -262,52 +342,70 @@ let TaChatImpl = class TaChatImpl {
|
|
|
262
342
|
}
|
|
263
343
|
enqueue(change) {
|
|
264
344
|
// With a conversation shown, a failure is a notice; with none, the page says it in its place.
|
|
265
|
-
const next = this.queue
|
|
266
|
-
|
|
267
|
-
|
|
345
|
+
const next = this.queue.then(change).catch(error =>
|
|
346
|
+
// A lost connection is no failure: the row of the connection says it, and what was asked goes on once it is back.
|
|
347
|
+
chat_util_1.ChatUtil.lost(error)
|
|
348
|
+
? undefined
|
|
349
|
+
: this.current.store || this.current.draft
|
|
350
|
+
? void this.notices.error(error)
|
|
351
|
+
: this.update({ error: chat_util_1.ChatUtil.message(error) }));
|
|
268
352
|
this.queue = next;
|
|
269
353
|
return next;
|
|
270
354
|
}
|
|
271
|
-
/** Opens a session with the tools of the web extensions of now. */
|
|
272
|
-
async open(options) {
|
|
273
|
-
var _a, _b;
|
|
274
|
-
const tools = this.extensions.state.tools;
|
|
275
|
-
const { sessionId } = await this.workbench.server.openSession({
|
|
276
|
-
...options,
|
|
277
|
-
cwd: ((_a = options.cwd) === null || _a === void 0 ? void 0 : _a.trim()) || ((_b = this.workbench.state.server) === null || _b === void 0 ? void 0 : _b.cwd) || '.',
|
|
278
|
-
clientTools: tools.map(({ name, description, parameters }) => ({ name, description, parameters })),
|
|
279
|
-
});
|
|
280
|
-
this.opened.set(sessionId, ChatUtil.toolNames(tools));
|
|
281
|
-
return sessionId;
|
|
282
|
-
}
|
|
283
355
|
/**
|
|
284
356
|
* Follows a session, running the web tools it asks for. One shown lately and still open shows at once
|
|
285
|
-
* as it was, and catches up as it attaches again
|
|
286
|
-
*
|
|
357
|
+
* as it was, and catches up as it attaches again; so does one this device kept (its file: `sessionFile`,
|
|
358
|
+
* else the list's). Another shows once loaded, the conversation shown staying until then, so that
|
|
359
|
+
* switching does not flash an empty page.
|
|
287
360
|
*/
|
|
288
|
-
async attach(sessionId) {
|
|
289
|
-
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
361
|
+
async attach(sessionId, send, sessionFile) {
|
|
362
|
+
var _a;
|
|
363
|
+
const tools = this.stores.toolNames();
|
|
364
|
+
const shown = this.current.store;
|
|
365
|
+
// Shown already, from the device before the connection: attached now, as it is.
|
|
366
|
+
const early = (shown === null || shown === void 0 ? void 0 : shown.sessionId) === sessionId && !this.stores.isAttached(shown) && this.stores.toolsOf(shown) === tools ? shown : undefined;
|
|
367
|
+
const kept = early !== null && early !== void 0 ? early : this.stores.recent.take(sessionId, tools);
|
|
368
|
+
if (kept && this.stores.listed(sessionId)) {
|
|
369
|
+
if (!early) {
|
|
370
|
+
this.enter(kept);
|
|
371
|
+
}
|
|
293
372
|
try {
|
|
294
|
-
|
|
373
|
+
const attaching = kept.attach();
|
|
374
|
+
const sending = send === null || send === void 0 ? void 0 : send(kept);
|
|
375
|
+
sending === null || sending === void 0 ? void 0 : sending.catch(() => undefined);
|
|
376
|
+
await attaching;
|
|
377
|
+
this.stores.setAttached(kept);
|
|
295
378
|
if (this.current.store === kept) {
|
|
296
379
|
this.listen(kept);
|
|
297
380
|
}
|
|
381
|
+
await sending;
|
|
298
382
|
return;
|
|
299
383
|
}
|
|
300
|
-
catch (
|
|
384
|
+
catch (_b) {
|
|
301
385
|
// Closed meanwhile: loaded as any other, which fails as it does.
|
|
302
386
|
this.leave(false);
|
|
303
387
|
}
|
|
304
388
|
}
|
|
305
|
-
const
|
|
306
|
-
this.
|
|
389
|
+
const file = sessionFile !== null && sessionFile !== void 0 ? sessionFile : this.stores.fileOf(sessionId);
|
|
390
|
+
const initial = (_a = early === null || early === void 0 ? void 0 : early.state) !== null && _a !== void 0 ? _a : (await this.stores.read(file));
|
|
391
|
+
const store = this.stores.create(sessionId, initial);
|
|
392
|
+
const before = this.current.store;
|
|
393
|
+
if (before && this.stores.standsFor(before, file)) {
|
|
394
|
+
// Shown from the device under another key (a saved one, an agent's on its way): what failed to go there stays.
|
|
395
|
+
store.carry(before);
|
|
396
|
+
}
|
|
397
|
+
if (initial) {
|
|
398
|
+
// As this device saw it, at once.
|
|
399
|
+
this.enter(store);
|
|
400
|
+
}
|
|
401
|
+
const attaching = store.attach();
|
|
402
|
+
// Behind the attach on the same connection: the service has the session followed when it runs.
|
|
403
|
+
const sending = send === null || send === void 0 ? void 0 : send(store);
|
|
404
|
+
sending === null || sending === void 0 ? void 0 : sending.catch(() => undefined);
|
|
307
405
|
try {
|
|
308
|
-
await
|
|
406
|
+
await attaching;
|
|
309
407
|
// A session opened since (an agent's) is not listed yet: web extensions get the directory of this one.
|
|
310
|
-
if (!this.listed(sessionId)) {
|
|
408
|
+
if (!this.stores.listed(sessionId)) {
|
|
311
409
|
await this.workbench.refresh();
|
|
312
410
|
}
|
|
313
411
|
}
|
|
@@ -315,28 +413,34 @@ let TaChatImpl = class TaChatImpl {
|
|
|
315
413
|
store.detach().catch(() => undefined);
|
|
316
414
|
throw error;
|
|
317
415
|
}
|
|
318
|
-
this.
|
|
416
|
+
this.stores.setAttached(store);
|
|
417
|
+
if (!initial) {
|
|
418
|
+
this.enter(store);
|
|
419
|
+
}
|
|
319
420
|
this.listen(store);
|
|
421
|
+
await sending;
|
|
320
422
|
}
|
|
321
|
-
|
|
322
|
-
|
|
423
|
+
/**
|
|
424
|
+
* Before the connection, the conversation picked as this device kept it, under `key` (what is pending):
|
|
425
|
+
* one shown lately, else the one of its file. It attaches once connected (`attach`); online, `attach` shows it.
|
|
426
|
+
*/
|
|
427
|
+
async showKept(key, sessionFile) {
|
|
428
|
+
var _a;
|
|
429
|
+
const offline = () => this.workbench.state.status !== 'online';
|
|
430
|
+
const store = offline() ? await this.stores.shown(key, sessionFile) : undefined;
|
|
431
|
+
if (store && this.wanted === key && ((_a = this.current.store) === null || _a === void 0 ? void 0 : _a.sessionId) !== key && offline()) {
|
|
432
|
+
this.enter(store);
|
|
433
|
+
}
|
|
323
434
|
}
|
|
324
435
|
/** Shows a store in place of the one shown, which is kept for later. */
|
|
325
436
|
enter(store) {
|
|
326
437
|
this.leave();
|
|
327
|
-
this.
|
|
328
|
-
for (const id of Object.keys(store.state.tools)) {
|
|
329
|
-
this.seenEdits.add(id);
|
|
330
|
-
}
|
|
438
|
+
this.packages.saw(store, true);
|
|
331
439
|
this.follow(store);
|
|
332
440
|
this.remember(this.workbench.state.sessions.find(session => session.sessionId === store.sessionId));
|
|
333
441
|
// How the sessions are now (running, last change), without holding up the conversation.
|
|
334
442
|
this.workbench.refresh().catch(() => undefined);
|
|
335
443
|
}
|
|
336
|
-
/** The open session of a file. */
|
|
337
|
-
openOf(sessionFile) {
|
|
338
|
-
return this.workbench.state.sessions.find(session => session.sessionFile === sessionFile);
|
|
339
|
-
}
|
|
340
444
|
/**
|
|
341
445
|
* A session of the list that the service closed since the list was read (idle, or a restart): opened
|
|
342
446
|
* again from its file. One of a package's group is left to its package, which opens it with its role.
|
|
@@ -347,16 +451,16 @@ let TaChatImpl = class TaChatImpl {
|
|
|
347
451
|
await this.workbench.refresh().catch(() => undefined);
|
|
348
452
|
throw error;
|
|
349
453
|
}
|
|
350
|
-
await this.attach(await this.open({ sessionFile: info.sessionFile, cwd: info.cwd }));
|
|
454
|
+
await this.attach(await this.stores.open({ sessionFile: info.sessionFile, cwd: info.cwd }), undefined, info.sessionFile);
|
|
351
455
|
}
|
|
352
456
|
/** The conversation shown, opened again from its file; the newest other one if that fails. */
|
|
353
457
|
async recover() {
|
|
354
458
|
const gone = this.current.store;
|
|
355
459
|
try {
|
|
356
460
|
const file = this.persisted.get(FILE);
|
|
357
|
-
const sessionId = file ? await this.open({ sessionFile: file }).catch(() => undefined) : undefined;
|
|
461
|
+
const sessionId = file ? await this.stores.open({ sessionFile: file }).catch(() => undefined) : undefined;
|
|
358
462
|
if (sessionId) {
|
|
359
|
-
await this.attach(sessionId);
|
|
463
|
+
await this.attach(sessionId, undefined, file);
|
|
360
464
|
}
|
|
361
465
|
else {
|
|
362
466
|
await this.replace();
|
|
@@ -364,7 +468,7 @@ let TaChatImpl = class TaChatImpl {
|
|
|
364
468
|
}
|
|
365
469
|
finally {
|
|
366
470
|
if (gone) {
|
|
367
|
-
this.recent.drop(gone.sessionId);
|
|
471
|
+
this.stores.recent.drop(gone.sessionId);
|
|
368
472
|
}
|
|
369
473
|
}
|
|
370
474
|
}
|
|
@@ -383,25 +487,9 @@ let TaChatImpl = class TaChatImpl {
|
|
|
383
487
|
showDraft() {
|
|
384
488
|
var _a;
|
|
385
489
|
const cwd = ((_a = this.workbench.state.server) === null || _a === void 0 ? void 0 : _a.cwd) || '';
|
|
386
|
-
this.update({ draft: { cwd
|
|
490
|
+
this.update({ draft: { cwd }, error: undefined });
|
|
387
491
|
this.extensions.connect(cwd ? { cwd } : undefined);
|
|
388
492
|
}
|
|
389
|
-
/** Runs the web tool of the name that is loaded when the model calls it: a changed one runs as it is now. */
|
|
390
|
-
clientTool(name) {
|
|
391
|
-
var _a;
|
|
392
|
-
const tool = () => this.extensions.state.tools.find(candidate => candidate.name === name);
|
|
393
|
-
const { description = '', parameters = {} } = (_a = tool()) !== null && _a !== void 0 ? _a : {};
|
|
394
|
-
return {
|
|
395
|
-
definition: { name, description, parameters },
|
|
396
|
-
run: async (input, request) => {
|
|
397
|
-
const current = tool();
|
|
398
|
-
if (!current) {
|
|
399
|
-
throw new Error(`The web extension of the tool ${name} is no longer loaded.`);
|
|
400
|
-
}
|
|
401
|
-
return current.execute(request.id, (input !== null && input !== void 0 ? input : {}));
|
|
402
|
-
},
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
493
|
follow(store) {
|
|
406
494
|
var _a;
|
|
407
495
|
let working = store.state.working;
|
|
@@ -412,7 +500,7 @@ let TaChatImpl = class TaChatImpl {
|
|
|
412
500
|
void this.enqueue(() => (this.current.store === store ? this.replace() : Promise.resolve()));
|
|
413
501
|
}
|
|
414
502
|
else if (working && !state.working) {
|
|
415
|
-
void this.settled(store);
|
|
503
|
+
void this.packages.settled(store);
|
|
416
504
|
}
|
|
417
505
|
working = state.working;
|
|
418
506
|
}),
|
|
@@ -423,7 +511,7 @@ let TaChatImpl = class TaChatImpl {
|
|
|
423
511
|
send: text => store.prompt(text, { streamingBehavior: 'followUp' }).then(() => undefined),
|
|
424
512
|
cwd: (_a = this.workbench.state.sessions.find(session => session.sessionId === store.sessionId)) === null || _a === void 0 ? void 0 : _a.cwd,
|
|
425
513
|
sessionId: store.sessionId,
|
|
426
|
-
reload: () => this.
|
|
514
|
+
reload: () => this.packages.reload(store),
|
|
427
515
|
});
|
|
428
516
|
this.update({ store, draft: undefined, error: undefined });
|
|
429
517
|
}
|
|
@@ -432,10 +520,10 @@ let TaChatImpl = class TaChatImpl {
|
|
|
432
520
|
* happened while another conversation was shown.
|
|
433
521
|
*/
|
|
434
522
|
listen(store) {
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
this.
|
|
523
|
+
this.packages.saw(store);
|
|
524
|
+
this.unfollow.push(store.onEvent(event => this.onEvent(event)),
|
|
525
|
+
// On the device as it changes, to show again without the computer.
|
|
526
|
+
this.kept.follow(store, () => this.stores.fileOf(store.sessionId)));
|
|
439
527
|
}
|
|
440
528
|
/** Stops following the conversation shown; it is kept to show again unless `keep` is false (it closed, or is gone). */
|
|
441
529
|
leave(keep = true) {
|
|
@@ -445,10 +533,11 @@ let TaChatImpl = class TaChatImpl {
|
|
|
445
533
|
}
|
|
446
534
|
this.extensions.connect(undefined);
|
|
447
535
|
const { store } = this.current;
|
|
448
|
-
|
|
536
|
+
// One not attached (shown from the device) has nothing to detach, and the device keeps it.
|
|
537
|
+
if (store && this.stores.setDetached(store)) {
|
|
449
538
|
store.detach().catch(() => undefined);
|
|
450
539
|
if (keep && !store.state.closed) {
|
|
451
|
-
this.recent.keep(store, (_a = this.toolsOf
|
|
540
|
+
this.stores.recent.keep(store, (_a = this.stores.toolsOf(store)) !== null && _a !== void 0 ? _a : '');
|
|
452
541
|
}
|
|
453
542
|
}
|
|
454
543
|
this.update({ store: undefined });
|
|
@@ -459,48 +548,6 @@ let TaChatImpl = class TaChatImpl {
|
|
|
459
548
|
}
|
|
460
549
|
this.extensions.emit(event);
|
|
461
550
|
}
|
|
462
|
-
/**
|
|
463
|
-
* A run ended, in which ta may have made or changed a package. The web extensions load again. New or
|
|
464
|
-
* removed web tools need the conversation opened again with them; a changed package needs its pi
|
|
465
|
-
* extensions loaded again. A new run in the meantime puts both off to its end.
|
|
466
|
-
*/
|
|
467
|
-
settled(store) {
|
|
468
|
-
return this.enqueue(async () => {
|
|
469
|
-
const changed = await this.extensions.refresh();
|
|
470
|
-
const edits = ChatUtil.packageEdits(store.state, this.seenEdits);
|
|
471
|
-
for (const id of edits) {
|
|
472
|
-
this.seenEdits.add(id);
|
|
473
|
-
}
|
|
474
|
-
if (store !== this.current.store || store.state.working) {
|
|
475
|
-
return;
|
|
476
|
-
}
|
|
477
|
-
const pending = this.reloadPending;
|
|
478
|
-
this.reloadPending = false;
|
|
479
|
-
await this.loadPackages(store, changed || edits.length > 0 || pending);
|
|
480
|
-
});
|
|
481
|
-
}
|
|
482
|
-
/** A web extension changed packages (reloadExtensions): as at the end of a run, or at the end of the one under way. */
|
|
483
|
-
reloadPackages(store) {
|
|
484
|
-
return this.enqueue(async () => {
|
|
485
|
-
if (store !== this.current.store) {
|
|
486
|
-
return;
|
|
487
|
-
}
|
|
488
|
-
if (store.state.working) {
|
|
489
|
-
this.reloadPending = true;
|
|
490
|
-
return;
|
|
491
|
-
}
|
|
492
|
-
await this.loadPackages(store, true);
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
async loadPackages(store, changed) {
|
|
496
|
-
const tools = this.opened.get(store.sessionId);
|
|
497
|
-
if (tools !== undefined && tools !== ChatUtil.toolNames(this.extensions.state.tools)) {
|
|
498
|
-
await this.reopen(store);
|
|
499
|
-
}
|
|
500
|
-
else if (changed) {
|
|
501
|
-
await this.workbench.server.reload(store.sessionId);
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
551
|
/** The same conversation, from its file, with the tools of now. */
|
|
505
552
|
async reopen(store) {
|
|
506
553
|
var _a;
|
|
@@ -508,8 +555,8 @@ let TaChatImpl = class TaChatImpl {
|
|
|
508
555
|
const cwd = (_a = this.workbench.state.sessions.find(session => session.sessionId === store.sessionId)) === null || _a === void 0 ? void 0 : _a.cwd;
|
|
509
556
|
this.leave(false);
|
|
510
557
|
await this.workbench.server.closeSession(store.sessionId);
|
|
511
|
-
this.
|
|
512
|
-
await this.attach(await this.open({ sessionFile, cwd }));
|
|
558
|
+
this.stores.closed(store.sessionId);
|
|
559
|
+
await this.attach(await this.stores.open({ sessionFile, cwd }), undefined, sessionFile);
|
|
513
560
|
}
|
|
514
561
|
remember(info) {
|
|
515
562
|
if (info === null || info === void 0 ? void 0 : info.sessionFile) {
|
|
@@ -541,6 +588,10 @@ __decorate([
|
|
|
541
588
|
(0, core_1.Autowired)(state_protocol_1.TaState),
|
|
542
589
|
__metadata("design:type", Object)
|
|
543
590
|
], TaChatImpl.prototype, "persisted", void 0);
|
|
591
|
+
__decorate([
|
|
592
|
+
(0, core_1.Autowired)(kept_chats_protocol_1.TaKeptChats),
|
|
593
|
+
__metadata("design:type", Object)
|
|
594
|
+
], TaChatImpl.prototype, "kept", void 0);
|
|
544
595
|
exports.TaChatImpl = TaChatImpl = __decorate([
|
|
545
596
|
(0, core_1.Component)(chat_protocol_1.TaChat)
|
|
546
597
|
], TaChatImpl);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type WebViewEntry } from '../extension/web-extension-protocol';
|
|
3
|
-
import { type Navigation } from './nav-places';
|
|
3
|
+
import { type EntryHolds, type Navigation } from './nav-places';
|
|
4
4
|
import type { PhoneSurface } from './phone-shell';
|
|
5
5
|
import type { SettingsSection } from './settings-view';
|
|
6
6
|
import type { SideList } from './side-lists';
|
|
@@ -27,12 +27,15 @@ export interface RailProps {
|
|
|
27
27
|
/** The one open in its flyout. */
|
|
28
28
|
surface?: PhoneSurface;
|
|
29
29
|
onSurface(surface: PhoneSurface | undefined): void;
|
|
30
|
+
/** What a held entry does: the double listens, the chats open a new one (entryHold). */
|
|
31
|
+
holds: EntryHolds;
|
|
30
32
|
}
|
|
31
33
|
/**
|
|
32
34
|
* The navigation on the left, as the tabs of a phone: the logo; the lists of the sidebar; the pages, and Discover
|
|
33
|
-
* once some are under it; the account with the settings at the bottom. A page's menu (a right click) puts it under
|
|
35
|
+
* once some are under it; the account with the settings at the bottom. A page's menu (a right click) puts it under
|
|
36
|
+
* Discover; that of the double talks to it, and that of the chats opens a new one (entryMenu).
|
|
34
37
|
*/
|
|
35
|
-
export declare function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface }: RailProps): React.JSX.Element;
|
|
38
|
+
export declare function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, }: RailProps): React.JSX.Element;
|
|
36
39
|
/** A sidebar view of a web extension, under its title or its own top bar. */
|
|
37
40
|
export declare function SidebarView({ view }: {
|
|
38
41
|
view: WebViewEntry;
|