Conversation
Detect the desktop environment's configured UI font on Linux via gsettings (GNOME/Cinnamon/Budgie/XFCE) and kdeglobals (KDE), and apply it as a CSS variable. Also expand the static fallback font stack to include common Linux UI fonts (Ubuntu, Cantarell, Noto Sans, DejaVu Sans) so the UI renders well even when detection fails. Closes #160 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds Linux UI font detection: a new Tauri command and fonts module, Linux-specific detection/parsing logic, and frontend changes that set a CSS variable with the detected font on Linux at runtime. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/components/layout/Layout.tsx (1)
190-198: Consider handling potential promise rejection.The
commands.getLinuxUiFont()call uses.then()without a.catch()handler. If the command fails at the IPC level (not just returning an error result), the promise rejection would be unhandled.🛡️ Suggested fix to handle rejection
- void commands.getLinuxUiFont().then(result => { + void commands.getLinuxUiFont().then(result => { if (cancelled) return if (result.status === 'ok' && result.data) { window.document.documentElement.style.setProperty( '--font-ui', `'${result.data}', -apple-system, 'Segoe UI', 'Ubuntu', 'Cantarell', 'Noto Sans', 'DejaVu Sans', sans-serif` ) } - }) + }).catch(() => { + // Font detection failed at IPC level; fallback fonts will be used + })🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/layout/Layout.tsx` around lines 190 - 198, The call to commands.getLinuxUiFont() can reject and currently has no rejection handler; update the caller (the anonymous promise handler where cancelled is checked and window.document.documentElement.style.setProperty is set) to handle promise rejections — either convert to async/await inside an async function with try/catch or append a .catch(err => { if (!cancelled) { /* log or silently handle */ } }) to the existing chain — and ensure you still check cancelled before touching the DOM and surface/log the error appropriately.src-tauri/src/commands/fonts.rs (1)
34-37: Blocking process execution in async context.
Command::new(...).output()is a synchronous/blocking call within anasync fn. While Tauri handles this by running commands on a separate thread pool, consider usingtokio::process::Commandfor true async execution if this becomes a performance concern on startup.This is acceptable for a startup-only operation but worth noting for future reference.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src-tauri/src/commands/fonts.rs` around lines 34 - 37, The current sync call using std::process::Command::output() inside the async context should be replaced with tokio::process::Command to avoid blocking the async runtime: import tokio::process::Command, replace Command::new(...).args(...).output().ok()? with an awaited async call like Command::new(...).args(...).output().await and propagate or handle the Result (instead of .ok()?) inside the existing async function (e.g., the function in commands/fonts.rs that calls this), ensuring necessary use statements and error handling are updated accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src-tauri/src/commands/fonts.rs`:
- Around line 34-37: The current sync call using std::process::Command::output()
inside the async context should be replaced with tokio::process::Command to
avoid blocking the async runtime: import tokio::process::Command, replace
Command::new(...).args(...).output().ok()? with an awaited async call like
Command::new(...).args(...).output().await and propagate or handle the Result
(instead of .ok()?) inside the existing async function (e.g., the function in
commands/fonts.rs that calls this), ensuring necessary use statements and error
handling are updated accordingly.
In `@src/components/layout/Layout.tsx`:
- Around line 190-198: The call to commands.getLinuxUiFont() can reject and
currently has no rejection handler; update the caller (the anonymous promise
handler where cancelled is checked and
window.document.documentElement.style.setProperty is set) to handle promise
rejections — either convert to async/await inside an async function with
try/catch or append a .catch(err => { if (!cancelled) { /* log or silently
handle */ } }) to the existing chain — and ensure you still check cancelled
before touching the DOM and surface/log the error appropriately.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: d60a836b-6157-4059-809d-fbdae2df69a3
⛔ Files ignored due to path filters (1)
src/lib/bindings.tsis excluded by!src/lib/bindings.ts
📒 Files selected for processing (5)
src-tauri/src/bindings.rssrc-tauri/src/commands/fonts.rssrc-tauri/src/commands/mod.rssrc/App.csssrc/components/layout/Layout.tsx
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
* origin/main: Formatting issues Improve UI font handling on Linux (#167) Fix Content Linker Update docs and complete tasks Upgrade vite Update jsdom Update knip Upgrade lucide-react from 0.564 to 1.7 Upgrade @ast-grep/cli from 0.41 to 0.42 Update deps Upgrade deps Update task doc to reflect completed phases Upgrade notify crate from v8 to v9.0.0-rc.2 Add file watcher error recovery and periodic rescan Fix macOS window close to hide instead of quit chore(deps): bump rustls-webpki from 0.103.9 to 0.103.10 in /src-tauri chore(deps): bump wrangler chore(deps): bump tar from 0.4.44 to 0.4.45 in /src-tauri
Summary
gsettings(GNOME/Cinnamon/Budgie/XFCE) and~/.config/kdeglobals(KDE Plasma), applied as a CSS variable-apple-system/Segoe UIbehaviour is preservedHow it works
App.css):font-familynow usesvar(--font-ui, ...)with an improved fallback that covers the major Linux distrosfonts.rs):get_linux_ui_font()tries gsettings first, then KDE config. ReturnsNoneon non-Linux (compiled out via#[cfg])Layout.tsx): Calls the command once on startup if running on Linux, sets--font-uiCSS variable with the detected font prepended to the full fallback stackWhy not
system-ui?Tauri uses WebKitGTK on Linux, where CSS
system-uiis unreliable. Explicit detection is more dependable.Closes #160
Summary by CodeRabbit