Skip to content

Commit 9b6bda6

Browse files
authored
fix(channels): make status --channel all show every channel (#118124)
Normalize the CLI-only `all` sentinel into the existing unfiltered channel-status request for both Gateway and config-only fallback paths.
1 parent 82f7330 commit 9b6bda6

3 files changed

Lines changed: 26 additions & 7 deletions

File tree

‎src/cli/channels-status-cold-imports.test.ts‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,31 @@ describe("routed channels status cold imports", () => {
5555
vi.clearAllMocks();
5656
});
5757

58-
it("keeps successful JSON routes out of config/plugin runtimes with and without probing", async () => {
58+
it("keeps successful all-channel JSON routes cold with and without probing", async () => {
5959
for (const probe of [false, true]) {
6060
vi.clearAllMocks();
61-
const argv = ["node", "openclaw", "channels", "status", "--json"];
61+
const timeoutMs = probe ? 30000 : 10000;
62+
const argv = [
63+
"node",
64+
"openclaw",
65+
"channels",
66+
"status",
67+
"--json",
68+
"--channel",
69+
probe ? " ALL " : "all",
70+
];
6271
if (probe) {
6372
argv.push("--probe");
6473
}
6574

6675
await expect(tryRouteCli(argv)).resolves.toBe(true);
6776

6877
expect(callGatewayMock).toHaveBeenCalledOnce();
78+
expect(callGatewayMock).toHaveBeenCalledWith({
79+
method: "channels.status",
80+
params: { probe, timeoutMs },
81+
timeoutMs,
82+
});
6983
expect(runtime.writeJson).toHaveBeenCalledWith({ channelAccounts: {} }, 2);
7084
expect(loaded.modules).not.toContain("config-guard");
7185
expect(loaded.modules).not.toContain("channels-status-runtime");

‎src/commands/channels.status.command-flow.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ describe("channelsStatusCommand SecretRef fallback flow", () => {
381381
expect(payload.configuredChannels).toStrictEqual([]);
382382
});
383383

384-
it("includes explicitly configured channels in JSON config-only fallback", async () => {
384+
it("treats all as no filter in JSON config-only fallback", async () => {
385385
mocks.callGateway.mockRejectedValue(new Error("gateway closed"));
386386
mocks.requireValidConfigSnapshot.mockResolvedValue({
387387
channels: { clickclack: { enabled: true } },
@@ -394,7 +394,7 @@ describe("channelsStatusCommand SecretRef fallback flow", () => {
394394
mocks.listConfiguredAnnounceChannelIdsForConfig.mockReturnValue(["clickclack"]);
395395
const { runtime, logs } = createCapturingTestRuntime();
396396

397-
await channelsStatusCommand({ json: true, probe: false }, runtime as never);
397+
await channelsStatusCommand({ channel: "all", json: true, probe: false }, runtime as never);
398398

399399
const payload = JSON.parse(logs.at(-1) ?? "{}");
400400
expect(payload.gatewayReachable).toBe(false);

‎src/commands/channels/status.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Implements `openclaw channels status` with gateway status and config-only fallback.
22
import { redactSensitiveUrlLikeString } from "@openclaw/net-policy/redact-sensitive-url";
3+
import { normalizeOptionalLowercaseString } from "@openclaw/normalization-core/string-coerce";
34
import { parseTimeoutMsWithFallback } from "../../cli/parse-timeout.js";
45
import { withProgress } from "../../cli/progress.js";
56
import { callGateway } from "../../gateway/call.js";
@@ -32,6 +33,10 @@ export async function channelsStatusCommand(
3233
opts: ChannelsStatusOptions,
3334
runtime: RuntimeEnv = defaultRuntime,
3435
) {
36+
const args =
37+
normalizeOptionalLowercaseString(opts.channel) === "all"
38+
? { ...opts, channel: undefined }
39+
: opts;
3540
const timeoutMs = parseTimeoutMsWithFallback(opts.timeout, opts.probe ? 30_000 : 10_000, {
3641
invalidType: "error",
3742
});
@@ -52,8 +57,8 @@ export async function channelsStatusCommand(
5257
probe: Boolean(opts.probe),
5358
timeoutMs,
5459
};
55-
if (opts.channel) {
56-
params.channel = opts.channel;
60+
if (args.channel) {
61+
params.channel = args.channel;
5762
}
5863
return await callGateway({
5964
method: "channels.status",
@@ -72,6 +77,6 @@ export async function channelsStatusCommand(
7277
const safeError = formatChannelsStatusError(err);
7378
const gatewayAuthUnavailable = isGatewaySecretRefUnavailableError(err);
7479
const { renderChannelsStatusFallback } = await loadChannelsStatusRuntime();
75-
await renderChannelsStatusFallback({ opts, runtime, safeError, gatewayAuthUnavailable });
80+
await renderChannelsStatusFallback({ opts: args, runtime, safeError, gatewayAuthUnavailable });
7681
}
7782
}

0 commit comments

Comments
 (0)