Skip to content

refactor(FR-3078): use antd tokens directly, shrink the :root --token-* bridge#7800

Open
yomybaby wants to merge 1 commit into
worktree-csp-no-style-elementsfrom
csp-token-vars-to-antd-tokens
Open

refactor(FR-3078): use antd tokens directly, shrink the :root --token-* bridge#7800
yomybaby wants to merge 1 commit into
worktree-csp-no-style-elementsfrom
csp-token-vars-to-antd-tokens

Conversation

@yomybaby

@yomybaby yomybaby commented Jun 9, 2026

Copy link
Copy Markdown
Member

Resolves #7798 (FR-3078)

Follow-up to #7799. Migrates in-tree var(--token-*) consumers to the antd token directly and shrinks the :root CSS-variable bridge.

Why the bridge can't just be deleted

antd v6 native cssVar (--ant-*) is class-scoped, not :root — in @ant-design/cssinjs/util/css-variables.js the selector ends in .{cssVarKey}, applied only inside the React tree. So out-of-tree CSS (resources/webui.css styles body) cannot read --ant-*. The :root --token-* bridge therefore stays — but only for the tokens that out-of-tree CSS actually needs.

Changes

  • Migrate in-tree consumers (BAIBoard, FolderCreateModal/V2, SettingList, BAIModal) from var(--token-X) → antd token/theme directly (createStyles/createGlobalStyle already expose them). (The MainLayout scrollbar's invalid multi-fallback var() was fixed directly in the parent refactor(FR-3077): replace direct <style> elements with nonce-safe styling #7799, so it carries no var(--token-*) by the time this PR applies.)
  • SettingList's var(--token-fontWeightSuperStrong, 700) referenced a non-antd token that was never set, so it always rendered 700 → inlined.
  • Shrink CSSTokenVariables from the full-token loop to the only 4 tokens resources/webui.css reads (colorPrimary, colorBgBase, colorBgContainer, colorBorder); drop the dead --theme-logo-url (no consumer anywhere).

No in-tree var(--token-*) remains; behavior preserved.

Verification

scripts/verify.sh=== ALL PASS ===.

🤖 Generated with Claude Code

yomybaby commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • flow:merge-queue - adds this PR to the back of the merge queue
  • flow:hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has required the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions Bot added the size:M 30~100 LoC label Jun 9, 2026
@yomybaby yomybaby marked this pull request as ready for review June 9, 2026 10:24
Copilot AI review requested due to automatic review settings June 9, 2026 10:24
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for backend-ai-ui-coverage (./packages/backend.ai-ui)

Status Category Percentage Covered / Total
🔵 Lines 11.25% 558 / 4957
🔵 Statements 9.58% 621 / 6477
🔵 Functions 12.46% 137 / 1099
🔵 Branches 7.94% 503 / 6333
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/backend.ai-ui/src/components/BAIModal.tsx 0% 0% 0% 0% 23-705
Generated in workflow #1749 for commit 04b06d0 by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for react-coverage (./react)

Status Category Percentage Covered / Total
🔵 Lines 6.44% 1798 / 27916
🔵 Statements 5.23% 1994 / 38102
🔵 Functions 5.34% 300 / 5616
🔵 Branches 3.66% 1305 / 35641
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
react/src/components/BAIBoard.tsx 0% 0% 0% 0% 10-226
react/src/components/FolderCreateModal.tsx 0% 0% 0% 0% 41-219
react/src/components/FolderCreateModalV2.tsx 0% 0% 0% 0% 50-729
react/src/components/SettingList.tsx 0% 0% 0% 0% 24-231
react/src/components/MainLayout/MainLayout.tsx 0% 0% 0% 0% 46-429
Generated in workflow #1748 for commit 04b06d0 by the Vitest Coverage Report Action

Copilot AI 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.

Pull request overview

This PR reduces reliance on the legacy :root { --token-* } CSS-variable bridge by migrating in-React styling from var(--token-*) to Ant Design v6 tokens directly, while keeping a minimal :root bridge for the few remaining out-of-tree CSS consumers.

Changes:

  • Replaced in-tree var(--token-*) usages with token.* / theme.* in several React components and global styles.
  • Shrunk the CSSTokenVariables :root bridge to a minimal set of color tokens needed by out-of-tree CSS.
  • Removed the unused --theme-logo-url bridge output and its supporting plumbing.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
react/src/components/SettingList.tsx Removes reliance on an unset CSS variable for active tab font-weight (keeps effective behavior).
react/src/components/MainLayout/MainLayout.tsx Updates scrollbar global styles to use theme tokens directly; minimizes :root --token-* bridge.
react/src/components/FolderCreateModalV2.tsx Migrates modal form padding from var(--token-*) to token.* values.
react/src/components/FolderCreateModal.tsx Migrates modal form padding from var(--token-*) to token.* values.
react/src/components/BAIBoard.tsx Migrates board placeholder styling from CSS variables to token.* values.
packages/backend.ai-ui/src/components/BAIModal.tsx Replaces var(--token-colorBorder, ...) usage with direct token.colorBorder.

…-* bridge

The custom `:root { --token-*: ... }` bridge mirrored the whole antd token
set so CSS could read tokens via var(). antd's native cssVar can't replace
it for OUT-OF-TREE CSS (resources/webui.css styles `body`, outside antd's
class-scoped `--ant-*` vars), but almost every consumer is IN-TREE.

- Migrate all in-tree consumers (BAIBoard, FolderCreateModal[V2], SettingList,
  BAIModal, MainLayout scrollbar) from `var(--token-X)` to the antd token
  directly — createStyles/createGlobalStyle already expose `token`/`theme`.
- SettingList's `var(--token-fontWeightSuperStrong, 700)` referenced a
  non-antd token that was never set, so it always rendered 700 — inline it.
- Shrink CSSTokenVariables from the full-token loop to the only 4 tokens
  resources/webui.css actually reads (colorPrimary, colorBgBase,
  colorBgContainer, colorBorder), and drop the dead `--theme-logo-url`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30~100 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants