@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
@@ -34,6 +34,8 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.MessageFooterUtil = exports.MessageActions = void 0;
37
+ exports.useTimeLabel = useTimeLabel;
38
+ exports.TimeBreak = TimeBreak;
37
39
  exports.UserFooter = UserFooter;
38
40
  exports.TurnFooter = TurnFooter;
39
41
  const lucide_react_1 = require("lucide-react");
@@ -63,12 +65,12 @@ var MessageFooterUtil;
63
65
  }
64
66
  MessageFooterUtil.debugInfo = debugInfo;
65
67
  })(MessageFooterUtil || (exports.MessageFooterUtil = MessageFooterUtil = {}));
66
- function FooterButton({ icon, label, onClick }) {
67
- return (React.createElement("button", { type: "button", className: "ta-footer-button", title: label, "aria-label": label, onClick: onClick },
68
+ function FooterButton({ icon, label, onClick, className }) {
69
+ return (React.createElement("button", { type: "button", className: className ? `ta-footer-button ${className}` : 'ta-footer-button', title: label, "aria-label": label, onClick: onClick },
68
70
  React.createElement(icon_1.Icon, { icon: icon, size: 14 })));
69
71
  }
70
72
  /** Copies, and says so on the button for a moment. */
71
- function CopyButton({ text, icon, label, done }) {
73
+ function CopyButton({ text, icon, label, done, className }) {
72
74
  const t = (0, use_t_1.useT)();
73
75
  const [copied, setCopied] = React.useState(false);
74
76
  React.useEffect(() => {
@@ -78,16 +80,29 @@ function CopyButton({ text, icon, label, done }) {
78
80
  }
79
81
  }, [copied]);
80
82
  const copy = () => { var _a; return void ((_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText(text()).then(() => setCopied(true))); };
81
- return React.createElement(FooterButton, { icon: copied ? lucide_react_1.Check : icon, label: t(copied ? done : label), onClick: copy });
83
+ return React.createElement(FooterButton, { icon: copied ? lucide_react_1.Check : icon, label: t(copied ? done : label), onClick: copy, className: className });
82
84
  }
83
- function Time({ timestamp }) {
85
+ /** When, as a person says it: the time today, "Yesterday" and the time, else the date and the time. */
86
+ function useTimeLabel() {
84
87
  const t = (0, use_t_1.useT)();
88
+ return timestamp => {
89
+ const { day, time, date } = message_1.MessageUtil.when(timestamp);
90
+ return day === 'today' ? time : day === 'date' ? `${date} ${time}` : `${t(day === 'yesterday' ? 'ta.time.yesterday' : 'ta.time.dayBefore')} ${time}`;
91
+ };
92
+ }
93
+ function Time({ timestamp, className = 'ta-footer-time' }) {
94
+ const label = useTimeLabel();
85
95
  if (timestamp === undefined) {
86
96
  return null;
87
97
  }
88
- const { day, time, date } = message_1.MessageUtil.when(timestamp);
89
- const label = day === 'today' ? time : day === 'date' ? `${date} ${time}` : `${t(day === 'yesterday' ? 'ta.time.yesterday' : 'ta.time.dayBefore')} ${time}`;
90
- return (React.createElement("time", { className: "ta-footer-time", dateTime: new Date(timestamp).toISOString(), title: new Date(timestamp).toLocaleString() }, label));
98
+ return (React.createElement("time", { className: className, dateTime: new Date(timestamp).toISOString(), title: new Date(timestamp).toLocaleString() }, label(timestamp)));
99
+ }
100
+ /**
101
+ * The time between two messages far apart (ProcessUtil.timeBreaks), as WeChat shows it: on a touch screen,
102
+ * where the footers of the messages, which carry their times, are not shown.
103
+ */
104
+ function TimeBreak({ timestamp }) {
105
+ return React.createElement(Time, { timestamp: timestamp, className: "ta-time-break" });
91
106
  }
92
107
  /** Under a message of the user: when, copy, a new conversation from here, back to here. */
93
108
  function UserFooter({ message, text }) {
@@ -100,16 +115,20 @@ function UserFooter({ message, text }) {
100
115
  branches && React.createElement(FooterButton, { icon: lucide_react_1.GitFork, label: t('ta.message.forkBefore'), onClick: () => actions.fork(message, 'before') }),
101
116
  branches && React.createElement(FooterButton, { icon: lucide_react_1.Undo2, label: t('ta.message.rewind'), onClick: () => actions.rewind(message) })));
102
117
  }
103
- /** Under a turn that ended: copy the reply, a new conversation from it, what to report, when, what it took. */
104
- function TurnFooter({ messages, last, reply, session }) {
118
+ /**
119
+ * Under a turn that ended: copy the reply, a new conversation from it, what to report, when, what it took.
120
+ * `latest`: the last turn of the conversation, whose footer a touch screen keeps (only its copy and fork;
121
+ * the rest, and the footers of the others, are in the menu of a held message).
122
+ */
123
+ function TurnFooter({ messages, last, reply, session, latest, }) {
105
124
  const t = (0, use_t_1.useT)();
106
125
  const actions = React.useContext(exports.MessageActions);
107
126
  const usage = React.useMemo(() => message_1.MessageUtil.usage(messages), [messages]);
108
127
  const used = usage.input > 0 || usage.output > 0;
109
- return (React.createElement("div", { className: "ta-footer" },
128
+ return (React.createElement("div", { className: latest ? 'ta-footer ta-footer-latest' : 'ta-footer' },
110
129
  reply && React.createElement(CopyButton, { text: () => reply, icon: lucide_react_1.Copy, label: "ta.copy", done: "ta.copied" }),
111
130
  last && actions && !actions.working && React.createElement(FooterButton, { icon: lucide_react_1.GitFork, label: t('ta.message.forkAt'), onClick: () => actions.fork(last, 'at') }),
112
- last && React.createElement(CopyButton, { text: () => MessageFooterUtil.debugInfo(last, session), icon: lucide_react_1.Bug, label: "ta.message.debug", done: "ta.message.debugCopied" }),
131
+ last && (React.createElement(CopyButton, { text: () => MessageFooterUtil.debugInfo(last, session), icon: lucide_react_1.Bug, label: "ta.message.debug", done: "ta.message.debugCopied", className: "ta-footer-debug" })),
113
132
  React.createElement(Time, { timestamp: last === null || last === void 0 ? void 0 : last.timestamp }),
114
133
  used && (React.createElement("span", { className: "ta-footer-usage", title: t('ta.message.usageTitle', { input: usage.input, output: usage.output }) },
115
134
  React.createElement("span", null, t('ta.message.used')),
@@ -6,13 +6,32 @@ import { MessageUtil, type ToolOutput } from '../util/message';
6
6
  import { type ProcessStep, type ThreadItem } from '../util/process';
7
7
  /** The session of the conversation: who answers in it may be drawn by the extension of its group. */
8
8
  export declare const ConversationSession: React.Context<TaSessionInfo | undefined>;
9
+ /** What can be done with a message sent from here that failed to go. */
10
+ export interface OutboxActions {
11
+ resend(id: string): void;
12
+ discard(id: string): void;
13
+ }
9
14
  /** Who answers, at the head of a turn: ta, or the avatar the extension of the session's group draws. */
10
15
  export declare function TurnAvatar({ mood }: {
11
16
  mood: Mood;
12
17
  }): React.JSX.Element;
13
- /** The images of a message of the user, as thumbnails. */
18
+ type Blocks = ReturnType<typeof MessageUtil.blocks>;
19
+ /**
20
+ * The images of a message of the user: one keeps its own shape at the size of a bubble, a few stand as
21
+ * squares of one size, and a click on any of them opens it full size over the page.
22
+ */
14
23
  export declare function UserImages({ blocks }: {
15
- blocks: ReturnType<typeof MessageUtil.blocks>;
24
+ blocks: Blocks;
25
+ }): React.JSX.Element | null;
26
+ /**
27
+ * What the user said, in the bubble of a message of theirs, with the pictures they sent with it in the same
28
+ * bubble: the pictures first, the words under them. A message of pictures alone has no bubble of its own.
29
+ * `bubble` is the class of that bubble, which a conversation and the double have of their own.
30
+ */
31
+ export declare function UserSaid({ blocks, text, bubble }: {
32
+ blocks: Blocks;
33
+ text: string;
34
+ bubble?: string;
16
35
  }): React.JSX.Element | null;
17
36
  /**
18
37
  * The head of a turn and its work: the work in one line, "N steps", open while ta is at it, then folded,
@@ -32,7 +51,9 @@ export declare function Process({ steps, active, results, tools, leading, status
32
51
  /** A turn that has shown nothing yet: what ta does goes on its head. */
33
52
  export declare function quiet(item: ThreadItem | undefined): boolean;
34
53
  /** The conversation; tool results show with the calls they answer. */
35
- export declare function MessageList({ state }: {
54
+ export declare function MessageList({ state, outbox }: {
36
55
  state: SessionState;
56
+ outbox?: OutboxActions;
37
57
  }): React.JSX.Element;
58
+ export {};
38
59
  //# sourceMappingURL=message-list.d.ts.map
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.ConversationSession = void 0;
37
37
  exports.TurnAvatar = TurnAvatar;
38
38
  exports.UserImages = UserImages;
39
+ exports.UserSaid = UserSaid;
39
40
  exports.Process = Process;
40
41
  exports.quiet = quiet;
41
42
  exports.MessageList = MessageList;
@@ -50,6 +51,7 @@ const tool_1 = require("../util/tool");
50
51
  const callout_1 = require("./callout");
51
52
  const conversation_scroll_1 = require("./conversation-scroll");
52
53
  const icon_1 = require("./icon");
54
+ const lightbox_1 = require("./lightbox");
53
55
  const markdown_1 = require("./markdown");
54
56
  const message_footer_1 = require("./message-footer");
55
57
  const message_menu_1 = require("./message-menu");
@@ -58,6 +60,18 @@ const ta_avatar_1 = require("./ta-avatar");
58
60
  const tool_view_1 = require("./tool-view");
59
61
  /** The session of the conversation: who answers in it may be drawn by the extension of its group. */
60
62
  exports.ConversationSession = React.createContext(undefined);
63
+ /** The messages of the conversation still on their way from here, by message, with what can be done with those that failed. */
64
+ const Outbox = React.createContext({ of: new Map() });
65
+ /** A message that did not go: marked as such, with a way to send it again or take it back, as in a messenger. */
66
+ function SendFailed({ sent, actions }) {
67
+ const t = (0, use_t_1.useT)();
68
+ return (React.createElement("div", { className: "ta-send-failed", title: sent.failed },
69
+ React.createElement(icon_1.Icon, { icon: lucide_react_1.CircleAlert, size: 14 }),
70
+ React.createElement("span", null, t('ta.message.sendFailed')),
71
+ actions && (React.createElement(React.Fragment, null,
72
+ React.createElement("button", { type: "button", className: "ta-link-button", onClick: () => actions.resend(sent.id) }, t('ta.message.resend')),
73
+ React.createElement("button", { type: "button", className: "ta-link-button", onClick: () => actions.discard(sent.id) }, t('ta.message.discard'))))));
74
+ }
61
75
  /** Who answers, at the head of a turn: ta, or the avatar the extension of the session's group draws. */
62
76
  function TurnAvatar({ mood }) {
63
77
  var _a;
@@ -82,10 +96,39 @@ function TaskUpdate({ title, status, result }) {
82
96
  t(`ta.task.${status}`)),
83
97
  React.createElement(markdown_1.Markdown, { text: result })));
84
98
  }
85
- /** The images of a message of the user, as thumbnails. */
99
+ /** The images of a message: those the page can show. */
100
+ function imagesOf(blocks) {
101
+ return blocks.filter(block => { var _a; return block.type === 'image' && block.data && ((_a = block.mimeType) === null || _a === void 0 ? void 0 : _a.startsWith('image/')); });
102
+ }
103
+ /**
104
+ * The images of a message of the user: one keeps its own shape at the size of a bubble, a few stand as
105
+ * squares of one size, and a click on any of them opens it full size over the page.
106
+ */
86
107
  function UserImages({ blocks }) {
87
- const images = blocks.filter(block => { var _a; return block.type === 'image' && block.data && ((_a = block.mimeType) === null || _a === void 0 ? void 0 : _a.startsWith('image/')); });
88
- return images.length > 0 ? (React.createElement("div", { className: "ta-user-images" }, images.map((block, index) => (React.createElement("img", { key: index, className: "ta-thumb", src: `data:${block.mimeType};base64,${block.data}`, alt: "" }))))) : null;
108
+ const t = (0, use_t_1.useT)();
109
+ const [open, setOpen] = React.useState();
110
+ const images = imagesOf(blocks);
111
+ if (images.length === 0) {
112
+ return null;
113
+ }
114
+ const src = (block) => `data:${block.mimeType};base64,${block.data}`;
115
+ return (React.createElement("div", { className: "ta-user-images", "data-count": Math.min(images.length, 3) },
116
+ images.map((block, index) => (React.createElement("button", { key: index, type: "button", className: "ta-user-image", title: t('ta.markdown.enlarge'), onClick: () => setOpen(index) },
117
+ React.createElement("img", { className: "ta-thumb", src: src(block), alt: "" })))),
118
+ open !== undefined && images[open] && React.createElement(lightbox_1.Lightbox, { src: src(images[open]), alt: "", onClose: () => setOpen(undefined) })));
119
+ }
120
+ /**
121
+ * What the user said, in the bubble of a message of theirs, with the pictures they sent with it in the same
122
+ * bubble: the pictures first, the words under them. A message of pictures alone has no bubble of its own.
123
+ * `bubble` is the class of that bubble, which a conversation and the double have of their own.
124
+ */
125
+ function UserSaid({ blocks, text, bubble = 'ta-bubble' }) {
126
+ if (imagesOf(blocks).length === 0) {
127
+ return text ? React.createElement("div", { className: bubble }, text) : null;
128
+ }
129
+ return (React.createElement("div", { className: `${bubble} ta-bubble-media${text ? '' : ' ta-bubble-bare'}` },
130
+ React.createElement(UserImages, { blocks: blocks }),
131
+ text && React.createElement("div", { className: "ta-bubble-text" }, text)));
89
132
  }
90
133
  function UserMessage({ message }) {
91
134
  var _a;
@@ -94,7 +137,7 @@ function UserMessage({ message }) {
94
137
  if (update) {
95
138
  return React.createElement(TaskUpdate, { title: update[1], status: update[2], result: update[3] });
96
139
  }
97
- const said = ta_protocol_1.TaMessageContext.strip(message_1.MessageUtil.text(blocks));
140
+ const said = ta_protocol_1.TaImageNote.strip(ta_protocol_1.TaMessageContext.strip(message_1.MessageUtil.text(blocks)));
98
141
  const skill = ta_protocol_1.TaSkillUse.parse(said);
99
142
  if (skill) {
100
143
  return React.createElement(UserBubble, { message: message, blocks: blocks, text: (_a = skill.message) !== null && _a !== void 0 ? _a : '', copied: ta_protocol_1.TaSkillUse.command(skill), skill: skill });
@@ -118,10 +161,17 @@ function SkillUse({ skill }) {
118
161
  }
119
162
  function UserBubble({ message, blocks, text, copied, skill, }) {
120
163
  const [menu, onContextMenu] = (0, message_menu_1.useMessageMenu)({ kind: 'user', message, text: copied });
164
+ const outbox = React.useContext(Outbox);
165
+ const sent = outbox.of.get(message);
166
+ if (sent) {
167
+ // Not in the session yet: nothing to branch from or rewind to.
168
+ return (React.createElement("div", { className: `ta-message ta-user ${sent.failed ? 'ta-user-failed' : 'ta-user-sending'}` },
169
+ React.createElement(UserSaid, { blocks: blocks, text: text }),
170
+ sent.failed ? React.createElement(SendFailed, { sent: sent, actions: outbox.actions }) : React.createElement("div", { className: "ta-footer" })));
171
+ }
121
172
  return (React.createElement("div", { className: "ta-message ta-user", onContextMenu: onContextMenu },
122
- React.createElement(UserImages, { blocks: blocks }),
123
173
  skill && React.createElement(SkillUse, { skill: skill }),
124
- text && React.createElement("div", { className: "ta-bubble" }, text),
174
+ React.createElement(UserSaid, { blocks: blocks, text: text }),
125
175
  React.createElement(message_footer_1.UserFooter, { message: message, text: copied }),
126
176
  menu));
127
177
  }
@@ -136,6 +186,17 @@ const ThinkingStep = React.memo(function ThinkingStep({ text, tagged = true }) {
136
186
  !open && React.createElement("span", { className: "ta-step-preview" }, process_1.ProcessUtil.preview(text))),
137
187
  open && React.createElement("div", { className: "ta-thinking-text" }, text)));
138
188
  });
189
+ /** The summary an agent compacted its context to: folded into one line, it opens to the whole summary. */
190
+ const SummaryStep = React.memo(function SummaryStep({ text }) {
191
+ const t = (0, use_t_1.useT)();
192
+ const [open, setOpen] = React.useState(false);
193
+ return (React.createElement("div", { className: "ta-step-summary" },
194
+ React.createElement("button", { type: "button", className: "ta-step-toggle", "aria-expanded": open, onClick: () => setOpen(!open) },
195
+ React.createElement("span", { className: "ta-status ta-status-thought" }),
196
+ React.createElement("span", { className: "ta-step-tag" }, t('ta.message.compacted')),
197
+ React.createElement(icon_1.Icon, { icon: lucide_react_1.ChevronRight, size: 14, className: "ta-step-chevron" })),
198
+ open && React.createElement("div", { className: "ta-thinking-text" }, text)));
199
+ });
139
200
  const TextStep = React.memo(function TextStep({ text }) {
140
201
  return (React.createElement("div", { className: "ta-step-text" },
141
202
  React.createElement("span", { className: "ta-status ta-status-thought" }),
@@ -148,12 +209,68 @@ function Step({ step, results, tools, tagged }) {
148
209
  return React.createElement(ThinkingStep, { text: step.text, tagged: tagged });
149
210
  case 'text':
150
211
  return React.createElement(TextStep, { text: step.text });
212
+ case 'summary':
213
+ return React.createElement(SummaryStep, { text: step.text });
151
214
  default: {
152
215
  const { id = '', name = '', arguments: args } = step.call;
153
216
  return (React.createElement(tool_view_1.ToolView, { id: id, name: name, args: (_a = args) !== null && _a !== void 0 ? _a : {}, run: id ? tools[id] : undefined, message: id ? results.get(id) : undefined, runs: tools }));
154
217
  }
155
218
  }
156
219
  }
220
+ /** How long the steps of a turn take to fold or open, and how. */
221
+ const FOLD_MS = 220;
222
+ const FOLD_EASE = 'cubic-bezier(0.2, 0.8, 0.2, 1)';
223
+ /**
224
+ * Whether the steps of `ref` are in the page: they fold and open in a motion, so that what is under them
225
+ * slides to its place rather than jumps there (as when a turn ends and its steps fold under the eyes of
226
+ * the user). While they fold they stay; without motion they come and go at once. `slideOpen`: they open in
227
+ * a motion too (opened by the user); steps that come while ta works come in as steps do, without it.
228
+ */
229
+ function useFold(open, ref, slideOpen) {
230
+ const [closing, setClosing] = React.useState(false);
231
+ const [was, setWas] = React.useState(open);
232
+ if (was !== open) {
233
+ setWas(open);
234
+ setClosing(!open);
235
+ }
236
+ const opened = React.useRef(open);
237
+ React.useLayoutEffect(() => {
238
+ const opening = open && !opened.current && slideOpen;
239
+ opened.current = open;
240
+ const element = ref.current;
241
+ if (!opening && !closing) {
242
+ return;
243
+ }
244
+ if (!element || typeof element.animate !== 'function' || document.documentElement.hasAttribute('data-reduce-motion')) {
245
+ setClosing(false);
246
+ return;
247
+ }
248
+ const style = getComputedStyle(element);
249
+ const full = {
250
+ height: `${element.offsetHeight}px`,
251
+ paddingTop: style.paddingTop,
252
+ paddingBottom: style.paddingBottom,
253
+ marginTop: style.marginTop,
254
+ marginBottom: style.marginBottom,
255
+ opacity: 1,
256
+ };
257
+ const none = { height: '0px', paddingTop: '0px', paddingBottom: '0px', marginTop: '0px', marginBottom: '0px', opacity: 0 };
258
+ element.style.overflow = 'hidden';
259
+ // Folded, the steps stay at no height until they go: not drawn whole again for the frame before.
260
+ const animation = element.animate(opening ? [none, full] : [full, none], { duration: FOLD_MS, easing: FOLD_EASE, fill: opening ? 'none' : 'forwards' });
261
+ animation.onfinish = () => {
262
+ element.style.overflow = '';
263
+ if (!opening) {
264
+ setClosing(false);
265
+ }
266
+ };
267
+ return () => {
268
+ animation.cancel();
269
+ element.style.overflow = '';
270
+ };
271
+ }, [open, closing, ref, slideOpen]);
272
+ return open || closing;
273
+ }
157
274
  /**
158
275
  * The head of a turn and its work: the work in one line, "N steps", open while ta is at it, then folded,
159
276
  * so that a long conversation reads as what was asked and what came of it. Before the first step the
@@ -164,9 +281,11 @@ function Process({ steps, active, results, tools, leading, status, }) {
164
281
  const [manual, setManual] = React.useState();
165
282
  const [showAll, setShowAll] = React.useState(false);
166
283
  const id = React.useId();
284
+ const stepsRef = React.useRef(null);
167
285
  const { steps: count, failed } = tool_1.ToolUtil.count(process_1.ProcessUtil.tools(steps), results, tools);
168
286
  // Open while it works, then folded; a failed step says so on the head, quietly.
169
287
  const open = manual !== null && manual !== void 0 ? manual : active;
288
+ const shown = useFold(open && steps.length > 0, stepsRef, !active);
170
289
  const folded = process_1.ProcessUtil.fold(steps, active, showAll);
171
290
  // Only thoughts: the head already says so, the steps need not say it again.
172
291
  const thoughtOnly = steps.every(step => step.kind === 'thinking');
@@ -180,7 +299,7 @@ function Process({ steps, active, results, tools, leading, status, }) {
180
299
  "\u00B7 ",
181
300
  t('ta.process.failed', { count: failed })),
182
301
  React.createElement(icon_1.Icon, { icon: lucide_react_1.ChevronRight, size: 14, className: "ta-process-chevron" }))) : (status)),
183
- open && steps.length > 0 && (React.createElement("div", { id: id, className: "ta-process-steps" },
302
+ shown && (React.createElement("div", { id: id, ref: stepsRef, className: "ta-process-steps" },
184
303
  folded.hidden > 0 && (React.createElement("button", { type: "button", className: "ta-link ta-more", onClick: () => setShowAll(true) }, t('ta.process.earlier', { count: folded.hidden }))),
185
304
  folded.steps.map(step => (React.createElement(Step, { key: step.key, step: step, results: results, tools: tools, tagged: !thoughtOnly })))))));
186
305
  }
@@ -188,7 +307,7 @@ function Process({ steps, active, results, tools, leading, status, }) {
188
307
  function quiet(item) {
189
308
  return (item === null || item === void 0 ? void 0 : item.kind) === 'turn' && item.active && !item.steps.length && !item.reply.some(text => text.trim());
190
309
  }
191
- function Turn({ item, tools, mood, status }) {
310
+ function Turn({ item, tools, mood, status, latest, }) {
192
311
  var _a;
193
312
  const t = (0, use_t_1.useT)();
194
313
  const session = React.useContext(exports.ConversationSession);
@@ -196,13 +315,19 @@ function Turn({ item, tools, mood, status }) {
196
315
  const { errorMessage } = ((_a = item.last) !== null && _a !== void 0 ? _a : {});
197
316
  const stopReason = message_1.MessageUtil.stopReason(item.last);
198
317
  const reply = item.reply.join('\n\n').trim();
199
- const [menu, onContextMenu] = (0, message_menu_1.useMessageMenu)({ kind: 'turn', last: item.active ? undefined : item.last, reply: item.active ? '' : reply, session });
318
+ const [menu, onContextMenu] = (0, message_menu_1.useMessageMenu)({
319
+ kind: 'turn',
320
+ last: item.active ? undefined : item.last,
321
+ reply: item.active ? '' : reply,
322
+ session,
323
+ messages: item.messages,
324
+ });
200
325
  return (React.createElement("div", { className: `ta-message ta-assistant ${item.active ? 'ta-turn-live' : ''}`, onContextMenu: onContextMenu },
201
326
  React.createElement(Process, { steps: item.steps, active: item.active, results: results, tools: tools, leading: React.createElement(TurnAvatar, { mood: mood }), status: status }),
202
- item.reply.map((text, index) => (React.createElement(markdown_1.Markdown, { key: index, text: text }))),
327
+ item.reply.map((text, index) => (React.createElement(markdown_1.Markdown, { key: index, text: text, streaming: item.active && index === item.reply.length - 1 }))),
203
328
  !item.active && stopReason === 'error' && errorMessage && React.createElement(callout_1.Callout, { level: "error" }, errorMessage),
204
329
  !item.active && stopReason === 'aborted' && React.createElement("div", { className: "ta-muted ta-small" }, t('ta.message.stopped')),
205
- !item.active && React.createElement(message_footer_1.TurnFooter, { messages: item.messages, last: item.last, reply: reply, session: session }),
330
+ !item.active && React.createElement(message_footer_1.TurnFooter, { messages: item.messages, last: item.last, reply: reply, session: session, latest: latest }),
206
331
  menu));
207
332
  }
208
333
  /** `!command` of a user, which pi records as its own kind of message. */
@@ -245,18 +370,22 @@ function Message({ item }) {
245
370
  * One item of the conversation. The store replaces only the message that changed, so an item draws
246
371
  * again only when one of its messages did, or, while ta is at it, when a tool run did.
247
372
  */
248
- const ThreadRow = React.memo(function ThreadRow({ item, tools, mood, status }) {
249
- return item.kind === 'turn' ? React.createElement(Turn, { item: item, tools: tools, mood: mood, status: status }) : React.createElement(Message, { item: item });
373
+ const ThreadRow = React.memo(function ThreadRow({ item, tools, mood, status, latest, }) {
374
+ return item.kind === 'turn' ? React.createElement(Turn, { item: item, tools: tools, mood: mood, status: status, latest: latest }) : React.createElement(Message, { item: item });
250
375
  }, (previous, next) => previous.mood === next.mood &&
251
376
  previous.status === next.status &&
377
+ previous.latest === next.latest &&
252
378
  process_1.ProcessUtil.same(previous.item, next.item) &&
253
379
  (next.item.kind === 'message' || !next.item.active || previous.tools === next.tools));
254
380
  /** The last rows, which change and are in view, are always laid out. */
255
381
  const SETTLED_AFTER = 4;
256
382
  /** The conversation; tool results show with the calls they answer. */
257
- function MessageList({ state }) {
383
+ function MessageList({ state, outbox }) {
258
384
  var _a;
259
385
  const items = React.useMemo(() => process_1.ProcessUtil.items(state.messages, state.working, state.start), [state.messages, state.working, state.start]);
386
+ const renderers = React.useContext(extension_view_1.MessageRenderers);
387
+ const breaks = React.useMemo(() => process_1.ProcessUtil.timeBreaks(process_1.ProcessUtil.starts(items), index => process_1.ProcessUtil.shown(items[index], renderers)), [items, renderers]);
388
+ const sent = React.useMemo(() => { var _a; return ({ of: new Map(((_a = state.outbox) !== null && _a !== void 0 ? _a : []).map(message => [message.message, message])), actions: outbox }); }, [state.outbox, outbox]);
260
389
  // Rows of earlier messages put in front are laid out once before they may skip it (content-visibility):
261
390
  // their height is then known, and the view does not move as they come near it.
262
391
  const firstKey = React.useRef((_a = items[0]) === null || _a === void 0 ? void 0 : _a.key);
@@ -281,7 +410,7 @@ function MessageList({ state }) {
281
410
  // What ta does while it works: on the head of a turn that shows nothing yet, else under all it has shown.
282
411
  const status = state.working || state.compacting ? React.createElement(run_status_1.RunStatus, { state: state }) : undefined;
283
412
  const onHead = status && quiet(last);
284
- return (React.createElement(React.Fragment, null,
413
+ return (React.createElement(Outbox.Provider, { value: sent },
285
414
  items.map((item, index) => (React.createElement("div", { key: item.key, className: [
286
415
  'ta-thread-item',
287
416
  index >= front && index < items.length - SETTLED_AFTER && 'ta-settled',
@@ -291,7 +420,8 @@ function MessageList({ state }) {
291
420
  ]
292
421
  .filter(Boolean)
293
422
  .join(' ') },
294
- React.createElement(ThreadRow, { item: item, tools: state.tools, mood: item.kind === 'turn' ? process_1.ProcessUtil.mood(item, index === lastTurn, waiting) : 'idle', status: onHead && item === last ? status : undefined })))),
423
+ breaks[index] !== undefined && React.createElement(message_footer_1.TimeBreak, { timestamp: breaks[index] }),
424
+ React.createElement(ThreadRow, { item: item, tools: state.tools, mood: item.kind === 'turn' ? process_1.ProcessUtil.mood(item, index === lastTurn, waiting) : 'idle', status: onHead && item === last ? status : undefined, latest: index === lastTurn })))),
295
425
  status && !onHead && React.createElement("div", { className: "ta-run-line" }, status)));
296
426
  }
297
427
  //# sourceMappingURL=message-list.js.map
@@ -11,10 +11,12 @@ export type MessageMenuSubject = {
11
11
  last?: SessionMessage;
12
12
  reply: string;
13
13
  session?: TaSessionInfo;
14
+ messages?: SessionMessage[];
14
15
  };
15
16
  /**
16
17
  * The menu of a message under a held finger, as in WeChat: copy it, select its text (in a sheet of its own, as
17
- * WeChat shows a message to select from), and what its footer does.
18
+ * WeChat shows a message to select from), and what its footer does; above them, what the footer says (when,
19
+ * what the turn took), since a touch screen shows no footer but that of the last turn.
18
20
  * On a touch screen only; a right click elsewhere keeps the menu of the browser, which copies a selection.
19
21
  */
20
22
  export declare function useMessageMenu(subject: MessageMenuSubject): [React.ReactNode, ((event: React.MouseEvent<HTMLElement>) => void) | undefined];
@@ -37,6 +37,8 @@ exports.useMessageMenu = useMessageMenu;
37
37
  const React = __importStar(require("react"));
38
38
  const device_1 = require("../device/device");
39
39
  const use_t_1 = require("../i18n/use-t");
40
+ const message_1 = require("../util/message");
41
+ const progress_1 = require("../util/progress");
40
42
  const context_menu_1 = require("./context-menu");
41
43
  const message_footer_1 = require("./message-footer");
42
44
  const web_dialog_1 = require("./web-dialog");
@@ -44,11 +46,13 @@ const web_dialog_1 = require("./web-dialog");
44
46
  const OWN_PRESS = 'a, button, img, video, .ta-code, pre, .ta-process-steps, .ta-footer';
45
47
  /**
46
48
  * The menu of a message under a held finger, as in WeChat: copy it, select its text (in a sheet of its own, as
47
- * WeChat shows a message to select from), and what its footer does.
49
+ * WeChat shows a message to select from), and what its footer does; above them, what the footer says (when,
50
+ * what the turn took), since a touch screen shows no footer but that of the last turn.
48
51
  * On a touch screen only; a right click elsewhere keeps the menu of the browser, which copies a selection.
49
52
  */
50
53
  function useMessageMenu(subject) {
51
54
  const t = (0, use_t_1.useT)();
55
+ const timeLabel = (0, message_footer_1.useTimeLabel)();
52
56
  const touch = (0, device_1.useDevice)(device => device.touch);
53
57
  const actions = React.useContext(message_footer_1.MessageActions);
54
58
  const [menu, open] = (0, context_menu_1.useContextMenu)();
@@ -82,7 +86,18 @@ function useMessageMenu(subject) {
82
86
  items.push({ label: t('ta.message.debug'), run: () => copy(message_footer_1.MessageFooterUtil.debugInfo(last, subject.session), t('ta.message.debugCopied')) });
83
87
  }
84
88
  if (items.length) {
85
- open(event, items);
89
+ const said = subject.kind === 'user' ? subject.message : subject.last;
90
+ const at = said === null || said === void 0 ? void 0 : said.timestamp;
91
+ const usage = subject.kind === 'turn' && subject.messages ? message_1.MessageUtil.usage(subject.messages) : undefined;
92
+ const caption = [
93
+ at !== undefined && timeLabel(at),
94
+ usage &&
95
+ (usage.input > 0 || usage.output > 0) &&
96
+ `${t('ta.message.used')} ↑${progress_1.ProgressUtil.format(usage.input)} ↓${progress_1.ProgressUtil.format(usage.output)}${usage.cost > 0 ? ` ${message_1.MessageUtil.cost(usage.cost)}` : ''}`,
97
+ ]
98
+ .filter(Boolean)
99
+ .join(' · ');
100
+ open(event, items, caption || undefined);
86
101
  }
87
102
  };
88
103
  return [
@@ -1,3 +1,4 @@
1
+ import type { Hold } from '../device/hold';
1
2
  import { type WebViewEntry } from '../extension/web-extension-protocol';
2
3
  import { type NavigationSetting } from '../settings/navigation';
3
4
  import type { ContextMenuItem } from './context-menu';
@@ -8,6 +9,17 @@ import { type SideList } from './side-lists';
8
9
  * extensions started on open from the launcher (ta-launcher.md), as they come and go.
9
10
  */
10
11
  export declare function railPages(views: WebViewEntry[]): WebViewEntry[];
12
+ /**
13
+ * What an entry of the navigation does while it is held, without a menu: the double opens and listens to what is
14
+ * said to it, the chats open a new conversation that does (HeldTalk). None where the browser cannot recognize
15
+ * speech: the entries are a tap. The chats are the list without an id.
16
+ */
17
+ export interface EntryHolds {
18
+ double?: Hold;
19
+ chats?: Hold;
20
+ }
21
+ /** The hold of an entry of the navigation: the double's, the chats'; pages keep their menus (their fold and the settings). */
22
+ export declare function entryHold(id: string, double: boolean | undefined, holds: EntryHolds): Hold | undefined;
11
23
  /** The id of Discover where the navigation has the ids of pages: a tab of a phone, `current` of the rail. */
12
24
  export declare const DISCOVER = "ta/discover";
13
25
  /** The last tab of a phone: the account and the settings, as the menu of the account on the rail. */
@@ -38,10 +50,13 @@ export interface PhoneTabLabels {
38
50
  fold: string;
39
51
  /** The settings of the navigation, in the menu of a page's tab and of Discover. */
40
52
  settings: Exclude<ContextMenuItem, '-'>;
53
+ /** What a held tab of the double or of the chats does. */
54
+ holds: EntryHolds;
41
55
  }
42
56
  /**
43
57
  * The tabs at the bottom of a phone, as a messaging app has them: the lists of the sidebar, the chats, the pages
44
- * in the navigation, Discover once some are under it, Me. A held tab of a page puts it under Discover.
58
+ * in the navigation, Discover once some are under it, Me. A held tab of a page puts it under Discover; that of the
59
+ * double talks to it while it is held, and that of the chats to a new conversation.
45
60
  */
46
61
  export declare function phoneTabs(lists: SideList[], navigation: Navigation, labels: PhoneTabLabels): PhoneTab[];
47
62
  //# sourceMappingURL=nav-places.d.ts.map
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ME_TAB = exports.DISCOVER = void 0;
4
4
  exports.railPages = railPages;
5
+ exports.entryHold = entryHold;
5
6
  exports.fixedTabs = fixedTabs;
6
7
  exports.places = places;
7
8
  exports.phoneTabs = phoneTabs;
@@ -18,6 +19,13 @@ function railPages(views) {
18
19
  const listed = new Set(views.flatMap(view => { var _a; return (view.location === 'sidebar' ? ((_a = view.pages) !== null && _a !== void 0 ? _a : []) : []); }));
19
20
  return views.filter(view => view.location === 'page' && !view.onOpen && !listed.has(view.id));
20
21
  }
22
+ /** The hold of an entry of the navigation: the double's, the chats'; pages keep their menus (their fold and the settings). */
23
+ function entryHold(id, double, holds) {
24
+ if (double) {
25
+ return holds.double;
26
+ }
27
+ return id === '' ? holds.chats : undefined;
28
+ }
21
29
  /** The id of Discover where the navigation has the ids of pages: a tab of a phone, `current` of the rail. */
22
30
  exports.DISCOVER = 'ta/discover';
23
31
  /** The last tab of a phone: the account and the settings, as the menu of the account on the rail. */
@@ -36,7 +44,8 @@ function places(views, setting, handheld) {
36
44
  }
37
45
  /**
38
46
  * The tabs at the bottom of a phone, as a messaging app has them: the lists of the sidebar, the chats, the pages
39
- * in the navigation, Discover once some are under it, Me. A held tab of a page puts it under Discover.
47
+ * in the navigation, Discover once some are under it, Me. A held tab of a page puts it under Discover; that of the
48
+ * double talks to it while it is held, and that of the chats to a new conversation.
40
49
  */
41
50
  function phoneTabs(lists, navigation, labels) {
42
51
  const tab = (view, menu) => { var _a; return ({
@@ -45,9 +54,10 @@ function phoneTabs(lists, navigation, labels) {
45
54
  icon: (_a = view.icon) !== null && _a !== void 0 ? _a : lucide_react_1.PanelTop,
46
55
  menu,
47
56
  }); };
57
+ const list = (entry) => ({ ...entry, hold: entryHold(entry.id, entry.double, labels.holds) });
48
58
  return [
49
- ...(navigation.home ? [{ ...tab(navigation.home), double: true }] : []),
50
- ...lists,
59
+ ...(navigation.home ? [{ ...tab(navigation.home), double: true, hold: labels.holds.double }] : []),
60
+ ...lists.map(list),
51
61
  ...navigation.nav.map(view => tab(view, [{ label: labels.fold, run: () => navigation.fold(view.id) }, '-', labels.settings])),
52
62
  ...(navigation.discover.length > 0 ? [{ id: exports.DISCOVER, label: labels.discover, icon: lucide_react_1.Compass, menu: [labels.settings] }] : []),
53
63
  { id: exports.ME_TAB, label: labels.me, icon: lucide_react_1.User },
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+ import { type Hold } from '../device/hold';
2
3
  import type { WebIcon } from '../extension/web-extension-api';
3
4
  import { type ContextMenuItem } from './context-menu';
4
5
  /** A tab at the bottom of the phone: a list of the sidebar, a page of the rail, Discover, or Me. */
@@ -8,8 +9,10 @@ export interface PhoneTab {
8
9
  icon: WebIcon;
9
10
  /** The double's tab: drawn as its face (DinoFace), not its icon. */
10
11
  double?: boolean;
11
- /** Its menu, for a held finger. */
12
+ /** Its menu, for a held finger (the pages of the navigation, Discover). */
12
13
  menu?: ContextMenuItem[];
14
+ /** What it does while it is held instead: the double listens, the chats open a new conversation. */
15
+ hold?: Hold;
13
16
  }
14
17
  export interface PhoneShellProps {
15
18
  tabs: PhoneTab[];
@@ -41,6 +41,7 @@ const React = __importStar(require("react"));
41
41
  const back_stack_1 = require("../device/back-stack");
42
42
  const device_1 = require("../device/device");
43
43
  const device_protocol_1 = require("../device/device-protocol");
44
+ const hold_1 = require("../device/hold");
44
45
  const pull_down_1 = require("../device/pull-down");
45
46
  const sheet_swipe_1 = require("../device/sheet-swipe");
46
47
  const use_t_1 = require("../i18n/use-t");
@@ -235,11 +236,12 @@ function PhoneStack({ base, top, open, onClose }) {
235
236
  function TabBar({ tabs, tab, onTab }) {
236
237
  const t = (0, use_t_1.useT)();
237
238
  const [menu, openMenu] = (0, context_menu_1.useContextMenu)();
239
+ const held = (0, hold_1.useHeld)();
238
240
  return (React.createElement("nav", { className: "ta-tabbar", "aria-label": t('ta.menu') },
239
241
  tabs.map(item => {
240
242
  const Glyph = item.icon;
241
243
  const active = item.id === tab;
242
- return (React.createElement("button", { key: item.id, type: "button", className: `ta-tabbar-item${active ? ' ta-active' : ''}`, "aria-current": active ? 'page' : undefined, onClick: event => (active ? PhoneUtil.toTop(event.currentTarget.closest('.ta-phone-home')) : onTab(item.id)), onContextMenu: item.menu && (event => { var _a; return openMenu(event, (_a = item.menu) !== null && _a !== void 0 ? _a : []); }) },
244
+ return (React.createElement("button", { key: item.id, type: "button", className: `ta-tabbar-item${active ? ' ta-active' : ''}`, "aria-current": active ? 'page' : undefined, onClick: event => (active ? PhoneUtil.toTop(event.currentTarget.closest('.ta-phone-home')) : onTab(item.id)), onContextMenu: item.menu ? event => { var _a; return openMenu(event, (_a = item.menu) !== null && _a !== void 0 ? _a : []); } : undefined, ...held(item.hold) },
243
245
  item.double ? React.createElement(ta_avatar_1.DinoFace, { size: 24, className: "ta-nav-face" }) : React.createElement(Glyph, { size: 22, strokeWidth: active ? 2 : 1.6 }),
244
246
  React.createElement("span", null, item.label)));
245
247
  }),
@@ -40,11 +40,11 @@ const use_t_1 = require("../i18n/use-t");
40
40
  const progress_1 = require("../util/progress");
41
41
  const tool_1 = require("../util/tool");
42
42
  const icon_1 = require("./icon");
43
- function usePhaseText(phase) {
43
+ function usePhaseText(phase, working) {
44
44
  const t = (0, use_t_1.useT)();
45
45
  switch (phase.kind) {
46
46
  case 'waiting':
47
- return t('ta.progress.waiting');
47
+ return working !== null && working !== void 0 ? working : t('ta.progress.waiting');
48
48
  case 'thinking':
49
49
  return t('ta.session.phase.thinking');
50
50
  case 'writing':
@@ -74,7 +74,7 @@ function usePhaseText(phase) {
74
74
  function RunStatus({ state }) {
75
75
  const t = (0, use_t_1.useT)();
76
76
  const phase = progress_1.ProgressUtil.phase(state);
77
- const text = usePhaseText(phase);
77
+ const text = usePhaseText(phase, state.workingMessage);
78
78
  const { input, output } = progress_1.ProgressUtil.tokens(state);
79
79
  return (React.createElement("span", { className: "ta-run-status", role: "status" },
80
80
  React.createElement("span", { className: `ta-status ${phase.kind === 'attention' || phase.kind === 'retrying' ? 'ta-status-waiting' : 'ta-status-running'}` }),