perf(cli): keep channel option help lightweight

This commit is contained in:
Vincent Koc
2026-05-14 16:07:32 +08:00
parent db743e4918
commit f6d0cc6cc3
3 changed files with 11 additions and 12 deletions

View File

@@ -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.

View File

@@ -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", () => {

View File

@@ -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 = {