diff --git a/src/bin/claude-statusline.rs b/src/bin/claude-statusline.rs index 1cf2658..3be7f0e 100644 --- a/src/bin/claude-statusline.rs +++ b/src/bin/claude-statusline.rs @@ -229,6 +229,7 @@ fn main() { vcs_type, project_dir, &session, + &config_hash, &ctx, ); return; @@ -404,6 +405,7 @@ fn dump_state_output( vcs: section::VcsType, project_dir: &str, session_id: &str, + config_hash: &str, ctx: &RenderContext, ) { // Render all sections with per-section timing @@ -468,7 +470,10 @@ fn dump_state_output( "cache": cache_diags, "paths": { "project_dir": project_dir, - "cache_dir": config.global.cache_dir.replace("{session_id}", session_id), + "cache_dir": config.global.cache_dir + .replace("{session_id}", session_id) + .replace("{cache_version}", &config.global.cache_version.to_string()) + .replace("{config_hash}", config_hash), }, "session_id": session_id, }); diff --git a/src/cache.rs b/src/cache.rs index fa9325b..0b08413 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -95,8 +95,20 @@ impl Cache { return None; } }; - let modified = meta.modified().ok()?; - let age = SystemTime::now().duration_since(modified).ok()?; + let modified = match meta.modified().ok() { + Some(m) => m, + None => { + self.record_diag(key, false, None); + return None; + } + }; + let age = match SystemTime::now().duration_since(modified).ok() { + Some(a) => a, + None => { + self.record_diag(key, false, None); + return None; + } + }; let age_ms = age.as_millis() as u64; let effective_ttl = self.jittered_ttl(key, ttl); if age < effective_ttl { diff --git a/src/config.rs b/src/config.rs index f2ba0d1..4b5350b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -69,7 +69,6 @@ pub struct GlobalConfig { pub shell_env: HashMap, pub cache_version: u32, pub drop_strategy: String, - pub breakpoint_hysteresis: u16, } impl Default for GlobalConfig { @@ -80,7 +79,7 @@ impl Default for GlobalConfig { vcs: "auto".into(), width: None, width_margin: 4, - cache_dir: "/tmp/claude-sl-{session_id}".into(), + cache_dir: "/tmp/claude-sl-{session_id}-{cache_version}-{config_hash}".into(), cache_gc_days: 7, cache_gc_interval_hours: 24, cache_ttl_jitter_pct: 10, @@ -100,7 +99,6 @@ impl Default for GlobalConfig { shell_env: HashMap::new(), cache_version: 1, drop_strategy: "tiered".into(), - breakpoint_hysteresis: 2, } } } diff --git a/src/section/vcs.rs b/src/section/vcs.rs index d1bc528..0e23081 100644 --- a/src/section/vcs.rs +++ b/src/section/vcs.rs @@ -30,7 +30,13 @@ pub fn render(ctx: &RenderContext) -> Option { /// Serve stale cached VCS data without running any commands. fn render_stale_cache(ctx: &RenderContext) -> Option { - let branch = ctx.cache.get_stale("vcs_branch")?; + let branch_raw = ctx.cache.get_stale("vcs_branch")?; + let trunc = &ctx.config.sections.vcs.truncate; + let branch = if trunc.enabled && trunc.max > 0 { + crate::format::truncate(&branch_raw, trunc.max, &trunc.style) + } else { + branch_raw + }; let branch_glyph = glyph::glyph("branch", &ctx.config.glyphs); let raw = format!("{branch_glyph}{branch}"); let ansi = if ctx.color_enabled { @@ -164,28 +170,23 @@ fn render_jj( let branch_ttl = Duration::from_secs(ttl.branch); let branch = ctx.cache.get("vcs_branch", branch_ttl).or_else(|| { - // Use prefetched result if available - let out = ctx - .shell_results - .get("vcs") - .cloned() - .flatten() - .or_else(|| { - shell::exec_gated( - ctx.shell_config, - "jj", - &[ - "log", - "-r", - "@", - "--no-graph", - "-T", - "if(bookmarks, bookmarks.join(\",\"), change_id.shortest(8))", - "--color=never", - ], - Some(dir), - ) - })?; + // Use prefetched result if available, otherwise exec + let out = ctx.shell_results.get("vcs").cloned().unwrap_or_else(|| { + shell::exec_gated( + ctx.shell_config, + "jj", + &[ + "log", + "-r", + "@", + "--no-graph", + "-T", + "if(bookmarks, bookmarks.join(\",\"), change_id.shortest(8))", + "--color=never", + ], + Some(dir), + ) + })?; ctx.cache.set("vcs_branch", &out); Some(out) })?;