diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index 270c6bf..6efe312 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -83,19 +83,24 @@ pub struct TierInfo { /// The caps that this tier maps to. The user's current Settings may /// differ if they tuned manually. pub recommended_caps: Caps, + /// Diagnostic: the candidate `.claude/` directories that were probed. + /// Useful for users on novel setups (multi-distro, custom $HOME, etc.). + pub searched: Vec, } #[tauri::command] pub async fn detect_plan_tier( state: tauri::State<'_, SharedState>, ) -> Result { - // Each resolved root is a `/.claude/projects` path. The tier - // file lives in the parent (`/.claude/`) — so check those, plus - // the native home as a fallback, so this works whether Claude Code - // runs in WSL (UNC paths) or natively. - let mut candidates: Vec = state + // Resolve roots fresh — `state.roots` may be empty if this command is + // invoked before the cold-start refresh finishes (which IS what happens + // when the user opens Settings shortly after launch). + let s = state.settings.read().clone(); + let resolved = + resolve_roots(s.wsl_distro_override.as_deref(), s.include_native); + + let mut candidates: Vec = resolved .roots - .read() .iter() .filter_map(|r| r.parent().map(PathBuf::from)) .collect(); @@ -109,5 +114,9 @@ pub async fn detect_plan_tier( let tier = detect_tier_in(&candidates); let label = tier.label(); let recommended_caps = tier.caps(); - Ok(TierInfo { tier, label, recommended_caps }) + Ok(TierInfo { tier, label, recommended_caps, searched: paths_to_strings(&candidates) }) +} + +fn paths_to_strings(paths: &[PathBuf]) -> Vec { + paths.iter().map(|p| p.display().to_string()).collect() } diff --git a/src-tauri/src/tier.rs b/src-tauri/src/tier.rs index c88288a..fe7c8c2 100644 --- a/src-tauri/src/tier.rs +++ b/src-tauri/src/tier.rs @@ -131,6 +131,7 @@ pub fn detect_in(claude_dirs: &[PathBuf]) -> PlanTier { /// Native-only fallback path. Most callers should prefer `detect_in` with /// the resolved-roots' parents so the WSL case works. +#[allow(dead_code)] pub fn detect() -> PlanTier { let Some(home) = dirs::home_dir() else { return PlanTier::NotFound; diff --git a/src/components/Settings.svelte b/src/components/Settings.svelte index 30fd69d..a961efa 100644 --- a/src/components/Settings.svelte +++ b/src/components/Settings.svelte @@ -93,6 +93,14 @@ Approximate — Anthropic doesn't publish exact caps. Tune below once you actually hit a limit. + {#if tier.label.startsWith("Unknown") && tier.searched.length > 0} +
+ Searched paths +
    + {#each tier.searched as p (p)}
  • {p}
  • {/each} +
+
+ {/if} {/if} @@ -194,6 +202,9 @@ gap: 4px; } .hint { font-size: 10px; line-height: 1.3; } + details summary { cursor: pointer; font-size: 10px; } + ul.paths { margin: 4px 0 0; padding-left: 14px; max-height: 70px; overflow: auto; } + ul.paths code { font-size: 10px; word-break: break-all; } .error { background: rgba(255, 107, 107, 0.15); border: 1px solid var(--danger); diff --git a/src/types.ts b/src/types.ts index af093b0..d05b2bf 100644 --- a/src/types.ts +++ b/src/types.ts @@ -67,4 +67,5 @@ export interface TierInfo { tier: unknown; label: string; recommended_caps: Caps; + searched: string[]; }