Repository navigation
fix(cli): report the dashboard bind a sandbox was created with #10933
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
Closed
Closed
Changes from 4 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
e617b42
fix(cli): report the dashboard bind a sandbox was created with
Dongni-Yang 8602f34
fix(cli): record the bind the forward was started with
Dongni-Yang 7a8ebd1
merge: resolve conflicts with main
github-actions[bot] 07b5d38
fix(cli): record the dashboard bind at every forward launch
Dongni-Yang 0376480
fix(cli): print a usable dashboard URL and record the reused-sandbox …
Dongni-Yang 999a7a2
fix(cli): never start an undisclosed wide dashboard forward
Dongni-Yang f99b1c9
fix(cli): start a dashboard forward only when its record will describ…
Dongni-Yang 5f585dd
fix(onboard): put the bind record back when a reused forward does not…
Dongni-Yang d7e0309
fix(onboard): record a bind before every launch that changes exposure…
Dongni-Yang bafb6ca
fix(onboard): clear or restore a recorded bind whose forward never st…
Dongni-Yang c829cdf
Merge upstream/main into fix/10861-report-actual-dashboard-bind
Dongni-Yang 54e6f60
test(onboard): register the reuse harness's registry write
Dongni-Yang fdb1cce
docs(dashboard): state the host forward bind a remote CHAT_UI_URL cre…
Dongni-Yang fe4625f
docs(hermes): use the literal CLI name on the single-variant quicksta…
Dongni-Yang 57f0591
Merge remote-tracking branch 'upstream/main' into fix/10861-report-ac…
Dongni-Yang 01907ea
docs(dashboard): describe the recovery bind rule and what status repo…
Dongni-Yang 47057b8
fix(dashboard): record the bind where the forward starts (#10861)
Dongni-Yang 86de168
docs(dashboard): make Run Sandboxes the owner of the CHAT_UI_URL guid…
Dongni-Yang 9de4014
Merge upstream/main into fix/10861-report-actual-dashboard-bind
Dongni-Yang 894aaa5
fix(dashboard): record the bind only for the dashboard forward (#10861)
Dongni-Yang a11f5fe
docs(dashboard): describe the bind under the explicit remote-bind opt…
Dongni-Yang b21bd41
docs(dashboard): describe the bind record under the opt-in rule in co…
Dongni-Yang b821212
merge: reconcile dashboard bind reporting with main
rsliter 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
106 changes: 106 additions & 0 deletions
106
src/lib/actions/sandbox/forward-recovery-dashboard-bind-record.test.ts
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,106 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { beforeEach, describe, expect, it, vi } from "vitest"; | ||
|
|
||
| const mocks = vi.hoisted(() => ({ | ||
| captureOpenshell: vi.fn(), | ||
| runOpenshell: vi.fn((_args: string[], _options?: unknown) => ({ status: 0 })), | ||
| getSandbox: vi.fn(), | ||
| updateSandbox: vi.fn(() => true), | ||
| isLocalForwardReachable: vi.fn(() => false), | ||
| launchForwardService: vi.fn(), | ||
| })); | ||
|
|
||
| vi.mock("../../adapters/openshell/forward-service", async (importOriginal) => ({ | ||
| ...(await importOriginal<typeof import("../../adapters/openshell/forward-service")>()), | ||
| launchForwardService: mocks.launchForwardService, | ||
| })); | ||
| vi.mock("../../adapters/openshell/resolve", () => ({ | ||
| resolveOpenshell: () => "/usr/local/bin/openshell", | ||
| })); | ||
| vi.mock("../../adapters/openshell/runtime", () => ({ | ||
| captureOpenshell: mocks.captureOpenshell, | ||
| runOpenshell: mocks.runOpenshell, | ||
| isCommandTimeout: () => false, | ||
| })); | ||
| vi.mock("../../agent/runtime", () => ({ | ||
| getSessionAgent: () => ({ forward_ports: [18789], forwardPort: 18789 }), | ||
| hasGatewayRuntime: () => true, | ||
| })); | ||
| vi.mock("../../state/registry", () => ({ | ||
| getSandbox: mocks.getSandbox, | ||
| updateSandbox: mocks.updateSandbox, | ||
| })); | ||
| vi.mock("./hermes-dashboard-recovery", () => ({ | ||
| getHermesDashboardRecoveryConfig: () => null, | ||
| ensureHermesDashboardPortForwardIfEnabled: vi.fn(() => null), | ||
| })); | ||
| vi.mock("./forward-health", async (importOriginal) => ({ | ||
| ...(await importOriginal<typeof import("./forward-health")>()), | ||
| isLocalForwardReachable: mocks.isLocalForwardReachable, | ||
| })); | ||
|
|
||
| import { ensureSandboxPortForward, ensureSandboxPortForwardForPort } from "./forward-recovery"; | ||
|
|
||
| const SANDBOX = { name: "hm", agent: "hermes", dashboardPort: 18789 }; | ||
|
|
||
| beforeEach(() => { | ||
| vi.clearAllMocks(); | ||
| vi.unstubAllEnvs(); | ||
| mocks.runOpenshell.mockReturnValue({ status: 0 }); | ||
| // An empty forward list for the legacy-migration probe that runs before a | ||
| // launch; `clearAllMocks` keeps return values, so set it for every test. | ||
| mocks.captureOpenshell.mockReturnValue({ status: 0, output: "SANDBOX BIND PORT PID STATUS" }); | ||
| mocks.updateSandbox.mockReturnValue(true); | ||
| mocks.getSandbox.mockReturnValue(SANDBOX); | ||
| // Not reachable until the launch runs, so every test below exercises the | ||
| // path that actually creates a forward. | ||
| mocks.isLocalForwardReachable.mockReturnValue(false); | ||
| mocks.launchForwardService.mockImplementation(() => { | ||
| mocks.isLocalForwardReachable.mockReturnValue(true); | ||
| }); | ||
| }); | ||
|
|
||
| describe("the recorded dashboard bind follows the forward (#10861)", () => { | ||
| it("records the loopback bind when recovery re-creates the forward without an opt-in", () => { | ||
| expect(ensureSandboxPortForward("hm", { isWsl: false })).toBe(true); | ||
|
|
||
| expect(mocks.launchForwardService).toHaveBeenCalledOnce(); | ||
| expect(mocks.updateSandbox).toHaveBeenCalledWith("hm", { dashboardBindAddress: "127.0.0.1" }); | ||
| }); | ||
|
|
||
| it("records the wide bind when the operator opted in and the sandbox was prepared for it", () => { | ||
| vi.stubEnv("NEMOCLAW_DASHBOARD_BIND", "0.0.0.0"); | ||
| mocks.getSandbox.mockReturnValue({ ...SANDBOX, dashboardRemoteBindPrepared: true }); | ||
|
|
||
| expect(ensureSandboxPortForward("hm", { isWsl: false })).toBe(true); | ||
|
|
||
| expect(mocks.updateSandbox).toHaveBeenCalledWith("hm", { dashboardBindAddress: "0.0.0.0" }); | ||
| }); | ||
|
|
||
| it("leaves the record alone when the forward is already reachable", () => { | ||
| mocks.isLocalForwardReachable.mockReturnValue(true); | ||
|
|
||
| expect(ensureSandboxPortForward("hm", { isWsl: false })).toBe(true); | ||
|
|
||
| expect(mocks.launchForwardService).not.toHaveBeenCalled(); | ||
| expect(mocks.updateSandbox).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it("does not record a bind for a forward that is not the dashboard's", () => { | ||
| expect(ensureSandboxPortForwardForPort("hm", 8642, { expectedBind: "127.0.0.1" })).toBe(true); | ||
|
|
||
| expect(mocks.launchForwardService).toHaveBeenCalledOnce(); | ||
| expect(mocks.updateSandbox).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it("keeps the forward up and warns when the record cannot be written", () => { | ||
| const stderr = vi.spyOn(console, "error").mockImplementation(() => undefined); | ||
| mocks.updateSandbox.mockReturnValue(false); | ||
|
|
||
| expect(ensureSandboxPortForward("hm", { isWsl: false })).toBe(true); | ||
|
|
||
| expect(stderr).toHaveBeenCalledWith(expect.stringContaining("could not be recorded")); | ||
| }); | ||
| }); | ||
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
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
Oops, something went wrong.
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.