Skip to content

Commit 7b583d2

Browse files
committed
fix(auto-reply): 限制空回复兜底仅用于私聊
避免通用 fallback 误伤 Slack 无回复也合法的 ack 场景 仅在 direct/private 类会话且确实无可发送输出时补发提示 补充频道消息回归测试,保持现有静默分支行为不变
1 parent 034b29c commit 7b583d2

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/auto-reply/reply/dispatch-from-config.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2984,4 +2984,20 @@ describe("before_dispatch hook", () => {
29842984
expect(result.queuedFinal).toBe(true);
29852985
expect(result.counts.final).toBe(1);
29862986
});
2987+
2988+
it("does not send the fallback final reply for channel messages", async () => {
2989+
hookMocks.runner.runBeforeDispatch.mockResolvedValue({ handled: false });
2990+
const dispatcher = createDispatcher();
2991+
2992+
const result = await dispatchReplyFromConfig({
2993+
ctx: createHookCtx({ ChatType: "channel", Surface: "slack", Provider: "slack" }),
2994+
cfg: emptyConfig,
2995+
dispatcher,
2996+
replyResolver: async () => undefined,
2997+
});
2998+
2999+
expect(dispatcher.sendFinalReply).not.toHaveBeenCalled();
3000+
expect(result.queuedFinal).toBe(false);
3001+
expect(result.counts.final).toBe(0);
3002+
});
29873003
});

src/auto-reply/reply/dispatch-from-config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ const normalizeMediaType = (value: string): string =>
104104
normalizeOptionalLowercaseString(value.split(";")[0]) ?? "";
105105
const EMPTY_RUN_FALLBACK_TEXT =
106106
"I couldn't produce a reply for that request. Please try again or rephrase your message.";
107+
const isDirectLikeChatType = (value?: string): boolean => {
108+
const normalized = normalizeOptionalLowercaseString(value);
109+
return normalized === "direct" || normalized === "dm" || normalized === "private";
110+
};
107111

108112
const isInboundAudioContext = (ctx: FinalizedMsgContext): boolean => {
109113
const rawTypes = [
@@ -1044,6 +1048,7 @@ export async function dispatchReplyFromConfig(params: {
10441048
counts.final += routedFinalCount;
10451049

10461050
const shouldSendEmptyRunFallback =
1051+
isDirectLikeChatType(ctx.ChatType) &&
10471052
!shouldRouteToOriginating &&
10481053
replies.length === 0 &&
10491054
blockCount === 0 &&

0 commit comments

Comments
 (0)