Skip to content

Commit 3418fc9

Browse files
committed
fix(sandbox): clear active session after deleting the active sandbox
When the deleted sandbox is the currently active one (tracked via HOTDATA_SANDBOX env var or config.sandbox), clear the cached sandbox session and config pointer so subsequent commands do not keep routing through a stale JWT -- mirrors what sandbox set (no args) already does.
1 parent 6fae6c9 commit 3418fc9

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/sandbox.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,19 @@ pub fn delete(sandbox_id: &str, workspace_id: &str) {
350350
std::process::exit(1);
351351
}
352352

353+
// If the deleted sandbox was the active one, clear the cached session
354+
// and config pointer so subsequent commands don't keep routing through
355+
// a stale sandbox JWT — mirroring what `sandbox set` (no args) does.
356+
let active = std::env::var("HOTDATA_SANDBOX")
357+
.ok()
358+
.or_else(|| config::load("default").ok().and_then(|p| p.sandbox));
359+
if active.as_deref() == Some(sandbox_id) {
360+
sandbox_session::clear();
361+
if let Err(e) = config::clear_sandbox("default") {
362+
eprintln!("warning: could not clear sandbox from config: {e}");
363+
}
364+
}
365+
353366
eprintln!("{}", "Sandbox deleted".green());
354367
}
355368

0 commit comments

Comments
 (0)