@micha.bigler/ui-core-micha 4.27.0 → 4.27.1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.27.1 - UCM-CHAT-14 follow-up
4
+
5
+ The thread's bottom pin no longer depends on scroll events: switching chats re-pins explicitly, and the thread also
6
+ observes its own scroll region, so a chat mounted in a hidden host panel goes to the bottom when the panel is shown.
7
+ Found in the Maana staging acceptance of 4.27.0 (thread opened far above the bottom after mounting in a not-yet-shown
8
+ tab, and after switching chats).
9
+
3
10
  ## 4.27.0 - UCM-CHAT-14
4
11
 
5
12
  Typing in a long chat relayouts only the composer. The thread's scroll region and the wide side panel are CSS
@@ -52,7 +52,8 @@ export function ChatThread({ turns = [], tool = null, notice = null, hasOlder =
52
52
  useEffect(() => { var _a, _b; if (pinned.current)
53
53
  (_b = (_a = end.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView) === null || _b === void 0 ? void 0 : _b.call(_a, { block: 'end' }); }, [last === null || last === void 0 ? void 0 : last.id, last === null || last === void 0 ? void 0 : last.assistant_text, last === null || last === void 0 ? void 0 : last.state]);
54
54
  // Turns skip layout off-screen (content-visibility, UCM-CHAT-14) and take their real height only once rendered, so the
55
- // content can still grow after the scroll above. While pinned, follow that growth to stay at the bottom.
55
+ // content can still grow after the scroll above. While pinned, follow that growth to stay at the bottom. The scroll
56
+ // region itself is observed too: a thread mounted in a hidden host panel gets its real size only when shown.
56
57
  const content = useRef(null);
57
58
  useEffect(() => {
58
59
  const el = scroller.current;
@@ -61,8 +62,12 @@ export function ChatThread({ turns = [], tool = null, notice = null, hasOlder =
61
62
  const observer = new ResizeObserver(() => { if (pinned.current)
62
63
  el.scrollTop = el.scrollHeight; });
63
64
  observer.observe(content.current);
65
+ observer.observe(el);
64
66
  return () => observer.disconnect();
65
67
  }, []);
68
+ // Another chat opens at its bottom, whatever the reader did in the previous one; do not rely on the scroll event that
69
+ // emptying the thread may (or, in a background page, may not) produce.
70
+ useLayoutEffect(() => { pinned.current = true; }, [chat === null || chat === void 0 ? void 0 : chat.id]);
66
71
  // Keep the reader's position when older turns are prepended.
67
72
  useLayoutEffect(() => {
68
73
  const el = scroller.current;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micha.bigler/ui-core-micha",
3
- "version": "4.27.0",
3
+ "version": "4.27.1",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "exports": {