@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
@@ -0,0 +1,51 @@
1
+ import type { Translate } from '../i18n/use-t.js';
2
+ import { type ChatHomeRow } from './chat-home-util.js';
3
+ import type { ChatListProps } from './chat-list-props.js';
4
+ import { type ChatEntry, type ChatRow } from './chat-list-util.js';
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("../index.js").WebChat) => import("./chat-icon.js").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.js").ChatSource[];
27
+ homeTasks: import("./chat-home-util.js").ChatHomeTasks | undefined;
28
+ shown: ChatEntry[];
29
+ byFile: Map<string, ChatEntry>;
30
+ taskRows: import("./chat-home-util.js").ChatTaskRow[];
31
+ archivedTasks: import("./chat-home-util.js").ChatTaskRow[];
32
+ shownRemoved: ChatEntry[];
33
+ apart: {
34
+ pinned: ChatEntry[];
35
+ rest: ChatEntry[];
36
+ };
37
+ rest: ChatEntry[];
38
+ folders: import("./chat-list-util.js").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[];
@@ -0,0 +1,110 @@
1
+ import * as React from 'react';
2
+ import { ChatIcons } from '../extension/extension-view.js';
3
+ import { WorkbenchUtil } from '../workbench-util.js';
4
+ import { ChatBusyUtil } from './chat-busy.js';
5
+ import { ChatHomeUtil } from './chat-home-util.js';
6
+ import { ChatIconUtil } from './chat-icon.js';
7
+ import { useOfferPins } from './chat-list-hooks.js';
8
+ import { ChatListUtil } from './chat-list-util.js';
9
+ /**
10
+ * What the list of conversations shows (ChatList), and in what part: listed, archived, taken out, pinned, in folders, the
11
+ * double's tasks and rows of its home, as the search finds them.
12
+ */
13
+ export function useChatRows({ sessions, saved, archived: archivedSaved, foldDays, archiveDays, pinned, letGo, home, double, removedFiles, now, query, t, }) {
14
+ // Worked out again only when the conversations or the search change, not as the minute or the selection does.
15
+ // The bounds of the archive and of the fold move once a day.
16
+ const searching = !!query.trim();
17
+ const since = WorkbenchUtil.daysAgo(now, archiveDays);
18
+ const foldBefore = searching ? undefined : WorkbenchUtil.daysAgo(now, foldDays);
19
+ // Those an extension archives sooner (WebChatIcon.archiveDays), asked again as its icons change.
20
+ const icons = React.useContext(ChatIcons);
21
+ const sooner = React.useMemo(() => ChatIconUtil.archiveSince(icons.entries, now), [icons, now]);
22
+ // Those an extension folds into a row of their folder (WebChatIcon.folder), asked again as its icons change.
23
+ const folderOf = React.useMemo(() => ChatIconUtil.folderOf(icons.entries), [icons]);
24
+ const partnerSessions = home === null || home === void 0 ? void 0 : home.partnerSessions; // The agents' conversations, listed once closed too.
25
+ const groupListed = React.useMemo(() => ChatListUtil.groupListed(folderOf, partnerSessions), [folderOf, partnerSessions]);
26
+ // One that waits for the user is not archived, however old, as one pinned.
27
+ const kept = React.useMemo(() => ChatListUtil.keptFiles([...saved, ...(archivedSaved !== null && archivedSaved !== void 0 ? archivedSaved : [])], pinned, letGo), [saved, archivedSaved, pinned, letGo]);
28
+ const { listed, archived, removed } = React.useMemo(() => ChatListUtil.entries(sessions, saved, removedFiles, archivedSaved, since, kept, sooner, groupListed), [sessions, saved, removedFiles, archivedSaved, since, kept, sooner, groupListed]);
29
+ // A folder pinned holds its archived conversations too, and stays once they all are: a row pinned never goes away.
30
+ const { held, rest: archivedRest } = React.useMemo(() => ChatListUtil.heldByPinned(archived, folderOf, pinned), [archived, folderOf, pinned]);
31
+ const sources = React.useMemo(() => ChatListUtil.sources(listed), [listed]);
32
+ // The double's tasks: what waits for the user above the rest, those that are no conversation rows by their time.
33
+ const allTasks = home === null || home === void 0 ? void 0 : home.tasks;
34
+ const homeTasks = React.useMemo(() => (allTasks ? ChatHomeUtil.tasks(allTasks) : undefined), [allTasks]);
35
+ // The rows extensions add to the double's list (a daily brief), and the conversations they stand for.
36
+ const allItems = home === null || home === void 0 ? void 0 : home.items;
37
+ const homeItems = React.useMemo(() => (allItems ? ChatHomeUtil.items(allItems) : []), [allItems]);
38
+ const standIns = React.useMemo(() => ChatHomeUtil.standIns(homeItems), [homeItems]);
39
+ // On the double's list its own conversation is its card, one that waits for the user is under the card, and one a
40
+ // row of the home stands for is that row.
41
+ const onHome = React.useCallback((entry) => !!homeTasks &&
42
+ ((!!double && ChatListUtil.isDouble(entry, double)) ||
43
+ homeTasks.hidden.has(ChatListUtil.file(entry)) ||
44
+ standIns.has(ChatListUtil.file(entry)) ||
45
+ (ChatListUtil.isOpen(entry) && homeTasks.hidden.has(entry.sessionId))), [homeTasks, double, standIns]);
46
+ // A search finds the archived too.
47
+ const shown = React.useMemo(() => ChatListUtil.filter(searching ? [...listed, ...archived] : listed, query, t).filter(entry => !onHome(entry)), [listed, archived, searching, query, t, onHome]);
48
+ // The conversation of a task (WebTask.session), by its file or the id of its session.
49
+ const byFile = React.useMemo(() => new Map(listed.flatMap(entry => [
50
+ [ChatListUtil.file(entry), entry],
51
+ ...(ChatListUtil.isOpen(entry) ? [[entry.sessionId, entry]] : []),
52
+ ])), [listed]);
53
+ // 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.
54
+ const { listed: taskRows, archived: archivedTasks } = React.useMemo(() => ChatHomeUtil.rows(homeTasks, allTasks, byFile, query, searching ? undefined : since, archived.map(ChatListUtil.file), removedFiles), [homeTasks, allTasks, byFile, query, searching, since, archived, removedFiles]);
55
+ const shownRemoved = React.useMemo(() => ChatListUtil.filter(removed, query, t), [removed, query, t]);
56
+ // Those pinned at the top, whatever their day or directory. Those that wait for the user to decide stay where they
57
+ // are, marked by a blue ?: the double's home gathers them (docs/design/ta-decide.md).
58
+ const apart = React.useMemo(() => ChatListUtil.pinnedApart(shown, pinned), [shown, pinned]);
59
+ // Each folder one row where its latest is; those pinned or asking the user stay above, as any other.
60
+ const { folders: allFolders, rest } = React.useMemo(() => (searching ? { folders: [], rest: apart.rest } : ChatListUtil.folders([...apart.rest, ...held], folderOf)), [apart.rest, held, folderOf, searching]);
61
+ // A folder pinned is a row of those pinned, as a conversation pinned; so is a row of the home.
62
+ const { pinned: pinnedFolders, rest: folders } = React.useMemo(() => ChatListUtil.pinnedApart(allFolders, pinned), [allFolders, pinned]);
63
+ // With the conversations with partners that are none of pi (a chat of two, a group chat), by their time as any other.
64
+ const partners = home === null || home === void 0 ? void 0 : home.partners;
65
+ const homeRows = React.useMemo(() => ChatHomeUtil.homeRows(homeItems, partners !== null && partners !== void 0 ? partners : [], query), [homeItems, partners, query]);
66
+ const { pinned: pinnedHome, rest: homeRest } = React.useMemo(() => ChatListUtil.pinnedApart(homeRows, pinned), [homeRows, pinned]);
67
+ const pinnedRows = React.useMemo(() => ChatListUtil.withFolders(apart.pinned, [...pinnedFolders, ...pinnedHome]), [apart.pinned, pinnedFolders, pinnedHome]);
68
+ useOfferPins(listed, folderOf, homeItems);
69
+ return {
70
+ searching,
71
+ foldBefore,
72
+ folderOf,
73
+ partnerSessions,
74
+ listed,
75
+ archived,
76
+ removed,
77
+ held,
78
+ archivedRest,
79
+ sources,
80
+ homeTasks,
81
+ shown,
82
+ byFile,
83
+ taskRows,
84
+ archivedTasks,
85
+ shownRemoved,
86
+ apart,
87
+ rest,
88
+ folders,
89
+ homeRows,
90
+ homeRest,
91
+ pinnedRows,
92
+ };
93
+ }
94
+ /** Only those going on, as the row of the double opened the list: the one shown stays, though seen once opened. */
95
+ export function useBusyRows({ busy, double, sessions, saved, removedFiles, seen, letGo, folderOf, selected, listed, query, t, }) {
96
+ return React.useMemo(() => {
97
+ var _a;
98
+ if (!busy) {
99
+ return [];
100
+ }
101
+ 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));
102
+ const going = ChatBusyUtil.list(sessions, saved, removedFiles, others, seen, letGo, entry => !!(folderOf === null || folderOf === void 0 ? void 0 : folderOf(entry))).entries.map(each => each.entry);
103
+ const kept = selected && !going.some(entry => ChatListUtil.key(entry) === selected) ? listed.find(entry => ChatListUtil.key(entry) === selected) : undefined;
104
+ const rows = kept ? [...going, kept] : going;
105
+ // Those that wait first, as the double's row counts them, not by when they last said something.
106
+ const found = new Set(ChatListUtil.filter(rows, query, t));
107
+ return rows.filter(entry => found.has(entry));
108
+ }, [busy, double, sessions, saved, removedFiles, seen, letGo, folderOf, selected, listed, query, t]);
109
+ }
110
+ //# sourceMappingURL=chat-list-rows.js.map
@@ -0,0 +1,36 @@
1
+ import * as React from 'react';
2
+ import type { Translate } from '../i18n/use-t.js';
3
+ import type { ChatTaskRow } from './chat-home-util.js';
4
+ import { type ChatEntry, type ChatFolder, type ChatRow, type ChatSource, type RowBudget } from './chat-list-util.js';
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[];
@@ -0,0 +1,72 @@
1
+ import { Plus } from 'lucide-react';
2
+ import * as React from 'react';
3
+ import { ChatIconTile } from './chat-icon.js';
4
+ import { ChatFoldToggle, ChatGroupHead, ChatSourceMark } from './chat-list-controls.js';
5
+ import { ChatListUtil } from './chat-list-util.js';
6
+ import { IconButton } from './icon.js';
7
+ import { DinoFace } from './ta-avatar.js';
8
+ /**
9
+ * The sections of the list, by directory or by day: called as the list renders, not drawn as a component of its own,
10
+ * for the budget is taken in the order the list is drawn.
11
+ */
12
+ export function drawChatSections({ grouped, rest, sources, folders, taskRows, homeRest, folded, fold, foldBefore, foldDays, groupsOlder, setGroupsOlder, olderOpen, setOlderOpen, budget, rowStays, rowItem, draftIn, now, t, }) {
13
+ // A group of the list by directory: its head, and its conversations, those older folded.
14
+ const groupSection = (key, head, sessions) => {
15
+ const closed = folded.includes(key);
16
+ const [recent, older] = ChatListUtil.split(sessions, foldBefore);
17
+ const olderShown = groupsOlder.includes(key);
18
+ // Folded, a group still has the conversation shown and those unseen; so do its older ones.
19
+ const candidates = closed ? sessions.filter(rowStays) : olderShown ? sessions : [...recent, ...older.filter(rowStays)];
20
+ const rows = budget.take(candidates);
21
+ if (rows.length === 0 && candidates.length > 0) {
22
+ return null;
23
+ }
24
+ return (React.createElement("section", { key: key, className: "ta-chat-group" },
25
+ head,
26
+ rows.length > 0 && React.createElement("ul", { className: "ta-side-list" }, rows.map(row => rowItem(row, true))),
27
+ !closed && older.length > 0 && rows.length === candidates.length && (React.createElement(ChatFoldToggle, { label: t('ta.chat.olderCount', { days: foldDays, count: older.length }), open: olderShown, onClick: () => setGroupsOlder(olderShown ? groupsOlder.filter(other => other !== key) : [...groupsOlder, key]) }))));
28
+ };
29
+ // The rows in the order of the list, as far as the budget goes: what is drawn after uses what is left. By
30
+ // directory, a folder is a group as a directory is, where its latest is.
31
+ // By directory, the double's tasks that are no conversation are a group of their own, where the latest of them is.
32
+ const doubleRows = [...homeRest, ...taskRows].sort((a, b) => b.updatedAt - a.updatedAt);
33
+ const taskGroup = grouped &&
34
+ doubleRows.length > 0 &&
35
+ groupSection('tasks', React.createElement(ChatGroupHead, { open: !folded.includes('tasks'), onFold: () => fold('tasks'), leading: React.createElement(DinoFace, { size: 20, mood: "idle" }), label: t('ta.home.tasks'), count: doubleRows.length }), doubleRows);
36
+ return grouped
37
+ ? [
38
+ ...(taskGroup ? [{ latest: doubleRows[0].updatedAt, group: undefined, folder: undefined, tasks: taskGroup }] : []),
39
+ ...ChatListUtil.groups(rest, sources).map(group => { var _a; var _b; return ({ latest: (_b = (_a = group.sessions[0]) === null || _a === void 0 ? void 0 : _a.updatedAt) !== null && _b !== void 0 ? _b : 0, group, folder: undefined }); }),
40
+ ...folders.map(folder => ({ latest: folder.updatedAt, group: undefined, folder })),
41
+ ]
42
+ .sort((a, b) => b.latest - a.latest)
43
+ .map(({ group, folder, tasks }) => {
44
+ if (tasks) {
45
+ return tasks;
46
+ }
47
+ if (folder) {
48
+ return groupSection(folder.key, React.createElement(ChatGroupHead, { open: !folded.includes(folder.key), title: folder.title, onFold: () => fold(folder.key), leading: React.createElement(ChatIconTile, { found: folder.icon, size: 20 }), label: folder.title, count: folder.sessions.length }), folder.sessions);
49
+ }
50
+ const { source, sessions } = group;
51
+ return groupSection(source.key, React.createElement(ChatGroupHead, { open: !folded.includes(source.key), title: source.title, onFold: () => fold(source.key), leading: React.createElement(ChatSourceMark, { source: source }), label: source.label, count: sessions.length }, source.cwd && (React.createElement(IconButton, { className: "ta-chat-group-add", icon: Plus, label: t('ta.chat.newIn', { name: source.label }), onClick: () => draftIn(source.cwd) }))), sessions);
52
+ })
53
+ : (() => {
54
+ const [recent, older] = ChatListUtil.split(ChatListUtil.withFolders(rest, [...folders, ...taskRows, ...homeRest]), foldBefore);
55
+ const sections = ChatListUtil.sections(recent, now).map(section => {
56
+ const rows = budget.take(section.sessions);
57
+ return (rows.length > 0 && (React.createElement("section", { key: section.id, className: "ta-chat-section" },
58
+ React.createElement("div", { className: "ta-chat-section-title" }, t(section.id)),
59
+ React.createElement("ul", { className: "ta-side-list" }, rows.map(row => rowItem(row))))));
60
+ });
61
+ // Folded, the older still have the conversation shown and those unseen, drawn even before the rows above them are.
62
+ const cut = budget.more;
63
+ const olderRows = older.length > 0 ? budget.take(olderOpen ? older : older.filter(rowStays)) : [];
64
+ return [
65
+ ...sections,
66
+ older.length > 0 && (!cut || olderRows.length > 0) && (React.createElement("section", { key: "older", className: "ta-chat-section ta-chat-older" },
67
+ React.createElement(ChatFoldToggle, { label: t('ta.chat.olderCount', { days: foldDays, count: older.length }), open: olderOpen, onClick: () => setOlderOpen(!olderOpen) }),
68
+ olderRows.length > 0 && React.createElement("ul", { className: "ta-side-list" }, olderRows.map(row => rowItem(row))))),
69
+ ];
70
+ })();
71
+ }
72
+ //# sourceMappingURL=chat-list-sections.js.map
@@ -1,28 +1,25 @@
1
- import { ChevronLeft, ChevronRight, FolderTree, Plus, Search, X } from 'lucide-react';
1
+ import { X } from 'lucide-react';
2
2
  import * as React from 'react';
3
3
  import { useDevice } from '../device/device.js';
4
4
  import { DeviceMotion } from '../device/device-protocol.js';
5
5
  import { DraftPlaces, DraftsUtil } from '../drafts/drafts-protocol.js';
6
6
  import { useDrafts } from '../drafts/use-composer-draft.js';
7
- import { ChatIcons, SessionMenus } from '../extension/extension-view.js';
7
+ import { SessionMenus } from '../extension/extension-view.js';
8
8
  import { useT } from '../i18n/use-t.js';
9
9
  import { ScreenUtil } from '../screen/screen-protocol.js';
10
- import { useScreenPart } from '../screen/use-screen-part.js';
11
- import { WorkbenchUtil } from '../workbench-util.js';
12
10
  import { ChatAskUtil } from './chat-asks.js';
13
- import { ChatBusyUtil } from './chat-busy.js';
14
11
  import { ChatHomeItem, ChatHomeTop, ChatTaskItem } from './chat-home.js';
15
12
  import { ChatHomeUtil } from './chat-home-util.js';
16
- import { ChatIconTile, ChatIconUtil } from './chat-icon.js';
17
- import { useChatListMotion, useMinute, useOfferPins, usePageEnd, useReadArchive, useRowCalls } from './chat-list-hooks.js';
13
+ import { ChatFolderHead, ChatFoldToggle, ChatSearchHead } from './chat-list-controls.js';
14
+ import { useChatListMotion, useChatsScreen, useMinute, usePageEnd, useReadArchive, useRowCalls } from './chat-list-hooks.js';
18
15
  import { ChatFolderItem, ChatItem } from './chat-list-row.js';
16
+ import { useBusyRows, useChatRows } from './chat-list-rows.js';
17
+ import { drawChatSections } from './chat-list-sections.js';
19
18
  import { CHAT_PAGE, ChatListUtil } from './chat-list-util.js';
20
19
  import { EmptyState } from './empty-state.js';
21
- import { HostTag } from './host-tag.js';
22
- import { Icon, IconButton } from './icon.js';
20
+ import { Icon } from './icon.js';
23
21
  import { Loading } from './loading.js';
24
22
  import { PhoneStack } from './phone-shell.js';
25
- import { DinoFace } from './ta-avatar.js';
26
23
  /**
27
24
  * The conversations of the server, open or saved, the latest first, with a search and `+` for a new one:
28
25
  * by directory or package, each group folding and with a `+` of its own, or by day. Those not updated for
@@ -86,61 +83,7 @@ export function ChatList({ sessions, saved, removed: removedFiles, archived: arc
86
83
  }, [pinKey]);
87
84
  // A failure is a notice of the chat: what it changes goes on without the list.
88
85
  const pick = (_change) => onPicked();
89
- // Worked out again only when the conversations or the search change, not as the minute or the selection does.
90
- // The bounds of the archive and of the fold move once a day.
91
- const searching = !!query.trim();
92
- const since = WorkbenchUtil.daysAgo(now, archiveDays);
93
- const foldBefore = searching ? undefined : WorkbenchUtil.daysAgo(now, foldDays);
94
- // Those an extension archives sooner (WebChatIcon.archiveDays), asked again as its icons change.
95
- const icons = React.useContext(ChatIcons);
96
- const sooner = React.useMemo(() => ChatIconUtil.archiveSince(icons.entries, now), [icons, now]);
97
- // Those an extension folds into a row of their folder (WebChatIcon.folder), asked again as its icons change.
98
- const folderOf = React.useMemo(() => ChatIconUtil.folderOf(icons.entries), [icons]);
99
- const partnerSessions = home === null || home === void 0 ? void 0 : home.partnerSessions; // The agents' conversations, listed once closed too.
100
- const groupListed = React.useMemo(() => ChatListUtil.groupListed(folderOf, partnerSessions), [folderOf, partnerSessions]);
101
- // One that waits for the user is not archived, however old, as one pinned.
102
- const kept = React.useMemo(() => ChatListUtil.keptFiles([...saved, ...(archivedSaved !== null && archivedSaved !== void 0 ? archivedSaved : [])], pinned, letGo), [saved, archivedSaved, pinned, letGo]);
103
- const { listed, archived, removed } = React.useMemo(() => ChatListUtil.entries(sessions, saved, removedFiles, archivedSaved, since, kept, sooner, groupListed), [sessions, saved, removedFiles, archivedSaved, since, kept, sooner, groupListed]);
104
- // A folder pinned holds its archived conversations too, and stays once they all are: a row pinned never goes away.
105
- const { held, rest: archivedRest } = React.useMemo(() => ChatListUtil.heldByPinned(archived, folderOf, pinned), [archived, folderOf, pinned]);
106
- const sources = React.useMemo(() => ChatListUtil.sources(listed), [listed]);
107
- // The double's tasks: what waits for the user above the rest, those that are no conversation rows by their time.
108
- const allTasks = home === null || home === void 0 ? void 0 : home.tasks;
109
- const homeTasks = React.useMemo(() => (allTasks ? ChatHomeUtil.tasks(allTasks) : undefined), [allTasks]);
110
- // The rows extensions add to the double's list (a daily brief), and the conversations they stand for.
111
- const allItems = home === null || home === void 0 ? void 0 : home.items;
112
- const homeItems = React.useMemo(() => (allItems ? ChatHomeUtil.items(allItems) : []), [allItems]);
113
- const standIns = React.useMemo(() => ChatHomeUtil.standIns(homeItems), [homeItems]);
114
- // On the double's list its own conversation is its card, one that waits for the user is under the card, and one a
115
- // row of the home stands for is that row.
116
- const onHome = React.useCallback((entry) => !!homeTasks &&
117
- ((!!double && ChatListUtil.isDouble(entry, double)) ||
118
- homeTasks.hidden.has(ChatListUtil.file(entry)) ||
119
- standIns.has(ChatListUtil.file(entry)) ||
120
- (ChatListUtil.isOpen(entry) && homeTasks.hidden.has(entry.sessionId))), [homeTasks, double, standIns]);
121
- // A search finds the archived too.
122
- const shown = React.useMemo(() => ChatListUtil.filter(searching ? [...listed, ...archived] : listed, query, t).filter(entry => !onHome(entry)), [listed, archived, searching, query, t, onHome]);
123
- // The conversation of a task (WebTask.session), by its file or the id of its session.
124
- const byFile = React.useMemo(() => new Map(listed.flatMap(entry => [
125
- [ChatListUtil.file(entry), entry],
126
- ...(ChatListUtil.isOpen(entry) ? [[entry.sessionId, entry]] : []),
127
- ])), [listed]);
128
- // 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.
129
- const { listed: taskRows, archived: archivedTasks } = React.useMemo(() => ChatHomeUtil.rows(homeTasks, allTasks, byFile, query, searching ? undefined : since, archived.map(ChatListUtil.file), removedFiles), [homeTasks, allTasks, byFile, query, searching, since, archived, removedFiles]);
130
- const shownRemoved = React.useMemo(() => ChatListUtil.filter(removed, query, t), [removed, query, t]);
131
- // Those pinned at the top, whatever their day or directory. Those that wait for the user to decide stay where they
132
- // are, marked by a blue ?: the double's home gathers them (docs/design/ta-decide.md).
133
- const apart = React.useMemo(() => ChatListUtil.pinnedApart(shown, pinned), [shown, pinned]);
134
- // Each folder one row where its latest is; those pinned or asking the user stay above, as any other.
135
- const { folders: allFolders, rest } = React.useMemo(() => (searching ? { folders: [], rest: apart.rest } : ChatListUtil.folders([...apart.rest, ...held], folderOf)), [apart.rest, held, folderOf, searching]);
136
- // A folder pinned is a row of those pinned, as a conversation pinned; so is a row of the home.
137
- const { pinned: pinnedFolders, rest: folders } = React.useMemo(() => ChatListUtil.pinnedApart(allFolders, pinned), [allFolders, pinned]);
138
- // With the conversations with partners that are none of pi (a chat of two, a group chat), by their time as any other.
139
- const partners = home === null || home === void 0 ? void 0 : home.partners;
140
- const homeRows = React.useMemo(() => ChatHomeUtil.homeRows(homeItems, partners !== null && partners !== void 0 ? partners : [], query), [homeItems, partners, query]);
141
- const { pinned: pinnedHome, rest: homeRest } = React.useMemo(() => ChatListUtil.pinnedApart(homeRows, pinned), [homeRows, pinned]);
142
- const pinnedRows = React.useMemo(() => ChatListUtil.withFolders(apart.pinned, [...pinnedFolders, ...pinnedHome]), [apart.pinned, pinnedFolders, pinnedHome]);
143
- useOfferPins(listed, folderOf, homeItems);
86
+ const { searching, foldBefore, folderOf, partnerSessions, listed, archived, removed, held, archivedRest, sources, homeTasks, shown, byFile, taskRows, archivedTasks, shownRemoved, apart, rest, folders, homeRows, homeRest, pinnedRows, } = useChatRows({ sessions, saved, archived: archivedSaved, foldDays, archiveDays, pinned, letGo, home, double, removedFiles, now, query, t });
144
87
  // The folder opened: all of it, those pinned too, as the search of the list finds them; one of the archive, its archived.
145
88
  const folder = React.useMemo(() => folderShown
146
89
  ? ChatListUtil.folders(folderShown.archived ? archivedRest : [...listed, ...held], folderOf).folders.find(candidate => candidate.key === folderShown.key)
@@ -179,53 +122,19 @@ export function ChatList({ sessions, saved, removed: removedFiles, archived: arc
179
122
  return kept && DraftsUtil.preview(kept);
180
123
  };
181
124
  const item = (session, compact) => { var _a; var _b; return (React.createElement(ChatItem, { key: ChatListUtil.key(session), session: session, source: byKey.get(ChatListUtil.sourceKey(session)), selected: ChatListUtil.key(session) === selected, time: ChatListUtil.clock(session.updatedAt, now), compact: compact, actions: actions, task: (_b = (ChatListUtil.isOpen(session) ? double === null || double === void 0 ? void 0 : double.tasks.get(session.sessionId) : undefined)) !== null && _b !== void 0 ? _b : (session.sessionFile ? double === null || double === void 0 ? void 0 : double.tasks.get(session.sessionFile) : undefined), doubleName: double && ChatListUtil.isDouble(session, double) ? double.name : undefined, handable: !!double && ChatListUtil.isOpen(session) && !session.group && !double.tasks.has(session.sessionId) && !ChatListUtil.isDouble(session, double), pinned: pinnedKeys.has(ChatListUtil.file(session)), unseen: isUnseen(session), asking: (_a = ChatAskUtil.asking(session, letGo)) === null || _a === void 0 ? void 0 : _a.question, draft: draftOf(session) })); };
182
- // 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.
183
- const inSight = () => (folder ? folderRows : [...apart.pinned, ...apart.rest]);
184
- useScreenPart({
185
- id: 'chats',
125
+ useChatsScreen({
186
126
  title: folder ? folder.title : t('ta.chat'),
187
- state: () => t('ta.screen.chats', { count: shown.length, unread: shown.filter(isUnseen).length }),
188
- items: () => inSight().map(entry => {
189
- var _a;
190
- const asking = (_a = ChatAskUtil.asking(entry, letGo)) === null || _a === void 0 ? void 0 : _a.question;
191
- const marks = [
192
- ...(asking ? [t('ta.screen.asks', { question: asking })] : []),
193
- ...(isUnseen(entry) ? [t('ta.screen.unread')] : []),
194
- ...(pinnedKeys.has(ChatListUtil.file(entry)) ? [t('ta.chat.pinned')] : []),
195
- ...(ChatListUtil.isOpen(entry) && entry.isStreaming ? [t('ta.screen.working')] : []),
196
- ...(draftOf(entry) ? [t('ta.chat.draft')] : []),
197
- ];
198
- return { id: ChatListUtil.file(entry), text: ChatListUtil.title(entry, t), ...(marks.length ? { marks } : {}) };
199
- }),
200
- actions: {
201
- open: {
202
- label: t('ta.screen.open'),
203
- each: true,
204
- run: file => {
205
- const entry = inSight().find(one => ChatListUtil.file(one) === file);
206
- if (entry) {
207
- actions.open(entry);
208
- }
209
- },
210
- },
211
- pin: {
212
- label: t('ta.chat.pin'),
213
- each: true,
214
- command: 'chats.pin',
215
- commandInput: file => ({ file, pinned: true }),
216
- run: file => pinKey(file !== null && file !== void 0 ? file : '', true),
217
- },
218
- unpin: {
219
- label: t('ta.chat.unpin'),
220
- each: true,
221
- command: 'chats.pin',
222
- commandInput: file => ({ file, pinned: false }),
223
- run: file => pinKey(file !== null && file !== void 0 ? file : '', false),
224
- },
225
- stop: { label: t('ta.stop'), each: true, command: 'chats.stop', commandInput: file => ({ file }) },
226
- search: { label: t('ta.chat.search'), takes: 'text', run: (_file, input) => { var _a; return setQuery(String((_a = input.text) !== null && _a !== void 0 ? _a : '')); } },
227
- },
228
- scroll: { more: () => ((folder ? folderBudget : budget).more ? 'bottom' : undefined) },
127
+ shown,
128
+ inSight: () => (folder ? folderRows : [...apart.pinned, ...apart.rest]),
129
+ letGo,
130
+ isUnseen,
131
+ pinned: pinnedKeys,
132
+ hasDraft: entry => !!draftOf(entry),
133
+ open: entry => actions.open(entry),
134
+ pinKey,
135
+ search: setQuery,
136
+ more: () => (folder ? folderBudget : budget).more,
137
+ t,
229
138
  });
230
139
  // Into a folder from the top of its list, and back where the list was left.
231
140
  const listScroll = React.useRef(0);
@@ -291,87 +200,29 @@ export function ChatList({ sessions, saved, removed: removedFiles, archived: arc
291
200
  }
292
201
  });
293
202
  // A toggle of what folds under a title: the older conversations, the archive, those taken out.
294
- const toggle = (label, open, onClick, title) => (React.createElement("button", { type: "button", className: "ta-chat-section-title ta-chat-fold", "aria-expanded": open, title: title, onClick: onClick },
295
- React.createElement(Icon, { icon: ChevronRight, size: 13 }),
296
- label));
297
- // A group of the list by directory: its head, and its conversations, those older folded.
298
- const groupSection = (key, head, sessions) => {
299
- const closed = folded.includes(key);
300
- const [recent, older] = ChatListUtil.split(sessions, foldBefore);
301
- const olderShown = groupsOlder.includes(key);
302
- // Folded, a group still has the conversation shown and those unseen; so do its older ones.
303
- const candidates = closed ? sessions.filter(rowStays) : olderShown ? sessions : [...recent, ...older.filter(rowStays)];
304
- const rows = budget.take(candidates);
305
- if (rows.length === 0 && candidates.length > 0) {
306
- return null;
307
- }
308
- return (React.createElement("section", { key: key, className: "ta-chat-group" },
309
- head,
310
- rows.length > 0 && React.createElement("ul", { className: "ta-side-list" }, rows.map(row => rowItem(row, true))),
311
- !closed &&
312
- older.length > 0 &&
313
- rows.length === candidates.length &&
314
- toggle(t('ta.chat.olderCount', { days: foldDays, count: older.length }), olderShown, () => setGroupsOlder(olderShown ? groupsOlder.filter(other => other !== key) : [...groupsOlder, key]))));
315
- };
316
- // The rows in the order of the list, as far as the budget goes: what is drawn after uses what is left. By
317
- // directory, a folder is a group as a directory is, where its latest is.
318
- // By directory, the double's tasks that are no conversation are a group of their own, where the latest of them is.
319
- const doubleRows = [...homeRest, ...taskRows].sort((a, b) => b.updatedAt - a.updatedAt);
320
- const taskGroup = grouped &&
321
- doubleRows.length > 0 &&
322
- groupSection('tasks', React.createElement("div", { className: "ta-chat-group-head" },
323
- React.createElement("button", { type: "button", className: "ta-chat-group-toggle", "aria-expanded": !folded.includes('tasks'), onClick: () => fold('tasks') },
324
- React.createElement(DinoFace, { size: 20, mood: "idle" }),
325
- React.createElement("span", { className: "ta-chat-group-label" }, t('ta.home.tasks')),
326
- React.createElement("span", { className: "ta-chat-group-count" }, doubleRows.length),
327
- React.createElement(Icon, { icon: ChevronRight, size: 13, className: "ta-chat-group-chevron" }))), doubleRows);
328
- const list = grouped
329
- ? [
330
- ...(taskGroup ? [{ latest: doubleRows[0].updatedAt, group: undefined, folder: undefined, tasks: taskGroup }] : []),
331
- ...ChatListUtil.groups(rest, sources).map(group => { var _a; var _b; return ({ latest: (_b = (_a = group.sessions[0]) === null || _a === void 0 ? void 0 : _a.updatedAt) !== null && _b !== void 0 ? _b : 0, group, folder: undefined }); }),
332
- ...folders.map(folder => ({ latest: folder.updatedAt, group: undefined, folder })),
333
- ]
334
- .sort((a, b) => b.latest - a.latest)
335
- .map(({ group, folder, tasks }) => {
336
- if (tasks) {
337
- return tasks;
338
- }
339
- if (folder) {
340
- return groupSection(folder.key, React.createElement("div", { className: "ta-chat-group-head" },
341
- React.createElement("button", { type: "button", className: "ta-chat-group-toggle", "aria-expanded": !folded.includes(folder.key), title: folder.title, onClick: () => fold(folder.key) },
342
- React.createElement(ChatIconTile, { found: folder.icon, size: 20 }),
343
- React.createElement("span", { className: "ta-chat-group-label" }, folder.title),
344
- React.createElement("span", { className: "ta-chat-group-count" }, folder.sessions.length),
345
- React.createElement(Icon, { icon: ChevronRight, size: 13, className: "ta-chat-group-chevron" }))), folder.sessions);
346
- }
347
- const { source, sessions } = group;
348
- return groupSection(source.key, React.createElement("div", { className: "ta-chat-group-head" },
349
- React.createElement("button", { type: "button", className: "ta-chat-group-toggle", "aria-expanded": !folded.includes(source.key), title: source.title, onClick: () => fold(source.key) },
350
- React.createElement("span", { className: `ta-chat-group-avatar ta-tone-${source.tone}`, "aria-hidden": "true" }, source.initial),
351
- React.createElement(HostTag, { host: source.host }),
352
- React.createElement("span", { className: "ta-chat-group-label" }, source.label),
353
- React.createElement("span", { className: "ta-chat-group-count" }, sessions.length),
354
- React.createElement(Icon, { icon: ChevronRight, size: 13, className: "ta-chat-group-chevron" })),
355
- source.cwd && (React.createElement(IconButton, { className: "ta-chat-group-add", icon: Plus, label: t('ta.chat.newIn', { name: source.label }), onClick: () => draftIn(source.cwd) }))), sessions);
356
- })
357
- : (() => {
358
- const [recent, older] = ChatListUtil.split(ChatListUtil.withFolders(rest, [...folders, ...taskRows, ...homeRest]), foldBefore);
359
- const sections = ChatListUtil.sections(recent, now).map(section => {
360
- const rows = budget.take(section.sessions);
361
- return (rows.length > 0 && (React.createElement("section", { key: section.id, className: "ta-chat-section" },
362
- React.createElement("div", { className: "ta-chat-section-title" }, t(section.id)),
363
- React.createElement("ul", { className: "ta-side-list" }, rows.map(row => rowItem(row))))));
364
- });
365
- // Folded, the older still have the conversation shown and those unseen, drawn even before the rows above them are.
366
- const cut = budget.more;
367
- const olderRows = older.length > 0 ? budget.take(olderOpen ? older : older.filter(rowStays)) : [];
368
- return [
369
- ...sections,
370
- older.length > 0 && (!cut || olderRows.length > 0) && (React.createElement("section", { key: "older", className: "ta-chat-section ta-chat-older" },
371
- toggle(t('ta.chat.olderCount', { days: foldDays, count: older.length }), olderOpen, () => setOlderOpen(!olderOpen)),
372
- olderRows.length > 0 && React.createElement("ul", { className: "ta-side-list" }, olderRows.map(row => rowItem(row))))),
373
- ];
374
- })();
203
+ const toggle = (label, open, onClick, title) => (React.createElement(ChatFoldToggle, { label: label, open: open, onClick: onClick, title: title }));
204
+ const list = drawChatSections({
205
+ grouped,
206
+ rest,
207
+ sources,
208
+ folders,
209
+ taskRows,
210
+ homeRest,
211
+ folded,
212
+ fold,
213
+ foldBefore,
214
+ foldDays,
215
+ groupsOlder,
216
+ setGroupsOlder,
217
+ olderOpen,
218
+ setOlderOpen,
219
+ budget,
220
+ rowStays,
221
+ rowItem,
222
+ draftIn,
223
+ now,
224
+ t,
225
+ });
375
226
  // The archive, after the list once it is all drawn: read each time it opens, as it is not read with the list.
376
227
  const archive = !searching && archiveShown && !budget.more && (React.createElement("section", { className: "ta-chat-section ta-chat-archive" },
377
228
  toggle(archivedSaved ? t('ta.chat.archivedCount', { count: archivedRest.length + archivedTasks.length }) : t('ta.chat.archived'), archiveOpen, () => {
@@ -394,20 +245,7 @@ export function ChatList({ sessions, saved, removed: removedFiles, archived: arc
394
245
  React.createElement("div", { className: "ta-chat-section-title" }, t(section.id)),
395
246
  React.createElement("ul", { className: "ta-side-list" }, section.sessions.map(session => item(session)))))),
396
247
  folderRows.length === 0 && React.createElement(EmptyState, { title: t('ta.chat.noMatch') })));
397
- // Only those going on, as the row of the double opened the list: the one shown stays, though seen once opened.
398
- const busyRows = React.useMemo(() => {
399
- var _a;
400
- if (!busy) {
401
- return [];
402
- }
403
- 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));
404
- const going = ChatBusyUtil.list(sessions, saved, removedFiles, others, seen, letGo, entry => !!(folderOf === null || folderOf === void 0 ? void 0 : folderOf(entry))).entries.map(each => each.entry);
405
- const kept = selected && !going.some(entry => ChatListUtil.key(entry) === selected) ? listed.find(entry => ChatListUtil.key(entry) === selected) : undefined;
406
- const rows = kept ? [...going, kept] : going;
407
- // Those that wait first, as the double's row counts them, not by when they last said something.
408
- const found = new Set(ChatListUtil.filter(rows, query, t));
409
- return rows.filter(entry => found.has(entry));
410
- }, [busy, double, sessions, saved, removedFiles, seen, letGo, folderOf, selected, listed, query, t]);
248
+ const busyRows = useBusyRows({ busy, double, sessions, saved, removedFiles, seen, letGo, folderOf, selected, listed, query, t });
411
249
  const busyContent = (React.createElement(React.Fragment, null,
412
250
  React.createElement("div", { className: "ta-chat-filter" },
413
251
  React.createElement("button", { type: "button", className: "ta-chat-filter-chip", title: t('ta.chats.busyClear'), onClick: () => onBusy === null || onBusy === void 0 ? void 0 : onBusy(false) },
@@ -438,30 +276,19 @@ export function ChatList({ sessions, saved, removed: removedFiles, archived: arc
438
276
  usePageEnd(budget.more && !(folderOpen && !handheld), scroller, end, nextPage, pageKey);
439
277
  usePageEnd(!!folder && folderBudget.more, folderScroller, folderEnd, nextPage, pageKey);
440
278
  useChatListMotion(scroller, folderScroller);
441
- const head = (React.createElement("header", { className: "ta-chats-head" },
442
- React.createElement("label", { className: "ta-chats-search" },
443
- React.createElement(Icon, { icon: Search, size: 15 }),
444
- React.createElement("input", { value: query, placeholder: t('ta.chat.search'), "aria-label": t('ta.chat.search'), onChange: event => setQuery(event.target.value) }),
445
- query ? (React.createElement(IconButton, { className: "ta-chats-clear", icon: X, label: t('ta.close'), onClick: () => setQuery('') })) : (sources.length > 1 && (React.createElement(IconButton, { className: "ta-chats-view", icon: FolderTree, label: t('ta.chat.byDirectory'), "aria-pressed": byDirectory, onClick: () => onByDirectory(!byDirectory) })))),
446
- React.createElement(IconButton, { className: "ta-chats-add", icon: Plus, label: t('ta.chat.new'), onClick: () => pick(chat.draft()) })));
279
+ const head = (React.createElement(ChatSearchHead, { query: query, onQuery: setQuery, byDirectory: sources.length > 1 ? byDirectory : undefined, onByDirectory: onByDirectory, onNew: () => pick(chat.draft()) }));
447
280
  const listPane = (React.createElement("div", { className: "ta-side-scroll", ref: scroller },
448
281
  listContent,
449
282
  budget.more && React.createElement("div", { ref: end, className: "ta-chat-more", "aria-hidden": "true" })));
450
283
  const folderPane = folder && (React.createElement(React.Fragment, null,
451
- React.createElement("div", { className: "ta-chat-folder-head" },
452
- React.createElement(IconButton, { className: "ta-chat-folder-back", icon: ChevronLeft, label: t('ta.back'), onClick: closeFolder }),
453
- React.createElement("span", { className: "ta-chat-folder-title" }, folder.title),
454
- React.createElement("span", { className: "ta-chat-group-count" }, folder.sessions.length)),
284
+ React.createElement(ChatFolderHead, { title: folder.title, count: folder.sessions.length, onBack: closeFolder }),
455
285
  React.createElement("div", { className: "ta-side-scroll", ref: folderScroller },
456
286
  folderList,
457
287
  folderBudget.more && React.createElement("div", { ref: folderEnd, className: "ta-chat-more", "aria-hidden": "true" }))));
458
- // On a phone those going on are a page pushed over a tab (AppShell's PhoneHome): its head, as a folder's, goes back.
288
+ // On a phone those going on are a page pushed over a tab (PhoneHome, phone-shell.tsx): its head, as a folder's, goes back.
459
289
  if (busy && handheld) {
460
290
  return (React.createElement("section", { className: "ta-chats", "aria-label": t('ta.chats.busy'), ...ScreenUtil.part('chats') },
461
- React.createElement("div", { className: "ta-chat-folder-head" },
462
- React.createElement(IconButton, { className: "ta-chat-folder-back", icon: ChevronLeft, label: t('ta.back'), onClick: () => onBusy === null || onBusy === void 0 ? void 0 : onBusy(false) }),
463
- React.createElement("span", { className: "ta-chat-folder-title" }, t('ta.chats.busy')),
464
- React.createElement("span", { className: "ta-chat-group-count" }, busyRows.length)),
291
+ React.createElement(ChatFolderHead, { title: t('ta.chats.busy'), count: busyRows.length, onBack: () => onBusy === null || onBusy === void 0 ? void 0 : onBusy(false) }),
465
292
  notice,
466
293
  React.createElement("div", { className: "ta-side-scroll", ref: scroller }, busyRows.length > 0 ? (React.createElement("ul", { className: "ta-side-list" }, busyRows.map(session => item(session)))) : (React.createElement(EmptyState, { title: t('ta.chats.busyNone') })))));
467
294
  }