@celljs/ta-web 4.11.0 → 4.13.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 (281) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/esm/browser/assistant/assistant-extension.js +14 -0
  4. package/esm/browser/assistant/assistant-initiative.d.ts +27 -0
  5. package/esm/browser/assistant/assistant-initiative.js +76 -0
  6. package/esm/browser/assistant/assistant-task-source.d.ts +7 -0
  7. package/esm/browser/assistant/assistant-task-source.js +12 -2
  8. package/esm/browser/assistant/assistant-view.js +10 -6
  9. package/esm/browser/assistant/assistant.d.ts +5 -0
  10. package/esm/browser/assistant/assistant.js +25 -6
  11. package/esm/browser/chat/chat-view.js +6 -5
  12. package/esm/browser/components/app-nav.d.ts +3 -1
  13. package/esm/browser/components/app-nav.js +5 -2
  14. package/esm/browser/components/app-view.js +26 -13
  15. package/esm/browser/components/asks-badge.d.ts +5 -0
  16. package/esm/browser/components/asks-badge.js +8 -0
  17. package/esm/browser/components/chat-asks.d.ts +46 -0
  18. package/esm/browser/components/chat-asks.js +101 -0
  19. package/esm/browser/components/chat-list.d.ts +7 -1
  20. package/esm/browser/components/chat-list.js +46 -17
  21. package/esm/browser/components/composer-addon-util.d.ts +11 -0
  22. package/esm/browser/components/composer-addon-util.js +40 -0
  23. package/esm/browser/components/composer-addons.d.ts +1 -7
  24. package/esm/browser/components/composer-addons.js +1 -27
  25. package/esm/browser/components/composer-box.d.ts +1 -0
  26. package/esm/browser/components/composer-box.js +50 -28
  27. package/esm/browser/components/composer.d.ts +10 -1
  28. package/esm/browser/components/composer.js +61 -22
  29. package/esm/browser/components/connection-bar.js +31 -12
  30. package/esm/browser/components/conversation-scroll-hooks.d.ts +16 -0
  31. package/esm/browser/components/conversation-scroll-hooks.js +98 -0
  32. package/esm/browser/components/conversation-scroll-util.d.ts +35 -0
  33. package/esm/browser/components/conversation-scroll-util.js +74 -0
  34. package/esm/browser/components/conversation-scroll.d.ts +57 -33
  35. package/esm/browser/components/conversation-scroll.js +188 -123
  36. package/esm/browser/components/discover-view.js +5 -1
  37. package/esm/browser/components/earlier-messages.d.ts +10 -3
  38. package/esm/browser/components/earlier-messages.js +14 -8
  39. package/esm/browser/components/face.d.ts +24 -0
  40. package/esm/browser/components/face.js +42 -0
  41. package/esm/browser/components/folder-picker.d.ts +2 -0
  42. package/esm/browser/components/folder-picker.js +7 -0
  43. package/esm/browser/components/host-view.d.ts +1 -1
  44. package/esm/browser/components/markdown.js +4 -2
  45. package/esm/browser/components/media.js +25 -11
  46. package/esm/browser/components/mermaid-view.js +45 -3
  47. package/esm/browser/components/message-actions.js +1 -0
  48. package/esm/browser/components/message-footer.d.ts +4 -0
  49. package/esm/browser/components/message-footer.js +8 -1
  50. package/esm/browser/components/message-list.d.ts +15 -1
  51. package/esm/browser/components/message-list.js +204 -41
  52. package/esm/browser/components/phone-shell.d.ts +7 -2
  53. package/esm/browser/components/phone-shell.js +9 -3
  54. package/esm/browser/components/relay-services.d.ts +24 -0
  55. package/esm/browser/components/relay-services.js +249 -0
  56. package/esm/browser/components/relay-view.js +17 -1
  57. package/esm/browser/components/remote-hosts.js +1 -1
  58. package/esm/browser/components/session-view.d.ts +3 -1
  59. package/esm/browser/components/session-view.js +23 -7
  60. package/esm/browser/components/settings-controls.js +3 -3
  61. package/esm/browser/components/settings-parts.js +13 -1
  62. package/esm/browser/components/stop-times.d.ts +47 -0
  63. package/esm/browser/components/stop-times.js +81 -0
  64. package/esm/browser/components/ta-avatar.js +6 -0
  65. package/esm/browser/components/tool-result.d.ts +13 -0
  66. package/esm/browser/components/tool-result.js +138 -0
  67. package/esm/browser/components/tool-view.js +5 -15
  68. package/esm/browser/components/use-stop-times.d.ts +3 -0
  69. package/esm/browser/components/use-stop-times.js +17 -0
  70. package/esm/browser/components/web-composer.js +2 -1
  71. package/esm/browser/device/photo-picker.d.ts +14 -0
  72. package/esm/browser/device/photo-picker.js +48 -0
  73. package/esm/browser/device/row-swipe.d.ts +2 -0
  74. package/esm/browser/device/row-swipe.js +8 -2
  75. package/esm/browser/device/sheet-swipe.d.ts +1 -1
  76. package/esm/browser/device/sheet-swipe.js +17 -3
  77. package/esm/browser/extension/extension-view.d.ts +3 -1
  78. package/esm/browser/extension/extension-view.js +7 -0
  79. package/esm/browser/extension/icons.js +10 -1
  80. package/esm/browser/extension/web-api-components.d.ts +21 -3
  81. package/esm/browser/extension/web-api-contributions.d.ts +128 -0
  82. package/esm/browser/extension/web-extension-api.d.ts +45 -48
  83. package/esm/browser/extension/web-extension-context.d.ts +6 -1
  84. package/esm/browser/extension/web-extension-context.js +72 -7
  85. package/esm/browser/extension/web-extension-protocol.d.ts +18 -2
  86. package/esm/browser/extension/web-extension-protocol.js +2 -0
  87. package/esm/browser/extension/web-extension-run.d.ts +3 -2
  88. package/esm/browser/extension/web-extension-run.js +3 -0
  89. package/esm/browser/extension/web-extensions.d.ts +2 -8
  90. package/esm/browser/extension/web-extensions.js +12 -35
  91. package/esm/browser/extension/web-page-list.d.ts +25 -0
  92. package/esm/browser/extension/web-page-list.js +35 -0
  93. package/esm/browser/extension/web-session-notices.d.ts +6 -1
  94. package/esm/browser/extension/web-session-notices.js +30 -4
  95. package/esm/browser/extension/web-sharing.d.ts +5 -2
  96. package/esm/browser/extension/web-sharing.js +10 -1
  97. package/esm/browser/i18n/locales.d.ts +77 -1
  98. package/esm/browser/i18n/messages.d.ts +76 -0
  99. package/esm/browser/i18n/messages.js +154 -2
  100. package/esm/browser/links/links-protocol.d.ts +2 -0
  101. package/esm/browser/links/links.d.ts +7 -2
  102. package/esm/browser/links/links.js +16 -9
  103. package/esm/browser/markdown/code-renderers.d.ts +4 -0
  104. package/esm/browser/markdown/code-renderers.js +4 -0
  105. package/esm/browser/markdown/lazy.d.ts +8 -0
  106. package/esm/browser/markdown/lazy.js +35 -0
  107. package/esm/browser/markdown/mermaid.d.ts +15 -3
  108. package/esm/browser/markdown/mermaid.js +45 -6
  109. package/esm/browser/notices/notices-protocol.d.ts +5 -0
  110. package/esm/browser/notices/notices.d.ts +19 -0
  111. package/esm/browser/notices/notices.js +85 -2
  112. package/esm/browser/notices/session-notices.d.ts +5 -2
  113. package/esm/browser/notices/session-notices.js +10 -1
  114. package/esm/browser/style/base.d.ts +1 -1
  115. package/esm/browser/style/base.js +2 -1
  116. package/esm/browser/style/conversation.d.ts +1 -1
  117. package/esm/browser/style/conversation.js +53 -0
  118. package/esm/browser/style/device.js +3 -0
  119. package/esm/browser/style/layout.d.ts +1 -1
  120. package/esm/browser/style/layout.js +27 -9
  121. package/esm/browser/style/pages.d.ts +1 -1
  122. package/esm/browser/style/pages.js +5 -0
  123. package/esm/browser/style/phone.d.ts +1 -1
  124. package/esm/browser/style/phone.js +2 -0
  125. package/esm/browser/style/shell.d.ts +1 -1
  126. package/esm/browser/style/shell.js +16 -3
  127. package/esm/browser/style/surfaces.d.ts +1 -1
  128. package/esm/browser/style/surfaces.js +19 -0
  129. package/esm/browser/util/desktop.d.ts +18 -1
  130. package/esm/browser/util/desktop.js +13 -0
  131. package/esm/browser/util/frame.d.ts +2 -0
  132. package/esm/browser/util/frame.js +2 -0
  133. package/esm/browser/util/process.d.ts +69 -2
  134. package/esm/browser/util/process.js +163 -8
  135. package/esm/browser/util/progress.d.ts +6 -1
  136. package/esm/browser/util/progress.js +11 -2
  137. package/esm/browser/util/scroll-rest.d.ts +10 -0
  138. package/esm/browser/util/scroll-rest.js +44 -0
  139. package/esm/browser/util/tool-result.d.ts +32 -0
  140. package/esm/browser/util/tool-result.js +85 -0
  141. package/esm/browser/util/tool.js +7 -0
  142. package/lib/browser/assistant/assistant-extension.js +14 -0
  143. package/lib/browser/assistant/assistant-initiative.d.ts +28 -0
  144. package/lib/browser/assistant/assistant-initiative.js +80 -0
  145. package/lib/browser/assistant/assistant-task-source.d.ts +7 -0
  146. package/lib/browser/assistant/assistant-task-source.js +12 -2
  147. package/lib/browser/assistant/assistant-view.js +8 -4
  148. package/lib/browser/assistant/assistant.d.ts +5 -0
  149. package/lib/browser/assistant/assistant.js +24 -5
  150. package/lib/browser/chat/chat-view.js +6 -5
  151. package/lib/browser/components/app-nav.d.ts +3 -1
  152. package/lib/browser/components/app-nav.js +5 -2
  153. package/lib/browser/components/app-view.js +25 -12
  154. package/lib/browser/components/asks-badge.d.ts +6 -0
  155. package/lib/browser/components/asks-badge.js +44 -0
  156. package/lib/browser/components/chat-asks.d.ts +47 -0
  157. package/lib/browser/components/chat-asks.js +104 -0
  158. package/lib/browser/components/chat-list.d.ts +7 -1
  159. package/lib/browser/components/chat-list.js +46 -17
  160. package/lib/browser/components/composer-addon-util.d.ts +12 -0
  161. package/lib/browser/components/composer-addon-util.js +76 -0
  162. package/lib/browser/components/composer-addons.d.ts +1 -7
  163. package/lib/browser/components/composer-addons.js +2 -29
  164. package/lib/browser/components/composer-box.d.ts +1 -0
  165. package/lib/browser/components/composer-box.js +48 -26
  166. package/lib/browser/components/composer.d.ts +10 -1
  167. package/lib/browser/components/composer.js +61 -21
  168. package/lib/browser/components/connection-bar.js +30 -11
  169. package/lib/browser/components/conversation-scroll-hooks.d.ts +17 -0
  170. package/lib/browser/components/conversation-scroll-hooks.js +135 -0
  171. package/lib/browser/components/conversation-scroll-util.d.ts +36 -0
  172. package/lib/browser/components/conversation-scroll-util.js +78 -0
  173. package/lib/browser/components/conversation-scroll.d.ts +57 -33
  174. package/lib/browser/components/conversation-scroll.js +189 -158
  175. package/lib/browser/components/discover-view.js +5 -1
  176. package/lib/browser/components/earlier-messages.d.ts +10 -3
  177. package/lib/browser/components/earlier-messages.js +16 -9
  178. package/lib/browser/components/face.d.ts +25 -0
  179. package/lib/browser/components/face.js +79 -0
  180. package/lib/browser/components/folder-picker.d.ts +2 -0
  181. package/lib/browser/components/folder-picker.js +7 -0
  182. package/lib/browser/components/host-view.d.ts +1 -1
  183. package/lib/browser/components/markdown.js +3 -1
  184. package/lib/browser/components/media.js +24 -10
  185. package/lib/browser/components/mermaid-view.js +45 -3
  186. package/lib/browser/components/message-actions.js +1 -0
  187. package/lib/browser/components/message-footer.d.ts +4 -0
  188. package/lib/browser/components/message-footer.js +8 -0
  189. package/lib/browser/components/message-list.d.ts +15 -1
  190. package/lib/browser/components/message-list.js +200 -35
  191. package/lib/browser/components/phone-shell.d.ts +7 -2
  192. package/lib/browser/components/phone-shell.js +9 -3
  193. package/lib/browser/components/relay-services.d.ts +25 -0
  194. package/lib/browser/components/relay-services.js +286 -0
  195. package/lib/browser/components/relay-view.js +17 -1
  196. package/lib/browser/components/remote-hosts.js +1 -1
  197. package/lib/browser/components/session-view.d.ts +3 -1
  198. package/lib/browser/components/session-view.js +23 -7
  199. package/lib/browser/components/settings-controls.js +3 -3
  200. package/lib/browser/components/settings-parts.js +13 -1
  201. package/lib/browser/components/stop-times.d.ts +48 -0
  202. package/lib/browser/components/stop-times.js +85 -0
  203. package/lib/browser/components/ta-avatar.js +6 -0
  204. package/lib/browser/components/tool-result.d.ts +14 -0
  205. package/lib/browser/components/tool-result.js +175 -0
  206. package/lib/browser/components/tool-view.js +10 -20
  207. package/lib/browser/components/use-stop-times.d.ts +4 -0
  208. package/lib/browser/components/use-stop-times.js +53 -0
  209. package/lib/browser/components/web-composer.js +2 -1
  210. package/lib/browser/device/photo-picker.d.ts +15 -0
  211. package/lib/browser/device/photo-picker.js +51 -0
  212. package/lib/browser/device/row-swipe.d.ts +2 -0
  213. package/lib/browser/device/row-swipe.js +8 -2
  214. package/lib/browser/device/sheet-swipe.d.ts +1 -1
  215. package/lib/browser/device/sheet-swipe.js +17 -3
  216. package/lib/browser/extension/extension-view.d.ts +3 -1
  217. package/lib/browser/extension/extension-view.js +8 -1
  218. package/lib/browser/extension/icons.js +9 -0
  219. package/lib/browser/extension/web-api-components.d.ts +21 -3
  220. package/lib/browser/extension/web-api-contributions.d.ts +128 -0
  221. package/lib/browser/extension/web-extension-api.d.ts +45 -48
  222. package/lib/browser/extension/web-extension-context.d.ts +6 -1
  223. package/lib/browser/extension/web-extension-context.js +73 -8
  224. package/lib/browser/extension/web-extension-protocol.d.ts +18 -2
  225. package/lib/browser/extension/web-extension-protocol.js +2 -0
  226. package/lib/browser/extension/web-extension-run.d.ts +3 -2
  227. package/lib/browser/extension/web-extension-run.js +3 -0
  228. package/lib/browser/extension/web-extensions.d.ts +2 -8
  229. package/lib/browser/extension/web-extensions.js +12 -35
  230. package/lib/browser/extension/web-page-list.d.ts +26 -0
  231. package/lib/browser/extension/web-page-list.js +39 -0
  232. package/lib/browser/extension/web-session-notices.d.ts +6 -1
  233. package/lib/browser/extension/web-session-notices.js +30 -4
  234. package/lib/browser/extension/web-sharing.d.ts +5 -2
  235. package/lib/browser/extension/web-sharing.js +10 -1
  236. package/lib/browser/i18n/locales.d.ts +77 -1
  237. package/lib/browser/i18n/messages.d.ts +76 -0
  238. package/lib/browser/i18n/messages.js +154 -2
  239. package/lib/browser/links/links-protocol.d.ts +2 -0
  240. package/lib/browser/links/links.d.ts +7 -2
  241. package/lib/browser/links/links.js +16 -9
  242. package/lib/browser/markdown/code-renderers.d.ts +4 -0
  243. package/lib/browser/markdown/code-renderers.js +5 -1
  244. package/lib/browser/markdown/lazy.d.ts +8 -0
  245. package/lib/browser/markdown/lazy.js +37 -1
  246. package/lib/browser/markdown/mermaid.d.ts +15 -3
  247. package/lib/browser/markdown/mermaid.js +44 -5
  248. package/lib/browser/notices/notices-protocol.d.ts +5 -0
  249. package/lib/browser/notices/notices.d.ts +19 -0
  250. package/lib/browser/notices/notices.js +84 -1
  251. package/lib/browser/notices/session-notices.d.ts +5 -2
  252. package/lib/browser/notices/session-notices.js +10 -1
  253. package/lib/browser/style/base.d.ts +1 -1
  254. package/lib/browser/style/base.js +2 -1
  255. package/lib/browser/style/conversation.d.ts +1 -1
  256. package/lib/browser/style/conversation.js +53 -0
  257. package/lib/browser/style/device.js +3 -0
  258. package/lib/browser/style/layout.d.ts +1 -1
  259. package/lib/browser/style/layout.js +27 -9
  260. package/lib/browser/style/pages.d.ts +1 -1
  261. package/lib/browser/style/pages.js +5 -0
  262. package/lib/browser/style/phone.d.ts +1 -1
  263. package/lib/browser/style/phone.js +2 -0
  264. package/lib/browser/style/shell.d.ts +1 -1
  265. package/lib/browser/style/shell.js +16 -3
  266. package/lib/browser/style/surfaces.d.ts +1 -1
  267. package/lib/browser/style/surfaces.js +19 -0
  268. package/lib/browser/util/desktop.d.ts +18 -1
  269. package/lib/browser/util/desktop.js +13 -0
  270. package/lib/browser/util/frame.d.ts +2 -0
  271. package/lib/browser/util/frame.js +2 -0
  272. package/lib/browser/util/process.d.ts +69 -2
  273. package/lib/browser/util/process.js +165 -9
  274. package/lib/browser/util/progress.d.ts +6 -1
  275. package/lib/browser/util/progress.js +11 -2
  276. package/lib/browser/util/scroll-rest.d.ts +11 -0
  277. package/lib/browser/util/scroll-rest.js +47 -0
  278. package/lib/browser/util/tool-result.d.ts +33 -0
  279. package/lib/browser/util/tool-result.js +88 -0
  280. package/lib/browser/util/tool.js +7 -0
  281. package/package.json +7 -7
@@ -1,43 +1,9 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ConversationScroller = exports.SCROLL_SKIP = exports.ASK_CLASS = void 0;
37
- exports.useConversationScroll = useConversationScroll;
38
- exports.useAwayFromBottom = useAwayFromBottom;
39
- const React = __importStar(require("react"));
3
+ exports.ConversationScroller = exports.HELD_CLASS = exports.SCROLL_SKIP = exports.ASK_CLASS = void 0;
4
+ exports.calm = calm;
40
5
  const frame_1 = require("../util/frame");
6
+ const conversation_scroll_util_1 = require("./conversation-scroll-util");
41
7
  /** A message of the user in the thread: where the view goes when one is sent. */
42
8
  exports.ASK_CLASS = 'ta-thread-ask';
43
9
  /** How long a part of a message opened or closed by a click keeps its place (a motion of its height). */
@@ -62,11 +28,18 @@ const TOGGLE = '[aria-expanded], summary';
62
28
  * follow its answer.
63
29
  */
64
30
  const SCROLL_END_MS = 150;
31
+ /** How deep in a row taller than the view its part read is looked for. */
32
+ const PART_DEPTH = 8;
33
+ /** At most this share of the view is left to glide: more coming at once (a block, what came while away) jumps the rest. */
34
+ const GLIDE_MAX = 0.5;
65
35
  function hasScrollEnd() {
66
36
  return typeof window !== 'undefined' && 'onscrollend' in window;
67
37
  }
68
38
  /** A row of the thread under which earlier rows come in (what says they load): the row read is the one after it. */
69
39
  exports.SCROLL_SKIP = { 'data-scroll-skip': '' };
40
+ /** The thread while the mouse holds the scroll bar: what grows past its height is clipped, and no row shrinks for it. */
41
+ exports.HELD_CLASS = 'ta-scroll-held';
42
+ /** Whether motion is reduced in the settings: scrolls go at once. */
70
43
  function calm() {
71
44
  return typeof document !== 'undefined' && document.documentElement.hasAttribute('data-reduce-motion');
72
45
  }
@@ -90,7 +63,9 @@ function scrollsInside(target, view, up) {
90
63
  * holds a row for each message.
91
64
  *
92
65
  * - At the bottom, the view follows what comes in, after layout, on a change of the size of the thread or of
93
- * the view. The user scrolling up, by however little, leaves it where they took it: a wheel, a finger, a key,
66
+ * the view. What grew in sight glides into the view (GLIDE_MS); what grew above it moves the view with it at once,
67
+ * so that no row in sight moves for it; the view changing its height (the message box, the keyboard) goes at once.
68
+ * The user scrolling up, by however little, leaves it where they took it: a wheel, a finger, a key,
94
69
  * the scroll bar, whatever else moved the view up. Back down near the bottom, it follows again.
95
70
  * - Away from the bottom, what the user reads stays where it is: the row at the top of the view keeps its place
96
71
  * as rows above it change their height (earlier messages coming in, pictures, rows laid out as they come into
@@ -98,7 +73,8 @@ function scrollsInside(target, view, up) {
98
73
  * keyboard of a phone), as in a chat app.
99
74
  * - A part of a message opened or closed by a click (what has `aria-expanded`, a `summary`) stays where it was
100
75
  * clicked; opened past the bottom, the view stops following, for the user to read it.
101
- * - While the user holds the view (a finger on it, the mouse on its scroll bar), nothing moves it under them.
76
+ * - While the user holds the view (a finger on it, the mouse on its scroll bar), nothing moves it under them; the
77
+ * thread keeps its height while the scroll bar is held (`HELD_CLASS`), so that the thumb does not move under the mouse.
102
78
  * - A message the user sends goes to the top of the view, and the answer comes in under it: the thread keeps
103
79
  * the room for that until the answer fills it (`send`), and the message keeps to the top as rows above it
104
80
  * change their height (the turn it was sent into folding its steps).
@@ -108,7 +84,7 @@ class ConversationScroller {
108
84
  static of(view) {
109
85
  return ConversationScroller.views.get(view);
110
86
  }
111
- constructor(view, thread, now = () => performance.now()) {
87
+ constructor(view, thread, now = () => performance.now(), frames) {
112
88
  this.view = view;
113
89
  this.thread = thread;
114
90
  this.now = now;
@@ -116,6 +92,12 @@ class ConversationScroller {
116
92
  /** On a smooth way to the bottom (`toBottom`): what comes in meanwhile moves the end of the way. */
117
93
  this.chasing = false;
118
94
  this.held = false;
95
+ /**
96
+ * The mouse holds the scroll bar: the thread keeps its height until let go. The browser puts the view where
97
+ * the thumb is at each move of the mouse, by the height of the thread: a reply growing under it would move
98
+ * the view back and forth, and the thumb with it.
99
+ */
100
+ this.frozen = false;
119
101
  /** When the user last moved the view by hand (HAND_MS). */
120
102
  this.handAt = Number.NEGATIVE_INFINITY;
121
103
  /**
@@ -125,8 +107,10 @@ class ConversationScroller {
125
107
  this.room = 0;
126
108
  this.padding = 0;
127
109
  this.nativeEnd = hasScrollEnd();
110
+ this.glider = frames && new conversation_scroll_util_1.ScrollGlide(frames, now);
128
111
  this.top = view.scrollTop;
129
112
  this.height = view.clientHeight;
113
+ this.extent = view.scrollHeight;
130
114
  }
131
115
  /** Whether the view follows what comes in. */
132
116
  get atLatest() {
@@ -134,7 +118,9 @@ class ConversationScroller {
134
118
  }
135
119
  /** Listens to `view` (the view of this scroller) and its thread; returns what stops it. */
136
120
  attach(view, thread) {
121
+ var _a;
137
122
  ConversationScroller.views.set(view, this);
123
+ (_a = this.glider) !== null && _a !== void 0 ? _a : (this.glider = new conversation_scroll_util_1.ScrollGlide(frame_1.FrameUtil.animation, this.now));
138
124
  thread.style.paddingBottom = '';
139
125
  this.padding = Number.parseFloat(getComputedStyle(thread).paddingBottom) || 0;
140
126
  const onScroll = () => {
@@ -161,10 +147,16 @@ class ConversationScroller {
161
147
  // The mouse on the scroll bar (or beside the thread): the view itself is the target.
162
148
  const onPointerDown = (event) => {
163
149
  if (event.pointerType === 'mouse' && event.button === 0 && event.target === view) {
164
- this.hold();
150
+ this.hold(true);
165
151
  }
166
152
  };
167
153
  const onPointerUp = () => this.release();
154
+ // Let go outside the window, where no pointerup may come: the mouse moves with no button held.
155
+ const onPointerMove = (event) => {
156
+ if (this.frozen && event.buttons === 0) {
157
+ this.release();
158
+ }
159
+ };
168
160
  // Captured: before the click opens or closes what it is on (React handles it after, on the root).
169
161
  const onClick = (event) => this.clicked(event.target);
170
162
  const passive = { passive: true };
@@ -180,11 +172,15 @@ class ConversationScroller {
180
172
  view.addEventListener('click', onClick, true);
181
173
  window.addEventListener('pointerup', onPointerUp, passive);
182
174
  window.addEventListener('pointercancel', onPointerUp, passive);
175
+ window.addEventListener('pointermove', onPointerMove, passive);
183
176
  const observer = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(() => this.resized()) : undefined;
184
177
  observer === null || observer === void 0 ? void 0 : observer.observe(thread);
185
178
  // The view itself changes its height under what is around it (the message box, the keyboard of a phone).
186
179
  observer === null || observer === void 0 ? void 0 : observer.observe(view);
187
180
  return () => {
181
+ var _a;
182
+ this.freeze(false);
183
+ (_a = this.glider) === null || _a === void 0 ? void 0 : _a.stop();
188
184
  ConversationScroller.views.delete(view);
189
185
  view.removeEventListener('scroll', onScroll);
190
186
  view.removeEventListener('scrollend', onScrollEnd);
@@ -199,11 +195,13 @@ class ConversationScroller {
199
195
  view.removeEventListener('click', onClick, true);
200
196
  window.removeEventListener('pointerup', onPointerUp);
201
197
  window.removeEventListener('pointercancel', onPointerUp);
198
+ window.removeEventListener('pointermove', onPointerMove);
202
199
  observer === null || observer === void 0 ? void 0 : observer.disconnect();
203
200
  };
204
201
  }
205
202
  /** To the bottom at once, following from there: a conversation opened, loaded again or rewound. */
206
203
  reset() {
204
+ this.freeze(false);
207
205
  this.makeRoom(0);
208
206
  this.sent = undefined;
209
207
  this.heading = undefined;
@@ -245,6 +243,7 @@ class ConversationScroller {
245
243
  }
246
244
  scrolled() {
247
245
  const { view } = this;
246
+ this.keepAnchor();
248
247
  const top = view.scrollTop;
249
248
  const moved = top - this.top;
250
249
  this.top = top;
@@ -256,10 +255,13 @@ class ConversationScroller {
256
255
  return;
257
256
  }
258
257
  const distance = view.scrollHeight - top - view.clientHeight;
258
+ // More than a screen up with the thread as it was: a search in the page. As it changed, the browser's: in
259
+ // WebKit the view put back to the top while the steps of a turn fold into its reply, the event after.
260
+ const searched = -moved > view.clientHeight && view.scrollHeight === this.extent;
259
261
  if (distance < 1) {
260
262
  this.following = true;
261
263
  }
262
- else if (moved <= -1 && (this.held || this.now() - this.handAt < HAND_MS || -moved > view.clientHeight)) {
264
+ else if (moved <= -1 && (this.held || this.now() - this.handAt < HAND_MS || searched)) {
263
265
  // Up, by the user (the scroll bar dragged, a fling), or by more than a screen for them (a search in the
264
266
  // page, which goes to what is out of sight): the view stays where it was taken.
265
267
  this.following = false;
@@ -321,8 +323,12 @@ class ConversationScroller {
321
323
  }
322
324
  this.touchY = y;
323
325
  }
324
- hold() {
326
+ /** `bar`: the mouse on the scroll bar, rather than a finger on the view. */
327
+ hold(bar = false) {
325
328
  this.held = true;
329
+ if (bar) {
330
+ this.freeze(true);
331
+ }
326
332
  this.byUser();
327
333
  }
328
334
  /** Let go: what came in meanwhile shows, if the view follows. */
@@ -331,6 +337,7 @@ class ConversationScroller {
331
337
  return;
332
338
  }
333
339
  this.held = false;
340
+ this.freeze(false);
334
341
  this.touchY = undefined;
335
342
  if (this.following && this.heading === undefined && !this.chasing) {
336
343
  this.toBottomNow();
@@ -345,11 +352,12 @@ class ConversationScroller {
345
352
  /** The thread or the view changed its size. */
346
353
  resized() {
347
354
  const { view } = this;
355
+ this.extent = view.scrollHeight;
348
356
  const height = view.clientHeight;
349
357
  const shrunk = this.height - height;
350
358
  this.height = height;
351
- const sent = this.sent;
352
- if (sent === null || sent === void 0 ? void 0 : sent.isConnected) {
359
+ const sent = this.sentRow();
360
+ if (sent) {
353
361
  const top = this.place(sent);
354
362
  if (this.heading !== undefined && Math.abs(top - this.heading) >= 1) {
355
363
  this.heading = top;
@@ -374,16 +382,36 @@ class ConversationScroller {
374
382
  view.scrollTo({ top: view.scrollHeight - view.clientHeight, behavior: 'smooth' });
375
383
  }
376
384
  else if (!this.held) {
377
- this.toBottomNow();
385
+ this.follow(shrunk !== 0);
378
386
  }
379
387
  return;
380
388
  }
381
389
  // The row read where it was, the bottom of the view kept to the message box. From the row rather than the
382
390
  // view: the browser may have pulled the view up meanwhile, the thread shorter than where it was.
383
- const anchor = this.anchor;
384
- this.moveTo(((anchor === null || anchor === void 0 ? void 0 : anchor.row.isConnected) ? anchor.row.offsetTop - anchor.offset : this.top) + shrunk);
391
+ const at = this.anchor && this.anchorAt(this.anchor);
392
+ this.moveTo((at === undefined ? this.top : at - this.anchor.offset) + shrunk);
385
393
  this.remember();
386
394
  }
395
+ /**
396
+ * The row of the message sent, while it is there. Rows are drawn by the place of their message: one coming in
397
+ * before it (what an extension adds to the turn) gives its row to that one, which may show nothing, and the
398
+ * message to the next row; the view would else go to the top of the thread.
399
+ */
400
+ sentRow() {
401
+ var _a;
402
+ const sent = this.sent;
403
+ if (!(sent === null || sent === void 0 ? void 0 : sent.isConnected) || sent.classList.contains(exports.ASK_CLASS)) {
404
+ return (sent === null || sent === void 0 ? void 0 : sent.isConnected) ? sent : undefined;
405
+ }
406
+ const rows = this.thread.children;
407
+ for (let index = rows.length - 1; index >= 0; index--) {
408
+ if ((_a = rows[index].classList) === null || _a === void 0 ? void 0 : _a.contains(exports.ASK_CLASS)) {
409
+ this.sent = rows[index];
410
+ return rows[index];
411
+ }
412
+ }
413
+ return undefined;
414
+ }
387
415
  /** Where the view goes for the message sent to be at its top, with the room under the thread for that. */
388
416
  place(message) {
389
417
  // offsetTop: from the thread; the transform of the message coming in does not count.
@@ -391,6 +419,14 @@ class ConversationScroller {
391
419
  this.makeRoom(room);
392
420
  return top;
393
421
  }
422
+ freeze(on) {
423
+ if (on === this.frozen) {
424
+ return;
425
+ }
426
+ this.frozen = on;
427
+ this.thread.style.height = on ? `${this.thread.offsetHeight}px` : '';
428
+ this.thread.classList.toggle(exports.HELD_CLASS, on);
429
+ }
394
430
  makeRoom(room) {
395
431
  if (room !== this.room) {
396
432
  this.room = room;
@@ -401,6 +437,7 @@ class ConversationScroller {
401
437
  this.heading = undefined;
402
438
  this.following = true;
403
439
  this.top = this.view.scrollTop;
440
+ this.see();
404
441
  }
405
442
  /** The user moves the view: a smooth scroll on its way is theirs now, the message sent no longer holds the top. */
406
443
  byUser() {
@@ -420,7 +457,49 @@ class ConversationScroller {
420
457
  this.remember();
421
458
  }
422
459
  }
460
+ /**
461
+ * To the bottom, following what grew: at once when `now` (the view changed its height) or the view cannot glide;
462
+ * else the row at the top of the view keeps its place (what grew above it is out of sight), and the rest glides.
463
+ */
464
+ follow(now) {
465
+ const { view } = this;
466
+ const seen = this.seen;
467
+ if (now || !this.glider || calm() || !(seen === null || seen === void 0 ? void 0 : seen.row.isConnected)) {
468
+ this.toBottomNow();
469
+ return;
470
+ }
471
+ const bottom = view.scrollHeight - view.clientHeight;
472
+ // Never up: a move up of more than a screen would count as the user's (a search in the page).
473
+ const top = Math.max(seen.row.offsetTop - seen.offset, view.scrollTop, bottom - view.clientHeight * GLIDE_MAX);
474
+ this.moveTo(top);
475
+ this.see();
476
+ if (bottom - view.scrollTop >= 1) {
477
+ this.glide();
478
+ }
479
+ }
480
+ glide() {
481
+ var _a;
482
+ (_a = this.glider) === null || _a === void 0 ? void 0 : _a.start(share => {
483
+ const { view } = this;
484
+ const behind = view.scrollHeight - view.clientHeight - view.scrollTop;
485
+ if (!this.following || this.held || this.chasing || this.heading !== undefined || behind < 1) {
486
+ return false;
487
+ }
488
+ // The last pixel of the way at once: the view lands on the bottom, not short of it.
489
+ const move = Math.max(1, behind * share);
490
+ this.moveTo(behind - move < 1 ? view.scrollHeight - view.clientHeight : view.scrollTop + move);
491
+ this.see();
492
+ return true;
493
+ });
494
+ }
495
+ /** The row at the top of the view now (`seen`). */
496
+ see() {
497
+ const row = conversation_scroll_util_1.ScrollUtil.firstRow(this.thread.children, this.view.scrollTop);
498
+ this.seen = row ? { row, offset: row.offsetTop - this.view.scrollTop } : undefined;
499
+ }
423
500
  toBottomNow() {
501
+ var _a;
502
+ (_a = this.glider) === null || _a === void 0 ? void 0 : _a.stop();
424
503
  const { view } = this;
425
504
  const bottom = view.scrollHeight - view.clientHeight;
426
505
  if (bottom - view.scrollTop >= 1) {
@@ -428,6 +507,7 @@ class ConversationScroller {
428
507
  }
429
508
  this.top = view.scrollTop;
430
509
  this.anchor = undefined;
510
+ this.see();
431
511
  }
432
512
  moveTo(top) {
433
513
  const { view } = this;
@@ -437,29 +517,75 @@ class ConversationScroller {
437
517
  }
438
518
  this.top = view.scrollTop;
439
519
  }
440
- /** The first row in the view, while it does not follow. */
520
+ /** What the user reads, while the view does not follow (ScrollAnchor). */
441
521
  remember() {
442
- var _a, _b;
443
522
  if (this.following) {
444
523
  this.anchor = undefined;
524
+ this.see();
445
525
  return;
446
526
  }
447
- const rows = this.thread.children;
448
- const top = this.view.scrollTop;
449
- let low = 0;
450
- let high = rows.length - 1;
451
- while (low < high) {
452
- const middle = (low + high) >> 1;
453
- const row = rows[middle];
454
- if (row.offsetTop + row.offsetHeight > top) {
455
- high = middle;
527
+ const { view } = this;
528
+ const top = view.scrollTop;
529
+ const row = conversation_scroll_util_1.ScrollUtil.readRow(this.thread.children, top, view.clientHeight);
530
+ if (!row) {
531
+ this.anchor = undefined;
532
+ return;
533
+ }
534
+ // A row taller than the view, begun above it: what of it starts in the view keeps its place, so that what
535
+ // grows in the part of the row above it (a diagram drawn, a part laid out) does not move what is read.
536
+ const part = row.offsetTop < top && isElement(row) ? this.partIn(row) : undefined;
537
+ const at = part ? top + this.offsetOf(part) : row.offsetTop;
538
+ this.anchor = { row, part, offset: at - top, at };
539
+ }
540
+ /** Where the anchor is now, from the top of the thread; undefined once it is gone. */
541
+ anchorAt(anchor) {
542
+ var _a;
543
+ if (((_a = anchor.part) === null || _a === void 0 ? void 0 : _a.isConnected) && anchor.row.isConnected) {
544
+ return this.view.scrollTop + this.offsetOf(anchor.part);
545
+ }
546
+ return anchor.row.isConnected ? anchor.row.offsetTop : undefined;
547
+ }
548
+ /**
549
+ * What moved above the anchor before the view heard of it, kept out of sight. The scroll of a frame comes before
550
+ * the observer of sizes: rows drawn in front of the view meanwhile (earlier messages, a diagram drawn) would
551
+ * else be taken as where the user is, and what they read would go down by all of them.
552
+ */
553
+ keepAnchor() {
554
+ const anchor = this.anchor;
555
+ if (this.following || !anchor || this.toggled || this.heading !== undefined) {
556
+ return;
557
+ }
558
+ const at = this.anchorAt(anchor);
559
+ const drift = at === undefined ? 0 : at - anchor.at;
560
+ if (Math.abs(drift) >= 1) {
561
+ this.view.scrollTop += drift;
562
+ this.top += drift;
563
+ }
564
+ }
565
+ /** The first part of `row` (a row begun above the view) that starts in the view, as deep as it takes to find one. */
566
+ partIn(row) {
567
+ const top = this.view.getBoundingClientRect().top;
568
+ const bottom = top + this.view.clientHeight;
569
+ let node = row;
570
+ for (let depth = 0; depth < PART_DEPTH; depth++) {
571
+ let inside;
572
+ for (const child of node.children) {
573
+ const box = child.getBoundingClientRect();
574
+ if (box.bottom <= top || box.height === 0) {
575
+ continue;
576
+ }
577
+ if (box.top >= top) {
578
+ return box.top < bottom ? child : undefined;
579
+ }
580
+ inside = child;
581
+ break;
456
582
  }
457
- else {
458
- low = middle + 1;
583
+ if (!inside) {
584
+ return undefined;
459
585
  }
586
+ node = inside;
460
587
  }
461
- const row = ((_b = (_a = rows[low]) === null || _a === void 0 ? void 0 : _a.dataset) === null || _b === void 0 ? void 0 : _b.scrollSkip) !== undefined && low + 1 < rows.length ? rows[low + 1] : rows[low];
462
- this.anchor = row ? { row, offset: row.offsetTop - top } : undefined;
588
+ return undefined;
463
589
  }
464
590
  offsetOf(element) {
465
591
  return element.getBoundingClientRect().top - this.view.getBoundingClientRect().top;
@@ -473,99 +599,4 @@ class ConversationScroller {
473
599
  }
474
600
  exports.ConversationScroller = ConversationScroller;
475
601
  ConversationScroller.views = new WeakMap();
476
- /**
477
- * The scrolling of a conversation (ConversationScroller), whose thread is the first child of the element of the
478
- * returned ref. Opened, and when messages of the user go (a rewind), the view goes to the bottom.
479
- *
480
- * `asked`: how many messages of the user there are; the thread marks them with ASK_CLASS.
481
- */
482
- function useConversationScroll(asked, options = {}) {
483
- const { sentTo = 'top', key } = options;
484
- const ref = React.useRef(null);
485
- const attached = React.useRef(undefined);
486
- const before = React.useRef(undefined);
487
- // After each render, the view may only now be there (a page that shows it once its data came).
488
- React.useLayoutEffect(() => {
489
- var _a, _b;
490
- const view = ref.current;
491
- const thread = view === null || view === void 0 ? void 0 : view.firstElementChild;
492
- if (((_a = attached.current) === null || _a === void 0 ? void 0 : _a.view) === view) {
493
- return;
494
- }
495
- (_b = attached.current) === null || _b === void 0 ? void 0 : _b.detach();
496
- attached.current = undefined;
497
- if (view && thread instanceof HTMLElement) {
498
- const scroller = new ConversationScroller(view, thread);
499
- attached.current = { view, scroller, detach: scroller.attach(view, thread) };
500
- }
501
- });
502
- React.useLayoutEffect(() => () => {
503
- var _a;
504
- (_a = attached.current) === null || _a === void 0 ? void 0 : _a.detach();
505
- attached.current = undefined;
506
- }, []);
507
- React.useLayoutEffect(() => {
508
- var _a, _b;
509
- const previous = before.current;
510
- before.current = { asked, key };
511
- const current = (_a = attached.current) === null || _a === void 0 ? void 0 : _a.scroller;
512
- const thread = (_b = ref.current) === null || _b === void 0 ? void 0 : _b.firstElementChild;
513
- if (!current || !thread) {
514
- return;
515
- }
516
- // One more: sent now. More at once is the conversation loaded again, which opens at its bottom.
517
- const sent = previous !== undefined && previous.key === key && asked === previous.asked + 1;
518
- const asks = sent && sentTo === 'top' ? thread.getElementsByClassName(exports.ASK_CLASS) : undefined;
519
- const message = asks === null || asks === void 0 ? void 0 : asks[asks.length - 1];
520
- if (message) {
521
- current.send(message);
522
- }
523
- else {
524
- current.reset();
525
- }
526
- }, [asked, key, sentTo]);
527
- return ref;
528
- }
529
- /** Away from the bottom by more than half of the view: the button back to the latest shows. */
530
- const AWAY_SHARE = 0.5;
531
- /** Lower than this (a phone held sideways, its keyboard open) the view has no room for the button. */
532
- const AWAY_MIN_PX = 240;
533
- /** Whether the conversation of `ref` is scrolled up from its latest, and a way back to it. */
534
- function useAwayFromBottom(ref) {
535
- const [away, setAway] = React.useState(false);
536
- React.useEffect(() => {
537
- const element = ref.current;
538
- if (!element) {
539
- return;
540
- }
541
- let frame = 0;
542
- const measure = () => {
543
- cancelAnimationFrame(frame);
544
- frame = requestAnimationFrame(() => {
545
- const { scrollHeight, scrollTop, clientHeight } = element;
546
- setAway(clientHeight >= AWAY_MIN_PX && scrollHeight - scrollTop - clientHeight > clientHeight * AWAY_SHARE);
547
- });
548
- };
549
- element.addEventListener('scroll', measure, { passive: true });
550
- // The keyboard and a turn of the phone change the height of the view, not where it is.
551
- const observer = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(measure) : undefined;
552
- observer === null || observer === void 0 ? void 0 : observer.observe(element);
553
- return () => {
554
- cancelAnimationFrame(frame);
555
- observer === null || observer === void 0 ? void 0 : observer.disconnect();
556
- element.removeEventListener('scroll', measure);
557
- };
558
- }, [ref]);
559
- const back = React.useCallback(() => {
560
- const element = ref.current;
561
- const scroller = element ? ConversationScroller.of(element) : undefined;
562
- if (scroller) {
563
- scroller.toBottom();
564
- }
565
- else {
566
- element === null || element === void 0 ? void 0 : element.scrollTo({ top: element.scrollHeight, behavior: calm() ? 'auto' : 'smooth' });
567
- }
568
- }, [ref]);
569
- return [away, back];
570
- }
571
602
  //# sourceMappingURL=conversation-scroll.js.map
@@ -63,12 +63,16 @@ function DiscoverView({ pages, onOpenPages, onOpen, onPin, onSettings, onScan, l
63
63
  pages.map(page => {
64
64
  var _a;
65
65
  const title = web_extension_protocol_1.WebLabelUtil.text(page.title);
66
+ const Mark = page.mark;
66
67
  return (React.createElement(list_rows_1.ListRow, { key: page.id, icon: (_a = page.icon) !== null && _a !== void 0 ? _a : lucide_react_1.PanelTop, label: title, onClick: () => onOpen(page.id), onContextMenu: event => openMenu(event, [
67
68
  { label: t('ta.nav.open'), run: () => onOpen(page.id) },
68
69
  { label: t('ta.nav.pin'), run: () => onPin(page.id) },
69
70
  '-',
70
71
  { label: t('ta.nav.settings'), run: onSettings },
71
- ]), trailing: React.createElement(icon_1.IconButton, { icon: lucide_react_1.Pin, label: `${t('ta.nav.pin')} · ${title}`, className: "ta-list-trailing", onClick: () => onPin(page.id) }) }));
72
+ ]), trailing: React.createElement(React.Fragment, null,
73
+ Mark && (React.createElement("span", { className: "ta-list-mark" },
74
+ React.createElement(Mark, null))),
75
+ React.createElement(icon_1.IconButton, { icon: lucide_react_1.Pin, label: `${t('ta.nav.pin')} · ${title}`, className: "ta-list-trailing", onClick: () => onPin(page.id) })) }));
72
76
  }),
73
77
  onOpenPages.map(page => { var _a; return (React.createElement(list_rows_1.ListRow, { key: page.id, icon: (_a = page.icon) !== null && _a !== void 0 ? _a : lucide_react_1.PanelTop, label: page.title, onClick: () => onOpen(page.id), onContextMenu: event => openMenu(event, [
74
78
  { label: t('ta.nav.open'), run: () => onOpen(page.id) },
@@ -1,6 +1,9 @@
1
1
  import type { SessionMessage, SessionState, SessionStore } from '@celljs/ta-client';
2
2
  import * as React from 'react';
3
- /** How many rows of a conversation are drawn when it shows (from its end), and how many more each time the view nears the top of them. */
3
+ /**
4
+ * How many rows of a conversation are drawn when it shows (from its end), and how many more each time the view nears
5
+ * the top of them: a few at a time, each in a frame of its own, for a fling through them not to stutter.
6
+ */
4
7
  export declare const ROW_WINDOW: {
5
8
  first: number;
6
9
  more: number;
@@ -46,12 +49,16 @@ export declare namespace EarlierUtil {
46
49
  * How many messages were asked, so that earlier ones loaded in front do not count as sent: the view
47
50
  * goes to a message sent, and to the bottom of a conversation loaded again.
48
51
  */
49
- function asked(messages: readonly SessionMessage[], start: number, isAsk: (message: SessionMessage) => boolean, previous?: AskedCount): AskedCount & {
52
+ function asked(messages: readonly SessionMessage[], start: number, isAsk: AskTest, previous?: AskedCount): AskedCount & {
50
53
  count: number;
51
54
  };
52
55
  }
56
+ /** Whether the message at `index` of `messages` is one the user asked: a row of its own, where the view goes when sent. */
57
+ export type AskTest = (message: SessionMessage, index: number, messages: readonly SessionMessage[]) => boolean;
58
+ /** A message of the user, not one given to the agent on the way (ProcessUtil.steered), which is a step of its turn. */
59
+ export declare const isAsk: AskTest;
53
60
  /** EarlierUtil.asked for a view: `isAsk` should be the same function each render. */
54
- export declare function useAsked(state: SessionState, isAsk?: (message: SessionMessage) => boolean): number;
61
+ export declare function useAsked(state: SessionState, test?: AskTest): number;
55
62
  export declare function useRowWindow(): RowWindow;
56
63
  /**
57
64
  * The earlier messages of a long conversation, loaded as the view of `ref` nears the top of its thread
@@ -33,15 +33,19 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.EarlierUtil = exports.ROW_WINDOW = void 0;
36
+ exports.isAsk = exports.EarlierUtil = exports.ROW_WINDOW = void 0;
37
37
  exports.useAsked = useAsked;
38
38
  exports.useRowWindow = useRowWindow;
39
39
  exports.useEarlierMessages = useEarlierMessages;
40
40
  const React = __importStar(require("react"));
41
+ const process_1 = require("../util/process");
41
42
  /** Closer than this many heights of the view to the top of the thread, the earlier messages load. */
42
- const NEAR_TOP = 1.5;
43
- /** How many rows of a conversation are drawn when it shows (from its end), and how many more each time the view nears the top of them. */
44
- exports.ROW_WINDOW = { first: 12, more: 24 };
43
+ const NEAR_TOP = 2;
44
+ /**
45
+ * How many rows of a conversation are drawn when it shows (from its end), and how many more each time the view nears
46
+ * the top of them: a few at a time, each in a frame of its own, for a fling through them not to stutter.
47
+ */
48
+ exports.ROW_WINDOW = { first: 12, more: 8 };
45
49
  var EarlierUtil;
46
50
  (function (EarlierUtil) {
47
51
  /**
@@ -76,15 +80,17 @@ var EarlierUtil;
76
80
  }
77
81
  EarlierUtil.asked = asked;
78
82
  })(EarlierUtil || (exports.EarlierUtil = EarlierUtil = {}));
79
- const isUser = (message) => message.role === 'user';
83
+ /** A message of the user, not one given to the agent on the way (ProcessUtil.steered), which is a step of its turn. */
84
+ const isAsk = (message, index, messages) => message.role === 'user' && !process_1.ProcessUtil.steered(messages, index);
85
+ exports.isAsk = isAsk;
80
86
  /** EarlierUtil.asked for a view: `isAsk` should be the same function each render. */
81
- function useAsked(state, isAsk = isUser) {
87
+ function useAsked(state, test = exports.isAsk) {
82
88
  const previous = React.useRef(undefined);
83
89
  return React.useMemo(() => {
84
- const next = EarlierUtil.asked(state.messages, state.start, isAsk, previous.current);
90
+ const next = EarlierUtil.asked(state.messages, state.start, test, previous.current);
85
91
  previous.current = next;
86
92
  return next.count;
87
- }, [state.messages, state.start, isAsk]);
93
+ }, [state.messages, state.start, test]);
88
94
  }
89
95
  function useRowWindow() {
90
96
  const [rows, setRows] = React.useState(exports.ROW_WINDOW.first);
@@ -95,7 +101,8 @@ function useRowWindow() {
95
101
  }
96
102
  // Not again before the list drew them.
97
103
  hidden.current = 0;
98
- setRows(count => count + exports.ROW_WINDOW.more);
104
+ // Drawn as the page has time, not in the frame of a scroll.
105
+ React.startTransition(() => setRows(count => count + exports.ROW_WINDOW.more));
99
106
  return true;
100
107
  }, []);
101
108
  return React.useMemo(() => ({ rows, hidden, more }), [rows, more]);