Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
50 changes: 50 additions & 0 deletions src/lib/onboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3303,6 +3303,37 @@ async function promptValidatedSandboxName() {

// ── Step 5: Sandbox ──────────────────────────────────────────────

/**
* Render the configuration summary shown before the destructive sandbox build.
* Extracted from confirmOnboardConfiguration() for direct unit testing — see #2165.
*/
function formatOnboardConfigSummary({
provider,
model,
webSearchConfig,
enabledChannels,
sandboxName,
}) {
const bar = ` ${"─".repeat(50)}`;
const messaging =
Array.isArray(enabledChannels) && enabledChannels.length > 0
? enabledChannels.join(", ")
: "none";
const webSearch = webSearchConfig && webSearchConfig.fetchEnabled === true ? "enabled" : "disabled";
return [
"",
bar,
" Review configuration",
bar,
` Provider: ${provider ?? "(unset)"}`,
` Model: ${model ?? "(unset)"}`,
` Web search: ${webSearch}`,
` Messaging: ${messaging}`,
` Sandbox name: ${sandboxName}`,
bar,
].join("\n");
Comment thread
latenighthackathon marked this conversation as resolved.
Resolved
}

// eslint-disable-next-line complexity
async function createSandbox(
gpu,
Expand All @@ -3322,6 +3353,24 @@ async function createSandbox(
sandboxNameOverride ?? (await promptValidatedSandboxName()),
"sandbox name",
);

// Show a review summary and a Y/n gate before any destructive action
// (docker build, provider creation, credential persistence). Non-interactive
// runs opt out of the gate — they still see the summary for log clarity.
// See #2165.
console.log(formatOnboardConfigSummary({
provider, model, webSearchConfig, enabledChannels, sandboxName,
}));
if (!isNonInteractive() && !dangerouslySkipPermissions) {
const answer = (await promptOrDefault(" Apply this configuration? [Y/n]: ", null, "y"))
.trim()
.toLowerCase();
if (answer === "n" || answer === "no") {
console.log(" Aborted. Re-run `nemoclaw onboard` to start over.");
process.exit(0);
}
}

Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
const effectivePort = agent ? agent.forwardPort : CONTROL_UI_PORT;
const chatUiUrl = process.env.CHAT_UI_URL || `http://127.0.0.1:${effectivePort}`;

Expand Down Expand Up @@ -6834,6 +6883,7 @@ module.exports = {
setupInference,
setupMessagingChannels,
setupNim,
formatOnboardConfigSummary,
isInferenceRouteReady,
isNonInteractive,
isOpenclawReady,
Expand Down
47 changes: 47 additions & 0 deletions test/onboard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5364,4 +5364,51 @@ const { createSandbox } = require(${onboardPath});
"pullAndResolveBaseImageDigest must be called BEFORE patchStagedDockerfile — regression #1904",
);
});

it("formatOnboardConfigSummary renders all collected fields (#2165)", () => {
const repoRoot = path.join(import.meta.dirname, "..");
const onboardPath = path.join(repoRoot, "dist", "lib", "onboard.js");
delete require.cache[onboardPath];
const { formatOnboardConfigSummary } = require(onboardPath);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

const summary = formatOnboardConfigSummary({
provider: "gemini-api",
model: "gemini-2.5-flash",
webSearchConfig: { fetchEnabled: true },
enabledChannels: ["telegram", "slack"],
sandboxName: "my-assistant",
});

assert.ok(summary.includes("Review configuration"), "summary has review heading");
assert.ok(summary.includes("gemini-api"), "summary includes provider");
assert.ok(summary.includes("gemini-2.5-flash"), "summary includes model");
assert.ok(summary.includes("enabled"), "summary includes web-search enabled");
assert.ok(summary.includes("telegram, slack"), "summary lists enabled channels");
assert.ok(summary.includes("my-assistant"), "summary shows sandbox name");

// No messaging, no web search → "none" / "disabled"
const bareSummary = formatOnboardConfigSummary({
provider: "nvidia-prod",
model: "nvidia/nemotron-3-super-120b-a12b",
webSearchConfig: null,
enabledChannels: [],
sandboxName: "test",
});
assert.ok(bareSummary.includes("Messaging: none"), "empty channels renders as 'none'");
assert.ok(
bareSummary.includes("Web search: disabled"),
"null webSearch renders as 'disabled'",
);

// Missing provider/model → "(unset)" placeholder, not "undefined"
const orphanSummary = formatOnboardConfigSummary({
provider: null,
model: null,
webSearchConfig: null,
enabledChannels: null,
sandboxName: "orphan",
});
assert.ok(!orphanSummary.includes("undefined"), "null fields never render as 'undefined'");
assert.ok(orphanSummary.includes("(unset)"), "null fields fall back to '(unset)'");
});
});