fix(gateway): mark chat slash commands as text · openclaw/openclaw@7fd7f6f
vincentkoc
·
2026-05-06
·
via Recent Commits to openclaw:main
File tree
src/gateway/server-methods
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1173,6 +1173,28 @@ describe("chat directive tag stripping for non-streaming final payloads", () =>
|
1173 | 1173 | ); |
1174 | 1174 | }); |
1175 | 1175 | |
| 1176 | +it("chat.send marks user slash commands as text command sources", async () => { |
| 1177 | +createTranscriptFixture("openclaw-chat-send-text-command-source-"); |
| 1178 | +mockState.finalText = "ok"; |
| 1179 | +const respond = vi.fn(); |
| 1180 | +const context = createChatContext(); |
| 1181 | + |
| 1182 | +await runNonStreamingChatSend({ |
| 1183 | + context, |
| 1184 | + respond, |
| 1185 | +idempotencyKey: "idem-text-command-source", |
| 1186 | +message: "/codex status", |
| 1187 | +expectBroadcast: false, |
| 1188 | +}); |
| 1189 | + |
| 1190 | +expect(mockState.lastDispatchCtx).toEqual( |
| 1191 | +expect.objectContaining({ |
| 1192 | +BodyForCommands: "/codex status", |
| 1193 | +CommandSource: "text", |
| 1194 | +}), |
| 1195 | +); |
| 1196 | +}); |
| 1197 | + |
1176 | 1198 | it("chat.send keeps explicit delivery routes for Feishu channel-scoped sessions", async () => { |
1177 | 1199 | createTranscriptFixture("openclaw-chat-send-feishu-origin-routing-"); |
1178 | 1200 | mockState.finalText = "ok"; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2195,6 +2195,7 @@ export const chatHandlers: GatewayRequestHandlers = {
|
2195 | 2195 | p.thinking && trimmedMessage && !trimmedMessage.startsWith("/"), |
2196 | 2196 | ); |
2197 | 2197 | const commandBody = injectThinking ? `/think ${p.thinking} ${parsedMessage}` : parsedMessage; |
| 2198 | +const commandSource = trimmedMessage.startsWith("/") ? "text" : undefined; |
2198 | 2199 | const messageForAgent = systemProvenanceReceipt |
2199 | 2200 | ? [systemProvenanceReceipt, parsedMessage].filter(Boolean).join("\n\n") |
2200 | 2201 | : parsedMessage; |
@@ -2226,6 +2227,7 @@ export const chatHandlers: GatewayRequestHandlers = {
|
2226 | 2227 | AccountId: accountId, |
2227 | 2228 | MessageThreadId: messageThreadId, |
2228 | 2229 | ChatType: "direct", |
| 2230 | + ...(commandSource ? { CommandSource: commandSource } : {}), |
2229 | 2231 | CommandAuthorized: true, |
2230 | 2232 | MessageSid: clientRunId, |
2231 | 2233 | SenderId: clientInfo?.id, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。