git clone https://garage44.eu/jeroen/midas.gitcartopolis-agent · 2026-11-24T20:57:43Z
fix(web): a session opens at the end of its conversation Its log comes over the socket after the page is drawn, and the first growth glided down from the top: a long session opened at its start and slid through all of it to the end. For a moment after opening, and a little longer for each growth then (pictures loading), the end is now set at once rather than glided to; the person's own scroll, touch or key ends that, and what arrives after glides as before. Checked on the docs/screens stand-in hub, with the log of 81 messages sent 600 ms after the page asked to follow it, at 390x844: before, scrollTop was 0 when it came and reached the end ~0.6 s later; now it is at the end (9539 of 9539) at the first sample after it came.
web/src/components/sessions.tsx | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/web/src/components/sessions.tsx b/web/src/components/sessions.tsx
index 163baff..cd6a909 100644
--- a/web/src/components/sessions.tsx
+++ b/web/src/components/sessions.tsx
@@ -937,9 +937,26 @@ const draft = local({text: ''})
/** Follow the conversation down as it grows, unless the person scrolled up to read. */
let pinned = true
+/**
+ * Until when, just opened, the conversation is put at its end at once as it grows rather
+ * than glided to: its log comes over the socket after the page is drawn, and pictures
+ * load after that, so gliding opened a long session at its top and slid all the way
+ * down. Each growth meanwhile holds it a little longer; the person's own hand ends it.
+ */
+let landing = 0
+const LANDING = 1500
+const LANDING_MAX = 8000
+let openedAt = 0
+const landed = () => (landing = 0)
+const HANDS = ['wheel', 'touchstart', 'pointerdown', 'keydown'] as const
+
/** The Shell's content column scrolls, not the log: that is what follows the conversation down. */
const followDown = {
oncreate: (v: m.VnodeDOM) => {
+ openedAt = performance.now()
+ landing = openedAt + LANDING
+ const el = (v.dom as HTMLElement).closest('.m-shell__content')
+ for (const h of HANDS) el?.addEventListener(h, landed, {passive: true})
// Opened, it is at its end at once: only what arrives after glides.
stick(v.dom as HTMLElement, true)
// A picture or a film grows the log after it is drawn: follow that too.
@@ -955,6 +972,9 @@ const followDown = {
},
onremove: (v: m.VnodeDOM) => {
;(v.dom as HTMLElement & {watch?: ResizeObserver}).watch?.disconnect()
+ const el = (v.dom as HTMLElement).closest('.m-shell__content')
+ for (const h of HANDS) el?.removeEventListener(h, landed)
+ landing = 0
// Its blocks left the page with it: drawn again from nothing when it comes back.
drawn.session = ''
},
@@ -999,7 +1019,9 @@ function glideDown(el: HTMLElement) {
/** A block that grew by itself (Typed pacing a reply in), with no redraw of the page: followed down as `stick` would. */
function following(dom: HTMLElement) {
const el = dom.closest('.m-shell__content') as HTMLElement | null
- if (el && pinned && !reduced()) glideDown(el)
+ if (!el || !pinned) return
+ if (reduced() || performance.now() < landing) el.scrollTop = el.scrollHeight
+ else glideDown(el)
}
function stick(dom: HTMLElement, at = false) {
@@ -1026,6 +1048,11 @@ function stick(dom: HTMLElement, at = false) {
}
}
if (!pinned) return
+ const now = performance.now()
+ if (now < landing) {
+ if (grew) landing = Math.min(openedAt + LANDING_MAX, now + LANDING)
+ at = true
+ }
if (at || reduced()) el.scrollTop = el.scrollHeight
else glideDown(el)
}