fix: forward unknown TUI slash commands
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
47
src/tui/tui-command-handlers.test.ts
Normal file
47
src/tui/tui-command-handlers.test.ts
Normal 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();
|
||||
});
|
||||
});
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user