From 588bf7b12ecca630be996cfa616504930992ea47 Mon Sep 17 00:00:00 2001 From: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com> Date: Wed, 7 Oct 2026 19:33:57 -0400 Subject: [PATCH] refactor(tui): unify dialog row styling with shared rowColors helper --- ocm-cli/src/tui-form.tsx | 41 ++++++++++++++++-------- ocm-cli/src/tui-multi-run-dialogs.tsx | 46 +++++++++++++-------------- 2 files changed, 50 insertions(+), 37 deletions(-) diff --git a/ocm-cli/src/tui-form.tsx b/ocm-cli/src/tui-form.tsx index 7f8c57a6..332cfd05 100644 --- a/ocm-cli/src/tui-form.tsx +++ b/ocm-cli/src/tui-form.tsx @@ -12,6 +12,25 @@ export type KeyHint = readonly [key: string, label: string] const PICKER_ROWS = 8 +/** + * Row colors matching OpenCode's select dialogs: every text in the cursor row uses the + * primary-action focused color on the focused background; a chosen row away from the + * cursor uses the selected form-field color for its marker and title. + */ +export function rowColors(theme: DialogTheme, state: { active: boolean; chosen?: boolean }) { + if (state.active) { + const text = theme.text.action.primary.focused + return { background: theme.background.action.primary.focused, title: text, detail: text, marker: text, bold: true } + } + return { + background: undefined, + title: state.chosen ? theme.text.formfield.selected : theme.text.base, + detail: theme.text.muted, + marker: state.chosen ? theme.text.formfield.selected : theme.text.muted, + bold: false, + } +} + /** True for the dialog-wide submit chord. */ export function isSubmitKey(event: KeyEvent): boolean { return event.ctrl && event.name === 's' @@ -253,24 +272,20 @@ export function ModelPicker(props: { 0} fallback={No matching models}> {(option, index) => { - const active = () => props.focused && windowStart() + index() === cursor() - const chosen = () => props.selected.includes(option.value) + const colors = () => + rowColors(props.theme, { + active: props.focused && windowStart() + index() === cursor(), + chosen: props.selected.includes(option.value), + }) return ( - - + + {marker(option.value)} - + {option.title} - + {option.description} diff --git a/ocm-cli/src/tui-multi-run-dialogs.tsx b/ocm-cli/src/tui-multi-run-dialogs.tsx index 347be383..d6252ca9 100644 --- a/ocm-cli/src/tui-multi-run-dialogs.tsx +++ b/ocm-cli/src/tui-multi-run-dialogs.tsx @@ -1,4 +1,5 @@ /** @jsxImportSource @opentui/solid */ +import { TextAttributes } from '@opentui/core' import { useKeyboard } from '@opentui/solid' import { createEffect, createMemo, createSignal, For, on, onMount, Show } from 'solid-js' import type { Context } from '@opencode/plugin/tui/context' @@ -25,6 +26,7 @@ import { TextAreaField, TextField, isSubmitKey, + rowColors, useFieldFocus, } from './tui-form.js' import type { DialogTheme } from './tui-form.js' @@ -347,18 +349,19 @@ function MultiRunsDialog(props: MultiRunsDialogProps & { context: Context }) { {(item, index) => { - const active = () => index() === runIndex() - const focused = () => active() && pane() === 'runs' + const colors = () => + rowColors(theme, { active: index() === runIndex() && pane() === 'runs', chosen: index() === runIndex() }) return ( - + {item.name} - + {runSummary(item)} @@ -420,11 +423,7 @@ function RunDetails(props: { {(row, index) => { const active = () => props.focused && index() === props.rowIndex return ( - + {row.kind === 'entry' ? ( ) : ( @@ -446,22 +445,22 @@ function RunDetails(props: { } function EntryRow(props: { theme: DialogTheme; entry: MultiRunEntry; active: boolean; selected: boolean }) { + const colors = () => rowColors(props.theme, { active: props.active, chosen: props.selected }) + const statusColor = () => + !props.active && props.entry.status === 'failed' ? props.theme.text.feedback.error.base : colors().detail return ( <> - + {props.selected ? '[x]' : '[ ]'} {props.entry.model} - + {formatEntryStatus(props.entry)} @@ -469,19 +468,18 @@ function EntryRow(props: { theme: DialogTheme; entry: MultiRunEntry; active: boo } function FusionRow(props: { theme: DialogTheme; fusion: MultiRunFusion; active: boolean }) { + const colors = () => rowColors(props.theme, { active: props.active }) + const statusColor = () => + !props.active && props.fusion.status === 'failed' ? props.theme.text.feedback.error.base : colors().detail return ( <> - + {' ⇢'} - + fusion {props.fusion.model} - + {[props.fusion.status, props.fusion.error].filter(Boolean).join(' · ')}