@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
@@ -1,18 +1,21 @@
1
1
  import { Compass, Grip, LayoutDashboard, PanelTop } from 'lucide-react';
2
2
  import * as React from 'react';
3
3
  import { useDevice } from '../device/device.js';
4
+ import { useHeld } from '../device/hold.js';
4
5
  import { ExtensionBoundary } from '../extension/extension-view.js';
5
6
  import { WebLabelUtil } from '../extension/web-extension-protocol.js';
6
7
  import { useSettings, useWorkbench } from '../hooks.js';
7
8
  import { useT } from '../i18n/use-t.js';
9
+ import { ShortcutUtil } from '../settings/agent-settings.js';
8
10
  import { NavigationUtil } from '../settings/navigation.js';
9
11
  import { AccountMenu } from './account-menu.js';
10
12
  import { ConnectionBanner } from './connection-bar.js';
11
13
  import { useContextMenu } from './context-menu.js';
12
14
  import { Dino } from './dino.js';
13
- import { DISCOVER, places } from './nav-places.js';
15
+ import { SidebarRight } from './icon.js';
16
+ import { DISCOVER, entryHold, places } from './nav-places.js';
14
17
  import { DinoFace } from './ta-avatar.js';
15
- import { WorkbenchToggle } from './workbench-toggle.js';
18
+ import { WorkbenchToggle, WorkbenchToggleContext } from './workbench-toggle.js';
16
19
  /* The navigation of the app: the rail, a sidebar view, a page of the main area. */
17
20
  /** Where the pages of the rail go on this device: a phone has the room its tabs leave. */
18
21
  export function useNavigation(views) {
@@ -28,36 +31,42 @@ export function useNavigation(views) {
28
31
  update,
29
32
  };
30
33
  }
31
- function RailItem({ label, active, onClick, onContextMenu, children }) {
32
- 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));
34
+ function RailItem({ label, active, onClick, onContextMenu, onPointerDown, 'data-held': held, children }) {
35
+ 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));
33
36
  }
34
37
  /**
35
38
  * The navigation on the left, as the tabs of a phone: the logo; the lists of the sidebar; the pages, and Discover
36
- * once some are under it; the account with the settings at the bottom. A page's menu (a right click) puts it under Discover.
39
+ * once some are under it; the account with the settings at the bottom. A page's menu (a right click) puts it under
40
+ * Discover; that of the double talks to it, and that of the chats opens a new one (entryMenu).
37
41
  */
38
- export function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface }) {
42
+ export function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, }) {
39
43
  const t = useT();
40
44
  const [{ server }] = useWorkbench();
41
45
  const [menu, openMenu] = useContextMenu();
46
+ const held = useHeld();
42
47
  const settingsItem = { label: t('ta.nav.settings'), run: () => onSettings('navigation') };
43
- /** A page of the rail; the double's (`double`) is its face and stays out of Discover. */
48
+ /** A page of the rail; the double's (`double`) is its face and stays out of Discover, and talks while it is held. */
44
49
  const item = (view, foldable = true, double = false) => {
45
50
  var _a;
46
51
  const Glyph = (_a = view.icon) !== null && _a !== void 0 ? _a : PanelTop;
47
- return (React.createElement(RailItem, { key: view.id, label: 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(DinoFace, { size: 24, className: "ta-nav-face" }) : React.createElement(Glyph, { size: 20, strokeWidth: 1.6 })));
52
+ return (React.createElement(RailItem, { key: view.id, label: 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(DinoFace, { size: 24, className: "ta-nav-face" }) : React.createElement(Glyph, { size: 20, strokeWidth: 1.6 })));
48
53
  };
49
54
  const discover = navigation.discover.length > 0 || current === DISCOVER;
55
+ // The workbench from anywhere, a page or the settings too, as the launcher and the board.
56
+ const workbench = React.useContext(WorkbenchToggleContext);
50
57
  return (React.createElement("nav", { className: "ta-rail", "aria-label": t('ta.menu') },
51
58
  React.createElement("div", { className: "ta-rail-logo", title: server ? `Ta v${server.version}` : 'Ta' },
52
59
  React.createElement(Dino, { size: 26 })),
53
60
  React.createElement("div", { className: "ta-rail-items" },
54
61
  navigation.home && item(navigation.home, false, true),
55
- lists.map(entry => (React.createElement(RailItem, { key: entry.id, label: entry.label, active: list === entry.id, onClick: () => onList(entry.id) }, entry.double ? React.createElement(DinoFace, { size: 24, className: "ta-nav-face" }) : React.createElement(entry.icon, { size: 20, strokeWidth: 1.6 })))),
62
+ lists.map(entry => (React.createElement(RailItem, { key: entry.id, label: entry.label, active: list === entry.id, onClick: () => onList(entry.id), ...held(entryHold(entry.id, entry.double, holds)) }, entry.double ? React.createElement(DinoFace, { size: 24, className: "ta-nav-face" }) : React.createElement(entry.icon, { size: 20, strokeWidth: 1.6 })))),
56
63
  (navigation.nav.length > 0 || discover) && React.createElement("hr", { className: "ta-rail-divider" }),
57
64
  navigation.nav.map(view => item(view)),
58
65
  discover && (React.createElement(RailItem, { label: t('ta.discover'), active: !settingsShown && current === DISCOVER, onClick: onDiscover, onContextMenu: event => openMenu(event, [settingsItem]) },
59
66
  React.createElement(Compass, { size: 20, strokeWidth: 1.6 })))),
60
- (surfaces.launcher || surfaces.board) && (React.createElement("div", { className: "ta-rail-tools" },
67
+ (workbench || surfaces.launcher || surfaces.board) && (React.createElement("div", { className: "ta-rail-tools" },
68
+ workbench && (React.createElement(RailItem, { label: `${t('ta.workbench')} (${ShortcutUtil.keys('Mod+J').join(ShortcutUtil.isMac() ? '' : '+')})`, active: workbench.open, onClick: workbench.toggle },
69
+ React.createElement(SidebarRight, { size: 20, strokeWidth: 1.6 }))),
61
70
  surfaces.launcher && (React.createElement(SurfaceButton, { label: t('ta.launcher'), active: surface === 'launcher', onClick: () => onSurface(surface === 'launcher' ? undefined : 'launcher') },
62
71
  React.createElement(Grip, { size: 20, strokeWidth: 1.6 }))),
63
72
  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
@@ -49,8 +49,8 @@ export function useRight() {
49
49
  // `set` is stable, so `reveal` is too: effects may depend on it.
50
50
  return [open, toggle, reveal, uncover];
51
51
  }
52
- /** Cmd/Ctrl+B shows or hides the sidebar and Cmd/Ctrl+, opens the settings, as in an IDE. */
53
- export function useKeys(toggle, openSettings) {
52
+ /** Cmd/Ctrl+B shows or hides the sidebar, Cmd/Ctrl+J the workbench, and Cmd/Ctrl+, opens the settings, as in an IDE. */
53
+ export function useKeys(toggle, openSettings, toggleWorkbench) {
54
54
  React.useEffect(() => {
55
55
  const onKey = (event) => {
56
56
  if (!(event.metaKey || event.ctrlKey) || event.shiftKey || event.altKey) {
@@ -65,10 +65,14 @@ export function useKeys(toggle, openSettings) {
65
65
  event.preventDefault();
66
66
  openSettings();
67
67
  }
68
+ else if (key === 'j') {
69
+ event.preventDefault();
70
+ toggleWorkbench();
71
+ }
68
72
  };
69
73
  window.addEventListener('keydown', onKey);
70
74
  return () => window.removeEventListener('keydown', onKey);
71
- }, [toggle, openSettings]);
75
+ }, [toggle, openSettings, toggleWorkbench]);
72
76
  }
73
77
  /**
74
78
  * The installed app with its title bar hidden draws the bar itself (see .ta-titlebar), but the browser
@@ -1,3 +1,4 @@
1
+ import { useInject } from '@celljs/react';
1
2
  import { ChevronLeft } from 'lucide-react';
2
3
  import * as React from 'react';
3
4
  import { AssistantChatList } from '../assistant/assistant-chat-list.js';
@@ -6,9 +7,12 @@ import { ChatView, useChat } from '../chat/chat-view.js';
6
7
  import { useDevice } from '../device/device.js';
7
8
  import { LaunchScreenUtil } from '../device/launch-screen.js';
8
9
  import { MessageRenderers, SessionAvatars } from '../extension/extension-view.js';
10
+ import { WebCwdUtil } from '../extension/web-extension-protocol.js';
11
+ import { TaFiles } from '../files/files-protocol.js';
9
12
  import { useOpenLink, usePersisted, useSettings, useWebExtensions, useWorkbench } from '../hooks.js';
10
13
  import { useT } from '../i18n/use-t.js';
11
14
  import { SIGN_IN_EVENT } from '../notices/notices.js';
15
+ import { Voice } from '../util/voice.js';
12
16
  import { PageView, Rail, SidebarView, useNavigation } from './app-nav.js';
13
17
  import { CARDS_ID, EDITOR, FIRST_SIDE, LOGIN_LATER, RAIL, SIDE, SIDEBAR, useDrawerSwipe, useKeys, useRefresh, useRight, useTitlebarColor, useWorkbenchCards, } from './app-shell-hooks.js';
14
18
  import { AuthUtil, LoginPage, useAuthProviders } from './auth-view.js';
@@ -19,6 +23,7 @@ import { DinoLookHost, DinoLookProvider } from './dino-look.js';
19
23
  import { DiscoverView } from './discover-view.js';
20
24
  import { EditorArea } from './editor-area.js';
21
25
  import { EnvironmentPage } from './environment-view.js';
26
+ import { HeldTalk } from './held-talk.js';
22
27
  import { SwitchingVeil } from './host-view.js';
23
28
  import { IconButton, SidebarLeft } from './icon.js';
24
29
  import { KeptPages } from './kept-pages.js';
@@ -33,7 +38,7 @@ import { PhoneShell } from './phone-shell.js';
33
38
  import { RemotePrompts } from './remote-prompts.js';
34
39
  import { SettingsView } from './settings-view.js';
35
40
  import { ShareHost } from './share-dialog.js';
36
- import { SideListUtil } from './side-lists.js';
41
+ import { DOUBLE_PAGE, SideListUtil } from './side-lists.js';
37
42
  import { paneStyle, Sash, usePane } from './split-pane.js';
38
43
  import { SurfaceFlyout } from './surface-flyout.js';
39
44
  import { WorkbenchToggleContext } from './workbench-toggle.js';
@@ -46,8 +51,8 @@ import { SignIn, useDocument } from './workbench-view.js';
46
51
  * the conversation instead.
47
52
  */
48
53
  function AppShell() {
49
- var _a, _b;
50
- var _c, _d;
54
+ var _a, _b, _c, _d;
55
+ var _e, _f, _g, _h;
51
56
  const t = useT();
52
57
  const [workbench, bench] = useWorkbench();
53
58
  const [extensions, host] = useWebExtensions();
@@ -98,7 +103,8 @@ function AppShell() {
98
103
  const editor = usePane(EDITOR);
99
104
  const online = workbench.status === 'online';
100
105
  // Files named in replies outside a conversation (channels, pages) are in the server's directory.
101
- const fileUrl = React.useCallback((path) => bench.workspace.fileUrl(path), [bench]);
106
+ const files = useInject(TaFiles);
107
+ const fileUrl = React.useCallback(async (path) => files.loadable(await bench.workspace.fileUrl(path)), [bench, files]);
102
108
  const openLink = useOpenLink(undefined);
103
109
  useDocument();
104
110
  useRefresh(online);
@@ -111,6 +117,16 @@ function AppShell() {
111
117
  React.useEffect(() => {
112
118
  void bench.start();
113
119
  }, [bench]);
120
+ // The computer cannot be reached from the start: the web extensions of the last time start anyway (from
121
+ // the code this device kept) and show what they read last; online, `chat.start` loads them.
122
+ const offline = workbench.status === 'offline';
123
+ const startedOffline = React.useRef(false);
124
+ React.useEffect(() => {
125
+ if (offline && !startedOffline.current) {
126
+ startedOffline.current = true;
127
+ void host.refresh().catch(() => undefined);
128
+ }
129
+ }, [offline, host]);
114
130
  /** The conversation the page opens with is shown: those shown after are the user's doing. */
115
131
  const started = React.useRef(false);
116
132
  React.useEffect(() => {
@@ -127,6 +143,8 @@ function AppShell() {
127
143
  if (focus > 0) {
128
144
  revealRight();
129
145
  revealEditor();
146
+ // Opened from the launcher or the board: the workbench comes in their place.
147
+ setSurface(undefined);
130
148
  }
131
149
  }, [focus, revealRight, revealEditor]);
132
150
  // A web extension shows another conversation: the conversation, not a page, a drawer or the workbench over it, is then in front.
@@ -223,6 +241,11 @@ function AppShell() {
223
241
  const railView = view && (view === navigation.home || navigation.pages.includes(view)) ? view : undefined;
224
242
  // 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.
225
243
  const tabView = view && (view === navigation.home || navigation.nav.includes(view)) ? view : undefined;
244
+ // A page of the screen, and those in the background beside it, kept as they were.
245
+ const screenPage = settings === undefined && view && !tabView ? view : undefined;
246
+ // The conversation in front, where the tools of the workbench follow its directory; else they are in the default one.
247
+ const conversationShown = phone ? screenOpen && settings === undefined && !screenPage : settings === undefined && tabPage !== 'discover' && !view;
248
+ React.useEffect(() => host.setConversationShown(conversationShown), [host, conversationShown]);
226
249
  const { pageShown } = extensions;
227
250
  // biome-ignore lint/correctness/useExhaustiveDependencies: follows the pages shown
228
251
  React.useEffect(() => {
@@ -286,7 +309,20 @@ function AppShell() {
286
309
  sidebar.reveal();
287
310
  }
288
311
  };
289
- useKeys(toggleSide, openSettings);
312
+ const toggleWorkbench = () => {
313
+ if (showEditors) {
314
+ toggleRight();
315
+ }
316
+ else {
317
+ // Over the settings of a wide screen (the rail, Cmd/Ctrl+J): they give way to what was under them.
318
+ if (!phone && settings !== undefined) {
319
+ setSettings(undefined);
320
+ }
321
+ revealRight();
322
+ editor.reveal();
323
+ }
324
+ };
325
+ useKeys(toggleSide, openSettings, () => editors && toggleWorkbench());
290
326
  useTitlebarColor(workbench.status !== 'signed-out', theme);
291
327
  const [providers, reloadProviders] = useAuthProviders(online);
292
328
  const [later, setLater] = usePersisted(LOGIN_LATER);
@@ -300,6 +336,8 @@ function AppShell() {
300
336
  window.addEventListener(SIGN_IN_EVENT, ask);
301
337
  return () => window.removeEventListener(SIGN_IN_EVENT, ask);
302
338
  }, [reloadProviders]);
339
+ /** The page of the double: its own, or the one a sidebar view that lists it opens. */
340
+ const doubleId = (_e = (_b = navigation.home) === null || _b === void 0 ? void 0 : _b.id) !== null && _e !== void 0 ? _e : DOUBLE_PAGE;
303
341
  if (workbench.status === 'signed-out') {
304
342
  return React.createElement(SignIn, { error: workbench.error });
305
343
  }
@@ -315,15 +353,6 @@ function AppShell() {
315
353
  reloadProviders();
316
354
  } }));
317
355
  }
318
- const toggleWorkbench = () => {
319
- if (showEditors) {
320
- toggleRight();
321
- }
322
- else {
323
- revealRight();
324
- editor.reveal();
325
- }
326
- };
327
356
  // What the columns beside the conversation and the editors take, so that the editors never take more than the conversation.
328
357
  const sideWidths = {
329
358
  '--ta-left': `${RAIL + (sideShown ? sidebar.size : 0)}px`,
@@ -343,7 +372,7 @@ function AppShell() {
343
372
  }
344
373
  };
345
374
  const chats = (React.createElement(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 }));
346
- const editorArea = (React.createElement(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) }));
375
+ const editorArea = (React.createElement(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 = WebCwdUtil.shown(extensions)) !== null && _f !== void 0 ? _f : (_c = workbench.server) === null || _c === void 0 ? void 0 : _c.cwd, maximized: maximized, onMaximize: () => setMaximized(!maximized) }));
347
376
  const overlays = (React.createElement(React.Fragment, null,
348
377
  React.createElement(NoticeCenter, null),
349
378
  React.createElement(LinkDialog, null),
@@ -368,19 +397,44 @@ function AppShell() {
368
397
  }
369
398
  };
370
399
  const discoverView = (leading) => (React.createElement(DiscoverView, { pages: navigation.discover, onOpen: openDiscovered, onPin: pinDiscovered, onSettings: () => openSettings('navigation'), leading: leading }));
400
+ // A held entry of the navigation talks, without a menu: the double opens and its box listens, the chats open a
401
+ // new conversation whose box does; letting go gives what was said (HeldTalk). Nowhere to talk, they are a tap.
402
+ const talkHold = (place, open) => ({
403
+ start: () => {
404
+ open();
405
+ HeldTalk.hold(place);
406
+ },
407
+ move: HeldTalk.point,
408
+ end: HeldTalk.release,
409
+ cancel: HeldTalk.cancel,
410
+ });
411
+ const holds = Voice.canListen()
412
+ ? {
413
+ double: talkHold('double', () => {
414
+ showPage(doubleId);
415
+ // Over the tabs when a sidebar view lists the double; as a tab of its own elsewhere.
416
+ if (phone) {
417
+ setScreenOpen(!navigation.home);
418
+ }
419
+ }),
420
+ chats: talkHold('draft', () => {
421
+ void chat.draft();
422
+ picked();
423
+ }),
424
+ }
425
+ : {};
371
426
  const tabs = phone
372
427
  ? phoneTabs(lists, navigation, {
373
428
  discover: t('ta.discover'),
374
429
  me: t('ta.me'),
375
430
  fold: t('ta.nav.fold'),
376
431
  settings: { label: t('ta.nav.settings'), run: () => openSettings('navigation') },
432
+ holds,
377
433
  })
378
434
  : [];
379
- const tab = tabPage === 'me' ? ME_TAB : tabPage === 'discover' ? DISCOVER : ((_c = tabView === null || tabView === void 0 ? void 0 : tabView.id) !== null && _c !== void 0 ? _c : side);
435
+ const tab = tabPage === 'me' ? ME_TAB : tabPage === 'discover' ? DISCOVER : ((_g = tabView === null || tabView === void 0 ? void 0 : tabView.id) !== null && _g !== void 0 ? _g : side);
380
436
  // The launcher and the board are over the first tab only, as WeChat's over its chats.
381
- const firstTab = ((_b = tabs[0]) === null || _b === void 0 ? void 0 : _b.id) === tab;
382
- // A page of the screen, and those in the background beside it, kept as they were.
383
- const screenPage = settings === undefined && view && !tabView ? view : undefined;
437
+ const firstTab = ((_d = tabs[0]) === null || _d === void 0 ? void 0 : _d.id) === tab;
384
438
  const content = phone ? (React.createElement(PhoneShell, { tabs: tabs, tab: tab, launcher: firstTab && surfaces.launcher ? React.createElement(LauncherSurface, { active: surface === 'launcher' }) : undefined, board: firstTab && surfaces.board ? (React.createElement(BoardSurface, { leading: React.createElement(IconButton, { icon: ChevronLeft, label: t('ta.back'), onClick: () => setSurface(undefined) }) })) : undefined, surface: surface, onSurface: setSurface, onTab: id => {
385
439
  var _a;
386
440
  setSurface(undefined);
@@ -402,11 +456,11 @@ function AppShell() {
402
456
  settings !== undefined ? (React.createElement(SettingsView, { key: settingsOpened, section: settings || undefined, onClose: closeSettings, onBack: closeSettings })) : screenPage ? null : (React.createElement(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 },
403
457
  navOpen && React.createElement("button", { type: "button", className: "ta-scrim", "aria-label": t('ta.close'), onClick: () => setNavOpen(false) }),
404
458
  React.createElement("div", { className: "ta-nav" },
405
- React.createElement(Rail, { lists: lists, list: sideShown ? side : undefined, onList: showList, navigation: navigation, current: tabPage === 'discover' || (view && navigation.discover.includes(view)) ? DISCOVER : ((_d = view === null || view === void 0 ? void 0 : view.id) !== null && _d !== void 0 ? _d : ''), onPage: showPage, onDiscover: () => {
459
+ React.createElement(Rail, { lists: lists, list: sideShown ? side : undefined, onList: showList, navigation: navigation, current: tabPage === 'discover' || (view && navigation.discover.includes(view)) ? DISCOVER : ((_h = view === null || view === void 0 ? void 0 : view.id) !== null && _h !== void 0 ? _h : ''), onPage: showPage, onDiscover: () => {
406
460
  setSettings(undefined);
407
461
  setNavOpen(false);
408
462
  setTabPage('discover');
409
- }, onSettings: openSettings, settingsShown: settings !== undefined, surfaces: surfaces, surface: surface, onSurface: setSurface }),
463
+ }, onSettings: openSettings, settingsShown: settings !== undefined, surfaces: surfaces, surface: surface, onSurface: setSurface, holds: holds }),
410
464
  sideShown && (React.createElement("div", { className: "ta-sidebar", style: paneStyle(sidebar) },
411
465
  sideView ? React.createElement(SidebarView, { view: sideView }) : chats,
412
466
  React.createElement(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 {
@@ -1,7 +1,8 @@
1
1
  import { TaLocation } from '@celljs/ta-protocol';
2
- import { ChevronRight, FolderTree, Plus, Search, Trash2, Undo2, X } from 'lucide-react';
2
+ import { ChevronRight, Folder, FolderTree, Plus, Search, Trash2, Undo2, X } from 'lucide-react';
3
3
  import * as React from 'react';
4
4
  import { useDevice } from '../device/device.js';
5
+ import { ExtensionBoundary, SessionAvatars } from '../extension/extension-view.js';
5
6
  import { useT } from '../i18n/use-t.js';
6
7
  import { StateUtil } from '../state/state-protocol.js';
7
8
  import { MessageUtil } from '../util/message.js';
@@ -10,6 +11,7 @@ import { EmptyState } from './empty-state.js';
10
11
  import { HostTag } from './host-tag.js';
11
12
  import { Icon, IconButton } from './icon.js';
12
13
  import { SwipeRow } from './swipe-row.js';
14
+ import { DinoFace } from './ta-avatar.js';
13
15
  /** The list by directory or package, else by day; in any browser. */
14
16
  /** By day unless the user groups them: directories nest a list, and the remote ones are marked anyway (HostTag). */
15
17
  export const BY_DIRECTORY = { key: 'chat.byDirectory', tier: 'user', initial: false, parse: StateUtil.boolean };
@@ -28,6 +30,11 @@ export var ChatListUtil;
28
30
  return 'sessionId' in entry;
29
31
  }
30
32
  ChatListUtil.isOpen = isOpen;
33
+ /** Whether it is the double's own conversation: its session, or before that is open its file. */
34
+ function isDouble(entry, double) {
35
+ return isOpen(entry) && (entry.sessionId === double.session || (!!double.sessionFile && entry.sessionFile === double.sessionFile));
36
+ }
37
+ ChatListUtil.isDouble = isDouble;
31
38
  /** The id of an open session, the file of a saved one. */
32
39
  function key(entry) {
33
40
  return isOpen(entry) ? entry.sessionId : entry.sessionFile;
@@ -154,6 +161,42 @@ export var ChatListUtil;
154
161
  return session.sessionName || session.firstMessage || t('ta.chat.new');
155
162
  }
156
163
  ChatListUtil.title = title;
164
+ /**
165
+ * Whether a row shows the same: what of its conversation and its place it shows, and the rest as is. The list
166
+ * reads the conversations again every few seconds into new objects: one that answers draws its row again, not every row.
167
+ */
168
+ function sameRow(before, after) {
169
+ const a = before.session;
170
+ const b = after.session;
171
+ const sameSession = a === b ||
172
+ (key(a) === key(b) &&
173
+ a.sessionName === b.sessionName &&
174
+ a.firstMessage === b.firstMessage &&
175
+ a.lastMessage === b.lastMessage &&
176
+ a.updatedAt === b.updatedAt &&
177
+ a.cwd === b.cwd &&
178
+ a.group === b.group &&
179
+ (isOpen(a) && a.isStreaming) === (isOpen(b) && b.isStreaming));
180
+ const x = before.source;
181
+ const y = after.source;
182
+ 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);
183
+ if (!sameSession || !sameSource) {
184
+ return false;
185
+ }
186
+ for (const name of Object.keys(after)) {
187
+ if (name !== 'session' && name !== 'source' && before[name] !== after[name]) {
188
+ return false;
189
+ }
190
+ }
191
+ return Object.keys(before).length === Object.keys(after).length;
192
+ }
193
+ ChatListUtil.sameRow = sameRow;
194
+ /** What a row says under its title: the last thing said, unless it is the title again. */
195
+ function preview(session, title) {
196
+ const last = session.lastMessage;
197
+ return last && last !== title ? last : undefined;
198
+ }
199
+ ChatListUtil.preview = preview;
157
200
  /** The first letter of a name, for its avatar. */
158
201
  function initial(name) {
159
202
  const letter = [...name].find(char => /[\p{L}\p{N}]/u.test(char));
@@ -170,9 +213,49 @@ function useMinute() {
170
213
  }, []);
171
214
  return now;
172
215
  }
173
- function ChatItem({ session, source, selected, now, compact, onSelect, onRemove, onRestore, doubleTask, onHand }) {
216
+ /**
217
+ * The avatar of a row: the face of the double for its own conversation, the face an extension draws for its
218
+ * agents (registerAvatar), else the letter of its directory. A face works while the conversation answers.
219
+ */
220
+ function ChatAvatar({ session, source, who, size, mood }) {
221
+ var _a;
222
+ const avatars = React.useContext(SessionAvatars);
223
+ const letter = (React.createElement("span", { className: `ta-chat-avatar ta-tone-${source.tone}`, "aria-hidden": "true" }, source.initial));
224
+ if ((who === null || who === void 0 ? void 0 : who.kind) === 'double') {
225
+ return React.createElement(DinoFace, { className: "ta-chat-face", mood: mood, size: size });
226
+ }
227
+ const Avatar = who && ChatListUtil.isOpen(session) && session.group ? avatars[session.group] : undefined;
228
+ if (!Avatar || !ChatListUtil.isOpen(session)) {
229
+ return letter;
230
+ }
231
+ return (React.createElement("span", { className: "ta-chat-face", style: { width: size, height: size }, "aria-hidden": "true" },
232
+ React.createElement(ExtensionBoundary, { name: (_a = session.group) !== null && _a !== void 0 ? _a : '', resetKey: Avatar, fallback: letter },
233
+ React.createElement(Avatar, { session: session, mood: mood, size: size }))));
234
+ }
235
+ /** What goes on in it, on the line of a row of one line: answering now, or how the double's task ended. */
236
+ function ChatState({ streaming, task }) {
237
+ const t = useT();
238
+ if (streaming) {
239
+ return (React.createElement("span", { className: "ta-chat-state" },
240
+ React.createElement("span", { className: "ta-spinner" })));
241
+ }
242
+ if (task === 'failed' || task === 'stopped') {
243
+ return (React.createElement("span", { className: `ta-chat-state ta-${task}` },
244
+ React.createElement("span", { className: `ta-status ${task === 'failed' ? 'ta-status-error' : 'ta-status-cancelled'}` }),
245
+ t(task === 'failed' ? 'ta.task.failed' : 'ta.task.stopped')));
246
+ }
247
+ return null;
248
+ }
249
+ const ChatItem = React.memo(function ChatItem({ session, source, selected, time, compact, actions, restorable, task, doubleName, handable }) {
174
250
  const t = useT();
175
- const title = ChatListUtil.title(session, t);
251
+ const onSelect = () => actions.open(session);
252
+ const onRemove = () => actions.remove(session);
253
+ const onRestore = restorable ? () => actions.restore(session) : undefined;
254
+ const onHand = handable ? () => actions.hand(session) : undefined;
255
+ const avatars = React.useContext(SessionAvatars);
256
+ // The double's conversation is named after it; an agent's has its name (the extension named it so).
257
+ const who = doubleName !== undefined ? { kind: 'double', name: doubleName } : session.group && avatars[session.group] ? { kind: 'agent' } : undefined;
258
+ const title = (who === null || who === void 0 ? void 0 : who.kind) === 'double' ? who.name : ChatListUtil.title(session, t);
176
259
  // Held, a row offers what its hover does (its close button shows only on the row shown, on a phone).
177
260
  const [menu, openMenu] = useContextMenu();
178
261
  const onContextMenu = (event) => openMenu(event, [
@@ -180,33 +263,48 @@ function ChatItem({ session, source, selected, now, compact, onSelect, onRemove,
180
263
  ...(onHand ? [{ label: t('ta.chat.handToDouble'), run: onHand }] : []),
181
264
  onRestore ? { label: t('ta.chat.restore'), run: onRestore } : { label: t('ta.chat.remove'), run: () => onRemove === null || onRemove === void 0 ? void 0 : onRemove() },
182
265
  ]);
183
- const tag = doubleTask && (React.createElement("span", { className: "ta-double-tag", title: t('ta.chat.doubleTagTitle') }, t('ta.chat.doubleTag')));
266
+ const tag = task && (React.createElement("span", { className: "ta-double-tag", title: t('ta.chat.doubleTagTitle') }, t('ta.chat.doubleTag')));
184
267
  // On a phone, as in its messaging apps, a swipe to the left shows what its hover does behind the row.
185
268
  const handheld = useDevice(device => device.handheld);
186
269
  const swipe = onRestore
187
270
  ? { key: 'restore', label: t('ta.chat.restoreShort'), run: onRestore }
188
271
  : { key: 'remove', label: t('ta.chat.removeShort'), danger: true, run: () => onRemove === null || onRemove === void 0 ? void 0 : onRemove() };
189
272
  const streaming = ChatListUtil.isOpen(session) && session.isStreaming;
190
- return (React.createElement(SwipeRow, { as: "li", className: `ta-chat-row${selected ? ' ta-selected' : ''}`, actions: [swipe], overlay: menu, onContextMenu: onContextMenu },
273
+ const mood = streaming ? 'working' : 'idle';
274
+ const state = React.createElement(ChatState, { streaming: streaming, task: task });
275
+ // As in a messaging app, the last thing said; its directory before the first, and on hover in place of its time.
276
+ const said = ChatListUtil.preview(session, title);
277
+ const place = who ? MessageUtil.basename(session.cwd) : source.label;
278
+ const ended = task === 'failed' || task === 'stopped' ? task : undefined;
279
+ return (React.createElement(SwipeRow, { as: "li", className: `ta-chat-row${selected ? ' ta-selected' : ''}${who ? ` ta-chat-${who.kind}` : ''}`, actions: [swipe], overlay: menu, onContextMenu: onContextMenu },
191
280
  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" },
192
281
  React.createElement("span", { className: "ta-chat-line" },
282
+ who && React.createElement(ChatAvatar, { session: session, source: source, who: who, size: 20, mood: mood }),
193
283
  tag,
194
284
  React.createElement("span", { className: "ta-chat-title" }, title),
195
- streaming && React.createElement("span", { className: "ta-spinner" }),
196
- React.createElement("span", { className: "ta-chat-time" }, ChatListUtil.clock(session.updatedAt, now))))) : (React.createElement(React.Fragment, null,
197
- React.createElement("span", { className: `ta-chat-avatar ta-tone-${source.tone}`, "aria-hidden": "true" }, source.initial),
285
+ state,
286
+ React.createElement("span", { className: "ta-chat-time" }, time)))) : (React.createElement(React.Fragment, null,
287
+ React.createElement(ChatAvatar, { session: session, source: source, who: who, size: 38, mood: mood }),
198
288
  React.createElement("span", { className: "ta-chat-text" },
199
289
  React.createElement("span", { className: "ta-chat-line" },
200
290
  tag,
201
291
  React.createElement("span", { className: "ta-chat-title" }, title),
202
- React.createElement("span", { className: "ta-chat-time" }, ChatListUtil.clock(session.updatedAt, now))),
292
+ React.createElement("span", { className: "ta-chat-time" }, time),
293
+ React.createElement("span", { className: "ta-chat-place" },
294
+ React.createElement(Icon, { icon: Folder, size: 12 }),
295
+ React.createElement("span", null, place))),
203
296
  React.createElement("span", { className: "ta-chat-line" },
204
297
  React.createElement("span", { className: "ta-chat-sub" },
205
298
  React.createElement(HostTag, { host: source.host }),
206
- source.label),
207
- streaming && React.createElement("span", { className: "ta-spinner" })))))),
299
+ ended && !streaming && (React.createElement("span", { className: `ta-chat-flag ta-${ended}` },
300
+ "[",
301
+ t(ended === 'failed' ? 'ta.task.failed' : 'ta.task.stopped'),
302
+ "]")), said !== null && said !== void 0 ? said : (React.createElement("span", { className: "ta-chat-dir" },
303
+ React.createElement(Icon, { icon: Folder, size: 12 }),
304
+ place))),
305
+ streaming && React.createElement("span", { className: "ta-chat-state ta-spinner" })))))),
208
306
  handheld ? null : onRestore ? (React.createElement(IconButton, { className: "ta-chat-delete", icon: Undo2, label: t('ta.chat.restore'), onClick: onRestore })) : (React.createElement(IconButton, { className: "ta-chat-delete", icon: Trash2, label: t('ta.sidebar.closeTitle'), onClick: onRemove }))));
209
- }
307
+ }, ChatListUtil.sameRow);
210
308
  /**
211
309
  * The conversations of the server, open or saved, the latest first, with a search and `+` for a new one:
212
310
  * by directory or package, each group folding and with a `+` of its own, or by day. Those taken out are at
@@ -217,24 +315,42 @@ export function ChatList({ sessions, saved, removed: removedFiles, selected, cha
217
315
  const now = useMinute();
218
316
  const [query, setQuery] = React.useState('');
219
317
  const [removedOpen, setRemovedOpen] = React.useState(false);
318
+ // What the rows do reads the props of now, through one object that stays the same: no row is drawn again for it.
319
+ const latest = React.useRef({ chat, double, onPicked, t });
320
+ latest.current = { chat, double, onPicked, t };
321
+ const actions = React.useMemo(() => {
322
+ const pick = (change) => {
323
+ void change;
324
+ latest.current.onPicked();
325
+ };
326
+ return {
327
+ open: entry => pick(ChatListUtil.isOpen(entry) ? latest.current.chat.show(entry.sessionId) : latest.current.chat.resume(entry.sessionFile)),
328
+ remove: entry => void latest.current.chat.remove(entry),
329
+ restore: entry => void latest.current.chat.restore(ChatListUtil.key(entry)),
330
+ hand: entry => {
331
+ var _a;
332
+ if (ChatListUtil.isOpen(entry)) {
333
+ (_a = latest.current.double) === null || _a === void 0 ? void 0 : _a.hand(entry, ChatListUtil.title(entry, latest.current.t));
334
+ }
335
+ },
336
+ };
337
+ }, []);
220
338
  // A failure is a notice of the chat.
221
339
  const pick = (change) => {
222
340
  void change;
223
341
  onPicked();
224
342
  };
225
- const { listed, removed } = ChatListUtil.entries(sessions, saved, removedFiles);
226
- const sources = ChatListUtil.sources(listed);
227
- const shown = ChatListUtil.filter(listed, query, t);
228
- const shownRemoved = ChatListUtil.filter(removed, query, t);
343
+ // Worked out again only when the conversations or the search change, not as the minute or the selection does.
344
+ const { listed, removed } = React.useMemo(() => ChatListUtil.entries(sessions, saved, removedFiles), [sessions, saved, removedFiles]);
345
+ const sources = React.useMemo(() => ChatListUtil.sources(listed), [listed]);
346
+ const shown = React.useMemo(() => ChatListUtil.filter(listed, query, t), [listed, query, t]);
347
+ const shownRemoved = React.useMemo(() => ChatListUtil.filter(removed, query, t), [removed, query, t]);
229
348
  // What a search finds is one list by day, wherever it is.
230
349
  const grouped = byDirectory && sources.length > 1 && !query.trim();
231
- const open = (entry) => pick(ChatListUtil.isOpen(entry) ? chat.show(entry.sessionId) : chat.resume(entry.sessionFile));
232
350
  const draftIn = (cwd) => pick(chat.draft().then(() => chat.setDraftCwd(cwd)));
233
351
  const fold = (key) => onFolded(folded.includes(key) ? folded.filter(other => other !== key) : [...folded, key]);
234
- const byKey = new Map([...sources, ...ChatListUtil.sources(removed)].map(candidate => [candidate.key, candidate]));
235
- 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
236
- ? () => double.hand(session, ChatListUtil.title(session, t))
237
- : undefined }));
352
+ const byKey = React.useMemo(() => new Map([...sources, ...ChatListUtil.sources(removed)].map(candidate => [candidate.key, candidate])), [sources, removed]);
353
+ 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) }));
238
354
  // The conversation shown is found in the list, however it came to be shown: out of a search that hides it, and scrolled to.
239
355
  const scroller = React.useRef(null);
240
356
  const reveal = React.useRef(false);
@@ -287,6 +403,6 @@ export function ChatList({ sessions, saved, removed: removedFiles, selected, cha
287
403
  React.createElement("button", { type: "button", className: "ta-chat-section-title ta-chat-removed-toggle", "aria-expanded": removedOpen, onClick: () => setRemovedOpen(!removedOpen) },
288
404
  React.createElement(Icon, { icon: ChevronRight, size: 13 }),
289
405
  t('ta.chat.removed', { count: shownRemoved.length })),
290
- 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)) }))))))))));
406
+ 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 }))))))))));
291
407
  }
292
408
  //# sourceMappingURL=chat-list.js.map