Repository navigation
fix(ai): honour admin policy and leftover-RGB cutouts - #218
Merged
Merged
Conversation
A machine-wide ai.enabled: off policy used to paint Settings Off while leftover settings.ai.enabled still let the webview ONNX path download and run. The engine gate now applies the same overlay native IPC already enforced. Quick chroma-key and k-means ignored source alpha, so leftover RGB in transparent PNG pixels became a false subject or a second cluster. Transparent pixels are background. When the remaining opaque pixels never touch the frame, k-means keeps the cutout instead of dropping it. Inspector AI handlers refuse the master switch and map InferenceError copy. Enhance dialog user-facing text no longer uses em dashes; the four visual goldens are the caption colon only. Signed-off-by: Cursor Agent <cursoragent@cursor.com>
An unreadable organisation policy now turns AI off and shows a notice. Desktop webviews apply the overlay at startup, including auxiliary windows that do not wait for SettingsProvider. Quick k-means and auto use source alpha when the image has transparency, so an edge-touching cutout keeps the subject and soft anti-aliased edges keep partial alpha. Color vectorize palette reduction keeps distinct small hues in Oklab. Enhance preview copy is a full sentence. The visual fixture waits for the unsaved tab marker so the dirty-dot chrome is deterministic. Signed-off-by: Cursor Agent <cursoragent@cursor.com>
Palette preservation now ignores hues below 0.25% of samples (minimum 4 pixels) and, when a slot is needed, replaces the less common colour of the closest pair and merges its count. Photos and logos keep their dominant colours at 3 and 4 colours; the small blue triangle still survives. Quick/auto only uses the source alpha as the mask when a real share of pixels is fully transparent or much of the border is. Rounded screenshot corners still run segmentation. Signed-off-by: Cursor Agent <cursoragent@cursor.com>
Hue preservation now recounts palette slots by nearest-pixel assignment before it evicts, and on a remaining count tie it keeps the higher-chroma colour. Median-cut equal splits no longer replace the logo red with a pink blend at 3 colours. The small blue triangle still survives. Signed-off-by: Cursor Agent <cursoragent@cursor.com>
3 of 4 tasks
# Conflicts: # apps/desktop/src-tauri/src/policy.rs
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.
Lane
What and why
A school-lab
ai.enabled: offpolicy painted the Settings switch Off while leftoversettings.ai.enabled: truestill let the browser ONNX path download and run. Native IPC already refused; the webview gate did not. Quick background removal also treated leftover RGB in transparent PNG pixels as a subject, and k-means could drop an inset cutout when that leftover had similar luminance.This PR overlays the admin policy on the engine master switch, uses source alpha as the cutout mask when transparency is substantial (including partial alpha on soft edges), and makes inspector AI handlers refuse the user switch (not only the panel hide). Enhance dialog user-facing copy no longer uses em dashes.
Follow-up on the independent review of
ea05833, the re-review of76db63fcc, and the re-review ofa3c4d67ce:a = 0) are background; partial alpha stays. PASS..editor-tabs__dirty-dot. PASS.hasMeaningfulTransparencyno longer trips on anya < 255pixel. Alpha is the mask only when a real share of pixels isa = 0(8%) or much of the border is (40%). A 40x40 with 16 transparent corners still segments (256 subject pixels), matching master.Not applied: at 3 colours in the reds-blue-green sample, a 64 px blue still takes the slot that kept the red and dark-red quadrants (8192 px each) apart. A "do not evict a far-larger, distinct pair" rule would also refuse the logo's blue triangle: red vs the blended pink is itself above the 0.018 Oklab hue threshold (dist² about 0.033). Recount + chroma already keeps the logo red; collapsing two large distinct reds to keep a small blue remains the hue-preservation trade-off at k=3.
Related: #190, #197
Inventory (entry points, models, gating)
insertTraceGroupvarve-tracefirst; TSrasterTracefallback. Not ONNX.u2netp; optional u2net / isnet / …assertAiFeaturesEnabled+ policy overlay. AI-off falls back to Quick.aiEnabled/formatAiUserError.No new models, no cloud/network calls, no bundle growth. LICENSE, stable.json, and release-manifest.json are untouched.
Feature results
a=0Enhance goldens
Preview crop pixels unchanged. Import dirties the tab; the fixture waits for
.editor-tabs__dirty-dot. Other diffs vs master are the caption colon, inspector subpixel fields, and the dark scrollbar.Product decisions
onstill overrides a user's own off.Check command
pnpm verify:planthen targeted Tiers 0-2 for the touched packages. Websitetokens.test.tsempty-style / semantic-token failures are master (#215).After
5666d662f:packages/engine/src/rasterTrace.test.ts: 24 passed@varve/engine: 5628 passed, 19 skippedcargo test -p varve-trace: 78 passed; clippy-D warningscleanChecklist
git commit -s)