Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion bin/lib/onboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ async function preflight() {
console.log(" Cleaning up previous NemoClaw session...");
run("openshell forward stop 18789 2>/dev/null || true", { ignoreError: true });
run("openshell gateway destroy -g nemoclaw 2>/dev/null || true", { ignoreError: true });
// Sandboxes under the destroyed gateway no longer exist in OpenShell —
// clear the local registry so `nemoclaw list` stays consistent. (#532)
registry.clearAll();
console.log(" ✓ Previous session cleaned up");
}

Expand Down Expand Up @@ -420,8 +423,9 @@ async function preflight() {
async function startGateway(gpu) {
step(2, 7, "Starting OpenShell gateway");

// Destroy old gateway
// Destroy old gateway — also clear registry since its sandboxes are gone. (#532)
run("openshell gateway destroy -g nemoclaw 2>/dev/null || true", { ignoreError: true });
registry.clearAll();

const gwArgs = ["--name", "nemoclaw"];
// Do NOT pass --gpu here. On DGX Spark (and most GPU hosts), inference is
Expand Down
5 changes: 5 additions & 0 deletions bin/lib/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ function setDefault(name) {
return true;
}

function clearAll() {
save({ sandboxes: {}, defaultSandbox: null });
}

module.exports = {
clearAll,
load,
save,
getSandbox,
Expand Down
25 changes: 25 additions & 0 deletions test/registry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,29 @@ describe("registry", () => {
const { sandboxes } = registry.listSandboxes();
assert.equal(sandboxes.length, 0);
});

it("clearAll removes all sandboxes and resets default", () => {
registry.registerSandbox({ name: "alpha" });
registry.registerSandbox({ name: "beta" });
registry.setDefault("beta");
registry.clearAll();
const { sandboxes, defaultSandbox } = registry.listSandboxes();
assert.equal(sandboxes.length, 0);
assert.equal(defaultSandbox, null);
});

it("clearAll persists empty state to disk", () => {
registry.registerSandbox({ name: "persist-me" });
registry.clearAll();
const data = JSON.parse(fs.readFileSync(regFile, "utf-8"));
assert.deepEqual(data.sandboxes, {});
assert.equal(data.defaultSandbox, null);
});

it("clearAll is safe to call on empty registry", () => {
registry.clearAll();
const { sandboxes, defaultSandbox } = registry.listSandboxes();
assert.equal(sandboxes.length, 0);
assert.equal(defaultSandbox, null);
});
});