Skip to content

fix(thumbnails): expand embedded thumbnailer field codes - #339

Closed
k-kostin wants to merge 1 commit into
thisisgm:mainfrom
k-kostin:codex/fix-thumbnailer-embedded-placeholders
Closed

k-kostin wants to merge 1 commit into
thisisgm:mainfrom
k-kostin:codex/fix-thumbnailer-embedded-placeholders

Conversation

@k-kostin

@k-kostin k-kostin commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

F3D 3.5.0's packaged thumbnailers use --output=%o --resolution=%s,%s %i. Flea currently substitutes only whole-token field codes, so it launches F3D with literal %o and %s in those options and cannot produce the requested thumbnail. This also affects other thumbnailers that put field codes inside options.

Expand %i, %u, %o and %s anywhere within each already-tokenised argument. A single pass preserves argument boundaries and keeps replacement text literal, including percent signs, spaces, quotes and shell metacharacters in filenames. %% becomes a literal percent; unknown codes and a trailing % retain their existing literal behavior. The validated executable remains unchanged, and %i, %u and the sandbox bind still derive from the same canonical path.

Include an expansion-version salt in the thumbnailer-table fingerprint so existing failure markers do not suppress a newly working thumbnailer after upgrading. Valid cached thumbnails remain reusable. Update the documented behavior and re-derive the existing thumbspec.rs budget from 479 to 480 lines for that salt.

Validation on Arch Linux x86_64, Rust 1.98.0:

  • Five new regression tests cover F3D-style options, repeated codes, literal replacement text with a real child process, canonical paths through symlinks, the unchanged executable, and the old fingerprint. Four fail before the fix; all ten thumbargv tests pass afterward.
  • cargo test --locked and cargo test --release --locked: 2959 passed, 2 existing ignored tests in each profile.
  • Debug and release builds, the repository Clippy ratchet, file-budget checker and git diff --check pass.
  • Isolated real-backend smoke: the installed Flea 0.3.12 records three failures for an option-checking fixture thumbnailer; the patched build publishes all three thumbnails using the same cache, exercising failure-marker recovery.
  • With the unmodified system F3D 3.5.0 native .thumbnailer, installed Flea 0.3.12 fails all three entries; the patched backend renders all three to 256 × 256 PNGs using the same cache: a filename with spaces, a Unicode filename with percent signs and shell metacharacters, and a symlink. No wrapper is used for this check. Each run uses private XDG data, configuration, runtime and cache directories; the user's installed Flea and caches are untouched.

The full tests/run-all.sh GUI/media battery was not run. No renderer, dependency, sandbox limit or worker-count change is included.

Summary by CodeRabbit

  • New Features

    • Thumbnailer arguments now support field-code expansion anywhere within an argument, including repeated placeholders.
    • Literal %%, unknown codes, and trailing % sequences are preserved as written.
    • Executable tokens remain unchanged during expansion.
  • Bug Fixes

    • Replacement values are processed safely without being rescanned as additional field codes.
    • Thumbnail fingerprints now distinguish the updated expansion behavior.
  • Documentation

    • Added guidance covering embedded placeholders, repeated codes, literal sequences, and unchanged values.

Expand argument field codes once while keeping program paths literal.
Retry cached failures made before embedded options were supported.
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1d4dbf05-8f4a-4c11-bf5d-a07480cfe02a
📥 Commits

Reviewing files that changed from the base of the PR and between f21789e and be05cd3.

📒 Files selected for processing: 4
  • AGENTS.md
  • src/backend/thumbargv.rs
  • src/backend/thumbspec.rs
  • tools/flea-file-budget

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📝 Walkthrough

Thumbnailer arguments now expand field codes embedded in tokens after the validated executable. Expansion occurs in one pass. The thumbnailer fingerprint includes a fixed version marker, and documentation and tests cover the behavior.

Changes: Thumbnailer argument expansion

Layer / File(s) Summary
Expand field codes in argument tokens
src/backend/thumbargv.rs, AGENTS.md
Tokens after the validated executable support embedded and repeated field codes. Literal replacements are not rescanned. Unknown and trailing codes remain unchanged. Tests cover canonical paths and executable preservation.
Version the expansion fingerprint
src/backend/thumbspec.rs, src/backend/thumbargv.rs, AGENTS.md, tools/flea-file-budget
The thumbnailer fingerprint includes the embedded-field-codes-v1 marker. A test checks that it differs from the prior fingerprint. The recorded line ceiling is updated.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: thisisgm

Merge Risk: ⚪ Minimal · up to be05c

The updated argument expansion and cache versioning appear ready to merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 2 files. (2 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: expanding embedded thumbnailer field codes.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 2 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@thisisgm

Copy link
Copy Markdown
Owner

Nice one, will add to the next build! Major changes coming

@thisisgm

thisisgm commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Embedded thumbnailer field codes were passed literally. Thumbnailer field codes expand inside options such as --output=%o (578b080a73, v0.4.0). Thanks @k-kostin! Release.

@thisisgm thisisgm closed this Nov 3, 2026
demostenex pushed a commit to demostenex/flea that referenced this pull request Nov 4, 2026
Kirill Kostin's be05cd3 (thumbnailer field codes), reimplemented
in 6a13013; every conflict resolved to the reviewed stage code,
which already carries all of its behaviour and tests.

Co-authored-by: k-kostin <[email protected]>
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.

2 participants