Skip to content

Commit f6d0f71

Browse files
committed
fix(dashboard): name URL fragment key and suppress redundant --no-open hint
1 parent a6cbce9 commit f6d0f71

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

src/commands/dashboard.links.test.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ describe("dashboardCommand", () => {
183183

184184
// UX: user must be pointed to where their token lives so they can self-recover.
185185
expect(allLogs).toMatch(/OPENCLAW_GATEWAY_TOKEN/);
186+
// UX: hint must name the URL fragment key so the user knows the syntax.
187+
expect(allLogs).toContain("key `token`");
186188
});
187189

188190
it("respects --no-open and tells user token URL is in clipboard", async () => {
@@ -198,12 +200,25 @@ describe("dashboardCommand", () => {
198200
);
199201
});
200202

201-
it("respects --no-open with plain URL hint when clipboard fails", async () => {
203+
it("respects --no-open and falls through to manual-auth hint when clipboard fails (token configured)", async () => {
202204
mockSnapshot("abc");
203205
copyToClipboardMock.mockResolvedValue(false);
204206

205207
await dashboardCommand(runtime, { noOpen: true });
206208

209+
// Redundant fallback hint is suppressed when the manual-auth hint speaks.
210+
expect(runtime.log).not.toHaveBeenCalledWith(
211+
"Browser launch disabled (--no-open). Use the URL above.",
212+
);
213+
expect(runtime.log).toHaveBeenCalledWith(expect.stringContaining("OPENCLAW_GATEWAY_TOKEN"));
214+
});
215+
216+
it("respects --no-open with plain URL hint when clipboard fails and no token is configured", async () => {
217+
mockSnapshot("");
218+
copyToClipboardMock.mockResolvedValue(false);
219+
220+
await dashboardCommand(runtime, { noOpen: true });
221+
207222
expect(runtime.log).toHaveBeenCalledWith(
208223
"Browser launch disabled (--no-open). Use the URL above.",
209224
);

src/commands/dashboard.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,18 @@ export async function dashboardCommand(
8686
: "Browser launch disabled (--no-open). Use the URL above.";
8787
}
8888

89+
const fallbackToManualAuth = !copied && !opened && includeTokenInUrl;
90+
const suppressNoOpenHint = options.noOpen === true && fallbackToManualAuth;
91+
8992
if (opened) {
9093
runtime.log("Opened in your browser. Keep that tab to control OpenClaw.");
91-
} else if (hint) {
94+
} else if (hint && !suppressNoOpenHint) {
9295
runtime.log(hint);
9396
}
9497

95-
if (!copied && !opened && includeTokenInUrl) {
98+
if (fallbackToManualAuth) {
9699
runtime.log(
97-
"Token auto-auth not delivered. Append your gateway token (from OPENCLAW_GATEWAY_TOKEN or gateway.auth.token) as a URL fragment to authenticate.",
100+
"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.",
98101
);
99102
}
100103
}

0 commit comments

Comments
 (0)