fix(commands): harden fast status and Telegram callbacks

This commit is contained in:
Vincent Koc
2026-03-30 09:32:45 +09:00
parent 8657b65b05
commit 3034adfdb3
13 changed files with 121 additions and 12 deletions

View File

@@ -142,7 +142,7 @@ describe("directive behavior", () => {
},
});
expect(fastText).toContain("Current fast mode: on (config)");
expect(fastText).toContain("Options: on, off.");
expect(fastText).toContain("Options: status, on, off.");
const verboseText = await runCommand(home, "/verbose", {
defaults: { verboseDefault: "on" },
@@ -200,6 +200,23 @@ describe("directive behavior", () => {
expect(runEmbeddedPiAgentMock).not.toHaveBeenCalled();
});
});
it("treats /fast status like the no-argument status query", async () => {
await withTempHome(async (home) => {
const statusText = await runCommand(home, "/fast status", {
defaults: {
models: {
"anthropic/claude-opus-4-5": {
params: { fastMode: true },
},
},
},
});
expect(statusText).toContain("Current fast mode: on (config)");
expect(statusText).toContain("Options: status, on, off.");
expect(runEmbeddedPiAgentMock).not.toHaveBeenCalled();
});
});
it("persists elevated toggles across /status and /elevated", async () => {
await withTempHome(async (home) => {
const storePath = sessionStorePath(home);

View File

@@ -200,7 +200,7 @@ export async function handleDirectiveOnly(
};
}
if (directives.hasFastDirective && directives.fastMode === undefined) {
if (!directives.rawFastMode) {
if (!directives.rawFastMode || directives.rawFastMode.toLowerCase() === "status") {
const sourceSuffix =
effectiveFastModeSource === "config"
? " (config)"
@@ -210,12 +210,12 @@ export async function handleDirectiveOnly(
return {
text: withOptions(
`Current fast mode: ${effectiveFastMode ? "on" : "off"}${sourceSuffix}.`,
"on, off",
"status, on, off",
),
};
}
return {
text: `Unrecognized fast mode "${directives.rawFastMode}". Valid levels: on, off.`,
text: `Unrecognized fast mode "${directives.rawFastMode}". Valid levels: status, on, off.`,
};
}
if (directives.hasReasoningDirective && !directives.reasoningLevel) {

View File

@@ -1309,7 +1309,7 @@ describe("buildHelpMessage", () => {
});
it("includes /fast in help output", () => {
expect(buildHelpMessage()).toContain("/fast on|off");
expect(buildHelpMessage()).toContain("/fast status|on|off");
});
});

View File

@@ -842,7 +842,7 @@ export function buildHelpMessage(cfg?: OpenClawConfig): string {
lines.push(" /new | /reset | /compact [instructions] | /stop");
lines.push("");
const optionParts = ["/think <level>", "/model <id>", "/fast on|off", "/verbose on|off"];
const optionParts = ["/think <level>", "/model <id>", "/fast status|on|off", "/verbose on|off"];
if (isCommandFlagEnabled(cfg, "config")) {
optionParts.push("/config");
}