mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
The `/agents` transcript used `flex-col-reverse` for bottom-anchored chat layout, where `scrollTop = 0` means bottom and the sign of `scrollTop` when scrolled up varies by browser engine. A `ResizeObserver` detected content height changes and applied manual `compensateScroll(delta)` to preserve position, which fought manual upward scrolling during streaming — repeatedly adjusting the user's scroll position when they were trying to read earlier content. This replaces that model with normal DOM order (`flex-col`, standard `overflow-y: auto`) and a dedicated `useAgentTranscriptAutoScroll` hook that only auto-scrolls when follow-mode is enabled. When the user scrolls up, follow-mode disables and incoming content does not move the viewport. Changes: - **New**: `useAgentTranscriptAutoScroll.ts` — local hook with follow-mode state, RAF-throttled button visibility, dual `ResizeObserver` (content + container), and `jumpToBottom()` - **Modified**: `AgentDetailView.tsx` — removed `ScrollAnchoredContainer` (~350 lines of reverse-layout compensation), replaced with normal-order container wired to the new hook, added pagination prepend scroll restoration - **Modified**: `AgentDetailView.stories.tsx` — updated scroll stories for normal-order bottom-distance assertions