Skip to content

Commit 03eabb1

Browse files
authored
fix: use selectedForeground's computer colour (or theme's selectedForeground value) for the colour of text in permission selection (resolves anomalyco#7246) (anomalyco#7251)
1 parent 34c9d10 commit 03eabb1

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

packages/opencode/src/cli/cmd/tui/context/theme.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,16 @@ type Theme = ThemeColors & {
102102
thinkingOpacity: number
103103
}
104104

105-
export function selectedForeground(theme: Theme): RGBA {
105+
export function selectedForeground(theme: Theme, bg?: RGBA): RGBA {
106106
// If theme explicitly defines selectedListItemText, use it
107107
if (theme._hasSelectedListItemText) {
108108
return theme.selectedListItemText
109109
}
110110

111-
// For transparent backgrounds, calculate contrast based on primary color
111+
// For transparent backgrounds, calculate contrast based on the actual bg (or fallback to primary)
112112
if (theme.background.a === 0) {
113-
const { r, g, b } = theme.primary
113+
const targetColor = bg ?? theme.primary
114+
const { r, g, b } = targetColor
114115
const luminance = 0.299 * r + 0.587 * g + 0.114 * b
115116
return luminance > 0.5 ? RGBA.fromInts(0, 0, 0) : RGBA.fromInts(255, 255, 255)
116117
}

packages/opencode/src/cli/cmd/tui/routes/session/permission.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createMemo, For, Match, Show, Switch } from "solid-js"
33
import { useKeyboard, useTerminalDimensions, type JSX } from "@opentui/solid"
44
import type { TextareaRenderable } from "@opentui/core"
55
import { useKeybind } from "../../context/keybind"
6-
import { useTheme } from "../../context/theme"
6+
import { useTheme, selectedForeground } from "../../context/theme"
77
import type { PermissionRequest } from "@opencode-ai/sdk/v2"
88
import { useSDK } from "../../context/sdk"
99
import { SplitBorder } from "../../component/border"
@@ -395,7 +395,7 @@ function Prompt<const T extends Record<string, string>>(props: {
395395
paddingRight={1}
396396
backgroundColor={option === store.selected ? theme.warning : theme.backgroundMenu}
397397
>
398-
<text fg={option === store.selected ? theme.selectedListItemText : theme.textMuted}>
398+
<text fg={option === store.selected ? selectedForeground(theme, theme.warning) : theme.textMuted}>
399399
{props.options[option]}
400400
</text>
401401
</box>

0 commit comments

Comments
 (0)