diff --git a/ui/src/ui/storage.node.test.ts b/ui/src/ui/storage.node.test.ts index d620f67938a..5fea37dc0e0 100644 --- a/ui/src/ui/storage.node.test.ts +++ b/ui/src/ui/storage.node.test.ts @@ -76,6 +76,32 @@ describe("loadSettings default gateway URL derivation", () => { expect(loadSettings().gatewayUrl).toBe(expectedGatewayUrl("/apps/openclaw")); }); + it("skips node sessionStorage accessors that warn without a storage file", async () => { + vi.resetModules(); + vi.unstubAllGlobals(); + vi.stubGlobal("localStorage", createStorageMock()); + vi.stubGlobal("navigator", { language: "en-US" } as Navigator); + setTestLocation({ + protocol: "https:", + host: "gateway.example:8443", + pathname: "/", + }); + setControlUiBasePath(undefined); + const warningSpy = vi.spyOn(process, "emitWarning").mockImplementation(() => undefined); + + const { loadSettings } = await import("./storage.ts"); + + expect(loadSettings()).toMatchObject({ + gatewayUrl: expectedGatewayUrl(""), + token: "", + }); + expect(warningSpy).not.toHaveBeenCalledWith( + "`--localstorage-file` was provided without a valid path", + expect.anything(), + expect.anything(), + ); + }); + it("ignores and scrubs legacy persisted tokens", async () => { setTestLocation({ protocol: "https:", diff --git a/ui/src/ui/storage.ts b/ui/src/ui/storage.ts index 2da8532e9f9..61b398c3f66 100644 --- a/ui/src/ui/storage.ts +++ b/ui/src/ui/storage.ts @@ -21,7 +21,7 @@ type PersistedUiSettings = Omit