From 726cf096396d5014c3b1845e231cc01efe0421ee Mon Sep 17 00:00:00 2001 From: Aarav Sareen <96787824+arvsrn@users.noreply.github.com> Date: Thu, 29 Oct 2026 16:15:05 +0530 Subject: [PATCH] feat(tui): add dialog footer theme override and retire faint in new designs (#60003) --- packages/theme/src/tui/expand.ts | 10 +++++++++- packages/theme/src/tui/index.ts | 1 + packages/theme/src/tui/resolve.ts | 9 +++++++-- packages/theme/src/tui/schema.ts | 14 ++++++++++---- packages/tui/src/component/model-options.tsx | 4 ++-- packages/tui/src/theme/assets/v2/opencode2.json | 14 +++++++++----- packages/tui/src/ui/dialog-prompt.tsx | 7 +++---- packages/tui/src/ui/dialog-select.tsx | 14 +++++++------- packages/tui/src/ui/dialog.tsx | 8 ++++---- packages/tui/test/theme/v2/resolve.test.ts | 17 +++++++++++++++++ 10 files changed, 69 insertions(+), 29 deletions(-) diff --git a/packages/theme/src/tui/expand.ts b/packages/theme/src/tui/expand.ts index 4b4180bb20c..3cf77c09ef0 100644 --- a/packages/theme/src/tui/expand.ts +++ b/packages/theme/src/tui/expand.ts @@ -1,5 +1,6 @@ import type { BackgroundDefinition, + DialogTokensDefinition, ModeDefinition, StatefulColorDefinition, TextDefinition, @@ -11,7 +12,14 @@ export function expandTheme(definition: Defin return { ...definition, ...expandTokens(definition), - ...(definition["@dialog"] ? { "@dialog": expandTokens(definition["@dialog"]) } : {}), + ...(definition["@dialog"] ? { "@dialog": expandDialog(definition["@dialog"]) } : {}), + } +} + +function expandDialog(definition: DialogTokensDefinition): DialogTokensDefinition { + return { + ...expandTokens(definition), + ...(definition["@footer"] ? { "@footer": expandTokens(definition["@footer"]) } : {}), } } diff --git a/packages/theme/src/tui/index.ts b/packages/theme/src/tui/index.ts index fbbf8289c29..061505db002 100644 --- a/packages/theme/src/tui/index.ts +++ b/packages/theme/src/tui/index.ts @@ -18,6 +18,7 @@ export { ThemeDefinition, ThemeDocument, type BackgroundDefinition, + type DialogTokensDefinition, type DiffDefinition, type FormfieldColorDefinition, type HueDefinition, diff --git a/packages/theme/src/tui/resolve.ts b/packages/theme/src/tui/resolve.ts index 62708675691..e8607d32489 100644 --- a/packages/theme/src/tui/resolve.ts +++ b/packages/theme/src/tui/resolve.ts @@ -76,11 +76,16 @@ function resolveExpandedTheme(definition: ThemeDefinition): ResolvedTheme { ...resolveView(tokens, hue, categorical, hueSteps), surface: (name) => views[name], }) - views.dialog = definition["@dialog"] ? view(contextualize(base, definition["@dialog"])) : view(base) + const dialog = definition["@dialog"] + const dialogTokens = dialog ? contextualize(base, tokens(dialog)) : base + views.dialog = view(dialogTokens) + // The footer override layers on the dialog surface, so footers keep every dialog token they don't override. + const footer = dialog?.["@footer"] + views["dialog.footer"] = footer ? view(contextualize(dialogTokens, footer)) : views.dialog return view(base) } -function tokens(definition: ThemeDefinition): ThemeTokensDefinition { +function tokens(definition: ThemeTokensDefinition): ThemeTokensDefinition { return { text: definition.text, background: definition.background, diff --git a/packages/theme/src/tui/schema.ts b/packages/theme/src/tui/schema.ts index 7ad4eb89fdc..fd57b19e8ba 100644 --- a/packages/theme/src/tui/schema.ts +++ b/packages/theme/src/tui/schema.ts @@ -11,7 +11,7 @@ export const ActionState = Schema.Literals(["disabled", "pressed", "focused", "s export type ActionState = Schema.Schema.Type export type ActionStateKey = `$${ActionState}` -export const SurfaceName = Schema.Literal("dialog") +export const SurfaceName = Schema.Literals(["dialog", "dialog.footer"]) export type SurfaceName = Schema.Schema.Type export const FormfieldState = ActionState @@ -201,6 +201,12 @@ const ThemeTokensDefinition = Schema.Struct({ }) export type ThemeTokensDefinition = Schema.Schema.Type +const DialogTokensDefinition = Schema.Struct({ + ...ThemeTokensDefinition.fields, + "@footer": Schema.optional(ThemeTokensDefinition), +}) +export type DialogTokensDefinition = Schema.Schema.Type + const CompleteStatefulColorDefinition = Schema.Struct({ base: ColorValue, $hovered: Schema.optional(ColorValue), @@ -264,7 +270,7 @@ const ThemeDefinitionFields = Schema.Struct({ hue: HueDefinition, categorical: CategoricalDefinition, ...CompleteThemeTokensDefinition.fields, - "@dialog": Schema.optional(ThemeTokensDefinition), + "@dialog": Schema.optional(DialogTokensDefinition), }) export const ThemeDefinition = ThemeDefinitionFields export type ThemeDefinition = Schema.Schema.Type @@ -272,7 +278,7 @@ export type ThemeDefinition = Schema.Schema.Type export const BaseThemeDefinition = Schema.Struct({ categorical: CategoricalDefinition, ...CompleteThemeTokensDefinition.fields, - "@dialog": Schema.optional(ThemeTokensDefinition), + "@dialog": Schema.optional(DialogTokensDefinition), }) export type BaseThemeDefinition = Schema.Schema.Type @@ -280,7 +286,7 @@ export const ModeDefinition = Schema.Struct({ hue: HueDefinition, categorical: Schema.optional(CategoricalDefinition), ...ThemeTokensDefinition.fields, - "@dialog": Schema.optional(ThemeTokensDefinition), + "@dialog": Schema.optional(DialogTokensDefinition), }) export type ModeDefinition = Schema.Schema.Type diff --git a/packages/tui/src/component/model-options.tsx b/packages/tui/src/component/model-options.tsx index 58177e140bd..561526b7502 100644 --- a/packages/tui/src/component/model-options.tsx +++ b/packages/tui/src/component/model-options.tsx @@ -68,7 +68,7 @@ export function ModelDetail(props: { ...(props.model.variants.length > 0 ? ["Reasoning"] : []), ].filter(Boolean) const list = (items: string[]) => ( - + {(fact, index) => ( <> @@ -85,7 +85,7 @@ export function ModelDetail(props: { fallback={ - + {price()} diff --git a/packages/tui/src/theme/assets/v2/opencode2.json b/packages/tui/src/theme/assets/v2/opencode2.json index 95cdf95e611..cb913551b6f 100644 --- a/packages/tui/src/theme/assets/v2/opencode2.json +++ b/packages/tui/src/theme/assets/v2/opencode2.json @@ -10,12 +10,11 @@ ], "text": { "base": "$hue.neutral.100", - "muted": "$hue.neutral.200", - "faint": "$hue.neutral.300", + "muted": "$hue.neutral.300", "action": { "primary": { "base": "$text.base", - "$disabled": "$text.faint", + "$disabled": "$text.muted", "$focused": "$text.base", "$selected": "$hue.interactive.400" }, @@ -26,7 +25,7 @@ }, "destructive": { "base": "$hue.neutral.900", - "$disabled": "$text.faint" + "$disabled": "$text.muted" } }, "formfield": { @@ -34,7 +33,7 @@ "$hovered": "$hue.interactive.400", "$focused": "$hue.interactive.400", "$pressed": "$hue.interactive.400", - "$disabled": "$text.faint", + "$disabled": "$text.muted", "$selected": "$hue.interactive.400" }, "feedback": { @@ -159,6 +158,11 @@ "$hovered": "$background.raised.max" } } + }, + "@footer": { + "text": { + "muted": "$hue.neutral.200" + } } } }, diff --git a/packages/tui/src/ui/dialog-prompt.tsx b/packages/tui/src/ui/dialog-prompt.tsx index b9a98490170..9b328b578e8 100644 --- a/packages/tui/src/ui/dialog-prompt.tsx +++ b/packages/tui/src/ui/dialog-prompt.tsx @@ -4,7 +4,7 @@ import { useTheme } from "../context/theme" import { DialogFooter, DialogHeader, DialogLayout, useDialog, type DialogSize } from "./dialog" import { Show, createEffect, createSignal, onMount, type JSX } from "solid-js" import { Spinner } from "../component/spinner" -import { useConfig, useNewDesigns } from "../config" +import { useConfig } from "../config" import { useRenderer } from "@opentui/solid" export type DialogPromptAction = { @@ -19,7 +19,7 @@ export type DialogPromptAction = { export type DialogPromptProps = { title: string size?: DialogSize - /** Faint line below the title, under the "new-designs" experiment. */ + /** Muted line below the title, under the "new-designs" experiment. */ subtitle?: string description?: () => JSX.Element placeholder?: string @@ -36,7 +36,6 @@ export function DialogPrompt(props: DialogPromptProps) { const renderer = useRenderer() const theme = useTheme().surface("dialog") const config = useConfig().data - const newDesigns = useNewDesigns() const [textareaTarget, setTextareaTarget] = createSignal() let textarea: TextareaRenderable @@ -169,7 +168,7 @@ export function DialogPrompt(props: DialogPromptProps) { }} initialValue={props.value} placeholder={props.placeholder ?? "Enter text"} - placeholderColor={newDesigns() ? theme.text.faint : theme.text.muted} + placeholderColor={theme.text.muted} textColor={props.busy ? theme.text.formfield.disabled : theme.text.formfield.base} focusedTextColor={props.busy ? theme.text.formfield.disabled : theme.text.formfield.base} cursorColor={props.busy ? theme.background.formfield.disabled : theme.text.base} diff --git a/packages/tui/src/ui/dialog-select.tsx b/packages/tui/src/ui/dialog-select.tsx index c298c8d40ce..6b159d0c8dd 100644 --- a/packages/tui/src/ui/dialog-select.tsx +++ b/packages/tui/src/ui/dialog-select.tsx @@ -26,7 +26,7 @@ import { moveSelection, reconcileSelection } from "./select-controller" export interface DialogSelectProps { title: string titleView?: JSX.Element - /** Faint line below the title, under the "new-designs" experiment. Not shown with `searchInTitle`. */ + /** Muted line below the title, under the "new-designs" experiment. Not shown with `searchInTitle`. */ description?: string /** Blank rows above the footer under the "new-designs" experiment. Defaults to 1. */ footerGap?: number @@ -677,7 +677,7 @@ export function DialogSelect(props: DialogSelectProps) { }, 1) }} placeholder={(searchInTitle() ? props.titlePlaceholder : undefined) ?? props.placeholder ?? "Search"} - placeholderColor={newDesigns() ? theme.text.faint : theme.text.muted} + placeholderColor={theme.text.muted} /> ) @@ -829,7 +829,7 @@ export function DialogSelect(props: DialogSelectProps) { - … + … {/* Reserved whenever any option has a detail, so the dialog does not resize as the selection moves. */} @@ -839,7 +839,7 @@ export function DialogSelect(props: DialogSelectProps) { when={detailView()} keyed fallback={ - + {detailText() || " "} } @@ -865,7 +865,7 @@ export function DialogSelectChoice(props: { value: string; active: boolean; open if (!props.active) return ` ${props.value} ` return props.open ? ` ${props.value} ↵` : `‹ ${props.value} ›` } - return {text()} + return {text()} } function DialogSelectCategory(props: { title: string; first: boolean }) { @@ -873,7 +873,7 @@ function DialogSelectCategory(props: { title: string; first: boolean }) { const newDesigns = useNewDesigns() return ( - + {props.title} @@ -906,7 +906,7 @@ function DialogSelectRow(props: { // Secondary text (description and footer). const secondary = () => { if (!newDesigns()) return props.active ? text() : theme.text.muted - return props.active ? theme.text.action.secondary.focused : theme.text.faint + return props.active ? theme.text.action.secondary.focused : theme.text.muted } const row = () => ( diff --git a/packages/tui/src/ui/dialog.tsx b/packages/tui/src/ui/dialog.tsx index 849c5feb33d..fe5da514872 100644 --- a/packages/tui/src/ui/dialog.tsx +++ b/packages/tui/src/ui/dialog.tsx @@ -96,7 +96,7 @@ export function DialogHeader( closeLabel?: string onClose?: () => void gap?: number - /** Faint line below the title. Shown only under the "new-designs" experiment. */ + /** Muted line below the title. Shown only under the "new-designs" experiment. */ description?: string }>, ) { @@ -112,7 +112,7 @@ export function DialogHeader( )} {props.children} (props.onClose ?? dialog.clear)()} > @@ -124,7 +124,7 @@ export function DialogHeader( {row()} - + {props.description} @@ -297,7 +297,7 @@ function DialogFooterItem(props: { action: DialogFooterAction; variant: "primary onMouseOut={() => setHovered(false)} onMouseUp={trigger} > - {label(theme.text.faint)} + {label(theme.text.muted)} ) diff --git a/packages/tui/test/theme/v2/resolve.test.ts b/packages/tui/test/theme/v2/resolve.test.ts index 63ef4114487..4a23cd99a39 100644 --- a/packages/tui/test/theme/v2/resolve.test.ts +++ b/packages/tui/test/theme/v2/resolve.test.ts @@ -337,6 +337,23 @@ test("surface overrides rewire references and reset action states from their bas expect(raised.text.action.primary.focused.toInts()).toEqual([85, 85, 85, 255]) }) +test("dialog footer overrides layer on the dialog surface", () => { + const theme = resolveTheme( + override(light, { + "@dialog": { + text: { base: "#333333" }, + "@footer": { text: { muted: "#666666" } }, + }, + }), + ) + const footer = theme.surface("dialog.footer") + expect(footer.text.muted.toInts()).toEqual([102, 102, 102, 255]) + expect(footer.text.base.toInts()).toEqual([51, 51, 51, 255]) + expect(theme.surface("dialog").text.muted.toInts()).not.toEqual([102, 102, 102, 255]) + const plain = resolveTheme(light) + expect(plain.surface("dialog.footer")).toBe(plain.surface("dialog")) +}) + test("rejects missing and circular references", () => { expect(() => resolveTheme(override(light, { text: { base: "$missing" } }))).toThrow( 'Theme reference "$missing" was not found',