Skip to content

[refactor] Teach the mobile app the shared theme vocabulary (13/13) - #5741

Draft
ardaerzin wants to merge 1 commit into
release/v0.111.0from
fe-refactor/mobile-shared-theme-tokens
Draft

[refactor] Teach the mobile app the shared theme vocabulary (13/13)#5741
ardaerzin wants to merge 1 commit into
release/v0.111.0from
fe-refactor/mobile-shared-theme-tokens

Conversation

@ardaerzin

@ardaerzin ardaerzin commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Context

@agenta/ui is Radix + cva since v0.109.0, so the mobile app could in principle drop its duplicate primitives and use the shared ones. It cannot. The shared components are written against the palette-derived vocabulary (bg-btn-default-bg, h-control, rounded-control), and mobile defines none of those names. Dropped in as-is, a shared Button renders as unstyled markup: 12 of its 75 classes produced any CSS.

The two definitions mobile needs, controlScale and shadcnTokens, used to live inside web/oss/tailwind.config.ts, private to a Tailwind v3 JS config that mobile (v4, CSS-first) cannot read. #5740 lifted them out into web/oss/src/styles/theme/, and that already sits in this base. This PR is the mobile half: teach mobile to read them.

Changes

Three files, all under web/mobile.

Mobile's token generator now imports controlScale and shadcnTokens and emits them into Tailwind v4's namespaces: colours as --color-*, geometry as --height-* / --width-* / --spacing-* / --radius-* / --text-*. It flattens the nested families the v3 config gets for free ({primary: {DEFAULT, hover}} becomes primary and primary-hover) and unions the contract with a scan of what the package actually references, so a component reaching for a raw antd token name resolves too.

Colour values come from theme-variables.css rather than palette.ts. A good share are antd-algorithm output (derived fills, preset tag ramps) that palette.ts cannot reproduce. Both files come from the same generator run, so this stays one source of truth.

globals.css gains the hand-written bridge for the button and state families (--color-btn-*, --color-error*, --color-disabled*, --color-focus-ring), pointing each at the generated palette variable. theme.generated.css is the generator's output, committed so the build does not depend on a codegen step.

Coverage: 176 of the 181 colour utilities @agenta/ui uses now resolve in mobile, and Button 71 of 75. Of the five remaining, three are the scan matching prose in comments. bg-opacity-10 and bg-opacity-20 are real. They are Tailwind v3 utilities removed in v4, which @agenta/ui will need to restate as bg-black/10 before whichever component uses them can cross over.

Tests / notes

  • Drift is now caught. Changing control from 28px to 29px in web/oss/src/styles/theme/controlScale.ts makes mobile's tokens:check fail, and reverting makes it pass. Previously mobile hand-copied those pixels, so a retune desynced the apps silently and a shared component rendered at different sizes per app.
  • pnpm --filter @agenta/mobile test: 15 files, 130 tests pass.
  • pnpm --filter @agenta/mobile lint (eslint plus tokens:check) passes.
  • The generated file was rebuilt against the base, so it now carries the tag-pink, tag-yellow, tag-volcano, tag-geekblue and tag-lime presets in both light and dark. An earlier revision of this branch predated them and would have shipped mobile a short token set.

No component is adopted here, and mobile does not depend on @agenta/ui yet. That comes next, together with the @source directive that lets Tailwind scan the package. It is deliberately not in this change, because scanning the package emits utilities for components nothing renders and takes the mobile CSS bundle from 40 KB to 110 KB. The token layer on its own costs 5 KB.

Nothing is user-visible, so there is nothing to QA. No mobile screen changes appearance.

@vercel

vercel Bot commented Aug 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Ready Ready Preview Aug 8, 2026 7:07am

Request Review

@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. refactoring A code change that neither fixes a bug nor adds a feature labels Aug 5, 2026
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d1359ff4-4824-4305-bba7-7b61bcc0c0ab

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Preview URL https://gateway-pr-5741.up.railway.app/w
Project agenta-oss-clone-spike
Image tag pr-5741-d642a0c
Status Deployed
Railway logs Open logs
Workflow logs View workflow run
Updated at 2026-08-05T10:59:31.563Z

@ardaerzin
ardaerzin force-pushed the feat/mobile-parity-and-consolidation branch 10 times, most recently from fa9fe83 to e6b4ff5 Compare August 5, 2026 23:09
@ardaerzin
ardaerzin changed the base branch from feat/mobile-parity-and-consolidation to release/v0.111.0 August 8, 2026 06:57
`@agenta/ui` is Radix + cva now, so the mobile app could in principle drop its duplicate
primitives and use the shared ones. It could not: the components are written against the
palette-derived vocabulary (`bg-btn-default-bg`, `h-control`, `rounded-control`), and mobile
defined none of those names. Dropped in as-is, a shared Button rendered as unstyled markup —
12 of its 75 classes produced any CSS.

The two definitions it needs both lived inside `web/oss/tailwind.config.ts`, private to a
Tailwind v3 JS config that mobile (v4, CSS-first) cannot read:

- `controlScale` — control geometry, now `src/styles/theme/controlScale.ts`
- `shadcnTokens` — the utility-name → CSS-variable contract the components are written
  against, now `src/styles/theme/shadcnTokens.ts`

Both are unchanged; the config imports them instead of declaring them. `shadcnTokens` already
described itself as one shared definition for the app and Storybook — mobile is the third
consumer.

Mobile's generator now reads both and emits them into Tailwind v4's namespaces: colours as
`--color-*`, geometry as `--height-*`/`--width-*`/`--spacing-*`/`--radius-*`/`--text-*`. It
flattens the nested families the v3 config gets for free (`{primary: {DEFAULT, hover}}` →
`primary`, `primary-hover`), and unions the contract with a scan of what the package actually
references, so a component that reaches for a raw antd token name resolves too.

Colour values come from `theme-variables.css`, not `palette.ts`: a good share are antd-algorithm
output (derived fills, preset tag ramps) that `palette.ts` cannot reproduce. Both files come from
the same generator run.

176 of the 181 colour utilities `@agenta/ui` uses now resolve in mobile, Button 71 of 75. Of the
rest, three are the scan matching prose in comments; `bg-opacity-10` and `bg-opacity-20` are real
— Tailwind v3 utilities removed in v4, which `@agenta/ui` will need to restate as `bg-black/10`
before whichever component uses them can cross over.

No component is adopted here and mobile does not depend on `@agenta/ui` yet. That comes next,
together with the `@source` directive that lets Tailwind scan the package — deliberately not in
this change, because scanning it emits utilities for components nothing renders and takes the CSS
bundle from 40 KB to 110 KB. The token layer on its own costs 5 KB.

Verified: retuning `controlScale` in the shared module makes mobile's `tokens:check` fail, and
reverting it makes the check pass — the drift this replaces used to be silent, and a shared
component would have rendered at different sizes per app. oss type-checks clean and its config
still resolves 148 colours with the `btn` family and `control` radii intact; mobile type-checks,
lints, builds, and its 121 tests pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring A code change that neither fixes a bug nor adds a feature size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant