Repository navigation
feat(web): migrate semantic-warning banners onto --color-warning - #2203
Conversation
Green at
|
There was a problem hiding this comment.
Pull request overview
This PR advances the staged migration from raw Tailwind amber-* utilities to the semantic --color-warning token in the web app, focusing specifically on non-text warning surfaces (borders/background tints + one solid-fill).
Changes:
- Replaced
border-amber-*/bg-amber-*warning-semantic usages withborder-[var(--color-warning)]/*andbg-[var(--color-warning)]/*across multiple warning banners/callouts. - Updated the concentration-warning modal styling in
SpellbookPanelto use--color-warningfor border and the confirm button background. - Added a Playwright “unit” guard test to prevent the migrated sites from silently regressing back to raw
amber-*.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/web/src/features/notes/InboxPage.tsx | Migrates the disabled-provider warning border color to --color-warning. |
| apps/web/src/features/encounters/SpellbookPanel.tsx | Migrates concentration-warning modal border and confirm button background to --color-warning. |
| apps/web/src/features/encounters/RunSessionPage.tsx | Migrates multiple reconcile/sync warning banners’ border + bg tint to --color-warning. |
| apps/web/src/features/encounters/EncounterWhisperComposer.tsx | Migrates the composer warning border color to --color-warning. |
| apps/web/src/features/dashboard/HandoutsCard.tsx | Migrates handout reveal warning callout border + bg tint to --color-warning. |
| apps/web/src/features/admin/ResetRequestsCard.tsx | Migrates the reset-link disclosure border to --color-warning. |
| apps/web/src/features/admin/MembersPage.tsx | Migrates the invites-suspended banner border to --color-warning. |
| apps/web/src/features/admin/CampaignAuditPage.tsx | Migrates audit retention disclosure card border + bg tint to --color-warning. |
| apps/web/src/features/admin/AuditLogCard.tsx | Migrates audit retention policy callout border + bg tint to --color-warning. |
| apps/web/src/components/VisibleToPlayersBar.tsx | Migrates visible/hidden bars border + bg tint to --color-warning. |
| apps/web/src/components/EntityRevealDialog.tsx | Migrates irreversible-reveal warning callout border + bg tint to --color-warning. |
| apps/web/src/components/AudienceField.tsx | Migrates public-audience warning callout border + bg tint to --color-warning. |
| apps/web/e2e/tests/warning-token-migration.unit.spec.ts | Adds a source-scan guard test intended to pin the migrated sites to --color-warning. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3bd47ad085
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Two review findings on #2203: 1. Codex (P2): four of the sixteen "migrated" sites are cascade no-ops. index.css/nocturne.css are imported unlayered, which always beats a layered Tailwind utility (including arbitrary-value ones) regardless of specificity or source order. Measured with real Chromium against the actual compiled theme: - CampaignAuditPage.tsx:294 renders through <Card>, whose cf-card class carries an unlayered `background`/`border` shorthand (index.css) that wins outright over the arbitrary utility. - MembersPage.tsx:483 / InboxPage.tsx:700 carry cf-inset, same unlayered background/border shorthand, same effect. - SpellbookPanel.tsx:484's button carries `.btn`, whose unlayered `background: 0 0` (nocturne.css) resets it to fully transparent before `.btn-primary` ever applies anything; :hover/:active paint an unrelated accent-tinted color-mix() overlay instead, both before and after this migration. Adds warning-token-cascade.spec.ts (browser-backed, real getComputedStyle via renderCssFixture) that measures all 16 sites against the actual painted color rather than source text, documents the four known-inert sites precisely (KNOWN_INERT), and proves via a bare-utility reference fixture that the bug is the unlayered wrapper rule, not the utility class itself. Not fixed here — the fix is a design decision (unlayered semantic modifier vs an `!important` escape mirroring the existing MembersPage.tsx:1617 precedent) left for the coordinator per review. 2. Copilot: the source-string guard only asserted "at least one" occurrence of the migrated pattern per file, so a partial regression (one of several sites in the same file reverting to raw amber) could pass silently. VisibleToPlayersBar.tsx (2 sites) and RunSessionPage.tsx (3 sites) were exactly this shape. warning-token-migration.unit.spec.ts now asserts an exact occurrence COUNT per file. Verified by manually reverting one of two VisibleToPlayersBar sites to raw amber (including a different amber shade the banned-pattern regex doesn't match) and confirming the count assertion fails where the old "at least one" check would have passed. Copilot's SpellbookPanel.tsx:485 hover:bg-amber-500 finding is deferred: the button's base background is one of the four known-inert sites above, so fixing only the hover class would be an equally inert change pending the same design decision.
3bd47ad to
9aa55e4
Compare
Coordinator decision on #2203's review: neither an `!important` escape nor a new unlayered semantic modifier class belongs in a color migration PR — both are real design decisions. Revert CampaignAuditPage.tsx:294, MembersPage.tsx:483, InboxPage.tsx:700, and SpellbookPanel.tsx:484 to their original raw-amber classes (all four render identically either way, since none of them were actually painting --color-warning in the first place) rather than ship source that claims the token while painting --color-divider/--cf-card/ transparent. Tracked in follow-up issue #2208 with the full computed-style table, root-cause per site, and fix options. Updates both guard tests to the 12 sites that remain migrated and are confirmed effective: - warning-token-migration.unit.spec.ts: removes the 4 reverted entries, corrects SpellbookPanel.tsx's entry to its one remaining migrated declaration (the modal border), and rewrites the docstring to describe what actually happened rather than a still-open question. - warning-token-cascade.spec.ts: drops KNOWN_INERT and the reference-fixture diagnostics (no longer needed once the inert sites are gone) and becomes a straightforward regression guard for the 12 sites that do paint the token.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f171db24fa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Twelve components used raw amber-* Tailwind utilities for genuinely semantic warning state (visibility/audience disclosures, sync-conflict banners, audit-retention notices, a "shown once" caution, a concentration-warning confirm) instead of resolving through --color-warning (#1533). Only the non-text roles (border, background tint, and one near-exact-value solid fill) are migrated here -- --color-warning is a single flat hex, unlike --color-danger's multi-role family, so it has no text-safe or dark-muted-surface variant; those roles and every decorative/selection use of amber are left alone (see PR description for the full excluded population). Contrast measured in a real Chromium canvas against this app's actual compiled theme (Tailwind v4 ships oklch, not hex, so amber-600 and --color-warning are close but not byte-identical): every migrated text-bearing site is unchanged or slightly improved (8.8-13.7:1), decorative border contrast (already below 3:1 pre-existing) moves by well under half a ratio point. Adds a guard test pinning the migrated sites so they cannot silently regress back onto raw amber.
Two review findings on #2203: 1. Codex (P2): four of the sixteen "migrated" sites are cascade no-ops. index.css/nocturne.css are imported unlayered, which always beats a layered Tailwind utility (including arbitrary-value ones) regardless of specificity or source order. Measured with real Chromium against the actual compiled theme: - CampaignAuditPage.tsx:294 renders through <Card>, whose cf-card class carries an unlayered `background`/`border` shorthand (index.css) that wins outright over the arbitrary utility. - MembersPage.tsx:483 / InboxPage.tsx:700 carry cf-inset, same unlayered background/border shorthand, same effect. - SpellbookPanel.tsx:484's button carries `.btn`, whose unlayered `background: 0 0` (nocturne.css) resets it to fully transparent before `.btn-primary` ever applies anything; :hover/:active paint an unrelated accent-tinted color-mix() overlay instead, both before and after this migration. Adds warning-token-cascade.spec.ts (browser-backed, real getComputedStyle via renderCssFixture) that measures all 16 sites against the actual painted color rather than source text, documents the four known-inert sites precisely (KNOWN_INERT), and proves via a bare-utility reference fixture that the bug is the unlayered wrapper rule, not the utility class itself. Not fixed here — the fix is a design decision (unlayered semantic modifier vs an `!important` escape mirroring the existing MembersPage.tsx:1617 precedent) left for the coordinator per review. 2. Copilot: the source-string guard only asserted "at least one" occurrence of the migrated pattern per file, so a partial regression (one of several sites in the same file reverting to raw amber) could pass silently. VisibleToPlayersBar.tsx (2 sites) and RunSessionPage.tsx (3 sites) were exactly this shape. warning-token-migration.unit.spec.ts now asserts an exact occurrence COUNT per file. Verified by manually reverting one of two VisibleToPlayersBar sites to raw amber (including a different amber shade the banned-pattern regex doesn't match) and confirming the count assertion fails where the old "at least one" check would have passed. Copilot's SpellbookPanel.tsx:485 hover:bg-amber-500 finding is deferred: the button's base background is one of the four known-inert sites above, so fixing only the hover class would be an equally inert change pending the same design decision.
Coordinator decision on #2203's review: neither an `!important` escape nor a new unlayered semantic modifier class belongs in a color migration PR — both are real design decisions. Revert CampaignAuditPage.tsx:294, MembersPage.tsx:483, InboxPage.tsx:700, and SpellbookPanel.tsx:484 to their original raw-amber classes (all four render identically either way, since none of them were actually painting --color-warning in the first place) rather than ship source that claims the token while painting --color-divider/--cf-card/ transparent. Tracked in follow-up issue #2208 with the full computed-style table, root-cause per site, and fix options. Updates both guard tests to the 12 sites that remain migrated and are confirmed effective: - warning-token-migration.unit.spec.ts: removes the 4 reverted entries, corrects SpellbookPanel.tsx's entry to its one remaining migrated declaration (the modal border), and rewrites the docstring to describe what actually happened rather than a still-open question. - warning-token-cascade.spec.ts: drops KNOWN_INERT and the reference-fixture diagnostics (no longer needed once the inert sites are gone) and becomes a straightforward regression guard for the 12 sites that do paint the token.
…fallback" Codex (P2, warning-token-cascade.spec.ts:118): the previous version asserted only `computed !== --color-divider` / `!== --cf-card` — the two known no-op fallback colors this same review round found. That is the identical structural flaw one level up from what this spec exists to catch: if a future Tailwind change stopped emitting `border-[var(--color-warning)]/N`, the element would fall back to `currentColor`/`transparent`, neither of which equals the two excluded values, so the old assertion would keep passing with zero sites actually painting warning. Verified the failure mode directly: rendering a site's markup with a nonexistent utility class in place of the real one resolves to `currentColor` (rgb(233,233,237) here) — the old `!== --color-divider` check does not catch it, the new equality check does. Rewrote to assert EXACT equality against an independently-derived expected color: `color-mix(in oklab, var(--color-warning) N%, transparent)`, built from the live --color-warning custom property (never hardcoded) and evaluated on an element that never carries the Tailwind utility class at all, so it does not depend on Tailwind having emitted anything for the comparison to be meaningful. Verified empirically that this independently-constructed expression is byte-identical (canvas-normalized RGBA) to Tailwind's own compiled output across every opacity step used (5/10/30/35/40/50%) — both route through the same browser color-mix() primitive with the same inputs, so zero tolerance is used rather than a loose one that would risk admitting the currentColor/transparent fallback this check exists to catch. Re-checked warning-token-migration.unit.spec.ts's requiredPatterns (already exact-count, not "at least one" — fixed last round) and bannedPatterns (a legitimate negative source-text pin, not a correctness proxy) for the same shape; neither needed a change.
f171db2 to
fd10021
Compare
Fixes #2161
What
Migrates 12 raw
amber-*Tailwind call sites, across 9 components, that render genuinely semantic warning state onto--color-warning(defined in #1533, previously referenced by only 4 sites total). This is a staged, non-text-only migration, not the full sweep — see "Deliberately excluded" below and the issue's own required staging decision.This PR originally migrated 16 sites. Review found 4 of them were cascade no-ops — see "Cascade issue found and reverted" below. Those 4 were reverted to raw amber rather than shipped with source that claims
--color-warningwhile painting something else, and are tracked in follow-up issue #2208.Re-measurement (issue's first checklist item)
grep -rn "amber-" apps/web/src --include="*.tsx" --include="*.ts" | grep -v '\.spec\.\|\.test\.'at this PR's original base commit (88e8175f4) found 152 rawamber-*call sites across 63 files (the issue's original "126 amber-*" figure was stale, consistent with every other re-measurement in this backlog). Of those, only a minority are genuinely semantic-warning; most are decorative (icon/avatar accents, "amber-mosquito" icon slug, natural-20 crit flourish, section-heading brand color) or selection-state highlights, not warning.Why only 12 of ~152
--color-warning: #d97706(#1533) is a single flat hex, unlike--color-danger's multi-role family (--color-danger,--color-danger-solid*,--color-danger-border,--color-danger-focus,--color-danger-ghost-*,--color-danger-disabled-*). I was told not to invent new token family members, so I could only move the border/background-tint role the existing single value actually covers safely.Left untouched, and why:
text-amber-300/400/100/200etc.) at every site —--color-warninghas no text-safe tonal variant the way--color-dangerdoes, and swapping text color requires a contrast re-measurement I can't safely eyeball. Recommend a--color-warning-text/-solid/-borderfamily mirroring danger's, as tracked follow-up, not invented here.bg-amber-950/*—StaleWriteConflict.tsx:64,SpellbookPanel.tsx:260's concentration banner,QuickRollButtons.tsx:205):amber-950is much darker than--color-warning; swapping would visibly lighten the surface. Different role, not covered.text-[10px] font-bold text-amber-500 uppercase tracking-widest+cf-inset border-amber-500/30), repeated acrossStorageCard.tsx,TokensCard.tsx,UsersCard.tsx,RulePacksCard.tsx,AiConsoleCard.tsx,AiPricingEditor.tsx,MembersPage.tsx(862-863, 1612-1617): these are card titles ("New token", "Orphan cleanup", "Install a rule system"), not caution messages — amber is being used as a generic "highlighted subsection" brand accent here, inconsistently, across both warning and non-warning content. That inconsistency is itself the kind of drift Design system: migrate raw amber/slate/rose Tailwind colors used for semantic warning state onto --color-warning #2161 is about, but fixing it means componentizing a shared "admin callout" pattern and making an explicit semantic call per site — out of scope for this PR; flagging as a follow-up candidate rather than guessing site-by-site.OidcCard.tsx:333,340: identicalcf-inset border-amber-500/30 ... text-amber-300/90recipe used for one informational notice (env-var override) and one genuine caution (no e2e-verified login). Migrating one but not the other would leave two identically-styled boxes silently diverging — excluded both, flagged for a follow-up review of that one file.InventoryPage.tsx/inventoryShared.tsx/MyNotesPage.tsx:1073: text-only amber on a neutral (var(--color-neutral-800)) background, no border/bg-tint role to move without touching text.QuickRollButtons.tsx:205: base +hover:bg-amber-900/40+focus:ring-amber-400+text-amber-300on a dark-muted surface) — too many roles to move partially without an actual--color-warning-*family.NewCharacterForm.tsx:230,243(has-[:checked]:border-amber-600/60): a radio-selection highlight, not a warning — decorative, correctly out of scope per the issue's own guidance.slate-*orrose-*sites were touched at all — re-checked every candidate and every one was either neutral chrome (slate) or an unrelated danger/error state (rose), not warning.Cascade issue found and reverted
Review (Codex) found that
CampaignAuditPage.tsx:294renders through<Card>, whosecf-cardclass carries an unlayeredbackground/bordershorthand (index.css:1254-1257) that always wins over a layered Tailwind utility (including an arbitrary-value one likeborder-[var(--color-warning)]/30) regardless of specificity or source order —index.css/nocturne.cssare imported unlayered. Measuring with real ChromiumgetComputedStyleagainst the actual compiled theme found three more sites with the same bug that Codex's report didn't cover:CampaignAuditPage.tsx:294--color-divider--cf-card<Card>'s unlayeredcf-cardruleMembersPage.tsx:483--color-dividercf-inset's unlayered ruleInboxPage.tsx:700--color-dividercf-inset's unlayered ruleSpellbookPanel.tsx:484.btn's unlayeredbackground: 0 0resetFor each, the bare utility class alone (no
Card/cf-inset/.btnwrapper) against the same backdrop does resolve to--color-warning— confirming the bug is the unlayered wrapper rule, not the utility class. This also corrects an earlier contrast claim I made: I'd reportedSpellbookPanel.tsx:484's white-on-button contrast as 3.20:1 → 3.19:1, assuming a solid amber/warning fill. That fill was never actually painted — the real background is the modal'sbg-neutral-900, so the real contrast is 14.15:1.Decision: reverted all 4 to raw amber rather than fixed in this PR. Both realistic fixes are design decisions, not mechanical ones: an
!importantescape (a narrow precedent already exists atMembersPage.tsx:1617, but spreading it is exactly the kind of design-system bypass #1533 exists to stop) or a new unlayered semantic modifier class (.cf-card--warning,.cf-inset--warning,.btn-warningmirroring the existing.btn-dangerpattern) — the latter needs its own review, not a rider on a color migration. Filed as #2208 with the full measurement table, options, and the four sites to re-migrate once a pattern is chosen.Sites migrated (12, across 9 files) — all confirmed to actually paint
--color-warningAudienceField.tsx:61border-amber-500/30 bg-amber-500/10→border-[var(--color-warning)]/30 bg-[var(--color-warning)]/10EntityRevealDialog.tsx:64HandoutsCard.tsx:295VisibleToPlayersBar.tsx:95,113border-amber-500/35 bg-amber-500/10→ warning equivalentRunSessionPage.tsx:4496,4520,4551border-amber-500/40 bg-amber-500/10→ warning equivalent (no amber text at these sites — full migration)EncounterWhisperComposer.tsx:65border-amber-500/30→ warning (border only; title text and focus ring stay raw amber, no covered role)AuditLogCard.tsx:173border-amber-500/30 bg-amber-500/5→ warning equivalentResetRequestsCard.tsx:117border-amber-500/30→ warning (border only; heading stays raw amber)SpellbookPanel.tsx:463border-amber-500/50→ warning (modal border)Contrast evidence
Measured with real Chromium (
playwright-core, headless, canvasfillStyle+getImageData) against this app's actual compiled theme — Tailwind v4 ships its palette asoklch(), not hex, which matters for anyone assuming a same-family swap is a no-op.Text-bearing sites (background changed, text unchanged) — WCAG 1.4.3 (binding criterion):
text-amber-400/90)text-amber-300/90)text-amber-100)text-amber-200/80)text-amber-200)Every migrated text-bearing site is unchanged-to-slightly-improved; none approaches the 4.5:1 AA floor either before or after.
Decorative border-only sites (non-text framing; the actual warning content is conveyed by text inside, not the border): border-vs-backdrop contrast was already below the WCAG 1.4.11 3:1 non-text floor before this PR (1.74-2.78:1 across the 30/35/40/50% opacity steps used) and moves down by a further 0.2-0.6 with the new color (1.53-2.22:1). Flagging honestly rather than hiding it: this is a pre-existing, already-failing metric that gets marginally weaker, not a passing-to-failing regression, and fixing it is a different, unscoped problem (the border alone was never the sole conveyor of the warning — the text is).
Checked
apps/web/e2e/tests/control-surface-goldens.spec.ts(the repo's only golden/screenshot spec besides login/print) precisely rather than assuming: it navigates toRunSessionPage's route three times but everytoHaveScreenshot/measureBoxcall is scoped to aLocator(turn-workspace,encounter-vtt-header,.cf-vtt-panel-tabs) that doesn't contain any of the 12 changed sites. No pixel baseline needs updating or is invalidated by this PR.Guard tests
apps/web/e2e/tests/warning-token-migration.unit.spec.ts(source-scanning, cheap smoke check) — pins the migrated declaration at each of the 12 sites with an exact occurrence count per file (VisibleToPlayersBar.tsx: 2,RunSessionPage.tsx: 3) rather than "at least one," so a partial regression (one of several sites in a file reverting while others stay migrated) fails here. Verified this actually catches what a presence-only check would miss, including a reversion to a different amber shade the file'sbannedPatternsregex doesn't match. Its docstring now says plainly it's necessary but not sufficient — see next.apps/web/e2e/tests/warning-token-cascade.spec.ts(browser-backed, realgetComputedStyleviarenderCssFixture) — the check that actually proves each of the 12 sites paints--color-warningrather than just referencing it in source, which is what caught the 4 no-op sites above in the first place.Validation
npm run lint— clean (0 errors, 213 pre-existing warnings repo-wide, none new)npm run typecheck— cleannpm run test:unit:web -- e2e/tests/warning-token-migration.unit.spec.ts— 10/10 passnpx vite build(apps/web) — clean; used to extract the real compiled CSS/theme for every measurement above, including a second full rebuild after reverting the 4 no-op siteswarning-token-cascade.spec.tscould not be run through this sandbox's standardnpm run test:e2e— a pre-existing, documented environment limitation (no network path to fetch the pinned Chromium headless-shell revision the harness defaults to) that blocks the whole browser e2e tier here, not something specific to this file. Validated the identical measurement logic (same real compiled CSS, same DOM fixtures) via an equivalent ad hoc script using an explicit local Chromium binary (playwright-core+executablePath) — all 12 sites confirmed effective against that logic, including after the final revert. CI is authoritative for actually executing the spec.