Skip to content

feat(theme): resolve state precedence - #49813

Merged
jlongster merged 1 commit into
v2from
action-precedence
Sep 18, 2026
Merged

jlongster merged 1 commit into
v2from
action-precedence

Conversation

@jlongster

Copy link
Copy Markdown
Contributor

What

Add state(flags) to every resolved action and form-field color:

theme.background.action.primary.default

theme.background.action.primary.state({
  disabled: disabled(),
  pressed: pressed(),
  focused: focused(),
  selected: selected(),
  hovered: hovered(),
})

The first active state in ActionState.literals wins:

disabled > pressed > focused > selected > hovered > default

Missing and false flags are ignored. If every property is false or absent, state() returns the existing default color.

The API is available consistently on:

  • theme.text.action.<variant>
  • theme.background.action.<variant>
  • theme.text.formfield
  • theme.background.formfield
  • plugin context.theme, because it receives the same ResolvedTheme shape

Existing direct property access remains unchanged (primary.focused, formfield.selected, etc.). This PR only adds the resolver; production call sites will migrate separately.

Verification

  • bun run typecheck in packages/theme
  • bun run typecheck in packages/tui
  • bun test in packages/theme (6 pass)
  • focused TUI theme tests (21 pass)
  • tests cover every precedence level, all-false fallback, and form-field availability

@jlongster
jlongster merged commit d816047 into v2 Sep 18, 2026
8 of 10 checks passed
@jlongster
jlongster deleted the action-precedence branch September 18, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant