Repository navigation
fix(onboard): verify the persisted dashboard port when resume skips sandbox creation #8983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
3ed5651
fix(onboard): verify the persisted dashboard port when resume skips s…
Dongni-Yang 3ba493c
fix(onboard): apply documentation writer wording review
Dongni-Yang 6117bf4
merge: resolve conflicts with main
github-actions[bot] 3a84b55
test(onboard): use an ESM import for createOnboardDashboardHelpers
Dongni-Yang 38b839d
Merge remote-tracking branch 'upstream/fix/8970-reonboard-stale-dashb…
Dongni-Yang 217038f
fix(onboard): fail instead of reallocating the persisted dashboard port
Dongni-Yang af708bb
Merge branch 'main' into fix/8970-reonboard-stale-dashboard-port
rsliter 536c34c
Merge branch 'main' into fix/8970-reonboard-stale-dashboard-port
rsliter 91ef1a5
Merge branch 'main' into fix/8970-reonboard-stale-dashboard-port
rsliter 938846a
Merge branch 'main' into fix/8970-reonboard-stale-dashboard-port
rsliter c400e7f
chore(ci): lower onboarding source budget
rsliter de4c0b1
Merge branch 'main' into fix/8970-reonboard-stale-dashboard-port
rsliter c0a76d2
Merge branch 'main' into fix/8970-reonboard-stale-dashboard-port
rsliter 6ba418d
fix(test): preserve explicit WSL overrides
prekshivyas b370faa
fix(hermes): admit the managed API port
prekshivyas ccf67d3
test(onboard): use valid replacement identity
prekshivyas bab22f9
Merge remote-tracking branch 'origin/main' into fix/pr8983-conflict
prekshivyas 2cf591f
merge: sync main into dashboard port verification
cv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,167 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { describe, expect, it, vi } from "vitest"; | ||
| import { GATEWAY_PORT } from "../src/lib/core/ports"; | ||
| import type { OnboardDashboardDeps, OnboardDashboardHelpers } from "../src/lib/onboard/dashboard"; | ||
| import type { ListSandboxesFn } from "../src/lib/onboard/dashboard-port"; | ||
|
|
||
| const { createOnboardDashboardHelpers } = require("../src/lib/onboard/dashboard") as { | ||
| createOnboardDashboardHelpers: (deps: OnboardDashboardDeps) => OnboardDashboardHelpers; | ||
| }; | ||
|
|
||
| function createFinalizationForwardHarness(options: { | ||
| forwardList: string; | ||
| listSandboxes: ListSandboxesFn; | ||
| }) { | ||
| const runOpenshell = vi.fn((_args: string[], _opts?: Record<string, unknown>) => ({ | ||
| status: 0, | ||
| })); | ||
| const runCaptureOpenshell = vi.fn((args: string[], _opts?: Record<string, unknown>) => | ||
| args.join(" ") === "forward list" ? options.forwardList : "", | ||
| ); | ||
| const openshellArgv = vi.fn((args: string[]) => [process.execPath, "-e", "", ...args]); | ||
| const helpers = createOnboardDashboardHelpers({ | ||
| runOpenshell, | ||
| runCaptureOpenshell, | ||
| openshellArgv, | ||
| cliName: () => "nemoclaw", | ||
| agentProductName: () => "NemoClaw", | ||
| getProviderLabel: (provider: string) => provider, | ||
| note: vi.fn(), | ||
| isWsl: () => false, | ||
| redact: (value: unknown) => String(value), | ||
| sleep: vi.fn(), | ||
| printAgentDashboardUi: vi.fn(), | ||
| listSandboxes: options.listSandboxes, | ||
| }); | ||
| return { helpers, runOpenshell, openshellArgv }; | ||
| } | ||
|
|
||
| describe("finalization dashboard forward", () => { | ||
| it("prefers the persisted registry port over the default dashboard port when CHAT_UI_URL is unset (#8970)", () => { | ||
| vi.stubEnv("CHAT_UI_URL", undefined); | ||
| const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => undefined); | ||
| const { helpers, openshellArgv } = createFinalizationForwardHarness({ | ||
| forwardList: | ||
| "SANDBOX BIND PORT PID STATUS\n" + | ||
| "baseline 127.0.0.1 18789 42000 running\n" + | ||
| "reonboard-test 127.0.0.1 18790 42001 running", | ||
| listSandboxes: () => ({ | ||
| sandboxes: [ | ||
| { name: "baseline", dashboardPort: 18789 }, | ||
| { name: "reonboard-test", dashboardPort: 18790 }, | ||
| ], | ||
| }), | ||
| }); | ||
|
|
||
| try { | ||
| expect(helpers.ensureFinalizationDashboardForward("reonboard-test")).toBe(18790); | ||
| const warnings = warnSpy.mock.calls.map(([line]) => String(line)).join("\n"); | ||
| expect(warnings).not.toContain("is taken"); | ||
| const startCalls = openshellArgv.mock.calls | ||
| .map(([args]) => args.join(" ")) | ||
| .filter((line) => line.startsWith("forward start")); | ||
| expect(startCalls).toContainEqual("forward start --background 18790 reonboard-test"); | ||
| } finally { | ||
| warnSpy.mockRestore(); | ||
| } | ||
| }); | ||
|
|
||
| it("publishes the established forward port back to CHAT_UI_URL (#8970)", () => { | ||
| vi.stubEnv("CHAT_UI_URL", undefined); | ||
| const { helpers } = createFinalizationForwardHarness({ | ||
| forwardList: | ||
| "SANDBOX BIND PORT PID STATUS\n" + "reonboard-test 127.0.0.1 18790 42001 running", | ||
| listSandboxes: () => ({ | ||
| sandboxes: [ | ||
| { name: "reonboard-test", dashboardPort: 18790, scopeGatewayPort: GATEWAY_PORT }, | ||
| ], | ||
| }), | ||
| }); | ||
|
|
||
| expect(helpers.ensureFinalizationDashboardForward("reonboard-test")).toBe(18790); | ||
| expect(process.env.CHAT_UI_URL).toBe("http://127.0.0.1:18790"); | ||
| }); | ||
|
|
||
| it("publishes the reallocated port when another sandbox holds the persisted port (#8970)", () => { | ||
| vi.stubEnv("CHAT_UI_URL", undefined); | ||
| const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => undefined); | ||
| const { helpers } = createFinalizationForwardHarness({ | ||
| forwardList: | ||
| "SANDBOX BIND PORT PID STATUS\n" + | ||
| "baseline 127.0.0.1 18789 42000 running\n" + | ||
| "other-sandbox 127.0.0.1 18790 42002 running\n" + | ||
| "reonboard-test 127.0.0.1 18791 42001 running", | ||
| listSandboxes: () => ({ | ||
| sandboxes: [ | ||
| { name: "baseline", dashboardPort: 18789 }, | ||
| { name: "other-sandbox", dashboardPort: 18790 }, | ||
| { name: "reonboard-test", dashboardPort: 18790 }, | ||
| ], | ||
| }), | ||
| }); | ||
|
|
||
| try { | ||
| expect(helpers.ensureFinalizationDashboardForward("reonboard-test")).toBe(18791); | ||
| expect(process.env.CHAT_UI_URL).toBe("http://127.0.0.1:18791"); | ||
| const warnings = warnSpy.mock.calls.map(([line]) => String(line)).join("\n"); | ||
| expect(warnings).toContain("Port 18790 is taken. Using port 18791 instead."); | ||
| } finally { | ||
| warnSpy.mockRestore(); | ||
| } | ||
| }); | ||
|
|
||
| it("falls back to the default dashboard port when no port is persisted (#8970)", () => { | ||
| vi.stubEnv("CHAT_UI_URL", undefined); | ||
| const { helpers } = createFinalizationForwardHarness({ | ||
| forwardList: "SANDBOX BIND PORT PID STATUS\n" + "my-sandbox 127.0.0.1 18789 42001 running", | ||
| listSandboxes: () => ({ sandboxes: [] }), | ||
| }); | ||
|
|
||
| expect(helpers.ensureFinalizationDashboardForward("my-sandbox")).toBe(18789); | ||
| expect(process.env.CHAT_UI_URL).toBe("http://127.0.0.1:18789"); | ||
| }); | ||
|
|
||
| it("honors an explicit CHAT_UI_URL override over the persisted port (#8970)", () => { | ||
| vi.stubEnv("CHAT_UI_URL", "http://127.0.0.1:19005"); | ||
| const { helpers } = createFinalizationForwardHarness({ | ||
| forwardList: | ||
| "SANDBOX BIND PORT PID STATUS\n" + "reonboard-test 127.0.0.1 19005 42001 running", | ||
| listSandboxes: () => ({ | ||
| sandboxes: [{ name: "reonboard-test", dashboardPort: 18790 }], | ||
| }), | ||
| }); | ||
|
|
||
| expect(helpers.ensureFinalizationDashboardForward("reonboard-test")).toBe(19005); | ||
| expect(process.env.CHAT_UI_URL).toBe("http://127.0.0.1:19005"); | ||
| }); | ||
|
|
||
| it("ignores a dashboard port persisted for another gateway scope (#8970)", () => { | ||
| vi.stubEnv("CHAT_UI_URL", undefined); | ||
| const { helpers } = createFinalizationForwardHarness({ | ||
| forwardList: | ||
| "SANDBOX BIND PORT PID STATUS\n" + "reonboard-test 127.0.0.1 18789 42001 running", | ||
| listSandboxes: () => ({ | ||
| sandboxes: [{ name: "reonboard-test", dashboardPort: 18790, scopeGatewayPort: 9999 }], | ||
| }), | ||
| }); | ||
|
|
||
| expect(helpers.ensureFinalizationDashboardForward("reonboard-test")).toBe(18789); | ||
| expect(process.env.CHAT_UI_URL).toBe("http://127.0.0.1:18789"); | ||
| }); | ||
|
|
||
| it("ignores a zero persisted dashboard port and uses the default dashboard port (#8970)", () => { | ||
| vi.stubEnv("CHAT_UI_URL", undefined); | ||
| const { helpers } = createFinalizationForwardHarness({ | ||
| forwardList: | ||
| "SANDBOX BIND PORT PID STATUS\n" + "reonboard-test 127.0.0.1 18789 42001 running", | ||
| listSandboxes: () => ({ | ||
| sandboxes: [{ name: "reonboard-test", dashboardPort: 0 }], | ||
| }), | ||
| }); | ||
|
|
||
| expect(helpers.ensureFinalizationDashboardForward("reonboard-test")).toBe(18789); | ||
| expect(process.env.CHAT_UI_URL).toBe("http://127.0.0.1:18789"); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.