From ccda0cf68442641af55821635e378fdb7138d915 Mon Sep 17 00:00:00 2001 From: "Lucy E. Arias" Date: Fri, 4 Dec 2026 20:22:28 -0500 Subject: [PATCH 1/2] fix(ryoku-zed-theme): derive a real light variant when the palette renders dark Ryoku's palette plane can render a single dark scheme into both matugen template variants, so 'Ryoku Dynamic Light' shipped with the same dark surfaces as Dark (background luminance ~0.01). Zed users who switch to light mode got a dark editor while the rest of the system went light. Sync now checks each variant's surface luminance against its declared appearance. When they disagree, it rebuilds the variant from the opposite one: hue and chroma are preserved, lightness is mirrored across the source theme's own background-to-text OKLCH range (clamped to the gamut), and the existing improve() pass re-enforces WCAG AA contrast. The dark variant output is byte-identical to before when the source is sane. Bump the bundle to 1.2.1 and refresh the manifest and registry hashes. --- bundles/registry.json | 4 +- bundles/ryoku-zed-theme/bundle.json | 6 +- .../ryoku-zed-theme/runtime/scripts/theme.ts | 63 +++++++++++++++++++ 3 files changed, 68 insertions(+), 5 deletions(-) diff --git a/bundles/registry.json b/bundles/registry.json index bdb7f991..1ee8a938 100644 --- a/bundles/registry.json +++ b/bundles/registry.json @@ -689,7 +689,7 @@ { "id": "ryoku-zed-theme", "name": "Ryoku for Zed", - "version": "1.2.0", + "version": "1.2.1", "path": "bundles/ryoku-zed-theme", "author": "Ryoku Team", "upstream": "https://github.com/Ryoku-dev/ryostore/tree/main/bundles/ryoku-zed-theme", @@ -712,7 +712,7 @@ "assets/ryoku-blue.png" ], "manifest": "bundle.json", - "manifestSha256": "1c78bdd582669d295ad3353e85a20b4690ca89b81973ed40d99c12952c823e5f", + "manifestSha256": "db023a06381db4e1257ce32d8e5c6708d7de8104f701e3811fea1ccc8cb7a908", "components": [ { "type": "package", diff --git a/bundles/ryoku-zed-theme/bundle.json b/bundles/ryoku-zed-theme/bundle.json index f3b6d39d..a329a193 100644 --- a/bundles/ryoku-zed-theme/bundle.json +++ b/bundles/ryoku-zed-theme/bundle.json @@ -2,7 +2,7 @@ "schema": 1, "id": "ryoku-zed-theme", "category": "bundles", - "version": "1.2.0", + "version": "1.2.1", "destination": "ryoku/bundles/ryoku-zed-theme", "name": "Ryoku for Zed", "description": "Keep Zed's UI and syntax colors in step with Ryoku's wallpaper palette, including monochrome wallpapers.", @@ -104,8 +104,8 @@ "source": "runtime/scripts/theme.ts", "destination": "runtime/scripts/theme.ts", "mode": "0644", - "size": 12406, - "sha256": "0618c3c2f3ea142a885ee0d4a2e77a2ce1e1358973c0029e4c9a13805547f968", + "size": 15921, + "sha256": "6caaf3e6d930b779e4bdc1994436d41826bef6dc842d1dd6373c9bf671cc4c41", "install": false }, { diff --git a/bundles/ryoku-zed-theme/runtime/scripts/theme.ts b/bundles/ryoku-zed-theme/runtime/scripts/theme.ts index a048177e..2b4377b8 100644 --- a/bundles/ryoku-zed-theme/runtime/scripts/theme.ts +++ b/bundles/ryoku-zed-theme/runtime/scripts/theme.ts @@ -221,6 +221,52 @@ function syntheticMonochromeVariants(fallback: Json): Json[] { }); } +function surfaceLuminance(style: Json): number | null { + const bg = style["editor.background"] ?? style.background; + const rgb = hex(bg); + return rgb ? luminance(rgb) : null; +} + +// Ryoku's palette plane can render a single (dark) scheme into both template +// variants, leaving the "light" theme with a dark surface. When a variant +// arrives with the wrong surface for its appearance, rebuild it from the +// opposite variant: hue and chroma are preserved and only lightness is +// mirrored across the source theme's own background-to-text range, then +// improve() re-enforces WCAG contrast on the result. +function deriveOppositeVariant(source: Json, appearance: "light" | "dark"): Json { + const theme = structuredClone(source); + theme.appearance = appearance; + const style = theme.style as Json; + const srcStyle = source.style as Json; + const bgL = toOklch((srcStyle["editor.background"] ?? srcStyle.background) as string)?.l ?? 0.2; + const textL = toOklch(srcStyle.text as string)?.l ?? (appearance === "light" ? 0.9 : 0.2); + const targetBg = appearance === "light" ? 0.97 : 0.17; + const targetText = appearance === "light" ? 0.24 : 0.93; + const direction = textL >= bgL ? 1 : -1; + const span = Math.max(0.05, Math.abs(textL - bgL)); + const remap = (color: unknown): unknown => { + if (typeof color !== "string") return color; + const alpha = color.match(/^#?[\da-f]{6}([\da-f]{2})?$/i)?.[1]; + const parsed = toOklch(color); + if (parsed === null || !/^#?[\da-f]{6}([\da-f]{2})?$/i.test(color)) return color; + const rel = Math.min(1.25, Math.max(-0.25, ((parsed.l - bgL) * direction) / span)); + const l = Math.min(0.99, Math.max(0.02, targetBg + rel * (targetText - targetBg))); + const mapped = fromOklch({ l, c: parsed.c, h: parsed.h }); + return alpha ? `${mapped}${alpha}` : mapped; + }; + for (const [key, value] of Object.entries(style)) { + if (typeof value === "string") style[key] = remap(value); + else if (value && typeof value === "object" && !Array.isArray(value) && typeof (value as Json).color === "string") + (value as Json).color = remap((value as Json).color); + } + if (Array.isArray(style.accents)) style.accents = style.accents.map(remap); + if (Array.isArray(style.players)) for (const player of style.players as Json[]) { + if (!player) continue; + for (const key of ["cursor", "background", "selection"]) if (player[key]) player[key] = remap(player[key]); + } + return theme; +} + function checkHueSeparation(theme: Json) { const style = theme.style as Json; const categories = ["function", "string", "number", "constant", "boolean", "keyword", "type", "constructor", "operator"]; @@ -237,6 +283,7 @@ function checkHueSeparation(theme: Json) { } let family: Json; +const syncNotes: string[] = []; if (mode === "bootstrap") { family = await readJson(checkedIn); } else if (mode === "verify-monochrome") { @@ -254,6 +301,21 @@ if (mode === "bootstrap") { name: `Ryoku Dynamic ${theme.appearance === "light" ? "Light" : "Dark"}`, })); family.$schema = "https://zed.dev/schema/themes/v0.2.0.json"; + const dark = family.themes.find((theme: Json) => theme.appearance === "dark"); + const light = family.themes.find((theme: Json) => theme.appearance === "light"); + if (dark && light) { + const lightLum = surfaceLuminance(light.style as Json); + const darkLum = surfaceLuminance(dark.style as Json); + if (lightLum !== null && lightLum < 0.45) { + family.themes = family.themes.map((theme: Json) => + theme === light ? { ...deriveOppositeVariant(dark, "light"), name: light.name } : theme); + syncNotes.push(`light variant derived from dark (source rendered a dark surface, luminance ${lightLum.toFixed(3)})`); + } else if (darkLum !== null && darkLum >= 0.45) { + family.themes = family.themes.map((theme: Json) => + theme === dark ? { ...deriveOppositeVariant(light, "dark"), name: dark.name } : theme); + syncNotes.push(`dark variant derived from light (source rendered a light surface, luminance ${darkLum.toFixed(3)})`); + } + } } let report = ""; @@ -275,4 +337,5 @@ if (mode === "bootstrap") { await mkdir(dirname(outputPath), { recursive: true }); await writeFile(outputPath, `${JSON.stringify(family, null, 2)}\n`); console.log(`Wrote ${outputPath}\n${report.trim()}`); + for (const note of syncNotes) console.log(`note: ${note}`); } From 95f780147619a856d9afdb032e34777af5d24c9c Mon Sep 17 00:00:00 2001 From: "Lucy E. Arias" Date: Fri, 4 Dec 2026 21:33:19 -0500 Subject: [PATCH 2/2] fix(ryoku-zed-theme): hue-shift enum and variant with their siblings The template's new enum and variant scopes matched no rule in syntaxHueOffsets, so the generator re-hued type and constructor while enum and variant kept the raw palette hues. With a grayscale wallpaper the siblings turned colored and the new scopes stayed gray. Give enum the type offset (240) and variant the constructor offset (280) so each follows its sibling under every palette. Verified: enum renders the same hue as type and variant as constructor in both variants, and the monochrome validation still passes. Found by Greptile on ryoku-dev/ryoku#1063. --- bundles/registry.json | 2 +- bundles/ryoku-zed-theme/bundle.json | 4 ++-- bundles/ryoku-zed-theme/runtime/scripts/theme.ts | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bundles/registry.json b/bundles/registry.json index 1ee8a938..72a12a01 100644 --- a/bundles/registry.json +++ b/bundles/registry.json @@ -712,7 +712,7 @@ "assets/ryoku-blue.png" ], "manifest": "bundle.json", - "manifestSha256": "db023a06381db4e1257ce32d8e5c6708d7de8104f701e3811fea1ccc8cb7a908", + "manifestSha256": "f26d235f7867bd21a419a80596ffa2abcd3f88db5b22470196131608e03820c0", "components": [ { "type": "package", diff --git a/bundles/ryoku-zed-theme/bundle.json b/bundles/ryoku-zed-theme/bundle.json index a329a193..fa60cb8a 100644 --- a/bundles/ryoku-zed-theme/bundle.json +++ b/bundles/ryoku-zed-theme/bundle.json @@ -104,8 +104,8 @@ "source": "runtime/scripts/theme.ts", "destination": "runtime/scripts/theme.ts", "mode": "0644", - "size": 15921, - "sha256": "6caaf3e6d930b779e4bdc1994436d41826bef6dc842d1dd6373c9bf671cc4c41", + "size": 15954, + "sha256": "6d4ec206efe735ac7a4ac26840e6ab0af255acf7c507327ac7525d94140f2339", "install": false }, { diff --git a/bundles/ryoku-zed-theme/runtime/scripts/theme.ts b/bundles/ryoku-zed-theme/runtime/scripts/theme.ts index 2b4377b8..b643e35e 100644 --- a/bundles/ryoku-zed-theme/runtime/scripts/theme.ts +++ b/bundles/ryoku-zed-theme/runtime/scripts/theme.ts @@ -107,6 +107,8 @@ const syntaxHueOffsets: Record = { "text.literal": 40, "emphasis.strong": 0, "constructor": 280, + "variant": 280, + "enum": 240, "boolean": 160, "constant": 120, "function": 0,