Consolidate the icon-color palette onto one shared module - #961
Merged
Conversation
The eight-colour brand palette existed in three places, with the hexes
duplicated a fourth time:
1. apps/server/src/server/static-theme.ts — VALID_ICON_COLORS id tuple
2. apps/web/src/hooks/use-icon-color.ts — ICON_COLORS id tuple, plus
ICON_COLOR_OPTIONS re-listing the same hexes as `swatch`
3. scripts/generate-icon-colors.ts — the same ids with primary/dark hexes
Adding a colour meant editing three files in two TS programs. All three now
derive from a new dependency-free apps/server/src/shared/icon-colors.ts
(the #844/#849 shared-module pattern), which holds the ids and both hex
channels in one ordered table.
Behaviour is unchanged: the tuple order (teal, blue, purple, red, orange,
amber, pink, cyan) is preserved exactly, so the Appearance settings swatch
order and the server's `iconColor must be one of: ...` error string are
byte-identical. Re-running the icon generator produces zero git diff.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The eight-colour brand icon palette lived in three places, with the hexes duplicated a fourth time. Adding a colour meant editing three files across two TS programs and hoping the lists stayed in sync.
apps/server/src/server/static-theme.ts:7VALID_ICON_COLORSid tuple +IconColortypeapps/web/src/hooks/use-icon-color.ts:4,22ICON_COLORSid tuple (byte-identical) andICON_COLOR_OPTIONSre-listing the same hexes asswatchscripts/generate-icon-colors.ts:25primary/darkhexesAll three now derive from a new dependency-free
apps/server/src/shared/icon-colors.tsholding the ids and both hex channels in one ordered table — the same#844/#849shared-module pattern already used for agent types, IDE types, media file types, anderrorMessage.static-theme.tskeeps exportingVALID_ICON_COLORS/IconColoras aliases, soserver.tsandstatic-theme.test.tsare untouched.use-icon-color.tskeeps exportingIconColorId/ICON_COLOR_OPTIONS, sosettings-pane.tsxandappearance-settings.tsxare untouched. Display labels stay web-side, mirroringAGENT_TYPE_LABELSinlib/agent-types.ts.generate-icon-colors.tsimports the palette directly.Why it's tech debt
Four copies of one table, spread across the server, the web app, and a root-level build script — pure maintenance drag with a real drift risk (the web
swatchhexes and the generator'sprimaryhexes have to agree or the settings preview stops matching the icon that actually ships).No behaviour change
iconColor must be one of: ...error string; both verified identical against the live dev stack.apps/web/public/icons/.POST /api/v1/agents/settingsstill rejects an unknown colour with the same message.Deliberately left alone
scripts/is not covered by any TS program.tsconfig.scripts.jsonincludesbin/**/*.tsonly, sogenerate-icon-colors.tsis never type-checked bypnpm run check. The new import was validated by running the script undertsxrather than by type-checking it. Widening theincludeis a separate change and out of scope here.ICON_COLORS(web) was deleted, not aliased. It had zero importers repo-wide — its only use was derivingIconColorIdinside its own file, which now comes from the shared module.VALID_ICON_COLORSdoes have importers, so it kept its alias.ICON_COLOR_LABELSis aRecord<IconColorId, string>, so TS still enforces exhaustiveness when a colour is added, but a UI string doesn't move into a server module.DEFAULT_ICON_COLORstays instatic-theme.ts— it's a server runtime default, not part of the palette table.Next run
Queued: the server↔web wire-type duplication cluster, largest being
apps/web/src/hooks/use-service-resources.ts(~180 lines mirroringobservability/service-resources.ts).Checks
pnpm run check·pnpm run finalize:web·pnpm run test:e2e(180 passed) · server vitest (2733 passed) · web vitest (898 passed) — all green.🤖 Generated with Claude Code