@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,7 +8,9 @@ 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 { TaRemoteError } from '@celljs/ta-client';
11
12
  import { TaErrorCode, TaErrorUtil } from '@celljs/ta-protocol';
13
+ import { TaKeptChats } from '../offline/kept-chats-protocol.js';
12
14
  import { SettingsUtil, TaSettings } from '../settings/settings-protocol.js';
13
15
  import { TaState } from '../state/state-protocol.js';
14
16
  import { TaWorkbench } from '../workbench-protocol.js';
@@ -59,6 +61,11 @@ let TaAssistantImpl = class TaAssistantImpl {
59
61
  (_a = this.unwatchSettings) !== null && _a !== void 0 ? _a : (this.unwatchSettings = this.settings.subscribe(state => this.settingsChanged(state.settings)));
60
62
  (_b = this.starting) !== null && _b !== void 0 ? _b : (this.starting = this.open().catch(error => {
61
63
  this.starting = undefined;
64
+ if (TaRemoteError.isConnectionLost(error)) {
65
+ // No failure to show: it wakes once the connection is back (a moment after, not in a loop).
66
+ setTimeout(() => void this.workbench.connected().then(() => (this.starting || this.assistant ? undefined : this.start()), () => undefined), 1000);
67
+ return;
68
+ }
62
69
  this.update({ error: error instanceof Error ? error.message : String(error) });
63
70
  }));
64
71
  return this.starting;
@@ -69,7 +76,17 @@ let TaAssistantImpl = class TaAssistantImpl {
69
76
  }
70
77
  }
71
78
  store() {
72
- return this.assistant;
79
+ var _a;
80
+ return (_a = this.assistant) !== null && _a !== void 0 ? _a : this.preview;
81
+ }
82
+ async showKept() {
83
+ const file = this.assistant || this.preview ? undefined : await this.persisted.load(FILE);
84
+ const initial = file ? await this.kept.read(file).catch(() => undefined) : undefined;
85
+ if (initial && !this.assistant && !this.preview) {
86
+ // Under its file: it is of no session until the conversation opens, which takes over what it shows.
87
+ this.preview = this.workbench.createStore(file, { initial });
88
+ this.update({});
89
+ }
73
90
  }
74
91
  async loadTasks() {
75
92
  this.watchTasks();
@@ -151,6 +168,9 @@ let TaAssistantImpl = class TaAssistantImpl {
151
168
  // Opening (again, after a reconnect found it gone): sent once it is open.
152
169
  await this.starting;
153
170
  const store = this.assistant;
171
+ if (!store && this.workbench.state.status !== 'online') {
172
+ throw TaRemoteError.notConnected();
173
+ }
154
174
  if (!store) {
155
175
  throw new Error('Ta is not ready yet.');
156
176
  }
@@ -302,6 +322,18 @@ let TaAssistantImpl = class TaAssistantImpl {
302
322
  this.persisted.set(FILE, sessionFile);
303
323
  }
304
324
  }
325
+ /** Keeps the conversation on the device as it changes, under its file of the time (`restart` gives it another). */
326
+ keep(store) {
327
+ var _a;
328
+ (_a = this.unkeep) === null || _a === void 0 ? void 0 : _a.call(this);
329
+ let file = this.sessionFile;
330
+ this.unkeep = this.kept.follow(store, () => {
331
+ if (this.assistant === store) {
332
+ file = this.sessionFile;
333
+ }
334
+ return file;
335
+ });
336
+ }
305
337
  /** The role of ta, whether it asks first, and what the user added to it. */
306
338
  systemPrompt() {
307
339
  return assistantRole(this.settings.state.settings.confirmTasks, this.prompt);
@@ -334,8 +366,8 @@ let TaAssistantImpl = class TaAssistantImpl {
334
366
  * trip to ta serve, which over a relay or a phone's network takes long.
335
367
  */
336
368
  async open() {
337
- var _a;
338
- var _b;
369
+ var _a, _b;
370
+ var _c;
339
371
  this.watchTasks();
340
372
  const clientTools = this.clientTools();
341
373
  const [tasks, file, wasAsking, sessions] = await Promise.all([
@@ -360,7 +392,7 @@ let TaAssistantImpl = class TaAssistantImpl {
360
392
  if (!info) {
361
393
  this.persisted.set(ASKING, asking);
362
394
  const options = {
363
- cwd: (_b = (_a = this.workbench.state.server) === null || _a === void 0 ? void 0 : _a.cwd) !== null && _b !== void 0 ? _b : '.',
395
+ cwd: (_c = (_a = this.workbench.state.server) === null || _a === void 0 ? void 0 : _a.cwd) !== null && _c !== void 0 ? _c : '.',
364
396
  appendSystemPrompt: this.systemPrompt(),
365
397
  clientTools: clientTools.map(tool => tool.definition),
366
398
  };
@@ -378,7 +410,8 @@ let TaAssistantImpl = class TaAssistantImpl {
378
410
  }
379
411
  const { sessionId } = info;
380
412
  this.cwd = info.cwd;
381
- const store = this.workbench.createStore(sessionId, { clientTools });
413
+ // What the device kept shows on: the messages that are the same keep their objects.
414
+ const store = this.workbench.createStore(sessionId, { clientTools, initial: (_b = this.preview) === null || _b === void 0 ? void 0 : _b.state });
382
415
  await Promise.all([named ? this.server.setSessionName(sessionId, 'Ta') : undefined, this.applyModel(sessionId, info.model), store.attach()]);
383
416
  store.onGone(() => void this.recover(store));
384
417
  store.subscribe(state => {
@@ -387,6 +420,8 @@ let TaAssistantImpl = class TaAssistantImpl {
387
420
  }
388
421
  });
389
422
  this.assistant = store;
423
+ this.preview = undefined;
424
+ this.keep(store);
390
425
  this.update({ ready: true, error: undefined });
391
426
  this.flushNotes();
392
427
  await this.followRunning(sessions);
@@ -597,6 +632,10 @@ __decorate([
597
632
  Autowired(TaSettings),
598
633
  __metadata("design:type", Object)
599
634
  ], TaAssistantImpl.prototype, "settings", void 0);
635
+ __decorate([
636
+ Autowired(TaKeptChats),
637
+ __metadata("design:type", Object)
638
+ ], TaAssistantImpl.prototype, "kept", void 0);
600
639
  TaAssistantImpl = __decorate([
601
640
  Component(TaAssistant)
602
641
  ], TaAssistantImpl);
@@ -0,0 +1,39 @@
1
+ import type { SessionStore } from '@celljs/ta-client';
2
+ import type { TaWebExtensions } from '../extension/web-extension-protocol.js';
3
+ import type { TaWorkbench } from '../workbench-protocol.js';
4
+ import type { ChatStores } from './chat-stores.js';
5
+ /** What ChatPackages needs of the conversation shown (TaChat). */
6
+ export interface PackagesHost {
7
+ shown(): SessionStore | undefined;
8
+ /** One change of the conversation shown at a time. */
9
+ enqueue(change: () => Promise<void>): Promise<void>;
10
+ /** The same conversation, from its file, with the tools of now. */
11
+ reopen(store: SessionStore): Promise<void>;
12
+ }
13
+ /**
14
+ * The packages of the conversation shown, after a run in which ta may have made or changed one: the web
15
+ * extensions load again; new or removed web tools open the conversation again with them; a changed package
16
+ * has its pi extensions loaded again. A new run in the meantime puts both off to its end.
17
+ */
18
+ export declare class ChatPackages {
19
+ protected readonly extensions: TaWebExtensions;
20
+ protected readonly workbench: TaWorkbench;
21
+ protected readonly stores: ChatStores;
22
+ protected readonly host: PackagesHost;
23
+ /** The runs of tools of the conversation shown, seen before: only those after are its edits. */
24
+ protected readonly seen: Set<string>;
25
+ /** A web extension changed packages during a run: its end loads them again. */
26
+ protected pending: boolean;
27
+ constructor(extensions: TaWebExtensions, workbench: TaWorkbench, stores: ChatStores, host: PackagesHost);
28
+ /** The runs of a store so far are not edits of a run to come; `fresh`: a store shown in place of another. */
29
+ saw(store: SessionStore, fresh?: boolean): void;
30
+ /**
31
+ * A run ended, in which ta may have made or changed a package. The web extensions load again. New or
32
+ * removed web tools need the conversation opened again with them; a changed package needs its pi
33
+ * extensions loaded again. A new run in the meantime puts both off to its end.
34
+ */
35
+ settled(store: SessionStore): Promise<void>;
36
+ /** A web extension changed packages (reloadExtensions): as at the end of a run, or at the end of the one under way. */
37
+ reload(store: SessionStore): Promise<void>;
38
+ protected load(store: SessionStore, changed: boolean): Promise<void>;
39
+ }
@@ -0,0 +1,70 @@
1
+ import { ChatUtil } from './chat-util.js';
2
+ /**
3
+ * The packages of the conversation shown, after a run in which ta may have made or changed one: the web
4
+ * extensions load again; new or removed web tools open the conversation again with them; a changed package
5
+ * has its pi extensions loaded again. A new run in the meantime puts both off to its end.
6
+ */
7
+ export class ChatPackages {
8
+ constructor(extensions, workbench, stores, host) {
9
+ this.extensions = extensions;
10
+ this.workbench = workbench;
11
+ this.stores = stores;
12
+ this.host = host;
13
+ /** The runs of tools of the conversation shown, seen before: only those after are its edits. */
14
+ this.seen = new Set();
15
+ /** A web extension changed packages during a run: its end loads them again. */
16
+ this.pending = false;
17
+ }
18
+ /** The runs of a store so far are not edits of a run to come; `fresh`: a store shown in place of another. */
19
+ saw(store, fresh = false) {
20
+ if (fresh) {
21
+ this.seen.clear();
22
+ }
23
+ for (const id of Object.keys(store.state.tools)) {
24
+ this.seen.add(id);
25
+ }
26
+ }
27
+ /**
28
+ * A run ended, in which ta may have made or changed a package. The web extensions load again. New or
29
+ * removed web tools need the conversation opened again with them; a changed package needs its pi
30
+ * extensions loaded again. A new run in the meantime puts both off to its end.
31
+ */
32
+ settled(store) {
33
+ return this.host.enqueue(ChatUtil.quietly(async () => {
34
+ const changed = await this.extensions.refresh();
35
+ const edits = ChatUtil.packageEdits(store.state, this.seen);
36
+ for (const id of edits) {
37
+ this.seen.add(id);
38
+ }
39
+ if (store !== this.host.shown() || store.state.working) {
40
+ return;
41
+ }
42
+ const pending = this.pending;
43
+ this.pending = false;
44
+ await this.load(store, changed || edits.length > 0 || pending);
45
+ }));
46
+ }
47
+ /** A web extension changed packages (reloadExtensions): as at the end of a run, or at the end of the one under way. */
48
+ reload(store) {
49
+ return this.host.enqueue(async () => {
50
+ if (store !== this.host.shown()) {
51
+ return;
52
+ }
53
+ if (store.state.working) {
54
+ this.pending = true;
55
+ return;
56
+ }
57
+ await this.load(store, true);
58
+ });
59
+ }
60
+ async load(store, changed) {
61
+ const tools = this.stores.openedWith(store.sessionId);
62
+ if (tools !== undefined && tools !== this.stores.toolNames()) {
63
+ await this.host.reopen(store);
64
+ }
65
+ else if (changed) {
66
+ await this.workbench.server.reload(store.sessionId);
67
+ }
68
+ }
69
+ }
70
+ //# sourceMappingURL=chat-packages.js.map
@@ -10,11 +10,23 @@ export interface ChatDraft {
10
10
  cwd: string;
11
11
  /** `<provider>/<model id>` it will start on; none: the default model of the settings. */
12
12
  model?: string;
13
+ /**
14
+ * Its first message, shown at once while its session opens, or `failed` to open it. `heldAt`: when the
15
+ * connection was lost opening it; it opens once the connection is back, and fails only after HOLD_MS.
16
+ */
17
+ sending?: {
18
+ message: string;
19
+ images?: ImageContent[];
20
+ failed?: string;
21
+ heldAt?: number;
22
+ };
13
23
  }
14
24
  /** What a conversation still opening says of itself, before the server has it (TaChat.show of a session on its way). */
15
25
  export interface ChatOpening {
16
26
  title?: string;
17
27
  cwd?: string;
28
+ /** Its file, when known: what this device kept of it shows while it opens, without the computer too. */
29
+ sessionFile?: string;
18
30
  }
19
31
  export interface ChatState {
20
32
  /** The conversation shown, once there is one. */
@@ -49,8 +61,18 @@ export interface TaChat {
49
61
  setDraftCwd(cwd: string): Promise<void>;
50
62
  /** The model the new conversation starts on; none: the default one. */
51
63
  setDraftModel(model: string | undefined): void;
52
- /** Opens the session of the new conversation and sends its first message; fails as the opening fails. */
64
+ /**
65
+ * Opens the session of the new conversation and sends its first message. When that fails the message
66
+ * stays, marked failed (`ChatDraft.sending`), to send again or take back. Another message while it
67
+ * opens follows the first.
68
+ */
53
69
  submit(message: string, images?: ImageContent[]): Promise<void>;
70
+ /** Sends again the first message that failed. */
71
+ resendDraft(): Promise<void>;
72
+ /** Takes back the first message that failed. */
73
+ discardDraft(): void;
74
+ /** Stops the run of the conversation still opening, once it is there. */
75
+ stopDraft(): void;
54
76
  /**
55
77
  * Shows an open session; one the service closed meanwhile opens again from its file. A session still on its
56
78
  * way (a promise of its id) has its place at once, said by `opening`, and shows when it comes; it fails as it fails.
@@ -0,0 +1,59 @@
1
+ import type { ClientTool, SessionSnapshot, SessionStore } from '@celljs/ta-client';
2
+ import type { TaOpenSessionOptions, TaSessionInfo } from '@celljs/ta-protocol';
3
+ import type { TaWebExtensions } from '../extension/web-extension-protocol.js';
4
+ import type { TaKeptChats } from '../offline/kept-chats-protocol.js';
5
+ import type { TaWorkbench } from '../workbench-protocol.js';
6
+ import { RecentStores } from './recent-stores.js';
7
+ /**
8
+ * The sessions and stores of the conversations TaChat shows. Sessions open, and stores are made, with the
9
+ * web tools of now (each kept with their names, to tell when they changed); a store starts
10
+ * from what the device kept of its conversation when it has it, and knows whether it is attached. One that is
11
+ * not shows a conversation as the device kept it, until the connection is there: it is not kept among the
12
+ * recent ones, the device has it.
13
+ */
14
+ export declare class ChatStores {
15
+ protected readonly workbench: TaWorkbench;
16
+ protected readonly kept: TaKeptChats;
17
+ protected readonly extensions: TaWebExtensions;
18
+ /** The conversations shown before, to show again at once. */
19
+ readonly recent: RecentStores;
20
+ protected readonly tools: WeakMap<SessionStore, string>;
21
+ /** The tools of the sessions this page opened, by session: only those are opened again when the tools change. */
22
+ protected readonly opened: Map<string, string>;
23
+ protected readonly attached: WeakSet<SessionStore>;
24
+ /** The file of the conversation a store not attached shows: the store that attaches for it takes on what failed to go there. */
25
+ protected readonly files: WeakMap<SessionStore, string>;
26
+ constructor(workbench: TaWorkbench, kept: TaKeptChats, extensions: TaWebExtensions);
27
+ /** The names of the web tools of now. */
28
+ toolNames(): string;
29
+ /** Opens a session with the web tools of now. */
30
+ open(options: Partial<TaOpenSessionOptions>): Promise<string>;
31
+ /** The names of the tools this page opened a session with; none for one it did not open. */
32
+ openedWith(sessionId: string): string | undefined;
33
+ /** The session closed. */
34
+ closed(sessionId: string): void;
35
+ /** A store of the session with the web tools of now, showing `initial` until it attaches. */
36
+ create(sessionId: string, initial?: SessionSnapshot): SessionStore;
37
+ /** A store, not attached, of the conversation of `sessionFile` as the device kept it, under `key`; none if it kept none. */
38
+ fromDevice(key: string, sessionFile: string | undefined): Promise<SessionStore | undefined>;
39
+ /** The conversation under `key` as this page or else this device had it, not attached: one shown lately, else the one of its file (else the list's). */
40
+ shown(key: string, sessionFile: string | undefined): Promise<SessionStore | undefined>;
41
+ /** What the device kept of the conversation of a file. */
42
+ read(sessionFile: string | undefined): Promise<SessionSnapshot | undefined>;
43
+ /** Whether the list has the session open. */
44
+ listed(sessionId: string): boolean;
45
+ /** The open session of a file. */
46
+ openOf(sessionFile: string): TaSessionInfo | undefined;
47
+ /** The file of an open session of the list. */
48
+ fileOf(sessionId: string): string | undefined;
49
+ /** The names of the web tools a store runs. */
50
+ toolsOf(store: SessionStore): string | undefined;
51
+ isAttached(store: SessionStore): boolean;
52
+ setAttached(store: SessionStore): void;
53
+ /** It is detached: whether it was attached. */
54
+ setDetached(store: SessionStore): boolean;
55
+ /** Whether `store`, not attached, shows the conversation of `sessionFile`. */
56
+ standsFor(store: SessionStore, sessionFile: string | undefined): boolean;
57
+ /** Runs the web tool of the name that is loaded when the model calls it: a changed one runs as it is now. */
58
+ protected clientTool(name: string): ClientTool;
59
+ }
@@ -0,0 +1,121 @@
1
+ import { ChatUtil } from './chat-util.js';
2
+ import { RecentStores } from './recent-stores.js';
3
+ /**
4
+ * The sessions and stores of the conversations TaChat shows. Sessions open, and stores are made, with the
5
+ * web tools of now (each kept with their names, to tell when they changed); a store starts
6
+ * from what the device kept of its conversation when it has it, and knows whether it is attached. One that is
7
+ * not shows a conversation as the device kept it, until the connection is there: it is not kept among the
8
+ * recent ones, the device has it.
9
+ */
10
+ export class ChatStores {
11
+ constructor(workbench, kept, extensions) {
12
+ this.workbench = workbench;
13
+ this.kept = kept;
14
+ this.extensions = extensions;
15
+ /** The conversations shown before, to show again at once. */
16
+ this.recent = new RecentStores();
17
+ this.tools = new WeakMap();
18
+ /** The tools of the sessions this page opened, by session: only those are opened again when the tools change. */
19
+ this.opened = new Map();
20
+ this.attached = new WeakSet();
21
+ /** The file of the conversation a store not attached shows: the store that attaches for it takes on what failed to go there. */
22
+ this.files = new WeakMap();
23
+ }
24
+ /** The names of the web tools of now. */
25
+ toolNames() {
26
+ return ChatUtil.toolNames(this.extensions.state.tools);
27
+ }
28
+ /** Opens a session with the web tools of now. */
29
+ async open(options) {
30
+ var _a, _b;
31
+ const tools = this.extensions.state.tools;
32
+ const { sessionId } = await this.workbench.server.openSession({
33
+ ...options,
34
+ 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) || '.',
35
+ clientTools: tools.map(({ name, description, parameters }) => ({ name, description, parameters })),
36
+ });
37
+ this.opened.set(sessionId, ChatUtil.toolNames(tools));
38
+ return sessionId;
39
+ }
40
+ /** The names of the tools this page opened a session with; none for one it did not open. */
41
+ openedWith(sessionId) {
42
+ return this.opened.get(sessionId);
43
+ }
44
+ /** The session closed. */
45
+ closed(sessionId) {
46
+ this.opened.delete(sessionId);
47
+ }
48
+ /** A store of the session with the web tools of now, showing `initial` until it attaches. */
49
+ create(sessionId, initial) {
50
+ const store = this.workbench.createStore(sessionId, { clientTools: this.extensions.state.tools.map(tool => this.clientTool(tool.name)), initial });
51
+ this.tools.set(store, this.toolNames());
52
+ return store;
53
+ }
54
+ /** A store, not attached, of the conversation of `sessionFile` as the device kept it, under `key`; none if it kept none. */
55
+ async fromDevice(key, sessionFile) {
56
+ const initial = await this.read(sessionFile);
57
+ if (!sessionFile || !initial) {
58
+ return undefined;
59
+ }
60
+ const store = this.create(key, initial);
61
+ this.files.set(store, sessionFile);
62
+ return store;
63
+ }
64
+ /** The conversation under `key` as this page or else this device had it, not attached: one shown lately, else the one of its file (else the list's). */
65
+ async shown(key, sessionFile) {
66
+ var _a;
67
+ return (_a = this.recent.take(key, this.toolNames())) !== null && _a !== void 0 ? _a : (await this.fromDevice(key, sessionFile !== null && sessionFile !== void 0 ? sessionFile : this.fileOf(key)));
68
+ }
69
+ /** What the device kept of the conversation of a file. */
70
+ read(sessionFile) {
71
+ return sessionFile ? this.kept.read(sessionFile).catch(() => undefined) : Promise.resolve(undefined);
72
+ }
73
+ /** Whether the list has the session open. */
74
+ listed(sessionId) {
75
+ return this.workbench.state.sessions.some(session => session.sessionId === sessionId);
76
+ }
77
+ /** The open session of a file. */
78
+ openOf(sessionFile) {
79
+ return this.workbench.state.sessions.find(session => session.sessionFile === sessionFile);
80
+ }
81
+ /** The file of an open session of the list. */
82
+ fileOf(sessionId) {
83
+ var _a;
84
+ return (_a = this.workbench.state.sessions.find(session => session.sessionId === sessionId)) === null || _a === void 0 ? void 0 : _a.sessionFile;
85
+ }
86
+ /** The names of the web tools a store runs. */
87
+ toolsOf(store) {
88
+ return this.tools.get(store);
89
+ }
90
+ isAttached(store) {
91
+ return this.attached.has(store);
92
+ }
93
+ setAttached(store) {
94
+ this.attached.add(store);
95
+ }
96
+ /** It is detached: whether it was attached. */
97
+ setDetached(store) {
98
+ return this.attached.delete(store);
99
+ }
100
+ /** Whether `store`, not attached, shows the conversation of `sessionFile`. */
101
+ standsFor(store, sessionFile) {
102
+ return !!sessionFile && !this.attached.has(store) && this.files.get(store) === sessionFile;
103
+ }
104
+ /** Runs the web tool of the name that is loaded when the model calls it: a changed one runs as it is now. */
105
+ clientTool(name) {
106
+ var _a;
107
+ const tool = () => this.extensions.state.tools.find(candidate => candidate.name === name);
108
+ const { description = '', parameters = {} } = (_a = tool()) !== null && _a !== void 0 ? _a : {};
109
+ return {
110
+ definition: { name, description, parameters },
111
+ run: async (input, request) => {
112
+ const current = tool();
113
+ if (!current) {
114
+ throw new Error(`The web extension of the tool ${name} is no longer loaded.`);
115
+ }
116
+ return current.execute(request.id, (input !== null && input !== void 0 ? input : {}));
117
+ },
118
+ };
119
+ }
120
+ }
121
+ //# sourceMappingURL=chat-stores.js.map
@@ -0,0 +1,17 @@
1
+ import { type SessionState } from '@celljs/ta-client';
2
+ import type { WebTool } from '../extension/web-extension-api.js';
3
+ export declare namespace ChatUtil {
4
+ function toolNames(tools: WebTool[]): string;
5
+ /** Ids of the runs of `write` and `edit` in a directory of packages that are not in `seen`. */
6
+ function packageEdits(state: SessionState, seen: Set<string>): string[];
7
+ function message(error: unknown): string;
8
+ /** Only the connection was lost: it mends itself, and what it cut off goes again once it is back. */
9
+ function lost(error: unknown): boolean;
10
+ /** A change nobody asked for now (after a run): a lost connection is no failure to tell, the next run does it again. */
11
+ function quietly(change: () => Promise<void>): () => Promise<void>;
12
+ /**
13
+ * Runs `run` again each time the connection is lost under it and comes back, while `wanted` (a few times
14
+ * at most): opening a conversation on a network that drops goes on, rather than failing.
15
+ */
16
+ function untilConnected(run: () => Promise<void>, connected: () => Promise<void>, wanted: () => boolean): Promise<void>;
17
+ }
@@ -0,0 +1,61 @@
1
+ import { TaRemoteError } from '@celljs/ta-client';
2
+ /** A file in a directory of packages: `extensions/<name>/...`, of the user or a project. */
3
+ const PACKAGE_FILE = /(^|[\\/])extensions[\\/][^\\/]+[\\/]/;
4
+ export var ChatUtil;
5
+ (function (ChatUtil) {
6
+ function toolNames(tools) {
7
+ return tools
8
+ .map(tool => tool.name)
9
+ .sort()
10
+ .join(',');
11
+ }
12
+ ChatUtil.toolNames = toolNames;
13
+ /** Ids of the runs of `write` and `edit` in a directory of packages that are not in `seen`. */
14
+ function packageEdits(state, seen) {
15
+ return Object.entries(state.tools)
16
+ .filter(([id, run]) => {
17
+ var _a;
18
+ const path = (_a = run.args) === null || _a === void 0 ? void 0 : _a.path;
19
+ return !seen.has(id) && (run.toolName === 'write' || run.toolName === 'edit') && typeof path === 'string' && PACKAGE_FILE.test(path);
20
+ })
21
+ .map(([id]) => id);
22
+ }
23
+ ChatUtil.packageEdits = packageEdits;
24
+ function message(error) {
25
+ return error instanceof Error ? error.message : String(error);
26
+ }
27
+ ChatUtil.message = message;
28
+ /** Only the connection was lost: it mends itself, and what it cut off goes again once it is back. */
29
+ function lost(error) {
30
+ return TaRemoteError.isConnectionLost(error);
31
+ }
32
+ ChatUtil.lost = lost;
33
+ /** A change nobody asked for now (after a run): a lost connection is no failure to tell, the next run does it again. */
34
+ function quietly(change) {
35
+ return () => change().catch(error => {
36
+ if (!lost(error)) {
37
+ throw error;
38
+ }
39
+ });
40
+ }
41
+ ChatUtil.quietly = quietly;
42
+ /**
43
+ * Runs `run` again each time the connection is lost under it and comes back, while `wanted` (a few times
44
+ * at most): opening a conversation on a network that drops goes on, rather than failing.
45
+ */
46
+ async function untilConnected(run, connected, wanted) {
47
+ for (let tries = 1;; tries++) {
48
+ try {
49
+ return await run();
50
+ }
51
+ catch (error) {
52
+ if (!lost(error) || tries >= 5 || !wanted()) {
53
+ throw error;
54
+ }
55
+ await connected();
56
+ }
57
+ }
58
+ }
59
+ ChatUtil.untilConnected = untilConnected;
60
+ })(ChatUtil || (ChatUtil = {}));
61
+ //# sourceMappingURL=chat-util.js.map
@@ -1,4 +1,5 @@
1
1
  import { useInject } from '@celljs/react';
2
+ import { SessionReducer, SessionStore } from '@celljs/ta-client';
2
3
  import { ChevronLeft } from 'lucide-react';
3
4
  import * as React from 'react';
4
5
  import { Callout } from '../components/callout.js';
@@ -7,6 +8,7 @@ import { ConnectionBanner } from '../components/connection-bar.js';
7
8
  import { DirectoryButton } from '../components/folder-picker.js';
8
9
  import { HeroCards } from '../components/hero-cards.js';
9
10
  import { IconButton, SidebarLeft } from '../components/icon.js';
11
+ import { MessageList } from '../components/message-list.js';
10
12
  import { useScreenArriving } from '../components/phone-shell.js';
11
13
  import { SessionView } from '../components/session-view.js';
12
14
  import { TaAvatar } from '../components/ta-avatar.js';
@@ -53,24 +55,40 @@ function DraftView({ draft, menu, aboveComposer, belowComposer }) {
53
55
  const list = React.useCallback((directory) => workbench.workspace.listDirectory('.', directory), [workbench]);
54
56
  const pickModel = React.useCallback((model) => chat.setDraftModel(model), [chat]);
55
57
  const model = useDraftModel(workbench.settings, draft, pickModel, t);
58
+ const { sending } = draft;
59
+ const going = !!sending && !sending.failed;
60
+ // Its first message, as the conversation will show it, while the session opens.
61
+ const sent = React.useMemo(() => {
62
+ var _a;
63
+ if (!sending) {
64
+ return undefined;
65
+ }
66
+ const message = {
67
+ role: 'user',
68
+ content: [{ type: 'text', text: sending.message }, ...((_a = sending.images) !== null && _a !== void 0 ? _a : [])],
69
+ timestamp: Date.now(),
70
+ };
71
+ return SessionStore.withSent(SessionReducer.initial(), [{ id: 'draft', message, failed: sending.failed }]);
72
+ }, [sending]);
73
+ const outbox = React.useMemo(() => ({ resend: () => void chat.resendDraft(), discard: () => chat.discardDraft() }), [chat]);
56
74
  return (React.createElement("section", { className: "ta-session" },
57
75
  React.createElement("header", { className: "ta-session-header" },
58
76
  menu,
59
- React.createElement("div", { className: "ta-session-title" },
60
- React.createElement("span", { className: "ta-title" }, t('ta.chat.new'))),
77
+ React.createElement("div", { className: "ta-session-title" }, going ? (React.createElement(React.Fragment, null,
78
+ React.createElement("span", { className: "ta-title" }, MessageUtil.basename(draft.cwd) || t('ta.session.title')),
79
+ React.createElement("span", { className: "ta-muted ta-path", title: draft.cwd }, MessageUtil.shortPath(draft.cwd)))) : (React.createElement("span", { className: "ta-title" }, t('ta.chat.new')))),
61
80
  React.createElement(WorkbenchToggle, null)),
62
- React.createElement("div", { className: "ta-scroll" },
63
- React.createElement("div", { className: "ta-thread" },
64
- React.createElement(Hero, { cwd: draft.cwd, onPick: text => void submit(text).catch(fail) }))),
81
+ React.createElement("div", { className: sent ? 'ta-scroll ta-conversation' : 'ta-scroll' },
82
+ React.createElement("div", { className: "ta-thread" }, sent ? React.createElement(MessageList, { state: sent, outbox: outbox }) : React.createElement(Hero, { cwd: draft.cwd, onPick: text => void submit(text).catch(fail) }))),
65
83
  React.createElement("div", { className: "ta-bottom" },
66
84
  aboveComposer,
67
- React.createElement(Composer, { server: workbench.server, workspace: workbench.workspace, working: false, commands: [], cwd: draft.cwd || undefined, onSubmit: submit, onError: fail, actions: model ? [[model]] : undefined, beside: React.createElement(DirectoryButton, { cwd: draft.cwd, list: list, remote: workbench, onPick: cwd => chat.setDraftCwd(cwd) }) }),
85
+ React.createElement(Composer, { server: workbench.server, workspace: workbench.workspace, working: going, onStop: () => chat.stopDraft(), commands: [], cwd: draft.cwd || undefined, onSubmit: submit, onError: fail, talkPlace: "draft", actions: model ? [[model]] : undefined, beside: going ? undefined : React.createElement(DirectoryButton, { cwd: draft.cwd, list: list, remote: workbench, onPick: cwd => chat.setDraftCwd(cwd) }) }),
68
86
  belowComposer)));
69
87
  }
70
88
  /** A conversation picked that is still loading, laid out as it will be: its head, a spinner, a message box that waits. */
71
89
  function OpeningView({ info, menu }) {
72
90
  const t = useT();
73
- const [, workbench] = useWorkbench();
91
+ const [{ offlineShown }, workbench] = useWorkbench();
74
92
  return (React.createElement("section", { className: "ta-session", "aria-busy": "true" },
75
93
  React.createElement("header", { className: "ta-session-header" },
76
94
  menu,
@@ -78,16 +96,16 @@ function OpeningView({ info, menu }) {
78
96
  React.createElement("span", { className: "ta-title" }, (info === null || info === void 0 ? void 0 : info.title) || ((info === null || info === void 0 ? void 0 : info.cwd) ? MessageUtil.basename(info.cwd) : t('ta.session.title'))),
79
97
  (info === null || info === void 0 ? void 0 : info.cwd) && (React.createElement("span", { className: "ta-muted ta-path", title: info.cwd }, MessageUtil.shortPath(info.cwd)))),
80
98
  React.createElement(WorkbenchToggle, null)),
81
- React.createElement("div", { className: "ta-empty" },
99
+ React.createElement("div", { className: "ta-empty" }, offlineShown ? (React.createElement("span", { className: "ta-muted" }, t('ta.chat.openingOffline'))) : (React.createElement(React.Fragment, null,
82
100
  React.createElement("span", { className: "ta-spinner" }),
83
101
  " ",
84
- t('ta.chat.opening')),
102
+ t('ta.chat.opening')))),
85
103
  React.createElement("div", { className: "ta-bottom", inert: true },
86
104
  React.createElement(Composer, { server: workbench.server, workspace: workbench.workspace, working: false, commands: [], cwd: info === null || info === void 0 ? void 0 : info.cwd, onError: () => undefined }))));
87
105
  }
88
106
  /** The conversation shown, with the widgets of web extensions around its message box. */
89
107
  export function ChatView({ widgets, onMenu, back }) {
90
- var _a, _b;
108
+ var _a, _b, _c, _d;
91
109
  const t = useT();
92
110
  const [{ sessions, saved }, workbench] = useWorkbench();
93
111
  const [{ store, draft, pending, opening, error }] = useChat();
@@ -123,7 +141,10 @@ export function ChatView({ widgets, onMenu, back }) {
123
141
  " ",
124
142
  t('ta.chat.opening'))))));
125
143
  }
126
- const info = sessions.find(session => session.sessionId === store.sessionId);
127
- return (React.createElement(SessionView, { key: store.sessionId, store: store, server: workbench.server, workspace: workbench.workspace, info: info, onClosed: refresh, onActivity: refresh, leading: menu, trailing: React.createElement(WorkbenchToggle, null), empty: React.createElement(Hero, { cwd: (_b = info === null || info === void 0 ? void 0 : info.cwd) !== null && _b !== void 0 ? _b : '', onPick: text => store.prompt(text).catch(() => undefined) }), aboveComposer: aboveComposer, belowComposer: around('belowEditor') }));
144
+ // One shown from the device under what is pending (a saved conversation, an agent's on its way) is said by what opens.
145
+ const info = (_b = sessions.find(session => session.sessionId === store.sessionId)) !== null && _b !== void 0 ? _b : (opening && pending === store.sessionId
146
+ ? { sessionId: store.sessionId, sessionName: opening.title, cwd: (_c = opening.cwd) !== null && _c !== void 0 ? _c : '', sessionFile: opening.sessionFile }
147
+ : undefined);
148
+ return (React.createElement(SessionView, { key: store.sessionId, store: store, server: workbench.server, workspace: workbench.workspace, info: info, onClosed: refresh, onActivity: refresh, leading: menu, trailing: React.createElement(WorkbenchToggle, null), empty: React.createElement(Hero, { cwd: (_d = info === null || info === void 0 ? void 0 : info.cwd) !== null && _d !== void 0 ? _d : '', onPick: text => store.send(text).catch(() => undefined) }), aboveComposer: aboveComposer, belowComposer: around('belowEditor') }));
128
149
  }
129
150
  //# sourceMappingURL=chat-view.js.map