Skip to content

Commit a96a41a

Browse files
fix: preserve headless dashboard recovery
1 parent 5690d84 commit a96a41a

5 files changed

Lines changed: 29 additions & 10 deletions

File tree

‎docs/cli/dashboard.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ Notes:
5151
one-time `browserUrl`, never the shared token. SecretRef-managed shared tokens therefore do not leak
5252
into terminal output, clipboard history, or browser-launch arguments.
5353
- If clipboard/browser delivery fails for a token-authenticated URL, the command logs a safe manual-auth hint naming `OPENCLAW_GATEWAY_TOKEN`, `gateway.auth.token`, and the URL fragment key `token`, without printing the token value.
54+
- If the shared token cannot be placed in a URL and clipboard/browser delivery fails, run
55+
`openclaw dashboard --json` and open its short-lived `browserUrl` within ten minutes.
5456

5557
## Related
5658

‎docs/web/dashboard.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ The Control UI is an **admin surface** (chat, config, exec approvals). Do not ex
3636
- After onboarding, the CLI auto-opens the dashboard and prints a clean link.
3737
- Re-open or repair a browser anytime: `openclaw dashboard`. It copies/opens a single-use pairing link
3838
that replaces stale browser credentials without granting blanket remote auto-approval.
39-
- If clipboard and browser delivery both fail, `openclaw dashboard` still prints the clean URL and tells you to append your token (from `OPENCLAW_GATEWAY_TOKEN` or `gateway.auth.token`) as the URL fragment key `token`; it never prints the token value in logs.
39+
- If clipboard and browser delivery both fail, `openclaw dashboard` either gives a safe manual-token
40+
hint or tells you to run `openclaw dashboard --json` and open its short-lived `browserUrl`; it never
41+
prints the shared token value in interactive logs.
4042
- If the UI prompts for shared-secret auth, paste the configured token or password into Control UI settings.
4143

4244
## Auth basics (local vs remote)

‎src/cli/qr-dashboard.integration.test.ts‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,10 @@ describe("cli integration: qr + dashboard token SecretRef", () => {
165165
const joined = runtimeLogs.join("\n");
166166
expect(joined).toContain("Dashboard URL: http://127.0.0.1:18789/");
167167
expect(joined).not.toContain("#token=");
168-
expect(joined).toContain(
169-
"Token auto-auth is disabled for SecretRef-managed gateway.auth.token",
170-
);
168+
expect(joined).toContain("One-time pairing URL not delivered");
169+
expect(joined).toContain("openclaw dashboard --json");
170+
expect(joined).toContain("browserUrl");
171+
expect(joined).not.toContain("Token auto-auth is disabled");
171172
expect(joined).not.toContain("Token auto-auth unavailable");
172173
expect(runtimeErrors).toStrictEqual([]);
173174
});
@@ -193,8 +194,12 @@ describe("cli integration: qr + dashboard token SecretRef", () => {
193194
const joined = runtimeLogs.join("\n");
194195
expect(joined).toContain("Dashboard URL: http://127.0.0.1:18789/");
195196
expect(joined).not.toContain("#token=");
196-
expect(joined).toContain("Token auto-auth unavailable");
197-
expect(joined).toContain("Set OPENCLAW_GATEWAY_TOKEN");
197+
expect(joined).toContain("One-time pairing URL not delivered");
198+
expect(joined).toContain("openclaw dashboard --json");
199+
expect(joined).toContain("browserUrl");
200+
expect(joined).not.toContain("Token auto-auth unavailable");
201+
expect(joined).not.toContain("Set OPENCLAW_GATEWAY_TOKEN");
202+
expect(runtimeErrors).toStrictEqual([]);
198203
});
199204

200205
afterAll(() => {

‎src/commands/dashboard.links.test.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,18 @@ describe("dashboardCommand", () => {
287287
expectLogWith("OPENCLAW_GATEWAY_TOKEN");
288288
});
289289

290-
it("respects --no-open with plain URL hint when clipboard fails and no token is configured", async () => {
290+
it("guides no-token users to the explicit JSON handoff when clipboard delivery fails", async () => {
291291
mockSnapshot("");
292292
copyToClipboardMock.mockResolvedValue(false);
293293

294294
await dashboardCommand(runtime, { noOpen: true });
295295

296-
expect(runtime.log).toHaveBeenCalledWith(
296+
expect(runtime.log).not.toHaveBeenCalledWith(
297297
"Browser launch disabled (--no-open). Use the URL above.",
298298
);
299+
expect(runtime.log).toHaveBeenCalledWith(
300+
"One-time pairing URL not delivered. Run `openclaw dashboard --json` and open its `browserUrl` within ten minutes.",
301+
);
299302
});
300303

301304
it("uses browser bootstrap when the shared-token SecretRef is unresolved", async () => {

‎src/commands/dashboard.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,11 @@ export async function dashboardCommand(
322322
: "Browser launch disabled (--no-open). Use the URL above.";
323323
}
324324

325-
const fallbackToManualAuth = !copied && !opened && includeTokenInUrl;
326-
const suppressNoOpenHint = options.noOpen === true && fallbackToManualAuth;
325+
const handoffDeliveryFailed = !copied && !opened;
326+
const fallbackToManualAuth = handoffDeliveryFailed && includeTokenInUrl;
327+
const fallbackToJsonHandoff = handoffDeliveryFailed && !includeTokenInUrl;
328+
const suppressNoOpenHint =
329+
options.noOpen === true && (fallbackToManualAuth || fallbackToJsonHandoff);
327330

328331
if (opened) {
329332
runtime.log("Opened in your browser. Keep that tab to control OpenClaw.");
@@ -335,5 +338,9 @@ export async function dashboardCommand(
335338
runtime.log(
336339
"Token auto-auth not delivered. Append your gateway token (from OPENCLAW_GATEWAY_TOKEN or gateway.auth.token) as a URL fragment with key `token` to authenticate.",
337340
);
341+
} else if (fallbackToJsonHandoff) {
342+
runtime.log(
343+
"One-time pairing URL not delivered. Run `openclaw dashboard --json` and open its `browserUrl` within ten minutes.",
344+
);
338345
}
339346
}

0 commit comments

Comments
 (0)