From 50df99a8f31b891bb5735e9f69275cf7d0b824a1 Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" Date: Sun, 31 May 2026 20:45:17 +0000 Subject: [PATCH] fix(tui): soften syntax colors for calls and builtins --- .../src/cli/cmd/tui/context/theme.tsx | 26 ++++++++++++++++--- .../opencode/test/cli/tui/theme-store.test.ts | 16 +++++++++++- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/packages/opencode/src/cli/cmd/tui/context/theme.tsx b/packages/opencode/src/cli/cmd/tui/context/theme.tsx index 33dfd3056d..5fb465ba59 100644 --- a/packages/opencode/src/cli/cmd/tui/context/theme.tsx +++ b/packages/opencode/src/cli/cmd/tui/context/theme.tsx @@ -834,6 +834,12 @@ function getSyntaxRules(theme: Theme) { foreground: theme.syntaxFunction, }, }, + { + scope: ["function.call", "function.method.call", "function.builtin"], + style: { + foreground: theme.syntaxFunction, + }, + }, { scope: ["keyword"], style: { @@ -860,11 +866,17 @@ function getSyntaxRules(theme: Theme) { }, }, { - scope: ["variable", "variable.parameter", "function.method.call", "function.call"], + scope: ["variable"], style: { foreground: theme.syntaxVariable, }, }, + { + scope: ["variable.parameter", "variable.builtin", "module.builtin"], + style: { + foreground: theme.text, + }, + }, { scope: ["variable.member", "function", "constructor"], style: { @@ -908,15 +920,21 @@ function getSyntaxRules(theme: Theme) { }, }, { - scope: ["variable.builtin", "type.builtin", "function.builtin", "module.builtin", "constant.builtin"], + scope: ["type.builtin"], style: { - foreground: theme.error, + foreground: theme.syntaxType, + }, + }, + { + scope: ["constant.builtin"], + style: { + foreground: theme.syntaxNumber, }, }, { scope: ["variable.super"], style: { - foreground: theme.error, + foreground: theme.syntaxKeyword, }, }, { diff --git a/packages/opencode/test/cli/tui/theme-store.test.ts b/packages/opencode/test/cli/tui/theme-store.test.ts index 9ebfc4320e..f290240121 100644 --- a/packages/opencode/test/cli/tui/theme-store.test.ts +++ b/packages/opencode/test/cli/tui/theme-store.test.ts @@ -1,6 +1,6 @@ import { expect, test } from "bun:test" -const { DEFAULT_THEMES, allThemes, addTheme, hasTheme, resolveTheme } = await import( +const { DEFAULT_THEMES, allThemes, addTheme, generateSyntax, hasTheme, resolveTheme } = await import( "../../../src/cli/cmd/tui/context/theme" ) @@ -49,3 +49,17 @@ test("resolveTheme rejects circular color refs", () => { expect(() => resolveTheme(item, "dark")).toThrow("Circular color reference") }) + +test("generateSyntax maps calls and builtins away from error red", () => { + const theme = resolveTheme(DEFAULT_THEMES.opencode, "dark") + const syntax = generateSyntax(theme) + + try { + expect(syntax.getStyle("function.call")?.fg?.equals(theme.syntaxFunction)).toBe(true) + expect(syntax.getStyle("function.builtin")?.fg?.equals(theme.syntaxFunction)).toBe(true) + expect(syntax.getStyle("variable.parameter")?.fg?.equals(theme.text)).toBe(true) + expect(syntax.getStyle("function.builtin")?.fg?.equals(theme.error)).toBe(false) + } finally { + syntax.destroy() + } +})