Skip to content

Review: the file list stays put when you open a file - #2817

Merged
backnotprop merged 6 commits into
mainfrom
fix/review-file-list-stays-put
Nov 7, 2026
Merged

backnotprop merged 6 commits into
mainfrom
fix/review-file-list-stays-put

Conversation

@backnotprop

Copy link
Copy Markdown
Owner

Fixes #2713. Thank you @barreiroleo for the report, and for the two screenshots with the pointer in the same place. They showed exactly where to look.

What was wrong

I reproduced both causes in headless Chromium against the built review page, before and after the change, at the issue's window size of 1274×1185. A small one-off server sent the page the real git diff of a scratch repo shaped like the one in the issue: 15 changed files in nested folders. My sandbox could not start the plannotator binary itself, but the bug is all in page layout. The new e2e spec runs the real binary in CI.

1. The All changes list (the one in the issue's screenshots). With every file folded, opening one pushed every header down. Over 11 runs the rows above the opened file moved 8–25 px (the amount includes a random jitter from Pierre). In one 19 px run, the pointer that had been on service.hpp ended up on operation.hpp, so the next click opened the wrong file. A gap opened above the first header, as in the second screenshot.

The cause: Pierre's layout estimate counts an 8 px gap around each hunk separator, but our theme CSS never draws that gap (the separator's own 4 px margins replace it). So an open file was laid out taller than it is drawn: 637 px estimated against 589 px drawn for a file with three hunks. Pierre keeps its rendered window in a position: sticky box. When the list is shorter than the view, that box sits at the bottom of the extra room, which pushes the whole list down. The page-scrolling view (Guided Reviews in the Inbox) already counted no gap. The normal review view did not.

2. The file tree with Hide viewed on. Opening a file auto-marks the one you left as viewed. With Hide viewed on, that row disappeared at once and the rows under it moved up 28 px. Clicking operation.hpp and then service.hpp left the pointer on the src/transport folder row. Scrolled to the bottom, the next click hit CMakeLists.txt instead of operation.hpp.

With Hide viewed off, the file tree never moved: 0 px in every case I tried (top and bottom of the list, a folder with one file, a tall and a short window). The sticky tools block stayed 64 px tall and the "N of 15 viewed" line stayed 18 px tall. The list did not re-sort, and its width did not change, so no scrollbar appeared or disappeared.

The fix

  • AllFilesCodeView.tsx: count no gap around separators in every mode (spacing: 0, keeping the 8 px under the last row), as the page-scrolling view already did. Pierre's estimate now matches what is drawn.
  • useHiddenViewedFiles (new, used by FileTree and SectionsPanel): while the pointer is in the panel, Hide viewed hides only what was already viewed when the pointer came in. A file that becomes viewed meanwhile keeps its row until the pointer leaves the panel. Turning Hide viewed on still hides everything viewed at once.

Before and after

The same script, the same clicks:

Case Before After
All changes, all folded, open the 13th file (10 runs before, 8 after) rows move 8–25 px 0 px
All changes, then open the 2nd file rows move 8–25 px 0 px
File tree, Hide viewed on, click the next file rows move 28 px, pointer on another row 0 px, pointer on the clicked row
File tree, Hide viewed on, pointer leaves the panel — viewed rows go (25 → 22 rows)
File tree, Hide viewed off (all cases) 0 px 0 px

The before and after stills, with the pointer drawn in, are with the owner.

Tests

  • useHiddenViewedFiles.test.ts: what Hide viewed hides while the pointer is in the list and after it leaves.
  • tests/e2e/review-file-list-stays-put.spec.ts: both cases in a real browser against the compiled binary. I left it to CI. I ran the same checks as a one-off script against the old and new builds: both fail on the old build and pass on the new one.
  • These existing DOM tests pass, run one file at a time: FileTree.*, FileTreeNode.controls, PanelChrome, and the AllFilesCodeView.* files.

Pierre counted an 8px gap around every hunk separator that our theme CSS
never draws (the separator's own 4px margins replace it), so an open file
was laid out 48px taller than drawn. Pierre's sticky window then sat at
the bottom of that room: in a list that just outgrows the view, every
header moved 9-25px down under the pointer and the next click opened
another file (#2713). Count no gap in every mode, as the page-scrolling
view already did.
…e list

Opening a file auto-marks the one you left as viewed. With Hide viewed on,
that row went at once and the rows under it moved 28px under the pointer.
While the pointer is in the panel, hide only what was viewed when it came
in; the rest goes when it leaves (#2713).
With the mouse resting over the panel, files viewed by j/k, the arrows,
Home/End or Cmd+P kept their rows until the mouse left, so a keyboard user
saw Hide viewed do nothing. A key press in the panel now releases the hold;
the pointer's next move takes it again. With Hide viewed off the hook keeps
no hold, so crossing the panel edge no longer redraws the list. DOM tests
for the hook: enter/leave, the keyboard release, the toggle, the off case.
@backnotprop backnotprop added the ci:full Run the heavy CI tier on this PR (added by the merge script) label Nov 6, 2026
On a live checkout the header's last button is "Choose app to open in",
not "File actions", so the spec found no headers and timed out waiting
for 15. Key each header by its path span (title), which every mode draws,
and click the path itself.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:full Run the heavy CI tier on this PR (added by the merge script)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[UI Bug] Plannotator vertical spacing changes when expanding a file diff

1 participant