fix: forward unknown TUI slash commands

This commit is contained in:
Peter Steinberger
2026-01-23 18:41:02 +00:00
parent b77e730657
commit 1af227b619
3 changed files with 49 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ Docs: https://docs.clawd.bot
- Markdown: add per-channel table conversion (bullets for Signal/WhatsApp, code blocks elsewhere). (#1495) Thanks @odysseus0.
### Fixes
- TUI: forward unknown slash commands (for example, `/context`) to the Gateway.
- Media: preserve PNG alpha when possible; fall back to JPEG when still over size cap. (#1491) Thanks @robbyczgw-cla.
- Agents: treat plugin-only tool allowlists as opt-ins; keep core tools enabled. (#1467)

View File

@@ -0,0 +1,47 @@
import { describe, expect, it, vi } from "vitest";
import { createCommandHandlers } from "./tui-command-handlers.js";
describe("tui command handlers", () => {
it("forwards unknown slash commands to the gateway", async () => {
const sendChat = vi.fn().mockResolvedValue({ runId: "r1" });
const addUser = vi.fn();
const addSystem = vi.fn();
const requestRender = vi.fn();
const setActivityStatus = vi.fn();
const { handleCommand } = createCommandHandlers({
client: { sendChat } as never,
chatLog: { addUser, addSystem } as never,
tui: { requestRender } as never,
opts: {},
state: {
currentSessionKey: "agent:main:main",
activeChatRunId: null,
sessionInfo: {},
} as never,
deliverDefault: false,
openOverlay: vi.fn(),
closeOverlay: vi.fn(),
refreshSessionInfo: vi.fn(),
loadHistory: vi.fn(),
setSession: vi.fn(),
refreshAgents: vi.fn(),
abortActive: vi.fn(),
setActivityStatus,
formatSessionKey: vi.fn(),
});
await handleCommand("/context");
expect(addSystem).not.toHaveBeenCalled();
expect(addUser).toHaveBeenCalledWith("/context");
expect(sendChat).toHaveBeenCalledWith(
expect.objectContaining({
sessionKey: "agent:main:main",
message: "/context",
}),
);
expect(requestRender).toHaveBeenCalled();
});
});

View File

@@ -428,7 +428,7 @@ export function createCommandHandlers(context: CommandHandlerContext) {
process.exit(0);
break;
default:
chatLog.addSystem(`unknown command: /${name}`);
await sendMessage(raw);
break;
}
tui.requestRender();