From 479d6538dec7e6570a662744e7ffcf96b598e922 Mon Sep 17 00:00:00 2001 From: Onur Guengoeren Date: Tue, 14 Apr 2026 13:17:10 +0200 Subject: [PATCH] fix(sandbox): reset singleton before initialize in session_start When /new fires, session_shutdown calls SandboxManager.reset() on the module-level singleton. The new session's session_start then calls initialize() on the partially-reset singleton, which crashes. Add a guarded SandboxManager.reset() call before initialize() to ensure the singleton is in a clean state regardless of whether session_shutdown ran or not. --- packages/sandbox/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/sandbox/index.ts b/packages/sandbox/index.ts index 2672d3a..e837fcd 100644 --- a/packages/sandbox/index.ts +++ b/packages/sandbox/index.ts @@ -396,6 +396,9 @@ export default function (pi: ExtensionAPI) { : undefined; try { + // Reset any stale state from a previous session (e.g. after /new) + try { await SandboxManager.reset(); } catch {} + await SandboxManager.initialize( { network: activeConfig.network,