Fix hunkless file selection in all-files diff - #15325
Merged
Merged
Conversation
Repro: select a commit, wait for its details, then select a non-first hunkless uncommitted file; the diff stays on the first file.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes incorrect file targeting/scroll behavior in the Lite workspace “all-files” diff view when selecting uncommitted files that have no hunks (e.g., binary files), preventing the selection from snapping back to a previously active file and avoiding stale-view scroll warnings during deferred Details transitions.
Changes:
- Ensure initial diff scroll targets the active file’s item ID when the active file is hunkless (instead of using a resolved hunk from another file).
- Avoid calling
scrollToon a CodeView instance that does not contain the selected file during deferred Details transitions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| apps/lite/ui/src/routes/project/$id/workspace/WorkspacePage.tsx | Adds a guard to skip scrolling when the current viewer instance doesn’t contain the selected file item. |
| apps/lite/ui/src/routes/project/$id/workspace/Details.tsx | Threads activeFileItemId through and uses it to pick the initial scroll target when the active file has no hunks. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
395
to
+399
| didScrollToViaFileRef.current = true; | ||
| viewerRef.current?.scrollTo({ | ||
| const viewer = viewerRef.current?.getInstance(); | ||
| // Details selection is deferred, so the ref may still point at a viewer without this file. | ||
| if (!viewer?.getItem(itemId)) return; | ||
|
|
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.
What changed
Why
Selecting a binary or otherwise hunkless uncommitted file could resolve a hunk from the previously active file. During the deferred Details transition, WorkspacePage could also call scrollTo on the outgoing CodeView, producing an unknown-item warning and leaving the new file off-screen.
User impact
Hunkless files now open at the correct position in the all-files diff, and the stale CodeView warning is avoided without allowing file selection to bounce back.
Validation