fix(sidebar): don't scroll on same-session re-focus — track lastScrolledPath - #877
Merged
Merged
Conversation
…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.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
scrollIntoViewto 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
applyActiveProjectnow tracks alastScrolledPathvariable. 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 oflastScrolledPath.lastScrolledPathis cleared when the active project is set to null so subsequent re-activation scrolls correctly.Behavior
expandexpandexpandresetnoneTests
3 new tests covering the three invariants. 2876 pass, 0 fail.