The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 24, 16:30 UTC
fix(web): bound OKLCH gamut mapping (#6485)
Co-authored-by: Simone <185146821+Lucenx9@users.noreply.github.com>
Simone committed
Aug 15, 2026 at 01:32 UTC
74f7b434865c2d758c7b1cd5f52f4c96b76d03fb
2 files changed
+17
-1
apps/web/src/themePalette.test.ts
+12
@@ -246,6 +246,18 @@ describe("theme files", () => {
246
}
247
});
248
249
+ it("gamut maps extreme finite OKLCH chroma from theme files", () => {
250
+ const theme = parseThemeFile({
251
+ version: THEME_FILE_VERSION,
252
+ name: "Extreme chroma",
253
+ appearance: "light",
254
+ colors: { accent: "oklch(0.5 1e303 0)" },
255
+ });
256
+
257
+ expect(theme.colors.accent).toBe("oklch(0.5 1e+303 0)");
258
+ expect(themeColorToHex(theme.colors.accent)).toBe("#b5005e");
259
+ });
260
+
261
it("rejects unknown roles and invalid color values", () => {
262
expect(() =>
263
parseThemeFile({
apps/web/src/themePalette.ts
+5
-1
@@ -902,7 +902,11 @@ function mapThemeOklchToSrgbGamut(color: ThemeOklch): ThemeOklch {
902
903
let low = 0;
904
let high = color.C;
905
- const steps = Math.max(1, Math.ceil(Math.log2(Math.max(color.C, 0.000001) / 0.000001)));
905
+ const chromaResolution = 0.000001;
906
+ const steps = Math.max(
907
+ 1,
908
+ Math.ceil(Math.log2(Math.max(color.C, chromaResolution)) - Math.log2(chromaResolution)),
909
+ );
910
for (let step = 0; step < steps; step += 1) {
911
const mid = (low + high) / 2;
912
if (isInGamut(mid)) low = mid;