Skip to content

fix(ui): prevent snap-to-bottom and flickering during upward session scroll - #13009

Merged
marius-kilocode merged 2 commits into
mainfrom
fix-agent-manager-scroll-flicker
Aug 7, 2026
Merged

fix(ui): prevent snap-to-bottom and flickering during upward session scroll#13009
marius-kilocode merged 2 commits into
mainfrom
fix-agent-manager-scroll-flicker

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

Problem

When scrolling up in an idle Agent Manager or chat transcript, resizing virtualized elements triggers onContentResize in createAutoScroll. When the session is inactive, this callback was unconditionally invoking scrollToBottom, forcibly snapping the viewport back to the bottom and fighting upward scroll gestures. In addition, wheel gestures did not mark user activity on the scroll tracker, causing debounced scroll handlers to misclassify user scrolls, and overflow-anchor: auto on the scroll container clashed with Virtua's virtualized scroll offset compensation.

Solution

  • Auto-scroll resize guard: onContentResize now checks !userActivity.isRecent() before pinning to the bottom when inactive, allowing upward scroll gestures to proceed without interruption.
  • Scroll handler fallback: Replaced the immediate bottom() snap in handleScroll for unclassified scroll shifts with a debounced pause.
  • Wheel activity tracking: createUserActivity now invokes mark() on all scrollable wheel inputs (both directions) to keep the recent interaction state accurate.
  • Scroll anchoring: Configured overflowAnchor: "none" on the message list scroll container to avoid competing browser-native anchor adjustments during virtual list DOM recycling.
  • Unit tests: Added coverage for idle upward scrolling, content resizing, and scrollbar drag interactions.

Comment thread packages/kilo-ui/src/hooks/create-auto-scroll.tsx
@kilo-code-bot

kilo-code-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0

Incremental review of f1e5ed3: the debounced stopTimer was removed from handleScroll, which now pauses follow immediately once a scroll leaves the bottom threshold. The simplification is consistent — programmatic scrolls (bottom(), Virtua offset compensation, viewport clamping) land at ~0px from bottom so they don't trip the immediate pause, and pause() already no-ops when the user has scrolled. The removed timer's cleanup was removed with it; no new timers, listeners, or subscriptions are introduced, so no memory-leak concerns. The previously reported nested-scroll regression is unchanged and still open (existing inline comment, now at line 112).

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
packages/kilo-ui/src/hooks/create-auto-scroll.tsx 112 Nested-scroll wheel-up now pauses outer auto-follow — the upstream data-scrollable guard (present in packages/ui/src/hooks/create-auto-scroll.tsx) is missing from this variant, so wheeling up inside tool-output/code blocks stops transcript auto-follow while streaming
Files Reviewed (4 files)
  • .changeset/fix-session-scroll-flicker.md - no issues (user-facing changeset present)
  • packages/kilo-ui/src/hooks/create-auto-scroll.tsx - 1 issue (carried, re-verified at HEAD; incremental debounce removal reviewed — no new issues)
  • packages/kilo-ui/src/hooks/scroll-user-activity.ts - no new issues (unchanged since previous review; wheel handling feeds the finding above)
  • packages/kilo-ui/src/hooks/create-auto-scroll.test.tsx - no issues (unchanged since previous review; tests cover idle upward scroll, resize, scrollbar drag)
Previous Review Summary (commit c514c08)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit c514c08)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0

The scroll-flicker fix itself (resize guard, debounced pause, wheel activity tracking) is sound and well-tested. One behavioral regression risk remains around nested scrollable regions in the chat transcript.

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
packages/kilo-ui/src/hooks/create-auto-scroll.tsx 129 Nested-scroll wheel-up now pauses outer auto-follow — the upstream data-scrollable guard (present in packages/ui/src/hooks/create-auto-scroll.tsx) is missing from this variant, so wheeling up inside tool-output/code blocks stops transcript auto-follow while streaming
Files Reviewed (4 files)
  • .changeset/fix-session-scroll-flicker.md - no issues (user-facing changeset present)
  • packages/kilo-ui/src/hooks/create-auto-scroll.tsx - 1 issue
  • packages/kilo-ui/src/hooks/scroll-user-activity.ts - no issues (change reviewed; feeds the finding above)
  • packages/kilo-ui/src/hooks/create-auto-scroll.test.tsx - no issues (tests cover idle upward scroll, resize, scrollbar drag; no memory leaks — timers cleaned up in onCleanup)

Reviewed by kimi-k3 · Input: 25.4K · Output: 5.8K · Cached: 28K

Review guidance: REVIEW.md from base branch main

@marius-kilocode
marius-kilocode merged commit bfb1237 into main Aug 7, 2026
42 of 44 checks passed
@marius-kilocode
marius-kilocode deleted the fix-agent-manager-scroll-flicker branch August 7, 2026 16:57
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
…oll-flicker

fix(ui): prevent snap-to-bottom and flickering during upward session scroll
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants