Repository navigation
fix(cli): prepare Hermes light terminal skin #6578
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 5 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d14950b
fix(cli): preserve Hermes light terminal hints
chengjiew 7c0fb8c
fix(cli): cover Hermes terminal theme guards
chengjiew 68c9c26
test(cli): avoid branch in Hermes connect test
chengjiew ab1368f
refactor(cli): keep Hermes env helper pure
chengjiew 9a5995b
fix(cli): prepare Hermes light terminal skin
chengjiew ff9e814
merge(cli): sync main into Hermes light skin branch
cv 0581b7a
chore(cli): mark unused connect agent parameter
cv 441d304
fix(cli): manage Hermes light skin lifecycle
prekshivyas 09fcdf5
Merge remote-tracking branch 'origin/main' into fix/6380_hermes_light…
prekshivyas 0ab9ad9
refactor(connect): extract Hermes light skin preparation
prekshivyas 4e3a03f
fix(connect): avoid dark Hermes skin config reads
prekshivyas 082114c
refactor(connect): simplify Hermes light skin flow
prekshivyas bc80b11
fix(connect): clean up managed Hermes light skin
prekshivyas e30ea71
fix(connect): reject invalid Hermes skin values
prekshivyas 3e9db2d
test(connect): cover Hermes skin cleanup failures
prekshivyas ca83661
fix(connect): refresh Hermes light skin boundary
prekshivyas 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
128 changes: 128 additions & 0 deletions
128
src/lib/actions/sandbox/connect-hermes-light-theme.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,128 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { afterEach, beforeEach, describe, expect, it, type MockInstance, vi } from "vitest"; | ||
|
|
||
| import { | ||
| connectModulePath, | ||
| createConnectHarness, | ||
| requireDist, | ||
| } from "../../../../test/support/connect-flow-test-harness"; | ||
|
|
||
| describe("Hermes sandbox connect light terminal skin", () => { | ||
| let exitSpy: MockInstance; | ||
| const originalStdoutIsTty = process.stdout.isTTY; | ||
|
|
||
| beforeEach(() => { | ||
| process.env.NEMOCLAW_TEST_NO_SLEEP = "1"; | ||
| Object.defineProperty(process.stdout, "isTTY", { configurable: true, value: true }); | ||
| exitSpy = vi.spyOn(process, "exit").mockImplementation(((code?: number | string | null) => { | ||
| throw new Error(`process.exit(${code ?? 0})`); | ||
| }) as never); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| vi.restoreAllMocks(); | ||
| vi.unstubAllEnvs(); | ||
| Object.defineProperty(process.stdout, "isTTY", { | ||
| configurable: true, | ||
| value: originalStdoutIsTty, | ||
| }); | ||
| delete process.env.NEMOCLAW_TEST_NO_SLEEP; | ||
| delete require.cache[requireDist.resolve(connectModulePath)]; | ||
| }); | ||
|
|
||
| it("prepares the NemoClaw Hermes light skin inside the sandbox on light macOS Terminal.app (#6380)", async () => { | ||
| vi.stubEnv("TERM_PROGRAM", "Apple_Terminal"); | ||
| vi.stubEnv("COLORFGBG", "0;15"); | ||
| vi.stubEnv("HERMES_TUI_LIGHT", ""); | ||
| const harness = createConnectHarness({ | ||
| agentName: "hermes", | ||
| sessionAgent: { | ||
| name: "hermes", | ||
| runtime: { kind: "terminal", interactive_command: "hermes" }, | ||
| }, | ||
| }); | ||
|
|
||
| await expect(harness.connectSandbox("alpha")).rejects.toThrow("process.exit(0)"); | ||
|
|
||
| expect(harness.captureOpenshellSpy).toHaveBeenCalledWith( | ||
| [ | ||
| "sandbox", | ||
| "exec", | ||
| "--name", | ||
| "alpha", | ||
| "--", | ||
| "sh", | ||
| "-c", | ||
| 'hermes_home="${HERMES_HOME:-/sandbox/.hermes}"; test -f "$hermes_home/config.yaml" && cat "$hermes_home/config.yaml" || true', | ||
| ], | ||
| expect.objectContaining({ ignoreError: true }), | ||
| ); | ||
| const skinWriteCall = harness.runOpenshellSpy.mock.calls.find( | ||
| ([args]) => | ||
| Array.isArray(args) && | ||
| args.slice(0, 6).join(" ") === "sandbox exec --name alpha -- sh" && | ||
| String(args[7] ?? "").includes("nemoclaw-light.yaml"), | ||
| ); | ||
| expect(skinWriteCall?.[0][7]).toContain("/skins/nemoclaw-light.yaml"); | ||
| expect(skinWriteCall?.[0][7]).toContain("config.yaml"); | ||
|
|
||
| const connectCall = harness.spawnSyncSpy.mock.calls.find( | ||
| ([command, args]) => | ||
| command === "openshell" && | ||
| Array.isArray(args) && | ||
| args.join(" ") === "sandbox connect alpha", | ||
| ); | ||
| expect(connectCall?.[2]).toEqual( | ||
| expect.objectContaining({ | ||
| env: expect.objectContaining({ | ||
| COLORFGBG: "0;15", | ||
| TERM_PROGRAM: "Apple_Terminal", | ||
| }), | ||
| }), | ||
| ); | ||
| expect(connectCall?.[2]?.env).not.toEqual(expect.objectContaining({ HERMES_TUI_LIGHT: "1" })); | ||
| expect(exitSpy).toHaveBeenCalledWith(0); | ||
| }); | ||
|
|
||
| it("does not prepare the NemoClaw Hermes light skin when the sandbox Hermes config already sets display.skin (#6380)", async () => { | ||
| vi.stubEnv("TERM_PROGRAM", "Apple_Terminal"); | ||
| vi.stubEnv("COLORFGBG", "0;15"); | ||
| const harness = createConnectHarness({ | ||
| agentName: "hermes", | ||
| sessionAgent: { | ||
| name: "hermes", | ||
| runtime: { kind: "terminal", interactive_command: "hermes" }, | ||
| }, | ||
| }); | ||
| harness.captureOpenshellSpy.mockImplementation((args: unknown) => { | ||
| const argv = Array.isArray(args) ? args : []; | ||
| if ( | ||
| argv[0] === "sandbox" && | ||
| argv[1] === "exec" && | ||
| argv.join(" ").includes("/sandbox/.hermes") | ||
| ) { | ||
| return { status: 0, output: "display:\n skin: solarized-light\n" }; | ||
| } | ||
| if (argv[0] === "sandbox" && argv[1] === "list") { | ||
| return { status: 0, output: "alpha Ready" }; | ||
| } | ||
| if (argv[0] === "inference" && argv[1] === "get") { | ||
| return { status: 0, output: "Provider: unknown\nModel: unknown\n" }; | ||
| } | ||
| return { status: 0, output: "" }; | ||
| }); | ||
|
|
||
| await expect(harness.connectSandbox("alpha")).rejects.toThrow("process.exit(0)"); | ||
|
|
||
| const skinWriteCall = harness.runOpenshellSpy.mock.calls.find( | ||
| ([args]) => | ||
| Array.isArray(args) && | ||
| args.slice(0, 6).join(" ") === "sandbox exec --name alpha -- sh" && | ||
| String(args[7] ?? "").includes("nemoclaw-light.yaml"), | ||
| ); | ||
| expect(skinWriteCall).toBeUndefined(); | ||
| expect(exitSpy).toHaveBeenCalledWith(0); | ||
| }); | ||
| }); |
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,96 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| import { | ||
| buildHermesLightSkinConfig, | ||
| buildSandboxConnectEnv, | ||
| NEMOCLAW_HERMES_LIGHT_SKIN_NAME, | ||
| shouldPrepareHermesLightSkin, | ||
| } from "./connect-env"; | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
|
|
||
| describe("sandbox connect environment helpers", () => { | ||
| it("keeps the connect environment unchanged; Hermes light skin is prepared in sandbox config (#6380)", () => { | ||
| expect( | ||
| buildSandboxConnectEnv( | ||
| { name: "hermes" }, | ||
| { COLORFGBG: "0;15", TERM_PROGRAM: "Apple_Terminal" }, | ||
| ), | ||
| ).toEqual( | ||
| expect.objectContaining({ | ||
| COLORFGBG: "0;15", | ||
| TERM_PROGRAM: "Apple_Terminal", | ||
| }), | ||
| ); | ||
| }); | ||
|
|
||
| it("plans the NemoClaw Hermes light skin only for light terminals without user theme or skin (#6380)", () => { | ||
| expect( | ||
| shouldPrepareHermesLightSkin( | ||
| { name: "hermes" }, | ||
| { COLORFGBG: "0;15", TERM_PROGRAM: "Apple_Terminal" }, | ||
| "model: test\n", | ||
| ), | ||
| ).toBe(true); | ||
| }); | ||
|
|
||
| it("does not plan the NemoClaw Hermes light skin when the terminal is dark (#6380)", () => { | ||
| expect( | ||
| shouldPrepareHermesLightSkin( | ||
| { name: "hermes" }, | ||
| { COLORFGBG: "0;0", TERM_PROGRAM: "Apple_Terminal" }, | ||
| "model: test\n", | ||
| ), | ||
| ).toBe(false); | ||
| }); | ||
|
|
||
| it("does not plan the NemoClaw Hermes light skin when the user set Hermes theme env (#6380)", () => { | ||
| for (const env of [{ HERMES_TUI_LIGHT: "0" }, { HERMES_TUI_THEME: "dark" }]) { | ||
| expect( | ||
| shouldPrepareHermesLightSkin({ name: "hermes" }, { COLORFGBG: "0;15", ...env }, ""), | ||
| ).toBe(false); | ||
| } | ||
| }); | ||
|
|
||
| it("does not plan the NemoClaw Hermes light skin when config already has display.skin (#6380)", () => { | ||
| expect( | ||
| shouldPrepareHermesLightSkin( | ||
| { name: "hermes" }, | ||
| { COLORFGBG: "0;15" }, | ||
| "display:\n skin: solarized-light\n", | ||
| ), | ||
| ).toBe(false); | ||
| }); | ||
|
|
||
| it("does not plan the NemoClaw Hermes light skin for non-Hermes agents (#6380)", () => { | ||
| expect( | ||
| shouldPrepareHermesLightSkin({ name: "openclaw" }, { COLORFGBG: "0;15" }, "model: test\n"), | ||
| ).toBe(false); | ||
| }); | ||
|
|
||
| it("does not infer light mode from Apple Terminal without usable COLORFGBG (#6380)", () => { | ||
| expect( | ||
| shouldPrepareHermesLightSkin({ name: "hermes" }, { TERM_PROGRAM: "Apple_Terminal" }, ""), | ||
| ).toBe(false); | ||
| expect( | ||
| shouldPrepareHermesLightSkin( | ||
| { name: "hermes" }, | ||
| { COLORFGBG: "not-a-color", TERM_PROGRAM: "Apple_Terminal" }, | ||
| "", | ||
| ), | ||
| ).toBe(false); | ||
| }); | ||
|
|
||
| it("adds display.skin to Hermes config without changing existing fields (#6380)", () => { | ||
| expect(buildHermesLightSkinConfig("model: test\n")).toBe( | ||
| `model: test\ndisplay:\n skin: ${NEMOCLAW_HERMES_LIGHT_SKIN_NAME}\n`, | ||
| ); | ||
| }); | ||
|
|
||
| it("does not rewrite Hermes config when display.skin is already explicit (#6380)", () => { | ||
| expect( | ||
| buildHermesLightSkinConfig("display:\n skin: solarized-light\nmodel: test\n"), | ||
| ).toBeNull(); | ||
| }); | ||
| }); | ||
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.