mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 15:30:47 +00:00
fix(gateway): mark chat slash commands as text
This commit is contained in:
@@ -1173,6 +1173,28 @@ describe("chat directive tag stripping for non-streaming final payloads", () =>
|
||||
);
|
||||
});
|
||||
|
||||
it("chat.send marks user slash commands as text command sources", async () => {
|
||||
createTranscriptFixture("openclaw-chat-send-text-command-source-");
|
||||
mockState.finalText = "ok";
|
||||
const respond = vi.fn();
|
||||
const context = createChatContext();
|
||||
|
||||
await runNonStreamingChatSend({
|
||||
context,
|
||||
respond,
|
||||
idempotencyKey: "idem-text-command-source",
|
||||
message: "/codex status",
|
||||
expectBroadcast: false,
|
||||
});
|
||||
|
||||
expect(mockState.lastDispatchCtx).toEqual(
|
||||
expect.objectContaining({
|
||||
BodyForCommands: "/codex status",
|
||||
CommandSource: "text",
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("chat.send keeps explicit delivery routes for Feishu channel-scoped sessions", async () => {
|
||||
createTranscriptFixture("openclaw-chat-send-feishu-origin-routing-");
|
||||
mockState.finalText = "ok";
|
||||
|
||||
@@ -2195,6 +2195,7 @@ export const chatHandlers: GatewayRequestHandlers = {
|
||||
p.thinking && trimmedMessage && !trimmedMessage.startsWith("/"),
|
||||
);
|
||||
const commandBody = injectThinking ? `/think ${p.thinking} ${parsedMessage}` : parsedMessage;
|
||||
const commandSource = trimmedMessage.startsWith("/") ? "text" : undefined;
|
||||
const messageForAgent = systemProvenanceReceipt
|
||||
? [systemProvenanceReceipt, parsedMessage].filter(Boolean).join("\n\n")
|
||||
: parsedMessage;
|
||||
@@ -2226,6 +2227,7 @@ export const chatHandlers: GatewayRequestHandlers = {
|
||||
AccountId: accountId,
|
||||
MessageThreadId: messageThreadId,
|
||||
ChatType: "direct",
|
||||
...(commandSource ? { CommandSource: commandSource } : {}),
|
||||
CommandAuthorized: true,
|
||||
MessageSid: clientRunId,
|
||||
SenderId: clientInfo?.id,
|
||||
|
||||
Reference in New Issue
Block a user