diff --git a/packages/theme/src/tui/v1-migrate-new-designs.ts b/packages/theme/src/tui/v1-migrate-new-designs.ts index 9929a85aba7..497bc250cb0 100644 --- a/packages/theme/src/tui/v1-migrate-new-designs.ts +++ b/packages/theme/src/tui/v1-migrate-new-designs.ts @@ -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, } } diff --git a/packages/tui/test/theme/v2/v1-migrate.test.ts b/packages/tui/test/theme/v2/v1-migrate.test.ts index 58ace36b015..82c3e4c480e 100644 --- a/packages/tui/test/theme/v2/v1-migrate.test.ts +++ b/packages/tui/test/theme/v2/v1-migrate.test.ts @@ -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", () => {