diff --git a/opencode-plugin/package.json b/opencode-plugin/package.json index 1e8ab6f..a6a68e2 100644 --- a/opencode-plugin/package.json +++ b/opencode-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@jeffreyjyz/opencode-command-code", - "version": "0.5.27", + "version": "0.5.28", "description": "Command Code provider + usage dashboard for opencode: two providers (Anthropic wire for Claude, OpenAI wire for everything else) against api.commandcode.ai, live model list, plan gating, /cmd-usage. Requires the cmduse CLI for usage rendering.", "type": "module", "main": "dist/index.js", diff --git a/opencode-plugin/src/sidebar/settings.tsx b/opencode-plugin/src/sidebar/settings.tsx index f5ca9a8..e063833 100644 --- a/opencode-plugin/src/sidebar/settings.tsx +++ b/opencode-plugin/src/sidebar/settings.tsx @@ -1,21 +1,15 @@ /** @jsxImportSource @opentui/solid */ -// /cmd-settings dialog: one row per sidebar preference, each cycling through -// the labels `settings-rows.ts` already knows. Rows are data there; this file -// is the only place that knows how a row becomes a terminal line — the same -// split the sidebar panel uses. +// /cmd-settings dialog: one row per sidebar preference, cycling the labels +// settings-rows.ts owns. Modelled on opencode-wallpapers' Picker: the modal +// keymap layer lives in the component body, so it dies with the dialog instead +// of swallowing arrow keys in the prompt afterwards. // -// Modelled on opencode-wallpapers' Picker: the modal keymap layer is created -// inside the component body, so it lives exactly as long as the dialog and is -// gone when the dialog closes. `esc` closes through `dialog.clear()` because a -// modal layer's own `escape` binding is the one route that always works, even -// when the host dialog has already claimed the key. -// -// Colours come from the theme's `dialog` surface when the host exposes one -// (`theme.surface("dialog")`), otherwise from the base text tokens. The `hue` -// scales are widget colours, not chrome — see sidebar/panel.tsx. +// Colours come from the theme's `dialog` surface when the host exposes one, +// and follow opencode's own DialogSelect: primary title, secondary value over +// an action-primary band. The `hue` scales are widget colours, not chrome. import { RGBA } from "@opentui/core"; import type { Plugin as TuiPluginNs } from "@opencode/plugin/tui"; -import { createSignal, For } from "solid-js"; +import { createSignal, For, onMount } from "solid-js"; import { loadPrefs, type Prefs, savePrefs } from "./prefs"; import { type SettingRow, settingRows } from "./settings-rows"; @@ -24,14 +18,11 @@ interface ThemeView { readonly text: { readonly base: RGBA; readonly muted: RGBA; - readonly action?: { - readonly primary?: { readonly focused?: RGBA }; - }; + readonly action?: Readonly>; }; readonly background?: { - readonly action?: { - readonly primary?: { readonly focused?: RGBA }; - }; + readonly raised?: { readonly base?: RGBA }; + readonly action?: Readonly>; }; } @@ -40,8 +31,10 @@ interface DialogColors { readonly base: RGBA; /** Every value not under the cursor, and the footer hints. */ readonly muted: RGBA; - /** Title and value of the focused row. */ + /** Selected row's title. */ readonly accent: RGBA; + /** Selected row's value: native lists use the secondary tone, not the accent. */ + readonly secondary: RGBA; /** Focused row's background band. */ readonly selected: RGBA; } @@ -60,17 +53,13 @@ function dialogColors(ctx: TuiPluginNs.Context): DialogColors { base: view.text.base, muted: view.text.muted, accent: view.text.action?.primary?.focused ?? view.text.base, - // A theme without an action background still needs a visible band, so the - // band falls back to the accent's own colour at low alpha (pure black - // transparent would make the selection invisible). + // Matches opencode's own DialogSelect: an active row is a primary title over + // a secondary value, so both in the accent read as one loud block. + secondary: view.text.action?.secondary?.focused ?? view.text.muted, selected: view.background?.action?.primary?.focused ?? - RGBA.fromValues( - view.text.action?.primary?.focused?.r ?? view.text.base.r, - view.text.action?.primary?.focused?.g ?? view.text.base.g, - view.text.action?.primary?.focused?.b ?? view.text.base.b, - 0.25, - ), + view.background?.raised?.base ?? + RGBA.fromInts(0, 0, 0, 0), }; } @@ -81,19 +70,19 @@ function Row(props: { active: () => boolean; onClick: () => void; }) { - const fg = () => (props.active() ? props.colors.accent : props.colors.base); return ( - + {props.row.title} - + {props.active() ? `‹ ${props.row.value()} ›` : props.row.value()} @@ -118,6 +107,16 @@ export function SettingsDialog(props: { ctx: TuiPluginNs.Context }) { const [index, setIndex] = createSignal(0); const current = () => visible()[index()] ?? visible()[0]; + // Native list dialogs open at the large size; the host default is smaller and + // left the description wrapping into a ragged block. + onMount(() => { + try { + ctx.ui.dialog.set({ size: "large" }); + } catch { + // older host without a resizable dialog: the default size still works + } + }); + const move = (direction: number) => { const list = visible(); const length = list.length; @@ -159,8 +158,8 @@ export function SettingsDialog(props: { ctx: TuiPluginNs.Context }) { Command Code settings @@ -182,7 +181,7 @@ export function SettingsDialog(props: { ctx: TuiPluginNs.Context }) { /> )} - + {(() => { const row = current(); @@ -190,7 +189,7 @@ export function SettingsDialog(props: { ctx: TuiPluginNs.Context }) { })()} - + {"↑/↓ setting"} {"enter ←/→ change"}