Skip to content

feat(review): a file list that fits its names, with filters by name, kind and viewed - #189

Merged
backnotprop merged 3 commits into
mainfrom
feat/review-file-tree
Nov 23, 2026
Merged

backnotprop merged 3 commits into
mainfrom
feat/review-file-tree

Conversation

@backnotprop

@backnotprop backnotprop commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Why

In code review the file list cut most names short and left a lot of empty space on the left. It was the diff viewer's built-in list (diffs-rs src/app/sidebar.rs): a fixed 32 columns, a 2-column gutter, 2 columns of indent a level, a summary of up to 16 columns and a badge column. That left 10 to 18 columns for a name, and names were cut at the end, so the extension went first. The list needed 97 columns, so at 100 columns beside the notes there was no list.

What

The review draws its own list and hides the viewer's (SidebarPreference::Hide). The code is in crates/plannotator-tui/src/review/files/.

  • Rows: a chain of folders that each hold one folder is one row (plannotator-tui/src/). Folders come before files and sort without regard to case, as in Plannotator's diffFileTree.ts. The diff shows the files in the same order, so the list and n/N agree.
  • Width: as wide as the rows need, up to two fifths of the room. The diff keeps at least 48 columns. </> (narrow-files/widen-files) change the width by 4 columns. When there is no room (80 columns with notes) the list hides and the footer says f shows it; f then makes the notes rail give way.
  • Long names are cut in the middle so the start, end and extension stay readable (ReviewAge…lPanel.tsx). The columns are chosen once for all rows so they line up: the list widens first, then every row drops its counts, then its status letter. Folder rows keep their last folders (…/review-editor/components/). The diff heading shows the whole path, and so does the footer when the heading is too narrow for it.
  • Ticks: as before, viewed files get a tick and are dimmed. A folder gets a tick when every file in it is viewed.

Filters. While a filter is on, the diff shows only the files it lets through, so n/N, ]/[ and ctrl+n move among them:

  • / filters by name. Every word must appear in the path; if no path has them all, the existing fuzzy rank is used instead. The list updates as you type, enter applies the filter to the diff, and esc clears it.
  • t opens a kind picker with a count for each kind: code, tests, docs, config, generated and other. Space turns a kind on or off, and enter shows that kind alone.
  • H hides viewed files. A file you mark while they are hidden leaves the list, and the diff moves to the next file.
  • The heading shows Files · 12 of 340, with the filter on the line below it. The header counts and +/- totals cover only the files shown.
  • Notes are never hidden. The list counts unsent notes in hidden files, going to such a note says the filter hides its file, and Send sends every note.

The kinds for tests and generated files are ported from Plannotator's packages/core/file-kind.ts (isTestPath, TEST_FOLDERS, the source-set and .NET test project rules, isDefaultGeneratedPath), and its test cases are ported too. On top of those rules, this PR also treats more lockfiles, *.pb.go, *.g.dart, vendor/, node_modules/ and dist/ (outside src/) as generated. .gitattributes linguist-generated is read as Plannotator reads it: one git check-attr --stdin -z for every path, on its own thread, whose answer wins both ways; a failure leaves the name rules. Docs, config and other are new here; a data or config extension wins over a documentation name (security.yml is config).

The new keys are documented in the keymap and its config action names (filter-files, filter-kinds, hide-viewed, narrow-files, widen-files), the help overlay, the footer hints and the README. The list width has its own actions so a config that gave < or > to a code review key keeps loading and the reading column keeps its keys. The list keys also work over the whole-file view.

Footer hints drop the least useful ones to fit one row, or two balanced rows on a narrow screen; ? help and q quit stay.

Which file the diff is in comes from the viewer's cursor, whatever moved it (a key, the notes rail, d, ctrl+o, the mouse). diffs-rs names the file only on a line, so on a heading, a hunk heading or a binary file's note the cursor counts rows to the nearest lines above and below and comes back (review/diff/place.rs). An Engine method for the cursor's file would make this one call.

Large changes

With 3,000 changed files (release build, cargo test --release -p plannotator-tui big_change -- --ignored --nocapture), rows, kinds and widths are cached:

before after
a frame 4.2 ms 0.45 ms
j in the diff 4.2 ms 0.48 ms
j in the list 6.8 ms 0.46 ms
a key typed in / 5.8 ms 1.6 ms
a kind on or off 8.5 ms 4.7 ms

First paint is about 710 ms, most of it the review-progress identities that main computes too.

Not done

  • Snapshots (*.snap) count as tests, as in Plannotator, not as generated.

Tests

cargo fmt --check, cargo clippy --workspace --all-targets -- -D warnings and cargo test --workspace pass. The new tests cover the kinds, the tree, the cuts, the width, the hint fitting and the patch sections as unit tests, plus flow tests in review/tests/file_list.rs, file_moves.rs (the cursor's file, n/N, files without lines, type changes, filter cancel, narrow screens, hidden notes), file_list_mouse.rs and file_kinds.rs. The review tests were run 10 times in a loop. The viewed-ticks test could start its edit before the disk watch had taken its baseline. That failed 4 times in 10 runs on this branch, while main passed 10 times in 10, so the new list's slower start brings out the race. The test now waits for the baseline, as disk_flow does, and passed 10 times in 10.

…kind and viewed

The code review drew the viewer's own file list: 32 columns wide, a 2-column gutter,
two columns of indent a level, a 16-column summary and a badge column, so a name got 10
to 18 columns and lost its end. Below 97 columns of diff there was no list at all.

The review now draws its own list and hides the viewer's:

- folder chains with one folder each are one row, folders first, sorted as the browser
  sorts them; the diff shows the files in the same order
- the list is as wide as its rows need, up to two fifths of the room, and never takes
  the diff below 48 columns; `<`/`>` narrow or widen it
- a long name is cut in the middle so its end and extension stay; counts, then the
  status letter, give way first; folders keep their last folders
- without room it hides and the footer says `f` shows it; `f` makes the notes rail
  give way

Filters, which the diff, n/N, ]/[ and ctrl+n follow:

- `/` by name (every word in the path, else characters in order), live in the list,
  applied to the diff on enter, cleared with esc
- `t` by kind: code, tests, docs, config, generated, other, with counts; tests and
  generated follow Plannotator's packages/core/file-kind.ts
- `H` hides viewed files

Notes are never filtered: the list counts unsent notes in hidden files and Send sends
every note.
- n/N, the list highlight and the footer start from the file the
  viewer's cursor is in, whatever moved it (rail, d, ctrl+o, mouse);
  a heading or a binary file's note is placed by counting rows to the
  nearest lines, so j at a lineless last file no longer bounces back
- a file replaced by a symlink is one row (T) and the diff shows both
  sections; a section the parser cannot name is shown again
- cancelling a filter that changed nothing moves nothing and returns
  the focus; ctrl+c quits and paste works while typing it
- go to definition or ctrl+o into a file the filter hides opens it in
  the whole-file view and adds no history when nothing moved
- notes count as hidden only when a filter hides their file
- the list keys work over the whole-file view
- a screen too narrow for the list says so and shows the filter typed
- narrow-files/widen-files are their own actions, so an older config
  that gave < or > to a code review key keeps the reading column's
- data and config extensions win over documentation names; dist under
  src is source
- columns line up; footer hints drop to fit one or two rows
- .gitattributes linguist-generated is read off the event loop
- rows, kinds and widths are cached for large changes
@backnotprop
backnotprop added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit 5d97a80 Nov 23, 2026
3 checks passed
@backnotprop
backnotprop deleted the feat/review-file-tree branch November 23, 2026 18:09
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