Skip to content

Document dark-mode color token rule in AGENTS.md - #3748

Merged
sejas merged 1 commit into
trunkfrom
improve-agents-md-dark-mode-tokens
Jun 10, 2026
Merged

Document dark-mode color token rule in AGENTS.md#3748
sejas merged 1 commit into
trunkfrom
improve-agents-md-dark-mode-tokens

Conversation

@sejas

@sejas sejas commented Jun 9, 2026

Copy link
Copy Markdown
Member

Related issues

How AI was used in this PR

Claude Code analyzed the #3744 dark-theme fix, identified the root cause (renderer components used light-only --wpds-color-* tokens), and drafted the documentation guardrails. I reviewed the wording and scope myself before committing.

Proposed Changes

The Studio Code session UI shipped broken in dark mode because its CSS used --wpds-color-* tokens from @wordpress/ui, which carry hardcoded light fallbacks and don't respond to prefers-color-scheme: dark. Components looked correct in light mode, so the regression slipped through.

This documents the rule so contributors (and AI agents) don't reintroduce it:

  • Renderer CSS must use Studio's dark-aware --color-frame-* tokens for all colors; --wpds-color-* color tokens are banned. Non-color --wpds-* tokens (dimension, typography, border-width, elevation, cursor) remain fine.
  • UI/CSS changes must be verified in both light and dark schemes before being considered done.
  • Adds a CRITICAL pitfall entry referencing the regression for discoverability.

Docs-only change — no runtime impact.

Testing Instructions

  • Read AGENTS.md: confirm the new "Theming / colors (renderer CSS)" rule under Conventions, the dark-mode note in Post-Change Verification, and the "Dark Mode Color Tokens" entry under Common Pitfalls.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors? (N/A — docs only)
Require --color-frame-* tokens (dark-mode aware) over --wpds-color-*
for renderer CSS, and verify UI in both light and dark schemes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sejas sejas self-assigned this Jun 9, 2026
@sejas
sejas requested a review from nightnei June 10, 2026 06:57
@sejas
sejas marked this pull request as ready for review June 10, 2026 06:58

@wojtekn wojtekn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@sejas
sejas merged commit f057721 into trunk Jun 10, 2026
11 checks passed
@sejas
sejas deleted the improve-agents-md-dark-mode-tokens branch June 10, 2026 08:28
Comment thread AGENTS.md

**Files**: React components (PascalCase), utils (camelCase), tests (.test.ts/.tsx)
**Class names (`cx`)**: Use `cx()` (`apps/studio/src/lib/cx.ts`) only to join classes with conditions (e.g. `cx( 'base', isActive && 'active' )`). For a single static string, pass the bare string instead of wrapping it — `className="h-full"`, not `className={ cx( 'h-full' ) }`. Enforced (and auto-fixed) by the `studio/no-redundant-cx` ESLint rule (`tools/eslint-plugin-studio`).
**Theming / colors (renderer CSS)**: Studio supports light + dark via `@media (prefers-color-scheme: dark)`. For any **color** (text, background, border, fill, brand/theme, error/running states) **MUST** use Studio's dark-aware `--color-frame-*` tokens defined in `apps/studio/src/index.css` (e.g. `--color-frame-text`, `--color-frame-bg`, `--color-frame-surface`, `--color-frame-border`, `--color-frame-theme`, `--color-frame-error`). **NEVER** use `--wpds-color-*` tokens for color — they ship light-only fallbacks from `@wordpress/ui` and render broken (invisible text, wrong borders) in dark mode. Non-color `--wpds-*` tokens (`--wpds-dimension-*`, `--wpds-typography-*`, `--wpds-border-width-*`, `--wpds-elevation-*`, `--wpds-cursor-*`) are theme-independent and fine to use. When a needed color has no `--color-frame-*` token, add one (with both light and dark values) rather than reaching for `--wpds-color-*`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just nothing that this not true for all of studio and more precisely apps/ui. apps/ui uses a ThemeProvider for dark/light mode around the whole canvas which means we should do the opposite actually, always use --wpds variables because they adapt to the active theme.

@youknowriad youknowriad Jun 11, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should update this to specify that each "app" has its own dark mode rules as it doesn't feel worth our time to refactor apps/studio to use ThemeProvider as there's a chance that we'll replace it entirely.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I created a follow-up #3814

sejas added a commit that referenced this pull request Jun 12, 2026
- #3748 documented a blanket rule — always use `--color-frame-*`, never `--wpds-color-*` — but that only holds for `apps/studio`. In `apps/ui` the whole canvas is wrapped in a `ThemeProvider`, so `--wpds` variables adapt to the active theme and are exactly what should be used there (the agentic UI already uses them exclusively).
- This updates AGENTS.md so each app carries its own dark-mode rules, preventing agents and contributors from applying the `apps/studio`-only token guidance inside `apps/ui` (or vice versa). It also notes there's no plan to refactor `apps/studio` onto `ThemeProvider`, since it may be replaced entirely.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants