refactor(status): privatize channel feature rendering (#107428)

This commit is contained in:
Peter Steinberger
2026-07-14 04:40:29 -07:00
committed by GitHub
parent 35e3eff549
commit c4a2db93d9
3 changed files with 39 additions and 12 deletions

View File

@@ -717,7 +717,6 @@ export const KNIP_UNUSED_EXPORT_BASELINE = [
"src/skills/lifecycle/upload-store.ts: MAX_ACTIVE_SKILL_UPLOADS",
"src/skills/runtime/refresh.ts: resetSkillsRefreshForTest",
"src/skills/runtime/remote-skills.ts: resetRemoteNodeSkillsForTests",
"src/status/status-text.ts: resolveStatusChannelFeatureLine",
"src/talk/agent-consult-runtime.ts: setRealtimeVoiceAgentConsultDepsForTest",
"src/tasks/detached-task-runtime.ts: resetDetachedTaskLifecycleRuntimeForTests",
"src/tasks/detached-task-runtime.ts: setDetachedTaskLifecycleRuntime",

View File

@@ -1,17 +1,47 @@
import { describe, expect, it } from "vitest";
import { resolveStatusChannelFeatureLine } from "./status-text.js";
import { buildStatusText } from "./status-text.js";
type StatusTextParams = Parameters<typeof buildStatusText>[0];
async function renderTelegramStatus(params: {
cfg: StatusTextParams["cfg"];
sessionEntry: NonNullable<StatusTextParams["sessionEntry"]>;
statusAccountId?: string;
}): Promise<string> {
return await buildStatusText({
cfg: params.cfg,
sessionEntry: params.sessionEntry,
sessionKey: "agent:main:main",
statusChannel: "telegram",
...(params.statusAccountId ? { statusAccountId: params.statusAccountId } : {}),
provider: "openai",
model: "gpt-5.4-mini",
resolvedHarness: "pi",
resolvedVerboseLevel: "off",
resolvedReasoningLevel: "off",
resolveDefaultThinkingLevel: async () => undefined,
isGroup: false,
defaultGroupActivation: () => "mention",
pluginHealthLineOverride: "Plugins: test",
taskLineOverride: "",
skipDefaultTaskLookup: true,
primaryModelLabelOverride: "openai/gpt-5.4-mini",
modelAuthOverride: "test",
activeModelAuthOverride: "test",
includeTranscriptUsage: false,
});
}
describe("buildStatusText channel features", () => {
it.each([
{ richMessages: undefined, expected: "Telegram rich messages: off" },
{ richMessages: false, expected: "Telegram rich messages: off" },
{ richMessages: true, expected: "Telegram rich messages: on" },
])("shows Telegram rich message state for %s", ({ richMessages, expected }) => {
])("shows Telegram rich message state for %s", async ({ richMessages, expected }) => {
const telegram = richMessages === undefined ? {} : { richMessages };
const text = resolveStatusChannelFeatureLine({
const text = await renderTelegramStatus({
cfg: { channels: { telegram } },
sessionEntry: { sessionId: `telegram-rich-${String(richMessages)}`, updatedAt: 0 },
statusChannel: "telegram",
});
expect(text).toContain(expected);
@@ -22,8 +52,8 @@ describe("buildStatusText channel features", () => {
}
});
it("uses Telegram account rich message overrides", () => {
const text = resolveStatusChannelFeatureLine({
it("uses Telegram account rich message overrides", async () => {
const text = await renderTelegramStatus({
cfg: {
channels: {
telegram: {
@@ -37,15 +67,14 @@ describe("buildStatusText channel features", () => {
updatedAt: 0,
lastAccountId: "work",
},
statusChannel: "telegram",
});
expect(text).toContain("Telegram rich messages: off");
expect(text).toContain("enable richMessages for this Telegram account");
});
it("uses the current Telegram command account before the session records it", () => {
const text = resolveStatusChannelFeatureLine({
it("uses the current Telegram command account before the session records it", async () => {
const text = await renderTelegramStatus({
cfg: {
channels: {
telegram: {
@@ -58,7 +87,6 @@ describe("buildStatusText channel features", () => {
sessionId: "telegram-rich-command-account",
updatedAt: 0,
},
statusChannel: "telegram",
statusAccountId: "work",
});

View File

@@ -70,7 +70,7 @@ const USAGE_OAUTH_ONLY_PROVIDERS = new Set([
]);
const CODEX_APP_SERVER_HOME_DIRNAME = "codex-home";
export function resolveStatusChannelFeatureLine(params: {
function resolveStatusChannelFeatureLine(params: {
cfg: OpenClawConfig;
statusChannel: string;
statusAccountId?: string;