@celljs/ta-web 4.46.2 → 4.47.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 (285) hide show
  1. package/esm/browser/account/account-side.d.ts +3 -3
  2. package/esm/browser/account/account-side.js +11 -21
  3. package/esm/browser/account/device-account.d.ts +8 -0
  4. package/esm/browser/account/device-account.js +20 -0
  5. package/esm/browser/chat/chat-protocol.d.ts +7 -0
  6. package/esm/browser/chat/chat-view.js +1 -1
  7. package/esm/browser/chat/chat.d.ts +1 -0
  8. package/esm/browser/chat/chat.js +15 -3
  9. package/esm/browser/chat/draft-model.d.ts +1 -1
  10. package/esm/browser/chat/draft-model.js +2 -2
  11. package/esm/browser/components/access-view.js +12 -10
  12. package/esm/browser/components/account-menu.d.ts +2 -0
  13. package/esm/browser/components/account-menu.js +11 -2
  14. package/esm/browser/components/account-view.js +9 -5
  15. package/esm/browser/components/app-nav.js +4 -1
  16. package/esm/browser/components/app-shell-state.d.ts +2 -0
  17. package/esm/browser/components/app-update-view.d.ts +2 -0
  18. package/esm/browser/components/app-update-view.js +37 -0
  19. package/esm/browser/components/app-view.js +33 -108
  20. package/esm/browser/components/auth-guide.d.ts +25 -0
  21. package/esm/browser/components/auth-guide.js +44 -0
  22. package/esm/browser/components/auth-view.d.ts +2 -0
  23. package/esm/browser/components/auth-view.js +30 -9
  24. package/esm/browser/components/chat-list-controls.d.ts +38 -0
  25. package/esm/browser/components/chat-list-controls.js +46 -0
  26. package/esm/browser/components/chat-list-hooks.d.ts +19 -0
  27. package/esm/browser/components/chat-list-hooks.js +52 -0
  28. package/esm/browser/components/chat-list-rows.d.ts +51 -0
  29. package/esm/browser/components/chat-list-rows.js +110 -0
  30. package/esm/browser/components/chat-list-sections.d.ts +36 -0
  31. package/esm/browser/components/chat-list-sections.js +72 -0
  32. package/esm/browser/components/chat-list.js +48 -221
  33. package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
  34. package/esm/browser/components/cloud-sign-in-view.js +4 -1
  35. package/esm/browser/components/custom-provider-util.d.ts +2 -0
  36. package/esm/browser/components/custom-provider-util.js +5 -0
  37. package/esm/browser/components/custom-provider-view.js +33 -12
  38. package/esm/browser/components/device-sign-in-page.js +4 -5
  39. package/esm/browser/components/discover-view.d.ts +8 -1
  40. package/esm/browser/components/discover-view.js +28 -3
  41. package/esm/browser/components/environment-view.js +60 -62
  42. package/esm/browser/components/extension-settings.js +1 -0
  43. package/esm/browser/components/first-steps-util.d.ts +29 -0
  44. package/esm/browser/components/first-steps-util.js +41 -0
  45. package/esm/browser/components/first-steps.d.ts +3 -0
  46. package/esm/browser/components/first-steps.js +36 -0
  47. package/esm/browser/components/host-view.d.ts +3 -3
  48. package/esm/browser/components/host-view.js +11 -11
  49. package/esm/browser/components/me-rows.d.ts +8 -1
  50. package/esm/browser/components/me-rows.js +3 -3
  51. package/esm/browser/components/me-view.js +1 -1
  52. package/esm/browser/components/message-user.js +6 -3
  53. package/esm/browser/components/model-picker.d.ts +5 -0
  54. package/esm/browser/components/model-picker.js +10 -1
  55. package/esm/browser/components/nav-places.d.ts +14 -0
  56. package/esm/browser/components/nav-places.js +11 -0
  57. package/esm/browser/components/phone-shell.d.ts +14 -0
  58. package/esm/browser/components/phone-shell.js +22 -0
  59. package/esm/browser/components/picture-dialog.js +4 -7
  60. package/esm/browser/components/profile-view.js +1 -1
  61. package/esm/browser/components/relay-services.js +4 -7
  62. package/esm/browser/components/relay-view-util.d.ts +5 -0
  63. package/esm/browser/components/relay-view-util.js +14 -0
  64. package/esm/browser/components/relay-view.js +40 -37
  65. package/esm/browser/components/scan-screen.js +5 -8
  66. package/esm/browser/components/screen-navigator.d.ts +9 -0
  67. package/esm/browser/components/screen-navigator.js +84 -0
  68. package/esm/browser/components/search-page.js +9 -2
  69. package/esm/browser/components/serve-value.d.ts +27 -0
  70. package/esm/browser/components/serve-value.js +61 -0
  71. package/esm/browser/components/serve-watch.d.ts +23 -0
  72. package/esm/browser/components/serve-watch.js +36 -0
  73. package/esm/browser/components/settings-choices.js +2 -0
  74. package/esm/browser/components/settings-controls.d.ts +15 -0
  75. package/esm/browser/components/settings-controls.js +13 -0
  76. package/esm/browser/components/settings-more.js +6 -4
  77. package/esm/browser/components/settings-parts.d.ts +3 -1
  78. package/esm/browser/components/settings-parts.js +3 -0
  79. package/esm/browser/components/settings-view.js +37 -11
  80. package/esm/browser/components/share-friends.js +3 -4
  81. package/esm/browser/components/share-sheet.js +3 -4
  82. package/esm/browser/components/tool-view.js +17 -3
  83. package/esm/browser/device/app-update.d.ts +62 -0
  84. package/esm/browser/device/app-update.js +144 -0
  85. package/esm/browser/extension/icons.js +2 -1
  86. package/esm/browser/extension/web-api-contributions.d.ts +6 -1
  87. package/esm/browser/extension/web-api-partners.d.ts +6 -0
  88. package/esm/browser/extension/web-api-spec.js +1 -0
  89. package/esm/browser/extension/web-home.js +9 -0
  90. package/esm/browser/extension/web-metrics.d.ts +3 -0
  91. package/esm/browser/extension/web-metrics.js +33 -22
  92. package/esm/browser/extension/web-pages.d.ts +3 -1
  93. package/esm/browser/extension/web-pages.js +1 -0
  94. package/esm/browser/gateway/console-agents.js +11 -15
  95. package/esm/browser/gateway/console-parts.d.ts +7 -4
  96. package/esm/browser/gateway/console-parts.js +11 -20
  97. package/esm/browser/gateway/console-trend.js +2 -2
  98. package/esm/browser/gateway/console-updates.js +6 -4
  99. package/esm/browser/gateway/console-view.js +6 -6
  100. package/esm/browser/i18n/en/account.d.ts +7 -0
  101. package/esm/browser/i18n/en/account.js +13 -6
  102. package/esm/browser/i18n/en/chat.d.ts +2 -0
  103. package/esm/browser/i18n/en/chat.js +2 -0
  104. package/esm/browser/i18n/en/discover.d.ts +3 -0
  105. package/esm/browser/i18n/en/discover.js +3 -0
  106. package/esm/browser/i18n/en/service.d.ts +6 -0
  107. package/esm/browser/i18n/en/service.js +6 -0
  108. package/esm/browser/i18n/en/settings.d.ts +3 -0
  109. package/esm/browser/i18n/en/settings.js +3 -0
  110. package/esm/browser/i18n/ja/account.js +13 -6
  111. package/esm/browser/i18n/ja/chat.js +2 -0
  112. package/esm/browser/i18n/ja/discover.js +3 -0
  113. package/esm/browser/i18n/ja/service.js +6 -0
  114. package/esm/browser/i18n/ja/settings.js +3 -0
  115. package/esm/browser/i18n/locales.d.ts +22 -1
  116. package/esm/browser/i18n/messages.d.ts +21 -0
  117. package/esm/browser/i18n/zh/account.js +13 -6
  118. package/esm/browser/i18n/zh/chat.js +2 -0
  119. package/esm/browser/i18n/zh/discover.js +3 -0
  120. package/esm/browser/i18n/zh/service.js +6 -0
  121. package/esm/browser/i18n/zh/settings.js +3 -0
  122. package/esm/browser/i18n/zh-tw/account.js +13 -6
  123. package/esm/browser/i18n/zh-tw/chat.js +2 -0
  124. package/esm/browser/i18n/zh-tw/discover.js +3 -0
  125. package/esm/browser/i18n/zh-tw/service.js +6 -0
  126. package/esm/browser/i18n/zh-tw/settings.js +3 -0
  127. package/esm/browser/notices/notices.d.ts +2 -0
  128. package/esm/browser/notices/notices.js +2 -0
  129. package/esm/browser/partners/group-picker.js +3 -4
  130. package/esm/browser/sandbox/sandbox-runtime-code.js +1 -1
  131. package/esm/browser/settings/settings-protocol.d.ts +5 -0
  132. package/esm/browser/settings/settings-protocol.js +2 -0
  133. package/esm/browser/style/chat-list.d.ts +1 -1
  134. package/esm/browser/style/chat-list.js +4 -3
  135. package/esm/browser/style/dialogs.d.ts +1 -1
  136. package/esm/browser/style/dialogs.js +7 -0
  137. package/esm/browser/style/pages.d.ts +1 -1
  138. package/esm/browser/style/pages.js +5 -3
  139. package/esm/browser/style/shell.d.ts +1 -1
  140. package/esm/browser/style/shell.js +1 -1
  141. package/esm/browser/util/tool.d.ts +5 -0
  142. package/esm/browser/util/tool.js +21 -3
  143. package/lib/browser/account/account-side.d.ts +3 -3
  144. package/lib/browser/account/account-side.js +11 -21
  145. package/lib/browser/account/device-account.d.ts +8 -0
  146. package/lib/browser/account/device-account.js +20 -0
  147. package/lib/browser/chat/chat-protocol.d.ts +7 -0
  148. package/lib/browser/chat/chat-view.js +1 -1
  149. package/lib/browser/chat/chat.d.ts +1 -0
  150. package/lib/browser/chat/chat.js +14 -2
  151. package/lib/browser/chat/draft-model.d.ts +1 -1
  152. package/lib/browser/chat/draft-model.js +2 -2
  153. package/lib/browser/components/access-view.js +12 -10
  154. package/lib/browser/components/account-menu.d.ts +2 -0
  155. package/lib/browser/components/account-menu.js +11 -2
  156. package/lib/browser/components/account-view.js +9 -5
  157. package/lib/browser/components/app-nav.js +3 -0
  158. package/lib/browser/components/app-shell-state.d.ts +2 -0
  159. package/lib/browser/components/app-update-view.d.ts +3 -0
  160. package/lib/browser/components/app-update-view.js +73 -0
  161. package/lib/browser/components/app-view.js +30 -105
  162. package/lib/browser/components/auth-guide.d.ts +26 -0
  163. package/lib/browser/components/auth-guide.js +47 -0
  164. package/lib/browser/components/auth-view.d.ts +2 -0
  165. package/lib/browser/components/auth-view.js +29 -8
  166. package/lib/browser/components/chat-list-controls.d.ts +39 -0
  167. package/lib/browser/components/chat-list-controls.js +86 -0
  168. package/lib/browser/components/chat-list-hooks.d.ts +19 -0
  169. package/lib/browser/components/chat-list-hooks.js +53 -0
  170. package/lib/browser/components/chat-list-rows.d.ts +52 -0
  171. package/lib/browser/components/chat-list-rows.js +147 -0
  172. package/lib/browser/components/chat-list-sections.d.ts +37 -0
  173. package/lib/browser/components/chat-list-sections.js +108 -0
  174. package/lib/browser/components/chat-list.js +44 -217
  175. package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
  176. package/lib/browser/components/cloud-sign-in-view.js +4 -1
  177. package/lib/browser/components/custom-provider-util.d.ts +2 -0
  178. package/lib/browser/components/custom-provider-util.js +5 -0
  179. package/lib/browser/components/custom-provider-view.js +32 -11
  180. package/lib/browser/components/device-sign-in-page.js +4 -5
  181. package/lib/browser/components/discover-view.d.ts +8 -1
  182. package/lib/browser/components/discover-view.js +27 -2
  183. package/lib/browser/components/environment-view.js +60 -62
  184. package/lib/browser/components/extension-settings.js +1 -0
  185. package/lib/browser/components/first-steps-util.d.ts +30 -0
  186. package/lib/browser/components/first-steps-util.js +44 -0
  187. package/lib/browser/components/first-steps.d.ts +4 -0
  188. package/lib/browser/components/first-steps.js +72 -0
  189. package/lib/browser/components/host-view.d.ts +3 -3
  190. package/lib/browser/components/host-view.js +11 -11
  191. package/lib/browser/components/me-rows.d.ts +8 -1
  192. package/lib/browser/components/me-rows.js +3 -3
  193. package/lib/browser/components/me-view.js +1 -1
  194. package/lib/browser/components/message-user.js +5 -2
  195. package/lib/browser/components/model-picker.d.ts +5 -0
  196. package/lib/browser/components/model-picker.js +10 -1
  197. package/lib/browser/components/nav-places.d.ts +14 -0
  198. package/lib/browser/components/nav-places.js +13 -1
  199. package/lib/browser/components/phone-shell.d.ts +14 -0
  200. package/lib/browser/components/phone-shell.js +23 -0
  201. package/lib/browser/components/picture-dialog.js +4 -7
  202. package/lib/browser/components/profile-view.js +1 -1
  203. package/lib/browser/components/relay-services.js +4 -7
  204. package/lib/browser/components/relay-view-util.d.ts +6 -0
  205. package/lib/browser/components/relay-view-util.js +17 -0
  206. package/lib/browser/components/relay-view.js +38 -35
  207. package/lib/browser/components/scan-screen.js +5 -8
  208. package/lib/browser/components/screen-navigator.d.ts +9 -0
  209. package/lib/browser/components/screen-navigator.js +85 -0
  210. package/lib/browser/components/search-page.js +8 -1
  211. package/lib/browser/components/serve-value.d.ts +28 -0
  212. package/lib/browser/components/serve-value.js +97 -0
  213. package/lib/browser/components/serve-watch.d.ts +24 -0
  214. package/lib/browser/components/serve-watch.js +39 -0
  215. package/lib/browser/components/settings-choices.js +2 -0
  216. package/lib/browser/components/settings-controls.d.ts +15 -0
  217. package/lib/browser/components/settings-controls.js +13 -0
  218. package/lib/browser/components/settings-more.js +6 -4
  219. package/lib/browser/components/settings-parts.d.ts +3 -1
  220. package/lib/browser/components/settings-parts.js +3 -0
  221. package/lib/browser/components/settings-view.js +36 -10
  222. package/lib/browser/components/share-friends.js +3 -4
  223. package/lib/browser/components/share-sheet.js +3 -4
  224. package/lib/browser/components/tool-view.js +17 -3
  225. package/lib/browser/device/app-update.d.ts +63 -0
  226. package/lib/browser/device/app-update.js +182 -0
  227. package/lib/browser/extension/icons.js +1 -0
  228. package/lib/browser/extension/web-api-contributions.d.ts +6 -1
  229. package/lib/browser/extension/web-api-partners.d.ts +6 -0
  230. package/lib/browser/extension/web-api-spec.js +1 -0
  231. package/lib/browser/extension/web-home.js +9 -0
  232. package/lib/browser/extension/web-metrics.d.ts +3 -0
  233. package/lib/browser/extension/web-metrics.js +32 -21
  234. package/lib/browser/extension/web-pages.d.ts +3 -1
  235. package/lib/browser/extension/web-pages.js +1 -0
  236. package/lib/browser/gateway/console-agents.js +10 -14
  237. package/lib/browser/gateway/console-parts.d.ts +7 -4
  238. package/lib/browser/gateway/console-parts.js +12 -21
  239. package/lib/browser/gateway/console-trend.js +1 -1
  240. package/lib/browser/gateway/console-updates.js +5 -3
  241. package/lib/browser/gateway/console-view.js +5 -5
  242. package/lib/browser/i18n/en/account.d.ts +7 -0
  243. package/lib/browser/i18n/en/account.js +13 -6
  244. package/lib/browser/i18n/en/chat.d.ts +2 -0
  245. package/lib/browser/i18n/en/chat.js +2 -0
  246. package/lib/browser/i18n/en/discover.d.ts +3 -0
  247. package/lib/browser/i18n/en/discover.js +3 -0
  248. package/lib/browser/i18n/en/service.d.ts +6 -0
  249. package/lib/browser/i18n/en/service.js +6 -0
  250. package/lib/browser/i18n/en/settings.d.ts +3 -0
  251. package/lib/browser/i18n/en/settings.js +3 -0
  252. package/lib/browser/i18n/ja/account.js +13 -6
  253. package/lib/browser/i18n/ja/chat.js +2 -0
  254. package/lib/browser/i18n/ja/discover.js +3 -0
  255. package/lib/browser/i18n/ja/service.js +6 -0
  256. package/lib/browser/i18n/ja/settings.js +3 -0
  257. package/lib/browser/i18n/locales.d.ts +22 -1
  258. package/lib/browser/i18n/messages.d.ts +21 -0
  259. package/lib/browser/i18n/zh/account.js +13 -6
  260. package/lib/browser/i18n/zh/chat.js +2 -0
  261. package/lib/browser/i18n/zh/discover.js +3 -0
  262. package/lib/browser/i18n/zh/service.js +6 -0
  263. package/lib/browser/i18n/zh/settings.js +3 -0
  264. package/lib/browser/i18n/zh-tw/account.js +13 -6
  265. package/lib/browser/i18n/zh-tw/chat.js +2 -0
  266. package/lib/browser/i18n/zh-tw/discover.js +3 -0
  267. package/lib/browser/i18n/zh-tw/service.js +6 -0
  268. package/lib/browser/i18n/zh-tw/settings.js +3 -0
  269. package/lib/browser/notices/notices.d.ts +2 -0
  270. package/lib/browser/notices/notices.js +3 -1
  271. package/lib/browser/partners/group-picker.js +3 -4
  272. package/lib/browser/sandbox/sandbox-runtime-code.js +1 -1
  273. package/lib/browser/settings/settings-protocol.d.ts +5 -0
  274. package/lib/browser/settings/settings-protocol.js +2 -0
  275. package/lib/browser/style/chat-list.d.ts +1 -1
  276. package/lib/browser/style/chat-list.js +4 -3
  277. package/lib/browser/style/dialogs.d.ts +1 -1
  278. package/lib/browser/style/dialogs.js +7 -0
  279. package/lib/browser/style/pages.d.ts +1 -1
  280. package/lib/browser/style/pages.js +5 -3
  281. package/lib/browser/style/shell.d.ts +1 -1
  282. package/lib/browser/style/shell.js +1 -1
  283. package/lib/browser/util/tool.d.ts +5 -0
  284. package/lib/browser/util/tool.js +21 -3
  285. package/package.json +7 -7
@@ -47,6 +47,7 @@ const web_extension_protocol_1 = require("../extension/web-extension-protocol");
47
47
  const hooks_1 = require("../hooks");
48
48
  const use_t_1 = require("../i18n/use-t");
49
49
  const workbench_util_1 = require("../workbench-util");
50
+ const auth_guide_1 = require("./auth-guide");
50
51
  const auth_pictures_1 = require("./auth-pictures");
51
52
  const callout_1 = require("./callout");
52
53
  const custom_provider_view_1 = require("./custom-provider-view");
@@ -95,7 +96,7 @@ var AuthUtil;
95
96
  case 'done':
96
97
  return { ...state, prompt: undefined, result: 'done' };
97
98
  case 'failed':
98
- return { ...state, prompt: undefined, result: event.cancelled ? 'cancelled' : 'failed', error: event.message };
99
+ return { ...state, prompt: undefined, result: event.cancelled ? 'cancelled' : 'failed', error: event.message, refused: event.refused };
99
100
  }
100
101
  }
101
102
  AuthUtil.reduce = reduce;
@@ -126,7 +127,7 @@ function open(url) {
126
127
  window.open(url, '_blank', 'noopener,noreferrer');
127
128
  }
128
129
  /** One sign-in, run on the server: what it shows, and what it asks. */
129
- function AuthFlow({ provider, onDone, onBack }) {
130
+ function AuthFlow({ provider, onDone, onBack, onRetry }) {
130
131
  var _a, _b, _c;
131
132
  const t = (0, use_t_1.useT)();
132
133
  const [workbench, bench] = (0, hooks_1.useWorkbench)();
@@ -180,6 +181,7 @@ function AuthFlow({ provider, onDone, onBack }) {
180
181
  }
181
182
  };
182
183
  const kind = provider.type === 'api_key' ? t('ta.auth.apiKey') : provider.subscription ? t('ta.auth.subscription') : t('ta.auth.account');
184
+ const guide = provider.type === 'api_key' ? auth_guide_1.AuthGuideUtil.guide(provider.id) : undefined;
183
185
  return (React.createElement("div", { className: "ta-auth-flow" },
184
186
  React.createElement("div", { className: "ta-auth-flow-head" },
185
187
  React.createElement(icon_1.IconButton, { icon: lucide_react_1.ArrowLeft, label: t('ta.auth.back'), onClick: onBack }),
@@ -237,9 +239,15 @@ function AuthFlow({ provider, onDone, onBack }) {
237
239
  React.createElement("label", { className: "ta-field" },
238
240
  React.createElement(lucide_react_1.KeyRound, { size: 16, strokeWidth: 1.75, "aria-hidden": "true" }),
239
241
  React.createElement("input", { type: prompt.prompt.type === 'secret' ? 'password' : 'text', autoFocus: true, autoComplete: "off", spellCheck: false, placeholder: (_a = prompt.prompt.placeholder) !== null && _a !== void 0 ? _a : (prompt.prompt.type === 'secret' ? t('ta.auth.apiKey') : ''), value: answer, onChange: event => setAnswer(event.target.value) })),
242
+ prompt.prompt.type === 'secret' && guide && (React.createElement("p", { className: "ta-auth-guide" },
243
+ t('ta.auth.keyGuide', { name: provider.name }),
244
+ ' ',
245
+ React.createElement("a", { href: guide.keys, target: "_blank", rel: "noreferrer", className: "ta-auth-link" }, t('ta.auth.keyPage')),
246
+ ' · ',
247
+ React.createElement("a", { href: guide.pricing, target: "_blank", rel: "noreferrer", className: "ta-auth-link" }, t('ta.auth.pricing')))),
240
248
  React.createElement("button", { type: "submit", className: "ta-button ta-primary ta-wide", disabled: !answer.trim() }, t('ta.auth.continue'))))),
241
249
  !state.result && !prompt && React.createElement(loading_1.Loading, { compact: true, label: (_b = state.progress) !== null && _b !== void 0 ? _b : t('ta.auth.waiting') }),
242
- state.result === 'failed' && (React.createElement(callout_1.Callout, { level: "error", action: React.createElement("button", { type: "button", className: "ta-button", onClick: onBack }, t('ta.auth.back')) }, t('ta.auth.failed', { message: (_c = state.error) !== null && _c !== void 0 ? _c : '' })))));
250
+ state.result === 'failed' && (React.createElement(callout_1.Callout, { level: "error", action: state.refused ? (React.createElement("button", { type: "button", className: "ta-button", onClick: onRetry }, t('ta.auth.keyAgain'))) : (React.createElement("button", { type: "button", className: "ta-button", onClick: onBack }, t('ta.auth.back'))) }, state.refused ? t('ta.auth.keyRefused', { name: provider.name }) : t('ta.auth.failed', { message: (_c = state.error) !== null && _c !== void 0 ? _c : '' })))));
243
251
  }
244
252
  function ProviderRow({ provider, onPick, onSignOut, plain }) {
245
253
  var _a, _b;
@@ -298,7 +306,12 @@ function AuthPanel({ onSignedIn, onProviders, kinds }) {
298
306
  const [, notices] = (0, hooks_1.useNotices)();
299
307
  const [providers, reload] = useAuthProviders(workbench.status === 'online');
300
308
  const [picked, setPicked] = React.useState();
309
+ /** Sign-ins of `picked` begun: one more begins it again, as after a key the service refused. */
310
+ const [tries, setTries] = React.useState(0);
301
311
  const [words, setWords] = React.useState('');
312
+ const language = (0, use_t_1.useLanguage)();
313
+ /** The providers of keys under "more" are shown. */
314
+ const [more, setMore] = React.useState(false);
302
315
  /** On the first page: which way the user chose, before the providers of that way. */
303
316
  const [kind, setKind] = React.useState();
304
317
  /** A provider the user adds by its address (`new`), or one added so, being changed. */
@@ -324,7 +337,7 @@ function AuthPanel({ onSignedIn, onProviders, kinds }) {
324
337
  } }));
325
338
  }
326
339
  if (picked) {
327
- return React.createElement(AuthFlow, { provider: picked, onDone: done, onBack: back });
340
+ return React.createElement(AuthFlow, { key: tries, provider: picked, onDone: done, onBack: back, onRetry: () => setTries(value => value + 1) });
328
341
  }
329
342
  if (!providers) {
330
343
  return React.createElement(loading_1.Loading, null);
@@ -367,10 +380,16 @@ function AuthPanel({ onSignedIn, onProviders, kinds }) {
367
380
  const offered = AuthUtil.offered(providers, words);
368
381
  const accounts = kind === 'api_key' ? [] : offered.accounts;
369
382
  const keys = kind === 'oauth' ? [] : offered.keys;
370
- const group = (title, list, first) => (list.length > 0 || first) && (React.createElement("section", { className: "ta-auth-group" },
383
+ // Before a search, a few to pick from (those of the language of the page, and the user's own); the others folded.
384
+ const split = words.trim() ? { first: keys, more: [] } : auth_guide_1.AuthGuideUtil.split(keys, language);
385
+ const shownKeys = more ? keys : split.first;
386
+ const group = (title, list, after) => (list.length > 0 || after) && (React.createElement("section", { className: "ta-auth-group" },
371
387
  title && React.createElement("h3", null, title),
372
- first,
373
- list.map(provider => (React.createElement(ProviderRow, { key: AuthUtil.key(provider), provider: provider, plain: kind !== undefined, onPick: () => (provider.custom ? edit(provider) : setPicked(provider)), onSignOut: () => void signOut(provider) })))));
388
+ list.map(provider => (React.createElement(ProviderRow, { key: AuthUtil.key(provider), provider: provider, plain: kind !== undefined, onPick: () => (provider.custom ? edit(provider) : setPicked(provider)), onSignOut: () => void signOut(provider) }))),
389
+ after));
390
+ const unfold = !more && split.more.length > 0 && (React.createElement("button", { type: "button", className: "ta-auth-item ta-auth-more", onClick: () => setMore(true) },
391
+ React.createElement("span", { className: "ta-auth-name" }, t('ta.auth.more', { count: split.more.length })),
392
+ React.createElement(icon_1.Icon, { icon: lucide_react_1.ChevronRight, size: 15 })));
374
393
  // Whatever is searched: a service not in the list is one to add.
375
394
  const add = kind !== 'oauth' && (React.createElement("button", { type: "button", className: "ta-auth-item ta-custom-add", onClick: () => setEditing('new') },
376
395
  React.createElement(icon_1.Icon, { icon: lucide_react_1.Plus, size: 15 }),
@@ -386,7 +405,9 @@ function AuthPanel({ onSignedIn, onProviders, kinds }) {
386
405
  React.createElement("input", { placeholder: t('ta.auth.search'), value: words, onChange: event => setWords(event.target.value) })),
387
406
  React.createElement("div", { className: "ta-auth-list" },
388
407
  group(kind ? '' : t('ta.auth.accounts'), accounts),
389
- group(kind ? '' : t('ta.auth.keys'), keys, add),
408
+ group(kind ? '' : t('ta.auth.keys'), shownKeys, (unfold || add) && (React.createElement(React.Fragment, null,
409
+ unfold,
410
+ add))),
390
411
  accounts.length + keys.length === 0 && !add && React.createElement(empty_state_1.EmptyState, { compact: true, title: t('ta.auth.none') }))));
391
412
  }
392
413
  /** The model accounts, over the page (the gear menu). */
@@ -0,0 +1,39 @@
1
+ import * as React from 'react';
2
+ import type { ChatSource } from './chat-list-util';
3
+ /** The head of the list: its search, the switch of the list by directory (`byDirectory`, when there are several), and `+`. */
4
+ export declare function ChatSearchHead({ query, onQuery, byDirectory, onByDirectory, onNew, }: {
5
+ query: string;
6
+ onQuery(query: string): void;
7
+ /** Undefined: no switch, as for one directory. */
8
+ byDirectory?: boolean;
9
+ onByDirectory(byDirectory: boolean): void;
10
+ onNew(): void;
11
+ }): React.JSX.Element;
12
+ /** The head of a group of the list by directory: folds it; what it adds after (a `+` of its own) as `children`. */
13
+ export declare function ChatGroupHead({ open, title, onFold, leading, label, count, children, }: {
14
+ open: boolean;
15
+ title?: string;
16
+ onFold(): void;
17
+ leading: React.ReactNode;
18
+ label: string;
19
+ count: number;
20
+ children?: React.ReactNode;
21
+ }): React.JSX.Element;
22
+ /** The mark of a directory or package at the head of its group: its initial in its tone, and the host it is on. */
23
+ export declare function ChatSourceMark({ source }: {
24
+ source: ChatSource;
25
+ }): React.JSX.Element;
26
+ /** The head of a list pushed over the list (a folder, those going on): back, its title and how many. */
27
+ export declare function ChatFolderHead({ title, count, onBack }: {
28
+ title: string;
29
+ count: number;
30
+ onBack(): void;
31
+ }): React.JSX.Element;
32
+ /** A toggle of what folds under a title: the older conversations, the archive, those taken out. */
33
+ export declare function ChatFoldToggle({ label, open, onClick, title }: {
34
+ label: string;
35
+ open: boolean;
36
+ onClick(): void;
37
+ title?: string;
38
+ }): React.JSX.Element;
39
+ //# sourceMappingURL=chat-list-controls.d.ts.map
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.ChatSearchHead = ChatSearchHead;
37
+ exports.ChatGroupHead = ChatGroupHead;
38
+ exports.ChatSourceMark = ChatSourceMark;
39
+ exports.ChatFolderHead = ChatFolderHead;
40
+ exports.ChatFoldToggle = ChatFoldToggle;
41
+ const lucide_react_1 = require("lucide-react");
42
+ const React = __importStar(require("react"));
43
+ const use_t_1 = require("../i18n/use-t");
44
+ const host_tag_1 = require("./host-tag");
45
+ const icon_1 = require("./icon");
46
+ /** The head of the list: its search, the switch of the list by directory (`byDirectory`, when there are several), and `+`. */
47
+ function ChatSearchHead({ query, onQuery, byDirectory, onByDirectory, onNew, }) {
48
+ const t = (0, use_t_1.useT)();
49
+ return (React.createElement("header", { className: "ta-chats-head" },
50
+ React.createElement("label", { className: "ta-chats-search" },
51
+ React.createElement(icon_1.Icon, { icon: lucide_react_1.Search, size: 15 }),
52
+ React.createElement("input", { value: query, placeholder: t('ta.chat.search'), "aria-label": t('ta.chat.search'), onChange: event => onQuery(event.target.value) }),
53
+ query ? (React.createElement(icon_1.IconButton, { className: "ta-chats-clear", icon: lucide_react_1.X, label: t('ta.close'), onClick: () => onQuery('') })) : (byDirectory !== undefined && (React.createElement(icon_1.IconButton, { className: "ta-chats-view", icon: lucide_react_1.FolderTree, label: t('ta.chat.byDirectory'), "aria-pressed": byDirectory, onClick: () => onByDirectory(!byDirectory) })))),
54
+ React.createElement(icon_1.IconButton, { className: "ta-chats-add", icon: lucide_react_1.Plus, label: t('ta.chat.new'), onClick: onNew })));
55
+ }
56
+ /** The head of a group of the list by directory: folds it; what it adds after (a `+` of its own) as `children`. */
57
+ function ChatGroupHead({ open, title, onFold, leading, label, count, children, }) {
58
+ return (React.createElement("div", { className: "ta-chat-group-head" },
59
+ React.createElement("button", { type: "button", className: "ta-chat-group-toggle", "aria-expanded": open, title: title, onClick: onFold },
60
+ leading,
61
+ React.createElement("span", { className: "ta-chat-group-label" }, label),
62
+ React.createElement("span", { className: "ta-chat-group-count" }, count),
63
+ React.createElement(icon_1.Icon, { icon: lucide_react_1.ChevronRight, size: 13, className: "ta-chat-group-chevron" })),
64
+ children));
65
+ }
66
+ /** The mark of a directory or package at the head of its group: its initial in its tone, and the host it is on. */
67
+ function ChatSourceMark({ source }) {
68
+ return (React.createElement(React.Fragment, null,
69
+ React.createElement("span", { className: `ta-chat-group-avatar ta-tone-${source.tone}`, "aria-hidden": "true" }, source.initial),
70
+ React.createElement(host_tag_1.HostTag, { host: source.host })));
71
+ }
72
+ /** The head of a list pushed over the list (a folder, those going on): back, its title and how many. */
73
+ function ChatFolderHead({ title, count, onBack }) {
74
+ const t = (0, use_t_1.useT)();
75
+ return (React.createElement("div", { className: "ta-chat-folder-head" },
76
+ React.createElement(icon_1.IconButton, { className: "ta-chat-folder-back", icon: lucide_react_1.ChevronLeft, label: t('ta.back'), onClick: onBack }),
77
+ React.createElement("span", { className: "ta-chat-folder-title" }, title),
78
+ React.createElement("span", { className: "ta-chat-group-count" }, count)));
79
+ }
80
+ /** A toggle of what folds under a title: the older conversations, the archive, those taken out. */
81
+ function ChatFoldToggle({ label, open, onClick, title }) {
82
+ return (React.createElement("button", { type: "button", className: "ta-chat-section-title ta-chat-fold", "aria-expanded": open, title: title, onClick: onClick },
83
+ React.createElement(icon_1.Icon, { icon: lucide_react_1.ChevronRight, size: 13 }),
84
+ label));
85
+ }
86
+ //# sourceMappingURL=chat-list-controls.js.map
@@ -1,5 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import type { WebChat, WebHomeEntry } from '../extension/web-extension-api';
3
+ import type { Translate } from '../i18n/use-t';
4
+ import { type LetGoAsks } from './chat-asks';
3
5
  import type { ChatTaskHome } from './chat-home';
4
6
  import { type ChatHome } from './chat-home-util';
5
7
  import type { ChatFolderIcon } from './chat-icon';
@@ -50,4 +52,21 @@ export declare function useRowCalls(given: {
50
52
  /** Pins or unpins a conversation's file or a folder's key: the last pinned first, as several may be. */
51
53
  pinKey(key: string, pin: boolean): void;
52
54
  };
55
+ /** What an agent reads of the list and does to it (docs/design/ta-app-use.md 3): the screen keeps the rows drawn in sight. */
56
+ export declare function useChatsScreen(given: {
57
+ title: string;
58
+ shown: readonly ChatEntry[];
59
+ /** The rows drawn in sight: those of the folder opened, else of the list. */
60
+ inSight(): ChatEntry[];
61
+ letGo: LetGoAsks;
62
+ isUnseen(entry: ChatEntry): boolean;
63
+ pinned: ReadonlySet<string>;
64
+ hasDraft(entry: ChatEntry): boolean;
65
+ open(entry: ChatEntry): void;
66
+ pinKey(key: string, pin: boolean): void;
67
+ search(text: string): void;
68
+ /** Whether rows are left to draw below. */
69
+ more(): boolean;
70
+ t: Translate;
71
+ }): void;
53
72
  //# sourceMappingURL=chat-list-hooks.d.ts.map
@@ -39,9 +39,12 @@ exports.useMinute = useMinute;
39
39
  exports.usePageEnd = usePageEnd;
40
40
  exports.useChatListMotion = useChatListMotion;
41
41
  exports.useRowCalls = useRowCalls;
42
+ exports.useChatsScreen = useChatsScreen;
42
43
  const react_1 = require("@celljs/react");
43
44
  const React = __importStar(require("react"));
45
+ const use_screen_part_1 = require("../screen/use-screen-part");
44
46
  const state_protocol_1 = require("../state/state-protocol");
47
+ const chat_asks_1 = require("./chat-asks");
45
48
  const chat_home_util_1 = require("./chat-home-util");
46
49
  const chat_list_util_1 = require("./chat-list-util");
47
50
  const list_motion_1 = require("./list-motion");
@@ -146,4 +149,54 @@ function useRowCalls(given) {
146
149
  openFolder: (key, archived) => latest.current.openFolder(key, archived),
147
150
  }), []);
148
151
  }
152
+ /** What an agent reads of the list and does to it (docs/design/ta-app-use.md 3): the screen keeps the rows drawn in sight. */
153
+ function useChatsScreen(given) {
154
+ const { title, shown, inSight, letGo, isUnseen, pinned, hasDraft, open, pinKey, search, more, t } = given;
155
+ (0, use_screen_part_1.useScreenPart)({
156
+ id: 'chats',
157
+ title,
158
+ state: () => t('ta.screen.chats', { count: shown.length, unread: shown.filter(isUnseen).length }),
159
+ items: () => inSight().map(entry => {
160
+ var _a;
161
+ const asking = (_a = chat_asks_1.ChatAskUtil.asking(entry, letGo)) === null || _a === void 0 ? void 0 : _a.question;
162
+ const marks = [
163
+ ...(asking ? [t('ta.screen.asks', { question: asking })] : []),
164
+ ...(isUnseen(entry) ? [t('ta.screen.unread')] : []),
165
+ ...(pinned.has(chat_list_util_1.ChatListUtil.file(entry)) ? [t('ta.chat.pinned')] : []),
166
+ ...(chat_list_util_1.ChatListUtil.isOpen(entry) && entry.isStreaming ? [t('ta.screen.working')] : []),
167
+ ...(hasDraft(entry) ? [t('ta.chat.draft')] : []),
168
+ ];
169
+ return { id: chat_list_util_1.ChatListUtil.file(entry), text: chat_list_util_1.ChatListUtil.title(entry, t), ...(marks.length ? { marks } : {}) };
170
+ }),
171
+ actions: {
172
+ open: {
173
+ label: t('ta.screen.open'),
174
+ each: true,
175
+ run: file => {
176
+ const entry = inSight().find(one => chat_list_util_1.ChatListUtil.file(one) === file);
177
+ if (entry) {
178
+ open(entry);
179
+ }
180
+ },
181
+ },
182
+ pin: {
183
+ label: t('ta.chat.pin'),
184
+ each: true,
185
+ command: 'chats.pin',
186
+ commandInput: file => ({ file, pinned: true }),
187
+ run: file => pinKey(file !== null && file !== void 0 ? file : '', true),
188
+ },
189
+ unpin: {
190
+ label: t('ta.chat.unpin'),
191
+ each: true,
192
+ command: 'chats.pin',
193
+ commandInput: file => ({ file, pinned: false }),
194
+ run: file => pinKey(file !== null && file !== void 0 ? file : '', false),
195
+ },
196
+ stop: { label: t('ta.stop'), each: true, command: 'chats.stop', commandInput: file => ({ file }) },
197
+ search: { label: t('ta.chat.search'), takes: 'text', run: (_file, input) => { var _a; return search(String((_a = input.text) !== null && _a !== void 0 ? _a : '')); } },
198
+ },
199
+ scroll: { more: () => (more() ? 'bottom' : undefined) },
200
+ });
201
+ }
149
202
  //# sourceMappingURL=chat-list-hooks.js.map
@@ -0,0 +1,52 @@
1
+ import type { Translate } from '../i18n/use-t';
2
+ import { type ChatHomeRow } from './chat-home-util';
3
+ import type { ChatListProps } from './chat-list-props';
4
+ import { type ChatEntry, type ChatRow } from './chat-list-util';
5
+ /** What the rows are worked out of: the props of the list, the minute and the search. */
6
+ export type ChatRowsGiven = Pick<ChatListProps, 'sessions' | 'saved' | 'archived' | 'foldDays' | 'archiveDays' | 'pinned' | 'letGo' | 'home' | 'double'> & {
7
+ removedFiles: string[];
8
+ now: number;
9
+ query: string;
10
+ t: Translate;
11
+ };
12
+ /**
13
+ * What the list of conversations shows (ChatList), and in what part: listed, archived, taken out, pinned, in folders, the
14
+ * double's tasks and rows of its home, as the search finds them.
15
+ */
16
+ export declare function useChatRows({ sessions, saved, archived: archivedSaved, foldDays, archiveDays, pinned, letGo, home, double, removedFiles, now, query, t, }: ChatRowsGiven): {
17
+ searching: boolean;
18
+ foldBefore: number | undefined;
19
+ folderOf: ((chat: import("..").WebChat) => import("./chat-icon").ChatFolderIcon | undefined) | undefined;
20
+ partnerSessions: ReadonlyMap<string, number> | undefined;
21
+ listed: ChatEntry[];
22
+ archived: ChatEntry[];
23
+ removed: ChatEntry[];
24
+ held: ChatEntry[];
25
+ archivedRest: ChatEntry[];
26
+ sources: import("./chat-list-util").ChatSource[];
27
+ homeTasks: import("./chat-home-util").ChatHomeTasks | undefined;
28
+ shown: ChatEntry[];
29
+ byFile: Map<string, ChatEntry>;
30
+ taskRows: import("./chat-home-util").ChatTaskRow[];
31
+ archivedTasks: import("./chat-home-util").ChatTaskRow[];
32
+ shownRemoved: ChatEntry[];
33
+ apart: {
34
+ pinned: ChatEntry[];
35
+ rest: ChatEntry[];
36
+ };
37
+ rest: ChatEntry[];
38
+ folders: import("./chat-list-util").ChatFolder[];
39
+ homeRows: ChatHomeRow[];
40
+ homeRest: ChatRow[];
41
+ pinnedRows: ChatRow[];
42
+ };
43
+ /** Only those going on, as the row of the double opened the list: the one shown stays, though seen once opened. */
44
+ export declare function useBusyRows({ busy, double, sessions, saved, removedFiles, seen, letGo, folderOf, selected, listed, query, t, }: Pick<ChatListProps, 'double' | 'sessions' | 'saved' | 'seen' | 'letGo' | 'selected'> & {
45
+ busy: boolean;
46
+ removedFiles: string[];
47
+ folderOf: ((entry: ChatEntry) => unknown) | undefined;
48
+ listed: ChatEntry[];
49
+ query: string;
50
+ t: Translate;
51
+ }): ChatEntry[];
52
+ //# sourceMappingURL=chat-list-rows.d.ts.map
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.useChatRows = useChatRows;
37
+ exports.useBusyRows = useBusyRows;
38
+ const React = __importStar(require("react"));
39
+ const extension_view_1 = require("../extension/extension-view");
40
+ const workbench_util_1 = require("../workbench-util");
41
+ const chat_busy_1 = require("./chat-busy");
42
+ const chat_home_util_1 = require("./chat-home-util");
43
+ const chat_icon_1 = require("./chat-icon");
44
+ const chat_list_hooks_1 = require("./chat-list-hooks");
45
+ const chat_list_util_1 = require("./chat-list-util");
46
+ /**
47
+ * What the list of conversations shows (ChatList), and in what part: listed, archived, taken out, pinned, in folders, the
48
+ * double's tasks and rows of its home, as the search finds them.
49
+ */
50
+ function useChatRows({ sessions, saved, archived: archivedSaved, foldDays, archiveDays, pinned, letGo, home, double, removedFiles, now, query, t, }) {
51
+ // Worked out again only when the conversations or the search change, not as the minute or the selection does.
52
+ // The bounds of the archive and of the fold move once a day.
53
+ const searching = !!query.trim();
54
+ const since = workbench_util_1.WorkbenchUtil.daysAgo(now, archiveDays);
55
+ const foldBefore = searching ? undefined : workbench_util_1.WorkbenchUtil.daysAgo(now, foldDays);
56
+ // Those an extension archives sooner (WebChatIcon.archiveDays), asked again as its icons change.
57
+ const icons = React.useContext(extension_view_1.ChatIcons);
58
+ const sooner = React.useMemo(() => chat_icon_1.ChatIconUtil.archiveSince(icons.entries, now), [icons, now]);
59
+ // Those an extension folds into a row of their folder (WebChatIcon.folder), asked again as its icons change.
60
+ const folderOf = React.useMemo(() => chat_icon_1.ChatIconUtil.folderOf(icons.entries), [icons]);
61
+ const partnerSessions = home === null || home === void 0 ? void 0 : home.partnerSessions; // The agents' conversations, listed once closed too.
62
+ const groupListed = React.useMemo(() => chat_list_util_1.ChatListUtil.groupListed(folderOf, partnerSessions), [folderOf, partnerSessions]);
63
+ // One that waits for the user is not archived, however old, as one pinned.
64
+ const kept = React.useMemo(() => chat_list_util_1.ChatListUtil.keptFiles([...saved, ...(archivedSaved !== null && archivedSaved !== void 0 ? archivedSaved : [])], pinned, letGo), [saved, archivedSaved, pinned, letGo]);
65
+ const { listed, archived, removed } = React.useMemo(() => chat_list_util_1.ChatListUtil.entries(sessions, saved, removedFiles, archivedSaved, since, kept, sooner, groupListed), [sessions, saved, removedFiles, archivedSaved, since, kept, sooner, groupListed]);
66
+ // A folder pinned holds its archived conversations too, and stays once they all are: a row pinned never goes away.
67
+ const { held, rest: archivedRest } = React.useMemo(() => chat_list_util_1.ChatListUtil.heldByPinned(archived, folderOf, pinned), [archived, folderOf, pinned]);
68
+ const sources = React.useMemo(() => chat_list_util_1.ChatListUtil.sources(listed), [listed]);
69
+ // The double's tasks: what waits for the user above the rest, those that are no conversation rows by their time.
70
+ const allTasks = home === null || home === void 0 ? void 0 : home.tasks;
71
+ const homeTasks = React.useMemo(() => (allTasks ? chat_home_util_1.ChatHomeUtil.tasks(allTasks) : undefined), [allTasks]);
72
+ // The rows extensions add to the double's list (a daily brief), and the conversations they stand for.
73
+ const allItems = home === null || home === void 0 ? void 0 : home.items;
74
+ const homeItems = React.useMemo(() => (allItems ? chat_home_util_1.ChatHomeUtil.items(allItems) : []), [allItems]);
75
+ const standIns = React.useMemo(() => chat_home_util_1.ChatHomeUtil.standIns(homeItems), [homeItems]);
76
+ // On the double's list its own conversation is its card, one that waits for the user is under the card, and one a
77
+ // row of the home stands for is that row.
78
+ const onHome = React.useCallback((entry) => !!homeTasks &&
79
+ ((!!double && chat_list_util_1.ChatListUtil.isDouble(entry, double)) ||
80
+ homeTasks.hidden.has(chat_list_util_1.ChatListUtil.file(entry)) ||
81
+ standIns.has(chat_list_util_1.ChatListUtil.file(entry)) ||
82
+ (chat_list_util_1.ChatListUtil.isOpen(entry) && homeTasks.hidden.has(entry.sessionId))), [homeTasks, double, standIns]);
83
+ // A search finds the archived too.
84
+ const shown = React.useMemo(() => chat_list_util_1.ChatListUtil.filter(searching ? [...listed, ...archived] : listed, query, t).filter(entry => !onHome(entry)), [listed, archived, searching, query, t, onHome]);
85
+ // The conversation of a task (WebTask.session), by its file or the id of its session.
86
+ const byFile = React.useMemo(() => new Map(listed.flatMap(entry => [
87
+ [chat_list_util_1.ChatListUtil.file(entry), entry],
88
+ ...(chat_list_util_1.ChatListUtil.isOpen(entry) ? [[entry.sessionId, entry]] : []),
89
+ ])), [listed]);
90
+ // A task whose conversation the list does not have is a row of its own; those that ended before the archive's bound are archived.
91
+ const { listed: taskRows, archived: archivedTasks } = React.useMemo(() => chat_home_util_1.ChatHomeUtil.rows(homeTasks, allTasks, byFile, query, searching ? undefined : since, archived.map(chat_list_util_1.ChatListUtil.file), removedFiles), [homeTasks, allTasks, byFile, query, searching, since, archived, removedFiles]);
92
+ const shownRemoved = React.useMemo(() => chat_list_util_1.ChatListUtil.filter(removed, query, t), [removed, query, t]);
93
+ // Those pinned at the top, whatever their day or directory. Those that wait for the user to decide stay where they
94
+ // are, marked by a blue ?: the double's home gathers them (docs/design/ta-decide.md).
95
+ const apart = React.useMemo(() => chat_list_util_1.ChatListUtil.pinnedApart(shown, pinned), [shown, pinned]);
96
+ // Each folder one row where its latest is; those pinned or asking the user stay above, as any other.
97
+ const { folders: allFolders, rest } = React.useMemo(() => (searching ? { folders: [], rest: apart.rest } : chat_list_util_1.ChatListUtil.folders([...apart.rest, ...held], folderOf)), [apart.rest, held, folderOf, searching]);
98
+ // A folder pinned is a row of those pinned, as a conversation pinned; so is a row of the home.
99
+ const { pinned: pinnedFolders, rest: folders } = React.useMemo(() => chat_list_util_1.ChatListUtil.pinnedApart(allFolders, pinned), [allFolders, pinned]);
100
+ // With the conversations with partners that are none of pi (a chat of two, a group chat), by their time as any other.
101
+ const partners = home === null || home === void 0 ? void 0 : home.partners;
102
+ const homeRows = React.useMemo(() => chat_home_util_1.ChatHomeUtil.homeRows(homeItems, partners !== null && partners !== void 0 ? partners : [], query), [homeItems, partners, query]);
103
+ const { pinned: pinnedHome, rest: homeRest } = React.useMemo(() => chat_list_util_1.ChatListUtil.pinnedApart(homeRows, pinned), [homeRows, pinned]);
104
+ const pinnedRows = React.useMemo(() => chat_list_util_1.ChatListUtil.withFolders(apart.pinned, [...pinnedFolders, ...pinnedHome]), [apart.pinned, pinnedFolders, pinnedHome]);
105
+ (0, chat_list_hooks_1.useOfferPins)(listed, folderOf, homeItems);
106
+ return {
107
+ searching,
108
+ foldBefore,
109
+ folderOf,
110
+ partnerSessions,
111
+ listed,
112
+ archived,
113
+ removed,
114
+ held,
115
+ archivedRest,
116
+ sources,
117
+ homeTasks,
118
+ shown,
119
+ byFile,
120
+ taskRows,
121
+ archivedTasks,
122
+ shownRemoved,
123
+ apart,
124
+ rest,
125
+ folders,
126
+ homeRows,
127
+ homeRest,
128
+ pinnedRows,
129
+ };
130
+ }
131
+ /** Only those going on, as the row of the double opened the list: the one shown stays, though seen once opened. */
132
+ function useBusyRows({ busy, double, sessions, saved, removedFiles, seen, letGo, folderOf, selected, listed, query, t, }) {
133
+ return React.useMemo(() => {
134
+ var _a;
135
+ if (!busy) {
136
+ return [];
137
+ }
138
+ const others = new Set([...((_a = double === null || double === void 0 ? void 0 : double.tasks.keys()) !== null && _a !== void 0 ? _a : []), double === null || double === void 0 ? void 0 : double.session, double === null || double === void 0 ? void 0 : double.sessionFile].filter((id) => !!id));
139
+ const going = chat_busy_1.ChatBusyUtil.list(sessions, saved, removedFiles, others, seen, letGo, entry => !!(folderOf === null || folderOf === void 0 ? void 0 : folderOf(entry))).entries.map(each => each.entry);
140
+ const kept = selected && !going.some(entry => chat_list_util_1.ChatListUtil.key(entry) === selected) ? listed.find(entry => chat_list_util_1.ChatListUtil.key(entry) === selected) : undefined;
141
+ const rows = kept ? [...going, kept] : going;
142
+ // Those that wait first, as the double's row counts them, not by when they last said something.
143
+ const found = new Set(chat_list_util_1.ChatListUtil.filter(rows, query, t));
144
+ return rows.filter(entry => found.has(entry));
145
+ }, [busy, double, sessions, saved, removedFiles, seen, letGo, folderOf, selected, listed, query, t]);
146
+ }
147
+ //# sourceMappingURL=chat-list-rows.js.map
@@ -0,0 +1,37 @@
1
+ import * as React from 'react';
2
+ import type { Translate } from '../i18n/use-t';
3
+ import type { ChatTaskRow } from './chat-home-util';
4
+ import { type ChatEntry, type ChatFolder, type ChatRow, type ChatSource, type RowBudget } from './chat-list-util';
5
+ /** What the list of conversations draws its rows by (ChatList). */
6
+ export interface ChatSectionsGiven {
7
+ /** By directory or package, else by day. */
8
+ grouped: boolean;
9
+ rest: ChatEntry[];
10
+ sources: ChatSource[];
11
+ folders: ChatFolder[];
12
+ taskRows: ChatTaskRow[];
13
+ homeRest: ChatRow[];
14
+ folded: readonly string[];
15
+ fold(key: string): void;
16
+ /** Those updated before are older, folded at the end; undefined while searching. */
17
+ foldBefore: number | undefined;
18
+ foldDays: number;
19
+ groupsOlder: string[];
20
+ setGroupsOlder(keys: string[]): void;
21
+ olderOpen: boolean;
22
+ setOlderOpen(open: boolean): void;
23
+ budget: RowBudget<ChatRow>;
24
+ /** Drawn though folded or past the budget: the conversation shown, those unseen. */
25
+ rowStays(row: ChatRow): boolean;
26
+ rowItem(row: ChatRow, compact?: boolean): React.ReactNode;
27
+ /** A new conversation in a directory. */
28
+ draftIn(cwd: string): void;
29
+ now: number;
30
+ t: Translate;
31
+ }
32
+ /**
33
+ * The sections of the list, by directory or by day: called as the list renders, not drawn as a component of its own,
34
+ * for the budget is taken in the order the list is drawn.
35
+ */
36
+ export declare function drawChatSections({ grouped, rest, sources, folders, taskRows, homeRest, folded, fold, foldBefore, foldDays, groupsOlder, setGroupsOlder, olderOpen, setOlderOpen, budget, rowStays, rowItem, draftIn, now, t, }: ChatSectionsGiven): React.ReactNode[];
37
+ //# sourceMappingURL=chat-list-sections.d.ts.map