Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
refactor(webv2): derive theme tokens from neutral ramps
joshistoastecc09d4917ba
diff --git a/invokeai/frontend/webv2/src/theme/__fixtures__/legacyTokenBaseline.json b/invokeai/frontend/webv2/src/theme/__fixtures__/legacyTokenBaseline.jsonnew file mode 100644index 0000000000..906dba0ba1--- /dev/null+++ b/invokeai/frontend/webv2/src/theme/__fixtures__/legacyTokenBaseline.json@@ -0,0 +1,237 @@+{+ "classic": {+ "bg": "oklch(21.074% 0.0087 264.37)",+ "bg.subtle": "oklch(26.279% 0.0123 264.34)",+ "bg.muted": "oklch(31.237% 0.0157 264.32)",+ "bg.panel": "oklch(31.237% 0.0157 264.32)",+ "bg.emphasized": "oklch(36.004% 0.019 264.3)",+ "bg.inset": "oklch(21.074% 0.0087 264.37)",+ "bg.error": "color-mix(in oklab, oklch(70.61% 0.0841 19.38) 14%, oklch(26.279% 0.0123 264.34))",+ "bg.success": "color-mix(in oklab, oklch(79.8% 0.1132 141.63) 14%, oklch(26.279% 0.0123 264.34))",+ "bg.warning": "color-mix(in oklab, oklch(76.62% 0.0612 62.9) 14%, oklch(26.279% 0.0123 264.34))",+ "fg": "oklch(96.017% 0.0029 264.54)",+ "fg.muted": "oklch(73.736% 0.0202 264.44)",+ "fg.subtle": "oklch(57.965% 0.0337 264.27)",+ "fg.grid": "oklch(40.619% 0.0221 264.29)",+ "fg.error": "oklch(70.61% 0.0841 19.38)",+ "fg.success": "oklch(79.8% 0.1132 141.63)",+ "fg.warning": "oklch(76.62% 0.0612 62.9)",+ "border": "oklch(40.619% 0.0221 264.29)",+ "border.subtle": "oklch(40.619% 0.0221 264.29)",+ "border.muted": "oklch(40.619% 0.0221 264.29)",+ "border.emphasized": "oklch(45.106% 0.0251 264.28)",+ "border.error": "oklch(70.61% 0.0841 19.38)",+ "gray.contrast": "oklch(21.074% 0.0087 264.37)",+ "gray.fg": "oklch(96.017% 0.0029 264.54)",+ "gray.subtle": "oklch(31.237% 0.0157 264.32)",+ "gray.muted": "oklch(36.004% 0.019 264.3)",+ "gray.emphasized": "oklch(45.106% 0.0251 264.28)",+ "gray.solid": "oklch(96.017% 0.0029 264.54)",+ "gray.focusRing": "oklch(77.738% 0.1 231.76)",+ "gray.border": "oklch(45.106% 0.0251 264.28)",+ "brand.solid": "oklch(92.041% 0.2103 116.59)",+ "brand.contrast": "oklch(21.074% 0.0087 264.37)",+ "brand.fg": "oklch(92.041% 0.2103 116.59)",+ "brand.subtle": "color-mix(in oklab, oklch(92.041% 0.2103 116.59) 16%, oklch(26.279% 0.0123 264.34))",+ "brand.muted": "color-mix(in oklab, oklch(92.041% 0.2103 116.59) 26%, oklch(26.279% 0.0123 264.34))",+ "brand.emphasized": "color-mix(in oklab, oklch(92.041% 0.2103 116.59) 36%, oklch(26.279% 0.0123 264.34))",+ "brand.focusRing": "oklch(77.738% 0.1 231.76)",+ "brand.border": "oklch(92.041% 0.2103 116.59)",+ "accent.solid": "oklch(77.738% 0.1 231.76)",+ "accent.contrast": "oklch(21.074% 0.0087 264.37)",+ "accent.fg": "oklch(77.738% 0.1 231.76)",+ "accent.subtle": "color-mix(in oklab, oklch(77.738% 0.1 231.76) 16%, oklch(26.279% 0.0123 264.34))",+ "accent.muted": "color-mix(in oklab, oklch(77.738% 0.1 231.76) 26%, oklch(26.279% 0.0123 264.34))",+ "accent.emphasized": "color-mix(in oklab, oklch(77.738% 0.1 231.76) 36%, oklch(26.279% 0.0123 264.34))",+ "accent.focusRing": "oklch(77.738% 0.1 231.76)",+ "accent.border": "oklch(77.738% 0.1 231.76)"+ },+ "light": {+ "bg": "oklch(96% 0.0038 264)",+ "bg.subtle": "oklch(99.4% 0.002 264)",+ "bg.muted": "oklch(97% 0.003 264)",+ "bg.panel": "oklch(97% 0.003 264)",+ "bg.emphasized": "oklch(93.5% 0.005 264)",+ "bg.inset": "oklch(96% 0.0038 264)",+ "bg.error": "color-mix(in oklab, oklch(55.509% 0.1707 24.62) 14%, oklch(99.4% 0.002 264))",+ "bg.success": "color-mix(in oklab, oklch(53% 0.15 150) 14%, oklch(99.4% 0.002 264))",+ "bg.warning": "color-mix(in oklab, oklch(60% 0.13 72) 14%, oklch(99.4% 0.002 264))",+ "fg": "oklch(22.5% 0.013 264)",+ "fg.muted": "oklch(45% 0.017 264)",+ "fg.subtle": "oklch(63% 0.014 264)",+ "fg.grid": "oklch(88.5% 0.0075 264)",+ "fg.error": "oklch(55.509% 0.1707 24.62)",+ "fg.success": "oklch(53% 0.15 150)",+ "fg.warning": "oklch(60% 0.13 72)",+ "border": "oklch(90.5% 0.0065 264)",+ "border.subtle": "oklch(90.5% 0.0065 264)",+ "border.muted": "oklch(90.5% 0.0065 264)",+ "border.emphasized": "oklch(84% 0.0095 264)",+ "border.error": "oklch(55.509% 0.1707 24.62)",+ "gray.contrast": "oklch(96% 0.0038 264)",+ "gray.fg": "oklch(22.5% 0.013 264)",+ "gray.subtle": "oklch(95.5% 0.005 264)",+ "gray.muted": "oklch(93.5% 0.005 264)",+ "gray.emphasized": "oklch(84% 0.0095 264)",+ "gray.solid": "oklch(22.5% 0.013 264)",+ "gray.focusRing": "oklch(54.615% 0.2152 262.88)",+ "gray.border": "oklch(84% 0.0095 264)",+ "brand.solid": "oklch(92.041% 0.2103 116.59)",+ "brand.contrast": "oklch(22.5% 0.013 264)",+ "brand.fg": "oklch(92.041% 0.2103 116.59)",+ "brand.subtle": "color-mix(in oklab, oklch(92.041% 0.2103 116.59) 16%, oklch(99.4% 0.002 264))",+ "brand.muted": "color-mix(in oklab, oklch(92.041% 0.2103 116.59) 26%, oklch(99.4% 0.002 264))",+ "brand.emphasized": "color-mix(in oklab, oklch(92.041% 0.2103 116.59) 36%, oklch(99.4% 0.002 264))",+ "brand.focusRing": "oklch(54.615% 0.2152 262.88)",+ "brand.border": "oklch(92.041% 0.2103 116.59)",+ "accent.solid": "oklch(54.615% 0.2152 262.88)",+ "accent.contrast": "oklch(100% 0 0)",+ "accent.fg": "oklch(54.615% 0.2152 262.88)",+ "accent.subtle": "color-mix(in oklab, oklch(54.615% 0.2152 262.88) 16%, oklch(99.4% 0.002 264))",+ "accent.muted": "color-mix(in oklab, oklch(54.615% 0.2152 262.88) 26%, oklch(99.4% 0.002 264))",+ "accent.emphasized": "color-mix(in oklab, oklch(54.615% 0.2152 262.88) 36%, oklch(99.4% 0.002 264))",+ "accent.focusRing": "oklch(54.615% 0.2152 262.88)",+ "accent.border": "oklch(54.615% 0.2152 262.88)"+ },+ "forest": {+ "bg": "oklch(17.349% 0.0154 144.88)",+ "bg.subtle": "oklch(19.03% 0.0175 144.85)",+ "bg.muted": "oklch(20.99% 0.0219 144.74)",+ "bg.panel": "oklch(20.99% 0.0219 144.74)",+ "bg.emphasized": "oklch(25.62% 0.03 144.64)",+ "bg.inset": "oklch(17.349% 0.0154 144.88)",+ "bg.error": "color-mix(in oklab, oklch(69.305% 0.1467 35.44) 14%, oklch(19.03% 0.0175 144.85))",+ "bg.success": "color-mix(in oklab, oklch(78% 0.16 148) 14%, oklch(19.03% 0.0175 144.85))",+ "bg.warning": "color-mix(in oklab, oklch(80% 0.12 76) 14%, oklch(19.03% 0.0175 144.85))",+ "fg": "oklch(90.57% 0.0511 134.45)",+ "fg.muted": "oklch(71.619% 0.0575 135.25)",+ "fg.subtle": "oklch(53.577% 0.0538 136.73)",+ "fg.grid": "oklch(34.825% 0.0526 141.63)",+ "fg.error": "oklch(69.305% 0.1467 35.44)",+ "fg.success": "oklch(78% 0.16 148)",+ "fg.warning": "oklch(80% 0.12 76)",+ "border": "oklch(27.425% 0.0354 143.04)",+ "border.subtle": "oklch(27.425% 0.0354 143.04)",+ "border.muted": "oklch(27.425% 0.0354 143.04)",+ "border.emphasized": "oklch(36.133% 0.0575 141.06)",+ "border.error": "oklch(69.305% 0.1467 35.44)",+ "gray.contrast": "oklch(17.349% 0.0154 144.88)",+ "gray.fg": "oklch(90.57% 0.0511 134.45)",+ "gray.subtle": "oklch(28.489% 0.0483 141.22)",+ "gray.muted": "oklch(25.62% 0.03 144.64)",+ "gray.emphasized": "oklch(36.133% 0.0575 141.06)",+ "gray.solid": "oklch(90.57% 0.0511 134.45)",+ "gray.focusRing": "oklch(70.437% 0.1101 178.23)",+ "gray.border": "oklch(36.133% 0.0575 141.06)",+ "brand.solid": "oklch(79.714% 0.1784 136.37)",+ "brand.contrast": "oklch(18.298% 0.0314 147.69)",+ "brand.fg": "oklch(79.714% 0.1784 136.37)",+ "brand.subtle": "color-mix(in oklab, oklch(79.714% 0.1784 136.37) 16%, oklch(19.03% 0.0175 144.85))",+ "brand.muted": "color-mix(in oklab, oklch(79.714% 0.1784 136.37) 26%, oklch(19.03% 0.0175 144.85))",+ "brand.emphasized": "color-mix(in oklab, oklch(79.714% 0.1784 136.37) 36%, oklch(19.03% 0.0175 144.85))",+ "brand.focusRing": "oklch(70.437% 0.1101 178.23)",+ "brand.border": "oklch(79.714% 0.1784 136.37)",+ "accent.solid": "oklch(70.437% 0.1101 178.23)",+ "accent.contrast": "oklch(17.44% 0.0258 171.89)",+ "accent.fg": "oklch(70.437% 0.1101 178.23)",+ "accent.subtle": "color-mix(in oklab, oklch(70.437% 0.1101 178.23) 16%, oklch(19.03% 0.0175 144.85))",+ "accent.muted": "color-mix(in oklab, oklch(70.437% 0.1101 178.23) 26%, oklch(19.03% 0.0175 144.85))",+ "accent.emphasized": "color-mix(in oklab, oklch(70.437% 0.1101 178.23) 36%, oklch(19.03% 0.0175 144.85))",+ "accent.focusRing": "oklch(70.437% 0.1101 178.23)",+ "accent.border": "oklch(70.437% 0.1101 178.23)"+ },+ "mono": {+ "bg": "oklch(18.22% 0 0)",+ "bg.subtle": "oklch(20.019% 0 0)",+ "bg.muted": "oklch(22.213% 0 0)",+ "bg.panel": "oklch(22.213% 0 0)",+ "bg.emphasized": "oklch(27.274% 0 0)",+ "bg.inset": "oklch(18.22% 0 0)",+ "bg.error": "color-mix(in oklab, oklch(71.115% 0.0934 19.64) 14%, oklch(20.019% 0 0))",+ "bg.success": "color-mix(in oklab, oklch(76% 0.06 150) 14%, oklch(20.019% 0 0))",+ "bg.warning": "color-mix(in oklab, oklch(79% 0.07 80) 14%, oklch(20.019% 0 0))",+ "fg": "oklch(93.1% 0 0)",+ "fg.muted": "oklch(71.547% 0 0)",+ "fg.subtle": "oklch(53.824% 0 0)",+ "fg.grid": "oklch(32.897% 0 0)",+ "fg.error": "oklch(71.115% 0.0934 19.64)",+ "fg.success": "oklch(76% 0.06 150)",+ "fg.warning": "oklch(79% 0.07 80)",+ "border": "oklch(28.908% 0 0)",+ "border.subtle": "oklch(28.908% 0 0)",+ "border.muted": "oklch(28.908% 0 0)",+ "border.emphasized": "oklch(34.846% 0 0)",+ "border.error": "oklch(71.115% 0.0934 19.64)",+ "gray.contrast": "oklch(18.22% 0 0)",+ "gray.fg": "oklch(93.1% 0 0)",+ "gray.subtle": "oklch(28.908% 0 0)",+ "gray.muted": "oklch(27.274% 0 0)",+ "gray.emphasized": "oklch(34.846% 0 0)",+ "gray.solid": "oklch(93.1% 0 0)",+ "gray.focusRing": "oklch(68.622% 0 0)",+ "gray.border": "oklch(34.846% 0 0)",+ "brand.solid": "oklch(93.1% 0 0)",+ "brand.contrast": "oklch(18.22% 0 0)",+ "brand.fg": "oklch(93.1% 0 0)",+ "brand.subtle": "color-mix(in oklab, oklch(93.1% 0 0) 16%, oklch(20.019% 0 0))",+ "brand.muted": "color-mix(in oklab, oklch(93.1% 0 0) 26%, oklch(20.019% 0 0))",+ "brand.emphasized": "color-mix(in oklab, oklch(93.1% 0 0) 36%, oklch(20.019% 0 0))",+ "brand.focusRing": "oklch(68.622% 0 0)",+ "brand.border": "oklch(93.1% 0 0)",+ "accent.solid": "oklch(68.622% 0 0)",+ "accent.contrast": "oklch(18.22% 0 0)",+ "accent.fg": "oklch(68.622% 0 0)",+ "accent.subtle": "color-mix(in oklab, oklch(68.622% 0 0) 16%, oklch(20.019% 0 0))",+ "accent.muted": "color-mix(in oklab, oklch(68.622% 0 0) 26%, oklch(20.019% 0 0))",+ "accent.emphasized": "color-mix(in oklab, oklch(68.622% 0 0) 36%, oklch(20.019% 0 0))",+ "accent.focusRing": "oklch(68.622% 0 0)",+ "accent.border": "oklch(68.622% 0 0)"+ },+ "ultradark": {+ "bg": "oklch(0% 0 0)",+ "bg.subtle": "oklch(11.492% 0 0)",+ "bg.muted": "oklch(14.479% 0 0)",+ "bg.panel": "oklch(14.479% 0 0)",+ "bg.emphasized": "oklch(19.125% 0 0)",+ "bg.inset": "oklch(0% 0 0)",+ "bg.error": "color-mix(in oklab, oklch(71.161% 0.1812 22.84) 14%, oklch(11.492% 0 0))",+ "bg.success": "color-mix(in oklab, oklch(76.5% 0.16 150.5) 14%, oklch(11.492% 0 0))",+ "bg.warning": "color-mix(in oklab, oklch(79.5% 0.13 80) 14%, oklch(11.492% 0 0))",+ "fg": "oklch(88.901% 0.0317 120.83)",+ "fg.muted": "oklch(66.382% 0.0192 131.96)",+ "fg.subtle": "oklch(47.041% 0.0184 127.12)",+ "fg.grid": "oklch(23.929% 0 0)",+ "fg.error": "oklch(71.161% 0.1812 22.84)",+ "fg.success": "oklch(76.5% 0.16 150.5)",+ "fg.warning": "oklch(79.5% 0.13 80)",+ "border": "oklch(20.904% 0 0)",+ "border.subtle": "oklch(20.904% 0 0)",+ "border.muted": "oklch(20.904% 0 0)",+ "border.emphasized": "oklch(26.862% 0 0)",+ "border.error": "oklch(71.161% 0.1812 22.84)",+ "gray.contrast": "oklch(0% 0 0)",+ "gray.fg": "oklch(88.901% 0.0317 120.83)",+ "gray.subtle": "oklch(21.779% 0 0)",+ "gray.muted": "oklch(19.125% 0 0)",+ "gray.emphasized": "oklch(26.862% 0 0)",+ "gray.solid": "oklch(88.901% 0.0317 120.83)",+ "gray.focusRing": "oklch(80.623% 0.1248 228.24)",+ "gray.border": "oklch(26.862% 0 0)",+ "brand.solid": "oklch(93.444% 0.19 125.56)",+ "brand.contrast": "oklch(15.913% 0.0233 128.66)",+ "brand.fg": "oklch(93.444% 0.19 125.56)",+ "brand.subtle": "color-mix(in oklab, oklch(93.444% 0.19 125.56) 16%, oklch(11.492% 0 0))",+ "brand.muted": "color-mix(in oklab, oklch(93.444% 0.19 125.56) 26%, oklch(11.492% 0 0))",+ "brand.emphasized": "color-mix(in oklab, oklch(93.444% 0.19 125.56) 36%, oklch(11.492% 0 0))",+ "brand.focusRing": "oklch(80.623% 0.1248 228.24)",+ "brand.border": "oklch(93.444% 0.19 125.56)",+ "accent.solid": "oklch(80.623% 0.1248 228.24)",+ "accent.contrast": "oklch(17.416% 0.0256 235.84)",+ "accent.fg": "oklch(80.623% 0.1248 228.24)",+ "accent.subtle": "color-mix(in oklab, oklch(80.623% 0.1248 228.24) 16%, oklch(11.492% 0 0))",+ "accent.muted": "color-mix(in oklab, oklch(80.623% 0.1248 228.24) 26%, oklch(11.492% 0 0))",+ "accent.emphasized": "color-mix(in oklab, oklch(80.623% 0.1248 228.24) 36%, oklch(11.492% 0 0))",+ "accent.focusRing": "oklch(80.623% 0.1248 228.24)",+ "accent.border": "oklch(80.623% 0.1248 228.24)"+ }+}diff --git a/invokeai/frontend/webv2/src/theme/__tokenResolve.ts b/invokeai/frontend/webv2/src/theme/__tokenResolve.tsnew file mode 100644index 0000000000..0bdd9a12b3--- /dev/null+++ b/invokeai/frontend/webv2/src/theme/__tokenResolve.ts@@ -0,0 +1,130 @@+/**+ * Test-only helper: resolve every semantic color token to its FINAL literal value+ * (following `var(--chakra-colors-…)` references) for each workbench theme, straight+ * from `system.getTokenCss()`. This mirrors what the browser computes for a given+ * `<html data-theme=… class="dark|light">`, so it is the ground truth used by the+ * legacy-value gate in `system.test.ts`.+ *+ * Not imported by any app entry — excluded from the production bundle.+ */++type Block = Record<string, string>;+type Layer = Record<string, Block>;++export interface TokenSystem {+ getTokenCss: () => Record<string, Layer>;+ tokens: { getByName: (name: string) => { extensions: { cssVar: { var: string } } } | undefined };+}++const BASE_SEL = '&:where(html, .chakra-theme)';+const DARK_SEL = '.dark &, .dark .chakra-theme:not(.light) &';+const LIGHT_SEL = ':root &, .light &';+const dataSel = (id: string): string => `&:root[data-theme=${id}]`;++/** Selectors that apply to each theme, HIGHEST CSS priority first. */+export const THEME_SELECTORS: Record<string, string[]> = {+ classic: [DARK_SEL, BASE_SEL], // default theme: no [data-theme=classic] rule+ light: [dataSel('light'), LIGHT_SEL, BASE_SEL],+ forest: [dataSel('forest'), DARK_SEL, BASE_SEL],+ mono: [dataSel('mono'), DARK_SEL, BASE_SEL],+ ultradark: [dataSel('ultradark'), DARK_SEL, BASE_SEL],+};++export const THEMES = Object.keys(THEME_SELECTORS);++const VAR_REF = /var\((--chakra-colors-[A-Za-z0-9\\.-]+)\)/g;++const layerOf = (sys: TokenSystem): Layer => sys.getTokenCss()['@layer tokens'];++const resolveVar = (layer: Layer, theme: string, varName: string, seen: Set<string>): string | undefined => {+ for (const sel of THEME_SELECTORS[theme]) {+ const block = layer[sel];+ if (block && varName in block) {+ return resolveValue(layer, theme, block[varName], seen);+ }+ }+ return undefined;+};++const resolveValue = (layer: Layer, theme: string, value: string, seen: Set<string>): string =>+ value.replace(VAR_REF, (whole, varName: string) => {+ if (seen.has(varName)) {+ return whole;+ }+ const resolved = resolveVar(layer, theme, varName, new Set(seen).add(varName));+ return resolved ?? whole;+ });++/** Final literal value of `colors.<tokenName>` in `theme`. */+export const resolveToken = (sys: TokenSystem, theme: string, tokenName: string): string => {+ const token = sys.tokens.getByName(`colors.${tokenName}`);+ if (!token) {+ throw new Error(`token not found: colors.${tokenName}`);+ }+ const value = resolveVar(layerOf(sys), theme, token.extensions.cssVar.var, new Set());+ if (value === undefined) {+ throw new Error(`could not resolve colors.${tokenName} for theme ${theme}`);+ }+ return value;+};++/** Resolve every token across every theme → { [theme]: { [token]: value } }. */+export const resolveAll = (sys: TokenSystem, tokens: readonly string[]): Record<string, Record<string, string>> => {+ const out: Record<string, Record<string, string>> = {};+ for (const theme of THEMES) {+ out[theme] = {};+ for (const token of tokens) {+ out[theme][token] = resolveToken(sys, theme, token);+ }+ }+ return out;+};++/** The frozen public color-token contract — every name a component/recipe may consume. */+export const CONSUMER_TOKENS = [+ 'bg',+ 'bg.subtle',+ 'bg.muted',+ 'bg.panel',+ 'bg.emphasized',+ 'bg.inset',+ 'bg.error',+ 'bg.success',+ 'bg.warning',+ 'fg',+ 'fg.muted',+ 'fg.subtle',+ 'fg.grid',+ 'fg.error',+ 'fg.success',+ 'fg.warning',+ 'border',+ 'border.subtle',+ 'border.muted',+ 'border.emphasized',+ 'border.error',+ 'gray.contrast',+ 'gray.fg',+ 'gray.subtle',+ 'gray.muted',+ 'gray.emphasized',+ 'gray.solid',+ 'gray.focusRing',+ 'gray.border',+ 'brand.solid',+ 'brand.contrast',+ 'brand.fg',+ 'brand.subtle',+ 'brand.muted',+ 'brand.emphasized',+ 'brand.focusRing',+ 'brand.border',+ 'accent.solid',+ 'accent.contrast',+ 'accent.fg',+ 'accent.subtle',+ 'accent.muted',+ 'accent.emphasized',+ 'accent.focusRing',+ 'accent.border',+] as const;diff --git a/invokeai/frontend/webv2/src/theme/system.test.ts b/invokeai/frontend/webv2/src/theme/system.test.tsnew file mode 100644index 0000000000..9fc8dc2be8--- /dev/null+++ b/invokeai/frontend/webv2/src/theme/system.test.ts@@ -0,0 +1,133 @@+import { describe, expect, it } from 'vitest';++import legacyBaseline from './__fixtures__/legacyTokenBaseline.json';+import { CONSUMER_TOKENS, resolveToken, THEMES, type TokenSystem } from './__tokenResolve';+import { system } from './system';++const sys = system as unknown as TokenSystem;+const STEPS = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950] as const;++const lightnessOf = (oklch: string): number => {+ const match = /oklch\(\s*([\d.]+)%/.exec(oklch);+ if (!match) {+ throw new Error(`not a plain oklch value: ${oklch}`);+ }+ return Number(match[1]);+};++describe('color token contract — legacy-value gate', () => {+ // Primary gate: every consumer token must resolve to the EXACT value it had+ // before the ramp refactor. The baseline was captured from the previous system+ // on the working tree before any change (see __fixtures__/legacyTokenBaseline.json).+ for (const theme of THEMES) {+ for (const token of CONSUMER_TOKENS) {+ it(`${theme}: ${token} is unchanged`, () => {+ const expected = (legacyBaseline as Record<string, Record<string, string>>)[theme][token];+ expect(resolveToken(sys, theme, token)).toBe(expected);+ });+ }+ }+});++describe('ramp + mapping structure', () => {+ it('emits every neutral ramp step for every theme', () => {+ for (const theme of THEMES) {+ for (const step of STEPS) {+ expect(resolveToken(sys, theme, `neutral.${step}`)).toMatch(/^oklch\(/);+ }+ }+ });++ it('maps the light surface ladder to the corrected (non-mirrored) steps', () => {+ // The point-1 fix: light bg sits at neutral.200, not the lightest step.+ expect(resolveToken(sys, 'light', 'bg')).toBe(resolveToken(sys, 'light', 'neutral.200'));+ expect(resolveToken(sys, 'light', 'bg.subtle')).toBe(resolveToken(sys, 'light', 'neutral.50'));+ expect(resolveToken(sys, 'light', 'bg.muted')).toBe(resolveToken(sys, 'light', 'neutral.100'));+ expect(resolveToken(sys, 'light', 'border')).toBe(resolveToken(sys, 'light', 'neutral.300'));+ expect(resolveToken(sys, 'light', 'border.emphasized')).toBe(resolveToken(sys, 'light', 'neutral.400'));+ });++ it('maps the dark surface ladder onto the ramp', () => {+ expect(resolveToken(sys, 'classic', 'bg')).toBe(resolveToken(sys, 'classic', 'neutral.950'));+ expect(resolveToken(sys, 'classic', 'bg.subtle')).toBe(resolveToken(sys, 'classic', 'neutral.900'));+ expect(resolveToken(sys, 'classic', 'fg')).toBe(resolveToken(sys, 'classic', 'neutral.50'));+ expect(resolveToken(sys, 'classic', 'border')).toBe(resolveToken(sys, 'classic', 'neutral.600'));+ });++ it('emits surface/text/border tokens via per-theme conditions only — never the leaky mode selectors', () => {+ // Chakra's `_light` selector (`:root &, .light &`) matches under EVERY theme via its+ // `:root &` arm. A surface token placed there leaks its light value into the dark+ // themes (the classic-renders-light regression). These tokens must live ONLY in the+ // base + `[data-theme=…]` selectors.+ const layer = sys.getTokenCss()['@layer tokens'];+ const LEAKY = [':root &, .light &', '.dark &, .dark .chakra-theme:not(.light) &'];+ const surfaceTokens = [+ 'bg',+ 'bg.subtle',+ 'bg.muted',+ 'bg.panel',+ 'fg',+ 'fg.muted',+ 'fg.subtle',+ 'border',+ 'border.subtle',+ 'border.muted',+ 'border.emphasized',+ ];+ for (const name of surfaceTokens) {+ const token = sys.tokens.getByName(`colors.${name}`);+ const cssVar = token?.extensions.cssVar.var ?? '';+ for (const selector of LEAKY) {+ expect(layer[selector]?.[cssVar], `${name} must not be emitted under "${selector}"`).toBeUndefined();+ }+ }+ });++ it('keeps each ramp strictly decreasing in lightness 50 → 950', () => {+ for (const theme of THEMES) {+ const ls = STEPS.map((step) => lightnessOf(resolveToken(sys, theme, `neutral.${step}`)));+ for (let i = 1; i < ls.length; i++) {+ expect(ls[i], `${theme} neutral.${STEPS[i]} should be darker than neutral.${STEPS[i - 1]}`).toBeLessThan(+ ls[i - 1]+ );+ }+ }+ });+});++describe('native Chakra integration', () => {+ it('resolves every gray virtual-palette key under both dark and light', () => {+ const keys = ['contrast', 'fg', 'subtle', 'muted', 'emphasized', 'solid', 'focusRing', 'border'];+ for (const theme of ['classic', 'light']) {+ for (const key of keys) {+ expect(resolveToken(sys, theme, `gray.${key}`)).toBeTruthy();+ }+ }+ });++ it('leaves stock Chakra hue palettes untouched in Phase 1', () => {+ // Phase 2 will theme these; for now they must remain Chakra defaults so model+ // badges / destructive actions keep their stock colors.+ expect(sys.tokens.getByName('colors.red.500')).toBeTruthy();+ expect(sys.tokens.getByName('colors.blue.500')).toBeTruthy();+ expect(sys.tokens.getByName('colors.purple.500')).toBeTruthy();+ });+});++describe('brand palette derives from its two seeds (like accent)', () => {+ it('fg/border equal solid; subtle/muted/emphasized mix solid into the surface', () => {+ for (const theme of THEMES) {+ const solid = resolveToken(sys, theme, 'brand.solid');+ const surface = resolveToken(sys, theme, 'bg.subtle');+ expect(resolveToken(sys, theme, 'brand.fg')).toBe(solid);+ expect(resolveToken(sys, theme, 'brand.border')).toBe(solid);+ for (const [key, pct] of [+ ['subtle', 16],+ ['muted', 26],+ ['emphasized', 36],+ ] as const) {+ expect(resolveToken(sys, theme, `brand.${key}`)).toBe(`color-mix(in oklab, ${solid} ${pct}%, ${surface})`);+ }+ }+ });+});diff --git a/invokeai/frontend/webv2/src/theme/system.ts b/invokeai/frontend/webv2/src/theme/system.tsindex 984155d3ac..e1d0aade03 100644--- a/invokeai/frontend/webv2/src/theme/system.ts+++ b/invokeai/frontend/webv2/src/theme/system.ts@@ -1,29 +1,33 @@import { createSystem, defaultConfig, defineConfig } from '@chakra-ui/react';import { dialogSlotRecipe, menuSlotRecipe, tooltipSlotRecipe } from './recipes';-import { DEFAULT_THEME, DEFAULT_THEME_ID, THEMES, THEMES_BY_ID, type ThemeColors } from './themes';+import { DEFAULT_THEME, DEFAULT_THEME_ID, type NeutralStep, THEMES, type ThemeDefinition } from './themes';/*** Workbench design system.*- * The shell is theme-able across several presets (dark, light, forest, mono,- * ultra dark). Rather than hand-author one token set per theme, we derive the- * semantic-token layer from the theme registry in `themes.ts`:+ * Each theme (`themes.ts`) is authored as one neutral ramp (`neutral.50…neutral.950`,+ * lightest → darkest) plus a few seeds (brand, accent, status) and four off-ramp+ * neutrals (`inset`, `fill`, `grid`, `control`). This module turns that into two+ * token layers:*- * - the default theme (`DEFAULT_THEME_ID`) becomes each token's `base` value;- * - every other theme contributes a conditional value keyed on a custom- * `[data-theme=<id>]` condition.+ * 1. The **ramp** is emitted verbatim as conditional semantic tokens+ * (`neutral.*`), one value per theme keyed on a custom `[data-theme=<id>]`+ * condition. Chakra base `tokens.colors` only hold plain strings, so anything+ * that varies per theme must live in `semanticTokens`.+ * 2. The **semantic contract** (`bg`, `fg.muted`, `border.emphasized`, the+ * `gray`/`brand`/`accent` palettes, …) is theme-agnostic: it references ramp+ * steps and flips by light/dark mode only. `bg` is `neutral.950` in dark mode and+ * `neutral.200` in light — the light ramp is not a mirror of the dark one, because+ * light panels go *whiter* than the app background.*- * `ThemeController` sets `data-theme` on `<html>`, so flipping themes is a single- * attribute change with zero re-render of the React tree. Components reference- * only the semantic tokens below — they never know which theme is active.+ * `ThemeController` sets `data-theme` (and the `.dark`/`.light` class) on `<html>`,+ * so switching themes is a single attribute change with zero React re-render.+ * Components reference only the semantic tokens — never the ramp or a theme.*- * The token contract deliberately reuses Chakra's own semantic names (`bg`,- * `bg.subtle`, `fg.muted`, `border.emphasized`, …) and re-points its neutral- * `gray` palette at the theme ladder, so built-in components (Dialog, Menu,- * Input, Button, Tooltip) follow the active theme with no per-component- * overrides. Workbench-specific additions are intent-based (`bg.inset`,- * `fg.grid`, the `brand` and `accent` palettes) — never named after a widget.+ * Re-pointing Chakra's neutral `gray` palette at the ramp makes every built-in+ * component (Dialog, Menu, Input, Button, Tooltip, Badge) follow the active theme+ * with no per-component overrides.*/const NON_DEFAULT_THEMES = THEMES.filter((theme) => theme.id !== DEFAULT_THEME_ID);@@ -32,121 +36,156 @@ const NON_DEFAULT_THEMES = THEMES.filter((theme) => theme.id !== DEFAULT_THEME_Iconst conditionName = (id: string): string => `theme${id.charAt(0).toUpperCase()}${id.slice(1)}`;type TokenValue = { value: Record<string, string> };+type Compute = (theme: ThemeDefinition) => string;-/** Build a semantic-token value object: default theme as `base`, the rest as conditions. */-const buildToken = (compute: (colors: ThemeColors) => string): TokenValue => {- const value: Record<string, string> = { base: compute(DEFAULT_THEME.colors) };-+/** Build a semantic-token value object: default theme as `base`, the rest as `[data-theme]` conditions. */+const colorToken = (compute: Compute): TokenValue => {+ const value: Record<string, string> = { base: compute(DEFAULT_THEME) };for (const theme of NON_DEFAULT_THEMES) {- value[`_${conditionName(theme.id)}`] = compute(theme.colors);+ value[`_${conditionName(theme.id)}`] = compute(theme);}-return { value };};-const colorToken = (slot: keyof ThemeColors): TokenValue => buildToken((colors) => colors[slot]);+/** Blend `pct`% of one computed color into another — used for derived hover/tint steps. */+const mix = (top: Compute, pct: number, bottom: Compute): TokenValue =>+ colorToken((theme) => `color-mix(in oklab, ${top(theme)} ${pct}%, ${bottom(theme)})`);-/** Blend `pct`% of a slot color into another slot — used for derived hover/tint steps. */-const mixToken = (slot: keyof ThemeColors, pct: number, baseSlot: keyof ThemeColors): TokenValue =>- buildToken((colors) => `color-mix(in oklab, ${colors[slot]} ${pct}%, ${colors[baseSlot]})`);--const LIGHT_FALLBACK_THEME = THEMES.find((theme) => theme.colorScheme === 'light') ?? THEMES_BY_ID[DEFAULT_THEME_ID];+const LIGHT_FALLBACK_THEME = THEMES.find((theme) => theme.colorScheme === 'light') ?? DEFAULT_THEME;/*** Like `colorToken`, but additionally shadows Chakra's `_light`/`_dark`* class-conditional values. Nested palette tokens (`gray.*`) deep-merge with* `defaultConfig` instead of replacing it, so without these keys the default* gray values would survive the merge and outrank our zero-specificity `base`- * value whenever `ThemeController` sets the `.dark`/`.light` class. The- * explicit `:root[data-theme=…]` conditions still win over both.+ * value whenever `ThemeController` sets the `.dark`/`.light` class. The explicit+ * `:root[data-theme=…]` conditions still win over both.*/-const colorTokenWithModeFallback = (slot: keyof ThemeColors): TokenValue => {- const token = colorToken(slot);- token.value._light = LIGHT_FALLBACK_THEME.colors[slot];- token.value._dark = DEFAULT_THEME.colors[slot];+const grayToken = (compute: Compute): TokenValue => {+ const token = colorToken(compute);+ token.value._light = compute(LIGHT_FALLBACK_THEME);+ token.value._dark = compute(DEFAULT_THEME);return token;};/**- * The semantic-token contract. Where a Chakra built-in name exists for a- * concept we use it verbatim; the handful of workbench-specific tokens- * (`bg.inset`, `fg.grid`) describe elevation or intent, never a widget.+ * A token that reads a ramp step, chosen per theme by `colorScheme`. Emitted as+ * per-`[data-theme]` conditions, NOT Chakra's `_light`/`_dark`: the built-in+ * `_light` selector is `:root &, .light &`, and its `:root &` arm matches under+ * EVERY theme — so a mode-flip token leaks its light value into the dark themes.+ * Per-theme conditions sidestep the cascade entirely (this is how the pre-refactor+ * system worked, and why dark themes rendered correctly).*/-const colorSlotByToken: Record<string, keyof ThemeColors> = {- // Surface ladder, deepest to most lifted- bg: 'base',- 'bg.subtle': 'surface',- 'bg.muted': 'raised',- 'bg.emphasized': 'control',- // Popover / dialog surface used by Chakra's built-in components- 'bg.panel': 'raised',- // Recessed work-area floor framed by the chrome- 'bg.inset': 'inset',- // Foreground- fg: 'text',- 'fg.muted': 'textMuted',- 'fg.subtle': 'textSubtle',- // Dot-grid decoration drawn on inset surfaces- 'fg.grid': 'grid',- // Borders- border: 'line',- 'border.subtle': 'line',- 'border.muted': 'line',- 'border.emphasized': 'lineStrong',- // Status intent- 'fg.error': 'danger',- 'border.error': 'danger',- 'fg.success': 'success',- 'fg.warning': 'warning',-};+const ref = (step: NeutralStep): string => `{colors.neutral.${step}}`;+const stepRef = (darkStep: NeutralStep, lightStep: NeutralStep): TokenValue =>+ colorToken((theme) => ref(theme.colorScheme === 'light' ? lightStep : darkStep));++const STEPS: NeutralStep[] = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];++/** The default panel surface of a theme — `bg.subtle`'s step. Used as the floor for tints. */+const surface: Compute = (theme) =>+ theme.colorScheme === 'light' ? theme.colors.neutral[50] : theme.colors.neutral[900];++// Seed accessors.+const danger: Compute = (theme) => theme.colors.danger;+const success: Compute = (theme) => theme.colors.success;+const warning: Compute = (theme) => theme.colors.warning;+const brandSolid: Compute = (theme) => theme.colors.brand.solid;+const accentSolid: Compute = (theme) => theme.colors.accent.solid;+/** The neutral ramp, emitted as `neutral.50…neutral.950`, one value per theme. */+const neutralRamp = Object.fromEntries(STEPS.map((step) => [step, colorToken((theme) => theme.colors.neutral[step])]));++/**+ * The semantic-token contract. Backgrounds/foregrounds/borders reference ramp+ * steps (`stepRef`); the four off-ramp neutrals and the status/identity hues read+ * their per-theme seed directly. Where a Chakra built-in name exists we use it+ * verbatim so built-ins inherit the theme for free.+ */const semanticColors = {- ...Object.fromEntries(Object.entries(colorSlotByToken).map(([token, slot]) => [token, colorToken(slot)])),- // Soft status fills for alerts/banners, derived from each theme's palette.- 'bg.error': mixToken('danger', 14, 'surface'),- 'bg.success': mixToken('success', 14, 'surface'),- 'bg.warning': mixToken('warning', 14, 'surface'),+ neutral: neutralRamp,++ // Surface ladder. Light panels are whiter than the app bg, so the light steps+ // are not a mirror of the dark ones.+ bg: stepRef(950, 200),+ 'bg.subtle': stepRef(900, 50),+ 'bg.muted': stepRef(800, 100),+ 'bg.panel': stepRef(800, 100),+ 'bg.emphasized': colorToken((theme) => theme.colors.control),+ 'bg.inset': colorToken((theme) => theme.colors.inset),+ // Soft status fills for alerts/banners, mixed into the panel surface.+ 'bg.error': mix(danger, 14, surface),+ 'bg.success': mix(success, 14, surface),+ 'bg.warning': mix(warning, 14, surface),++ // Foreground.+ fg: stepRef(50, 950),+ 'fg.muted': stepRef(300, 700),+ 'fg.subtle': stepRef(400, 500),+ 'fg.grid': colorToken((theme) => theme.colors.grid),+ 'fg.error': colorToken(danger),+ 'fg.success': colorToken(success),+ 'fg.warning': colorToken(warning),++ // Borders.+ border: stepRef(600, 300),+ 'border.subtle': stepRef(600, 300),+ 'border.muted': stepRef(600, 300),+ 'border.emphasized': stepRef(500, 400),+ 'border.error': colorToken(danger),+/*** Chakra's default `colorPalette` is `gray`; re-pointing its virtual-palette- * keys at the theme ladder makes every un-palettized component (ghost- * buttons, menu items, badges, …) theme-aware with zero props.+ * keys at the ramp makes every un-palettized component (ghost buttons, menu+ * items, badges, …) theme-aware with zero props.** Palette tokens must stay NESTED — the `colorPalette` virtual-token map is- * built from the nested structure and ignores flat dotted keys. Because- * nesting deep-merges with the defaults, every gray key shadows the default- * `_light`/`_dark` values via `colorTokenWithModeFallback`.+ * built from the nested structure and ignores flat dotted keys. Because nesting+ * deep-merges with the defaults, every gray key shadows the default+ * `_light`/`_dark` values via `grayToken`.*/gray: {- contrast: colorTokenWithModeFallback('base'),- fg: colorTokenWithModeFallback('text'),- subtle: colorTokenWithModeFallback('fill'),- muted: colorTokenWithModeFallback('control'),- emphasized: colorTokenWithModeFallback('lineStrong'),- solid: colorTokenWithModeFallback('text'),- focusRing: colorTokenWithModeFallback('accent'),- border: colorTokenWithModeFallback('lineStrong'),+ contrast: grayToken((theme) =>+ theme.colorScheme === 'light' ? theme.colors.neutral[200] : theme.colors.neutral[950]+ ),+ fg: grayToken((theme) => (theme.colorScheme === 'light' ? theme.colors.neutral[950] : theme.colors.neutral[50])),+ subtle: grayToken((theme) => theme.colors.fill),+ muted: grayToken((theme) => theme.colors.control),+ emphasized: grayToken((theme) =>+ theme.colorScheme === 'light' ? theme.colors.neutral[400] : theme.colors.neutral[500]+ ),+ solid: grayToken((theme) => (theme.colorScheme === 'light' ? theme.colors.neutral[950] : theme.colors.neutral[50])),+ focusRing: grayToken(accentSolid),+ border: grayToken((theme) =>+ theme.colorScheme === 'light' ? theme.colors.neutral[400] : theme.colors.neutral[500]+ ),},- /** Invoke identity palette. Use sparingly for the logo and global Invoke action. */+ /**+ * Invoke identity palette (lime). Authored from two seeds (`solid` + `contrast`),+ * like `accent`; the rest derive. NOTE: `brand.fg` is the bright `solid` fill, so+ * `brand.fg` on `brand.subtle` reads well on the dark themes but is low-contrast in+ * the light theme — brand is meant for emphasis fills, not body text.+ */brand: {- solid: colorToken('brand'),- contrast: colorToken('brandContrast'),- fg: colorToken('brandFg'),- subtle: colorToken('brandSubtle'),- muted: mixToken('brandFg', 12, 'brandSubtle'),- emphasized: mixToken('brandFg', 22, 'brandSubtle'),- focusRing: colorToken('accent'),- border: mixToken('brandFg', 50, 'surface'),+ solid: colorToken(brandSolid),+ contrast: colorToken((theme) => theme.colors.brand.contrast),+ fg: colorToken(brandSolid),+ subtle: mix(brandSolid, 16, surface),+ muted: mix(brandSolid, 26, surface),+ emphasized: mix(brandSolid, 36, surface),+ focusRing: colorToken(accentSolid),+ border: colorToken(brandSolid),},/** Selection / focus palette (blue). Use via `accent.solid` or `colorPalette="accent"`. */accent: {- solid: colorToken('accent'),- contrast: colorToken('accentContrast'),- fg: colorToken('accent'),- subtle: mixToken('accent', 16, 'surface'),- muted: mixToken('accent', 26, 'surface'),- emphasized: mixToken('accent', 36, 'surface'),- focusRing: colorToken('accent'),- border: colorToken('accent'),+ solid: colorToken(accentSolid),+ contrast: colorToken((theme) => theme.colors.accent.contrast),+ fg: colorToken(accentSolid),+ subtle: mix(accentSolid, 16, surface),+ muted: mix(accentSolid, 26, surface),+ emphasized: mix(accentSolid, 36, surface),+ focusRing: colorToken(accentSolid),+ border: colorToken(accentSolid),},};@@ -207,5 +246,5 @@ const config = defineConfig({export const system = createSystem(defaultConfig, config);/** Theme metadata re-exported so UI can import a single module. */-export { THEMES, THEMES_BY_ID, DEFAULT_THEME, DEFAULT_THEME_ID } from './themes';-export type { ThemeColors, ThemeDefinition } from './themes';+export { THEMES, THEMES_BY_ID, DEFAULT_THEME, DEFAULT_THEME_ID, previewSwatches } from './themes';+export type { ThemeColors, ThemeDefinition, NeutralStep } from './themes';diff --git a/invokeai/frontend/webv2/src/theme/themes.ts b/invokeai/frontend/webv2/src/theme/themes.tsindex 5b12c5ddbd..38a5d8a38b 100644--- a/invokeai/frontend/webv2/src/theme/themes.ts+++ b/invokeai/frontend/webv2/src/theme/themes.ts@@ -1,59 +1,51 @@import type { WorkbenchThemeId } from '../workbench/types';/**- * A single, mode-agnostic set of concrete CSS color values that fully describes- * one workbench theme. Every theme provides the same slots so the semantic-token- * builder in `system.ts` can generate a uniform token contract across themes.+ * Steps of the neutral ramp. `50` is the lightest, `950` the darkest — the same+ * absolute orientation Chakra/Tailwind use, so the ramp can be aliased onto the+ * built-in `gray` palette without surprises.+ */+export type NeutralStep = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;++/**+ * One workbench theme, expressed as a small set of concrete OKLch values.+ *+ * The bulk of a theme is the `base` ramp — a single neutral scale from which the+ * semantic-token layer in `system.ts` derives every background, foreground, and+ * border (`bg → neutral.950` in dark mode, `fg → neutral.50`, …). Everything else is a+ * handful of seeds:*- * Slots are named for *elevation* and *intent* — never for the widget or screen- * region that happens to use them. Components never read these slots directly;- * they consume the semantic tokens (`bg.subtle`, `fg.muted`, `brand.solid`, …)- * that map onto them. Adding a new theme is therefore a matter of adding one- * entry here; no component changes.+ * - `brand` / `accent` — the two identity hues (lime action, blue selection);+ * - `danger` / `success` / `warning` — status intents;+ * - `inset` / `fill` / `grid` / `control` — four neutrals whose *elevation rank*+ * differs from theme to theme, so they cannot sit on a single shared ramp step+ * (e.g. `inset` recesses below the app background in the light theme but lifts+ * above it in the dark themes). They are kept as explicit per-theme values and+ * consumed by name through `bg.inset`, `fg.grid`, `gray.subtle`, `bg.emphasized`.+ *+ * Adding a theme is therefore: author one ramp + the seeds. No component changes.*/export interface ThemeColors {- /** Deepest backdrop behind every panel (`bg`). */- base: string;- /** Default panel / rail surface (`bg.subtle`). */- surface: string;- /** Lifted chrome: top bar, headers, popovers, dialogs (`bg.muted`, `bg.panel`). */- raised: string;- /** Recessed work-area floor framed by the chrome (`bg.inset`). */- inset: string;- /** Control / chip fill inside panels (`bg.emphasized`). */- control: string;- /** Subtle neutral fill for hovered/ghost controls (`gray.subtle`). */- fill: string;- /** Hairline divider (`border`, `border.subtle`, `border.muted`). */- line: string;- /** Emphasized divider / popover stroke (`border.emphasized`). */- lineStrong: string;- /** Dot-grid decoration drawn on `inset` surfaces (`fg.grid`). */- grid: string;- /** Primary text (`fg`). */- text: string;- /** Secondary text (`fg.muted`). */- textMuted: string;- /** Tertiary / disabled text (`fg.subtle`). */- textSubtle: string;- /** Invoke identity / global action fill (`brand.solid`). */- brand: string;- /** Foreground on top of `brand` (`brand.contrast`). */- brandContrast: string;- /** Tinted brand surface for identity chips (`brand.subtle`). */- brandSubtle: string;- /** Standalone brand foreground, readable on panels (`brand.fg`). */- brandFg: string;- /** Selection / focus accent fill (`accent.solid`). */- accent: string;- /** Foreground on top of `accent` (`accent.contrast`). */- accentContrast: string;- /** Destructive / error (`fg.error`). */+ /** Neutral ramp, lightest (`50`) → darkest (`950`). Source of all bg/fg/border. */+ neutral: Record<NeutralStep, string>;+ /** Invoke identity (lime). Two seeds; the palette's other steps derive in `system.ts`. */+ brand: { solid: string; contrast: string };+ /** Selection / focus (blue). */+ accent: { solid: string; contrast: string };+ /** Destructive / error intent. */danger: string;- /** Positive / success (`fg.success`). */+ /** Positive / success intent. */success: string;- /** Caution / warning (`fg.warning`). */+ /** Caution / warning intent. */warning: string;+ /** Recessed work-area floor framed by the chrome (`bg.inset`). Off-ramp. */+ inset: string;+ /** Subtle neutral fill for hovered/ghost controls (`gray.subtle`). Off-ramp. */+ fill: string;+ /** Dot-grid decoration drawn on inset surfaces (`fg.grid`). Off-ramp. */+ grid: string;+ /** Control / chip fill inside panels (`bg.emphasized`). Off-ramp. */+ control: string;}export interface ThemeDefinition {@@ -66,123 +58,130 @@ export interface ThemeDefinition {}const classic: ThemeColors = {- base: 'oklch(21.074% 0.0087 264.37)',- surface: 'oklch(26.279% 0.0123 264.34)',- raised: 'oklch(31.237% 0.0157 264.32)',- inset: 'oklch(21.074% 0.0087 264.37)',- control: 'oklch(36.004% 0.019 264.3)',- fill: 'oklch(31.237% 0.0157 264.32)',- line: 'oklch(40.619% 0.0221 264.29)',- lineStrong: 'oklch(45.106% 0.0251 264.28)',- grid: 'oklch(40.619% 0.0221 264.29)',- text: 'oklch(96.017% 0.0029 264.54)',- textMuted: 'oklch(73.736% 0.0202 264.44)',- textSubtle: 'oklch(57.965% 0.0337 264.27)',- brand: 'oklch(92.041% 0.2103 116.59)',- brandContrast: 'oklch(21.074% 0.0087 264.37)',- brandSubtle: 'oklch(38.737% 0.0865 115.91)',- brandFg: 'oklch(94.161% 0.1719 114.56)',- accent: 'oklch(77.738% 0.1 231.76)',- accentContrast: 'oklch(21.074% 0.0087 264.37)',+ neutral: {+ 50: 'oklch(96.017% 0.0029 264.54)',+ 100: 'oklch(91.561% 0.0064 264.52)',+ 200: 'oklch(82.648% 0.0133 264.48)',+ 300: 'oklch(73.736% 0.0202 264.44)',+ 400: 'oklch(57.965% 0.0337 264.27)',+ 500: 'oklch(45.106% 0.0251 264.28)',+ 600: 'oklch(40.619% 0.0221 264.29)',+ 700: 'oklch(36.004% 0.019 264.3)',+ 800: 'oklch(31.237% 0.0157 264.32)',+ 900: 'oklch(26.279% 0.0123 264.34)',+ 950: 'oklch(21.074% 0.0087 264.37)',+ },+ brand: { solid: 'oklch(92.041% 0.2103 116.59)', contrast: 'oklch(21.074% 0.0087 264.37)' },+ accent: { solid: 'oklch(77.738% 0.1 231.76)', contrast: 'oklch(21.074% 0.0087 264.37)' },danger: 'oklch(70.61% 0.0841 19.38)',success: 'oklch(79.8% 0.1132 141.63)',warning: 'oklch(76.62% 0.0612 62.9)',+ inset: 'oklch(21.074% 0.0087 264.37)',+ fill: 'oklch(31.237% 0.0157 264.32)',+ grid: 'oklch(40.619% 0.0221 264.29)',+ control: 'oklch(36.004% 0.019 264.3)',};+// Cool blue-gray neutrals (hue 264, harmonizing with the blue accent): near-white+// chrome floating on a soft-gray work floor, near-black cool text. Airy and clean.const light: ThemeColors = {- base: 'oklch(95.222% 0.007 124.45)',- surface: 'oklch(100% 0 0)',- raised: 'oklch(98.221% 0.0069 124.45)',- inset: 'oklch(91.025% 0.0128 126.38)',- control: 'oklch(96.697% 0.0082 121.63)',- fill: 'oklch(98.221% 0.0069 124.45)',- line: 'oklch(90.402% 0.014 124.57)',- lineStrong: 'oklch(82.866% 0.0254 121.98)',- grid: 'oklch(85.598% 0.0198 122.88)',- text: 'oklch(22.5% 0.0139 126.4)',- textMuted: 'oklch(46.478% 0.0248 125.12)',- textSubtle: 'oklch(64.728% 0.0229 124.86)',- brand: 'oklch(92.041% 0.2103 116.59)',- brandContrast: 'oklch(22.5% 0.0139 126.4)',- brandSubtle: 'oklch(96.2% 0.055 115.8)',- brandFg: 'oklch(77.849% 0.1774 116.51)',- accent: 'oklch(54.615% 0.2152 262.88)',- accentContrast: 'oklch(100% 0 0)',+ neutral: {+ 50: 'oklch(99.4% 0.002 264)',+ 100: 'oklch(97% 0.003 264)',+ 200: 'oklch(96% 0.0038 264)',+ 300: 'oklch(90.5% 0.0065 264)',+ 400: 'oklch(84% 0.0095 264)',+ 500: 'oklch(63% 0.014 264)',+ 600: 'oklch(53.5% 0.016 264)',+ 700: 'oklch(45% 0.017 264)',+ 800: 'oklch(35% 0.015 264)',+ 900: 'oklch(27% 0.013 264)',+ 950: 'oklch(22.5% 0.013 264)',+ },+ brand: { solid: 'oklch(92.041% 0.2103 116.59)', contrast: 'oklch(22.5% 0.013 264)' },+ accent: { solid: 'oklch(54.615% 0.2152 262.88)', contrast: 'oklch(100% 0 0)' },danger: 'oklch(55.509% 0.1707 24.62)',success: 'oklch(53% 0.15 150)',warning: 'oklch(60% 0.13 72)',+ inset: 'oklch(96% 0.0038 264)',+ fill: 'oklch(95.5% 0.005 264)',+ grid: 'oklch(88.5% 0.0075 264)',+ control: 'oklch(93.5% 0.005 264)',};const forest: ThemeColors = {- base: 'oklch(17.349% 0.0154 144.88)',- surface: 'oklch(19.03% 0.0175 144.85)',- raised: 'oklch(20.99% 0.0219 144.74)',- inset: 'oklch(18.457% 0.0201 144.71)',- control: 'oklch(25.62% 0.03 144.64)',- fill: 'oklch(28.489% 0.0483 141.22)',- line: 'oklch(27.425% 0.0354 143.04)',- lineStrong: 'oklch(36.133% 0.0575 141.06)',- grid: 'oklch(34.825% 0.0526 141.63)',- text: 'oklch(90.57% 0.0511 134.45)',- textMuted: 'oklch(71.619% 0.0575 135.25)',- textSubtle: 'oklch(53.577% 0.0538 136.73)',- brand: 'oklch(79.714% 0.1784 136.37)',- brandContrast: 'oklch(18.298% 0.0314 147.69)',- brandSubtle: 'oklch(30.516% 0.0451 143.28)',- brandFg: 'oklch(88.797% 0.1051 134.45)',- accent: 'oklch(70.437% 0.1101 178.23)',- accentContrast: 'oklch(17.44% 0.0258 171.89)',+ neutral: {+ 50: 'oklch(90.57% 0.0511 134.45)',+ 100: 'oklch(86.78% 0.0524 134.61)',+ 200: 'oklch(79.199% 0.0549 134.93)',+ 300: 'oklch(71.619% 0.0575 135.25)',+ 400: 'oklch(53.577% 0.0538 136.73)',+ 500: 'oklch(36.133% 0.0575 141.06)',+ 600: 'oklch(27.425% 0.0354 143.04)',+ 700: 'oklch(25.62% 0.03 144.64)',+ 800: 'oklch(20.99% 0.0219 144.74)',+ 900: 'oklch(19.03% 0.0175 144.85)',+ 950: 'oklch(17.349% 0.0154 144.88)',+ },+ brand: { solid: 'oklch(79.714% 0.1784 136.37)', contrast: 'oklch(18.298% 0.0314 147.69)' },+ accent: { solid: 'oklch(70.437% 0.1101 178.23)', contrast: 'oklch(17.44% 0.0258 171.89)' },danger: 'oklch(69.305% 0.1467 35.44)',success: 'oklch(78% 0.16 148)',warning: 'oklch(80% 0.12 76)',+ inset: 'oklch(17.349% 0.0154 144.88)',+ fill: 'oklch(28.489% 0.0483 141.22)',+ grid: 'oklch(34.825% 0.0526 141.63)',+ control: 'oklch(25.62% 0.03 144.64)',};const mono: ThemeColors = {- base: 'oklch(18.22% 0 0)',- surface: 'oklch(20.019% 0 0)',- raised: 'oklch(22.213% 0 0)',- inset: 'oklch(22.645% 0 0)',- control: 'oklch(27.274% 0 0)',- fill: 'oklch(28.908% 0 0)',- line: 'oklch(28.908% 0 0)',- lineStrong: 'oklch(34.846% 0 0)',- grid: 'oklch(32.897% 0 0)',- text: 'oklch(93.1% 0 0)',- textMuted: 'oklch(71.547% 0 0)',- textSubtle: 'oklch(53.824% 0 0)',- brand: 'oklch(93.1% 0 0)',- brandContrast: 'oklch(18.22% 0 0)',- brandSubtle: 'oklch(30.118% 0 0)',- brandFg: 'oklch(87.61% 0 0)',- accent: 'oklch(68.622% 0 0)',- accentContrast: 'oklch(18.22% 0 0)',+ neutral: {+ 50: 'oklch(93.1% 0 0)',+ 100: 'oklch(88.789% 0 0)',+ 200: 'oklch(80.168% 0 0)',+ 300: 'oklch(71.547% 0 0)',+ 400: 'oklch(53.824% 0 0)',+ 500: 'oklch(34.846% 0 0)',+ 600: 'oklch(28.908% 0 0)',+ 700: 'oklch(27.274% 0 0)',+ 800: 'oklch(22.213% 0 0)',+ 900: 'oklch(20.019% 0 0)',+ 950: 'oklch(18.22% 0 0)',+ },+ brand: { solid: 'oklch(93.1% 0 0)', contrast: 'oklch(18.22% 0 0)' },+ accent: { solid: 'oklch(68.622% 0 0)', contrast: 'oklch(18.22% 0 0)' },danger: 'oklch(71.115% 0.0934 19.64)',success: 'oklch(76% 0.06 150)',warning: 'oklch(79% 0.07 80)',+ inset: 'oklch(18.22% 0 0)',+ fill: 'oklch(28.908% 0 0)',+ grid: 'oklch(32.897% 0 0)',+ control: 'oklch(27.274% 0 0)',};const ultradark: ThemeColors = {- base: 'oklch(0% 0 0)',- surface: 'oklch(11.492% 0 0)',- raised: 'oklch(14.479% 0 0)',- inset: 'oklch(14.958% 0 0)',- control: 'oklch(19.125% 0 0)',- fill: 'oklch(21.779% 0 0)',- line: 'oklch(20.904% 0 0)',- lineStrong: 'oklch(26.862% 0 0)',- grid: 'oklch(23.929% 0 0)',- text: 'oklch(88.901% 0.0317 120.83)',- textMuted: 'oklch(66.382% 0.0192 131.96)',- textSubtle: 'oklch(47.041% 0.0184 127.12)',- brand: 'oklch(93.444% 0.19 125.56)',- brandContrast: 'oklch(15.913% 0.0233 128.66)',- brandSubtle: 'oklch(25.602% 0.0333 125.95)',- brandFg: 'oklch(90.752% 0.134 124.5)',- accent: 'oklch(80.623% 0.1248 228.24)',- accentContrast: 'oklch(17.416% 0.0256 235.84)',+ neutral: {+ 50: 'oklch(88.901% 0.0317 120.83)',+ 100: 'oklch(84.397% 0.0292 123.06)',+ 200: 'oklch(75.39% 0.0242 127.51)',+ 300: 'oklch(66.382% 0.0192 131.96)',+ 400: 'oklch(47.041% 0.0184 127.12)',+ 500: 'oklch(26.862% 0 0)',+ 600: 'oklch(20.904% 0 0)',+ 700: 'oklch(19.125% 0 0)',+ 800: 'oklch(14.479% 0 0)',+ 900: 'oklch(11.492% 0 0)',+ 950: 'oklch(0% 0 0)',+ },+ brand: { solid: 'oklch(93.444% 0.19 125.56)', contrast: 'oklch(15.913% 0.0233 128.66)' },+ accent: { solid: 'oklch(80.623% 0.1248 228.24)', contrast: 'oklch(17.416% 0.0256 235.84)' },danger: 'oklch(71.161% 0.1812 22.84)',success: 'oklch(76.5% 0.16 150.5)',warning: 'oklch(79.5% 0.13 80)',+ inset: 'oklch(0% 0 0)',+ fill: 'oklch(21.779% 0 0)',+ grid: 'oklch(23.929% 0 0)',+ control: 'oklch(19.125% 0 0)',};/**@@ -234,7 +233,7 @@ if (!defaultTheme) {throw new Error('At least one workbench theme must be defined.');}-/** The default theme. Its palette is emitted as the semantic-token `base` value. */+/** The default theme. Its ramp/seeds are emitted as the semantic-token `base` value. */export const DEFAULT_THEME = defaultTheme;export const DEFAULT_THEME_ID: WorkbenchThemeId = DEFAULT_THEME.id;@@ -249,3 +248,18 @@ export const THEMES_BY_ID: Record<WorkbenchThemeId, ThemeDefinition> = THEMES.reexport const isWorkbenchThemeId = (value: unknown): value is WorkbenchThemeId =>typeof value === 'string' && Object.prototype.hasOwnProperty.call(THEMES_BY_ID, value);++/** The default panel surface of a theme (lightest end in light mode, near-darkest in dark). */+const surfaceOf = (theme: ThemeDefinition): string =>+ theme.colorScheme === 'light' ? theme.colors.neutral[50] : theme.colors.neutral[900];++/**+ * The four representative chips shown in the Settings appearance picker:+ * surface, control fill, brand, accent — a compact read of the theme's identity.+ */+export const previewSwatches = (theme: ThemeDefinition): [string, string, string, string] => [+ surfaceOf(theme),+ theme.colors.control,+ theme.colors.brand.solid,+ theme.colors.accent.solid,+];diff --git a/invokeai/frontend/webv2/src/workbench/components/TopBar.tsx b/invokeai/frontend/webv2/src/workbench/components/TopBar.tsxindex b2bc067e50..d2924217bf 100644--- a/invokeai/frontend/webv2/src/workbench/components/TopBar.tsx+++ b/invokeai/frontend/webv2/src/workbench/components/TopBar.tsx@@ -36,7 +36,7 @@ export const TopBar = () => (<Flexalign="center"as="header"- bg="bg.muted"+ bg="bg.subtle"borderBottomWidth="1px"borderColor="border.subtle"flexShrink={0}@@ -77,7 +77,7 @@ const BrandMark = () => {<svg aria-hidden="true" fill="none" height="20" viewBox="0 0 44 44" width="20"><pathd="M29.1951 10.6667H42V2H2V10.6667H14.8049L29.1951 33.3333H42V42H2V33.3333H14.8049"- stroke={theme.colors.brandFg}+ stroke={theme.colors.brand.solid}strokeWidth="2.8"/></svg>diff --git a/invokeai/frontend/webv2/src/workbench/settings/SettingsDialog.tsx b/invokeai/frontend/webv2/src/workbench/settings/SettingsDialog.tsxindex 38f4032de1..5707a6d24f 100644--- a/invokeai/frontend/webv2/src/workbench/settings/SettingsDialog.tsx+++ b/invokeai/frontend/webv2/src/workbench/settings/SettingsDialog.tsx@@ -32,7 +32,7 @@ import {} from 'lucide-react';import { themeCardRecipe } from '../../theme/recipes';-import { THEMES, type ThemeDefinition } from '../../theme/system';+import { previewSwatches, THEMES, type ThemeDefinition } from '../../theme/system';import { Button, CloseButton, IconButton } from '../components/ui/Button';import { ConfirmDialog } from '../components/ui/ConfirmDialog';import { syncedWorkbenchPersistence } from '../projects/syncedPersistence';@@ -335,14 +335,15 @@ const ThemeCard = ({}) => {const recipe = useSlotRecipe({ recipe: themeCardRecipe });const styles = recipe({ selected });+ const [surface, control, brandColor, accentColor] = previewSwatches(theme);return (<chakra.button type="button" aria-pressed={selected} css={styles.root} onClick={() => onSelect(theme.id)}><Flex css={styles.preview}>- <Box css={styles.swatch} bg={theme.colors.surface} />- <Box css={styles.swatch} bg={theme.colors.control} />- <Box css={styles.swatch} bg={theme.colors.brand} />- <Box css={styles.swatch} bg={theme.colors.accent} />+ <Box css={styles.swatch} bg={surface} />+ <Box css={styles.swatch} bg={control} />+ <Box css={styles.swatch} bg={brandColor} />+ <Box css={styles.swatch} bg={accentColor} /></Flex><Box css={styles.body}><HStack justify="space-between" w="full">