@celljs/ta-web 4.47.1 → 4.49.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 (247) hide show
  1. package/esm/browser/assistant/assistant-role.d.ts +1 -1
  2. package/esm/browser/assistant/assistant-role.js +1 -1
  3. package/esm/browser/assistant/assistant-task-source.js +6 -1
  4. package/esm/browser/assistant/assistant-task-util.d.ts +1 -0
  5. package/esm/browser/assistant/assistant-task-util.js +9 -3
  6. package/esm/browser/assistant/assistant-view.js +4 -2
  7. package/esm/browser/cloud/cloud-sign-in.d.ts +26 -4
  8. package/esm/browser/cloud/cloud-sign-in.js +88 -18
  9. package/esm/browser/components/app-nav.d.ts +3 -1
  10. package/esm/browser/components/app-nav.js +3 -3
  11. package/esm/browser/components/app-view.js +16 -6
  12. package/esm/browser/components/asks-badge.d.ts +12 -0
  13. package/esm/browser/components/asks-badge.js +17 -1
  14. package/esm/browser/components/chat-list-row.d.ts +4 -1
  15. package/esm/browser/components/chat-list-row.js +7 -1
  16. package/esm/browser/components/chats-dot.d.ts +4 -1
  17. package/esm/browser/components/chats-dot.js +6 -2
  18. package/esm/browser/components/cloud-sign-in-view.d.ts +2 -1
  19. package/esm/browser/components/cloud-sign-in-view.js +28 -5
  20. package/esm/browser/components/composer-box-protocol.d.ts +5 -3
  21. package/esm/browser/components/composer-box.js +11 -11
  22. package/esm/browser/components/composer.d.ts +8 -1
  23. package/esm/browser/components/composer.js +57 -34
  24. package/esm/browser/components/host-view.d.ts +1 -1
  25. package/esm/browser/components/lightbox.d.ts +15 -1
  26. package/esm/browser/components/lightbox.js +14 -2
  27. package/esm/browser/components/link.js +8 -3
  28. package/esm/browser/components/markdown.d.ts +4 -2
  29. package/esm/browser/components/markdown.js +13 -4
  30. package/esm/browser/components/media.d.ts +6 -0
  31. package/esm/browser/components/media.js +9 -1
  32. package/esm/browser/components/message-images.d.ts +5 -0
  33. package/esm/browser/components/message-images.js +40 -4
  34. package/esm/browser/components/message-user.js +4 -2
  35. package/esm/browser/components/partner-row.js +4 -4
  36. package/esm/browser/components/phone-shell.d.ts +2 -0
  37. package/esm/browser/components/phone-shell.js +2 -2
  38. package/esm/browser/components/sending.d.ts +19 -0
  39. package/esm/browser/components/sending.js +27 -0
  40. package/esm/browser/components/session-view.js +4 -3
  41. package/esm/browser/components/settings-choices.js +1 -0
  42. package/esm/browser/components/settings-parts.js +28 -17
  43. package/esm/browser/components/share-dialog.js +3 -2
  44. package/esm/browser/components/share-item-sheet.js +1 -1
  45. package/esm/browser/components/share-sheet.d.ts +4 -2
  46. package/esm/browser/components/share-sheet.js +16 -2
  47. package/esm/browser/components/sign-in-accounts.js +7 -1
  48. package/esm/browser/components/unseen-drop.d.ts +2 -2
  49. package/esm/browser/components/unseen-drop.js +1 -1
  50. package/esm/browser/device/app-badge.d.ts +8 -0
  51. package/esm/browser/device/app-badge.js +28 -0
  52. package/esm/browser/device/code-scan.js +1 -1
  53. package/esm/browser/extension/web-api-code.d.ts +26 -0
  54. package/esm/browser/extension/web-api-components.d.ts +31 -0
  55. package/esm/browser/extension/web-api-menus.d.ts +15 -0
  56. package/esm/browser/extension/web-api-messages.d.ts +15 -0
  57. package/esm/browser/extension/web-api-messages.js +2 -0
  58. package/esm/browser/extension/web-api-partners.d.ts +16 -0
  59. package/esm/browser/extension/web-api-spec.js +1 -0
  60. package/esm/browser/extension/web-extension-api.d.ts +7 -13
  61. package/esm/browser/extension/web-extension-context.js +2 -0
  62. package/esm/browser/extension/web-session-notices.js +11 -2
  63. package/esm/browser/extension/web-share-ui.js +1 -0
  64. package/esm/browser/extension/web-share.js +3 -3
  65. package/esm/browser/extension/web-sharing.js +1 -1
  66. package/esm/browser/i18n/en/assistant.d.ts +2 -0
  67. package/esm/browser/i18n/en/assistant.js +2 -0
  68. package/esm/browser/i18n/en/chat.d.ts +11 -0
  69. package/esm/browser/i18n/en/chat.js +13 -2
  70. package/esm/browser/i18n/en/common.d.ts +4 -0
  71. package/esm/browser/i18n/en/common.js +4 -0
  72. package/esm/browser/i18n/en/service.d.ts +5 -0
  73. package/esm/browser/i18n/en/service.js +5 -0
  74. package/esm/browser/i18n/en/settings.d.ts +6 -0
  75. package/esm/browser/i18n/en/settings.js +8 -2
  76. package/esm/browser/i18n/ja/assistant.js +2 -0
  77. package/esm/browser/i18n/ja/chat.js +13 -2
  78. package/esm/browser/i18n/ja/common.js +4 -0
  79. package/esm/browser/i18n/ja/service.js +5 -0
  80. package/esm/browser/i18n/ja/settings.js +10 -4
  81. package/esm/browser/i18n/locales.d.ts +29 -1
  82. package/esm/browser/i18n/messages.d.ts +28 -0
  83. package/esm/browser/i18n/zh/assistant.js +2 -0
  84. package/esm/browser/i18n/zh/chat.js +13 -2
  85. package/esm/browser/i18n/zh/common.js +4 -0
  86. package/esm/browser/i18n/zh/service.js +5 -0
  87. package/esm/browser/i18n/zh/settings.js +8 -2
  88. package/esm/browser/i18n/zh-tw/assistant.js +2 -0
  89. package/esm/browser/i18n/zh-tw/chat.js +13 -2
  90. package/esm/browser/i18n/zh-tw/common.js +4 -0
  91. package/esm/browser/i18n/zh-tw/service.js +5 -0
  92. package/esm/browser/i18n/zh-tw/settings.js +8 -2
  93. package/esm/browser/links/links.js +1 -1
  94. package/esm/browser/notices/session-notices.d.ts +4 -4
  95. package/esm/browser/notices/session-notices.js +3 -6
  96. package/esm/browser/partners/partners-util.d.ts +6 -0
  97. package/esm/browser/partners/partners-util.js +22 -0
  98. package/esm/browser/sandbox/sandbox-runtime-code.js +1 -1
  99. package/esm/browser/settings/agent-settings.d.ts +2 -0
  100. package/esm/browser/settings/agent-settings.js +2 -0
  101. package/esm/browser/settings/settings-protocol.d.ts +8 -0
  102. package/esm/browser/settings/settings-protocol.js +5 -0
  103. package/esm/browser/style/base.d.ts +1 -1
  104. package/esm/browser/style/base.js +3 -0
  105. package/esm/browser/style/chat-list.d.ts +1 -1
  106. package/esm/browser/style/chat-list.js +8 -3
  107. package/esm/browser/style/conversation-column.d.ts +1 -1
  108. package/esm/browser/style/conversation-column.js +6 -1
  109. package/esm/browser/style/conversation.d.ts +1 -1
  110. package/esm/browser/style/conversation.js +18 -0
  111. package/esm/browser/style/phone.d.ts +1 -1
  112. package/esm/browser/style/phone.js +2 -0
  113. package/esm/browser/util/composer.d.ts +18 -3
  114. package/esm/browser/util/composer.js +31 -5
  115. package/esm/browser/util/desktop.d.ts +8 -1
  116. package/esm/browser/util/desktop.js +10 -0
  117. package/esm/browser/util/image-shrink.d.ts +5 -1
  118. package/esm/browser/util/image-shrink.js +1 -1
  119. package/esm/browser/util/markdown.d.ts +3 -5
  120. package/esm/browser/util/markdown.js +5 -29
  121. package/esm/browser/util/process.js +2 -2
  122. package/lib/browser/assistant/assistant-role.d.ts +1 -1
  123. package/lib/browser/assistant/assistant-role.js +1 -1
  124. package/lib/browser/assistant/assistant-task-source.js +5 -0
  125. package/lib/browser/assistant/assistant-task-util.d.ts +1 -0
  126. package/lib/browser/assistant/assistant-task-util.js +8 -2
  127. package/lib/browser/assistant/assistant-view.js +4 -2
  128. package/lib/browser/cloud/cloud-sign-in.d.ts +26 -4
  129. package/lib/browser/cloud/cloud-sign-in.js +89 -19
  130. package/lib/browser/components/app-nav.d.ts +3 -1
  131. package/lib/browser/components/app-nav.js +2 -2
  132. package/lib/browser/components/app-view.js +16 -6
  133. package/lib/browser/components/asks-badge.d.ts +12 -0
  134. package/lib/browser/components/asks-badge.js +19 -1
  135. package/lib/browser/components/chat-list-row.d.ts +4 -1
  136. package/lib/browser/components/chat-list-row.js +7 -1
  137. package/lib/browser/components/chats-dot.d.ts +4 -1
  138. package/lib/browser/components/chats-dot.js +6 -2
  139. package/lib/browser/components/cloud-sign-in-view.d.ts +2 -1
  140. package/lib/browser/components/cloud-sign-in-view.js +28 -5
  141. package/lib/browser/components/composer-box-protocol.d.ts +5 -3
  142. package/lib/browser/components/composer-box.js +11 -11
  143. package/lib/browser/components/composer.d.ts +8 -1
  144. package/lib/browser/components/composer.js +56 -33
  145. package/lib/browser/components/host-view.d.ts +1 -1
  146. package/lib/browser/components/lightbox.d.ts +15 -1
  147. package/lib/browser/components/lightbox.js +15 -2
  148. package/lib/browser/components/link.js +8 -3
  149. package/lib/browser/components/markdown.d.ts +4 -2
  150. package/lib/browser/components/markdown.js +11 -2
  151. package/lib/browser/components/media.d.ts +6 -0
  152. package/lib/browser/components/media.js +10 -2
  153. package/lib/browser/components/message-images.d.ts +5 -0
  154. package/lib/browser/components/message-images.js +40 -4
  155. package/lib/browser/components/message-user.js +4 -2
  156. package/lib/browser/components/partner-row.js +4 -4
  157. package/lib/browser/components/phone-shell.d.ts +2 -0
  158. package/lib/browser/components/phone-shell.js +1 -1
  159. package/lib/browser/components/sending.d.ts +20 -0
  160. package/lib/browser/components/sending.js +63 -0
  161. package/lib/browser/components/session-view.js +4 -3
  162. package/lib/browser/components/settings-choices.js +1 -0
  163. package/lib/browser/components/settings-parts.js +26 -15
  164. package/lib/browser/components/share-dialog.js +3 -2
  165. package/lib/browser/components/share-item-sheet.js +1 -1
  166. package/lib/browser/components/share-sheet.d.ts +4 -2
  167. package/lib/browser/components/share-sheet.js +16 -2
  168. package/lib/browser/components/sign-in-accounts.js +7 -1
  169. package/lib/browser/components/unseen-drop.d.ts +2 -2
  170. package/lib/browser/components/unseen-drop.js +1 -1
  171. package/lib/browser/device/app-badge.d.ts +9 -0
  172. package/lib/browser/device/app-badge.js +31 -0
  173. package/lib/browser/device/code-scan.js +1 -1
  174. package/lib/browser/extension/web-api-code.d.ts +26 -0
  175. package/lib/browser/extension/web-api-components.d.ts +31 -0
  176. package/lib/browser/extension/web-api-menus.d.ts +15 -0
  177. package/lib/browser/extension/web-api-messages.d.ts +16 -0
  178. package/lib/browser/extension/web-api-messages.js +3 -0
  179. package/lib/browser/extension/web-api-partners.d.ts +16 -0
  180. package/lib/browser/extension/web-api-spec.js +1 -0
  181. package/lib/browser/extension/web-extension-api.d.ts +7 -13
  182. package/lib/browser/extension/web-extension-context.js +2 -0
  183. package/lib/browser/extension/web-session-notices.js +10 -1
  184. package/lib/browser/extension/web-share-ui.js +1 -0
  185. package/lib/browser/extension/web-share.js +3 -3
  186. package/lib/browser/extension/web-sharing.js +1 -1
  187. package/lib/browser/i18n/en/assistant.d.ts +2 -0
  188. package/lib/browser/i18n/en/assistant.js +2 -0
  189. package/lib/browser/i18n/en/chat.d.ts +11 -0
  190. package/lib/browser/i18n/en/chat.js +13 -2
  191. package/lib/browser/i18n/en/common.d.ts +4 -0
  192. package/lib/browser/i18n/en/common.js +4 -0
  193. package/lib/browser/i18n/en/service.d.ts +5 -0
  194. package/lib/browser/i18n/en/service.js +5 -0
  195. package/lib/browser/i18n/en/settings.d.ts +6 -0
  196. package/lib/browser/i18n/en/settings.js +8 -2
  197. package/lib/browser/i18n/ja/assistant.js +2 -0
  198. package/lib/browser/i18n/ja/chat.js +13 -2
  199. package/lib/browser/i18n/ja/common.js +4 -0
  200. package/lib/browser/i18n/ja/service.js +5 -0
  201. package/lib/browser/i18n/ja/settings.js +10 -4
  202. package/lib/browser/i18n/locales.d.ts +29 -1
  203. package/lib/browser/i18n/messages.d.ts +28 -0
  204. package/lib/browser/i18n/zh/assistant.js +2 -0
  205. package/lib/browser/i18n/zh/chat.js +13 -2
  206. package/lib/browser/i18n/zh/common.js +4 -0
  207. package/lib/browser/i18n/zh/service.js +5 -0
  208. package/lib/browser/i18n/zh/settings.js +8 -2
  209. package/lib/browser/i18n/zh-tw/assistant.js +2 -0
  210. package/lib/browser/i18n/zh-tw/chat.js +13 -2
  211. package/lib/browser/i18n/zh-tw/common.js +4 -0
  212. package/lib/browser/i18n/zh-tw/service.js +5 -0
  213. package/lib/browser/i18n/zh-tw/settings.js +8 -2
  214. package/lib/browser/links/links.js +1 -1
  215. package/lib/browser/notices/session-notices.d.ts +4 -4
  216. package/lib/browser/notices/session-notices.js +3 -6
  217. package/lib/browser/partners/partners-util.d.ts +6 -0
  218. package/lib/browser/partners/partners-util.js +22 -0
  219. package/lib/browser/sandbox/sandbox-runtime-code.js +1 -1
  220. package/lib/browser/settings/agent-settings.d.ts +2 -0
  221. package/lib/browser/settings/agent-settings.js +3 -1
  222. package/lib/browser/settings/settings-protocol.d.ts +8 -0
  223. package/lib/browser/settings/settings-protocol.js +6 -1
  224. package/lib/browser/style/base.d.ts +1 -1
  225. package/lib/browser/style/base.js +3 -0
  226. package/lib/browser/style/chat-list.d.ts +1 -1
  227. package/lib/browser/style/chat-list.js +8 -3
  228. package/lib/browser/style/conversation-column.d.ts +1 -1
  229. package/lib/browser/style/conversation-column.js +6 -1
  230. package/lib/browser/style/conversation.d.ts +1 -1
  231. package/lib/browser/style/conversation.js +18 -0
  232. package/lib/browser/style/phone.d.ts +1 -1
  233. package/lib/browser/style/phone.js +2 -0
  234. package/lib/browser/util/composer.d.ts +18 -3
  235. package/lib/browser/util/composer.js +31 -5
  236. package/lib/browser/util/desktop.d.ts +8 -1
  237. package/lib/browser/util/desktop.js +10 -0
  238. package/lib/browser/util/image-shrink.d.ts +5 -1
  239. package/lib/browser/util/image-shrink.js +1 -1
  240. package/lib/browser/util/markdown.d.ts +3 -5
  241. package/lib/browser/util/markdown.js +5 -29
  242. package/lib/browser/util/process.js +1 -1
  243. package/package.json +7 -7
  244. package/esm/browser/util/share-link.d.ts +0 -21
  245. package/esm/browser/util/share-link.js +0 -61
  246. package/lib/browser/util/share-link.d.ts +0 -22
  247. package/lib/browser/util/share-link.js +0 -64
@@ -1,6 +1,6 @@
1
1
  import { type TaDelegateLevel } from '@celljs/ta-protocol';
2
2
  /** The role of ta in its conversation with the user. */
3
- export declare const ASSISTANT_PROMPT = "You are Ta, the user's personal agent: a little green dinosaur they talk to by voice or text in a web page. The user hands you work and mostly does not care how it gets done: you talk with them and hand the work out to tasks, which do it.\n- To hand out work, call start_task with a short title and complete, self-contained instructions: a task runs in its own session that cannot see this conversation. Say in them what to do and what to answer, never how the answer looks (its length, its format): Ta shows every answer as the user reads it. Start independent tasks in parallel. Then tell the user in one sentence what you started.\n- A task opens in the user's default directory, which they may change at any time; start_task says which it was. Give a cwd only when the user names a directory.\n- When tasks change code in parallel, or a change should not touch the user's working copy until they agree, start them with isolate: each works in a git worktree of its own, on a branch of its own, and its update says which; merging is for the user to ask.\n- Give verify only for a change a second look may catch out: code changed across several files, or behavior the user relies on. Not for documents, a small fix of a file or two, research, or what the task checks well itself. verify is one check (a command such as \"bun test\", or one thing to look at), not a list; and when you give it, add no steps of checking again to the instructions: the check does that. When such a task ends, its update asks you to start a check: do it with start_task and verifies, with the instructions it gives as they are, and tell the user what the check found.\n- When the user asks what goes on, list_tasks has your tasks and the conversations they have going on themselves. You cannot write to those or stop them: tell the user, and if they want you to follow one, they hand it to you from the list of chats.\n- When a <task_update> message arrives, the user already sees that the task ended and what it said, its cards too: tell them in one or two sentences what was done and what was not, and whether they need to decide anything. Do not repeat the numbers, lists of files, comparisons or tests it already shows, and write no card of your own for it. With nothing to decide, suggest nothing; with something, name that one thing alone. get_task has the details.\n- What the user says is often spoken and transcribed, with wrong words and sentences cut off: read it for what they mean, with what was said before. A message from a call ([ta:from @celljs/ta-call \u2026]) is the user's own request, retold by the call: \"the user wants X\" means they ask you for X.\n- When they ask for something to be done (\"\u5E2E\u6211\u5F04\", \"\u5E2E\u6211\u6539\", \"\u6362\u4E00\u4E2A\", \"\u88C5\u4E0A\", \"\u6253\u5F00\u2026\"), that is their go: start it now, in this turn, then say in one sentence what you started, with asked: true. Do not ask first whether to start, nor offer to, nor stop at saying what you would do.\n- A short go (\"\u6765\", \"\u597D\", \"\u5F00\u59CB\", \"\u884C\", \"\u55EF\") answers what you said last: do what you proposed, or the most likely of what waits for them (the step they usually take next, as installing what was just changed, before what needs their taste), with asked: true, and say in one sentence which you took. Ask only when two are as likely, and then one yes-or-no question with your best guess (\"\u88C5\u5230\u624B\u673A\u4E0A\uFF0C\u5BF9\u5427\uFF1F\"), never a card of choices.\n- What a task can find out (which voices a service has, where a setting is, which file) is no question for the user: the task finds it, picks what fits, does it and tries it. A taste they did not say (a man's or a woman's voice) is yours to pick: say what you picked, so they can change it.\n- Instructions of a task say to get it done and checked: the result the user wants, how the task shows it works (it tries it, as the user would), and that it asks them only before what is risky or cannot be undone.\n- What the user asks of their screen (open a page, look at what is wrong, press something) is done on the page in front of them, on the device they use, a phone's on a phone: do it yourself, with app_look, app_go and app_do; a message from a call says which device. Never the computer's desktop (screenshots, tools that drive the computer) unless they name the computer.\n- When you cannot tell what they want at all (words that ask for nothing, a sentence cut off), say in one short sentence what you heard and ask them to say it again; never answer nothing.\n- Ask first only before what is risky or cannot be undone (deleting, publishing, sending or paying for them) that they did not clearly ask for.\n- Your replies are read aloud: short plain sentences, no tables, no code unless asked. Short is not vague: say what you started, picked or found. Reply in the user's language.";
3
+ export declare const ASSISTANT_PROMPT = "You are Ta, the user's personal agent: a little green dinosaur they talk to by voice or text in a web page. The user hands you work and mostly does not care how it gets done: you talk with them and hand the work out to tasks, which do it.\n- To hand out work, call start_task with a short title and complete, self-contained instructions (its two required fields, named title and instructions): a task runs in its own session that cannot see this conversation. Say in them what to do and what to answer, never how the answer looks (its length, its format): Ta shows every answer as the user reads it. Start independent tasks in parallel. Then tell the user in one sentence what you started.\n- A task opens in the user's default directory, which they may change at any time; start_task says which it was. Give a cwd only when the user names a directory.\n- When tasks change code in parallel, or a change should not touch the user's working copy until they agree, start them with isolate: each works in a git worktree of its own, on a branch of its own, and its update says which; merging is for the user to ask.\n- Give verify only for a change a second look may catch out: code changed across several files, or behavior the user relies on. Not for documents, a small fix of a file or two, research, or what the task checks well itself. verify is one check (a command such as \"bun test\", or one thing to look at), not a list; and when you give it, add no steps of checking again to the instructions: the check does that. When such a task ends, its update asks you to start a check: do it with start_task and verifies, with the instructions it gives as they are, and tell the user what the check found.\n- When the user asks what goes on, list_tasks has your tasks and the conversations they have going on themselves. You cannot write to those or stop them: tell the user, and if they want you to follow one, they hand it to you from the list of chats.\n- When a <task_update> message arrives, the user already sees that the task ended and what it said, its cards too: tell them in one or two sentences what was done and what was not, and whether they need to decide anything. Do not repeat the numbers, lists of files, comparisons or tests it already shows, and write no card of your own for it. With nothing to decide, suggest nothing; with something, name that one thing alone. get_task has the details.\n- What the user says is often spoken and transcribed, with wrong words and sentences cut off: read it for what they mean, with what was said before. A message from a call ([ta:from @celljs/ta-call \u2026]) is the user's own request, retold by the call: \"the user wants X\" means they ask you for X.\n- When they ask for something to be done (\"\u5E2E\u6211\u5F04\", \"\u5E2E\u6211\u6539\", \"\u6362\u4E00\u4E2A\", \"\u88C5\u4E0A\", \"\u6253\u5F00\u2026\"), that is their go: start it now, in this turn, then say in one sentence what you started, with asked: true. Do not ask first whether to start, nor offer to, nor stop at saying what you would do.\n- A short go (\"\u6765\", \"\u597D\", \"\u5F00\u59CB\", \"\u884C\", \"\u55EF\") answers what you said last: do what you proposed, or the most likely of what waits for them (the step they usually take next, as installing what was just changed, before what needs their taste), with asked: true, and say in one sentence which you took. Ask only when two are as likely, and then one yes-or-no question with your best guess (\"\u88C5\u5230\u624B\u673A\u4E0A\uFF0C\u5BF9\u5427\uFF1F\"), never a card of choices.\n- What a task can find out (which voices a service has, where a setting is, which file) is no question for the user: the task finds it, picks what fits, does it and tries it. A taste they did not say (a man's or a woman's voice) is yours to pick: say what you picked, so they can change it.\n- Instructions of a task say to get it done and checked: the result the user wants, how the task shows it works (it tries it, as the user would), and that it asks them only before what is risky or cannot be undone.\n- What the user asks of their screen (open a page, look at what is wrong, press something) is done on the page in front of them, on the device they use, a phone's on a phone: do it yourself, with app_look, app_go and app_do; a message from a call says which device. Never the computer's desktop (screenshots, tools that drive the computer) unless they name the computer.\n- When you cannot tell what they want at all (words that ask for nothing, a sentence cut off), say in one short sentence what you heard and ask them to say it again; never answer nothing.\n- Ask first only before what is risky or cannot be undone (deleting, publishing, sending or paying for them) that they did not clearly ask for.\n- Your replies are read aloud: short plain sentences, no tables, no code unless asked. Short is not vague: say what you started, picked or found. Reply in the user's language.";
4
4
  /**
5
5
  * In the role while the user wants to be asked first (Settings.confirmTasks): of what the double starts of its own
6
6
  * accord only, never twice (docs/design/ta-double.md, 听懂与派活). The team tools of ta-channels read the same words in the
@@ -1,7 +1,7 @@
1
1
  import { TaDelegateUtil } from '@celljs/ta-protocol';
2
2
  /** The role of ta in its conversation with the user. */
3
3
  export const ASSISTANT_PROMPT = `You are Ta, the user's personal agent: a little green dinosaur they talk to by voice or text in a web page. The user hands you work and mostly does not care how it gets done: you talk with them and hand the work out to tasks, which do it.
4
- - To hand out work, call start_task with a short title and complete, self-contained instructions: a task runs in its own session that cannot see this conversation. Say in them what to do and what to answer, never how the answer looks (its length, its format): Ta shows every answer as the user reads it. Start independent tasks in parallel. Then tell the user in one sentence what you started.
4
+ - To hand out work, call start_task with a short title and complete, self-contained instructions (its two required fields, named title and instructions): a task runs in its own session that cannot see this conversation. Say in them what to do and what to answer, never how the answer looks (its length, its format): Ta shows every answer as the user reads it. Start independent tasks in parallel. Then tell the user in one sentence what you started.
5
5
  - A task opens in the user's default directory, which they may change at any time; start_task says which it was. Give a cwd only when the user names a directory.
6
6
  - When tasks change code in parallel, or a change should not touch the user's working copy until they agree, start them with isolate: each works in a git worktree of its own, on a branch of its own, and its update says which; merging is for the user to ask.
7
7
  - Give verify only for a change a second look may catch out: code changed across several files, or behavior the user relies on. Not for documents, a small fix of a file or two, research, or what the task checks well itself. verify is one check (a command such as "bun test", or one thing to look at), not a list; and when you give it, add no steps of checking again to the instructions: the check does that. When such a task ends, its update asks you to start a check: do it with start_task and verifies, with the instructions it gives as they are, and tell the user what the check found.
@@ -1,4 +1,4 @@
1
- import { TaSaid } from '@celljs/ta-protocol';
1
+ import { TaDeadEnd, TaSaid } from '@celljs/ta-protocol';
2
2
  import { ShieldCheck } from 'lucide-react';
3
3
  import { ProgressUtil } from '../util/progress.js';
4
4
  import { AssistantTaskUtil } from './assistant-task-util.js';
@@ -13,6 +13,11 @@ export function activity(task, state, t) {
13
13
  if (task.paused && task.status !== 'running') {
14
14
  return t('ta.task.paused');
15
15
  }
16
+ // Not done because its reply came to nothing (filtered, empty): why, in the user's language.
17
+ const deadEnd = task.status === 'failed' ? TaDeadEnd.describedKind(task.result) : undefined;
18
+ if (deadEnd) {
19
+ return t(deadEnd === 'empty' ? 'ta.task.deadEndEmpty' : 'ta.task.deadEndFiltered');
20
+ }
16
21
  return task.status === 'running' ? t('ta.task.running') : TaSaid.line(said !== null && said !== void 0 ? said : '', { chars: 80 }) || t(`ta.task.${task.status}`);
17
22
  }
18
23
  /** How a task came out of a check: its own verdict for a check that ended, else the verdict of the check of it. */
@@ -41,6 +41,7 @@ export declare namespace AssistantTaskUtil {
41
41
  timestamp?: number;
42
42
  stopReason?: string;
43
43
  errorMessage?: string;
44
+ content?: unknown;
44
45
  } | undefined;
45
46
  /** How the run of a task's session ended (ended), and the id of the message that tells the double, the same in every page. */
46
47
  function outcome(state: SessionState): {
@@ -1,4 +1,4 @@
1
- import { TaMessageSource, TaTaskNote } from '@celljs/ta-protocol';
1
+ import { TaDeadEnd, TaMessageSource, TaTaskNote } from '@celljs/ta-protocol';
2
2
  import { MessageUtil } from '../util/message.js';
3
3
  /** The tasks kept: the last ones, those taken off the list among them. */
4
4
  export const MAX_TASKS = 50;
@@ -103,9 +103,12 @@ export var AssistantTaskUtil;
103
103
  var _a, _b, _c;
104
104
  const last = lastAnswer(state.messages);
105
105
  const reason = MessageUtil.stopReason(last);
106
+ // A reply that came to nothing (filtered, refused, empty) is no answer: not done, and its words are not the result.
107
+ const deadEnd = TaDeadEnd.kind({ role: 'assistant', ...last });
106
108
  // Its last answer asked for a tool, whose result never came: the run was cut, not done.
107
- const status = state.closed || reason === 'aborted' || reason === 'toolUse' ? 'stopped' : reason === 'error' ? 'failed' : 'done';
108
- const result = (_b = (_a = (status === 'failed' ? last === null || last === void 0 ? void 0 : last.errorMessage : undefined)) !== null && _a !== void 0 ? _a : lastWords(state.messages)) !== null && _b !== void 0 ? _b : '';
109
+ const status = state.closed || reason === 'aborted' || reason === 'toolUse' ? 'stopped' : reason === 'error' || deadEnd ? 'failed' : 'done';
110
+ const failure = deadEnd ? TaDeadEnd.describe(deadEnd, last === null || last === void 0 ? void 0 : last.errorMessage) : last === null || last === void 0 ? void 0 : last.errorMessage;
111
+ const result = (_b = (_a = (status === 'failed' ? failure : undefined)) !== null && _a !== void 0 ? _a : lastWords(state.messages)) !== null && _b !== void 0 ? _b : '';
109
112
  return { status, result, endedAt: state.closed ? undefined : last === null || last === void 0 ? void 0 : last.timestamp, key: `${status}:${(_c = last === null || last === void 0 ? void 0 : last.timestamp) !== null && _c !== void 0 ? _c : 0}` };
110
113
  }
111
114
  AssistantTaskUtil.outcome = outcome;
@@ -119,6 +122,9 @@ export var AssistantTaskUtil;
119
122
  function updateNote(task) {
120
123
  var _a, _b;
121
124
  const lines = [((_a = task.result) !== null && _a !== void 0 ? _a : '').slice(0, RESULT_CHARS)];
125
+ if (task.status === 'failed' && TaDeadEnd.described(task.result)) {
126
+ lines.push('Do not start it again on your own: tell the user it is not done and why, and let them decide.');
127
+ }
122
128
  if (task.paused) {
123
129
  lines.push('The user paused it, with the other tasks that ran: leave it until they resume it.');
124
130
  }
@@ -25,6 +25,7 @@ import { WorkbenchToggle } from '../components/workbench-toggle.js';
25
25
  import { DraftPlaces } from '../drafts/drafts-protocol.js';
26
26
  import { useNotices, usePersisted, useSessionState, useSettings, useTasks, useWebExtensions, useWorkbench } from '../hooks.js';
27
27
  import { useT } from '../i18n/use-t.js';
28
+ import { QUEUE_SETTINGS } from '../settings/agent-settings.js';
28
29
  import { MessageUtil } from '../util/message.js';
29
30
  import { useAssistant, useLastActive, useNow, useTaskStates } from './assistant-hooks.js';
30
31
  import { ASSISTANT_NAME_STATE } from './assistant-state.js';
@@ -96,7 +97,8 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
96
97
  const [, notices] = useNotices();
97
98
  const spoken = React.useRef(undefined);
98
99
  const box = React.useRef(null);
99
- const { speak, speakTalk, confirmTasks, delegate, voice } = settingsState.settings;
100
+ const { speak, speakTalk, confirmTasks, delegate, voice, sendWhileWorking } = settingsState.settings;
101
+ const [, extensions] = useWebExtensions();
100
102
  const [name] = usePersisted(ASSISTANT_NAME_STATE);
101
103
  const attentions = [
102
104
  ...state.pendingUi.map(request => ({ source: 'ta', store, request })),
@@ -321,7 +323,7 @@ function Chat({ store, tasks, taskStates, onTask, onMood, onTasks }) {
321
323
  React.createElement(ConnectionBanner, null),
322
324
  addons.above,
323
325
  React.createElement(CallBar, { state: callState, call: call }),
324
- React.createElement(Composer, { above: React.createElement(PhoneHint, null), ref: box, store: store, server: bench.server, workspace: bench.workspace, working: state.working, compacting: !!state.compacting, commands: session.settings.commands, cwd: cwd, placeholder: t('ta.assistant.placeholder'), actions: actions, onSending: hush, onStopTimed: stopTimed, onError: fail, after: speaking ? React.createElement(SpeakingButton, { onStop: hush }) : undefined, voiceSends: true, recentShots: settingsState.settings.recentShots, talkPlace: "double", draft: DraftPlaces.DOUBLE, onTalkSent: () => {
326
+ React.createElement(Composer, { above: React.createElement(PhoneHint, null), ref: box, store: store, server: bench.server, workspace: bench.workspace, working: state.working, compacting: !!state.compacting, commands: session.settings.commands, cwd: cwd, placeholder: t('ta.assistant.placeholder'), actions: actions, onSending: hush, onStopTimed: stopTimed, onError: fail, after: speaking ? React.createElement(SpeakingButton, { onStop: hush }) : undefined, voiceSends: true, recentShots: settingsState.settings.recentShots, sendWhileWorking: sendWhileWorking, onQueueSettings: () => extensions.openSettings(QUEUE_SETTINGS), talkPlace: "double", draft: DraftPlaces.DOUBLE, onTalkSent: () => {
325
327
  aloud.current = speakTalk;
326
328
  }, onTalkCall: Voice.canSpeak() && Voice.canListen() && !callState.active ? talkCall(call) : undefined, talkCalls: talkCalls, onListening: on => {
327
329
  setListening(on);
@@ -1,4 +1,4 @@
1
- import { TaDeploymentUtil, type TaDeviceSignIn, type TaDeviceSignInState, type TaDistribution, type TaSignInProvider } from '@celljs/ta-protocol';
1
+ import { TaDeploymentUtil, type TaDeviceSignIn, type TaDeviceSignInFailure, type TaDeviceSignInState, type TaDistribution, type TaSignInProvider } from '@celljs/ta-protocol';
2
2
  import type { Credential } from '../workbench-protocol.js';
3
3
  /** Why signing in to Ta in the cloud stopped: the address answers no gateway, does not answer, or the code ran out. */
4
4
  export declare class CloudSignInError extends Error {
@@ -12,7 +12,15 @@ export interface CloudSignInProgress {
12
12
  waiting?: string;
13
13
  /** The browser went straight to a way to sign in, no code to check there (CloudSignIn's `provider`). */
14
14
  direct?: true;
15
+ /** The sign-in there did not go through (TaDeviceSignInState `failed`): the user starts it again from here. */
16
+ failed?: TaDeviceSignInFailure;
17
+ /** The code ran out, or the gateway lost it, and a new one is ready: the browser to be opened again. */
18
+ renewed?: true;
19
+ /** The gateway has not answered for a while (restarting, the network gone): asked on, and said so. */
20
+ offline?: true;
15
21
  }
22
+ /** How long the gateway may not answer the polls before the sign-in says it is reconnecting. */
23
+ export declare const OFFLINE_MS = 6000;
16
24
  /**
17
25
  * Signing this device in to Ta in the cloud of a deployment, with an account (docs/design/ta-deploy.md 8.1): no code to
18
26
  * scan, no token to paste. The gateway of the address gives a code (TA_DEVICE_SIGN_IN_PATH), the user signs in in a
@@ -61,12 +69,14 @@ export declare namespace CloudSignInUtil {
61
69
  /** Where the browser signs in for the device of `code` with `provider` at once, as RFC 8628's verification_uri_complete. */
62
70
  function direct(gateway: string, provider: string, code: string): string;
63
71
  function start(gateway: string, name: string, fetcher?: typeof fetch): Promise<TaDeviceSignIn>;
64
- /** One poll: a network that drops for a moment is `pending`, as nothing changed. */
65
- function poll(gateway: string, device: string, fetcher?: typeof fetch): Promise<TaDeviceSignInState>;
72
+ /** One poll; undefined when the gateway did not answer (the network, a restart): nothing changed, asked again. */
73
+ function poll(gateway: string, device: string, fetcher?: typeof fetch): Promise<TaDeviceSignInState | undefined>;
66
74
  }
67
75
  /**
68
76
  * One sign-in to Ta in the cloud, from asking for the code until the token: it polls until then, or until stopped. What
69
- * it shows goes to `onProgress`; the browser is opened by `open`.
77
+ * it shows goes to `onProgress`; the browser is opened by `open`. It does not end on what the user can get past from
78
+ * here: a sign-in that failed at the provider, the gateway away for a while, a code that ran out (`renews`) each show,
79
+ * and the browser opened again (`reopen`) takes it on (docs/design/ta-deploy.md 8.5).
70
80
  */
71
81
  export declare class CloudSignIn {
72
82
  protected readonly options: {
@@ -77,11 +87,16 @@ export declare class CloudSignIn {
77
87
  onProgress(progress: CloudSignInProgress): void;
78
88
  /** A way to sign in of the gateway the browser goes to at once, rather than the page that shows the code. */
79
89
  provider?: string;
90
+ /** How many times a code that ran out is quietly replaced by a new one, rather than failing; none by default. */
91
+ renews?: number;
80
92
  fetcher?: typeof fetch;
81
93
  };
82
94
  protected stopped: boolean;
83
95
  protected timer?: ReturnType<typeof setTimeout>;
84
96
  protected wake?: () => void;
97
+ protected progress?: CloudSignInProgress;
98
+ /** Opened again after it failed: what the gateway said before is old until it says something else. */
99
+ protected reopened: boolean;
85
100
  constructor(options: {
86
101
  gateway: string;
87
102
  /** What the sign-ins of the account list this device as: its user agent, as a browser's. */
@@ -90,10 +105,17 @@ export declare class CloudSignIn {
90
105
  onProgress(progress: CloudSignInProgress): void;
91
106
  /** A way to sign in of the gateway the browser goes to at once, rather than the page that shows the code. */
92
107
  provider?: string;
108
+ /** How many times a code that ran out is quietly replaced by a new one, rather than failing; none by default. */
109
+ renews?: number;
93
110
  fetcher?: typeof fetch;
94
111
  });
95
112
  /** The credential of the gateway once signed in; undefined when stopped. */
96
113
  run(): Promise<Credential | undefined>;
114
+ protected wait(started: TaDeviceSignIn): Promise<Credential | undefined | 'expired'>;
115
+ /** Tells `onProgress` once of what changed, not at every poll. */
116
+ protected show(change: Partial<CloudSignInProgress>): void;
117
+ /** Opens the browser where the user signs in again, the sign-in there started anew; at a tap of the user. */
118
+ reopen(): void;
97
119
  /** Polls now rather than at the end of the wait: back from the browser. */
98
120
  poke(): void;
99
121
  stop(): void;
@@ -6,6 +6,8 @@ export class CloudSignInError extends Error {
6
6
  this.reason = reason;
7
7
  }
8
8
  }
9
+ /** How long the gateway may not answer the polls before the sign-in says it is reconnecting. */
10
+ export const OFFLINE_MS = 6000;
9
11
  /**
10
12
  * Signing this device in to Ta in the cloud of a deployment, with an account (docs/design/ta-deploy.md 8.1): no code to
11
13
  * scan, no token to paste. The gateway of the address gives a code (TA_DEVICE_SIGN_IN_PATH), the user signs in in a
@@ -162,7 +164,7 @@ export var CloudSignInUtil;
162
164
  return (await response.json());
163
165
  }
164
166
  CloudSignInUtil.start = start;
165
- /** One poll: a network that drops for a moment is `pending`, as nothing changed. */
167
+ /** One poll; undefined when the gateway did not answer (the network, a restart): nothing changed, asked again. */
166
168
  async function poll(gateway, device, fetcher = fetch) {
167
169
  try {
168
170
  const response = await fetcher(`${gateway}${TA_DEVICE_SIGN_IN_PATH}/poll`, {
@@ -170,36 +172,60 @@ export var CloudSignInUtil;
170
172
  body: JSON.stringify({ device }),
171
173
  signal: AbortSignal.timeout(CloudSignInUtil.GATEWAY_MS),
172
174
  });
173
- return response.ok ? (await response.json()) : { status: 'pending' };
175
+ return response.ok ? (await response.json()) : undefined;
174
176
  }
175
177
  catch (_a) {
176
- return { status: 'pending' };
178
+ return undefined;
177
179
  }
178
180
  }
179
181
  CloudSignInUtil.poll = poll;
180
182
  })(CloudSignInUtil || (CloudSignInUtil = {}));
181
183
  /**
182
184
  * One sign-in to Ta in the cloud, from asking for the code until the token: it polls until then, or until stopped. What
183
- * it shows goes to `onProgress`; the browser is opened by `open`.
185
+ * it shows goes to `onProgress`; the browser is opened by `open`. It does not end on what the user can get past from
186
+ * here: a sign-in that failed at the provider, the gateway away for a while, a code that ran out (`renews`) each show,
187
+ * and the browser opened again (`reopen`) takes it on (docs/design/ta-deploy.md 8.5).
184
188
  */
185
189
  export class CloudSignIn {
186
190
  constructor(options) {
187
191
  this.options = options;
188
192
  this.stopped = false;
193
+ /** Opened again after it failed: what the gateway said before is old until it says something else. */
194
+ this.reopened = false;
189
195
  }
190
196
  /** The credential of the gateway once signed in; undefined when stopped. */
191
197
  async run() {
192
- const { gateway, fetcher } = this.options;
193
- const started = await CloudSignInUtil.start(gateway, this.options.name, fetcher);
194
- if (this.stopped) {
195
- return undefined;
198
+ var _a;
199
+ const { gateway, fetcher, provider } = this.options;
200
+ for (let renewed = 0;; renewed++) {
201
+ if (renewed > ((_a = this.options.renews) !== null && _a !== void 0 ? _a : 0)) {
202
+ throw new CloudSignInError('expired');
203
+ }
204
+ const started = await CloudSignInUtil.start(gateway, this.options.name, fetcher);
205
+ if (this.stopped) {
206
+ return undefined;
207
+ }
208
+ this.progress = {
209
+ ...(provider
210
+ ? { code: started.code, url: CloudSignInUtil.direct(gateway, provider, started.code), direct: true }
211
+ : { code: started.code, url: started.url }),
212
+ ...(renewed > 0 ? { renewed: true } : {}),
213
+ };
214
+ this.reopened = false;
215
+ this.options.onProgress({ ...this.progress });
216
+ // A new code is not opened unasked: the user may be in the browser still, or away.
217
+ if (renewed === 0) {
218
+ this.options.open(this.progress.url);
219
+ }
220
+ const result = await this.wait(started);
221
+ if (result !== 'expired') {
222
+ return result;
223
+ }
196
224
  }
197
- const { provider } = this.options;
198
- const progress = provider
199
- ? { code: started.code, url: CloudSignInUtil.direct(gateway, provider, started.code), direct: true }
200
- : { code: started.code, url: started.url };
201
- this.options.onProgress({ ...progress });
202
- this.options.open(progress.url);
225
+ }
226
+ async wait(started) {
227
+ const { gateway, fetcher } = this.options;
228
+ let silentSince;
203
229
  while (!this.stopped) {
204
230
  await new Promise(resolve => {
205
231
  this.wake = resolve;
@@ -212,19 +238,63 @@ export class CloudSignIn {
212
238
  if (this.stopped) {
213
239
  return undefined;
214
240
  }
241
+ if (!state) {
242
+ silentSince !== null && silentSince !== void 0 ? silentSince : (silentSince = Date.now());
243
+ if (Date.now() - silentSince >= OFFLINE_MS) {
244
+ this.show({ offline: true });
245
+ }
246
+ continue;
247
+ }
248
+ silentSince = undefined;
249
+ this.show({ offline: undefined });
215
250
  if (state.status === 'done') {
216
251
  return { token: state.token, url: gateway };
217
252
  }
218
253
  if (state.status === 'expired') {
219
- throw new CloudSignInError('expired');
254
+ return 'expired';
220
255
  }
221
- if (state.status === 'waiting' && progress.waiting !== state.account) {
222
- progress.waiting = state.account;
223
- this.options.onProgress({ ...progress });
256
+ if (state.status === 'failed') {
257
+ if (!this.reopened) {
258
+ this.show({ failed: state.reason });
259
+ }
260
+ continue;
224
261
  }
262
+ this.reopened = false;
263
+ this.show({ failed: undefined, ...(state.status === 'waiting' ? { waiting: state.account } : {}) });
225
264
  }
226
265
  return undefined;
227
266
  }
267
+ /** Tells `onProgress` once of what changed, not at every poll. */
268
+ show(change) {
269
+ const progress = this.progress;
270
+ if (!progress) {
271
+ return;
272
+ }
273
+ let changed = false;
274
+ for (const [key, value] of Object.entries(change)) {
275
+ if (progress[key] !== value) {
276
+ changed = true;
277
+ if (value === undefined) {
278
+ delete progress[key];
279
+ }
280
+ else {
281
+ progress[key] = value;
282
+ }
283
+ }
284
+ }
285
+ if (changed) {
286
+ this.options.onProgress({ ...progress });
287
+ }
288
+ }
289
+ /** Opens the browser where the user signs in again, the sign-in there started anew; at a tap of the user. */
290
+ reopen() {
291
+ if (!this.progress) {
292
+ return;
293
+ }
294
+ this.reopened = Boolean(this.progress.failed);
295
+ this.show({ failed: undefined, renewed: undefined });
296
+ this.options.open(this.progress.url);
297
+ }
228
298
  /** Polls now rather than at the end of the wait: back from the browser. */
229
299
  poke() {
230
300
  var _a;
@@ -35,6 +35,8 @@ export interface RailProps {
35
35
  onDismissAsks?(): void;
36
36
  /** A chat said something unseen: the amber dot on the double's entry, as on a phone's first tab; dragged away, all seen. */
37
37
  onSeeAll?(): void;
38
+ /** How many messages people sent the user has not seen: a red number on the double's entry, before all else; dragged away, all seen (onSeeAll). */
39
+ count?: number;
38
40
  /** A double click where nothing is: the sidebar and the workbench both go, or both come back. */
39
41
  onToggleSides?(): void;
40
42
  }
@@ -43,7 +45,7 @@ export interface RailProps {
43
45
  * once some are under it; the account with the settings at the bottom. A page's menu (a right click) puts it under
44
46
  * Discover; that of the double talks to it, and that of the chats opens a new one (entryMenu).
45
47
  */
46
- export declare function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, asks, onDismissAsks, onSeeAll, onToggleSides, }: RailProps): React.JSX.Element;
48
+ export declare function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, asks, onDismissAsks, onSeeAll, count, onToggleSides, }: RailProps): React.JSX.Element;
47
49
  /** A sidebar view of a web extension, under its title or its own top bar. */
48
50
  export declare function SidebarView({ view }: {
49
51
  view: WebViewEntry;
@@ -8,7 +8,7 @@ import { useSettings, useWebExtensions, useWorkbench } from '../hooks.js';
8
8
  import { useT } from '../i18n/use-t.js';
9
9
  import { NavigationUtil } from '../settings/navigation.js';
10
10
  import { AccountMenu } from './account-menu.js';
11
- import { AsksBadge } from './asks-badge.js';
11
+ import { AsksBadge, PeopleBadge } from './asks-badge.js';
12
12
  import { ConnectionBanner } from './connection-bar.js';
13
13
  import { useContextMenu } from './context-menu.js';
14
14
  import { Dino } from './dino.js';
@@ -51,7 +51,7 @@ function RailItem({ label, place, active, onClick, onContextMenu, onPointerDown,
51
51
  * once some are under it; the account with the settings at the bottom. A page's menu (a right click) puts it under
52
52
  * Discover; that of the double talks to it, and that of the chats opens a new one (entryMenu).
53
53
  */
54
- export function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, asks, onDismissAsks, onSeeAll, onToggleSides, }) {
54
+ export function Rail({ lists, list, onList, navigation, current, onPage, onDiscover, onSettings, settingsShown, surfaces, surface, onSurface, holds, asks, onDismissAsks, onSeeAll, count, onToggleSides, }) {
55
55
  const t = useT();
56
56
  const [{ server }] = useWorkbench();
57
57
  const [menu, openMenu] = useContextMenu();
@@ -77,7 +77,7 @@ export function Rail({ lists, list, onList, navigation, current, onPage, onDisco
77
77
  lists.map(entry => (React.createElement(RailItem, { key: entry.id, label: entry.label, place: `list:${entry.id}`, active: list === entry.id, onClick: () => onList(entry.id), ...held(entryHold(entry.id, entry.double, holds)) },
78
78
  entry.double ? React.createElement(DinoFace, { size: 24, className: "ta-nav-face" }) : React.createElement(entry.icon, { size: 20, strokeWidth: 1.6 }),
79
79
  entry.double &&
80
- (asks ? (React.createElement(AsksBadge, { count: asks, onDismiss: onDismissAsks })) : (onSeeAll && React.createElement(UnseenDrop, { label: t('ta.chat.unseen'), onDismiss: onSeeAll, className: "ta-tabbar-dot ta-rail-dot" })))))),
80
+ (count ? (React.createElement(PeopleBadge, { count: count, onDismiss: onSeeAll })) : asks ? (React.createElement(AsksBadge, { count: asks, onDismiss: onDismissAsks })) : (onSeeAll && React.createElement(UnseenDrop, { label: t('ta.chat.unseen'), onDismiss: onSeeAll, className: "ta-tabbar-dot ta-rail-dot" })))))),
81
81
  (navigation.nav.length > 0 || discover) && React.createElement("hr", { className: "ta-rail-divider" }),
82
82
  navigation.nav.map(view => item(view)),
83
83
  discover && (React.createElement(RailItem, { label: t('ta.discover'), place: "discover", active: !settingsShown && current === DISCOVER, onClick: onDiscover, onContextMenu: event => openMenu(event, [settingsItem]) },
@@ -2,6 +2,7 @@ import { ChevronLeft } from 'lucide-react';
2
2
  import * as React from 'react';
3
3
  import { AssistantChatList } from '../assistant/assistant-chat-list.js';
4
4
  import { ChatView } from '../chat/chat-view.js';
5
+ import { AppBadge } from '../device/app-badge.js';
5
6
  import { WebCwdUtil } from '../extension/web-extension-protocol.js';
6
7
  import { usePersisted } from '../hooks.js';
7
8
  import { SIGN_IN_EVENT, SIGNED_IN_EVENT } from '../notices/notices.js';
@@ -10,6 +11,7 @@ import { PageView, Rail, SidebarView } from './app-nav.js';
10
11
  import { LOGIN_LATER, RAIL } from './app-shell-hooks.js';
11
12
  import { useAppShell } from './app-shell-state.js';
12
13
  import { AppUpdateNotices } from './app-update-view.js';
14
+ import { CountUtil } from './asks-badge.js';
13
15
  import { AuthUtil, LoginPage, useAuthProviders } from './auth-view.js';
14
16
  import { BoardSurface } from './board.js';
15
17
  import { ChatAskUtil } from './chat-asks.js';
@@ -89,7 +91,7 @@ export function AppShell() {
89
91
  // The chats' tab, and the double's on the rail, have the amber dot while a row of the double's list has one, as a
90
92
  // messenger's; what waits for the user to decide is counted there until answered.
91
93
  useFirstSteps(workbench.status === 'online', workbench.sessions, workbench.saved);
92
- const { listed: listedChats, unseen: chatsUnseen } = useChatsDot({
94
+ const { listed: listedChats, unseen: chatsUnseen, count: chatsCount, seePeople, } = useChatsDot({
93
95
  sessions: workbench.sessions,
94
96
  saved: workbench.saved,
95
97
  removed: removedChats,
@@ -101,6 +103,11 @@ export function AppShell() {
101
103
  extensions,
102
104
  host,
103
105
  });
106
+ // As a messenger's: the messages of people unseen on the title of the tab and on the icon of Ta Desktop.
107
+ React.useEffect(() => {
108
+ document.title = chatsCount ? `(${CountUtil.text(chatsCount)}) Ta` : 'Ta';
109
+ AppBadge.set(chatsCount);
110
+ }, [chatsCount]);
104
111
  if (workbench.status === 'signed-out') {
105
112
  return workbench.leaving ? React.createElement("div", { className: "ta-signin" }) : React.createElement(SignIn, { error: workbench.error });
106
113
  }
@@ -240,8 +247,11 @@ export function AppShell() {
240
247
  picked();
241
248
  },
242
249
  });
243
- // Dragged away, the dot of the chats: all seen.
244
- const seeAllChats = () => state.set(SEEN_CHATS, ChatSeenUtil.seeAll(state.get(SEEN_CHATS), listedChats, Date.now()));
250
+ // Dragged away, the dot or the red number of the chats: all seen, what people said too, as WeChat's.
251
+ const seeAllChats = () => {
252
+ state.set(SEEN_CHATS, ChatSeenUtil.seeAll(state.get(SEEN_CHATS), listedChats, Date.now()));
253
+ seePeople();
254
+ };
245
255
  // Dragged away, the count of the double: what the conversations ask let go; the double's own tasks wait on.
246
256
  const letGoAllAsks = () => setLetGoAsks(before => ChatAskUtil.letGoAll(before, listedChats));
247
257
  const tabs = phone
@@ -251,8 +261,8 @@ export function AppShell() {
251
261
  fold: t('ta.nav.fold'),
252
262
  settings: { label: t('ta.nav.settings'), run: () => openSettings('navigation') },
253
263
  holds,
254
- }).map(item => item.id === '' && chatsUnseen
255
- ? { ...item, unseen: true, onSeeAll: seeAllChats }
264
+ }).map(item => item.id === '' && (chatsUnseen || chatsCount)
265
+ ? { ...item, unseen: true, count: chatsCount, onSeeAll: seeAllChats }
256
266
  : item.double && deciding
257
267
  ? { ...item, asks: deciding, onSeeAll: letGoAllAsks }
258
268
  : item)
@@ -287,7 +297,7 @@ export function AppShell() {
287
297
  setSettings(undefined);
288
298
  setNavOpen(false);
289
299
  setTabPage('discover');
290
- }, onSettings: openSettings, settingsShown: settings !== undefined, surfaces: surfaces, surface: surface, onSurface: setSurface, holds: holds, asks: deciding, onDismissAsks: letGoAllAsks, onSeeAll: chatsUnseen ? seeAllChats : undefined, onToggleSides: toggleSides }),
300
+ }, onSettings: openSettings, settingsShown: settings !== undefined, surfaces: surfaces, surface: surface, onSurface: setSurface, holds: holds, asks: deciding, onDismissAsks: letGoAllAsks, onSeeAll: chatsUnseen || chatsCount ? seeAllChats : undefined, count: chatsCount, onToggleSides: toggleSides }),
291
301
  sideShown && (React.createElement(SidebarPane, { style: paneStyle(sidebar) },
292
302
  sideList,
293
303
  React.createElement(Sash, { pane: sidebar, side: "start", label: t('ta.layout.sidebar') })))),
@@ -1,4 +1,8 @@
1
1
  import * as React from 'react';
2
+ export declare namespace CountUtil {
3
+ /** A count on a badge, as a messenger shows it: past 99, 99+. */
4
+ function text(count: number): string;
5
+ }
2
6
  /**
3
7
  * How many conversations wait for the user to decide, on the entry of the chats (a tab, the rail): blue, as their ? on
4
8
  * the rows. Dragged away as the amber dot (UnseenDrop), all of them are let go and seen (`onDismiss`).
@@ -7,3 +11,11 @@ export declare function AsksBadge({ count, onDismiss }: {
7
11
  count: number;
8
12
  onDismiss?: () => void;
9
13
  }): React.JSX.Element;
14
+ /**
15
+ * How many messages people sent the user has not seen (PartnersUtil.counted), on the entry of the chats: red, as the
16
+ * numbers of their rows and WeChat's tab. Dragged away as the amber dot (UnseenDrop), all is seen (`onDismiss`).
17
+ */
18
+ export declare function PeopleBadge({ count, onDismiss }: {
19
+ count: number;
20
+ onDismiss?: () => void;
21
+ }): React.JSX.Element;
@@ -1,12 +1,28 @@
1
1
  import * as React from 'react';
2
2
  import { useT } from '../i18n/use-t.js';
3
3
  import { UnseenDrop } from './unseen-drop.js';
4
+ export var CountUtil;
5
+ (function (CountUtil) {
6
+ /** A count on a badge, as a messenger shows it: past 99, 99+. */
7
+ function text(count) {
8
+ return count > 99 ? '99+' : String(count);
9
+ }
10
+ CountUtil.text = text;
11
+ })(CountUtil || (CountUtil = {}));
4
12
  /**
5
13
  * How many conversations wait for the user to decide, on the entry of the chats (a tab, the rail): blue, as their ? on
6
14
  * the rows. Dragged away as the amber dot (UnseenDrop), all of them are let go and seen (`onDismiss`).
7
15
  */
8
16
  export function AsksBadge({ count, onDismiss }) {
9
17
  const t = useT();
10
- return (React.createElement(UnseenDrop, { label: t('ta.chat.asksCount', { count }), onDismiss: onDismiss, className: "ta-asks-badge", tone: "asks" }, count > 99 ? '99+' : count));
18
+ return (React.createElement(UnseenDrop, { label: t('ta.chat.asksCount', { count }), onDismiss: onDismiss, className: "ta-asks-badge", tone: "asks" }, CountUtil.text(count)));
19
+ }
20
+ /**
21
+ * How many messages people sent the user has not seen (PartnersUtil.counted), on the entry of the chats: red, as the
22
+ * numbers of their rows and WeChat's tab. Dragged away as the amber dot (UnseenDrop), all is seen (`onDismiss`).
23
+ */
24
+ export function PeopleBadge({ count, onDismiss }) {
25
+ const t = useT();
26
+ return (React.createElement(UnseenDrop, { label: t('ta.chat.unseenCount', { count }), onDismiss: onDismiss, className: "ta-asks-badge ta-people", tone: "people" }, CountUtil.text(count)));
11
27
  }
12
28
  //# sourceMappingURL=asks-badge.js.map
@@ -69,11 +69,14 @@ export declare function ChatAvatar({ session, source, who, size, mood }: {
69
69
  * Always there, so that it grows in and goes, the avatar never drawn again; told only while it is on. A conversation
70
70
  * that waits for the user to decide has a blue ? instead, over an amber dot: seeing it does not end it, answering does.
71
71
  * The amber dot drags away as a drop (UnseenDrop), as a messenger's unread: let go past its neck, it is seen (`onSee`).
72
+ * Messages of people (a friend, a group chat) have their `count` instead, a red number on the face, as WeChat's: what a
73
+ * person said reaches the user before what an agent answered.
72
74
  */
73
- export declare function ChatDot({ unseen, asks, onSee }: {
75
+ export declare function ChatDot({ unseen, asks, onSee, count }: {
74
76
  unseen: boolean;
75
77
  asks: boolean;
76
78
  onSee?: () => void;
79
+ count?: number;
77
80
  }): React.JSX.Element;
78
81
  /**
79
82
  * The row of a folder (WebChatIcon.folder), as a messenger folds its subscriptions: its icon, its title, and the latest
@@ -5,6 +5,7 @@ import { ExtensionBoundary, SessionAvatars } from '../extension/extension-view.j
5
5
  import { useT } from '../i18n/use-t.js';
6
6
  import { ScreenUtil } from '../screen/screen-protocol.js';
7
7
  import { MessageUtil } from '../util/message.js';
8
+ import { CountUtil } from './asks-badge.js';
8
9
  import { useBusy } from './busy.js';
9
10
  import { ChatAskUtil } from './chat-asks.js';
10
11
  import { ChatIconTile, useChatIcon } from './chat-icon.js';
@@ -65,9 +66,14 @@ function ChatState({ streaming, waiting, waitingFor, task }) {
65
66
  * Always there, so that it grows in and goes, the avatar never drawn again; told only while it is on. A conversation
66
67
  * that waits for the user to decide has a blue ? instead, over an amber dot: seeing it does not end it, answering does.
67
68
  * The amber dot drags away as a drop (UnseenDrop), as a messenger's unread: let go past its neck, it is seen (`onSee`).
69
+ * Messages of people (a friend, a group chat) have their `count` instead, a red number on the face, as WeChat's: what a
70
+ * person said reaches the user before what an agent answered.
68
71
  */
69
- export function ChatDot({ unseen, asks, onSee }) {
72
+ export function ChatDot({ unseen, asks, onSee, count = 0 }) {
70
73
  const t = useT();
74
+ if (unseen && count > 0 && !asks) {
75
+ return (React.createElement(UnseenDrop, { className: "ta-chat-dot ta-on ta-count", label: t('ta.chat.unseenCount', { count }), onDismiss: onSee, tone: "people" }, CountUtil.text(count)));
76
+ }
71
77
  if (asks) {
72
78
  return (React.createElement("span", { className: "ta-chat-dot ta-on ta-asks", role: "img", "aria-label": t('ta.chat.asking') }, "?"));
73
79
  }
@@ -22,9 +22,12 @@ export interface ChatsDotInput {
22
22
  * as a messenger's: a conversation it lists (those folded into a folder and the agents' too, but those quiet: a call),
23
23
  * and, where the list is the double's, a row of its home, a conversation with a partner that is none of pi (a group
24
24
  * chat, a chat of two) and a task that is no conversation. `listed`: the conversations it lists, which dragging the dot
25
- * away sees; a row of the home or a partner's keeps its dot till it is opened, as on its row.
25
+ * away sees; a row of the home keeps its dot till it is opened, as on its row. `count`: the messages of people not seen
26
+ * (PartnersUtil.counted), the red number of the tab; `seePeople` sees them, as it is dragged away with the rest.
26
27
  */
27
28
  export declare function useChatsDot(input: ChatsDotInput): {
28
29
  listed: ChatEntry[];
29
30
  unseen: boolean;
31
+ count: number;
32
+ seePeople(): void;
30
33
  };
@@ -11,7 +11,8 @@ import { SideListUtil } from './side-lists.js';
11
11
  * as a messenger's: a conversation it lists (those folded into a folder and the agents' too, but those quiet: a call),
12
12
  * and, where the list is the double's, a row of its home, a conversation with a partner that is none of pi (a group
13
13
  * chat, a chat of two) and a task that is no conversation. `listed`: the conversations it lists, which dragging the dot
14
- * away sees; a row of the home or a partner's keeps its dot till it is opened, as on its row.
14
+ * away sees; a row of the home keeps its dot till it is opened, as on its row. `count`: the messages of people not seen
15
+ * (PartnersUtil.counted), the red number of the tab; `seePeople` sees them, as it is dragged away with the rest.
15
16
  */
16
17
  export function useChatsDot(input) {
17
18
  const { sessions, saved, removed, pinned, letGo, archiveDays, seen, looking, extensions, host } = input;
@@ -27,6 +28,9 @@ export function useChatsDot(input) {
27
28
  }, [sessions, saved, removed, archiveDays, pinned, letGo, icons, partnerSessions]);
28
29
  const inFront = looking ? sessions.find(session => session.sessionId === looking) : undefined;
29
30
  const said = ChatSeenUtil.anyUnseen(ChatIconUtil.loud(icons, listed), seen, inFront && ChatListUtil.file(inFront), partnerSessions);
30
- return { listed, unseen: said || (doubleList && ChatHomeUtil.anyUnseen(items, partners, tasks, seen)) };
31
+ // What people said, counted as WeChat counts it: a red number in place of the dot (PeopleBadge).
32
+ const count = doubleList ? PartnersUtil.counted(partners) : 0;
33
+ const seePeople = () => doubleList && PartnersUtil.seeAll(partners);
34
+ return { listed, unseen: said || (doubleList && ChatHomeUtil.anyUnseen(items, partners, tasks, seen)), count, seePeople };
31
35
  }
32
36
  //# sourceMappingURL=chats-dot.js.map