Skip to content

Optimize previews, details pane, and thumbnail loading - #218

Merged
dhh merged 2 commits into
mainfrom
optimize-previews
Nov 23, 2026
Merged

dhh merged 2 commits into
mainfrom
optimize-previews

Conversation

@dhh

@dhh dhh commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Removes UI-thread stalls when stepping through files in Columns view, speeds up thumbnail generation and delivery, and makes folio preview more responsive in large folders.

Changes

  • Desktop app & MIME lookup caching (src/fileops.h, src/fileops.cpp, src/PreviewPane.qml):
    • Cache omarchy-launch-editor.desktop name resolution (which previously called g_app_info_get_all() twice per keypress on text/code files), defaultAppName(mime), and appsFor() results, keyed by editor/mimeapps/applications mtimes and invalidated immediately on setDefaultApp().
    • Pass pane.type from PreviewPane.qml into FileOps::appsFor(path, mime) so stepping through files in Columns view does not open files on the UI thread to sniff MIME types.
  • Details & per-folder sort caching (src/backend.cpp):
    • Cache parsed per-folder sort settings in Backend::sortFor() with stat() invalidation instead of reopening and parsing folio.conf on every column or navigation.
    • Combine permissions and creation time into a single statx() call in Backend::describe(), and cache Backend::typeName() per (locale, mime).
  • Thumbnails (src/thumbnails.h, src/thumbnails.cpp):
    • Defer .thumbnailer directory scanning and QMimeDatabase setup via std::call_once to the first thumbnailer lookup (off the UI thread).
    • Emit finished() in ThumbnailProvider before writing newly generated PNG cache entries and failure markers (matching sharp), and prioritize cached/ and sharp/ preview requests over grid/row thumbnail backlogs.
    • Optimize withPlainText() (single pre-sized output buffer using QByteArrayView), textPage() (stop line iteration at the page bottom), cache pdftoppm lookup, skip redundant mkpath/setPermissions calls, and compute cacheKey() once per lookup.
  • Preview window (src/previewer.h, src/previewer.cpp):
    • Cache QImageReader::supportedMimeTypes() in Previewer::viewerFor().
    • Index siblings by path (m_pathIndex) for O(1) Previewer::show().
    • Run Previewer::relist() on FolderModel::listingPool() with a generation stop predicate so switching folders or closing cancels in-flight listings early.

Benchmarks

Measured on Release builds:

Benchmark Before After Speedup
Thumbnails() startup init 2.26 ms 0.01 ms 226×
200× Backend::sortFor() 3.14 ms 0.15 ms 21×
20× FileOps::appsFor() + defaultAppName() (text/plain) 479.85 ms (24.0 ms/call) 6.22 ms (0.31 ms/call, < 0.01 ms warm) 77×
Thumbnails::load() (2400×1600 JPG, cold) 9.05 ms 3.73 ms 2.4×
Thumbnails::load() (2400×1600 PNG, cold) 44.47 ms 15.68 ms 2.8×
Thumbnails::sharp() (2400×1600 JPG, cold) 10.73 ms 4.44 ms 2.4×
20× Thumbnails::textPage() (256px) 14.07 ms (0.70 ms/call) 5.02 ms (0.25 ms/call) 2.8×

@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; all three previous findings are fixed, and no new actionable issues were found.

Summary

Speeds up previews by caching app and file-type lookups, reducing repeated settings reads, and moving more work away from the window's thread.

  • Thumbnail requests show new images sooner and favor active previews.
  • The details pane reuses app choices as you move between files.
  • Folder settings and file details reuse results between lookups.
  • The preview window finds siblings faster and stops outdated folder listings.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Select file] --> B[Show known details]
  A --> C[Read details in background]
  C --> D[Refresh type and app choices]
  A --> E[Request thumbnail]
  E --> F[Return pixels]
  F --> G[Write cache]
Loading

Reviews (2) · Last reviewed commit: "Address Greptile review comments on app ..." · Reviewed by Greptile

Comment thread src/fileops.cpp Resolved
Comment thread src/fileops.cpp Resolved
Comment thread src/thumbnails.cpp Resolved
@dhh
dhh merged commit f73d8e4 into main Nov 23, 2026
2 checks passed
@dhh
dhh deleted the optimize-previews branch November 23, 2026 14:16
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