GeezerVison is showing github.com — fix(tui): draw paste chip text dark in dark mode and light in light m… · yusha/opencode@f352b08
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/theme/src/tui/syntax.ts +9-5Lines changed: 9 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -13,11 +13,15 @@ export function generateSyntax(theme: ResolvedThemeTokens, owner: NativeResource | 13 | 13 | rule(["extmark.file"], feedback.warning.base, { bold: true }), | 14 | 14 | rule(["extmark.agent"], theme.categorical[0][step], { bold: true }), | 15 | 15 | rule(["extmark.skill"], (theme.categorical[1] ?? theme.categorical[0])[step], { bold: true }), | 16 | | - // V1 migration preserves its selected/inverse foreground in this action state. | 17 | | - rule(["extmark.paste"], theme.text.action.primary.focused, { | 18 | | - background: feedback.warning.base, | 19 | | - bold: true, | 20 | | - }), | | 16 | + rule( | | 17 | + ["extmark.paste"], | | 18 | + // The page color: dark in dark mode, light in light mode. A transparent page (the system theme) falls back to the selected-row text. | | 19 | + theme.background.base.a === 1 ? theme.background.base : theme.text.action.primary.focused, | | 20 | + { | | 21 | + background: feedback.warning.base, | | 22 | + bold: true, | | 23 | + }, | | 24 | + ), | 21 | 25 | rule(["comment", "comment.documentation"], syntax.comment, { italic: true }), | 22 | 26 | rule(["string", "symbol", "character.special", "character"], syntax.string), | 23 | 27 | rule(["number", "boolean", "constant", "float"], syntax.number), | |
Collapse file Copy file name to clipboardExpand all lines: packages/tui/test/theme/v2/resolve.test.ts +19-1Lines changed: 19 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -10,7 +10,7 @@ import { | 10 | 10 | type ResolvedTheme, | 11 | 11 | type ThemeDefinition, | 12 | 12 | } from "@opencode/theme/tui" | 13 | | -import { getOpenCodeTheme, parseTheme, type ThemeDocumentSource } from "../../../src/theme" | | 13 | +import { getOpenCode2Theme, getOpenCodeTheme, parseTheme, type ThemeDocumentSource } from "../../../src/theme" | 14 | 14 |
| 15 | 15 | const opencodeLight = selectTheme(getOpenCodeTheme(), "light") | 16 | 16 | const opencodeDark = selectTheme(getOpenCodeTheme(), "dark") | @@ -120,6 +120,24 @@ test("generates syntax with one categorical hue", () => { | 120 | 120 | } | 121 | 121 | }) | 122 | 122 |
| | 123 | +test("draws paste chip text dark in dark mode and light in light mode", () => { | | 124 | + for (const mode of ["dark", "light"] as const) { | | 125 | + const theme = resolveThemeDocument(getOpenCode2Theme(), mode) | | 126 | + const owner = new ResourceContext({ objectCapacity: 1, renderCellsMax: 1 }) | | 127 | + const syntax = generateSyntax(theme, owner) | | 128 | + try { | | 129 | + const style = syntax.getStyle("extmark.paste")! | | 130 | + expect(style.bg!.equals(theme.text.feedback.warning.base)).toBeTrue() | | 131 | + const luminance = (color: RGBA) => 0.299 * color.r + 0.587 * color.g + 0.114 * color.b | | 132 | + if (mode === "dark") expect(luminance(style.fg!)).toBeLessThan(luminance(style.bg!)) | | 133 | + else expect(luminance(style.fg!)).toBeGreaterThan(luminance(style.bg!)) | | 134 | + } finally { | | 135 | + syntax.destroy() | | 136 | + owner.destroy() | | 137 | + } | | 138 | + } | | 139 | +}) | | 140 | + | 123 | 141 | test("rejects incomplete themes instead of merging defaults", () => { | 124 | 142 | expect(() => resolveSource({ light: { hue: light.hue } }, "light")).toThrow("Invalid theme") | 125 | 143 | expect(() => resolveSource({ light: { ...light, categorical: undefined } }, "light")).toThrow( | |
|