Fix chat autoscroll jitter and inner scroll during streaming (Excel add-in)
Session from pi-for-excel-sessions on Hugging Face by thomasmustier · MIT · condensed by Coders Talk
Diagnose and fix jittery autoscroll in the Pi for Excel sidebar during streaming, then extend auto-follow behaviour to expanded thinking/tool blocks so users don't have to manually scroll to keep up with streamed content.
- +0Prompt · +0When streaming, new rows appearing cause the view to jerk up then down. Also the last line during streaming is partly hidden above the input box — please investigate.
- +0mAgent did · +0mTraced autoscroll logic in pi-sidebar.ts/tabs.css: it watched content height (.pi-messages__inner) but not viewport height (.pi-messages), causing jitter when footer widgets resized the viewport. Fixed by observing both.
- +11mPrompt · +11mYes please tune the auto-follow disengage/re-engage thresholds, then open a PR following the poll-review-merge process, and refactor if there's a better approach.
- +11mAgent did · +11mCreated an isolated worktree, tuned disengage/re-engage thresholds (50px/10px → 32px/20px), added shared scroll-to-bottom helpers, opened PR #397, waited on Codex review, merged after checks passed, cleaned up worktree.
- +54mPrompt · +54mInside thinking and tool blocks, we should think about good UX/consistent behaviour — currently opening a thinking or tool block during streaming never follows the stream.
- +54mAgent did · +54mDiagnosed capped-height inner scroll areas (thinking-block markdown-block, .pi-tool-card__body--open) that don't auto-follow. Implemented an rAF loop with a distance-from-bottom heuristic to auto-scroll expanded inner panes, opened PR #401, merged after CI passed.
- +1h 34mFail · +1h 34mDeveloper reported the fix doesn't actually work: if the thinking block is expanded when streaming starts, it doesn't follow down.
- +1h 35mAgent did · +1h 35mRoot-caused the distance heuristic: token batches could grow >30px per frame, wrongly triggering the 'user scrolled up' disengage logic. Reworked to per-element scroll listeners that only detach on real scroll events, applied it live on main, then discussed holistic UX for outer vs inner scroll coupling.
- +1h 49mPrompt · +1h 49mPlease write up a GitHub issue with full context on the inner-scroll UX problem and design thinking.
- +1h 49mAgent did · +1h 49mFiled issue #406, then implemented it in a fresh worktree by porting the scroll-listener approach onto main, opened PR #408, addressed a Codex review comment about listener registry reset, resolved a merge conflict via rebase, resolved a review thread blocking merge, and merged as commit a30f00d.
- +2h 3mOutcome · +2h 3m3 PRs merged (#397, #401, #408) plus issue #406 documenting the UX design; final scroll-listener based inner auto-follow fix landed on main.
Next time I'd ask for the holistic design pass (outer vs inner scroll UX) up front instead of shipping a quick distance-heuristic fix first — that first attempt (#401) looked fine in CI but didn't actually work in practice, and I only caught it by testing manually. The fix that actually worked was switching from a distance-from-bottom heuristic to real per-element scroll listeners, which is what should have been done from the start.