|
1 | 1 | import { withAlpha } from "@opencode-ai/ui/theme/color" |
2 | 2 | import { useTheme } from "@opencode-ai/ui/theme/context" |
3 | 3 | import { resolveThemeVariant } from "@opencode-ai/ui/theme/resolve" |
4 | | -import type { HexColor } from "@opencode-ai/ui/theme/types" |
| 4 | +import { resolveThemeVariantV2 } from "@opencode-ai/ui/theme/v2/resolve" |
| 5 | +import type { HexColor, ResolvedV2Theme } from "@opencode-ai/ui/theme/types" |
5 | 6 | import { showToast } from "@/utils/toast" |
6 | 7 | import type { FitAddon, Ghostty, Terminal as Term } from "ghostty-web" |
7 | 8 | import { type ComponentProps, createEffect, createMemo, onCleanup, onMount, splitProps } from "solid-js" |
@@ -68,6 +69,19 @@ const debugTerminal = (...values: unknown[]) => { |
68 | 69 | console.debug("[terminal]", ...values) |
69 | 70 | } |
70 | 71 |
|
| 72 | +const resolveV2Token = (tokens: ResolvedV2Theme, key: string) => { |
| 73 | + let current = tokens[key] |
| 74 | + for (let i = 0; i < 8 && current; i++) { |
| 75 | + const match = /^var\(--([^)]+)\)$/.exec(current.trim()) |
| 76 | + if (!match) { |
| 77 | + const hex = current.trim() |
| 78 | + if (/^#[0-9a-fA-F]{8}$/.test(hex)) return hex.slice(0, 7) |
| 79 | + return hex |
| 80 | + } |
| 81 | + current = tokens[match[1]] |
| 82 | + } |
| 83 | +} |
| 84 | + |
71 | 85 | const useTerminalUiBindings = (input: { |
72 | 86 | container: HTMLDivElement |
73 | 87 | term: Term |
@@ -238,7 +252,10 @@ export const Terminal = (props: TerminalProps) => { |
238 | 252 | if (!variant?.seeds && !variant?.palette) return fallback |
239 | 253 | const resolved = resolveThemeVariant(variant, mode === "dark") |
240 | 254 | const text = resolved["text-stronger"] ?? fallback.foreground |
241 | | - const background = resolved["background-stronger"] ?? fallback.background |
| 255 | + const background = settings.general.newLayoutDesigns() |
| 256 | + ? (resolveV2Token(resolveThemeVariantV2(variant, mode === "dark"), "v2-background-bg-base") ?? |
| 257 | + fallback.background) |
| 258 | + : (resolved["background-stronger"] ?? fallback.background) |
242 | 259 | const alpha = mode === "dark" ? 0.25 : 0.2 |
243 | 260 | const base = text.startsWith("#") ? (text as HexColor) : (fallback.foreground as HexColor) |
244 | 261 | const selectionBackground = withAlpha(base, alpha) |
|
0 commit comments