GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(tui): draw paste chip text dark in dark mode and light in light m… · yusha/opencode@f352b08

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages
    • theme/src/tui
      • syntax.ts
    • tui/test/theme/v2
      • resolve.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/theme/src/tui/syntax.ts‎

Copy file name to clipboardExpand all lines: packages/theme/src/tui/syntax.ts
+9-5Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@ export function generateSyntax(theme: ResolvedThemeTokens, owner: NativeResource
1313
rule(["extmark.file"], feedback.warning.base, { bold: true }),
1414
rule(["extmark.agent"], theme.categorical[0][step], { bold: true }),
1515
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+
),
2125
rule(["comment", "comment.documentation"], syntax.comment, { italic: true }),
2226
rule(["string", "symbol", "character.special", "character"], syntax.string),
2327
rule(["number", "boolean", "constant", "float"], syntax.number),
Collapse file

‎packages/tui/test/theme/v2/resolve.test.ts‎

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 numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
type ResolvedTheme,
1111
type ThemeDefinition,
1212
} from "@opencode/theme/tui"
13-
import { getOpenCodeTheme, parseTheme, type ThemeDocumentSource } from "../../../src/theme"
13+
import { getOpenCode2Theme, getOpenCodeTheme, parseTheme, type ThemeDocumentSource } from "../../../src/theme"
1414

1515
const opencodeLight = selectTheme(getOpenCodeTheme(), "light")
1616
const opencodeDark = selectTheme(getOpenCodeTheme(), "dark")
@@ -120,6 +120,24 @@ test("generates syntax with one categorical hue", () => {
120120
}
121121
})
122122

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+
123141
test("rejects incomplete themes instead of merging defaults", () => {
124142
expect(() => resolveSource({ light: { hue: light.hue } }, "light")).toThrow("Invalid theme")
125143
expect(() => resolveSource({ light: { ...light, categorical: undefined } }, "light")).toThrow(

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.