Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
fix(web): bound OKLCH gamut mapping (#6485)
Simone74f7b434865c
diff --git a/apps/web/src/themePalette.test.ts b/apps/web/src/themePalette.test.tsindex 95ce10af9..3c5897c70 100644--- a/apps/web/src/themePalette.test.ts+++ b/apps/web/src/themePalette.test.ts@@ -246,6 +246,18 @@ describe("theme files", () => {}});+ it("gamut maps extreme finite OKLCH chroma from theme files", () => {+ const theme = parseThemeFile({+ version: THEME_FILE_VERSION,+ name: "Extreme chroma",+ appearance: "light",+ colors: { accent: "oklch(0.5 1e303 0)" },+ });++ expect(theme.colors.accent).toBe("oklch(0.5 1e+303 0)");+ expect(themeColorToHex(theme.colors.accent)).toBe("#b5005e");+ });+it("rejects unknown roles and invalid color values", () => {expect(() =>parseThemeFile({diff --git a/apps/web/src/themePalette.ts b/apps/web/src/themePalette.tsindex 00b29dce8..7bf4f0426 100644--- a/apps/web/src/themePalette.ts+++ b/apps/web/src/themePalette.ts@@ -902,7 +902,11 @@ function mapThemeOklchToSrgbGamut(color: ThemeOklch): ThemeOklch {let low = 0;let high = color.C;- const steps = Math.max(1, Math.ceil(Math.log2(Math.max(color.C, 0.000001) / 0.000001)));+ const chromaResolution = 0.000001;+ const steps = Math.max(+ 1,+ Math.ceil(Math.log2(Math.max(color.C, chromaResolution)) - Math.log2(chromaResolution)),+ );for (let step = 0; step < steps; step += 1) {const mid = (low + high) / 2;if (isInGamut(mid)) low = mid;