Lazy-load translations and batch selection deletion bookkeeping#2102
Merged
frankrousseau merged 2 commits intoJul 10, 2026
Conversation
All 15 translated locales were bundled eagerly into the main chunk: ~1.5 MB minified shipped to every user for languages they never open. Locales now load through dynamic imports — one chunk per language, registered via setLocaleMessage when setLocale asks for it. The main chunk drops from ~2.3 MB to 763 kB. English and its production-style overlays (en_nft, en_video-game) stay eager: en is the fallback locale and App.vue switches to the overlays synchronously. setLocale keeps its signature but returns a promise that resolves once the language is applied; a pending-language guard keeps a slow older chunk from overriding a newer switch. Also excludes .claude/ agent worktrees from vitest discovery (same hunk as on the audit-tests branch; merges cleanly).
deleteSelectedShots dispatched one deleteShot per selected shot: each commit paid three full list passes (cache.shots, cache.result, displayedShots), so deleting N shots from a list of M cost O(N×M) on top of the N HTTP calls. Assets had the identical pattern. The HTTP requests stay serial — no parallel hammering of the server — but the store bookkeeping now accumulates and lands in a single bulk mutation (REMOVE_SHOTS / REMOVE_ASSETS): one filter pass per list, one stats recompute, whatever the selection size. A finally block commits what the server actually deleted even when a request fails mid-loop, so the UI never desyncs on partial failure. Two deliberate behavior improvements over the sequential path: the displayed count is recomputed after pure removals (it previously went stale until the next search), and canceled flags are set before the assets stats recompute so canceled assets stop counting immediately. The shots spec pins bulk/sequential equivalence; both specs check the requests stay serial, the single commit, and the partial-failure path.
2c366a5 to
a8e3d7d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problems
deleteSelectedShotsdispatched onedeleteShotper selected shot, and each commit paid three full list passes (cache.shots,cache.result,displayedShots) — deleting N shots from a list of M cost O(N×M) of store work on top of the N HTTP calls.deleteSelectedAssetshad the identical pattern. A failure mid-loop also left no trace of what had already been deleted.Solutions
setLocaleMessagewhensetLocaleasks for it. The main chunk drops from ~2.3 MB to 763 kB. English and its production-style overlays (en_nft,en_video-game) stay eager sinceenis the fallback locale and App.vue switches to the overlays synchronously.setLocalekeeps its signature but returns a promise; a pending-language guard keeps a slow older chunk from overriding a newer switch.REMOVE_SHOTS/REMOVE_ASSETS): one filter pass per list and one stats recompute, whatever the selection size. Afinallyblock commits what the server actually deleted even when a request fails mid-loop, so the UI never desyncs on partial failure. Two deliberate improvements over the sequential path: the displayed count is recomputed after pure removals (it previously went stale until the next search), and canceled flags are set before the assets stats recompute so canceled assets stop counting immediately.Tests: bulk/sequential equivalence pinned for shots, serial requests asserted (
maxInFlight === 1), single-commit and partial-failure paths covered for both stores; lang spec extended with the lazy-load and rapid-switch cases. Full suite: 88 files, 1038 tests, 0 failures.