Skip to content

Reuse list rows safely during scrolling - #122

Merged
dhh merged 5 commits into
omacom:mainfrom
k-kostin:codex/reuse-list-rows
Nov 21, 2026
Merged

dhh merged 5 commits into
omacom:mainfrom
k-kostin:codex/reuse-list-rows

Conversation

@k-kostin

@k-kostin k-kostin commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

The list made a new row for every file scrolled into view and destroyed every row scrolled out. It now hands the rows scrolled out to the files scrolled in (reuseItems), so scrolling a long list costs a fraction of what it did: through 3,000 files, layout took about 0.16 s instead of 1.5 s, and the GUI's CPU during a scroll fell from 120 to 37 ms.

What a row shows follows its file on its own, except the picture a drag carries: a row given another file under a pointer that hasn't moved stays hovered and kept the previous file's picture. A reused row now drops it and retakes it when hovered.

🤖 Generated with Claude Code

@greptile-apps

greptile-apps Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] No new blocking issue was established in the current diff.

Summary

Enables row reuse in FolderList and refreshes the drag picture when a reused FileRow remains hovered.

  • Folder lists reuse rows as files scroll into view.

Reviews (3) · Last reviewed commit: "Keep only the reset a reused row needs" · Reviewed by Greptile

Comment thread tests/rowreuse_tests.cpp Resolved
@omarchybot omarchybot added the enhancement New feature or request label Nov 15, 2026
@dhh

dhh commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Thanks for this, and for the careful thinking about what a reused row must forget. The list has changed under it since: it's a tree now (#160), so FileRow carries a depth and an open/closed arrow, and rows show thumbnails for PDFs and other files too (#149), so the conflict is more than textual. To make it mergeable:

  • Rebase onto today's main and check reuse against the tree: an arrow, its depth and a folder opening or closing while rows are pooled and reused.
  • Put the tests in tests/folio_tests.cpp with the rest rather than a new rowreuse_tests target, and keep them to what reuse changes.
  • Answer Greptile's thread: add a picture to the fixtures, check a pooled row lets go of its thumbnail, and that a row reused for another picture, or for a text file, shows the right one.
  • Measure the win against main as a user would feel it (time to settle after a long scroll, or frames dropped while scrolling), since cumulative GUI CPU over 64 jumps is hard to weigh against the extra state each row now keeps.

If the win holds up on the tree with that, it can go in.

@k-kostin
k-kostin force-pushed the codex/reuse-list-rows branch from 98628c2 to 7c2593c Compare November 19, 2026 19:40
@k-kostin

Copy link
Copy Markdown
Contributor Author

Thanks. I rebased the original reuse change onto the current tree and moved the tests into tests/folio_tests.cpp. They cover the reused arrow and indentation, expansion/collapse while rows are pooled, picture → another picture → text, and interrupted clicks and drags. The full suite passes: 258 passed, 0 failed, 1 environmental skip. The focused cases also pass at 100% and 200% scaling, and native Wayland drop/Escape checks pass in LTR and RTL.

For the long-scroll measurement, I used an expanded 2,320-row tree with synthetic PNG/text files and the same 7,680-pixel, two-second scroll on both versions. Across three viewport configurations, median GUI CPU fell from 120–124 ms to 34–40 ms, and the median per-run p95 interval between Qt frame-swap notifications fell from 20.9–21.1 ms to 16.7 ms. This used NVIDIA OpenGL in a private Weston session with a virtual 60 Hz output, eight alternating pairs per configuration. Neither version had an interval over 25 ms; this measures application-side timing, not physical display FPS.

There is still a tradeoff: earlier software-rendered runs improved tall-list settling from about 8 to 6.5 ms, but the short mixed list went from 5.3 to 5.8 ms, and the first jump to the end from 8.7 to 11.9 ms. I wouldn't claim a win in every scenario.

k-kostin and others added 5 commits November 21, 2026 11:53
The list made a new row for every file scrolled in and threw away every
row scrolled out. Turning on reuseItems gives the rows scrolled out to
the files scrolled in instead; scrolling 3,000 files through the list
offscreen took 1.5 s of layout before and 0.16 s after.

Nearly everything a row shows is bound to its file's roles, so follows
the file it's given. What isn't is the picture taken for dragging it:
a row given another file under a still pointer stays hovered, so takes
no new one, and a drag from there showed the file before. A reused row
now drops that picture and, still hovered, takes a new one.

The rest of the pilot's guards are dropped: the pooled state gating
every handler, the Loader around the tap handler, the arrow's pressed
path, the drag generations and holding reuse off during a drag. They
cover a mouse button held through a page of scrolling, a double-click
split by a jump that moves the cursor, or a scroll during a drag the
system holds; and the drag picture's superseded grabs are already
ignored by DragPicture since omacom#196. The tests go down to one for the
picture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dhh
dhh force-pushed the codex/reuse-list-rows branch from 7c2593c to 443dc67 Compare November 21, 2026 11:02
@dhh

dhh commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Thanks @k-kostin, the win is real: scrolling 3,000 files through the list offscreen took 1.5 s of layout on main and 0.16 s with reuseItems. I rebased onto main (it conflicted with #196's DragPicture) and added a commit that keeps only the reset a reused row needs.

Almost everything a row shows is bound to its file's roles, so it follows the file it's given. The one thing that isn't is the drag picture. A row given another file under a still pointer stays hovered, so it never retakes the picture, and dragging from there showed the previous file. ListView.onReused now clears it and retakes it if the row is hovered, and one test covers that (it fails with reuse alone).

The other guards are gone: the pooled gates, the Loader around the TapHandler, the arrow's pressedPath, the drag generations and switching reuse off during a drag. Each one covers a button held down through a page of scrolling, a double-click split by a jump that also moves the cursor, or scrolling during a system-held drag. And since #196, DragPicture already ignores superseded grabs. That takes the PR from +550 to +77 lines. The change isn't visible, so there are no screenshots.

@dhh
dhh merged commit f6f5efa into omacom:main Nov 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants