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