Skip to content

LR-CLOUD-SMARTPREVIEW: opt-in lossless smart previews (#709) - #1400

Open
AlexChambers wants to merge 48 commits into
storytold:mainfrom
AlexChambers:lossless-smart-previews
Open

AlexChambers wants to merge 48 commits into
storytold:mainfrom
AlexChambers:lossless-smart-previews

Conversation

@AlexChambers

@AlexChambers AlexChambers commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #709

Rebased onto main 0da998f2 after integration batch 40. This branch inherits main's LOOK_VERSION 9 and RENDER_CACHE_VERSION 64.

Changes

Adds a per-library Lossless format using the existing pure-Rust float TIFF codec with Deflate. Compact JPEG remains the default. The Settings preference controls future builds; Build Smart Previews can override it for a selection.

Lossless stores the decoded, reduced scene-linear source before tone curves and edits. It preserves finite source floats exactly, including negative values and highlights above 1.0. This improves editing from an offline proxy while retaining the proxy's existing resolution limit. Online originals still take precedence.

Existing LCSP1 JPEG previews keep working. LCSP2 adds bounded parsing, payload length and checksum checks, and a completeness marker. Format conversion rebuilds from available originals and keeps offline proxies unchanged. Unknown header and tone fields, including white_stat, survive rewrites.

Builds verify payload integrity and successful decoding before reusing a proxy. A Compact proxy must also be complete: a JPEG cut short still decodes, with part of the picture made up, so a cut-short Compact proxy is not counted, rendered or kept over a complete copy, and Build Smart Previews repairs it, as on main (issue #106). Migration verifies the destination before removing the source, including after an atomic copy. The structural staleness hint and the full usability check have separate names. Builds, discards and look refreshes invalidate the cache currently attached to the same library, including cache replacement and reopening in another session. Render jobs capture their cache generation before acquiring a source and reject construction if it changes. Returned sources must also belong to the current cache object, because different cache objects can have the same generation. Size accounting includes both formats and layouts. Documentation and the LR-CLOUD-SMARTPREVIEW checklist row are updated.

Folder changes and cancellation

Settings starts folder changes on a worker. The activity stack reports progress and accepts cancellation while files are copied and verified. The old location stays in use until every destination verifies and the library saves the new location. Builds and look refreshes must finish before migration starts; they cannot start during migration. This also resolves the pre-existing move race reproduced below.

Cancellation or a failure during copying, verification or preference saving leaves the entire old folder in use. A source that does not decode, such as a proxy cut short, is not a failure: it stays in the old folder, the rest of the folder moves, and the result names it. Build Smart Previews rebuilds it in the new folder from its original. Copies already written to the new folder can remain, and retries reuse valid destinations. Source cleanup runs on a worker after the location switch and cannot be cancelled. A crash before the switch reopens the complete old folder. A crash during cleanup reopens the complete new folder and may leave redundant old files. Each destination is verified again before its source is removed.

The folder and a thumbnail cache generation are saved in the same atomic preferences write. Reopening uses that generation before reading any disk thumbnail. An exit immediately after the save and failure to spawn cleanup therefore cannot expose thumbnails from a different proxy in the old folder. Cache replacement changes memory state without scanning or deleting files, and old writers use separate disk keys. Old thumbnail files share the existing cache budget and are removed by normal pruning.

Same-volume moves also use copy and verification. Renaming sources early would break the cancellation guarantee. The destination needs space for the copies while the old folder is retained.

Automatic look refresh checks stale candidates. It can skip corruption in current-look proxies without decoding them. Build Smart Previews is the verification and repair action for those files.

Interrupted builds

A build, discard or look refresh clears the thumbnail cache once, after its last photo. Before it writes or removes its first proxy, it creates and syncs an empty marker file in the library's thumbnail folder, and it removes the marker after that clear. A quit or crash in between, for example Quit Anyway during a long Lossless conversion, leaves the marker. The next opening then saves a new thumbnail cache generation before it reads any disk thumbnail, and removes the marker. Thumbnails of the replaced proxies therefore do not come back, also when a retry with the originals offline changes no proxy. Every change records the marker, including a discard: an interrupted discard leaves thumbnails of the removed proxies, which still show the photo until a later first build replaces that picture. Each leftover marker moves the generation on by one, so if an opening cannot save its generation and is interrupted again, the next opening does not reuse it. Opening the library again in the same process while a build runs keeps that build's marker and receives its final clear, through any spelling of the library's path (a symlink, .. or a relative path).

A full drive can refuse even an empty file; APFS and HFS+ both do. The run then clears the thumbnail cache at once, which removes every thumbnail of the proxies about to change and frees space, and tries the marker again. If the drive is still full, it continues without the marker and clears the thumbnail cache again after each proxy it replaces (a format conversion or a newer camera look). A build into a smart preview folder on another drive with room therefore works while the library drive is full, and a thumbnail rendered from a proxy before its replacement can survive an exit only between writing that proxy and the clear after it. A first build or a repair skips that clear, which would empty every thumbnail and loaded picture on screen once per proxy. Other failures, such as a read-only thumbnail folder, stop a build with an error before it changes any proxy, without clearing anything. A discard is never stopped: without a marker it still removes the proxies, so a full drive never blocks the discard that frees its space.

Translations

The new interface messages have translations in German, Spanish, French, Japanese, Brazilian Portuguese, Russian, Ukrainian, Simplified Chinese, Traditional Chinese, Czech, Polish, Italian and Georgian, covering thirteen non-English locales. They cover the storage dialog with its Build and Build Anyway buttons, the format choices, warnings, offline-original guidance, activity labels, completion messages, and the Smart Preview Format command in Keyboard Shortcuts. Photo and file counts use explicit whole-number plural forms, including Russian and Ukrainian counts such as 21 and 22. The new strings use each catalog's existing words for smart previews and folders: смарт-просмотры in Russian, смарт-перегляди and тека in Ukrainian, 智慧型預覽 in Traditional Chinese, and, in Portuguese, the catalog's existing mix of "prévias inteligentes" and "pré-visualizações inteligentes". A native speaker should still check the new translations.

The rebase adds only this PR's own message and format keys to the Czech, Polish, Italian and Georgian catalogs introduced on main. Existing keys and translations from main are retained. The new count messages use neutral labels and preserve all placeholders and plural-form fields. The added Italian, Czech, Polish and Georgian text has not had native-speaker review.

Opening the library in an older version

Versions up to 0.7.1 can open a library this PR has used, with limits that docs/smart-previews.md now lists:

  • They cannot read Lossless (LCSP2) proxies, so a photo whose original is offline has no usable smart preview there.
  • Saving preferences in them drops the format and the thumbnail cache generation, and the format returns to Compact.
  • They ignore the generation and the interrupted-build marker. After a folder change or an interrupted build, they can show thumbnails made from the previous proxies.
  • After an older version has saved preferences, this version starts again at generation 0 and can show the same thumbnails.

File > Previews > Discard Preview Cache removes cached thumbnails of every generation. A second copy of the generation outside prefs.json would cover only the last case, because the older version reads the old thumbnails itself, so this PR documents the limits instead.

Storage and fidelity

On the public 61 MP Sony ILCE-7CR sample, the actual binned proxy is 2376 x 1584. Float TIFF used about 39.5 MB versus 0.92 MB for JPEG at the former quality 92. On the ILCA-77M2 sample, it used about 45.4 MB versus 0.52 MB. Compact at quality 97, since PR #850, is about twice those sizes. Before a Lossless build starts, the UI shows the photo count, estimated total size and destination free space. The estimate uses 39.5 MB per photo and states that actual sizes vary. An estimate above free space shows a warning and Build Anyway. The space query runs on a worker. The native UI adds fs4, a Rust filesystem wrapper, for that query.

Compared existing PNG16, TIFF16 with a horizontal predictor, JXL16 lossless, and TIFF32 Deflate. TIFF16 used roughly half the space but quantized the source. The original JXL comparison mixed sRGB-tagged input samples with decoded linear Rec.2020 pixels. Correcting that comparison gives a maximum source error of 1.47e-5 on the A7CR sample; the direct 16-bit integer round trip is exact. There is no codec bug. Float TIFF retains its exact-float advantage. No codec dependency was added.

A real library test disconnected an isolated copy of the public A7CR raw and rendered in fresh processes. Lossless matched the online 1600 x 1067 render pixel for pixel at neutral settings, Exposure -2 with Highlights -100, and Exposure +2. JPEG mean delta E76 at quality 92 was 1.334, 0.773, and 1.506.

The synthetic source-grid render matched exactly after lossless storage at default settings, Exposure -2 with Highlights -100, and Exposure +2. JPEG mean CIE76 delta E at quality 92 was 0.620, 0.391, and 0.416 respectively. A smooth source gradient had 759 repeated adjacent samples after JPEG storage and none after lossless storage.

The float-output codec measurements isolate storage error on the same source grid. The library test also checks the actual offline metadata and render path for that A7CR sample. It does not cover the missing DNG metadata described below. Neither establishes full-resolution raw-render parity or compares against Lightroom.

The cost-confirmation interceptor now handles main's validated target Result, reports malformed ids before checking storage, and honors a singular id with no selection. The new regression covers those cases. The crash-regression fixtures now use main's .lcthumb extension and distinguish its two persistent cache metadata files from build markers. Crash, stale-pixel and invalidation assertions are retained. The added Georgian lossless-build title is shorter so the existing layout test can check it without elision. Builds and tests were not rerun after this rebase.

Validation

Historical implementation commit before this rebase: cf1c803ac1ee72ac417a55b92421dd6028955575. At that commit, the branch was rebased onto main b3d392b4, which includes integration batch 33 and PR #850. Rebasing onto batch 33 kept every commit and its message; its conflicts were strings both sides added to the 18 translation catalogs (both kept), history rows and the header of docs/parity-checklist.md (one tracker row per id), and two new RenderResult constructions in crates/engine/src/media.rs that now carry this branch's cache fields. Rebasing onto b3d392b4 reconciled crates/engine/src/smart.rs with PR #850 (see Coordination) and left every other file of those commits unchanged; a new last commit adds the Lossless test and the documentation for it.

Each regression below was written before its fix and failed on the branch commit before it, with only the tests added. The red runs before the last commit were made before the rebase onto batch 33; the hashes below are those commits after the rebase.

  • Interrupted conversion (failed on 35213536). Two photos have Compact proxies. The first photo's thumbnail, rendered from its proxy while the original was offline, is in the disk cache. A subprocess converts both photos to Lossless and exits, without running destructors, while it reads the second original. At that point the first photo's Lossless proxy is durable. On 35213536, reopening with the originals offline served the old Compact thumbnail from disk (cache_hit=true), 7,844 pixels different from the Lossless render under the same cache encoding. The test reopens twice, retries the build with the originals offline, and reopens again.
  • Full library drive (failed on c35a7873). The library sits on a 40 MB APFS or HFS+ disk image that is filled until even an empty file is refused. Discard Smart Previews, and a Lossless conversion into a proxy folder on another drive, were both refused with "No space left on device". Now the discard removes the proxies and the conversion converts both, with no thumbnail of the old proxies left. The test runs on macOS and is skipped where hdiutil cannot attach an image; portable tests inject the same failure into marker creation.
  • Another path spelling (failed on c35a7873). Reopening the library through aside/../library while a build was blocked deleted the build's marker. The test then checks that the finished build's clear reaches the reopened session.
  • Failed preferences save at opening (failed on c35a7873). A leftover marker is followed by a session whose prefs.json save fails. That session renders a thumbnail from a Compact proxy and is interrupted during a conversion. The next opening reused that session's namespace and served the old thumbnail, 7,844 pixels different.
  • Cut-short Compact proxies (failed on d214084f). A 1200 x 800 Compact proxy is cut to 50, 75, 90 and 99 %. Info reported a smart preview, the offline render showed a partly wrong picture (800 to 23,421 of 43,776 pixels), and Build reported it as built without repairing it. A move into a folder holding a 90 % copy kept that copy and deleted the complete proxy. Now Info reports none, the offline render refuses it, Build repairs it byte for byte, and the move keeps the complete proxy.
  • Interrupted discard, then interrupted first build (failed on d214084f). A discard ends after removing the proxies and before its clear, then a first Lossless build ends while reading its second original. Neither left a marker, so the next opening served the old Compact thumbnail, 7,844 pixels different.
  • Full drive, then space during the run (failed on d214084f). With marker creation failing for lack of space, the grid writes a thumbnail of the second photo from its old proxy during the run, the build replaces that proxy, and the process ends. The next opening served that thumbnail, 8,369 pixels different.
  • Unwritable thumbnail folder (failed on d214084f). A discard goes ahead, but a first build afterward must stop like a conversion; it built both proxies. A conversion refused for a permission error must keep the thumbnail cache; it was cleared.
  • Move with a cut-short source (failed on bc559d29). Two Compact proxies, one cut to 90 % with its original offline, so Build cannot repair it. The folder move failed with "smart preview is cut short", naming no file. Now the move commits, the intact proxy moves, and the cut one stays in the old folder and is named in the result.
  • First build without a marker (failed on bc559d29). On a thumbnail drive that stays full, a first build of two photos moved the cache generation four times, once per proxy, and each move empties the grid and the loupe. Now it moves twice: the clear that frees space and the final one. A conversion still clears after each proxy it replaces.
  • A clear held up drawing (failed on 4d6e1829; found in the review of Full-size demosaic runs before white balance: green/cyan fringes beside clipped specular highlights and on sharp white edges #1328, which is stacked on this branch). Every run that changes a proxy ends with a thumbnail clear, and PreviewCache::clear removed every disk file while holding the generation lock that the app reads every frame (Renderer::poll): 100,000 cached thumbnails took 6.7 s, all of it with drawing waiting. Now the generation moves on and memory empties under the lock, briefly, and the files are removed after it is released. Until they are gone no disk file is read, so none from before the clear is served, and the clear returns only once they are gone, so a run still removes its marker only after the files. The test fills a cache with 20,000 files: on 4d6e1829 the new generation could be read only once all were gone; now it is read while files remain, no old thumbnail is served meanwhile, and none is left after.
  • Size after a clear (failed on 6bc9e680). Thumbnails of the new generation can be written while a clear removes the files, and one written after the clear lists them outlives it. The clear then set the cache's size to zero (0 for 807 bytes on disk in the test), so the budget undercounted until something scanned the folder again. Now the size is unknown after a clear and the next check scans the nearly empty folder; a writer updates it under the same lock as its file replacement, so none can put back a size from before the clear.
  • Lossless and the JPEG encode version (fails when PR smart previews: store proxies at JPEG quality 97 and version the encoding (#709) #850's encode check is applied to every format). A photo that takes the per-file camera look gets a Compact proxy from before the encode version, which Build rebuilds once, then a Lossless proxy. Its header's own enc (1) is lower than Compact's encode version (2); read as that version, the proxy was marked stale. Now it is current: Build keeps it without reading the original, and the opening scan of a folder checked before the encode version leaves it untouched.
  • Labels (failed on 35213536). "Build" and "Smart Preview Format" had no translation in any catalog. A test now covers every smart preview command label and the dialog buttons, and the localized storage dialog test also checks the usual state with enough free space, where the button is Build.

Further tests: a reopening in the same process while a build is blocked keeps the build's marker and namespace; a conversion whose thumbnail folder cannot hold a marker for another reason (here a file in its place) stops before it changes a proxy; a thumbnail drive that is full at first is cleared before the first replacement, which makes room for the marker; and one that stays full still converts. Earlier regressions still cover an exit immediately after the durable preferences write of a folder change, failure to start the cleanup thread, preference-save rollback, a folder switch while an old thumbnail read is blocked, late results and writes, cache-budget changes, reopening, cancellation, exits during copying and cleanup, reopening during conversion, concurrent preferences, and active-build exclusion.

After the rebase onto main b3d392b4, which includes #990, #997 and the 0.7.1 on_exit fix, so no temporary patches were needed: cargo fmt --check, Clippy with warnings denied on the engine, preview and UI crates (all targets), the preview crate's tests (19 passed), the engine's smart preview and import tests (167 passed and 7 ignored child processes, including PR #850's tests and the full-volume test on real disk images), the UI's localization tests (30 passed), and cargo xtask parity, layers and wasm (all 28 crates) pass. The wasm32 warnings are in files this PR does not change, plus the missing optional CJK-font warning. Both public reproductions below give the stated results on the final commit. The full workspace suite was not rerun after the rebases, which changed no invalidation code.

Before the rebase, on main 76b53778 with the #990 and #997 patches applied temporarily: cargo xtask ci passed formatting, workspace Clippy with warnings denied, and the HEIF gates, then stopped at the 11 known engine test failures. The complete cargo test --workspace --no-fail-fast run finished with 3,074 passed, exactly the 12 known failures listed below, and 33 ignored, and parity, layers, assets and wasm passed. The thumbnail clear was validated the same way on the #1328 branch stacked on it: 3,099 passed, the same 12 known failures, 34 ignored.

The known workspace failures before the rebase:

  • sidecar::tests_repair_companions::partial_move_companions_allow_save_and_autowrite_without_weakening_collisions
  • sidecar::tests_repair_companions::queued_stem_retry_preserves_shared_packet_after_batch_rollback
  • sidecar::tests_repair_companions::rollback_repair_and_shared_copy_keep_known_companions
  • sidecar::tests_repair_provenance::absent_peer_destinations_are_not_owned_and_retirement_records_only_completed_packets
  • sidecar::tests_repair_provenance::changed_separated_sources_are_not_moved_or_retired
  • sidecar::tests_repair_provenance::failed_redo_and_discarded_or_pruned_history_keep_companion_provenance
  • sidecar::tests_repair_provenance::own_atomic_shared_packet_writes_advance_retained_versions_and_failures_do_not
  • sidecar::tests_repair_provenance::replaced_and_in_place_companions_block_save_autowrite_retry_and_file_history
  • sidecar::tests_repair_saves::autowrite_repairs_partial_rename_before_merging_foreign_xmp_across_library_switch
  • sidecar::tests_repair_saves::unowned_shared_stem_repair_does_not_block_healthy_jpeg_full_sidecar_save
  • tests_dialog_fit::export_dialog_is_unchanged_in_a_tall_window
  • tests_lightroom_folder::odd_folders_never_fail_the_check

The same 12 tests also failed on main 701f78ea (0.7.1) in this environment. They are unrelated to smart previews.

The tests simulate process exit, not physical power loss. Native-speaker review, physical drive disconnection, and optional model and external-corpus coverage were not performed. CJK font files are unavailable in this checkout, so the localized headless checks do not verify Japanese or Chinese glyph coverage. The public raw fidelity and codec measurements above are from earlier runs of this branch.

Resolved folder-move race

On main, a running preview build captures the old folder. A concurrent folder move can change the active location before that build writes its output. The build then leaves one proxy in the old folder and none in the new folder, while the new folder is active. This PR rejects a folder change while a build or look refresh is active, so the old folder and its completed proxy stay in use.

Save the following as crates/engine/examples/repro_smart_move.rs and run cargo run -p lightcraft-engine --example repro_smart_move. It creates its own fixture and uses public engine APIs. It works on main using the default Compact format. Remove the temporary example afterward.

use lightcraft_codecs::{EncodeImage, Samples, TiffCompression, encode_tiff};
use lightcraft_engine::{Session, smart};
use serde_json::json;
use std::{sync::{Arc, Mutex, atomic::Ordering, mpsc}, time::{Duration, Instant}};

fn main() {
    let root = std::env::temp_dir().join(format!("lc-smart-move-{}", std::process::id()));
    std::fs::create_dir(&root).unwrap();
    let path = root.join("source.tif");
    let pixels: Vec<f32> = (0..96 * 64 * 3).map(|i| (i % 257) as f32 / 256.0).collect();
    let image = EncodeImage::new(96, 64, 3, Samples::F32(&pixels));
    std::fs::write(&path, encode_tiff(&image, TiffCompression::Deflate, &Default::default()).unwrap()).unwrap();
    let mut s = Session::new().with_fs();
    s.open_library(root.join("library"), false).unwrap();
    s.execute("library.import", &json!({"paths": [path]})).unwrap();
    let loader = s.media.file_loader.clone().unwrap();
    let (entered, waiting) = mpsc::channel();
    let (release, blocked) = mpsc::channel();
    let blocked = Mutex::new(blocked);
    s.media.file_loader = Some(Arc::new(move |path, edge| {
        entered.send(()).unwrap();
        blocked.lock().unwrap().recv_timeout(Duration::from_secs(30)).unwrap();
        loader(path, edge)
    }));
    s.execute("library.smartPreviews", &json!({"background": true})).unwrap();
    waiting.recv_timeout(Duration::from_secs(30)).unwrap();
    let old = s.media.smart_dir.clone().unwrap();
    let new = root.join("new-previews");
    let moved = s.execute("library.smartPreviewsLocation", &json!({"path": new, "existing": "move"}));
    release.send(()).unwrap();
    let until = Instant::now() + Duration::from_secs(30);
    while !s.preview_build.as_ref().unwrap().finished.load(Ordering::Acquire) {
        assert!(Instant::now() < until, "build timeout");
        std::thread::sleep(Duration::from_millis(1));
    }
    println!("accepted={}, old={}, new={}, current_is_new={}",
        moved.is_ok(), smart::stats(&old).0, smart::stats(&new).0,
        s.media.smart_dir.as_ref() == Some(&new));
    drop(s);
    std::fs::remove_dir_all(root).unwrap();
}

On main (76b53778; 0.7.1 does not change this code) it prints accepted=true, old=1, new=0, current_is_new=true. On the final commit of this PR it prints accepted=false, old=1, new=0, current_is_new=false.

Separate metadata issue

Offline smart previews still lose source metadata needed for some edits. The defect exists on main and affects Compact too. Catalog reconstruction does not restore camera colour metadata, DNG local tone maps or semantic mattes. It is not part of this PR. It is filed as #1534, with a synthetic reproducer and five measured pixel counts.

Coordination

These open branches conflict with this one. The merges were checked with git merge-tree without changing this branch, and no rebase onto them is included.

No code from other contributors' open PRs is included in this branch.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added Lossless 32-bit TIFF smart previews alongside Compact JPEG, with per-library format selection and options to build previews for all photos.
    • Added storage estimates and available-space checks before lossless builds.
    • Added background smart-preview folder changes with progress and cancellation.
    • Expanded translations for preview controls, storage information, and status messages.
  • Bug Fixes
    • Improved preview migration and recovery, including retaining usable previews when originals are unavailable.
    • Preview build results now report existing previews kept unchanged.
    • Improved handling of damaged previews, interrupted builds, and outdated render results to prevent stale images from appearing.

@AlexChambers
AlexChambers force-pushed the lossless-smart-previews branch from b23d04c to a2c6fc4 Compare October 13, 2026 05:46
@AlexChambers

Copy link
Copy Markdown
Contributor Author

Rebased onto batch 33 (#1431). The conflicts were in media.rs (main's new failed() helper and quick-render fallback; this branch's two cache fields are added to both), the 18 locale catalogs (three-way merge, every key from both sides kept) and the parity checklist (one row per id). There are also two new commits:

  • the thumbnail clear moves the cache generation on under a short lock and deletes the old files after releasing it, so drawing is never held up (a clear of 100,000 files used to hold the lock for about 7 s);
  • a thumbnail written during that deletion keeps its place in the cache's size accounting.

Both have regression tests. The description has the details.

@AlexChambers
AlexChambers force-pushed the lossless-smart-previews branch from a2c6fc4 to cf1c803 Compare October 13, 2026 07:31
@AlexChambers

Copy link
Copy Markdown
Contributor Author

Rebased onto main b3d392b, which includes #850. The only conflict was in smart.rs, and there was a field-name clash. This branch's Lossless header already uses "enc": 1 for its own format version, so #850's check (enc below 2 means stale) would have rebuilt every Lossless proxy on every build and every opening scan.

#850's quality 97, its Compact enc: 2 and its look marker are kept as merged. An encode-version rebuild goes through this branch's thumbnail invalidation, like a look refresh, so it leaves no stale thumbnails.

@eliets2, one thing I noticed while reconciling, which is also true on main. The encode-version rebuild only reaches photos with a per-file camera look (raws), because the build consults is_stale only for those. JPEG and PNG proxies made at quality 92 are never rebuilt. That may be intended, so I've left it as is.

@mattsivak

Copy link
Copy Markdown
Contributor

Heads-up @AlexChambers: I'm building #1492 (Build Smart Previews runs several photos at once) on top of this PR, because it changes the same smart_run loop. The change replaces the global SMART_WRITE lock with a per-proxy lock and runs the jobs in lanes like Build Previews, and it keeps your Pending thumbnail-marker handling. I'll open it as a draft stacked on this PR and rebase when this one merges, so nothing changes here.

@AlexChambers
AlexChambers force-pushed the lossless-smart-previews branch from cf1c803 to 5a97a2e Compare October 14, 2026 08:48
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 14, 2026
… downgrade a newer proxy (storytold#1328 review)

Review of 52f6b7e8:

P2. A pixel next to a strongly coloured clipped highlight (the blue sample
at an orange sun's rim, a neon tube's edge) had its interpolated channels
rebuilt from its weakest, measured channel, mostly with a neutral colour
where the content around was clipped: a dark checkerboard line just inside
the edge (public sunset ARW (2973, 1267): linear Y 0.874 -> 0.213). The
rebuild may now darken a pixel only to 0.8 of the luminance its
reconstruction told by value gives (highlight::CONTINUITY), else it keeps
the latter; it may brighten it by as much among strongly coloured content,
and further among pale content (a white sky behind twigs, where the value
keeps the demosaic's cyan and magenta). That pixel is Y 0.874 again, the
neon's (1491, 1210) 0.912 (main 0.979, 52f6b7e8 0.287); no pixel of either
frame goes from Y > 0.8 to below 0.4 (52f6b7e8: 132 and 495). The Canon 80D
twigs stay dark. Treating only the channels with their own FROM bit as
unknown was tried: the mean colour spread around clipped areas went from
under 3 % to 8.5 % and X-Trans lifted dark lines, so the other
interpolated channel stays unknown with them.

P2. Build Smart Previews rebuilt a stale proxy from the session's source,
which is the old proxy's when it was decoded while the original was
offline: it kept the proxy. P2. A rebuilt proxy left the session's decoded
sources and rendered previews made from the old one. On storytold#1400 both are
covered by its machinery, which this commit uses instead of its own: jobs
read the original afresh (origin_ref), and a replaced proxy takes storytold#1400's
invalidation (a marker before the first change, the thumbnail clear at the
end of the run, decoded sources following the cache generation, late
results refused by generation). The tests below pass on it.

P2. A refresh rewrote a proxy whose other version came from a newer build
(look 5 / source 0 -> 4 / 1). Ages::stale reads both versions together and
leaves any proxy with a newer one alone; the folder markers only go up.
With storytold#850 on storytold#1400, a Compact proxy's encode version (`enc`) counts the
same way (smart::from_newer_build), staleness for the look includes an
older Compact encoding (storytold#850's is_stale), and the look marker keeps its two
versions, each never going back.

P2. Finite samples too large for the scaling (a float DNG of 1e37 at gains
64 : 1 : 1) overflowed. The scaling pass now also checks every sample: one
that is not finite, or whose magnitude times the largest gain (or divided
by the smallest) exceeds 1e30 (MAX_BALANCED), makes the mosaic, read
afresh, develop unbalanced. The MAX_GAIN doc no longer claims more.

P3. Docs: previews bin_factor can't bin are Bayer under about 4600 px and
X-Trans under about 5760 px on the long side (the 16 MP X-E1 changes).

Tests: coloured suns and tubes keep their brightness at the edges (every
method, phase and X-Trans), and a decoded F32 DNG of 1e37 develops
unbalanced and finite (1.5e28 at the extreme gains balanced and finite),
both failing on 52f6b7e8; proxies with a newer look or source version are
never rewritten and the markers stay, failing without this commit. Build
Smart Previews refreshes with the old proxy still cached, and a refreshed
proxy replaces the session's source, cached render and late results and
the reopened library's: these pass through storytold#1400's machinery.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 14, 2026
…on (storytold#1328 review)

Review of 6d8a2a67, now stacked on storytold#1400 (issue storytold#709):

storytold#1328's own cache invalidation (a per-photo refresh queue, a proxy epoch in
the sources' identity, and a rendered-cache clear through the cache object
the run started with) is gone. A raw decode refresh replaces a proxy
through storytold#1400's run: the marker before the first change, the clear at the
end through the invalidation that follows the library's folder, decoded
sources following the cache generation, the generation read before the
source, late results refused by generation and cache owner.

P2. Another library opened during a refresh left the rebuilt photo's old
thumbnail on disk for good (the refresh cleared a retired cache). storytold#1400's
invalidation clears the folder the library owns: reopened, the thumbnail
is the new proxy's (mean 76.6; it was 25.6, the old proxy's).

P2. A refresh that finished after a job took its old source but before it
read the generation let the job fill the cleared cache with the old
proxy's thumbnail. storytold#1400 reads the generation first and drops the job.

P2. A clear removed the disk files while holding the generation lock that
the app reads every frame (6.7 s for 100,000 files). That clear is storytold#1400's
too (its conversions, discards and look refreshes end with it), so the fix
is on storytold#1400 (739c2f02, the unlocked clear) and this branch builds on it.

P3. Docs: the protection from newer proxies holds for builds with the
guard; a build that knows only the look version still rewrites a look 4 /
source 1 proxy as look 5 without a source version.

Tests: another library opened during a refresh, a refresh between a job's
source and its generation, and the process ending in the middle of a
source refresh (child process) leave no old thumbnail; a run that
refreshes nothing keeps the thumbnails; a Lossless proxy records the raw
decode version and is rebuilt as Lossless, keeping unknown header fields
but not the old version. The first three fail with storytold#1400's folder clear,
generation order or marker taken out (25.6, 25.4 and 25.6 against about
77).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 14, 2026
…wer build (storytold#1328 review)

Review of 0accb271: a format mismatch bypassed the forward-version guard.
smart_run ORed Ages::stale with "stored format differs from the one to
build", so an ordinary Build Smart Previews (no format asked for) rebuilt
a Lossless proxy under the default Compact preference, or a Compact one
under a Lossless preference, with this build's older look or decode and
stamped its versions: (look + 1, 0), (look - 1, source + 1) and
(look + 1, source + 1) all became (5, 1) in the other format. The opening
refresh kept them already.

A usable proxy is now classified first: one from a newer build
(smart::from_newer_build: its look or source version, or a Compact
proxy's encode version from storytold#850, above this build's) is kept as
it is, in its stored format, whatever format is preferred or asked for,
and counted as newerKept in the result; only a current or older one is
considered for a format conversion. A deliberate downgrade is not offered
(Discard removes the proxy). Ages::stale uses the same check.
source_version stays a field the writer owns.

Rebased onto storytold#1400 at cf1c803, which brings main b3d392b (batch 33 and
storytold#850): LOOK_VERSION is 5 there (storytold#1340), so this build writes look 5 /
source 1 (and Compact enc 2), which a build from main at look 5 takes as
current; RENDER_CACHE_VERSION goes to 65 (main is at 62).

Test: proxies at those three version pairs (and a Compact proxy from a
newer encoding) survive the opening refresh and Build Smart Previews for
both stored formats under both preferences, and are reported as newerKept
(6 of the 12 version-pair cases were rewritten before; the encoding case
is rewritten without its check).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AlexChambers

Copy link
Copy Markdown
Contributor Author

Rebased onto main a4b53b2 (batch 35). Conflicts were in media.rs (main's face_preview_cut is kept alongside this PR's generation checks), lib.rs (the smart-preview interceptor now sits in run_typed and keeps main's typed command errors) and the Portuguese formats file (main's corrected duplicate-count string is kept). Engine, preview, ui-egui and web tests (1799), fmt, Clippy and cargo xtask parity pass.

@mattsivak, this was a force-push, in case #1492 needs to rebase onto it.

@AlexChambers

Copy link
Copy Markdown
Contributor Author

The FreeBSD failure on 5a97a2e isn't from this PR: both failing tests come from main and this branch doesn't touch them. The settings dialog test's click back to the automatic memory budget didn't apply, which left the process-wide budget at 1 GiB, and the Compare test that ran after it needed more than that. #1463, which contains all of this branch, passed the same job. Details are on #1424, which is fixing that test.

@AlexChambers
AlexChambers force-pushed the lossless-smart-previews branch from 5a97a2e to 4d97de8 Compare October 15, 2026 02:49
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 15, 2026
… downgrade a newer proxy (storytold#1328 review)

Review of 52f6b7e8:

P2. A pixel next to a strongly coloured clipped highlight (the blue sample
at an orange sun's rim, a neon tube's edge) had its interpolated channels
rebuilt from its weakest, measured channel, mostly with a neutral colour
where the content around was clipped: a dark checkerboard line just inside
the edge (public sunset ARW (2973, 1267): linear Y 0.874 -> 0.213). The
rebuild may now darken a pixel only to 0.8 of the luminance its
reconstruction told by value gives (highlight::CONTINUITY), else it keeps
the latter; it may brighten it by as much among strongly coloured content,
and further among pale content (a white sky behind twigs, where the value
keeps the demosaic's cyan and magenta). That pixel is Y 0.874 again, the
neon's (1491, 1210) 0.912 (main 0.979, 52f6b7e8 0.287); no pixel of either
frame goes from Y > 0.8 to below 0.4 (52f6b7e8: 132 and 495). The Canon 80D
twigs stay dark. Treating only the channels with their own FROM bit as
unknown was tried: the mean colour spread around clipped areas went from
under 3 % to 8.5 % and X-Trans lifted dark lines, so the other
interpolated channel stays unknown with them.

P2. Build Smart Previews rebuilt a stale proxy from the session's source,
which is the old proxy's when it was decoded while the original was
offline: it kept the proxy. P2. A rebuilt proxy left the session's decoded
sources and rendered previews made from the old one. On storytold#1400 both are
covered by its machinery, which this commit uses instead of its own: jobs
read the original afresh (origin_ref), and a replaced proxy takes storytold#1400's
invalidation (a marker before the first change, the thumbnail clear at the
end of the run, decoded sources following the cache generation, late
results refused by generation). The tests below pass on it.

P2. A refresh rewrote a proxy whose other version came from a newer build
(look 5 / source 0 -> 4 / 1). Ages::stale reads both versions together and
leaves any proxy with a newer one alone; the folder markers only go up.
With storytold#850 on storytold#1400, a Compact proxy's encode version (`enc`) counts the
same way (smart::from_newer_build), staleness for the look includes an
older Compact encoding (storytold#850's is_stale), and the look marker keeps its two
versions, each never going back.

P2. Finite samples too large for the scaling (a float DNG of 1e37 at gains
64 : 1 : 1) overflowed. The scaling pass now also checks every sample: one
that is not finite, or whose magnitude times the largest gain (or divided
by the smallest) exceeds 1e30 (MAX_BALANCED), makes the mosaic, read
afresh, develop unbalanced. The MAX_GAIN doc no longer claims more.

P3. Docs: previews bin_factor can't bin are Bayer under about 4600 px and
X-Trans under about 5760 px on the long side (the 16 MP X-E1 changes).

Tests: coloured suns and tubes keep their brightness at the edges (every
method, phase and X-Trans), and a decoded F32 DNG of 1e37 develops
unbalanced and finite (1.5e28 at the extreme gains balanced and finite),
both failing on 52f6b7e8; proxies with a newer look or source version are
never rewritten and the markers stay, failing without this commit. Build
Smart Previews refreshes with the old proxy still cached, and a refreshed
proxy replaces the session's source, cached render and late results and
the reopened library's: these pass through storytold#1400's machinery.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 15, 2026
…on (storytold#1328 review)

Review of 6d8a2a67, now stacked on storytold#1400 (issue storytold#709):

storytold#1328's own cache invalidation (a per-photo refresh queue, a proxy epoch in
the sources' identity, and a rendered-cache clear through the cache object
the run started with) is gone. A raw decode refresh replaces a proxy
through storytold#1400's run: the marker before the first change, the clear at the
end through the invalidation that follows the library's folder, decoded
sources following the cache generation, the generation read before the
source, late results refused by generation and cache owner.

P2. Another library opened during a refresh left the rebuilt photo's old
thumbnail on disk for good (the refresh cleared a retired cache). storytold#1400's
invalidation clears the folder the library owns: reopened, the thumbnail
is the new proxy's (mean 76.6; it was 25.6, the old proxy's).

P2. A refresh that finished after a job took its old source but before it
read the generation let the job fill the cleared cache with the old
proxy's thumbnail. storytold#1400 reads the generation first and drops the job.

P2. A clear removed the disk files while holding the generation lock that
the app reads every frame (6.7 s for 100,000 files). That clear is storytold#1400's
too (its conversions, discards and look refreshes end with it), so the fix
is on storytold#1400 (739c2f02, the unlocked clear) and this branch builds on it.

P3. Docs: the protection from newer proxies holds for builds with the
guard; a build that knows only the look version still rewrites a look 4 /
source 1 proxy as look 5 without a source version.

Tests: another library opened during a refresh, a refresh between a job's
source and its generation, and the process ending in the middle of a
source refresh (child process) leave no old thumbnail; a run that
refreshes nothing keeps the thumbnails; a Lossless proxy records the raw
decode version and is rebuilt as Lossless, keeping unknown header fields
but not the old version. The first three fail with storytold#1400's folder clear,
generation order or marker taken out (25.6, 25.4 and 25.6 against about
77).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 15, 2026
…wer build (storytold#1328 review)

Review of 0accb271: a format mismatch bypassed the forward-version guard.
smart_run ORed Ages::stale with "stored format differs from the one to
build", so an ordinary Build Smart Previews (no format asked for) rebuilt
a Lossless proxy under the default Compact preference, or a Compact one
under a Lossless preference, with this build's older look or decode and
stamped its versions: (look + 1, 0), (look - 1, source + 1) and
(look + 1, source + 1) all became (5, 1) in the other format. The opening
refresh kept them already.

A usable proxy is now classified first: one from a newer build
(smart::from_newer_build: its look or source version, or a Compact
proxy's encode version from storytold#850, above this build's) is kept as
it is, in its stored format, whatever format is preferred or asked for,
and counted as newerKept in the result; only a current or older one is
considered for a format conversion. A deliberate downgrade is not offered
(Discard removes the proxy). Ages::stale uses the same check.
source_version stays a field the writer owns.

Rebased onto storytold#1400 at cf1c803, which brings main b3d392b (batch 33 and
storytold#850): LOOK_VERSION is 5 there (storytold#1340), so this build writes look 5 /
source 1 (and Compact enc 2), which a build from main at look 5 takes as
current; RENDER_CACHE_VERSION goes to 65 (main is at 62).

Test: proxies at those three version pairs (and a Compact proxy from a
newer encoding) survive the opening refresh and Build Smart Previews for
both stored formats under both preferences, and are reported as newerKept
(6 of the 12 version-pair cases were rewritten before; the encoding case
is rewritten without its check).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AlexChambers

Copy link
Copy Markdown
Contributor Author

Rebased onto main (af4c5e1, after #1406). The only conflicts were translation catalog ends: main's catalog-import messages are kept with this PR's smart-preview keys. Source patches are unchanged.

Scoped build and tests (1808 passed), fmt, Clippy with -D warnings, parity, layers and the wasm check pass.

@AlexChambers
AlexChambers force-pushed the lossless-smart-previews branch from 4d97de8 to 3eada64 Compare October 15, 2026 10:11
mattsivak added a commit to mattsivak/lightcraft that referenced this pull request Oct 15, 2026
…once (storytold#1492)

The global SMART_WRITE lock is replaced by a per-proxy lock keyed by file name. smart_run
runs its jobs on export_parallelism lanes (the opening look refresh keeps one). The thumbnail
marker (Pending) is shared behind a mutex, a marker failure stops every lane, and a panic in
one photo fails that photo alone. storytold#1400's interruption tests now wait for the first proxy
instead of assuming photos finish in order.

cargo xtask ci: everything passes except lightcraft-pipeline
visualize::tests::all_masks_overlay_shows_every_visible_mask_at_once, which fails
identically on the base (PR storytold#1400 head cf1c803) and on main's FreeBSD CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mattsivak added a commit to mattsivak/lightcraft that referenced this pull request Oct 15, 2026
…b order; tests run several lanes (storytold#1492)

- Two lanes creating the same new shard folder no longer fail one photo with
  "File exists": AlreadyExists is accepted when the folder is there; a missing
  parent of the shard still fails.
- Failures are reported in job order (the selection's order), as the serial
  build did, not sorted by photo id.
- Under cfg(test), library.smartPreviews uses up to 4 lanes, so storytold#1400's
  end-to-end tests exercise the lanes on small CI runners too.
- The cancel test checks a tight bound, done == built, and no leftover temp files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 15, 2026
… downgrade a newer proxy (storytold#1328 review)

Review of 52f6b7e8:

P2. A pixel next to a strongly coloured clipped highlight (the blue sample
at an orange sun's rim, a neon tube's edge) had its interpolated channels
rebuilt from its weakest, measured channel, mostly with a neutral colour
where the content around was clipped: a dark checkerboard line just inside
the edge (public sunset ARW (2973, 1267): linear Y 0.874 -> 0.213). The
rebuild may now darken a pixel only to 0.8 of the luminance its
reconstruction told by value gives (highlight::CONTINUITY), else it keeps
the latter; it may brighten it by as much among strongly coloured content,
and further among pale content (a white sky behind twigs, where the value
keeps the demosaic's cyan and magenta). That pixel is Y 0.874 again, the
neon's (1491, 1210) 0.912 (main 0.979, 52f6b7e8 0.287); no pixel of either
frame goes from Y > 0.8 to below 0.4 (52f6b7e8: 132 and 495). The Canon 80D
twigs stay dark. Treating only the channels with their own FROM bit as
unknown was tried: the mean colour spread around clipped areas went from
under 3 % to 8.5 % and X-Trans lifted dark lines, so the other
interpolated channel stays unknown with them.

P2. Build Smart Previews rebuilt a stale proxy from the session's source,
which is the old proxy's when it was decoded while the original was
offline: it kept the proxy. P2. A rebuilt proxy left the session's decoded
sources and rendered previews made from the old one. On storytold#1400 both are
covered by its machinery, which this commit uses instead of its own: jobs
read the original afresh (origin_ref), and a replaced proxy takes storytold#1400's
invalidation (a marker before the first change, the thumbnail clear at the
end of the run, decoded sources following the cache generation, late
results refused by generation). The tests below pass on it.

P2. A refresh rewrote a proxy whose other version came from a newer build
(look 5 / source 0 -> 4 / 1). Ages::stale reads both versions together and
leaves any proxy with a newer one alone; the folder markers only go up.
With storytold#850 on storytold#1400, a Compact proxy's encode version (`enc`) counts the
same way (smart::from_newer_build), staleness for the look includes an
older Compact encoding (storytold#850's is_stale), and the look marker keeps its two
versions, each never going back.

P2. Finite samples too large for the scaling (a float DNG of 1e37 at gains
64 : 1 : 1) overflowed. The scaling pass now also checks every sample: one
that is not finite, or whose magnitude times the largest gain (or divided
by the smallest) exceeds 1e30 (MAX_BALANCED), makes the mosaic, read
afresh, develop unbalanced. The MAX_GAIN doc no longer claims more.

P3. Docs: previews bin_factor can't bin are Bayer under about 4600 px and
X-Trans under about 5760 px on the long side (the 16 MP X-E1 changes).

Tests: coloured suns and tubes keep their brightness at the edges (every
method, phase and X-Trans), and a decoded F32 DNG of 1e37 develops
unbalanced and finite (1.5e28 at the extreme gains balanced and finite),
both failing on 52f6b7e8; proxies with a newer look or source version are
never rewritten and the markers stay, failing without this commit. Build
Smart Previews refreshes with the old proxy still cached, and a refreshed
proxy replaces the session's source, cached render and late results and
the reopened library's: these pass through storytold#1400's machinery.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 15, 2026
…on (storytold#1328 review)

Review of 6d8a2a67, now stacked on storytold#1400 (issue storytold#709):

storytold#1328's own cache invalidation (a per-photo refresh queue, a proxy epoch in
the sources' identity, and a rendered-cache clear through the cache object
the run started with) is gone. A raw decode refresh replaces a proxy
through storytold#1400's run: the marker before the first change, the clear at the
end through the invalidation that follows the library's folder, decoded
sources following the cache generation, the generation read before the
source, late results refused by generation and cache owner.

P2. Another library opened during a refresh left the rebuilt photo's old
thumbnail on disk for good (the refresh cleared a retired cache). storytold#1400's
invalidation clears the folder the library owns: reopened, the thumbnail
is the new proxy's (mean 76.6; it was 25.6, the old proxy's).

P2. A refresh that finished after a job took its old source but before it
read the generation let the job fill the cleared cache with the old
proxy's thumbnail. storytold#1400 reads the generation first and drops the job.

P2. A clear removed the disk files while holding the generation lock that
the app reads every frame (6.7 s for 100,000 files). That clear is storytold#1400's
too (its conversions, discards and look refreshes end with it), so the fix
is on storytold#1400 (739c2f02, the unlocked clear) and this branch builds on it.

P3. Docs: the protection from newer proxies holds for builds with the
guard; a build that knows only the look version still rewrites a look 4 /
source 1 proxy as look 5 without a source version.

Tests: another library opened during a refresh, a refresh between a job's
source and its generation, and the process ending in the middle of a
source refresh (child process) leave no old thumbnail; a run that
refreshes nothing keeps the thumbnails; a Lossless proxy records the raw
decode version and is rebuilt as Lossless, keeping unknown header fields
but not the old version. The first three fail with storytold#1400's folder clear,
generation order or marker taken out (25.6, 25.4 and 25.6 against about
77).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 15, 2026
…wer build (storytold#1328 review)

Review of 0accb271: a format mismatch bypassed the forward-version guard.
smart_run ORed Ages::stale with "stored format differs from the one to
build", so an ordinary Build Smart Previews (no format asked for) rebuilt
a Lossless proxy under the default Compact preference, or a Compact one
under a Lossless preference, with this build's older look or decode and
stamped its versions: (look + 1, 0), (look - 1, source + 1) and
(look + 1, source + 1) all became (5, 1) in the other format. The opening
refresh kept them already.

A usable proxy is now classified first: one from a newer build
(smart::from_newer_build: its look or source version, or a Compact
proxy's encode version from storytold#850, above this build's) is kept as
it is, in its stored format, whatever format is preferred or asked for,
and counted as newerKept in the result; only a current or older one is
considered for a format conversion. A deliberate downgrade is not offered
(Discard removes the proxy). Ages::stale uses the same check.
source_version stays a field the writer owns.

Rebased onto storytold#1400 at cf1c803, which brings main b3d392b (batch 33 and
storytold#850): LOOK_VERSION is 5 there (storytold#1340), so this build writes look 5 /
source 1 (and Compact enc 2), which a build from main at look 5 takes as
current; RENDER_CACHE_VERSION goes to 65 (main is at 62).

Test: proxies at those three version pairs (and a Compact proxy from a
newer encoding) survive the opening refresh and Build Smart Previews for
both stored formats under both preferences, and are reported as newerKept
(6 of the 12 version-pair cases were rewritten before; the encoding case
is rewritten without its check).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AlexChambers

Copy link
Copy Markdown
Contributor Author

I kept main's thumbnail migration and deferred writer alongside the preview namespace and unlocked clear; the regression fixtures now use .lcthumb names and distinguish cache metadata from build markers. Main's Move Photos dialog and ID validation remain, and locale conflicts retain only this PR's own keys, with a shorter Georgian title. Rebased onto main 0da998f2. On that base, scoped build and complete touched-crate tests, formatting, Clippy with warnings denied, parity, layers and assets pass, as does the scoped WebAssembly check.

AlexChambers and others added 4 commits November 6, 2026 02:48
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…atch-edit recipes, panic lints in every crate root) (storytold#709)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	crates/ui-egui/locales/cs-formats.json
#	crates/ui-egui/locales/cs.json
#	crates/ui-egui/locales/de-formats.json
#	crates/ui-egui/locales/de.json
#	crates/ui-egui/locales/es-formats.json
#	crates/ui-egui/locales/es.json
#	crates/ui-egui/locales/fi-formats.json
#	crates/ui-egui/locales/fr-formats.json
#	crates/ui-egui/locales/fr.json
#	crates/ui-egui/locales/id-formats.json
#	crates/ui-egui/locales/it-formats.json
#	crates/ui-egui/locales/it.json
#	crates/ui-egui/locales/ja-formats.json
#	crates/ui-egui/locales/ja.json
#	crates/ui-egui/locales/ka-formats.json
#	crates/ui-egui/locales/pl-formats.json
#	crates/ui-egui/locales/pl.json
#	crates/ui-egui/locales/pt-br-formats.json
#	crates/ui-egui/locales/pt-br.json
#	crates/ui-egui/locales/ru-formats.json
#	crates/ui-egui/locales/ru.json
#	crates/ui-egui/locales/sv-formats.json
#	crates/ui-egui/locales/uk-formats.json
#	crates/ui-egui/locales/uk.json
#	crates/ui-egui/locales/vi-formats.json
#	crates/ui-egui/locales/zh-hans-formats.json
#	crates/ui-egui/locales/zh-hans.json
#	crates/ui-egui/locales/zh-hant-formats.json
#	crates/ui-egui/locales/zh-hant.json
#	crates/ui-egui/src/app/frame.rs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(test) (storytold#709)

Main now denies unwrap_used in the engine's crate root (storytold#2170). Clippy's allowance for tests recognised neither cfg(all(test, ...)) nor these module names, so the wasm32 exclusion moves to its own attribute.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Nov 6, 2026
; render cache stays 83)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/parity-checklist.md
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Nov 6, 2026
; render cache stays 83)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Nov 6, 2026
; render cache stays 83)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AlexChambers

Copy link
Copy Markdown
Contributor Author

Refreshed #1400 again on top of Alex's Windows fix (bdb352758). New head 9be61f085.

Merged current main (ba282d363, then 472560b30) as normal merges.

  • Locales: main added entries in every language (cs, fi, id, it, ka, pl, sv and vi among them). Each locale and its -formats.json keeps main's new entries and this branch's new keys, with no key from either side lost and no clash. The files keep main's order and formatting.
  • app/frame.rs keeps both imports (smart_previews and main's startup).
  • The parity summary is recounted.
  • Main now denies unwrap_used in the engine's crate root (never-crash: deny the panic lints in every crate root; GPU asserts become fail paths (#2137) #2170). Clippy's allowance for tests didn't cover four smart preview test modules declared cfg(all(test, not(target_arch = "wasm32"))). Their wasm32 exclusion is now a separate attribute after #[cfg(test)] (9be61f085).

No version constants change.

Full local cargo xtask ci at 9be61f085, which includes the ui-egui locale and i18n tests: fmt, Clippy (--all-targets) and HEIF pass. Three tests fail the same way on clean main: tests_light::v1_and_v2_render_as_before_v3, wire::tests::wire_job_renders_like_the_engine and dialog_role::settings_is_a_dialog_too (no Georgian glyph without craft-fonts). slow_drive::a_reopen_waits_for_what_the_log_thread_could_not_write also failed once in the full run. It passed three times out of three alone on this head and on main 472560b30, and in #1463's full run, which contains this branch. Doctests, parity, layers, assets and wasm pass.

…hdrawn, DxO Kelvin white balance, Lightroom import masks) (storytold#709)

The view render keys in media/session.rs keep both this branch's cache generation and main's decoder key.
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Nov 8, 2026
; render cache stays 83)

The LR-IMP-FORMATS row takes main's compressed ORF withdrawal wording and keeps this branch's white-balanced demosaic text.
@AlexChambers

Copy link
Copy Markdown
Contributor Author

Merged current main (b3b4998) into this branch. The conflict was in crates/engine/src/media/session.rs: main added the decoder key to the view render keys (#3916), and this branch added the cache generation in the same place, so both keys now feed the render key.

AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Nov 11, 2026
@AlexChambers

Copy link
Copy Markdown
Contributor Author

Merged current main (1a301fc) into this branch. Main brought jez's #3462 (process V8 Highlights/Shadows base and a faster GPU median) and #2661 (Lens Blur). The only conflict was the parity checklist's summary table, which I regenerated with cargo xtask parity --write. No version number changed: the branch takes main's LOOK_VERSION 13, RENDER_CACHE_VERSION 76 and catalog journal 13. cargo xtask ci passed locally except two tests. tests_light::v1_and_v2_render_as_before_v3 fails the same way on main 1a301fc on this machine. find_similar::stopping_leaves_the_view_alone_and_the_next_search_reads_only_the_rest failed once (10 reads, expected 12), then passed three single runs and a full ui-egui rerun on the same commit. That is the flaky test tracked in #3823 (fix in #3824), and this branch does not touch it.

…ened-library write guards) (storytold#709)

Main gives the thumbnail disk cache a write gate (storytold#3825, issue storytold#3240); this branch attaches the
cache in a namespace. The two are combined:

- attach_disk_cache_namespace takes the gate and sets it on the new cache, at library open and
  when the smart preview folder changes (Library::thumbs_gate).
- set_disk_cache_bytes keeps this branch's form: it only changes the budget of an attached cache
  and attaches nothing, so it needs no gate.
- DiskCache::clear checks the gate first and every 256 files, as on main, and still leaves the
  total unknown after a clear, as here. The clear that replaces an exhausted namespace at open
  gets the gate too.
- The new early return for an over-budget brush mask (security batch) fills in this branch's
  cache_generation and cache_owner.

No version constant changes: LOOK 13 and RENDER 76 come from main.
… size after a clear (storytold#709)

A clear leaves the disk cache's size unknown here, because a thumbnail written while it removes files outlives it. The test's checks on which files a closed gate keeps are unchanged.
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Nov 13, 2026
…brary write guards; render cache stays 84, source version 1)

The thumbnail cache conflicts are the ones storytold#1400 has with main, resolved the same way: the
namespaced cache takes main's write gate at open and at a smart preview folder change,
set_disk_cache_bytes attaches nothing, and the brush budget early return fills in the cache
identity fields.
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Nov 13, 2026
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Nov 13, 2026
@AlexChambers

Copy link
Copy Markdown
Contributor Author

I brought this branch up to date with main at fd0b914, which adds the security batch and the opened-library write guards (#3825). Main gives the thumbnail disk cache a write gate, so it leaves a library's folder alone while the path leads somewhere else. This branch attaches that cache in a namespace, so the two met in library.rs, media/cache.rs and preview/src/disk.rs. I combined them. attach_disk_cache_namespace now takes the gate and sets it on the new cache, both when a library opens and when the smart preview folder changes. set_disk_cache_bytes keeps this branch's form, which only changes the budget and attaches nothing, so it needs no gate. DiskCache::clear checks the gate as on main and still leaves the size unknown afterwards, as here. The clear that replaces an exhausted namespace at open gets the gate too. Two smaller follow-ups: the new early return for an over-budget brush mask fills in this branch's cache identity fields, and main's new gate test now expects an unknown size after a clear instead of zero, with its checks on which files the gate keeps unchanged. No version constants change, so LOOK 13 and RENDER 76 come from main. The full cargo xtask ci ran locally on macOS. fmt, clippy, heif, parity, layers, assets, roots, wasm and the doctests passed. The test step passed except tests_light::v1_and_v2_render_as_before_v3, which also fails on main (#3801), and main's gate test, which passes after the follow-up.

…arity paths after the craft-libs cutover, ArtCraft feature-name guards) (storytold#709)
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Nov 14, 2026
…; the parity checklist takes main's craft-libs paths)
# Conflicts:
#	crates/ui-egui/src/menus/menubar/tests.rs
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Nov 18, 2026
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Nov 18, 2026
storytold#3861's new test a_proxy_from_the_previous_look_version_is_stale calls
smart::is_valid, which this stack (storytold#1400) renamed to is_complete with the
same meaning. Use is_complete there so the merge builds.
storytold#3861's new test a_proxy_from_the_previous_look_version_is_stale calls
smart::is_valid, which this branch renamed to is_complete with the same
meaning. Use is_complete there so the merge builds.
Merge main to resolve the conflict with storytold#3469 (Enter Keywords), which split
LightcraftApp::run_typed into run_typed and run_command. The PR author asked
for this so the PR can be reviewed and merged (AGENTS.md rule 37). The
smart-preview intercept now starts run_command, so it also gets main's
selection-change counting.
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Nov 21, 2026
Brings in storytold#1400's merge of main, which resolves the conflict with storytold#3469
(Enter Keywords) in crates/ui-egui/src/app.rs. The PR author asked for this
so the PR can be reviewed and merged (AGENTS.md rule 37).

This branch has not been deployed

No deployments
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.

Smart previews render visibly different from the original (8-bit JPEG proxy: ΔE2000 mean 1.1–2.2, P99 4.4–8.6)

3 participants