fix(reply): keep native command replies visible · openclaw/openclaw@195f704
obviyus
·
2026-04-29
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -4335,6 +4335,35 @@ describe("sendPolicy deny — suppress delivery, not processing (#53328)", () =>
|
4335 | 4335 | expect(dispatcher.sendFinalReply).not.toHaveBeenCalled(); |
4336 | 4336 | }); |
4337 | 4337 | |
| 4338 | +it("keeps native command replies visible in group/channel turns", async () => { |
| 4339 | +setNoAbort(); |
| 4340 | +const dispatcher = createDispatcher(); |
| 4341 | +const replyResolver = vi.fn(async (_ctx: MsgContext, opts?: GetReplyOptions) => { |
| 4342 | +expect(opts?.sourceReplyDeliveryMode).toBe("automatic"); |
| 4343 | +expect(opts?.suppressTyping).toBe(false); |
| 4344 | +return { text: "status reply" } satisfies ReplyPayload; |
| 4345 | +}); |
| 4346 | + |
| 4347 | +const result = await dispatchReplyFromConfig({ |
| 4348 | +ctx: buildTestCtx({ |
| 4349 | +ChatType: "group", |
| 4350 | +CommandSource: "native", |
| 4351 | +CommandAuthorized: true, |
| 4352 | +WasMentioned: true, |
| 4353 | +SessionKey: "test:telegram:group:G1", |
| 4354 | +}), |
| 4355 | +cfg: emptyConfig, |
| 4356 | + dispatcher, |
| 4357 | + replyResolver, |
| 4358 | +}); |
| 4359 | + |
| 4360 | +expect(replyResolver).toHaveBeenCalledTimes(1); |
| 4361 | +expect(result.queuedFinal).toBe(true); |
| 4362 | +expect(dispatcher.sendFinalReply).toHaveBeenCalledWith( |
| 4363 | +expect.objectContaining({ text: "status reply" }), |
| 4364 | +); |
| 4365 | +}); |
| 4366 | + |
4338 | 4367 | it("allows config to keep group/channel source delivery automatic", async () => { |
4339 | 4368 | setNoAbort(); |
4340 | 4369 | const dispatcher = createDispatcher(); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -42,6 +42,15 @@ describe("resolveSourceReplyDeliveryMode", () => {
|
42 | 42 | }), |
43 | 43 | ).toBe("automatic"); |
44 | 44 | }); |
| 45 | + |
| 46 | +it("treats native commands as explicit replies in groups", () => { |
| 47 | +expect( |
| 48 | +resolveSourceReplyDeliveryMode({ |
| 49 | +cfg: emptyConfig, |
| 50 | +ctx: { ChatType: "group", CommandSource: "native" }, |
| 51 | +}), |
| 52 | +).toBe("automatic"); |
| 53 | +}); |
45 | 54 | }); |
46 | 55 | |
47 | 56 | describe("resolveSourceReplyVisibilityPolicy", () => { |
@@ -83,6 +92,22 @@ describe("resolveSourceReplyVisibilityPolicy", () => {
|
83 | 92 | }); |
84 | 93 | }); |
85 | 94 | |
| 95 | +it("keeps native command replies visible in groups", () => { |
| 96 | +expect( |
| 97 | +resolveSourceReplyVisibilityPolicy({ |
| 98 | +cfg: emptyConfig, |
| 99 | +ctx: { ChatType: "group", CommandSource: "native" }, |
| 100 | +sendPolicy: "allow", |
| 101 | +}), |
| 102 | +).toMatchObject({ |
| 103 | +sourceReplyDeliveryMode: "automatic", |
| 104 | +suppressAutomaticSourceDelivery: false, |
| 105 | +suppressDelivery: false, |
| 106 | +suppressHookReplyLifecycle: false, |
| 107 | +suppressTyping: false, |
| 108 | +}); |
| 109 | +}); |
| 110 | + |
86 | 111 | it("keeps configured automatic group delivery visible", () => { |
87 | 112 | expect( |
88 | 113 | resolveSourceReplyVisibilityPolicy({ |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -5,6 +5,7 @@ import type { SourceReplyDeliveryMode } from "../get-reply-options.types.js";
|
5 | 5 | |
6 | 6 | export type SourceReplyDeliveryModeContext = { |
7 | 7 | ChatType?: string; |
| 8 | +CommandSource?: "text" | "native"; |
8 | 9 | }; |
9 | 10 | |
10 | 11 | export function resolveSourceReplyDeliveryMode(params: { |
@@ -15,6 +16,9 @@ export function resolveSourceReplyDeliveryMode(params: {
|
15 | 16 | if (params.requested) { |
16 | 17 | return params.requested; |
17 | 18 | } |
| 19 | +if (params.ctx.CommandSource === "native") { |
| 20 | +return "automatic"; |
| 21 | +} |
18 | 22 | const chatType = normalizeChatType(params.ctx.ChatType); |
19 | 23 | if (chatType === "group" || chatType === "channel") { |
20 | 24 | return params.cfg.messages?.groupChat?.visibleReplies === "automatic" |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。