Skip to content

feat(tui): Phase 3 — /theme command, OS light/dark auto-follow, sunken output panels#99

Merged
davidrhodus merged 4 commits into
mainfrom
tui-phase3
Jul 16, 2026
Merged

feat(tui): Phase 3 — /theme command, OS light/dark auto-follow, sunken output panels#99
davidrhodus merged 4 commits into
mainfrom
tui-phase3

Conversation

@davidrhodus

Copy link
Copy Markdown
Contributor

Continues the grok-inspired TUI work (Phase 1+2 already on main). Two focused, tested increments; no render-model rewrite, no new dependencies.

Phase 3a — /theme command + OS light/dark auto-follow

Turns the Phase-1 theme foundation into a user-facing feature.

  • ThemeMode { Dark, Light, Ansi, Auto } decoupled from the resolved palette so Auto re-resolves when the OS appearance changes.
  • /theme [dark|light|ansi|auto] — empty arg cycles; applies live (the whole UI re-reads the theme each frame) and echoes the mode. Registered in COMMANDS (help + completions). /theme in --plain prints a "TUI only" note.
  • OS auto-follow: macOS reads AppleInterfaceStyle; the idle event loop polls ~every 5s when mode = auto (a no-op with no subprocess for fixed modes). Linux XDG-portal / Windows-registry detection is a noted follow-up.

Phase 3b — sunken output panels

Tool-output body lines now sit in a subtle sunken panel on truecolor themes, so a block of command output reads as one unit beneath its header (grok's expanded-panel look).

  • flatten() tags each visible ToolOutput body line with a panel base background (truecolor only; ansi leaves it at terminal default); the fold footer stays plain as the panel's edge.
  • The render pass pads panel-tagged lines to full inner width — a Line background only paints behind text, so a trailing bg space turns the per-glyph tint into a full-width block (verified with a screen-dump probe).

Deferred (need a block-cursor / live-block / markdown engine)

Per-block selection folding, the running accent-wave animation, sticky prompt headers, mouse selection, a real markdown/syntect engine. These need render-model surgery and are honest P4+ work.

Verification

152 hi-tui + 151 hi-agent tests pass; cargo clippy -D warnings + cargo fmt clean; ratchet updated. Theme-global mutations are deliberately not unit-tested (they'd race parallel color-asserting render tests); the mode logic is covered by pure tests and the live behavior by screen-dump probes.

🤖 Generated with Claude Code

David and others added 4 commits July 15, 2026 23:03
Turns the Phase-1 theme foundation into a real user-facing feature.

- theme.rs: a ThemeMode { Dark, Light, Ansi, Auto } decoupled from the
  resolved palette so Auto can re-resolve when the OS appearance changes.
  set_mode/cycle_mode/mode() manage a single global (mode + palette under
  one lock); poll_auto_appearance() re-queries and swaps the palette when
  mode = Auto. macOS reads AppleInterfaceStyle; other platforms return
  None (Linux XDG portal / Windows registry are a follow-up).
- command.rs: new /theme [dark|light|ansi|auto] command (empty cycles),
  registered in COMMANDS so it appears in help + completions.
- hi-tui: handle_theme applies the mode live (the whole UI re-reads the
  theme each frame) and echoes it; the idle event loop polls OS
  appearance ~every 5s when mode = auto (a no-op — no subprocess — for
  fixed modes). hi-cli prints the "TUI only" note.

HI_THEME still seeds the initial mode (now default auto). Runtime /theme
applies for the session.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Tool-output body lines now sit in a subtle sunken panel on truecolor
themes, so a block of shell/command output reads as one grouped unit
beneath its ◆ header (grok's expanded-panel look).

- flatten() tags each visible ToolOutput body line with a `panel` base
  background (truecolor only; ansi leaves it at the terminal default). The
  fold footer stays plain so the fold boundary reads as the panel's edge.
- render pads panel-tagged lines to the full inner width: a Line
  background only paints behind its text, so a trailing space span in the
  panel color turns the per-glyph tint into a full-width block.

Non-racy test asserts the body carries theme().panel iff the active
palette paints backgrounds; the full-width fill is verified with a
screen-dump probe.

Deferred still (need block-cursor/live-block/markdown engine): per-block
selection folding, the running accent-wave, sticky headers, mouse
selection, a real markdown engine.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A pre-existing unformatted `pub use tools::{…}` block reached this branch
via the main merge; CI's cargo fmt --all --check flagged it. Whitespace
only.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
os_appearance only constructs OsAppearance::{Dark,Light} on macOS; on
Linux CI the detector always returns None, so the variants are matched
but never built and -D dead-code rejected them. Platform-conditional
dead code — annotate the enum.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@davidrhodus
davidrhodus merged commit eb81f7e into main Jul 16, 2026
1 check passed
@davidrhodus
davidrhodus deleted the tui-phase3 branch July 16, 2026 06:26
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