Repository navigation
Finish the AI setting: no model loads when AI is off - #190
Merged
Merged
Conversation
The master switch now fails closed on a corrupt or unreadable settings blob and stays on only for a missing key (fresh install). The three ONNX workers enforce the same snapshot the main thread sends. Lens Blur is hidden when AI is off. SAM2 Small decoder and both TrOCR parts are hash-verified even when the digest is stored as sha256. Co-authored-by: Kevin Arthur <K-Arthur@users.noreply.github.com>
Constructing ModelLoader used to HEAD bundled .onnx files and fetch the catalog even after downloads were gated. Those probes now no-op when AI is off so no model file is requested.
DownloadManager's registerModel wants the core catalog type, so the integration test now only calls startDownload. The hash audit accepts optional JSON fields from the on-disk manifest.
verify:affected's format:touched lane rejected the worker import order and the AI-off Playwright spec wrapping. The Worker postMessage interceptor now matches both browser overloads.
format:touched still failed on engine barrel exports and two test wrappers. No behavior change.
Components that read the persisted AI gate from @varve/engine crashed in tests whose engine mock omitted that export. Face-crop and semantic search now keep the real gate (or a true stub). The open-file fixture uses an encoded document so the second-tab case can actually decode.
Home visual search, Object Selection, subject proposal, and export/batch cutout methods stayed clickable after the engine gate. They now hide and point to Settings so turning AI off is not just a failed download.
Control-bar and shortcut Remove background now use Quick when AI is off and no longer mention on-device ML. The native store treats only "true" as on. The engine gate honours the legacy settings key, caches reads, fails closed on a missing worker flag, and keeps configure/reset private. Home, Design-tab AI Tools, and Enhance stay honest: non-AI upscale remains usable, Asset Browser updates when the toggle changes.
The spec now fails if control-bar Remove background is missing, asserts Home / Design / Selection Sources / export / Quick mask, and records screenshots. Quick guidance no longer mentions AI Balanced when AI is off.
When AI features are off, Enhance keeps only CPU operations and presets, blocks the model download dialog, and shows the Settings hint. Auto can only resolve to a CPU method. Unit tests now refresh the gate cache after writing the setting, mock subscribeAiFeaturesEnabled, and skip the storage listener when window.addEventListener is missing. Playwright screenshots write to testInfo.outputDir (or VARVE_AI_SCREENSHOT_DIR) instead of a hard-coded artifacts path.
The AI-on Playwright assertion used a regex that treated the plus in Restore + Upscale as a quantifier, so a present option looked missing.
Preset options include descriptions, so an exact-label query missed Photo cleanup + upscale even though the list was open.
Operations use exact labels so Deblur does not also match Deblur + Upscale. Presets match the accessible name prefix because options include descriptions.
Packaged builds still report at 20s. Vite serves /src/main.tsx one file at a time, so a contended transform was replacing the splash with "Startup timed out" before React could mount. The crash-loop Home spec now uses the same navigation budget as the rest of the suite.
K-Arthur
marked this pull request as ready for review
October 23, 2026 11:00
3 tasks done
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.
Completes the AI gate from merged PR #162, plus the independent re-review of head
ec885612e.AI stays on for a fresh install (missing settings key). A corrupt or unreadable settings blob is treated as off and logged. The model-download host allowlist is unchanged. LICENSE,
stable.json, andrelease-manifest.jsonare not touched.Head:
7ced74e64. Merged currentmaster(e114771, #189) into this branch. Conflicts were onlyCHANGELOG.md(both Security entries kept) andpackages/editor/src/__tests__/openFileDedupe.test.tsx(master'sDocumentCodec.encode(createDocument(name))plus the extra helper comment). This PR's boot watchdog values andsafe-mode-counterloadHomehelper are unchanged. No user-visible UI changed in the merge, so the existing Enhance / Remove-background screenshots still apply.Re-review fixes
testInfo.outputDirorVARVE_AI_SCREENSHOT_DIR. No hard-coded/opt/cursor/artifacts/screenshots.subscribeAiFeaturesEnabled. Storage listeners skip whenwindow.addEventListeneris missing. Worker preflight jobs passaiEnabled: true.Turn on AI features in Settings to use this. CPU methods stay. With AI on, the previous model options stay.CI follow-up (
a5b647c62shard 12/24)tests/e2e/crash/safe-mode-counter.spec.tshit the 20s HTML boot watchdog ("Startup timed out / The application bundle loaded but never rendered") on a warm shard afterprivacy-network(79 other tests in that shard passed, including the next crash screenshot spec). This is the documented Vite-dev false timeout, not an AI-gate first-paint break./src/main.tsxnow extends that watchdog to 120s so a contended transform cannot replace the splash before React mounts.reload()between gotos.Visual evidence (real editor)
AI-off Enhance operations (Auto and Upscale only):
AI-off Enhance operations: Auto and Upscale only
AI-off Enhance presets (Recommended, Fast preview, Pixel art) plus the Settings hint:
AI-off Enhance presets without model presets
AI-off Enhance CPU methods (Pixel art, Fast, Balanced, Quality):
AI-off Enhance CPU upscale methods
AI-on Enhance still shows Denoise, Restore + Upscale, Deblur, Deblur + Upscale:
AI-on Enhance operations still include model options
AI-on Enhance still shows Photo cleanup + upscale and Photo AI upscale:
AI-on Enhance presets still include model presets
AI-off control-bar Remove background produces the Quick result:
AI-off control-bar Remove background Quick review
Other AI-off surfaces from the same Playwright run:
Home Assets hint
Design tab without AI Tools
Selection Sources without Select subject
Export dialog Quick only plus hint
Gate contract
aiobject: on[ai-gate]"true"only: on. Any other stored value: offai.enabled === false: offTests
8fec59bc6(implementation head): 22680 passed, 23 skipped, 0 failed. Mastereb1d23afdstill had the intendedopenFileDedupefixture failure; this branch keeps that fix. After merging Security policy, incident runbook and CI security scans #189, the helper matches master:DocumentCodec.encode(createDocument(name))(2 passed).revealMainWindow.test.ts7 passed (watchdog contract).tests/e2e/settings/ai-enhance-gate.spec.ts: 2 passed.tests/e2e/settings/ai-disabled-no-model-load.spec.ts: 1 passed.tests/e2e/crash/safe-mode-counter.spec.ts: 1 passed locally; CI E2E 24/24 green on42496687a.Test plan
eb1d23afd: 0 new failuresmastere114771and resolved both conflicts7ced74e64Checklist
git commit -s) once DCO is activeTo show artifacts inline, enable in settings.