Conversation
…tting - feat: add use_terminal_theme setting (settings.conf, Settings type) to opt into terminal colors. - feat: add theme resolution (resolve.rs) to choose theme.conf vs terminal theme by setting and file presence. - feat: add terminal_detect.rs to detect supported terminals (alacritty, kitty, konsole, ghostty, xterm, gnome-terminal, xfce-terminal, tilix, mate-terminal). - feat: add terminal_query.rs to query foreground/background via OSC 10/11 and derive 16-color theme. - change: reload settings before theme in config reload so theme resolution sees updated use_terminal_theme. - change: theme store and loader use unified resolution; fallback to terminal theme when theme.conf missing/invalid and terminal supported. - change: parse_settings and settings_ensure handle use_terminal_theme; skeletons updated for new flow. - chore: add TERMINAL_THEME_FALLBACK.md to IMPROVEMENTS documenting design and OSC requirements.
…ache long filename fix - feat: use TERM env before COLORTERM for terminal detection; skip COLORTERM when only "truecolor" or "24bit". - feat: resolve theme before terminal setup so OSC color query runs before mouse capture. - feat: disable mouse capture during OSC query, drain events before/after, retry once on failure. - feat: increase OSC query timeout to 250ms; only toggle raw mode when not already enabled. - fix: AUR cache path uses hash when key length exceeds 200 to avoid "File name too long" (os error 36). - test: add tests for AUR cache path (long list uses short filename, determinism). - docs: update TERMINAL_THEME_FALLBACK detection priority (TERM, then COLORTERM, then parent process).
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an opt-in “use terminal theme” feature that queries terminal foreground/background via OSC 10/11 and derives Pacsea’s theme from those colors, with a unified resolution/fallback chain; also fixes AUR JSON cache filename length issues.
Changes:
- Introduce terminal theme support (OSC 10/11 query, terminal detection, fg/bg → full palette derivation).
- Centralize theme selection logic in a new resolver and update theme store/reload flow to use it.
- Prevent AUR cache failures by hashing long cache keys into short deterministic filenames.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/theme/types.rs | Adds use_terminal_theme setting with default false. |
| src/theme/settings/parse_settings.rs | Parses use_terminal_theme (and alias terminal_theme). |
| src/theme/config/skeletons.rs | Updates settings skeleton to document/emit use_terminal_theme. |
| src/theme/config/settings_ensure.rs | Ensures use_terminal_theme is persisted/read in settings management. |
| src/theme/terminal_detect.rs | Adds supported-terminal detection for attempting OSC theme queries. |
| src/theme/terminal_query.rs | Implements OSC 10/11 query + parsing + theme derivation from fg/bg. |
| src/theme/resolve.rs | Adds unified theme resolution order (terminal/file/default fallback). |
| src/theme/store.rs | Switches theme store initialization/reload to use unified resolver. |
| src/theme/mod.rs | Wires new theme modules into the crate. |
| src/theme/config/theme_loader.rs | Adds #[allow(dead_code)] to unused load_theme_from_file. |
| src/theme/config.rs | Stops re-exporting load_theme_from_file (keeps diagnostics loader). |
| src/events/global.rs | Reloads settings before reloading theme so resolver sees updated flag. |
| src/app/runtime/mod.rs | Forces theme resolution before terminal setup to avoid input conflicts. |
| src/sources/feeds/updates.rs | Hashes long AUR cache keys to avoid NAME_MAX filename limits + tests. |
| dev/IMPROVEMENTS/TERMINAL_THEME_FALLBACK.md | Adds design/implementation documentation for terminal theme fallback. |
| config/settings.conf | Documents use_terminal_theme in example config. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- feat: query terminal colors on Unix via /dev/tty with nix poll (no stdin, no race with crossterm). - feat: add WezTerm and wezterm-gui to supported terminals; add unit test. - fix: on Windows, always join reader thread on timeout to avoid detached thread draining stdin. - fix: in headless/test (PACSEA_TEST_HEADLESS=1), skip mouse capture disable/enable for clean output. - refactor: remove dead load_theme_from_file from theme_loader; add rustdoc and error logging in ensure_theme_file_exists. - build: add nix (Unix) dependency with poll and fs features.
- fix: skip Alert modal for official/AUR package-details-unavailable errors; only log. - fix: show modal only for other network errors so UX stays clear. - docs: update PR to document package-details error handling in event_loop.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 24 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- fix: Windows OSC reader uses WaitForSingleObject + cancel flag so join() returns quickly when query never yields; avoids startup/theme-reload freeze. - fix: other non-Unix use bounded join so caller does not block indefinitely if reader is stuck on stdin. - refactor: ensure_theme_file_exists() always creates config_dir()/theme.conf; reading still uses resolve_theme_config_path() elsewhere. - build: add windows-sys (Windows) for timeout-aware stdin wait in OSC reader. - docs: update PR with Windows/non-Unix reader behavior and theme path details.
- fix: drain terminal event queue multiple times with short delays after OSC query. - fix: avoid OSC response bytes (e.g. rgb:...) entering search field on Ctrl+R theme reload. - refactor: extract drain logic into drain_stray_events() with configurable iterations/delay.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
theme.confand used it. There was no way to use the terminal’s foreground/background colors so the UI could blend with the terminal palette.use_terminal_themesetting insettings.conf(default:false). Whentrue, theme resolution tries to query the terminal via OSC 10/11 (foreground/background), parses the reply, builds Pacsea’s 16-color theme from fg/bg and derivation rules, and uses it. If the terminal does not support query or the query fails (e.g. non-TTY, timeout), resolution falls back totheme.confor the default skeleton.use_terminal_theme=trueand terminal is supported; otherwise use file theme or skeleton.terminal_query.rs), terminal support detection (terminal_detect.rs), and resolution logic (resolve.rs)./dev/ttywith nixpollso stdin is not used and crossterm is not raced.PACSEA_TEST_HEADLESS=1): skip mouse capture disable/enable for clean output.load_theme_from_filefrom theme_loader; add rustdoc and error logging inensure_theme_file_exists.ensure_theme_file_exists()always targetsconfig_dir()/theme.conffor creation (never legacy pacsea.conf); reading continues to useresolve_theme_config_path()elsewhere.dev/IMPROVEMENTS/TERMINAL_THEME_FALLBACK.mddescribing design, OSC sequences, and implementation choices.Type of change
Related issues
Closes #122
How to test
cargo fmt --all cargo clippy --all-targets --all-features -- -D warnings cargo check cargo test -- --test-threads=1use_terminal_theme = trueinsettings.conf, run Pacsea; UI should match terminal fg/bg–derived colors. Change terminal theme and reload theme in Pacsea to see updates. On Unix, query uses/dev/tty(no stdin).use_terminal_theme = truein a pipe or unsupported terminal; should fall back to theme.conf or default skeleton without hanging.Checklist
Code Quality:
cargo check)cargo fmt --allran without changescargo clippy --all-targets --all-features -- -D warningsis cleancargo test -- --test-threads=1passescargo test complexity -- --nocapture)unwrap()orexpect()in non-test codeTesting:
Documentation:
config/directory if config keys changed (settings.conf:use_terminal_theme)Images/if applicableCompatibility:
--dry-runflagpacman/paru/yayare unavailablefalseOther:
pacsea-binorpacsea-gitrepos)Notes for reviewers
src/theme/resolve.rs): Order is (1) ifuse_terminal_themeand terminal supported → query OSC, use terminal theme; (2) else use theme from file or skeleton. Fallback on query failure avoids hanging in pipes/CI/unsupported terminals.src/theme/terminal_query.rs): Uses blocking read with timeout; parsesrgb:rrrr/gggg/bbbband optionalrgba; handles both\033\\and BEL as ST. Non-TTY or no reply → returns error so resolution can fall back.src/theme/terminal_detect.rs): Heuristic (e.g.COLORTERM,TERM) to decide if we try OSC query; WezTerm/wezterm-gui added; not all terminals that set these support query (some only support set), so we still rely on query success/failure.src/theme/terminal_query.rs): Colors are read from/dev/ttyvia nixpollso stdin is untouched and there is no race with crossterm.PACSEA_TEST_HEADLESS=1, mouse capture disable/enable is skipped for clean test output.src/sources/feeds/updates.rs): Long filename fix is a small, separate change in the same branch; included in this PR.src/app/runtime/event_loop.rs): When official or AUR package details fail to fetch (e.g. SSL/network or circuit breaker), the error is logged but no modal is shown, so scrolling through packages does not spam "Connection issue" dialogs.Breaking changes
None. New setting
use_terminal_themedefaults tofalse; existing configs unchanged.Additional context
dev/IMPROVEMENTS/TERMINAL_THEME_FALLBACK.mduse_terminal_theme = true; others fall back to file/skeleton.