Skip to content

fix(sidebar): don't scroll on same-session re-focus — track lastScrolledPath - #877

Merged
jeonghun-jj-lee merged 1 commit into
mainfrom
fix/sidebar-scroll-on-tab-switch
Sep 7, 2026
Merged

fix(sidebar): don't scroll on same-session re-focus — track lastScrolledPath#877
jeonghun-jj-lee merged 1 commit into
mainfrom
fix/sidebar-scroll-on-tab-switch

Conversation

@jeonghun-jj-lee

Copy link
Copy Markdown
Contributor

Problem

The sidebar file explorer jumps to the active session's project folder every time the chat panel regains focus — even when the user is browsing a different repo. This was a regression from #841, which added scrollIntoView to the "expand" mode path (used by tab switches and session re-focus).

The original fix in #673 (1155e30b) had the right intent: session switches should highlight without scrolling. #841 reintroduced the jump by adding scroll-into-view for both "expand" and "reset" modes, and #870 fixed timing issues but kept the scroll.

Fix

applyActiveProject now tracks a lastScrolledPath variable. For "expand" mode (tab switch / session re-focus), the scroll + section-auto-expand block is skipped when the path hasn't changed — re-focusing the same session no longer yanks the viewport. When the path does change (switching to a different session), it scrolls as expected.

"reset" mode (explicit dropdown selection) always scrolls regardless of lastScrolledPath. lastScrolledPath is cleared when the active project is set to null so subsequent re-activation scrolls correctly.

Behavior

Scenario Mode Path changed? Scrolls?
Click back into same session from sidebar expand No No
Switch to a different session tab expand Yes Yes
Open a session from the session dropdown expand Yes Yes
Pick a project from composer dropdown reset Either Always
Orphan / replay none Either Never

Tests

3 new tests covering the three invariants. 2876 pass, 0 fail.

…ledPath (#841 regression)

Tab switches (mode="expand") now only scroll the sidebar when the active
project path actually changed. Re-focusing the same session — e.g. clicking
back into the chat from the sidebar — no longer yanks the scroll position.

The mechanism: applyActiveProject tracks lastScrolledPath. For "expand"
mode, the scroll + section-auto-expand block is skipped when activePath
matches. For "reset" mode (explicit dropdown selection), the scroll always
fires regardless. lastScrolledPath is cleared when the active project is
set to null so subsequent re-activation scrolls correctly.

3 new tests covering the three invariants: same-path expand skips,
different-path expand scrolls, reset always scrolls. 2876 pass, 0 fail.
@jeonghun-jj-lee
jeonghun-jj-lee merged commit 0aab10c into main Sep 7, 2026
9 of 10 checks passed
@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 550aaeed-15fe-49e9-84c3-9c96a118fb34


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jeonghun-jj-lee
jeonghun-jj-lee deleted the fix/sidebar-scroll-on-tab-switch branch September 7, 2026 06:17
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.

1 participant