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
55 changes: 54 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ anyhow = "1.0.104"
directories = "6.0.0"
dunce = "1.0.5"
futures = "0.3.34"
# A system notification when a session finishes while the window is in the background (`platform::notify`).
notify-rust = "4.19.0"
# Editor mode's file tree follows its folder on disk.
notify = "8.2.0"
git2 = { version = "0.21.0", default-features = false }
Expand Down Expand Up @@ -64,8 +66,6 @@ codegen-units = 4
strip = true

[target."cfg(windows)".dependencies]
# The main window's handle, to flash its taskbar button (`platform::request_attention`).
raw-window-handle = "0.6"
junction = "2.1.0"
windows-sys = { version = "0.61", features = ["Win32_UI_WindowsAndMessaging", "Win32_Foundation", "Win32_Security", "Win32_System_DataExchange", "Win32_System_Memory", "Win32_System_Registry", "Win32_System_Threading"] }

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ Claudiu is a native desktop app, written in Rust with [Rune](https://github.com/

## What it does

Each session is your own `claude` process in a real pseudo-terminal, so Claude Code's keys, mouse and paste work unchanged. Claudiu has no API keys and never calls the Anthropic API. Sign-in stays with Claude Code. The first launch opens a setup window that checks for `claude` (required) and `gh` (optional), links to their install pages and installs nothing. It also has an optional switch that turns off six Claude Code features that add tokens to every request and that coding rarely uses, such as Artifacts and bundled skills. Settings → Claude Code tools shows each switch as high, medium or low savings. Settings has a Check setup button to open it again. A sidebar lists your projects and sessions. Settings → Projects adds, renames, reorders and removes projects. Removing one keeps its sessions, and the notice that follows has an Undo button. Ended sessions resume through `claude --resume`, and sessions that were running come back at the next start.
Each session is your own `claude` process in a real pseudo-terminal, so Claude Code's keys, mouse and paste work unchanged. Claudiu has no API keys and never calls the Anthropic API. Sign-in stays with Claude Code. The first launch opens a setup window that checks for `claude` (required) and `gh` (optional), links to their install pages and installs nothing. It also has an optional switch that turns off six Claude Code features that add tokens to every request and that coding rarely uses, such as Artifacts and bundled skills. Settings → Claude Code tools shows each switch as high, medium or low savings. Settings has a Check setup button to open it again. A sidebar lists your running sessions, with the rest in a Recent list at its bottom that opens and scrolls. Settings → Projects adds, renames, reorders and removes projects. Removing one keeps its sessions, and the notice that follows has an Undo button. Ended sessions resume through `claude --resume`, and sessions that were running come back at the next start.

Around the terminal, Claudiu adds an editor mode (Ctrl+Shift+E) with files, tabs, search, Git change marks and language-server diagnostics, definitions and completion. It also adds usage and context meters, a GitHub pane for issues and pull requests through your `gh` login, defaults for the model, effort and permission mode of new sessions, and extra Claude accounts that share one configuration. When a reply needs a table, chart or diagram, Claude draws it as a card inside the terminal, under the tool call, and the card scrolls with the transcript. Cards can hold buttons that send a message for you, collapsible sections, tabs and charts, and they come back when you reopen a session. A session can move between git worktrees the way it switches branches, so several agents work on separate branches at once: the worktree button in the top bar switches the shown session into another worktree, or into a new one that Claudiu makes on a branch you name, and its conversation continues there (a session that has no conversation yet starts over in the new folder). Claude can switch the session itself with the `switch_worktree` tool, after you approve it and once its turn ends. In the menu, the hover x removes a worktree, the branch button's x deletes a local branch after telling you which commits would be lost, and ending the last session in a worktree offers to remove it. Claudiu keeps the worktrees it makes in its own data folder, outside your repositories, so they never show up in `git status`; Settings has a Worktrees page that lists them to show in the file manager or remove. Settings lists the rest.
Around the terminal, Claudiu adds an editor mode (Ctrl+Shift+E) with files, tabs, search, Git change marks and language-server diagnostics, definitions and completion. It also adds usage and context meters, a GitHub pane for issues and pull requests through your `gh` login (Claude attaches the ones it works on to the right sidebar, from this project or another repository), defaults for the model, effort and permission mode of new sessions, and extra Claude accounts that share one configuration. When a reply needs a table, chart or diagram, Claude draws it as a card inside the terminal, under the tool call, and the card scrolls with the transcript. Cards can hold buttons that send a message for you, collapsible sections, tabs and charts, and they come back when you reopen a session. A session can move between git worktrees the way it switches branches, so several agents work on separate branches at once: the worktree button in the top bar switches the shown session into another worktree, or into a new one that Claudiu makes on a branch you name, and its conversation continues there (a session that has no conversation yet starts over in the new folder). Claude can switch the session itself with the `switch_worktree` tool, after you approve it and once its turn ends. In the menu, the hover x removes a worktree, the branch button's x deletes a local branch after telling you which commits would be lost, and ending the last session in a worktree offers to remove it. Claudiu keeps the worktrees it makes in its own data folder, outside your repositories, so they never show up in `git status`; Settings has a Worktrees page that lists them to show in the file manager or remove. Settings lists the rest.

Ctrl+Shift (Cmd+Shift on macOS) plus a letter drives the app. Everything else reaches Claude Code. Editor mode finds `rust-analyzer`, `tsc --lsp` and `gleam` on your PATH and installs nothing.

To reduce background rendering, an inactive window updates streaming terminal output at most four times a second, with a final update when output stops. Returning to the window restores the normal frame rate. Busy sidebar icons stop animating while the window is inactive, the sidebar is hidden, or editor mode hides it.
To reduce background rendering, an inactive window updates streaming terminal output at most four times a second, with a final update when output stops. Returning to the window restores the normal frame rate. Busy sidebar icons stop animating while the window is inactive, the sidebar is hidden, or editor mode hides it. When a session finishes or asks a question while the window is in the background, Claudiu sends a system notification.

## What it touches

Expand Down
37 changes: 22 additions & 15 deletions src/app/attached_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ fn retry_wait(failures: u32) -> Duration {
RETRY_EVERY.saturating_mul(2u32.saturating_pow(failures)).min(REFRESH_EVERY)
}

/// One answer: the session, which item, and what GitHub said.
type Answer = (Id, bool, u32, String, State);
/// One answer: the session, which item (its repository, whether it is a pull request, its number), and what GitHub said.
type Answer = (Id, Option<String>, bool, u32, String, State);

impl Sync {
fn due(&self, some_unanswered: bool) -> bool {
Expand All @@ -36,8 +36,8 @@ impl Sync {
}
}

/// A session, its folder, and the items attached to it (`true` for a pull request) to ask GitHub about.
type Ask = (Id, PathBuf, Vec<(bool, u32)>);
/// A session, its folder, and the items attached to it (repository, `true` for a pull request, number) to ask GitHub about.
type Ask = (Id, PathBuf, Vec<(Option<String>, bool, u32)>);

impl Workspace {
pub(super) fn sync_attached(&mut self) {
Expand All @@ -47,7 +47,7 @@ impl Workspace {
.sessions
.iter()
.filter_map(|s| {
let items: Vec<_> = s.claude.as_ref()?.attached.iter().map(|a| (a.pull, a.number)).collect();
let items: Vec<_> = s.claude.as_ref()?.attached.iter().map(|a| (a.repo.clone(), a.pull, a.number)).collect();
// A session whose folder is gone cannot be asked about (and would never be answered). Checked last:
// it asks the disk, from the UI thread, and most sessions have nothing attached.
(!items.is_empty() && s.cwd.is_dir()).then(|| (s.id.clone(), s.cwd.clone(), items))
Expand All @@ -63,8 +63,8 @@ impl Workspace {
move || { ask_github(asks) },
move |ws: &mut Workspace, answers| {
ws.attached_sync.running = false;
let changed = answers.into_iter().fold(false, |c, (id, pull, number, title, state)| {
ws.edit_attached(&id, |list| links::set_status(list, pull, number, &title, state)) | c
let changed = answers.into_iter().fold(false, |c, (id, repo, pull, number, title, state)| {
ws.edit_attached(&id, |list| links::set_status(list, repo.as_deref(), pull, number, &title, state)) | c
});
ws.attached_sync.failures = if ws.unanswered_items() { ws.attached_sync.failures + 1 } else { 0 };
if changed {
Expand All @@ -88,14 +88,21 @@ fn ask_github(asks: Vec<Ask>) -> Vec<Answer> {
let mut repos: HashMap<PathBuf, Option<(Gh, RepoRef)>> = HashMap::new();
let mut answers = vec![];
for (id, cwd, items) in asks {
let found = repos.entry(cwd.clone()).or_insert_with(|| {
let gh = Gh::new(exe.clone(), cwd);
gh.repo().ok().map(|repo| (gh, repo))
});
let Some((gh, repo)) = found else { continue };
for (pull, number) in items {
if let Ok((title, state)) = gh.item_status(repo, number) {
answers.push((id.clone(), pull, number, title, state));
for (named, pull, number) in items {
// An item of another repository needs no GitHub folder; the folder's own repository is looked up once.
let status = match named.as_deref().and_then(RepoRef::on_github) {
Some(repo) => Gh::new(exe.clone(), cwd.clone()).item_status(&repo, number),
None => {
let found = repos.entry(cwd.clone()).or_insert_with(|| {
let gh = Gh::new(exe.clone(), cwd.clone());
gh.repo().ok().map(|repo| (gh, repo))
});
let Some((gh, repo)) = found else { continue };
gh.item_status(repo, number)
}
};
if let Ok((title, state)) = status {
answers.push((id.clone(), named, pull, number, title, state));
}
}
}
Expand Down
35 changes: 29 additions & 6 deletions src/app/background.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ fn next_activity(working: bool, waiting: bool, before: Option<Activity>, viewing
}
}

/// What the system notification says when a session stops working while the window is in the background: it
/// finished its turn, or it asks something. Nothing for any other change.
fn notice(before: Option<Activity>, now: Option<Activity>, window_active: bool) -> Option<&'static str> {
match (window_active, before, now) {
(false, Some(Activity::Working), Some(Activity::Attention)) => Some("Claude finished."),
(false, Some(Activity::Working), Some(Activity::Waiting)) => Some("Claude is waiting for your answer."),
_ => None,
}
}

impl Workspace {
/// Startup reconciliation: scan Claude Code's records off the UI thread, then merge.
pub fn start_scan(&mut self) {
Expand Down Expand Up @@ -58,7 +68,7 @@ impl Workspace {

/// Once a second: derive each Claude session's `Activity` from its terminal output. When one stops working
/// while the user isn't looking at it, mark it for attention, and if the whole window is in the
/// background as well, flash the taskbar icon / bounce the dock icon.
/// background as well, send a system notification.
pub(super) fn start_activity_poll(&mut self) {
self.rt.after_quietly(Duration::from_secs(1), |ws: &mut Workspace| {
let mut seen = std::mem::take(&mut ws.status_files);
Expand Down Expand Up @@ -90,7 +100,7 @@ impl Workspace {
let window_active = self.window_active;
let shown = self.active_id().cloned();
let mut next: HashMap<Id, Activity> = HashMap::new();
let mut flash = false;
let mut notices = vec![];
for l in &self.live {
let is_claude = self.store.session(&l.id).is_some_and(|r| r.kind == SessionKind::Claude);
let view = &l.view;
Expand All @@ -103,7 +113,9 @@ impl Workspace {
let waiting = status.is_some_and(|s| s == "waiting");
let before = self.activity.get(&l.id).copied();
let now = next_activity(working, waiting, before, viewing);
flash |= !window_active && before == Some(Activity::Working) && matches!(now, Some(Activity::Attention | Activity::Waiting));
if let Some(body) = notice(before, now, window_active) {
notices.push((self.store.session(&l.id).map(|r| r.display_title().to_string()).unwrap_or_default(), body));
}
if let Some(now) = now {
next.insert(l.id.clone(), now);
}
Expand All @@ -112,8 +124,8 @@ impl Workspace {
self.activity = next;
self.rt.dirty = true;
}
if flash && let Some(window) = lifecycle::main_window() {
platform::request_attention(&window);
for (title, body) in notices {
platform::notify(title, body);
}
self.sync_claude_names();
}
Expand Down Expand Up @@ -262,7 +274,18 @@ fn spin_visible(working: bool, active: bool, sidebar: bool) -> bool {

#[cfg(test)]
mod tests {
use super::{Activity, next_activity, spin_visible};
use super::{Activity, next_activity, notice, spin_visible};

#[test]
fn a_notification_says_a_background_session_finished_or_asks() {
use Activity::*;
assert_eq!(notice(Some(Working), Some(Attention), false), Some("Claude finished."));
assert_eq!(notice(Some(Working), Some(Waiting), false), Some("Claude is waiting for your answer."));
assert_eq!(notice(Some(Working), Some(Attention), true), None, "the window is in front");
assert_eq!(notice(Some(Attention), Some(Attention), false), None, "already told");
assert_eq!(notice(Some(Waiting), Some(Working), false), None, "it started working");
assert_eq!(notice(None, Some(Waiting), false), None, "it never worked meanwhile");
}

#[test]
fn spin_only_runs_for_a_visible_busy_sidebar() {
Expand Down
Loading
Loading