Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,9 @@ The `[window]` and `[font]` sections are documented in [Window and font](#window

The six semantic roles map as: **background** → `colors.background`, **foreground** → `colors.foreground`, **accent** → `colors.prompt` and `colors.banner`, **muted** → `colors.empty`, **selection_background** → `colors.selected_bg`, **selection_foreground** → `colors.selected`, **font.family** → `font.family`. Explicit `[colors]` / `[font]` fields always win, even when they equal an old default.

A missing or invalid `theme_file` is reported on stderr and ignored. Hyprburst still launches, keeping valid app overrides and built-in values for everything else. The Rio parent and `hyprburst tui` child each load this file independently, so they pick the same theme. `hyprburst tui` (including that Rio child PTY) uses the resolved colors but **not** the theme family — glyphs there come from the hosting terminal.
A missing or invalid `theme_file` is reported on stderr and ignored. Hyprburst still launches, keeping valid app overrides and built-in values for everything else. The Rio parent and its TUI child each load this file independently, so they pick the same theme. External `hyprburst tui` applies the resolved foreground to ordinary text and background to the entire launcher area, while preserving selection/accent colors. It does **not** apply the theme family—the hosting terminal owns its fonts. Rio's internal child leaves base colors at ANSI defaults so its GPU parent owns the base palette and transparent background panel, just like the native frontend.

Without a shared theme (or if it fails to load), the external TUI uses the built-in palette plus explicit overrides. This intentionally replaces its previous reliance on terminal defaults for ordinary text and blank areas. To retain terminal-owned base colors, set `[colors] foreground = "reset"` and `background = "reset"`. Each `reset` independently means the hosting terminal's corresponding default, including when explicitly used for selection colors; it does not inherit the theme's base color. External terminals own opacity/transparency; `[window]` settings apply only to GPU windows.

The remaining section controls colors:

Expand All @@ -321,8 +323,8 @@ The remaining section controls colors:
| `colors.selected` | color | `#f2d5ff` | Text of the highlighted entry. |
| `colors.selected_bg` | color | `#3a2e5a` | Highlight bar drawn behind the selected row. |
| `colors.empty` | color | `#9a8cb5` | "No matches" message color. |
| `colors.background` | color | `#1a1b26` | Window background — painted opaque when `window.transparent = false`, and as the dimming panel (at `window.opacity`) when `transparent = true`. |
| `colors.foreground` | color | `#c8cce0` | Default text color for unstyled launcher text (the Reset color). |
| `colors.background` | color | `#1a1b26` | GPU window background/dimming panel; base background throughout the external TUI. |
| `colors.foreground` | color | `#c8cce0` | Base color for ordinary launcher text in every frontend. |

### Color values

Expand Down
12 changes: 9 additions & 3 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,22 @@
# black, red, green, yellow, blue, magenta, cyan, white,
# gray / grey, darkgray / darkgrey,
# light-red, light-green, light-yellow, light-blue, light-magenta, light-cyan,
# reset (falls back to your terminal's default foreground)
# reset (uses the hosting terminal's corresponding default in external TUI)
# Defaults are a modern dark, violet-tinted palette (shown below as hex).
[colors]
# banner = "#c6a0f6" # ASCII banner
# prompt = "#8aadf4" # search prompt + cursor
# selected = "#f2d5ff" # text of the highlighted entry
# selected_bg = "#3a2e5a" # highlight bar behind the selected row
# empty = "#9a8cb5" # "no matches" message
# background = "#1a1b26" # window background / dimming panel (see window.opacity)
# foreground = "#c8cce0" # default text color for unstyled (Reset) text
# background = "#1a1b26" # GPU background panel and external TUI base background
# foreground = "#c8cce0" # ordinary text color in all frontends
#
# External `hyprburst tui` uses these base colors even without a shared theme.
# Set foreground/background to "reset" to keep terminal-owned base colors, as
# in older versions. Explicit selection colors (including "reset") still win.
# Rio's internal TUI child leaves base colors to its GPU parent, preserving
# window transparency/opacity. [window] does not control external terminals.

# Launcher window. All keys are optional.
[window]
Expand Down
77 changes: 77 additions & 0 deletions docs/tui-base-colors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# External TUI base colors

The external TUI adapter fills its widget area with the resolved foreground and
background before invoking the shared renderer. Ordinary text and blank cells
inherit those colors; selection, prompt, banner, and empty-state styles still
win. An explicit `Color::Reset` remains the terminal's corresponding default,
not an instruction to inherit the theme's base color. Foreground fade-in skips
Reset cells because their actual RGB value belongs to the terminal/GPU host.

Without a valid shared theme, config still resolves the built-in palette plus
explicit overrides. Applying that palette to the external TUI's base cells is
intentional; previously these cells used terminal defaults. To restore that
behavior, set both `[colors] foreground = "reset"` and `background = "reset"`.
Terminal-owned font and opacity settings remain independent.

## GPU isolation

The native frontend still calls `render_core` directly and receives Reset base
cells. Rio spawns its TUI child with the internal `tui --gpu-host` argument.
That mode changes only the child's base foreground/background to Reset; its
selection/accent colors remain explicit. The parent resolves ANSI defaults to
its own configured colors and controls the translucent/opaque background panel.
This avoids painting opaque base backgrounds into every Rio cell. The internal
argument is not inherited by applications launched from the child.

## Regression coverage

`cargo test --all` covers:

- Theme loading through an original fixture, explicit base overrides, independent
foreground/background resets, ordinary app text, blank cells, and prompt colors
using ratatui's `TestBackend`.
- Selected-row foreground/background (including Reset), bold styling, and padding.
- Built-in no-theme palette, widget-area bounds, and empty-result background.
- Unchanged native shared-buffer Reset cells, Rio child arguments, and host config
adaptation preserving every field other than the two base colors.
- Reset foreground preservation throughout fade-in, alongside existing explicit
foreground animation tests.

## Live smoke record — 2026-09-13

Environment: Hyprland 0.56.2, Wayland, eDP-1 at 1.5× display scaling.
All runs used isolated XDG config/data directories and two harmless desktop
entries, Alpha and Beta (`Exec=true`); neither was launched. The Swatches theme
used foreground `#EAF3FF`, background `#10253F`, and selection colors
`#FFFFFF` / `#244A70` (see `tests/fixtures/themes/base.toml`).

Actual `hyprburst tui` output was captured in a 40×10 PTY, allowed to settle past
fade-in, and parsed with pyte. Assertions checked Beta's unselected text, top-left
and bottom-right blank cells, and Alpha's selection colors. All cases passed:

| Case | Base foreground / background |
| --- | --- |
| Shared theme | `#EAF3FF` / `#10253F` |
| Theme with explicit overrides | `#123456` / `#654321` |
| No theme | `#C8CCE0` / `#1A1B26` |
| Explicit base resets | ANSI default / default |
| Rio internal GPU-host mode | ANSI default / default |

Each PTY run exited successfully on Escape. This caught the fade effect turning
Reset foregrounds into explicit white before the regression fix.

Visual checks also passed in three real windows:

- Kitty, started without user config and with deliberately different defaults
(`foreground=#003311`, `background=#FFCCAA`): launcher text, selection, and blank
cells used the shared theme instead. Kitty's outer padding remained terminal-owned.
- Native and Rio with `window.transparent=true`, `window.opacity=0.4`: matching
themed text/selection and visible blurred wallpaper through the base background.
No new opaque base-cell rectangles appeared in Rio.

All three window runs had empty stdout/stderr logs. Each was captured with grim
1.5 seconds after mapping, then its test process was terminated. No compositor
settings or user config were changed. Temporary scripts, PTY captures, logs, and
screenshots are in `/tmp/hyprburst-tui-smoke.2yuDxf/` (`smoke.py`, `gui.py`,
`*.ansi`, `external.png`, `native.png`, `rio.png`); these are local artifacts, not
packaged assets. The PTY script runs via `uv run --with pyte python smoke.py`.
6 changes: 4 additions & 2 deletions src/gpu/rio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ struct ChildSpec {
fn child_spec(executable: &Path) -> ChildSpec {
ChildSpec {
program: executable.to_path_buf(),
args: vec!["tui".to_string()],
// Leave base cells at ANSI defaults so the GPU parent retains control
// of text color and the transparent/opaque background panel.
args: vec!["tui".to_string(), "--gpu-host".to_string()],
}
}

Expand Down Expand Up @@ -496,7 +498,7 @@ mod tests {
let spec = child_spec(Path::new("/tmp/hypr burst"));

assert_eq!(spec.program, Path::new("/tmp/hypr burst"));
assert_eq!(spec.args, ["tui"]);
assert_eq!(spec.args, ["tui", "--gpu-host"]);
}

#[test]
Expand Down
50 changes: 44 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ enum Command {
BenchStartup,
Rio { measure: bool },
Native { measure: bool },
Tui,
Tui { gpu_host: bool },
Help,
Unknown(String),
}
Expand All @@ -50,7 +50,9 @@ fn parse_command(args: &[String]) -> Command {
Some("native") => Command::Native {
measure: args.iter().any(|arg| arg == "--measure"),
},
Some("tui") => Command::Tui,
Some("tui") => Command::Tui {
gpu_host: args.iter().any(|arg| arg == "--gpu-host"),
},
Some("help" | "--help" | "-h") => Command::Help,
Some(other) => Command::Unknown(other.to_string()),
}
Expand Down Expand Up @@ -85,11 +87,23 @@ fn bench_startup() -> io::Result<()> {
Ok(())
}

/// Adapt only the base palette for Rio's internal child; external terminals
/// receive the resolved config unchanged.
fn tui_config(mut config: Config, gpu_host: bool) -> Config {
if gpu_host {
// Internal Rio child mode: ANSI default colors are resolved by the
// parent, preserving its base panel opacity. Keep selection/accent
// colors explicit, just as in the direct native renderer.
config.colors.foreground = ratatui::style::Color::Reset;
config.colors.background = ratatui::style::Color::Reset;
}
config
}

/// Run the crossterm TUI inline in the current terminal — the fallback for
/// SSH / no-GPU sessions where the windowed launcher can't open.
fn run_tui() -> io::Result<()> {
let config = load_config();

fn run_tui(gpu_host: bool) -> io::Result<()> {
let config = tui_config(load_config(), gpu_host);
let mut terminal = terminal::init()?;
let original_hook = std::panic::take_hook();
std::panic::set_hook(Box::new(move |info| {
Expand Down Expand Up @@ -166,7 +180,7 @@ fn main() -> ExitCode {
Command::BenchStartup => io_to_exit(bench_startup()),
Command::Rio { measure } => run_rio(measure, start),
Command::Native { measure } => run_window(measure, start),
Command::Tui => io_to_exit(run_tui()),
Command::Tui { gpu_host } => io_to_exit(run_tui(gpu_host)),
Command::Help => {
print!("{}", HELP);
ExitCode::SUCCESS
Expand Down Expand Up @@ -208,6 +222,30 @@ mod tests {
);
}

#[test]
fn gpu_host_tui_is_distinct_from_external_terminal() {
assert_eq!(
parse_command(&args(&["tui", "--gpu-host"])),
Command::Tui { gpu_host: true }
);
assert_eq!(
parse_command(&args(&["tui"])),
Command::Tui { gpu_host: false }
);
}

#[test]
fn only_gpu_host_defers_base_colors_and_keeps_selection_explicit() {
let config = Config::from_toml_str(
"[colors]\nforeground = \"#123456\"\nbackground = \"#654321\"\nselected = \"red\"\nselected_bg = \"blue\"",
).unwrap();
assert_eq!(tui_config(config.clone(), false), config);
let mut expected = config.clone();
expected.colors.foreground = ratatui::style::Color::Reset;
expected.colors.background = ratatui::style::Color::Reset;
assert_eq!(tui_config(config, true), expected);
}

#[test]
fn measurement_targets_the_selected_frontend() {
assert_eq!(
Expand Down
24 changes: 22 additions & 2 deletions src/tui/effects.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::time::Instant;

use ratatui::prelude::*;
use tachyonfx::{EffectRenderer, Interpolation, fx};
use tachyonfx::{CellFilter, EffectRenderer, Interpolation, fx};

const FADE_IN_MS: u32 = 220;

Expand All @@ -13,7 +13,10 @@ pub struct FadeIn {
impl FadeIn {
pub fn new() -> Self {
Self {
effect: fx::fade_from_fg(Color::Black, (FADE_IN_MS, Interpolation::QuadOut)),
// The terminal/GPU host owns Reset's RGB value. Interpolating it
// would invent an explicit color (white), even on the final frame.
effect: fx::fade_from_fg(Color::Black, (FADE_IN_MS, Interpolation::QuadOut))
.with_filter(CellFilter::Not(Box::new(CellFilter::FgColor(Color::Reset)))),
last_tick: Instant::now(),
}
}
Expand Down Expand Up @@ -84,6 +87,23 @@ mod tests {
assert_eq!(buf[(0, 0)].fg, Color::Black);
}

#[test]
fn fade_preserves_terminal_default_foreground_and_explicit_background() {
for elapsed in [
Duration::ZERO,
Duration::from_millis(100),
Duration::from_millis(1_000),
] {
let mut fade = FadeIn::new();
let area = Rect::new(0, 0, 5, 1);
let mut buf = Buffer::empty(area);
buf.set_string(0, 0, "hello", Style::new().fg(Color::Reset).bg(Color::Blue));
fade.apply_to_buffer(&mut buf, area, elapsed);
assert_eq!(buf[(0, 0)].fg, Color::Reset, "at {elapsed:?}");
assert_eq!(buf[(0, 0)].bg, Color::Blue);
}
}

#[test]
fn fade_reaches_target_foreground_when_complete() {
let mut fade = FadeIn::new();
Expand Down
Loading
Loading