Browse Source

fix(tui): support single-color themes (#41572)

opencode-agent[bot] 5 ngày trước cách đây
mục cha
commit
6895728add

+ 1 - 1
packages/theme/src/tui/syntax.ts

@@ -12,7 +12,7 @@ export function generateSyntax(theme: ResolvedThemeTokens, mode: Mode) {
     rule(["prompt"], theme.hue.accent[step]),
     rule(["extmark.file"], feedback.warning.default, { bold: true }),
     rule(["extmark.agent"], theme.categorical[0][step], { bold: true }),
-    rule(["extmark.skill"], theme.categorical[1][step], { bold: true }),
+    rule(["extmark.skill"], (theme.categorical[1] ?? theme.categorical[0])[step], { bold: true }),
     // V1 migration preserves its selected/inverse foreground in this action state.
     rule(["extmark.paste"], theme.text.action.primary.focused, {
       background: feedback.warning.default,

+ 9 - 0
packages/tui/test/theme/v2/resolve.test.ts

@@ -2,6 +2,7 @@ import { expect, test } from "bun:test"
 import { RGBA } from "@opentui/core"
 import {
   DEFAULT_THEME,
+  generateSyntax,
   resolveTheme,
   resolveThemeDocument,
   selectTheme,
@@ -42,6 +43,14 @@ test("validates and resolves categorical hues in configured order", () => {
   expect(() => resolveSource({ version: 2, light: { categorical: ["magenta"] } }, "light")).toThrow("Invalid theme")
 })
 
+test("generates syntax with one categorical hue", () => {
+  const theme = resolveSource({ version: 2, light: { categorical: ["red"] } }, "light")
+  const syntax = generateSyntax(theme, "light")
+
+  expect(syntax.getStyleId("extmark.skill")).not.toBeNull()
+  syntax.destroy()
+})
+
 test("uses the default categorical order for direct definitions", () => {
   const theme = resolveTheme({ ...light, categorical: undefined })