fix(cli): compact gateway command failures

This commit is contained in:
Vincent Koc
2026-05-10 14:30:01 +08:00
parent 14e696100e
commit d7c6b537dd
2 changed files with 5 additions and 1 deletions

View File

@@ -71,6 +71,7 @@ export function formatGatewayCommandFailure(params: {
const raw = params.error instanceof Error ? params.error.message : String(params.error);
const message = raw
.replace(/\s*Run [`"]?openclaw doctor[`"]? for diagnostics\.?/gi, "")
.replace(/\s+Gateway target:\s+.*$/isu, "")
.replace(/\s+/g, " ")
.trim()
.replace(/[.]+$/u, "");

View File

@@ -177,7 +177,9 @@ describe("secrets CLI", () => {
it("explains Gateway reload failures without duplicate doctor noise", async () => {
callGatewayFromCli.mockRejectedValue(
new Error("gateway closed (1006 abnormal closure). Run `openclaw doctor` for diagnostics."),
new Error(
"gateway closed (1006 abnormal closure). Gateway target: ws://127.0.0.1:18789 Source: local loopback Config: /tmp/openclaw.json Bind: loopback Possible causes: - Gateway not yet ready. Run `openclaw doctor` for diagnostics.",
),
);
await expect(
@@ -188,6 +190,7 @@ describe("secrets CLI", () => {
"Could not reload secrets because the Gateway did not respond: gateway closed (1006 abnormal closure).",
);
expect(runtimeErrors.at(-1)).toContain("openclaw gateway status --deep");
expect(runtimeErrors.at(-1)).not.toContain("Gateway target:");
expect(runtimeErrors.at(-1)).not.toContain("diagnostics..");
});