From f6d0cc6cc3be6932a73a5961bb924dfa458ae2e9 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Thu, 14 May 2026 16:07:32 +0800 Subject: [PATCH] perf(cli): keep channel option help lightweight --- CHANGELOG.md | 2 +- src/cli/channel-options.test.ts | 13 ++++++------- src/cli/channel-options.ts | 8 ++++---- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4997c2f375f..afd1144ba75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ Docs: https://docs.openclaw.ai ### Fixes -- CLI: lazy-load model, plugin, and device runtime helpers for command actions so parent/help output renders without importing those runtime paths. +- CLI: lazy-load model, plugin, and device runtime helpers and keep channel option help on generated startup metadata or generic fallback text so parent/help output renders without importing those runtime paths. - Gateway/session history: carry monotonic transcript message sequence through live updates and refresh SSE history when stale sequence input would otherwise append bad incremental state. (#81474) Thanks @samzong. - Security/sandbox: include Windows `USERPROFILE` in the sandbox blocked home roots so credential-bearing binds (such as `.codex`, `.openclaw`, or `.ssh` under the Windows user profile) are denied even when `HOME` points at a different shell home. (#63074) Thanks @luoyanglang. - Gateway/OpenAI-compatible HTTP: parse shared JSON endpoint paths without trusting malformed Host headers, avoiding 500s before `/v1/chat/completions`, `/v1/responses`, and `/v1/embeddings` request handling. diff --git a/src/cli/channel-options.test.ts b/src/cli/channel-options.test.ts index bdfdbfa462c..ed8e1c23bb8 100644 --- a/src/cli/channel-options.test.ts +++ b/src/cli/channel-options.test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -import { __testing, resolveCliChannelOptions } from "./channel-options.js"; +import { __testing, formatCliChannelOptions, resolveCliChannelOptions } from "./channel-options.js"; import { __testing as startupMetadataTesting } from "./startup-metadata.js"; const readFileSyncMock = vi.hoisted(() => vi.fn()); @@ -17,10 +17,6 @@ vi.mock("node:fs", async () => { }; }); -vi.mock("../channels/ids.js", () => ({ - CHAT_CHANNEL_ORDER: ["quietchat", "forum"], -})); - describe("resolveCliChannelOptions", () => { beforeEach(() => { __testing.resetPrecomputedChannelOptionsForTests(); @@ -39,14 +35,17 @@ describe("resolveCliChannelOptions", () => { ); expect(resolveCliChannelOptions()).toEqual(["cached", "quietchat"]); + expect(formatCliChannelOptions(["all"])).toBe("all|cached|quietchat"); }); - it("falls back to core channel order when metadata is missing", () => { + it("falls back to generic channel text when metadata is missing", () => { readFileSyncMock.mockImplementation(() => { throw new Error("ENOENT"); }); - expect(resolveCliChannelOptions()).toEqual(["quietchat", "forum"]); + expect(resolveCliChannelOptions()).toEqual([]); + expect(formatCliChannelOptions()).toBe("channel"); + expect(formatCliChannelOptions(["all"])).toBe("all"); }); it("ignores external catalog env during CLI bootstrap", () => { diff --git a/src/cli/channel-options.ts b/src/cli/channel-options.ts index 4459ada06fd..2674a352ccc 100644 --- a/src/cli/channel-options.ts +++ b/src/cli/channel-options.ts @@ -1,4 +1,3 @@ -import { CHAT_CHANNEL_ORDER } from "../channels/ids.js"; import { readCliStartupMetadata } from "./startup-metadata.js"; function dedupe(values: string[]): string[] { @@ -29,7 +28,7 @@ function loadPrecomputedChannelOptions(): string[] | null { return precomputedChannelOptions; } } catch { - // Fall back to dynamic catalog resolution. + // Source checkouts may not have generated startup metadata yet. } precomputedChannelOptions = null; return null; @@ -37,11 +36,12 @@ function loadPrecomputedChannelOptions(): string[] | null { export function resolveCliChannelOptions(): string[] { const precomputed = loadPrecomputedChannelOptions(); - return precomputed ?? [...CHAT_CHANNEL_ORDER]; + return precomputed ?? []; } export function formatCliChannelOptions(extra: string[] = []): string { - return [...extra, ...resolveCliChannelOptions()].join("|"); + const options = [...extra, ...resolveCliChannelOptions()]; + return options.length > 0 ? options.join("|") : "channel"; } export const __testing = {