Skip to content

feat(tui): derived syntax palette with optional theme syntax block (U4) - #103

Merged
lg2m merged 1 commit into
feat/eng-852-u9-sessions-railfrom
feat/eng-850-u4-syntax-palette
Sep 21, 2026
Merged

lg2m merged 1 commit into
feat/eng-852-u9-sessions-railfrom
feat/eng-850-u4-syntax-palette

Conversation

@lg2m

@lg2m lg2m commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

U4: derived syntax palette with optional theme syntax block

Spec: docs/plans/tui-redesign.md#s5-syntax-palette (decision D10) Linear: ENG-850 (parent ENG-843)

Stacked on #101 (U9). Review the top commit only until #101 merges.

What changed

  • qq-tui Palette gains eight syn_* roles derived from the declared roles: keyword → brand, function → accent, type → warning, string → success, constant → brand softened toward text (a const 2:1 channel blend; no role maps to error any more), comment → muted italic, property → text, punctuation → muted. render::code_* read them; code_punctuation() added.
  • HIGHLIGHT_CAPTURES adds operator, punctuation.bracket, punctuation.delimiter, variable.parameter.
  • qq-config theme documents accept an optional syntax: ( keyword: .., function: .., type: .., string: .., constant: .., comment: .., property: .., punctuation: .. ) block: every field optional, deny_unknown_fields, colors validated with the same alias/literal/cycle rules as the eight roles. Malformed input → ConfigError::InvalidThemeSyntax { origin, role: SyntaxRole, reason: ThemeColorFault }.
  • 11 shipped themes declare a syntax block from their upstream token colors (catppuccin, dracula, everforest, gruvbox, kanagawa, monokai, nord, onedark, rose-pine, solarized, tokyonight; sources listed in the ledger receipt). Fields a palette does not define are omitted so the derived default applies. ember, ink: no block.
  • Composition root (src/main.rs) applies syntax overrides after derivation.
  • Bug found via the ANSI gallery: view/highlight.rs spawn_blocking workers had no active palette, so highlighted panels came back in qq colors under every theme. request now captures theme::active() and activates it on the worker; regression test.
  • #[inline(never)] on highlighted_code_lines: the capture-table growth let it inline into layout_code_panel and cost +7 % on streaming_run_on_32kb; bisected with a size-only padded parent (427 µs) vs captures-only (459 µs).

How verified

  • cargo test --workspace green: qq-tui 280 → 285, qq-config 88 → 89, root 169 → 170; goldens unchanged (plain text). fmt, clippy -D warnings.
  • New tests: derived defaults never equal error; punctuation muted / operator+param text on a highlighted snippet; every bundled grammar highlights a bracketed snippet with the extended captures; syntax block absent / full / subset / empty / bad literal / unknown alias / cycle / unknown field / non-block value; every shipped theme loads and its block validates; root test that overrides land and everything else equals derivation; highlight worker uses the active theme.

Measurements (target/qq-perf/tui-U4-2026-09-20/, pinned core)

Gate Before After Budget
steady_state_frame 21.0 µs 21.5 ±5 %
golden_path 38.3 39.4 ±5 %
tool_calls_32_expanded 51.7 53.4 ±5 %
streaming_focused 33.8 33.6 ±5 %
streaming_run_on_32kb 430 417–440 ±5 %

resize_ultra_480x120 +8 % (110 → 118); ~3 µs reproduces on a parent padded by 32 bytes alone (Palette growth), the remainder appears to be code layout. Not a named gate; recorded.

Docs

  • docs/design/theme.md: syntax block, derived defaults, validation; the v1 out-of-scope bullet removed. Ledger receipt.

Compatibility

  • Theme documents: additive optional block. PROTOCOL / DESCRIPTOR / schema: unchanged.

Slice U4 of docs/plans/tui-redesign.md (ENG-850), stacked on U9.

Palette gains eight syn_* roles derived from the declared roles (constant
is brand blended toward text; nothing maps to error) and an optional
theme `syntax` block overrides any subset, validated per field with a
typed ConfigError variant. Eleven shipped themes carry upstream token
colors; ember and ink derive. Captures add punctuation (muted), operator
and parameter (text). Highlight jobs now run under the requesting
thread's palette, fixing themed panels that came back in qq colors.
@lg2m
lg2m added this pull request to stack #105 September 21, 2026 19:40
@lg2m
lg2m merged commit ac31a30 into main Sep 21, 2026
4 checks passed
@lg2m
lg2m deleted the feat/eng-850-u4-syntax-palette branch September 21, 2026 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant