@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
@@ -40,15 +40,18 @@ exports.PageView = PageView;
40
40
  const lucide_react_1 = require("lucide-react");
41
41
  const React = __importStar(require("react"));
42
42
  const device_1 = require("../device/device");
43
+ const hold_1 = require("../device/hold");
43
44
  const extension_view_1 = require("../extension/extension-view");
44
45
  const web_extension_protocol_1 = require("../extension/web-extension-protocol");
45
46
  const hooks_1 = require("../hooks");
46
47
  const use_t_1 = require("../i18n/use-t");
48
+ const agent_settings_1 = require("../settings/agent-settings");
47
49
  const navigation_1 = require("../settings/navigation");
48
50
  const account_menu_1 = require("./account-menu");
49
51
  const connection_bar_1 = require("./connection-bar");
50
52
  const context_menu_1 = require("./context-menu");
51
53
  const dino_1 = require("./dino");
54
+ const icon_1 = require("./icon");
52
55
  const nav_places_1 = require("./nav-places");
53
56
  const ta_avatar_1 = require("./ta-avatar");
54
57
  const workbench_toggle_1 = require("./workbench-toggle");
@@ -67,36 +70,42 @@ function useNavigation(views) {
67
70
  update,
68
71
  };
69
72
  }
70
- function RailItem({ label, active, onClick, onContextMenu, children }) {
71
- return (React.createElement("button", { type: "button", className: `ta-rail-item ${active ? 'ta-active' : ''}`, title: label, "aria-label": label, "aria-pressed": active, onClick: onClick, onContextMenu: onContextMenu }, children));
73
+ function RailItem({ label, active, onClick, onContextMenu, onPointerDown, 'data-held': held, children }) {
74
+ return (React.createElement("button", { type: "button", className: `ta-rail-item ${active ? 'ta-active' : ''}`, title: label, "aria-label": label, "aria-pressed": active, onClick: onClick, onContextMenu: onContextMenu, onPointerDown: onPointerDown, "data-held": held }, children));
72
75
  }
73
76
  /**
74
77
  * The navigation on the left, as the tabs of a phone: the logo; the lists of the sidebar; the pages, and Discover
75
- * once some are under it; the account with the settings at the bottom. A page's menu (a right click) puts it under Discover.
78
+ * once some are under it; the account with the settings at the bottom. A page's menu (a right click) puts it under
79
+ * Discover; that of the double talks to it, and that of the chats opens a new one (entryMenu).
76
80
  */
77
- function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface }) {
81
+ function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, }) {
78
82
  const t = (0, use_t_1.useT)();
79
83
  const [{ server }] = (0, hooks_1.useWorkbench)();
80
84
  const [menu, openMenu] = (0, context_menu_1.useContextMenu)();
85
+ const held = (0, hold_1.useHeld)();
81
86
  const settingsItem = { label: t('ta.nav.settings'), run: () => onSettings('navigation') };
82
- /** A page of the rail; the double's (`double`) is its face and stays out of Discover. */
87
+ /** A page of the rail; the double's (`double`) is its face and stays out of Discover, and talks while it is held. */
83
88
  const item = (view, foldable = true, double = false) => {
84
89
  var _a;
85
90
  const Glyph = (_a = view.icon) !== null && _a !== void 0 ? _a : lucide_react_1.PanelTop;
86
- return (React.createElement(RailItem, { key: view.id, label: web_extension_protocol_1.WebLabelUtil.text(view.title), active: !settingsShown && current === view.id, onClick: () => onPage(view.id), onContextMenu: foldable ? event => openMenu(event, [{ label: t('ta.nav.fold'), run: () => navigation.fold(view.id) }, '-', settingsItem]) : undefined }, double ? React.createElement(ta_avatar_1.DinoFace, { size: 24, className: "ta-nav-face" }) : React.createElement(Glyph, { size: 20, strokeWidth: 1.6 })));
91
+ return (React.createElement(RailItem, { key: view.id, label: web_extension_protocol_1.WebLabelUtil.text(view.title), active: !settingsShown && current === view.id, onClick: () => onPage(view.id), onContextMenu: foldable ? event => openMenu(event, [{ label: t('ta.nav.fold'), run: () => navigation.fold(view.id) }, '-', settingsItem]) : undefined, ...held(double ? holds.double : undefined) }, double ? React.createElement(ta_avatar_1.DinoFace, { size: 24, className: "ta-nav-face" }) : React.createElement(Glyph, { size: 20, strokeWidth: 1.6 })));
87
92
  };
88
93
  const discover = navigation.discover.length > 0 || current === nav_places_1.DISCOVER;
94
+ // The workbench from anywhere, a page or the settings too, as the launcher and the board.
95
+ const workbench = React.useContext(workbench_toggle_1.WorkbenchToggleContext);
89
96
  return (React.createElement("nav", { className: "ta-rail", "aria-label": t('ta.menu') },
90
97
  React.createElement("div", { className: "ta-rail-logo", title: server ? `Ta v${server.version}` : 'Ta' },
91
98
  React.createElement(dino_1.Dino, { size: 26 })),
92
99
  React.createElement("div", { className: "ta-rail-items" },
93
100
  navigation.home && item(navigation.home, false, true),
94
- lists.map(entry => (React.createElement(RailItem, { key: entry.id, label: entry.label, active: list === entry.id, onClick: () => onList(entry.id) }, entry.double ? React.createElement(ta_avatar_1.DinoFace, { size: 24, className: "ta-nav-face" }) : React.createElement(entry.icon, { size: 20, strokeWidth: 1.6 })))),
101
+ lists.map(entry => (React.createElement(RailItem, { key: entry.id, label: entry.label, active: list === entry.id, onClick: () => onList(entry.id), ...held((0, nav_places_1.entryHold)(entry.id, entry.double, holds)) }, entry.double ? React.createElement(ta_avatar_1.DinoFace, { size: 24, className: "ta-nav-face" }) : React.createElement(entry.icon, { size: 20, strokeWidth: 1.6 })))),
95
102
  (navigation.nav.length > 0 || discover) && React.createElement("hr", { className: "ta-rail-divider" }),
96
103
  navigation.nav.map(view => item(view)),
97
104
  discover && (React.createElement(RailItem, { label: t('ta.discover'), active: !settingsShown && current === nav_places_1.DISCOVER, onClick: onDiscover, onContextMenu: event => openMenu(event, [settingsItem]) },
98
105
  React.createElement(lucide_react_1.Compass, { size: 20, strokeWidth: 1.6 })))),
99
- (surfaces.launcher || surfaces.board) && (React.createElement("div", { className: "ta-rail-tools" },
106
+ (workbench || surfaces.launcher || surfaces.board) && (React.createElement("div", { className: "ta-rail-tools" },
107
+ workbench && (React.createElement(RailItem, { label: `${t('ta.workbench')} (${agent_settings_1.ShortcutUtil.keys('Mod+J').join(agent_settings_1.ShortcutUtil.isMac() ? '' : '+')})`, active: workbench.open, onClick: workbench.toggle },
108
+ React.createElement(icon_1.SidebarRight, { size: 20, strokeWidth: 1.6 }))),
100
109
  surfaces.launcher && (React.createElement(SurfaceButton, { label: t('ta.launcher'), active: surface === 'launcher', onClick: () => onSurface(surface === 'launcher' ? undefined : 'launcher') },
101
110
  React.createElement(lucide_react_1.Grip, { size: 20, strokeWidth: 1.6 }))),
102
111
  surfaces.board && (React.createElement(SurfaceButton, { label: t('ta.board'), active: surface === 'board', onClick: () => onSurface(surface === 'board' ? undefined : 'board') },
@@ -23,8 +23,8 @@ export declare const CARDS_ID = "ta/cards";
23
23
  * them hides it where it lies over the conversation, the user's choice kept.
24
24
  */
25
25
  export declare function useRight(): [boolean, () => void, () => void, () => void];
26
- /** Cmd/Ctrl+B shows or hides the sidebar and Cmd/Ctrl+, opens the settings, as in an IDE. */
27
- export declare function useKeys(toggle: () => void, openSettings: () => void): void;
26
+ /** Cmd/Ctrl+B shows or hides the sidebar, Cmd/Ctrl+J the workbench, and Cmd/Ctrl+, opens the settings, as in an IDE. */
27
+ export declare function useKeys(toggle: () => void, openSettings: () => void, toggleWorkbench: () => void): void;
28
28
  /**
29
29
  * The installed app with its title bar hidden draws the bar itself (see .ta-titlebar), but the browser
30
30
  * paints the corners of the window's buttons with theme-color: the traffic lights at the left over the
@@ -91,8 +91,8 @@ function useRight() {
91
91
  // `set` is stable, so `reveal` is too: effects may depend on it.
92
92
  return [open, toggle, reveal, uncover];
93
93
  }
94
- /** Cmd/Ctrl+B shows or hides the sidebar and Cmd/Ctrl+, opens the settings, as in an IDE. */
95
- function useKeys(toggle, openSettings) {
94
+ /** Cmd/Ctrl+B shows or hides the sidebar, Cmd/Ctrl+J the workbench, and Cmd/Ctrl+, opens the settings, as in an IDE. */
95
+ function useKeys(toggle, openSettings, toggleWorkbench) {
96
96
  React.useEffect(() => {
97
97
  const onKey = (event) => {
98
98
  if (!(event.metaKey || event.ctrlKey) || event.shiftKey || event.altKey) {
@@ -107,10 +107,14 @@ function useKeys(toggle, openSettings) {
107
107
  event.preventDefault();
108
108
  openSettings();
109
109
  }
110
+ else if (key === 'j') {
111
+ event.preventDefault();
112
+ toggleWorkbench();
113
+ }
110
114
  };
111
115
  window.addEventListener('keydown', onKey);
112
116
  return () => window.removeEventListener('keydown', onKey);
113
- }, [toggle, openSettings]);
117
+ }, [toggle, openSettings, toggleWorkbench]);
114
118
  }
115
119
  /**
116
120
  * The installed app with its title bar hidden draws the bar itself (see .ta-titlebar), but the browser
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.AppView = AppView;
37
+ const react_1 = require("@celljs/react");
37
38
  const lucide_react_1 = require("lucide-react");
38
39
  const React = __importStar(require("react"));
39
40
  const assistant_chat_list_1 = require("../assistant/assistant-chat-list");
@@ -42,9 +43,12 @@ const chat_view_1 = require("../chat/chat-view");
42
43
  const device_1 = require("../device/device");
43
44
  const launch_screen_1 = require("../device/launch-screen");
44
45
  const extension_view_1 = require("../extension/extension-view");
46
+ const web_extension_protocol_1 = require("../extension/web-extension-protocol");
47
+ const files_protocol_1 = require("../files/files-protocol");
45
48
  const hooks_1 = require("../hooks");
46
49
  const use_t_1 = require("../i18n/use-t");
47
50
  const notices_1 = require("../notices/notices");
51
+ const voice_1 = require("../util/voice");
48
52
  const app_nav_1 = require("./app-nav");
49
53
  const app_shell_hooks_1 = require("./app-shell-hooks");
50
54
  const auth_view_1 = require("./auth-view");
@@ -55,6 +59,7 @@ const dino_look_1 = require("./dino-look");
55
59
  const discover_view_1 = require("./discover-view");
56
60
  const editor_area_1 = require("./editor-area");
57
61
  const environment_view_1 = require("./environment-view");
62
+ const held_talk_1 = require("./held-talk");
58
63
  const host_view_1 = require("./host-view");
59
64
  const icon_1 = require("./icon");
60
65
  const kept_pages_1 = require("./kept-pages");
@@ -82,8 +87,8 @@ const workbench_view_1 = require("./workbench-view");
82
87
  * the conversation instead.
83
88
  */
84
89
  function AppShell() {
85
- var _a, _b;
86
- var _c, _d;
90
+ var _a, _b, _c, _d;
91
+ var _e, _f, _g, _h;
87
92
  const t = (0, use_t_1.useT)();
88
93
  const [workbench, bench] = (0, hooks_1.useWorkbench)();
89
94
  const [extensions, host] = (0, hooks_1.useWebExtensions)();
@@ -134,7 +139,8 @@ function AppShell() {
134
139
  const editor = (0, split_pane_1.usePane)(app_shell_hooks_1.EDITOR);
135
140
  const online = workbench.status === 'online';
136
141
  // Files named in replies outside a conversation (channels, pages) are in the server's directory.
137
- const fileUrl = React.useCallback((path) => bench.workspace.fileUrl(path), [bench]);
142
+ const files = (0, react_1.useInject)(files_protocol_1.TaFiles);
143
+ const fileUrl = React.useCallback(async (path) => files.loadable(await bench.workspace.fileUrl(path)), [bench, files]);
138
144
  const openLink = (0, hooks_1.useOpenLink)(undefined);
139
145
  (0, workbench_view_1.useDocument)();
140
146
  (0, app_shell_hooks_1.useRefresh)(online);
@@ -147,6 +153,16 @@ function AppShell() {
147
153
  React.useEffect(() => {
148
154
  void bench.start();
149
155
  }, [bench]);
156
+ // The computer cannot be reached from the start: the web extensions of the last time start anyway (from
157
+ // the code this device kept) and show what they read last; online, `chat.start` loads them.
158
+ const offline = workbench.status === 'offline';
159
+ const startedOffline = React.useRef(false);
160
+ React.useEffect(() => {
161
+ if (offline && !startedOffline.current) {
162
+ startedOffline.current = true;
163
+ void host.refresh().catch(() => undefined);
164
+ }
165
+ }, [offline, host]);
150
166
  /** The conversation the page opens with is shown: those shown after are the user's doing. */
151
167
  const started = React.useRef(false);
152
168
  React.useEffect(() => {
@@ -163,6 +179,8 @@ function AppShell() {
163
179
  if (focus > 0) {
164
180
  revealRight();
165
181
  revealEditor();
182
+ // Opened from the launcher or the board: the workbench comes in their place.
183
+ setSurface(undefined);
166
184
  }
167
185
  }, [focus, revealRight, revealEditor]);
168
186
  // A web extension shows another conversation: the conversation, not a page, a drawer or the workbench over it, is then in front.
@@ -259,6 +277,11 @@ function AppShell() {
259
277
  const railView = view && (view === navigation.home || navigation.pages.includes(view)) ? view : undefined;
260
278
  // On a phone a page of a list (a channel, the double) or of Discover comes in front of the tabs; one of the navigation is a tab.
261
279
  const tabView = view && (view === navigation.home || navigation.nav.includes(view)) ? view : undefined;
280
+ // A page of the screen, and those in the background beside it, kept as they were.
281
+ const screenPage = settings === undefined && view && !tabView ? view : undefined;
282
+ // The conversation in front, where the tools of the workbench follow its directory; else they are in the default one.
283
+ const conversationShown = phone ? screenOpen && settings === undefined && !screenPage : settings === undefined && tabPage !== 'discover' && !view;
284
+ React.useEffect(() => host.setConversationShown(conversationShown), [host, conversationShown]);
262
285
  const { pageShown } = extensions;
263
286
  // biome-ignore lint/correctness/useExhaustiveDependencies: follows the pages shown
264
287
  React.useEffect(() => {
@@ -322,7 +345,20 @@ function AppShell() {
322
345
  sidebar.reveal();
323
346
  }
324
347
  };
325
- (0, app_shell_hooks_1.useKeys)(toggleSide, openSettings);
348
+ const toggleWorkbench = () => {
349
+ if (showEditors) {
350
+ toggleRight();
351
+ }
352
+ else {
353
+ // Over the settings of a wide screen (the rail, Cmd/Ctrl+J): they give way to what was under them.
354
+ if (!phone && settings !== undefined) {
355
+ setSettings(undefined);
356
+ }
357
+ revealRight();
358
+ editor.reveal();
359
+ }
360
+ };
361
+ (0, app_shell_hooks_1.useKeys)(toggleSide, openSettings, () => editors && toggleWorkbench());
326
362
  (0, app_shell_hooks_1.useTitlebarColor)(workbench.status !== 'signed-out', theme);
327
363
  const [providers, reloadProviders] = (0, auth_view_1.useAuthProviders)(online);
328
364
  const [later, setLater] = (0, hooks_1.usePersisted)(app_shell_hooks_1.LOGIN_LATER);
@@ -336,6 +372,8 @@ function AppShell() {
336
372
  window.addEventListener(notices_1.SIGN_IN_EVENT, ask);
337
373
  return () => window.removeEventListener(notices_1.SIGN_IN_EVENT, ask);
338
374
  }, [reloadProviders]);
375
+ /** The page of the double: its own, or the one a sidebar view that lists it opens. */
376
+ const doubleId = (_e = (_b = navigation.home) === null || _b === void 0 ? void 0 : _b.id) !== null && _e !== void 0 ? _e : side_lists_1.DOUBLE_PAGE;
339
377
  if (workbench.status === 'signed-out') {
340
378
  return React.createElement(workbench_view_1.SignIn, { error: workbench.error });
341
379
  }
@@ -351,15 +389,6 @@ function AppShell() {
351
389
  reloadProviders();
352
390
  } }));
353
391
  }
354
- const toggleWorkbench = () => {
355
- if (showEditors) {
356
- toggleRight();
357
- }
358
- else {
359
- revealRight();
360
- editor.reveal();
361
- }
362
- };
363
392
  // What the columns beside the conversation and the editors take, so that the editors never take more than the conversation.
364
393
  const sideWidths = {
365
394
  '--ta-left': `${app_shell_hooks_1.RAIL + (sideShown ? sidebar.size : 0)}px`,
@@ -379,7 +408,7 @@ function AppShell() {
379
408
  }
380
409
  };
381
410
  const chats = (React.createElement(assistant_chat_list_1.AssistantChatList, { sessions: workbench.sessions, saved: workbench.saved, removed: removedChats, selected: view || phone ? undefined : (pending !== null && pending !== void 0 ? pending : store === null || store === void 0 ? void 0 : store.sessionId), chat: chat, byDirectory: chatsByDirectory, onByDirectory: setChatsByDirectory, folded: foldedChats, onFolded: setFoldedChats, onPicked: picked }));
382
- const editorArea = (React.createElement(editor_area_1.EditorArea, { editors: extensions.editors, active: activeEditor, views: tools, onShow: id => host.showEditor(id), onClose: ids => void host.closeEditors(ids), onPin: id => host.pinEditor(id), onOpenView: openTool, onHide: editor.toggle, maximized: maximized, onMaximize: () => setMaximized(!maximized) }));
411
+ const editorArea = (React.createElement(editor_area_1.EditorArea, { editors: extensions.editors, active: activeEditor, views: tools, onShow: id => host.showEditor(id), onClose: ids => void host.closeEditors(ids), onPin: id => host.pinEditor(id), onOpenView: openTool, onHide: editor.toggle, cwd: (_f = web_extension_protocol_1.WebCwdUtil.shown(extensions)) !== null && _f !== void 0 ? _f : (_c = workbench.server) === null || _c === void 0 ? void 0 : _c.cwd, maximized: maximized, onMaximize: () => setMaximized(!maximized) }));
383
412
  const overlays = (React.createElement(React.Fragment, null,
384
413
  React.createElement(notice_center_1.NoticeCenter, null),
385
414
  React.createElement(link_dialog_1.LinkDialog, null),
@@ -404,19 +433,44 @@ function AppShell() {
404
433
  }
405
434
  };
406
435
  const discoverView = (leading) => (React.createElement(discover_view_1.DiscoverView, { pages: navigation.discover, onOpen: openDiscovered, onPin: pinDiscovered, onSettings: () => openSettings('navigation'), leading: leading }));
436
+ // A held entry of the navigation talks, without a menu: the double opens and its box listens, the chats open a
437
+ // new conversation whose box does; letting go gives what was said (HeldTalk). Nowhere to talk, they are a tap.
438
+ const talkHold = (place, open) => ({
439
+ start: () => {
440
+ open();
441
+ held_talk_1.HeldTalk.hold(place);
442
+ },
443
+ move: held_talk_1.HeldTalk.point,
444
+ end: held_talk_1.HeldTalk.release,
445
+ cancel: held_talk_1.HeldTalk.cancel,
446
+ });
447
+ const holds = voice_1.Voice.canListen()
448
+ ? {
449
+ double: talkHold('double', () => {
450
+ showPage(doubleId);
451
+ // Over the tabs when a sidebar view lists the double; as a tab of its own elsewhere.
452
+ if (phone) {
453
+ setScreenOpen(!navigation.home);
454
+ }
455
+ }),
456
+ chats: talkHold('draft', () => {
457
+ void chat.draft();
458
+ picked();
459
+ }),
460
+ }
461
+ : {};
407
462
  const tabs = phone
408
463
  ? (0, nav_places_1.phoneTabs)(lists, navigation, {
409
464
  discover: t('ta.discover'),
410
465
  me: t('ta.me'),
411
466
  fold: t('ta.nav.fold'),
412
467
  settings: { label: t('ta.nav.settings'), run: () => openSettings('navigation') },
468
+ holds,
413
469
  })
414
470
  : [];
415
- const tab = tabPage === 'me' ? nav_places_1.ME_TAB : tabPage === 'discover' ? nav_places_1.DISCOVER : ((_c = tabView === null || tabView === void 0 ? void 0 : tabView.id) !== null && _c !== void 0 ? _c : side);
471
+ const tab = tabPage === 'me' ? nav_places_1.ME_TAB : tabPage === 'discover' ? nav_places_1.DISCOVER : ((_g = tabView === null || tabView === void 0 ? void 0 : tabView.id) !== null && _g !== void 0 ? _g : side);
416
472
  // The launcher and the board are over the first tab only, as WeChat's over its chats.
417
- const firstTab = ((_b = tabs[0]) === null || _b === void 0 ? void 0 : _b.id) === tab;
418
- // A page of the screen, and those in the background beside it, kept as they were.
419
- const screenPage = settings === undefined && view && !tabView ? view : undefined;
473
+ const firstTab = ((_d = tabs[0]) === null || _d === void 0 ? void 0 : _d.id) === tab;
420
474
  const content = phone ? (React.createElement(phone_shell_1.PhoneShell, { tabs: tabs, tab: tab, launcher: firstTab && surfaces.launcher ? React.createElement(launcher_surface_1.LauncherSurface, { active: surface === 'launcher' }) : undefined, board: firstTab && surfaces.board ? (React.createElement(board_1.BoardSurface, { leading: React.createElement(icon_1.IconButton, { icon: lucide_react_1.ChevronLeft, label: t('ta.back'), onClick: () => setSurface(undefined) }) })) : undefined, surface: surface, onSurface: setSurface, onTab: id => {
421
475
  var _a;
422
476
  setSurface(undefined);
@@ -438,11 +492,11 @@ function AppShell() {
438
492
  settings !== undefined ? (React.createElement(settings_view_1.SettingsView, { key: settingsOpened, section: settings || undefined, onClose: closeSettings, onBack: closeSettings })) : screenPage ? null : (React.createElement(chat_view_1.ChatView, { widgets: extensions.widgets, onMenu: closeScreen, back: true }))), screenOpen: screenOpen, onBack: closeScreen, workbench: editors && !settingsShown ? (React.createElement("div", { className: "ta-editors-pane", inert: !showEditors }, editorArea)) : undefined, workbenchOpen: showEditors, onWorkbench: open => (open ? toggleWorkbench() : showEditors && toggleRight()) }, overlays)) : (React.createElement("div", { className: classes.filter(Boolean).join(' '), style: sideWidths },
439
493
  navOpen && React.createElement("button", { type: "button", className: "ta-scrim", "aria-label": t('ta.close'), onClick: () => setNavOpen(false) }),
440
494
  React.createElement("div", { className: "ta-nav" },
441
- React.createElement(app_nav_1.Rail, { lists: lists, list: sideShown ? side : undefined, onList: showList, navigation: navigation, current: tabPage === 'discover' || (view && navigation.discover.includes(view)) ? nav_places_1.DISCOVER : ((_d = view === null || view === void 0 ? void 0 : view.id) !== null && _d !== void 0 ? _d : ''), onPage: showPage, onDiscover: () => {
495
+ React.createElement(app_nav_1.Rail, { lists: lists, list: sideShown ? side : undefined, onList: showList, navigation: navigation, current: tabPage === 'discover' || (view && navigation.discover.includes(view)) ? nav_places_1.DISCOVER : ((_h = view === null || view === void 0 ? void 0 : view.id) !== null && _h !== void 0 ? _h : ''), onPage: showPage, onDiscover: () => {
442
496
  setSettings(undefined);
443
497
  setNavOpen(false);
444
498
  setTabPage('discover');
445
- }, onSettings: openSettings, settingsShown: settings !== undefined, surfaces: surfaces, surface: surface, onSurface: setSurface }),
499
+ }, onSettings: openSettings, settingsShown: settings !== undefined, surfaces: surfaces, surface: surface, onSurface: setSurface, holds: holds }),
446
500
  sideShown && (React.createElement("div", { className: "ta-sidebar", style: (0, split_pane_1.paneStyle)(sidebar) },
447
501
  sideView ? React.createElement(app_nav_1.SidebarView, { view: sideView }) : chats,
448
502
  React.createElement(split_pane_1.Sash, { pane: sidebar, side: "start", label: t('ta.layout.sidebar') })))),
@@ -39,6 +39,8 @@ export declare const BY_DIRECTORY: StateSpec<boolean>;
39
39
  export declare const FOLDED: StateSpec<string[]>;
40
40
  export declare namespace ChatListUtil {
41
41
  function isOpen(entry: ChatEntry): entry is TaSessionInfo;
42
+ /** Whether it is the double's own conversation: its session, or before that is open its file. */
43
+ function isDouble(entry: ChatEntry, double: Pick<ChatListDouble, 'session' | 'sessionFile'>): boolean;
42
44
  /** The id of an open session, the file of a saved one. */
43
45
  function key(entry: ChatEntry): string;
44
46
  /**
@@ -64,15 +66,31 @@ export declare namespace ChatListUtil {
64
66
  /** `19:59` today, `11/8` before. */
65
67
  function clock(time: number, now: number): string;
66
68
  function title(session: ChatEntry, t: Translate): string;
69
+ /**
70
+ * Whether a row shows the same: what of its conversation and its place it shows, and the rest as is. The list
71
+ * reads the conversations again every few seconds into new objects: one that answers draws its row again, not every row.
72
+ */
73
+ function sameRow<T extends {
74
+ session: ChatEntry;
75
+ source: ChatSource;
76
+ }>(before: T, after: T): boolean;
77
+ /** What a row says under its title: the last thing said, unless it is the title again. */
78
+ function preview(session: ChatEntry, title: string): string | undefined;
67
79
  /** The first letter of a name, for its avatar. */
68
80
  function initial(name: string): string;
69
81
  }
82
+ /** What a task of the double came to, as the list says it beside the conversation. */
83
+ export type ChatTaskStatus = 'running' | 'done' | 'failed' | 'stopped';
70
84
  /** The double, for the list: which conversations are its tasks, and how to hand it one. */
71
85
  export interface ChatListDouble {
72
- /** The sessions of its tasks. */
73
- tasks: ReadonlySet<string>;
86
+ /** The sessions of its tasks, and where each is. */
87
+ tasks: ReadonlyMap<string, ChatTaskStatus>;
74
88
  /** Its own conversation. */
75
89
  session?: string;
90
+ /** The file of its own conversation: it is known before the conversation opens (and without the computer). */
91
+ sessionFile?: string;
92
+ /** What the user calls it. */
93
+ name: string;
76
94
  hand(session: TaSessionInfo, title: string): void;
77
95
  }
78
96
  export interface ChatListProps {
@@ -39,6 +39,7 @@ const ta_protocol_1 = require("@celljs/ta-protocol");
39
39
  const lucide_react_1 = require("lucide-react");
40
40
  const React = __importStar(require("react"));
41
41
  const device_1 = require("../device/device");
42
+ const extension_view_1 = require("../extension/extension-view");
42
43
  const use_t_1 = require("../i18n/use-t");
43
44
  const state_protocol_1 = require("../state/state-protocol");
44
45
  const message_1 = require("../util/message");
@@ -47,6 +48,7 @@ const empty_state_1 = require("./empty-state");
47
48
  const host_tag_1 = require("./host-tag");
48
49
  const icon_1 = require("./icon");
49
50
  const swipe_row_1 = require("./swipe-row");
51
+ const ta_avatar_1 = require("./ta-avatar");
50
52
  /** The list by directory or package, else by day; in any browser. */
51
53
  /** By day unless the user groups them: directories nest a list, and the remote ones are marked anyway (HostTag). */
52
54
  exports.BY_DIRECTORY = { key: 'chat.byDirectory', tier: 'user', initial: false, parse: state_protocol_1.StateUtil.boolean };
@@ -65,6 +67,11 @@ var ChatListUtil;
65
67
  return 'sessionId' in entry;
66
68
  }
67
69
  ChatListUtil.isOpen = isOpen;
70
+ /** Whether it is the double's own conversation: its session, or before that is open its file. */
71
+ function isDouble(entry, double) {
72
+ return isOpen(entry) && (entry.sessionId === double.session || (!!double.sessionFile && entry.sessionFile === double.sessionFile));
73
+ }
74
+ ChatListUtil.isDouble = isDouble;
68
75
  /** The id of an open session, the file of a saved one. */
69
76
  function key(entry) {
70
77
  return isOpen(entry) ? entry.sessionId : entry.sessionFile;
@@ -191,6 +198,42 @@ var ChatListUtil;
191
198
  return session.sessionName || session.firstMessage || t('ta.chat.new');
192
199
  }
193
200
  ChatListUtil.title = title;
201
+ /**
202
+ * Whether a row shows the same: what of its conversation and its place it shows, and the rest as is. The list
203
+ * reads the conversations again every few seconds into new objects: one that answers draws its row again, not every row.
204
+ */
205
+ function sameRow(before, after) {
206
+ const a = before.session;
207
+ const b = after.session;
208
+ const sameSession = a === b ||
209
+ (key(a) === key(b) &&
210
+ a.sessionName === b.sessionName &&
211
+ a.firstMessage === b.firstMessage &&
212
+ a.lastMessage === b.lastMessage &&
213
+ a.updatedAt === b.updatedAt &&
214
+ a.cwd === b.cwd &&
215
+ a.group === b.group &&
216
+ (isOpen(a) && a.isStreaming) === (isOpen(b) && b.isStreaming));
217
+ const x = before.source;
218
+ const y = after.source;
219
+ const sameSource = x === y || (x.key === y.key && x.label === y.label && x.title === y.title && x.host === y.host && x.initial === y.initial && x.tone === y.tone);
220
+ if (!sameSession || !sameSource) {
221
+ return false;
222
+ }
223
+ for (const name of Object.keys(after)) {
224
+ if (name !== 'session' && name !== 'source' && before[name] !== after[name]) {
225
+ return false;
226
+ }
227
+ }
228
+ return Object.keys(before).length === Object.keys(after).length;
229
+ }
230
+ ChatListUtil.sameRow = sameRow;
231
+ /** What a row says under its title: the last thing said, unless it is the title again. */
232
+ function preview(session, title) {
233
+ const last = session.lastMessage;
234
+ return last && last !== title ? last : undefined;
235
+ }
236
+ ChatListUtil.preview = preview;
194
237
  /** The first letter of a name, for its avatar. */
195
238
  function initial(name) {
196
239
  const letter = [...name].find(char => /[\p{L}\p{N}]/u.test(char));
@@ -207,9 +250,49 @@ function useMinute() {
207
250
  }, []);
208
251
  return now;
209
252
  }
210
- function ChatItem({ session, source, selected, now, compact, onSelect, onRemove, onRestore, doubleTask, onHand }) {
253
+ /**
254
+ * The avatar of a row: the face of the double for its own conversation, the face an extension draws for its
255
+ * agents (registerAvatar), else the letter of its directory. A face works while the conversation answers.
256
+ */
257
+ function ChatAvatar({ session, source, who, size, mood }) {
258
+ var _a;
259
+ const avatars = React.useContext(extension_view_1.SessionAvatars);
260
+ const letter = (React.createElement("span", { className: `ta-chat-avatar ta-tone-${source.tone}`, "aria-hidden": "true" }, source.initial));
261
+ if ((who === null || who === void 0 ? void 0 : who.kind) === 'double') {
262
+ return React.createElement(ta_avatar_1.DinoFace, { className: "ta-chat-face", mood: mood, size: size });
263
+ }
264
+ const Avatar = who && ChatListUtil.isOpen(session) && session.group ? avatars[session.group] : undefined;
265
+ if (!Avatar || !ChatListUtil.isOpen(session)) {
266
+ return letter;
267
+ }
268
+ return (React.createElement("span", { className: "ta-chat-face", style: { width: size, height: size }, "aria-hidden": "true" },
269
+ React.createElement(extension_view_1.ExtensionBoundary, { name: (_a = session.group) !== null && _a !== void 0 ? _a : '', resetKey: Avatar, fallback: letter },
270
+ React.createElement(Avatar, { session: session, mood: mood, size: size }))));
271
+ }
272
+ /** What goes on in it, on the line of a row of one line: answering now, or how the double's task ended. */
273
+ function ChatState({ streaming, task }) {
274
+ const t = (0, use_t_1.useT)();
275
+ if (streaming) {
276
+ return (React.createElement("span", { className: "ta-chat-state" },
277
+ React.createElement("span", { className: "ta-spinner" })));
278
+ }
279
+ if (task === 'failed' || task === 'stopped') {
280
+ return (React.createElement("span", { className: `ta-chat-state ta-${task}` },
281
+ React.createElement("span", { className: `ta-status ${task === 'failed' ? 'ta-status-error' : 'ta-status-cancelled'}` }),
282
+ t(task === 'failed' ? 'ta.task.failed' : 'ta.task.stopped')));
283
+ }
284
+ return null;
285
+ }
286
+ const ChatItem = React.memo(function ChatItem({ session, source, selected, time, compact, actions, restorable, task, doubleName, handable }) {
211
287
  const t = (0, use_t_1.useT)();
212
- const title = ChatListUtil.title(session, t);
288
+ const onSelect = () => actions.open(session);
289
+ const onRemove = () => actions.remove(session);
290
+ const onRestore = restorable ? () => actions.restore(session) : undefined;
291
+ const onHand = handable ? () => actions.hand(session) : undefined;
292
+ const avatars = React.useContext(extension_view_1.SessionAvatars);
293
+ // The double's conversation is named after it; an agent's has its name (the extension named it so).
294
+ const who = doubleName !== undefined ? { kind: 'double', name: doubleName } : session.group && avatars[session.group] ? { kind: 'agent' } : undefined;
295
+ const title = (who === null || who === void 0 ? void 0 : who.kind) === 'double' ? who.name : ChatListUtil.title(session, t);
213
296
  // Held, a row offers what its hover does (its close button shows only on the row shown, on a phone).
214
297
  const [menu, openMenu] = (0, context_menu_1.useContextMenu)();
215
298
  const onContextMenu = (event) => openMenu(event, [
@@ -217,33 +300,48 @@ function ChatItem({ session, source, selected, now, compact, onSelect, onRemove,
217
300
  ...(onHand ? [{ label: t('ta.chat.handToDouble'), run: onHand }] : []),
218
301
  onRestore ? { label: t('ta.chat.restore'), run: onRestore } : { label: t('ta.chat.remove'), run: () => onRemove === null || onRemove === void 0 ? void 0 : onRemove() },
219
302
  ]);
220
- const tag = doubleTask && (React.createElement("span", { className: "ta-double-tag", title: t('ta.chat.doubleTagTitle') }, t('ta.chat.doubleTag')));
303
+ const tag = task && (React.createElement("span", { className: "ta-double-tag", title: t('ta.chat.doubleTagTitle') }, t('ta.chat.doubleTag')));
221
304
  // On a phone, as in its messaging apps, a swipe to the left shows what its hover does behind the row.
222
305
  const handheld = (0, device_1.useDevice)(device => device.handheld);
223
306
  const swipe = onRestore
224
307
  ? { key: 'restore', label: t('ta.chat.restoreShort'), run: onRestore }
225
308
  : { key: 'remove', label: t('ta.chat.removeShort'), danger: true, run: () => onRemove === null || onRemove === void 0 ? void 0 : onRemove() };
226
309
  const streaming = ChatListUtil.isOpen(session) && session.isStreaming;
227
- return (React.createElement(swipe_row_1.SwipeRow, { as: "li", className: `ta-chat-row${selected ? ' ta-selected' : ''}`, actions: [swipe], overlay: menu, onContextMenu: onContextMenu },
310
+ const mood = streaming ? 'working' : 'idle';
311
+ const state = React.createElement(ChatState, { streaming: streaming, task: task });
312
+ // As in a messaging app, the last thing said; its directory before the first, and on hover in place of its time.
313
+ const said = ChatListUtil.preview(session, title);
314
+ const place = who ? message_1.MessageUtil.basename(session.cwd) : source.label;
315
+ const ended = task === 'failed' || task === 'stopped' ? task : undefined;
316
+ return (React.createElement(swipe_row_1.SwipeRow, { as: "li", className: `ta-chat-row${selected ? ' ta-selected' : ''}${who ? ` ta-chat-${who.kind}` : ''}`, actions: [swipe], overlay: menu, onContextMenu: onContextMenu },
228
317
  React.createElement("button", { type: "button", className: `ta-chat-item${compact ? ' ta-compact' : ''}`, title: `${title}\n${source.title}`, "aria-current": selected ? 'true' : undefined, onClick: onSelect }, compact ? (React.createElement("span", { className: "ta-chat-text" },
229
318
  React.createElement("span", { className: "ta-chat-line" },
319
+ who && React.createElement(ChatAvatar, { session: session, source: source, who: who, size: 20, mood: mood }),
230
320
  tag,
231
321
  React.createElement("span", { className: "ta-chat-title" }, title),
232
- streaming && React.createElement("span", { className: "ta-spinner" }),
233
- React.createElement("span", { className: "ta-chat-time" }, ChatListUtil.clock(session.updatedAt, now))))) : (React.createElement(React.Fragment, null,
234
- React.createElement("span", { className: `ta-chat-avatar ta-tone-${source.tone}`, "aria-hidden": "true" }, source.initial),
322
+ state,
323
+ React.createElement("span", { className: "ta-chat-time" }, time)))) : (React.createElement(React.Fragment, null,
324
+ React.createElement(ChatAvatar, { session: session, source: source, who: who, size: 38, mood: mood }),
235
325
  React.createElement("span", { className: "ta-chat-text" },
236
326
  React.createElement("span", { className: "ta-chat-line" },
237
327
  tag,
238
328
  React.createElement("span", { className: "ta-chat-title" }, title),
239
- React.createElement("span", { className: "ta-chat-time" }, ChatListUtil.clock(session.updatedAt, now))),
329
+ React.createElement("span", { className: "ta-chat-time" }, time),
330
+ React.createElement("span", { className: "ta-chat-place" },
331
+ React.createElement(icon_1.Icon, { icon: lucide_react_1.Folder, size: 12 }),
332
+ React.createElement("span", null, place))),
240
333
  React.createElement("span", { className: "ta-chat-line" },
241
334
  React.createElement("span", { className: "ta-chat-sub" },
242
335
  React.createElement(host_tag_1.HostTag, { host: source.host }),
243
- source.label),
244
- streaming && React.createElement("span", { className: "ta-spinner" })))))),
336
+ ended && !streaming && (React.createElement("span", { className: `ta-chat-flag ta-${ended}` },
337
+ "[",
338
+ t(ended === 'failed' ? 'ta.task.failed' : 'ta.task.stopped'),
339
+ "]")), said !== null && said !== void 0 ? said : (React.createElement("span", { className: "ta-chat-dir" },
340
+ React.createElement(icon_1.Icon, { icon: lucide_react_1.Folder, size: 12 }),
341
+ place))),
342
+ streaming && React.createElement("span", { className: "ta-chat-state ta-spinner" })))))),
245
343
  handheld ? null : onRestore ? (React.createElement(icon_1.IconButton, { className: "ta-chat-delete", icon: lucide_react_1.Undo2, label: t('ta.chat.restore'), onClick: onRestore })) : (React.createElement(icon_1.IconButton, { className: "ta-chat-delete", icon: lucide_react_1.Trash2, label: t('ta.sidebar.closeTitle'), onClick: onRemove }))));
246
- }
344
+ }, ChatListUtil.sameRow);
247
345
  /**
248
346
  * The conversations of the server, open or saved, the latest first, with a search and `+` for a new one:
249
347
  * by directory or package, each group folding and with a `+` of its own, or by day. Those taken out are at
@@ -254,24 +352,42 @@ function ChatList({ sessions, saved, removed: removedFiles, selected, chat, byDi
254
352
  const now = useMinute();
255
353
  const [query, setQuery] = React.useState('');
256
354
  const [removedOpen, setRemovedOpen] = React.useState(false);
355
+ // What the rows do reads the props of now, through one object that stays the same: no row is drawn again for it.
356
+ const latest = React.useRef({ chat, double, onPicked, t });
357
+ latest.current = { chat, double, onPicked, t };
358
+ const actions = React.useMemo(() => {
359
+ const pick = (change) => {
360
+ void change;
361
+ latest.current.onPicked();
362
+ };
363
+ return {
364
+ open: entry => pick(ChatListUtil.isOpen(entry) ? latest.current.chat.show(entry.sessionId) : latest.current.chat.resume(entry.sessionFile)),
365
+ remove: entry => void latest.current.chat.remove(entry),
366
+ restore: entry => void latest.current.chat.restore(ChatListUtil.key(entry)),
367
+ hand: entry => {
368
+ var _a;
369
+ if (ChatListUtil.isOpen(entry)) {
370
+ (_a = latest.current.double) === null || _a === void 0 ? void 0 : _a.hand(entry, ChatListUtil.title(entry, latest.current.t));
371
+ }
372
+ },
373
+ };
374
+ }, []);
257
375
  // A failure is a notice of the chat.
258
376
  const pick = (change) => {
259
377
  void change;
260
378
  onPicked();
261
379
  };
262
- const { listed, removed } = ChatListUtil.entries(sessions, saved, removedFiles);
263
- const sources = ChatListUtil.sources(listed);
264
- const shown = ChatListUtil.filter(listed, query, t);
265
- const shownRemoved = ChatListUtil.filter(removed, query, t);
380
+ // Worked out again only when the conversations or the search change, not as the minute or the selection does.
381
+ const { listed, removed } = React.useMemo(() => ChatListUtil.entries(sessions, saved, removedFiles), [sessions, saved, removedFiles]);
382
+ const sources = React.useMemo(() => ChatListUtil.sources(listed), [listed]);
383
+ const shown = React.useMemo(() => ChatListUtil.filter(listed, query, t), [listed, query, t]);
384
+ const shownRemoved = React.useMemo(() => ChatListUtil.filter(removed, query, t), [removed, query, t]);
266
385
  // What a search finds is one list by day, wherever it is.
267
386
  const grouped = byDirectory && sources.length > 1 && !query.trim();
268
- const open = (entry) => pick(ChatListUtil.isOpen(entry) ? chat.show(entry.sessionId) : chat.resume(entry.sessionFile));
269
387
  const draftIn = (cwd) => pick(chat.draft().then(() => chat.setDraftCwd(cwd)));
270
388
  const fold = (key) => onFolded(folded.includes(key) ? folded.filter(other => other !== key) : [...folded, key]);
271
- const byKey = new Map([...sources, ...ChatListUtil.sources(removed)].map(candidate => [candidate.key, candidate]));
272
- const item = (session, compact) => (React.createElement(ChatItem, { key: ChatListUtil.key(session), session: session, source: byKey.get(ChatListUtil.sourceKey(session)), selected: ChatListUtil.key(session) === selected, now: now, compact: compact, onSelect: () => open(session), onRemove: () => void chat.remove(session), doubleTask: ChatListUtil.isOpen(session) && !!(double === null || double === void 0 ? void 0 : double.tasks.has(session.sessionId)), onHand: double && ChatListUtil.isOpen(session) && !session.group && !double.tasks.has(session.sessionId) && session.sessionId !== double.session
273
- ? () => double.hand(session, ChatListUtil.title(session, t))
274
- : undefined }));
389
+ const byKey = React.useMemo(() => new Map([...sources, ...ChatListUtil.sources(removed)].map(candidate => [candidate.key, candidate])), [sources, removed]);
390
+ const item = (session, compact) => (React.createElement(ChatItem, { key: ChatListUtil.key(session), session: session, source: byKey.get(ChatListUtil.sourceKey(session)), selected: ChatListUtil.key(session) === selected, time: ChatListUtil.clock(session.updatedAt, now), compact: compact, actions: actions, task: ChatListUtil.isOpen(session) ? double === null || double === void 0 ? void 0 : double.tasks.get(session.sessionId) : undefined, doubleName: double && ChatListUtil.isDouble(session, double) ? double.name : undefined, handable: !!double && ChatListUtil.isOpen(session) && !session.group && !double.tasks.has(session.sessionId) && !ChatListUtil.isDouble(session, double) }));
275
391
  // The conversation shown is found in the list, however it came to be shown: out of a search that hides it, and scrolled to.
276
392
  const scroller = React.useRef(null);
277
393
  const reveal = React.useRef(false);
@@ -324,6 +440,6 @@ function ChatList({ sessions, saved, removed: removedFiles, selected, chat, byDi
324
440
  React.createElement("button", { type: "button", className: "ta-chat-section-title ta-chat-removed-toggle", "aria-expanded": removedOpen, onClick: () => setRemovedOpen(!removedOpen) },
325
441
  React.createElement(icon_1.Icon, { icon: lucide_react_1.ChevronRight, size: 13 }),
326
442
  t('ta.chat.removed', { count: shownRemoved.length })),
327
- removedOpen && (React.createElement("ul", { className: "ta-side-list" }, shownRemoved.map(session => (React.createElement(ChatItem, { key: ChatListUtil.key(session), session: session, source: byKey.get(ChatListUtil.sourceKey(session)), selected: false, now: now, onSelect: () => open(session), onRestore: () => chat.restore(ChatListUtil.key(session)) }))))))))));
443
+ removedOpen && (React.createElement("ul", { className: "ta-side-list" }, shownRemoved.map(session => (React.createElement(ChatItem, { key: ChatListUtil.key(session), session: session, source: byKey.get(ChatListUtil.sourceKey(session)), selected: false, time: ChatListUtil.clock(session.updatedAt, now), actions: actions, restorable: true }))))))))));
328
444
  }
329
445
  //# sourceMappingURL=chat-list.js.map