diff --git a/CHANGELOG.md b/CHANGELOG.md index fb89dd89f..889c8ef67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/tui/tui-command-handlers.test.ts b/src/tui/tui-command-handlers.test.ts new file mode 100644 index 000000000..fc2ac4fa6 --- /dev/null +++ b/src/tui/tui-command-handlers.test.ts @@ -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(); + }); +}); diff --git a/src/tui/tui-command-handlers.ts b/src/tui/tui-command-handlers.ts index 79765b5fc..7bedb4d62 100644 --- a/src/tui/tui-command-handlers.ts +++ b/src/tui/tui-command-handlers.ts @@ -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();