Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions packages/opencode/src/cli/cmd/tui/context/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { isRecord } from "@/util/record"
import type { TuiThemeCurrent } from "@opencode-ai/plugin/tui"

type Theme = TuiThemeCurrent & {
readonly toolOutput: RGBA
_hasSelectedListItemText: boolean
}
type ThemeColor = Exclude<keyof TuiThemeCurrent, "thinkingOpacity">
Expand Down Expand Up @@ -78,9 +79,10 @@ type ColorValue = HexColor | RefName | Variant | RGBA
export type ThemeJson = {
$schema?: string
defs?: Record<string, HexColor | RefName>
theme: Omit<Record<ThemeColor, ColorValue>, "selectedListItemText" | "backgroundMenu"> & {
theme: Omit<Record<ThemeColor, ColorValue>, "selectedListItemText" | "backgroundMenu" | "toolOutput"> & {
selectedListItemText?: ColorValue
backgroundMenu?: ColorValue
toolOutput?: ColorValue
thinkingOpacity?: number
}
}
Expand Down Expand Up @@ -222,11 +224,11 @@ export function resolveTheme(theme: ThemeJson, mode: "dark" | "light") {

const resolved = Object.fromEntries(
Object.entries(theme.theme)
.filter(([key]) => key !== "selectedListItemText" && key !== "backgroundMenu" && key !== "thinkingOpacity")
.filter(([key]) => key !== "selectedListItemText" && key !== "backgroundMenu" && key !== "thinkingOpacity" && key !== "toolOutput")
.map(([key, value]) => {
return [key, resolveColor(value as ColorValue)]
}),
) as Partial<Record<ThemeColor, RGBA>>
) as Partial<Record<ThemeColor, RGBA>> & { toolOutput?: RGBA }

// Handle selectedListItemText separately since it's optional
const hasSelectedListItemText = theme.theme.selectedListItemText !== undefined
Expand All @@ -245,6 +247,13 @@ export function resolveTheme(theme: ThemeJson, mode: "dark" | "light") {
resolved.backgroundMenu = resolved.backgroundElement
}

// Handle toolOutput - optional with fallback to text
if (theme.theme.toolOutput !== undefined) {
resolved.toolOutput = resolveColor(theme.theme.toolOutput)
} else {
resolved.toolOutput = resolved.text
}

// Handle thinkingOpacity - optional with default of 0.6
const thinkingOpacity = theme.theme.thinkingOpacity ?? 0.6

Expand Down
4 changes: 2 additions & 2 deletions packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1626,7 +1626,7 @@ function GenericTool(props: ToolProps<any>) {
onClick={overflow() ? () => setExpanded((prev) => !prev) : undefined}
>
<box gap={1}>
<text fg={theme.text}>{limited()}</text>
<text fg={theme.toolOutput}>{limited()}</text>
<Show when={overflow()}>
<text fg={theme.textMuted}>{expanded() ? "Click to collapse" : "Click to expand"}</text>
</Show>
Expand Down Expand Up @@ -1825,7 +1825,7 @@ function Bash(props: ToolProps<typeof BashTool>) {
<box gap={1}>
<text fg={theme.text}>$ {props.input.command}</text>
<Show when={output()}>
<text fg={theme.text}>{limited()}</text>
<text fg={theme.toolOutput}>{limited()}</text>
</Show>
<Show when={overflow()}>
<text fg={theme.textMuted}>{expanded() ? "Click to collapse" : "Click to expand"}</text>
Expand Down