Detect tier across WSL roots, not just native home (\\wsl$\<distro>\... probe)

This commit is contained in:
megaproxy 2026-05-09 01:00:50 +01:00
parent ef84257ddd
commit f33bb5481b
3 changed files with 86 additions and 34 deletions

View file

@ -1,9 +1,11 @@
//! Tauri command surface — every JS-callable function lives here.
use std::path::PathBuf;
use crate::paths::{list_wsl_distros, resolve_roots, ResolvedRoots};
use crate::settings::{save as save_settings, Caps, Settings};
use crate::state::SharedState;
use crate::tier::{detect as detect_tier, PlanTier};
use crate::tier::{detect_in as detect_tier_in, PlanTier};
use crate::usage::{build_snapshot, UsageSnapshot};
use crate::watch::refresh_and_emit;
@ -84,8 +86,27 @@ pub struct TierInfo {
}
#[tauri::command]
pub async fn detect_plan_tier() -> Result<TierInfo, String> {
let tier = detect_tier();
pub async fn detect_plan_tier(
state: tauri::State<'_, SharedState>,
) -> Result<TierInfo, String> {
// Each resolved root is a `<base>/.claude/projects` path. The tier
// file lives in the parent (`<base>/.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<PathBuf> = state
.roots
.read()
.iter()
.filter_map(|r| r.parent().map(PathBuf::from))
.collect();
if let Some(home) = dirs::home_dir() {
candidates.push(home.join(".claude"));
}
// Dedupe (canonicalize is unreliable on UNC paths, so compare raw).
candidates.sort();
candidates.dedup();
let tier = detect_tier_in(&candidates);
let label = tier.label();
let recommended_caps = tier.caps();
Ok(TierInfo { tier, label, recommended_caps })