Brand kit: upload-time alpha sniff picks the sign-in mono-mask strategy from actual image bytes #316

Closed
opened 2026-08-06 21:36:44 +00:00 by ben · 1 comment
Owner

Follow-up from the S3 brand-kit polish arc (DDR 0130, commits 8ee9492/eead829 on private-standup-polish).

The sign-in preview renders the uploaded mark one-colour via a CSS mask. Root cause of the original missing-mark bug: default mask-mode: alpha recovers no shape from an opaque source. The shipped fix scopes a luminance-subtract mask to JPEG uploads (sniffed from the data URL mime — JPEG structurally cannot carry alpha) and keeps the plain alpha mask for everything else.

Residual, documented limitations (app/src/components/founding/FoundingBrandKit.vue, .oc-prev__logo--mono* comments):

  • a non-JPEG flat-opaque upload (PNG on a solid canvas) still degrades to a solid block;
  • a JPEG renamed .png keeps the alpha mask (mime is trusted, not bytes);
  • a light mark on a dark opaque JPEG renders inverted.

Durable fix: at logo-choice time the renderer already reads the file bytes (DDR 0124 byte carriage) — decode once (canvas/ImageBitmap), detect whether a real alpha channel with variance exists, and carry that fact with the draft so the preview (and any later consumer) picks alpha vs luminance masking from evidence instead of mime. Cheap at upload time; removes all three residual cases.

Worth folding in while in the file (deferred minor from the same arc): the --mono / --mono-opaque SCSS override relies on source order; the source-regex regression tests do not guard a reordering that silently kills the JPEG path — harden the selector or pin the order.

Follow-up from the S3 brand-kit polish arc (DDR 0130, commits `8ee9492`/`eead829` on `private-standup-polish`). The sign-in preview renders the uploaded mark one-colour via a CSS mask. Root cause of the original missing-mark bug: default `mask-mode: alpha` recovers no shape from an opaque source. The shipped fix scopes a luminance-subtract mask to JPEG uploads (sniffed from the data URL mime — JPEG structurally cannot carry alpha) and keeps the plain alpha mask for everything else. **Residual, documented limitations** (`app/src/components/founding/FoundingBrandKit.vue`, `.oc-prev__logo--mono*` comments): - a non-JPEG flat-opaque upload (PNG on a solid canvas) still degrades to a solid block; - a JPEG renamed `.png` keeps the alpha mask (mime is trusted, not bytes); - a light mark on a dark opaque JPEG renders inverted. **Durable fix:** at logo-choice time the renderer already reads the file bytes (DDR 0124 byte carriage) — decode once (canvas/ImageBitmap), detect whether a real alpha channel with variance exists, and carry that fact with the draft so the preview (and any later consumer) picks alpha vs luminance masking from evidence instead of mime. Cheap at upload time; removes all three residual cases. Worth folding in while in the file (deferred minor from the same arc): the `--mono` / `--mono-opaque` SCSS override relies on source order; the source-regex regression tests do not guard a reordering that silently kills the JPEG path — harden the selector or pin the order.
Author
Owner

Shipped in b3b7463 (on origin/main).

The sign-in mono-mask strategy is now picked from the logo's decoded bytes, not its mime string. On upload the renderer decodes the mark once (2-D canvas) and carries the verdict with the draft:

  • logoAlphaHasVariance — a real alpha channel with variance keeps the plain alpha mask;
  • deriveLogoMonoMask — an opaque source (flat PNG, any JPEG, a JPEG renamed .png) gets a luminance-derived mono mask whose alpha is each pixel's distance from the sampled background. Polarity-agnostic, so a light mark on a dark JPEG recovers too.

Both facts (BrandDraft.logoHasAlpha + logoMaskData) travel with the draft and survive resume; the sign-in masks from logoMaskData || logoData — one CSS mask strategy, retiring the source-order fragility of a second --mono override (the deferred minor). Where no 2-D canvas is offered (headless) it degrades to the mime heuristic + alpha mask, fail-soft.

All three residual cases from the issue are removed: opaque PNG, JPEG-renamed-.png, and the inverted light-on-dark JPEG.

Evidence: app/src/lib/founding.ts (pure detection/synthesis), app/src/components/founding/FoundingBrandKit.vue (decode glue + carry/consume). Red-first tests in app/tests/unit/founding.test.ts (alpha-variance true/opaque/veil; mask recovery both polarities) and app/tests/unit/foundingWizard.test.ts (upload records verdict; opaque draft masks from derived mask, alpha draft from source; Remove clears). vue-tsc + eslint clean; app suite 628 passed (unrelated pre-existing boot.test.ts needs Go on PATH).

Shipped in `b3b7463` (on `origin/main`). The sign-in mono-mask strategy is now picked from the logo's **decoded bytes**, not its mime string. On upload the renderer decodes the mark once (2-D canvas) and carries the verdict with the draft: - `logoAlphaHasVariance` — a real alpha channel *with variance* keeps the plain alpha mask; - `deriveLogoMonoMask` — an opaque source (flat PNG, any JPEG, a JPEG renamed `.png`) gets a luminance-derived mono mask whose alpha is each pixel's distance from the sampled background. Polarity-agnostic, so a **light mark on a dark JPEG** recovers too. Both facts (`BrandDraft.logoHasAlpha` + `logoMaskData`) travel with the draft and survive `resume`; the sign-in masks from `logoMaskData || logoData` — **one** CSS mask strategy, retiring the source-order fragility of a second `--mono` override (the deferred minor). Where no 2-D canvas is offered (headless) it degrades to the mime heuristic + alpha mask, fail-soft. All three residual cases from the issue are removed: opaque PNG, JPEG-renamed-`.png`, and the inverted light-on-dark JPEG. Evidence: `app/src/lib/founding.ts` (pure detection/synthesis), `app/src/components/founding/FoundingBrandKit.vue` (decode glue + carry/consume). Red-first tests in `app/tests/unit/founding.test.ts` (alpha-variance true/opaque/veil; mask recovery both polarities) and `app/tests/unit/foundingWizard.test.ts` (upload records verdict; opaque draft masks from derived mask, alpha draft from source; Remove clears). `vue-tsc` + `eslint` clean; app suite 628 passed (unrelated pre-existing `boot.test.ts` needs Go on PATH).
ben closed this issue 2026-08-06 21:58:58 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#316
No description provided.