diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8d3fc8d..f2abff5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - os: [windows-latest, macos-latest] + os: [windows-latest, macos-latest, ubuntu-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -19,6 +19,9 @@ jobs: - name: Metal toolchain (macOS; GPUI compiles shaders) if: runner.os == 'macOS' run: xcrun -f metal >/dev/null 2>&1 || xcodebuild -downloadComponent MetalToolchain + - name: System libraries (Linux; GPUI's X11, Wayland and font backends) + if: runner.os == 'Linux' + run: sudo apt-get update && sudo apt-get install -y libfontconfig-dev libwayland-dev libx11-xcb-dev libxcb1-dev libxkbcommon-x11-dev libvulkan1 zlib1g-dev - name: Build run: cargo build --locked - name: Install just diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index acd2652..802a18a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -80,9 +80,41 @@ jobs: name: releases-osx path: dist/releases + linux: + # An AppImage; Velopack updates it in place. + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.x + - name: Install Velopack CLI + run: dotnet tool install -g vpk + - name: System libraries (GPUI's X11, Wayland and font backends) + run: sudo apt-get update && sudo apt-get install -y libfontconfig-dev libwayland-dev libx11-xcb-dev libxcb1-dev libxkbcommon-x11-dev libvulkan1 zlib1g-dev + - name: Version from tag + id: ver + run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" + - name: Build + run: | + cargo build --release --locked + mkdir -p dist/publish + cp target/release/claudiu dist/publish/ + - name: Fetch previous release (for delta updates) + continue-on-error: true + run: vpk download github --channel linux --repoUrl "${{ github.server_url }}/${{ github.repository }}" --token "${{ secrets.GITHUB_TOKEN }}" + - name: Pack + run: vpk pack --packId Claudiu --packVersion "${{ steps.ver.outputs.version }}" --packDir dist/publish --mainExe claudiu --packTitle Claudiu --icon assets/claudiu.png --channel linux --outputDir dist/releases + - uses: actions/upload-artifact@v4 + with: + name: releases-linux + path: dist/releases + publish: # The builds run in parallel; uploading from one job afterwards avoids both racing to create the release. - needs: [windows, macos] + needs: [windows, macos, linux] runs-on: ubuntu-latest steps: - uses: actions/download-artifact@v4 @@ -94,6 +126,6 @@ jobs: - name: Upload run: | version="${GITHUB_REF_NAME#v}" - for channel in win osx; do + for channel in win osx linux; do vpk upload github --channel "$channel" --repoUrl "${{ github.server_url }}/${{ github.repository }}" --outputDir "releases-$channel" --merge --publish --releaseName "Claudiu $version" --tag "${{ github.ref_name }}" --token "${{ secrets.GITHUB_TOKEN }}" done diff --git a/README.md b/README.md index bbceb63..7a20dc9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Claudiu -Claudiu is a native desktop app, written in Rust with [GPUI](https://gpui.rs), that runs several [Claude Code](https://code.claude.com) sessions in one window on Windows and macOS. It is a personal project with rough edges. Issues and pull requests are welcome. +Claudiu is a native desktop app, written in Rust with [GPUI](https://gpui.rs), that runs several [Claude Code](https://code.claude.com) sessions in one window on Windows, macOS and Linux. It is a personal project with rough edges. Issues and pull requests are welcome. > **Claudiu is an independent project. It is not affiliated with, endorsed by or sponsored by Anthropic.** Claude and Claude Code are trademarks of Anthropic. @@ -14,16 +14,23 @@ Ctrl+Shift (Cmd+Shift on macOS) plus a letter drives the app. Everything else re ## What it touches -Claudiu never deletes a transcript. It writes to Claude Code's own data only to change the settings you switch in Claudiu, as `/config` does, and to sync shared files between accounts. Nothing is uploaded and terminal contents are never logged. The only network use is GitHub: the update check (off with `"settings": { "update_url": "" }` in `state.json`) and the GitHub pane. State lives in `%LOCALAPPDATA%\m4rocks\Claudiu\data` on Windows and `~/Library/Application Support/Claudiu` on macOS, and crashes go to `crash.log` there. +Claudiu never deletes a transcript. It writes to Claude Code's own data only to change the settings you switch in Claudiu, as `/config` does, and to sync shared files between accounts. Nothing is uploaded and terminal contents are never logged. The only network use is GitHub: the update check (off with `"settings": { "update_url": "" }` in `state.json`) and the GitHub pane. State lives in `%LOCALAPPDATA%\m4rocks\Claudiu\data` on Windows, `~/Library/Application Support/Claudiu` on macOS and `~/.local/share/claudiu` on Linux, and crashes go to `crash.log` there. ## Known gaps - macOS is lightly tested, and the build isn't notarized, so Gatekeeper complains on first launch. +- Linux is new and lightly tested. An app started from the desktop sees only the session's PATH, so tools that only your shell's startup files add (nvm, for one) aren't found. - Quitting ends running PTYs. Sessions stay resumable, but live processes don't survive a restart. ## Development -You need stable Rust. On Windows you also need Visual Studio Build Tools (C++) and the Windows SDK. Tasks go through [just](https://just.systems); run `just` to list them. +You need stable Rust. On Windows you also need Visual Studio Build Tools (C++) and the Windows SDK. On Linux you need the headers GPUI builds against; on Debian or Ubuntu: + +```sh +sudo apt install libfontconfig-dev libwayland-dev libx11-xcb-dev libxcb1-dev libxkbcommon-x11-dev libvulkan1 zlib1g-dev +``` + +Tasks go through [just](https://just.systems); run `just` to list them. ```sh just run # dev build: shows stderr, never checks for updates @@ -39,4 +46,4 @@ The repository has four parts: - `web/` is the Astro site. - `vendor/gpui-base/` is a patched copy of the editor crate. `Cargo.toml` says what the patch changes and when to drop it. -`CLAUDE.md` has the conventions for contributing. Releases use [Velopack](https://velopack.io) and GitHub Releases: bump `version` in `Cargo.toml`, then `git tag vX.Y.Z && git push --tags`. `scripts\package.ps1` builds a local installer. +`CLAUDE.md` has the conventions for contributing. Releases use [Velopack](https://velopack.io) and GitHub Releases: bump `version` in `Cargo.toml`, then `git tag vX.Y.Z && git push --tags`. `scripts\package.ps1` builds a local installer. The Linux release is an AppImage. diff --git a/src/github/ui/changes.rs b/src/github/ui/changes.rs index df0829c..6d1a6eb 100644 --- a/src/github/ui/changes.rs +++ b/src/github/ui/changes.rs @@ -28,7 +28,7 @@ impl GithubView { .cursor_pointer() .hover(|s| s.bg(hsla(0x1c1c1d))) .child(div().text_color(hsla(theme::TEXT_FAINT)).child(icon(if open { IconName::ChevronDown } else { IconName::ChevronRight }, 12.0))) - .child(div().flex_1().min_w_0().overflow_hidden().whitespace_nowrap().text_ellipsis().font_family(FONT).text_size(crate::panels::scale::px(12.0)).child(f.path.clone())) + .child(div().flex_1().min_w_0().overflow_hidden().whitespace_nowrap().text_ellipsis().font_family(monospace_font()).text_size(crate::panels::scale::px(12.0)).child(f.path.clone())) .children((f.status != "modified").then(|| faint(f.status.clone()))) .child(div().text_size(crate::panels::scale::px(11.5)).text_color(hsla(GREEN)).child(format!("+{}", f.additions))) .child(div().text_size(crate::panels::scale::px(11.5)).text_color(hsla(RED)).child(format!("−{}", f.deletions))) @@ -47,7 +47,7 @@ impl GithubView { if f.no_patch { return div().p(px(12.0)).child(faint("No inline diff for this file (binary or too large). Open on GitHub to view it.")); } - let mut lines = div().flex().flex_col().font_family(FONT).text_size(crate::panels::scale::px(11.5)).py(px(4.0)); + let mut lines = div().flex().flex_col().font_family(monospace_font()).text_size(crate::panels::scale::px(11.5)).py(px(4.0)); for l in f.lines.iter().take(if full { usize::MAX } else { SHOWN }) { let (bg, sign) = match l.kind { DiffKind::Add => (Some(GREEN), "+"), diff --git a/src/github/ui/detail.rs b/src/github/ui/detail.rs index 6b00ec1..7f739e7 100644 --- a/src/github/ui/detail.rs +++ b/src/github/ui/detail.rs @@ -71,7 +71,7 @@ impl GithubView { if let Some(pr) = &d.pr { status = status.child( div() - .font_family(FONT) + .font_family(monospace_font()) .text_size(crate::panels::scale::px(11.5)) .px(px(7.0)) .py(px(1.0)) @@ -422,7 +422,7 @@ impl GithubView { .gap(px(8.0)) .px(px(4.0)) .child(div().text_color(hsla(theme::TEXT_FAINT)).child(icon(IconName::GitCommitHorizontal, 14.0))) - .child(div().font_family(FONT).text_size(crate::panels::scale::px(11.5)).text_color(hsla(theme::ACCENT)).child(c.short.clone())) + .child(div().font_family(monospace_font()).text_size(crate::panels::scale::px(11.5)).text_color(hsla(theme::ACCENT)).child(c.short.clone())) .child(div().flex_1().min_w_0().overflow_hidden().whitespace_nowrap().text_ellipsis().child(c.headline.clone())) .child(faint(format!("{} · {}", c.author, ago(c.created, t)))) } @@ -474,7 +474,7 @@ impl GithubView { } for (k, c) in r.comments.iter().enumerate() { let hunk: Vec<&str> = c.hunk.lines().rev().take(6).collect::>().into_iter().rev().collect(); - let mut code = div().flex().flex_col().font_family(FONT).text_size(crate::panels::scale::px(11.5)).bg(hsla(0x0e0e0f)).py(px(4.0)).overflow_hidden(); + let mut code = div().flex().flex_col().font_family(monospace_font()).text_size(crate::panels::scale::px(11.5)).bg(hsla(0x0e0e0f)).py(px(4.0)).overflow_hidden(); for l in hunk { let bg = if l.starts_with('+') { Some(GREEN) } else if l.starts_with('-') { Some(RED) } else { None }; code = code.child(div().px(px(10.0)).whitespace_nowrap().when_some(bg, |d, c| d.bg(hsla(c).opacity(0.14))).child(if l.is_empty() { " ".to_string() } else { l.to_string() })); @@ -489,7 +489,7 @@ impl GithubView { .gap(px(8.0)) .px(px(12.0)) .py(px(6.0)) - .child(div().font_family(FONT).text_size(crate::panels::scale::px(11.5)).text_color(hsla(theme::TEXT_DIM)).child(format!("{}{}", c.path, c.line.map(|l| format!(":{l}")).unwrap_or_default()))) + .child(div().font_family(monospace_font()).text_size(crate::panels::scale::px(11.5)).text_color(hsla(theme::TEXT_DIM)).child(format!("{}{}", c.path, c.line.map(|l| format!(":{l}")).unwrap_or_default()))) .children(c.outdated.then(|| faint("outdated"))), ) .child(code) diff --git a/src/github/ui/mod.rs b/src/github/ui/mod.rs index 5b34b42..b3e71ef 100644 --- a/src/github/ui/mod.rs +++ b/src/github/ui/mod.rs @@ -22,7 +22,7 @@ use super::model::*; use crate::panels::widgets::Trigger; use super::view::*; use crate::store::now; -use crate::terminal::view::FONT; +use crate::platform::monospace_font; use crate::panels::theme::{self, hsla}; use gpui_kit::assets::IconName; use crate::panels::widgets::{ago, avatar, button, button_disabled, button_leading, danger_button, fade_in, icon, icon_button, section_label}; diff --git a/src/main.rs b/src/main.rs index 424b6d4..d7920be 100644 --- a/src/main.rs +++ b/src/main.rs @@ -132,6 +132,9 @@ fn open_main_window(initial: Vec, cx: &mut App) -> MainWindo }), // The top bar owns dragging and double-click (see TitleBar::window_options). app_owns_titlebar_drag: true, + // Linux: the top bar draws min/max/close itself instead of the window manager adding a second bar above + // it. A compositor without client-side decorations keeps its own bar. Other platforms ignore this. + window_decorations: Some(gpui::WindowDecorations::Client), ..Default::default() }, cx, diff --git a/src/panels/workspace_view.rs b/src/panels/workspace_view.rs index 2251556..f4ad9f0 100644 --- a/src/panels/workspace_view.rs +++ b/src/panels/workspace_view.rs @@ -37,6 +37,9 @@ impl Workspace { // traffic lights at the left (they are hidden in fullscreen); Windows/Linux get min/max/close at the right. let left_pad = if cfg!(target_os = "macos") && !window.is_fullscreen() { 80.0 } else { 10.0 }; TitleBar::new() + // Linux draws its own close button, which would otherwise drop the window without asking about working + // sessions or saving the layout. Going through Quit is the same path as Ctrl+Q and the OS close. + .on_close_window(|_, window, cx| window.dispatch_action(Box::new(crate::app::Quit), cx)) .h(px(theme::TOPBAR_HEIGHT)) .pl(px(left_pad)) .bg(hsla(theme::APP_BG)) diff --git a/src/platform.rs b/src/platform.rs index 6b5a4d8..4b8d7be 100644 --- a/src/platform.rs +++ b/src/platform.rs @@ -45,6 +45,39 @@ pub fn through_login_shell(program: String, args: Vec) -> (String, Vec &'static str { + #[cfg(target_os = "windows")] + { + "Cascadia Mono" + } + #[cfg(target_os = "macos")] + { + "Menlo" + } + #[cfg(not(any(target_os = "windows", target_os = "macos")))] + { + static FAMILY: std::sync::OnceLock = std::sync::OnceLock::new(); + FAMILY.get_or_init(|| fontconfig_monospace().unwrap_or_else(|| "DejaVu Sans Mono".into())) + } +} + +#[cfg(not(any(target_os = "windows", target_os = "macos")))] +fn fontconfig_monospace() -> Option { + let output = Command::new("fc-match").args(["--format=%{family[0]}", "monospace"]).stderr(Stdio::null()).output().ok()?; + if !output.status.success() { + return None; + } + family_from_fc_match(&String::from_utf8_lossy(&output.stdout)) +} + +#[cfg(any(not(any(target_os = "windows", target_os = "macos")), test))] +fn family_from_fc_match(output: &str) -> Option { + Some(output.trim()).filter(|family| !family.is_empty()).map(String::from) +} + pub fn home_dir() -> Option { directories::BaseDirs::new().map(|d| d.home_dir().to_path_buf()) } @@ -152,6 +185,7 @@ fn path_between_markers(output: &str) -> Option<&str> { /// The registry's directories first, then whatever this process had that the registry lacks (for example folders a /// launcher added for Claudiu alone). Each directory appears once. +#[cfg(any(target_os = "windows", target_os = "macos", test))] fn rebuilt_path(registry: &[PathBuf], current: &OsStr) -> std::ffi::OsString { let mut dirs: Vec = Vec::new(); for dir in registry.iter().cloned().chain(std::env::split_paths(current)) { @@ -488,6 +522,14 @@ bye assert_eq!(clean_path(Path::new(r"\\?\C:\x\y")), PathBuf::from(r"C:\x\y")); } + #[test] + fn the_monospace_family_is_what_fc_match_printed() { + assert_eq!(family_from_fc_match("DejaVu Sans Mono"), Some("DejaVu Sans Mono".to_string())); + assert_eq!(family_from_fc_match(" Fira Mono\n"), Some("Fira Mono".to_string())); + assert_eq!(family_from_fc_match(""), None, "no answer keeps the default"); + assert_eq!(family_from_fc_match(" \n"), None); + } + #[test] fn env_expansion() { unsafe { std::env::set_var("CLAUDIU_TEST_X", "val") }; diff --git a/src/terminal/skeleton.rs b/src/terminal/skeleton.rs index d7bc03e..b5c468b 100644 --- a/src/terminal/skeleton.rs +++ b/src/terminal/skeleton.rs @@ -7,7 +7,6 @@ use std::time::Duration; use gpui::{Animation, AnimationExt, IntoElement, Keystroke, div, prelude::*, px}; use crate::terminal::glyphs; -use crate::terminal::view::FONT; use crate::panels::theme; /// The message being typed. Edits are by character; `at` is a byte offset on a character boundary. @@ -444,7 +443,7 @@ pub fn overlay(draft: &Draft, elapsed: Duration, phase: &str, grid: Grid) -> imp // Claude Code keeps its prompt at the bottom of the screen. .justify_end() .overflow_hidden() - .font_family(FONT) + .font_family(crate::platform::monospace_font()) .text_size(crate::panels::scale::px(14.0)) .line_height(px(lh)) .child( diff --git a/src/terminal/view/mod.rs b/src/terminal/view/mod.rs index 5ecb5fe..384731e 100644 --- a/src/terminal/view/mod.rs +++ b/src/terminal/view/mod.rs @@ -122,10 +122,6 @@ impl Focusable for TerminalView { /// A row's height at the terminal's 14 px font (`font_size * 1.35`, rounded); the skeleton prompt lines up with it. pub const LINE_H: f32 = 19.0; -#[cfg(target_os = "windows")] -pub const FONT: &str = "Cascadia Mono"; -#[cfg(not(target_os = "windows"))] -pub const FONT: &str = "Menlo"; /// What to look for on Claude Code's screen to know a piece of the draft arrived. enum Marker { @@ -191,7 +187,7 @@ impl TerminalView { handing: false, exit_code: None, marked: None, - font_family: FONT, + font_family: crate::platform::monospace_font(), font_size: px(14.0), loading: false, handover: None, diff --git a/src/visual/ui/render.rs b/src/visual/ui/render.rs index d38e7b8..2b0ffb7 100644 --- a/src/visual/ui/render.rs +++ b/src/visual/ui/render.rs @@ -231,7 +231,7 @@ impl R { font.style = FontStyle::Italic; } if ctx.mono { - font.family = crate::terminal::view::FONT.into(); + font.family = crate::platform::monospace_font().into(); } let color = hsla(ctx.color); out.runs.push(TextRun {