From 270161f748ec03ce940ff09b5e1ce3a0350ff88e Mon Sep 17 00:00:00 2001 From: Savin Angel-Mario Date: Mon, 16 Nov 2026 23:28:15 +0200 Subject: [PATCH 1/3] Follow renames and settings from Claude Code, share /config options across accounts - The model can no longer name the session: set_tab_title and its instructions are gone. The user names a session from its menu, by regenerating the title, or with /rename. - A /rename inside Claude Code renames the session in Claudiu. Claudiu reads the name from the transcript and adopts it when it changes, without undoing a rename made in Claudiu that hasn't reached Claude Code yet. The mod remembers the name so it doesn't run /rename again when Claudiu writes it back. - The /config options Claude Code saves in .claude.json are shared across every account and the main ~/.claude, next to MCP servers and folder trust. Sign-in, counters and caches stay per account. Closes #107 Closes #108 Closes #109 --- README.md | 2 +- mod/hooks/register.js | 8 ++- mod/hooks/rename.test.ts | 20 ++++++ src/app/ingest.rs | 26 +------- src/app/lifecycle.rs | 2 +- src/app/mod.rs | 3 - src/app/sessions.rs | 1 - src/claude/config_sync.rs | 65 +++++++++++++++++++- src/claude/mcp.rs | 124 +++++++++++--------------------------- src/claude/mod.rs | 3 +- src/store.rs | 57 +++++++++++++++++- 11 files changed, 186 insertions(+), 125 deletions(-) diff --git a/README.md b/README.md index 01ec3f9..4db98b4 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Claudiu is a native desktop app, written in Rust with [Rune](https://github.com/ 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 (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. +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: settings, `CLAUDE.md`, keybindings, MCP servers, folder trust and the options `/config` saves, with your main `~/.claude` too. An account with a running session takes a changed `/config` option once its sessions have ended. You name a session yourself, from its right-click menu, by regenerating its title, or with `/rename` in Claude Code, which Claudiu's sidebar follows. 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. diff --git a/mod/hooks/register.js b/mod/hooks/register.js index 3b0cee4..41409b8 100644 --- a/mod/hooks/register.js +++ b/mod/hooks/register.js @@ -11,8 +11,8 @@ // - Messages: sends a message Claudiu asks for through the same file (the editor's Ask Claude) as the user's own words, // when the session is idle, without typing into the terminal. (Claudiu itself pastes the editor's `@file#L` // reference into Claude's input box; that is not done here.) -// - Usage and status: reports context, the 5-hour and 7-day limits, auto-compact, background compaction, advisor and -// the last command to `CLAUDIU_USAGE_DIR/.json`. No tokens are spent. +// - Usage and status: reports context, the 5-hour and 7-day limits, auto-compact, background compaction and advisor to +// `CLAUDIU_USAGE_DIR/.json`, after each request, command and setting change. No tokens are spent. // - Cards: answers `show_visual` in-process and, while the model is still writing the call, streams its Markdown to // `CLAUDIU_VISUAL_PREFIX.json`. Under each call it reserves rows, each with a link naming the call, and Claudiu // paints the live card over them. Claudiu's measured height comes back in `CLAUDIU_VISUAL_PREFIX.rows`. @@ -354,6 +354,10 @@ async function onMeasure($, e, next) { async function onCommandRun($, e, next) { const r = await next(e) // the command has run: a setting it changed is read after it + // A name the user gave with /rename is the session's now. Claudiu reads it from the transcript and writes it back to + // CLAUDIU_NAME_FILE; it is already applied, so that must not run /rename again. + const name = e.command === 'rename' ? e.args.trim() : '' + if (name) named = (await $.session.id()) + '\n' + name await report($, true) return r } diff --git a/mod/hooks/rename.test.ts b/mod/hooks/rename.test.ts index 123c968..6905256 100644 --- a/mod/hooks/rename.test.ts +++ b/mod/hooks/rename.test.ts @@ -28,3 +28,23 @@ test('applies a changed name with /rename, never the launch name, and again afte await clock.advance(1000) expect(renames).toEqual(['rename New name', 'rename New name']) }) + +test('a name the user gave with /rename is not applied again when Claudiu writes it back', async ($, on) => { + const clock = mock.clock(on) + mock.env(on, { CLAUDIU_NAME_FILE: 'names/s.txt' }) + let name = 'Launch name' + const renames: string[] = [] + on('fs.read', () => ({ value: name })) + on('session.id', () => ({ value: 'claude-1' })) + on('session.start', (_$, e) => ({ cwd: e.cwd })) + on('command.run', (_$, e) => { + renames.push(`${e.command} ${e.args}`) + return {} + }) + + await $.session.start({ cwd: '/repo', surface: 'terminal', isInteractive: true }) + await $.command.run({ command: 'rename', args: ' Typed name ', origin: { kind: 'composer' }, presentation: { isFullscreen: false, columns: 80 } }) + name = 'Typed name' // Claudiu adopted it from the transcript and wrote it back + await clock.advance(3000) + expect(renames).toEqual(['rename Typed name ']) +}) diff --git a/src/app/ingest.rs b/src/app/ingest.rs index 20b40f1..5e33758 100644 --- a/src/app/ingest.rs +++ b/src/app/ingest.rs @@ -1,5 +1,5 @@ //! Taking in what other processes left in the data folder: the per-process mod's usage snapshots (limits, context, -//! settings), the tab titles Claude chose, and the links and GitHub items sessions asked for. Reading the files is +//! settings), and the links and GitHub items sessions asked for. Reading the files is //! off the UI thread; applying them is a handful of small, separately testable steps. use super::*; @@ -10,10 +10,9 @@ impl Workspace { /// Costs no tokens; the files are tiny. pub(super) fn ingest_usage(&mut self) { self.rt.spawn_quietly( - move || { (usage::read_snapshots(&usage::snapshot_dir()), mcp::read_titles(), mcp::read_attached()) }, - move |ws: &mut Workspace, (snaps, titles, items)| { + move || { (usage::read_snapshots(&usage::snapshot_dir()), mcp::read_attached()) }, + move |ws: &mut Workspace, (snaps, items)| { let mut changed = false; - changed |= titles.into_iter().fold(false, |c, (stem, title, stamp)| ws.apply_title(&stem, title, stamp) | c); changed |= snaps.iter().fold(false, |c, snap| ws.apply_snapshot(snap) | c); changed |= items.into_iter().fold(false, |c, (stem, item)| ws.apply_attachment(&stem, item) | c); if changed { @@ -24,25 +23,6 @@ impl Workspace { ); } - /// A title Claude chose for its session through the MCP tool. - fn apply_title(&mut self, stem: &str, title: String, stamp: Option) -> bool { - let Some(rec) = self.store.data.sessions.iter_mut().find(|s| s.claude_id().is_some_and(|id| datadir::safe_file_stem(id) == stem)) else { return false }; - if let Some(l) = self.live.iter_mut().find(|l| l.id == rec.id) - && l.title_stamp != stamp - { - // The first read only records the stamp: a resumed session already got `--name`. - if l.title_stamp.is_some() { - l.claude_name = None; - } - l.title_stamp = stamp; - } - if rec.auto_title.as_deref() == Some(title.as_str()) { - return false; - } - rec.auto_title = Some(title); - true - } - /// One mod report: the account's limits, and the session's own figures and settings. fn apply_snapshot(&mut self, snap: &Snapshot) -> bool { let account = snap.account.as_deref().unwrap_or(MAIN_ACCOUNT); diff --git a/src/app/lifecycle.rs b/src/app/lifecycle.rs index 6ed1387..7276fe8 100644 --- a/src/app/lifecycle.rs +++ b/src/app/lifecycle.rs @@ -18,7 +18,7 @@ pub fn tidy_leftovers() { datadir::prune(attached, 7 * 86_400); datadir::prune(mcp_configs, 7 * 86_400); datadir::prune(crate::claude::trim::settings_dir(), 7 * 86_400); - // Titles are copied into the store on the next tick, so an old file is only a duplicate. + // Nothing writes titles any more; the old files go. datadir::prune(titles, 7 * 86_400); datadir::prune(usage::snapshot_dir(), 30 * 86_400); datadir::prune(usage::ctl_dir(), 7 * 86_400); diff --git a/src/app/mod.rs b/src/app/mod.rs index 524792a..e7616cf 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -348,9 +348,6 @@ pub struct Live { pub view: TerminalView, /// The session name Claude Code was last given (`--name` or `/rename`), so a changed title is sent once. pub claude_name: Option, - /// When Claude last called the title tool. A later call (e.g. after `/clear`, which starts a nameless - /// Claude session) clears `claude_name` so the title is sent again. - pub title_stamp: Option, /// The account this process was started under; a session on another account than the active one can be handed off. pub account: Id, } diff --git a/src/app/sessions.rs b/src/app/sessions.rs index 10712eb..9f90523 100644 --- a/src/app/sessions.rs +++ b/src/app/sessions.rs @@ -276,7 +276,6 @@ impl Workspace { id: id.clone(), view, claude_name, - title_stamp: None, account, }); self.activate(&id); diff --git a/src/claude/config_sync.rs b/src/claude/config_sync.rs index c9f50f5..91224fa 100644 --- a/src/claude/config_sync.rs +++ b/src/claude/config_sync.rs @@ -20,8 +20,44 @@ use serde_json::{Map, Value}; /// Files inside each account's config folder that every account shares. const FILES: &[&str] = &["settings.json", "CLAUDE.md", "keybindings.json"]; -/// Top-level keys of an account's `.claude.json` that every account shares: the user's MCP servers. -const SHARED_KEYS: &[&str] = &["mcpServers"]; +/// Top-level keys of an account's `.claude.json` that every account shares: the user's MCP servers, and the +/// preferences `/config` saves there. The preferences are Claude Code's own list of global config keys (2.1.325), +/// without the sign-in, install details, counters, notices and caches it also holds; Claude Code writes only the ones +/// changed from their defaults, so most are usually absent. +const SHARED_KEYS: &[&str] = &[ + "mcpServers", + "theme", + "verbose", + "editorMode", + "preferredNotifChannel", + "autoCompactEnabled", + "autoScrollEnabled", + "showTurnDuration", + "showMessageTimestamps", + "diffTool", + "todoFeatureEnabled", + "showExpandedTodos", + "briefTranscript", + "messageIdleNotifThresholdMs", + "autoConnectIde", + "autoInstallIdeExtension", + "fileCheckpointingEnabled", + "terminalProgressBarEnabled", + "showStatusInTerminalTab", + "taskCompleteNotifEnabled", + "inputNeededNotifEnabled", + "agentPushNotifEnabled", + "respectGitignore", + "claudeInChromeDefaultEnabled", + "copyFullResponse", + "copyOnSelect", + "leftArrowOpensAgents", + "defaultToAgentsView", + "prStatusFooterEnabled", + "teammateMode", + "remoteControlAtStartup", + "autoUploadSessions", +]; /// One project's trust in `.claude.json`: once any account trusts a folder, every account does. const TRUST_KEY: &str = "hasTrustDialogAccepted"; @@ -384,6 +420,31 @@ mod tests { assert!(main.get("mcpServers").is_none(), "the removal reached main"); } + #[test] + fn a_config_option_changed_in_one_account_reaches_every_account_and_its_reset_does_too() { + let s = setup(3); + for (a, who) in s.accounts.iter().zip(["main", "alt1", "alt2"]) { + write_at(&a.claude_json, &format!(r#"{{"oauthAccount":{{"email":"{who}"}},"numStartups":1}}"#), 1000); + } + sync(&s.accounts, &s.state).unwrap(); + let json = |a: &Account| serde_json::from_str::(&fs::read_to_string(&a.claude_json).unwrap()).unwrap(); + + // `/config` in the second alt: the theme and auto-compact. + write_at(&s.accounts[2].claude_json, r#"{"oauthAccount":{"email":"alt2"},"numStartups":9,"theme":"light","autoCompactEnabled":false}"#, 2000); + sync(&s.accounts, &s.state).unwrap(); + for (a, who) in s.accounts.iter().zip(["main", "alt1", "alt2"]) { + let j = json(a); + assert_eq!((j["theme"].as_str(), j["autoCompactEnabled"].as_bool()), (Some("light"), Some(false)), "{who}"); + assert_eq!(j["oauthAccount"]["email"], who, "the login stays the account's own"); + } + assert_eq!(json(&s.accounts[0])["numStartups"], 1, "counters are not shared"); + + // Back to the default in main: Claude Code drops the key, and the others drop it too. + write_at(&s.accounts[0].claude_json, r#"{"oauthAccount":{"email":"main"},"numStartups":1,"autoCompactEnabled":false}"#, 3000); + sync(&s.accounts, &s.state).unwrap(); + assert!(s.accounts.iter().all(|a| json(a).get("theme").is_none())); + } + #[test] fn a_busy_accounts_claude_json_is_not_written_and_catches_up_when_idle() { let mut s = setup(2); diff --git a/src/claude/mcp.rs b/src/claude/mcp.rs index 0073892..2250235 100644 --- a/src/claude/mcp.rs +++ b/src/claude/mcp.rs @@ -25,7 +25,7 @@ pub const RECORD_ENV: &str = "CLAUDIU_RECORD"; /// Comma-separated names of what the server leaves out of this session (see `tools_off`). Missing means nothing is off. pub const TOOLS_OFF_ENV: &str = "CLAUDIU_TOOLS_OFF"; -/// A group of Claudiu's tools the user can switch off (Settings → Claudiu tools). `set_tab_title` has no switch. +/// A group of Claudiu's tools the user can switch off (Settings → Claudiu tools). #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum Feature { @@ -73,7 +73,7 @@ pub fn tools_off(features: &[Feature], trimmed: &[Trim]) -> Vec<&'static str> { off } -/// The feature a tool belongs to; `set_tab_title` belongs to none. +/// The feature a tool belongs to. fn feature_of(tool: &str) -> Option<&'static str> { match tool { "show_visual" => Some("visual"), @@ -90,13 +90,13 @@ fn is_off(off: &[&str], tool: &str) -> bool { } /// Tools the model uses to tell Claudiu something about itself; none of them reads or starts another session. -const OWN_TOOLS: [&str; 6] = ["set_tab_title", "attach_github", "detach_github", "link_session", "unlink_session", "show_visual"]; +const OWN_TOOLS: [&str; 5] = ["attach_github", "detach_github", "link_session", "unlink_session", "show_visual"]; /// Tools that reach other sessions (`claude/bridge.rs`). const BRIDGE_TOOLS: [&str; 6] = ["list_code_sessions", "read_code_session", "search_sessions", "search_projects", "start_code_session", "switch_worktree"]; -/// `mcp____` names allowed per process so Claude Code adds no prompt of its own: renaming the tab is -/// harmless, and the cross-session tools are limited to what the user asks of the model. +/// `mcp____` names allowed per process so Claude Code adds no prompt of its own: Claudiu's own tools only +/// change what Claudiu shows, and the cross-session tools are limited to what the user asks of the model. pub fn allowed_tools(off: &[&str]) -> Vec { OWN_TOOLS.iter().copied().chain(BRIDGE_TOOLS).filter(|t| !is_off(off, t)).map(|t| format!("mcp__claudiu__{t}")).collect() } @@ -124,10 +124,9 @@ const VISUAL_LOADING: &str = " Load it first with ToolSearch (select:mcp__claudi const GITHUB_INSTRUCTIONS: &str = " GitHub: call attach_github (silent, free) for each issue or pull request you work on, \ as its description says; detach_github takes one off again."; -const TITLE_INSTRUCTIONS: &str = "You are running inside Claudiu, which shows a tab title for this session. Call \ -set_tab_title (2-5 words, no quotes) once you understand the user's first request, again only when the task changes \ -and the title no longer fits, and whenever the user asks for a rename (use their name). Never repeat a near-identical \ -title; if the user ran /rename, leave it. Don't mention the tool unless asked."; +/// The opening of the instructions; each feature's text follows it. The user names the session, so there is nothing +/// about the title here. +const INTRO: &str = "You are running inside Claudiu, a desktop app that runs this Claude Code session."; /// What makes the model ask before it calls `set_model`; `ask` is how it asks. fn model_instructions(ask: &str) -> String { @@ -137,10 +136,10 @@ just named them. After set_model, end your turn and ask the user to confirm befo ) } -/// The `initialize` reply's instructions: the tab-title text, then the text of each feature that is not off. +/// The `initialize` reply's instructions: the opening, then the text of each feature that is not off. fn instructions(off: &[&str]) -> String { let on = |name: &str| !off.contains(&name); - let mut text = TITLE_INSTRUCTIONS.to_string(); + let mut text = INTRO.to_string(); if on("model") { text += &model_instructions(if on("ask_user_question") { "with AskUserQuestion" } else { "the user" }); } @@ -163,6 +162,7 @@ fn instructions(off: &[&str]) -> String { text } +/// Where the model's tab titles went before the user alone named sessions; kept so `app/lifecycle.rs` prunes old files. fn titles_dir() -> PathBuf { crate::datadir::data_dir().join("titles") } @@ -190,14 +190,6 @@ fn config_dir() -> PathBuf { crate::datadir::data_dir().join("mcp") } -/// Collapse whitespace, drop control characters, cap the length. `None` when nothing is left. -fn clean_title(raw: &str) -> Option { - let t: String = raw.chars().filter(|c| !c.is_control() || c.is_whitespace()).collect(); - let t = t.split_whitespace().collect::>().join(" "); - let t: String = t.chars().take(60).collect(); - (!t.is_empty()).then_some(t) -} - /// Entry point of `claudiu --mcp-title`: newline-delimited JSON-RPC over stdio. pub fn run() -> i32 { let session = std::env::var(SESSION_ENV).unwrap_or_default(); @@ -210,13 +202,13 @@ pub fn run() -> i32 { } let off_env = std::env::var(TOOLS_OFF_ENV).unwrap_or_default(); let off: Vec<&str> = off_env.split(',').map(str::trim).filter(|n| !n.is_empty()).collect(); - serve(std::io::stdin().lock(), std::io::stdout().lock(), &session, &record, &crate::datadir::data_dir(), &off, |tool, args| crate::claude::bridge::ask(&from, tool, args)); + serve(std::io::stdin().lock(), std::io::stdout().lock(), &record, &crate::datadir::data_dir(), &off, |tool, args| crate::claude::bridge::ask(&from, tool, args)); 0 } /// `off` names what this session leaves out (see `tools_off`): those tools are neither listed nor callable and their /// instruction text is dropped. `ask` carries a cross-session request to Claudiu and waits for the user's answer. -fn serve(input: impl BufRead, mut out: impl Write, session: &str, record: &str, data: &Path, off: &[&str], ask: impl Fn(&str, &Value) -> Result) { +fn serve(input: impl BufRead, mut out: impl Write, record: &str, data: &Path, off: &[&str], ask: impl Fn(&str, &Value) -> Result) { for line in input.lines().map_while(Result::ok) { let Ok(msg) = serde_json::from_str::(&line) else { continue }; // Notifications (no id) and responses (no method) need no answer. @@ -231,7 +223,6 @@ fn serve(input: impl BufRead, mut out: impl Write, session: &str, record: &str, "ping" => Ok(json!({})), "tools/list" => Ok(json!({ "tools": own_tools(off).into_iter().chain(bridge_tools()).filter(|t| !is_off(off, t["name"].as_str().unwrap_or_default())).collect::>() })), "tools/call" => Ok(match msg["params"]["name"].as_str().filter(|tool| !is_off(off, tool)) { - Some("set_tab_title") => set_title(&msg["params"], session, &data.join("titles")), Some("attach_github") => attach_github(&msg["params"], record, &attach_dir(data)), Some("detach_github") => detach_github(&msg["params"], record, &attach_dir(data)), Some("link_session") => link_session(&msg["params"], record, &attach_dir(data), "link"), @@ -321,15 +312,7 @@ fn own_tools(off: &[&str]) -> Vec { "required": ["content"], }, }); - vec![upfront(json!({ - "name": "set_tab_title", - "description": "Set this session's tab title in Claudiu (2-5 words). Call after the first request, when the current task or scope changes, and whenever the user asks to rename the session or tab. Don't repeat an unchanged title.", - "inputSchema": { - "type": "object", - "properties": { "title": { "type": "string", "description": "Short tab title, 2-5 words" } }, - "required": ["title"], - }, - })), attach, detach, json!({ + vec![attach, detach, json!({ "name": "set_model", "description": format!( "Switch this session's model and/or effort from your next request on, even mid-turn. Always ask the user first{} (which model, which effort) unless they just named them explicitly; never switch on your own. Claude Code also keeps the choice as the user's default model/effort.", @@ -387,19 +370,6 @@ fn reply(text: &str, is_error: bool) -> Value { json!({ "content": [{ "type": "text", "text": text }], "isError": is_error }) } -fn set_title(params: &Value, session: &str, dir: &Path) -> Value { - let Some(title) = params["arguments"]["title"].as_str().and_then(clean_title) else { - return reply("title must be a non-empty string", true); - }; - if session.is_empty() { - return reply("not running inside Claudiu", true); - } - match crate::datadir::write_atomic(&dir.join(format!("{}.txt", crate::datadir::safe_file_stem(session))), &title) { - Ok(()) => reply("Tab renamed.", false), - Err(e) => reply(&format!("could not save title: {e}"), true), - } -} - /// Remember an issue or pull request for the session: one JSON line per call, picked up by `read_attached`. /// Keyed by Claudiu's own record id, which (unlike Claude's session id) survives `/clear`. fn attach_github(params: &Value, record: &str, dir: &Path) -> Value { @@ -522,21 +492,6 @@ fn keep_config_fresh(path: PathBuf) { }); } -/// `(claude session id stem, title, written at)` for every title Claude has set. The timestamp changes on every -/// call of the tool, even with an unchanged title, which is how a `/clear` (new Claude session) is noticed. -pub fn read_titles() -> Vec<(String, String, Option)> { - let Ok(entries) = std::fs::read_dir(titles_dir()) else { return vec![] }; - entries - .flatten() - .filter(|e| e.path().extension().and_then(|x| x.to_str()) == Some("txt")) - .filter_map(|e| { - let stem = e.path().file_stem()?.to_string_lossy().into_owned(); - let title = clean_title(&std::fs::read_to_string(e.path()).ok()?)?; - Some((stem, title, e.metadata().and_then(|m| m.modified()).ok())) - }) - .collect() -} - /// What a session asked Claudiu to remember about itself. #[derive(Debug, PartialEq)] pub enum Attachment { @@ -600,7 +555,7 @@ mod tests { fn talk_off(requests: &[Value], session: &str, dir: &Path, off: &[&str], ask: impl Fn(&str, &Value) -> Result) -> Vec { let input: String = requests.iter().map(|r| format!("{r}\n")).collect(); let mut out = Vec::new(); - serve(input.as_bytes(), &mut out, session, session, dir, off, ask); + serve(input.as_bytes(), &mut out, session, dir, off, ask); String::from_utf8(out).unwrap().lines().map(|l| serde_json::from_str(l).unwrap()).collect() } @@ -646,10 +601,10 @@ mod tests { let names: Vec<_> = tools.iter().map(|t| t["name"].as_str().unwrap()).collect(); assert_eq!( names, - ["set_tab_title", "attach_github", "detach_github", "set_model", "link_session", "unlink_session", "show_visual", "list_code_sessions", "read_code_session", "search_sessions", "search_projects", "start_code_session", "switch_worktree"] + ["attach_github", "detach_github", "set_model", "link_session", "unlink_session", "show_visual", "list_code_sessions", "read_code_session", "search_sessions", "search_projects", "start_code_session", "switch_worktree"] ); let upfront: Vec<_> = tools.iter().filter(|t| t["_meta"]["anthropic/alwaysLoad"] == true).map(|t| t["name"].as_str().unwrap()).collect(); - assert_eq!(upfront, ["set_tab_title", "attach_github", "detach_github", "link_session", "unlink_session"], "show_visual and the session-reaching tools stay deferred"); + assert_eq!(upfront, ["attach_github", "detach_github", "link_session", "unlink_session"], "show_visual and the session-reaching tools stay deferred"); assert_eq!(r[1]["result"]["content"][0]["text"], "read_code_session \"x\""); assert_eq!(r[1]["result"]["isError"], false); assert_eq!(r[2]["result"]["content"][0]["text"], "The user declined."); @@ -676,14 +631,14 @@ mod tests { } #[test] - fn handshake_lists_the_tool_and_set_title_writes_a_file() { + fn handshake_lists_the_tools_and_the_model_cannot_name_the_session() { let tmp = tempfile::tempdir().unwrap(); let replies = talk( &[ json!({"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26"}}), json!({"jsonrpc":"2.0","method":"notifications/initialized"}), json!({"jsonrpc":"2.0","id":2,"method":"tools/list"}), - json!({"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"set_tab_title","arguments":{"title":" Fix\n the build "}}}), + json!({"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"set_tab_title","arguments":{"title":"Fix the build"}}}), json!({"jsonrpc":"2.0","id":4,"method":"nope"}), ], "abc-123", @@ -691,10 +646,10 @@ mod tests { ); assert_eq!(replies.len(), 4, "the notification gets no reply"); assert_eq!(replies[0]["result"]["protocolVersion"], "2025-03-26"); - assert!(replies[0]["result"]["instructions"].as_str().unwrap().contains("set_tab_title")); - assert_eq!(replies[1]["result"]["tools"][0]["name"], "set_tab_title"); - assert_eq!(replies[2]["result"]["isError"], false); - assert_eq!(std::fs::read_to_string(tmp.path().join("titles/abc-123.txt")).unwrap(), "Fix the build"); + assert!(!replies[0]["result"]["instructions"].as_str().unwrap().contains("title"), "nothing asks the model to name the session"); + assert_eq!(replies[1]["result"]["tools"][0]["name"], "attach_github"); + assert_eq!((replies[2]["result"]["isError"].clone(), replies[2]["result"]["content"][0]["text"].clone()), (json!(true), json!("unknown tool"))); + assert!(!tmp.path().join("titles").exists()); assert_eq!(replies[3]["error"]["code"], -32601); } @@ -703,7 +658,7 @@ mod tests { let tmp = tempfile::tempdir().unwrap(); let call = json!({"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"set_model","arguments":{"model":"opus"}}}); let r = talk(&[json!({"jsonrpc":"2.0","id":9,"method":"tools/list"}), call], "abc-123", tmp.path()); - assert_eq!(r[0]["result"]["tools"][3]["name"], "set_model"); + assert_eq!(r[0]["result"]["tools"][2]["name"], "set_model"); assert_eq!(r[1]["result"]["isError"], true); } @@ -786,17 +741,6 @@ mod tests { assert_eq!(parse_attachment("nonsense"), None); } - #[test] - fn bad_titles_are_rejected_and_long_ones_capped() { - let tmp = tempfile::tempdir().unwrap(); - let call = |args: Value| json!({"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"set_tab_title","arguments":args}}); - let r = talk(&[call(json!({"title":" "})), call(json!({})), call(json!({"title":"x".repeat(200)}))], "s", tmp.path()); - assert_eq!(r[0]["result"]["isError"], true); - assert_eq!(r[1]["result"]["isError"], true); - assert_eq!(std::fs::read_to_string(tmp.path().join("titles/s.txt")).unwrap().len(), 60); - assert_eq!(talk(&[call(json!({"title":"hi"}))], "", tmp.path())[0]["result"]["isError"], true); - } - /// The tool names and the instruction text a server with `off` hands out. fn offer(off: &[&str]) -> (Vec, String) { let tmp = tempfile::tempdir().unwrap(); @@ -814,8 +758,8 @@ mod tests { #[test] fn with_nothing_off_the_server_offers_every_tool_and_all_the_text() { let (names, text) = offer(&[]); - assert_eq!(names.len(), 13); - for part in [TITLE_INSTRUCTIONS, GITHUB_INSTRUCTIONS, LINK_INSTRUCTIONS, VISUAL_INSTRUCTIONS, BRIDGE_INSTRUCTIONS] { + assert_eq!(names.len(), 12); + for part in [INTRO, GITHUB_INSTRUCTIONS, LINK_INSTRUCTIONS, VISUAL_INSTRUCTIONS, BRIDGE_INSTRUCTIONS] { assert!(text.contains(part)); } assert!(text.contains("ask with AskUserQuestion which model") && text.contains("Artifacts are for pages to share.")); @@ -824,30 +768,30 @@ mod tests { #[test] fn each_feature_takes_its_tools_and_its_text_away() { let (names, text) = offer(&["visual"]); - assert!(!names.contains(&"show_visual".to_string()) && names.len() == 12); + assert!(!names.contains(&"show_visual".to_string()) && names.len() == 11); assert!(!text.contains("Visual:") && !text.contains("show_visual")); let (names, text) = offer(&["github"]); - assert!(!names.iter().any(|n| n.ends_with("_github")) && names.len() == 11); + assert!(!names.iter().any(|n| n.ends_with("_github")) && names.len() == 10); assert!(!text.contains("attach_github")); let (names, text) = offer(&["sessions"]); for gone in ["link_session", "unlink_session", "list_code_sessions", "read_code_session", "search_sessions", "search_projects", "start_code_session", "switch_worktree"] { assert!(!names.contains(&gone.to_string()), "{gone}"); } - assert_eq!(names.len(), 5); + assert_eq!(names.len(), 4); assert!(!text.contains("link_session") && !text.contains("start_code_session")); let (names, text) = offer(&["model"]); - assert!(!names.contains(&"set_model".to_string()) && names.len() == 12); + assert!(!names.contains(&"set_model".to_string()) && names.len() == 11); assert!(!text.contains("set_model") && !text.contains("Never switch models")); } #[test] - fn the_tab_title_tool_and_text_stay_with_every_feature_off() { + fn with_every_feature_off_only_the_opening_is_left() { let (names, text) = offer(&["visual", "github", "sessions", "model"]); - assert_eq!(names, ["set_tab_title"]); - assert_eq!(text, TITLE_INSTRUCTIONS); + assert!(names.is_empty()); + assert_eq!(text, INTRO); } #[test] @@ -863,7 +807,7 @@ mod tests { #[test] fn allowed_tools_leaves_out_the_tools_of_features_that_are_off() { - assert_eq!(allowed_tools(&["github", "sessions"]), ["mcp__claudiu__set_tab_title", "mcp__claudiu__show_visual"]); + assert_eq!(allowed_tools(&["github", "sessions"]), ["mcp__claudiu__show_visual"]); } #[test] diff --git a/src/claude/mod.rs b/src/claude/mod.rs index 394edeb..839090b 100644 --- a/src/claude/mod.rs +++ b/src/claude/mod.rs @@ -377,12 +377,13 @@ pub fn read_session(path: &Path) -> Option { } } - let title = custom_title.or(ai_title).or(first_prompt); + let title = custom_title.clone().or(ai_title).or(first_prompt); Some(SessionScan { session: ExternalSession { session_id, cwd, title, + custom_title, created_at: created.unwrap_or(created_fs), last_active: modified_fs, model, diff --git a/src/store.rs b/src/store.rs index f3e2a7b..e7ebfad 100644 --- a/src/store.rs +++ b/src/store.rs @@ -90,6 +90,10 @@ pub struct ClaudeMeta { /// Background compaction ("Precompute compaction" in `/config`); `None` while Claude Code does not offer it. #[serde(default)] pub precompute_compact: Option, + /// The name Claude Code held for the session (its last `/rename`) when Claudiu last read the transcript. A different + /// one later means the user renamed it inside Claude Code. + #[serde(default)] + pub claude_title: Option, /// Claude in Chrome: the session is (re)started with `--chrome`. Claudiu's own choice, so it survives restarts. #[serde(default)] pub chrome: bool, @@ -124,7 +128,8 @@ pub struct SessionRecord { /// Claudiu-only display label; wins over `title` when set. #[serde(default)] pub custom_title: Option, - /// Tab title Claude chose itself through Claudiu's MCP tool (see `claude/mcp.rs`). Beats `title`, loses to `custom_title`. + /// Tab title Claude chose through Claudiu's former `set_tab_title` tool. Nothing sets it any more; a session that + /// had one keeps showing it until it is renamed. Beats `title`, loses to `custom_title`. #[serde(default)] pub auto_title: Option, pub cwd: PathBuf, @@ -642,12 +647,29 @@ pub fn project_for(projects: &[Project], cwd: &Path) -> Option { .map(|(_, id)| id) } +/// A name the user gave the session inside Claude Code since the last read, to show in Claudiu too. Records what +/// Claude Code holds either way. Only a change counts: Claude Code keeps the old name until a rename made in Claudiu +/// reaches it, and that rename must not be undone meanwhile. The first name seen is taken only when Claudiu has no +/// name of its own; otherwise it is only recorded, since Claudiu can't tell whether it came before or after Claudiu's. +fn adopt_claude_title(rec: &mut SessionRecord, held: Option<&str>) -> Option { + let held = held.map(str::trim).filter(|t| !t.is_empty())?; + let named_in_claudiu = rec.custom_title.is_some(); + let meta = rec.claude.as_mut()?; + let changed = match meta.claude_title.replace(held.to_string()) { + Some(before) => before != held, + None => !named_in_claudiu, + }; + changed.then(|| held.to_string()) +} + /// What we learned about one Claude Code session from its on-disk record. #[derive(Clone, Debug, PartialEq)] pub struct ExternalSession { pub session_id: String, pub cwd: Option, pub title: Option, + /// The name the user gave it in Claude Code (`/rename`), apart from the generated title in `title`. + pub custom_title: Option, pub created_at: i64, pub last_active: i64, pub model: Option, @@ -680,6 +702,9 @@ pub fn reconcile(data: &mut Data, external: &[ExternalSession], scan_ok: bool) - if let Some(title) = ext.title.as_ref().filter(|t| !t.trim().is_empty()) { rec.title = title.clone(); } + if let Some(name) = adopt_claude_title(rec, ext.custom_title.as_deref()) { + rec.custom_title = Some(name); + } rec.last_active = rec.last_active.max(ext.last_active); if rec.project_id.is_none() && let Some(cwd) = &ext.cwd { @@ -759,6 +784,7 @@ mod tests { session_id: id.into(), cwd: Some(PathBuf::from(cwd)), title: Some(title.into()), + custom_title: None, created_at: 1, last_active: last, model: Some("claude-sonnet-5-5".into()), @@ -876,6 +902,35 @@ mod tests { assert_eq!(d.sessions[1].project_id, None); } + #[test] + fn a_rename_inside_claude_code_renames_the_session_in_claudiu() { + let mut d = Data::default(); + let named = |name: Option<&str>| ExternalSession { custom_title: name.map(Into::into), ..ext("a", "/w", "Generated", 10) }; + reconcile(&mut d, &[named(None)], true); + d.sessions[0].auto_title = Some("Old model title".into()); + reconcile(&mut d, &[named(Some("First /rename"))], true); + assert_eq!(d.sessions[0].display_title(), "First /rename", "the first name of a session Claudiu never named"); + + // Named in Claudiu before Claudiu saw a name in Claude Code: the one Claude Code holds may be older. + d.sessions[0].custom_title = Some("Named in Claudiu".into()); + d.sessions[0].claude.as_mut().unwrap().claude_title = None; + reconcile(&mut d, &[named(Some("Old name"))], true); + assert_eq!(d.sessions[0].display_title(), "Named in Claudiu", "the first name seen is only recorded"); + + reconcile(&mut d, &[named(Some("From /rename"))], true); + assert_eq!(d.sessions[0].display_title(), "From /rename"); + + // Renamed in Claudiu: Claude Code still holds the old name until the mod's /rename reaches it. + d.sessions[0].custom_title = Some("From Claudiu".into()); + reconcile(&mut d, &[named(Some("From /rename"))], true); + assert_eq!(d.sessions[0].display_title(), "From Claudiu", "a rename made in Claudiu is not undone"); + reconcile(&mut d, &[named(None)], true); + assert_eq!(d.sessions[0].display_title(), "From Claudiu", "a generated title never renames it"); + reconcile(&mut d, &[named(Some("From Claudiu"))], true); + reconcile(&mut d, &[named(Some("Again"))], true); + assert_eq!(d.sessions[0].display_title(), "Again"); + } + #[test] fn rerunning_is_idempotent_and_never_duplicates() { let mut d = Data::default(); From 1ebea3ac6f06a4f2af5601ef54a519f379c17b56 Mon Sep 17 00:00:00 2001 From: Savin Angel-Mario Date: Mon, 16 Nov 2026 23:41:19 +0200 Subject: [PATCH 2/3] Keep a quick second rename, agree on each shared key alone, keep login-bound options per account - A rename made in Claudiu is no longer replaced by an older Claudiu name that Claude Code reaches first. Claude Code's name is taken only when Claudiu has none or Claude Code already held Claudiu's. - Whether every account holds a shared key is now decided per key, so a busy account behind on folder trust or another key no longer stops a reset to the default from spreading. - Uploading sessions, remote control at startup, phone push and Claude in Chrome stay per account. --- src/claude/config_sync.rs | 57 ++++++++++++++++++++++++++++----------- src/store.rs | 21 ++++++++++----- 2 files changed, 56 insertions(+), 22 deletions(-) diff --git a/src/claude/config_sync.rs b/src/claude/config_sync.rs index 91224fa..3226feb 100644 --- a/src/claude/config_sync.rs +++ b/src/claude/config_sync.rs @@ -22,8 +22,9 @@ use serde_json::{Map, Value}; const FILES: &[&str] = &["settings.json", "CLAUDE.md", "keybindings.json"]; /// Top-level keys of an account's `.claude.json` that every account shares: the user's MCP servers, and the /// preferences `/config` saves there. The preferences are Claude Code's own list of global config keys (2.1.325), -/// without the sign-in, install details, counters, notices and caches it also holds; Claude Code writes only the ones -/// changed from their defaults, so most are usually absent. +/// without the sign-in, install details, counters, notices and caches it also holds, and without the ones tied to a +/// login: uploading sessions, remote control at startup, phone push and Claude in Chrome. Claude Code writes only the +/// ones changed from their defaults, so most are usually absent. const SHARED_KEYS: &[&str] = &[ "mcpServers", "theme", @@ -46,17 +47,13 @@ const SHARED_KEYS: &[&str] = &[ "showStatusInTerminalTab", "taskCompleteNotifEnabled", "inputNeededNotifEnabled", - "agentPushNotifEnabled", "respectGitignore", - "claudeInChromeDefaultEnabled", "copyFullResponse", "copyOnSelect", "leftArrowOpensAgents", "defaultToAgentsView", "prStatusFooterEnabled", "teammateMode", - "remoteControlAtStartup", - "autoUploadSessions", ]; /// One project's trust in `.claude.json`: once any account trusts a folder, every account does. const TRUST_KEY: &str = "hasTrustDialogAccepted"; @@ -210,8 +207,9 @@ fn sync_claude_json(accounts: &[Account], state: &mut State) -> io::Result<()> { }) .collect(); let mut dirty = vec![false; accounts.len()]; - let mut incomplete = false; + // Each key is agreed on alone, once every account holds it: a busy account behind on one key holds back only that. let mut agreed_now: Vec<(String, u64, Vec)> = vec![]; + let mut needs_write: Vec> = vec![]; for key in SHARED_KEYS { let state_key = format!("json:{key}"); @@ -233,13 +231,15 @@ fn sync_claude_json(accounts: &[Account], state: &mut State) -> io::Result<()> { let Some(winner) = pick(&held, state.agreed.get(&state_key).copied()) else { continue }; let source = held[winner].as_ref().expect("the winner holds a value"); let (print, value) = (source.print, source.value.clone()); + let mut behind = false; + let mut written_to = vec![]; for (i, file) in files.iter_mut().enumerate() { let Some((map, _)) = file else { continue }; if map.get(*key) == value.as_ref() { continue; } if accounts[i].busy { - incomplete = true; + behind = true; continue; } match &value { @@ -247,9 +247,14 @@ fn sync_claude_json(accounts: &[Account], state: &mut State) -> io::Result<()> { None => map.remove(*key), }; dirty[i] = true; + written_to.push(i); + } + if behind { + continue; } let holders = if value.is_some() { (0..files.len()).filter(|i| files[*i].is_some()).collect() } else { vec![] }; agreed_now.push((state_key, print, holders)); + needs_write.push(written_to); } // Trust only grows: a folder any account trusts is trusted everywhere. @@ -269,7 +274,6 @@ fn sync_claude_json(accounts: &[Account], state: &mut State) -> io::Result<()> { continue; } if accounts[i].busy { - incomplete = true; continue; } let Some(projects) = map.entry("projects").or_insert_with(|| Value::Object(Map::new())).as_object_mut() else { continue }; @@ -282,19 +286,21 @@ fn sync_claude_json(accounts: &[Account], state: &mut State) -> io::Result<()> { } let mut result = Ok(()); + let mut failed = vec![false; accounts.len()]; for (i, file) in files.iter().enumerate() { let (true, Some((map, _))) = (dirty[i], file) else { continue }; let text = serde_json::to_string_pretty(map).map_err(io::Error::other); let written = text.and_then(|text| crate::datadir::write_atomic(&accounts[i].claude_json, &text)); - incomplete |= written.is_err(); + failed[i] = written.is_err(); keep(&mut result, written); } - if !incomplete { - for (state_key, print, holders) in agreed_now { - state.agreed.insert(state_key.clone(), print); - state.had.retain(|h| !h.starts_with(&format!("{state_key}|"))); - state.had.extend(holders.into_iter().map(|i| had_key(&state_key, &accounts[i]))); + for ((state_key, print, holders), written_to) in agreed_now.into_iter().zip(needs_write) { + if written_to.iter().any(|i| failed[*i]) { + continue; } + state.agreed.insert(state_key.clone(), print); + state.had.retain(|h| !h.starts_with(&format!("{state_key}|"))); + state.had.extend(holders.into_iter().map(|i| had_key(&state_key, &accounts[i]))); } result } @@ -443,6 +449,27 @@ mod tests { write_at(&s.accounts[0].claude_json, r#"{"oauthAccount":{"email":"main"},"numStartups":1,"autoCompactEnabled":false}"#, 3000); sync(&s.accounts, &s.state).unwrap(); assert!(s.accounts.iter().all(|a| json(a).get("theme").is_none())); + assert!(s.accounts.iter().all(|a| json(a)["autoCompactEnabled"] == false), "the other option stays"); + } + + #[test] + fn an_account_busy_with_another_difference_does_not_hold_back_an_option() { + let mut s = setup(3); + write_at(&s.accounts[0].claude_json, r#"{"projects":{"/p":{"hasTrustDialogAccepted":true}}}"#, 1000); + write_at(&s.accounts[1].claude_json, r#"{"theme":"light"}"#, 1000); + write_at(&s.accounts[2].claude_json, r#"{"theme":"light"}"#, 2000); + s.accounts[1].busy = true; // it lacks the trust and takes nothing while busy, but agrees on the theme + sync(&s.accounts, &s.state).unwrap(); + let json = |a: &Account| serde_json::from_str::(&fs::read_to_string(&a.claude_json).unwrap()).unwrap(); + assert_eq!(json(&s.accounts[0])["theme"], "light"); + + // Back to the default in main while the alt is still busy: the reset spreads, it is not filled back in. + let mut main = json(&s.accounts[0]); + main.as_object_mut().unwrap().remove("theme"); + write_at(&s.accounts[0].claude_json, &main.to_string(), 3000); + sync(&s.accounts, &s.state).unwrap(); + assert!(json(&s.accounts[0]).get("theme").is_none()); + assert!(json(&s.accounts[2]).get("theme").is_none()); } #[test] diff --git a/src/store.rs b/src/store.rs index e7ebfad..be85fa1 100644 --- a/src/store.rs +++ b/src/store.rs @@ -649,17 +649,18 @@ pub fn project_for(projects: &[Project], cwd: &Path) -> Option { /// A name the user gave the session inside Claude Code since the last read, to show in Claudiu too. Records what /// Claude Code holds either way. Only a change counts: Claude Code keeps the old name until a rename made in Claudiu -/// reaches it, and that rename must not be undone meanwhile. The first name seen is taken only when Claudiu has no -/// name of its own; otherwise it is only recorded, since Claudiu can't tell whether it came before or after Claudiu's. +/// reaches it, and that rename must not be undone meanwhile. So a name is taken only when Claudiu has none of its own, +/// or when Claude Code already held Claudiu's name; any other change is Claude Code catching up with an older rename. fn adopt_claude_title(rec: &mut SessionRecord, held: Option<&str>) -> Option { let held = held.map(str::trim).filter(|t| !t.is_empty())?; - let named_in_claudiu = rec.custom_title.is_some(); + let ours = rec.custom_title.clone(); let meta = rec.claude.as_mut()?; - let changed = match meta.claude_title.replace(held.to_string()) { - Some(before) => before != held, - None => !named_in_claudiu, + let before = meta.claude_title.replace(held.to_string()); + let confirmed = match ours { + None => true, + Some(ours) => before.as_deref() == Some(ours.as_str()), }; - changed.then(|| held.to_string()) + (before.as_deref() != Some(held) && confirmed).then(|| held.to_string()) } /// What we learned about one Claude Code session from its on-disk record. @@ -916,6 +917,7 @@ mod tests { d.sessions[0].claude.as_mut().unwrap().claude_title = None; reconcile(&mut d, &[named(Some("Old name"))], true); assert_eq!(d.sessions[0].display_title(), "Named in Claudiu", "the first name seen is only recorded"); + reconcile(&mut d, &[named(Some("Named in Claudiu"))], true); reconcile(&mut d, &[named(Some("From /rename"))], true); assert_eq!(d.sessions[0].display_title(), "From /rename"); @@ -929,6 +931,11 @@ mod tests { reconcile(&mut d, &[named(Some("From Claudiu"))], true); reconcile(&mut d, &[named(Some("Again"))], true); assert_eq!(d.sessions[0].display_title(), "Again"); + + // Renamed twice in Claudiu, quickly: Claude Code reaches the first name while the second is on its way. + d.sessions[0].custom_title = Some("Second".into()); + reconcile(&mut d, &[named(Some("First"))], true); + assert_eq!(d.sessions[0].display_title(), "Second", "Claude Code catching up is not a rename"); } #[test] From 4dca8ca3df5acc80ab641fa9f82252467a435f48 Mon Sep 17 00:00:00 2001 From: Savin Angel-Mario Date: Mon, 16 Nov 2026 23:44:52 +0200 Subject: [PATCH 3/3] Keep following /rename after a Claudiu name with spaces around it Claude Code holds names trimmed, so an exact match never confirmed such a name again and later renames in Claude Code were ignored. --- src/store.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/store.rs b/src/store.rs index be85fa1..f370ba1 100644 --- a/src/store.rs +++ b/src/store.rs @@ -658,7 +658,8 @@ fn adopt_claude_title(rec: &mut SessionRecord, held: Option<&str>) -> Option true, - Some(ours) => before.as_deref() == Some(ours.as_str()), + // Claude Code holds names trimmed; an exact match would never confirm a name with spaces around it again. + Some(ours) => before.as_deref() == Some(ours.trim()), }; (before.as_deref() != Some(held) && confirmed).then(|| held.to_string()) } @@ -936,6 +937,12 @@ mod tests { d.sessions[0].custom_title = Some("Second".into()); reconcile(&mut d, &[named(Some("First"))], true); assert_eq!(d.sessions[0].display_title(), "Second", "Claude Code catching up is not a rename"); + + // Claudiu's name with spaces around it, which Claude Code holds trimmed: later renames still count. + d.sessions[0].custom_title = Some(" Spaced ".into()); + reconcile(&mut d, &[named(Some("Spaced"))], true); + reconcile(&mut d, &[named(Some("Next"))], true); + assert_eq!(d.sessions[0].display_title(), "Next"); } #[test]