fix(theme): lift the composer unless the V1 panel is fully transparent

This commit is contained in:
Aarav Sareen 2026-11-10 17:51:53 +05:30
parent f852933d56
commit a3ede9a35c
2 changed files with 22 additions and 14 deletions

View file

@ -54,18 +54,19 @@ const lightDialog = {
},
} satisfies ModeDefinition["@dialog"]
// The light composer sits level with raised panels, a step lighter than the dark one, like opencode2's.
// Transparent panels keep step 700 transparent, so those themes keep the composer on step 600.
// Light composers sit on step 700, level with raised panels, like opencode2's.
const lightComposer = {
background: { raised: { high: "$hue.neutral.700" } },
} satisfies ModeDefinition["@composer"]
function lightOverrides(definition: ThemeDefinition, theme: Theme): ModeDefinition {
if (theme.backgroundPanel.a === 1)
return { hue: definition.hue, "@dialog": lightDialog, "@composer": lightComposer }
// Step 700 stays transparent when the V1 panel is, so those composers keep step 600.
const composer = theme.backgroundPanel.toInts()[3] > 0 ? { "@composer": lightComposer } : {}
if (theme.backgroundPanel.a === 1) return { hue: definition.hue, "@dialog": lightDialog, ...composer }
return {
hue: definition.hue,
"@dialog": { ...lightDialog, background: { ...lightDialog.background, base: dialogBackground(theme) } },
...composer,
}
}

View file

@ -315,17 +315,24 @@ test("gives new designs dialogs an opaque background when V1 panels are see-thro
expect(opaque.light?.["@dialog"]?.background?.base).toBe("$hue.neutral.800")
})
test("lifts the new designs composer to step 700 in light unless V1 panels are see-through", () => {
for (const name of ["tokyonight", "lucent-orng"]) {
const migrated = migrateV1NewDesigns(DEFAULT_THEMES[name]!)
const light = resolveThemeDocument(migrated, "light")
const dark = resolveThemeDocument(migrated, "dark")
const lifted = resolveV1(DEFAULT_THEMES[name]!, "light").backgroundPanel.a === 1
expect(light.surface("composer").background.raised.high).toBe(
lifted ? light.hue.neutral[700] : light.hue.neutral[600],
)
expect(dark.surface("composer").background.raised.high).toBe(dark.hue.neutral[600])
test("lifts the new designs composer to step 700 in light unless V1 panels are transparent", () => {
const composer = (source: ThemeV1Json, mode: "light" | "dark") => {
const resolved = resolveThemeDocument(migrateV1NewDesigns(source), mode)
return { color: resolved.surface("composer").background.raised.high, neutral: resolved.hue.neutral }
}
const opaque = composer(DEFAULT_THEMES.tokyonight!, "light")
expect(opaque.color).toBe(opaque.neutral[700])
const dark = composer(DEFAULT_THEMES.tokyonight!, "dark")
expect(dark.color).toBe(dark.neutral[600])
const transparent = composer(DEFAULT_THEMES["lucent-orng"]!, "light")
expect(transparent.color).toBe(transparent.neutral[600])
const translucentSource = structuredClone(opencodeV1)
translucentSource.theme.backgroundPanel = "#f0f0f080"
const translucent = composer(translucentSource, "light")
expect(translucent.color).toBe(translucent.neutral[700])
expect(translucent.color.a).toBe(1)
})
test("keeps both modes when a shared background has different contrast", () => {