diff --git a/src/auto-reply/reply/commands-reset-hooks.test.ts b/src/auto-reply/reply/commands-reset-hooks.test.ts index 1b1b5809923..ddc1c094e0e 100644 --- a/src/auto-reply/reply/commands-reset-hooks.test.ts +++ b/src/auto-reply/reply/commands-reset-hooks.test.ts @@ -251,7 +251,7 @@ describe("handleCommands reset hooks", () => { }, ); - await maybeHandleResetCommand(params); + const result = await maybeHandleResetCommand(params); expect(routeReplyMock).toHaveBeenCalledWith( expect.objectContaining({ @@ -262,6 +262,7 @@ describe("handleCommands reset hooks", () => { threadId: "thread-1", }), ); + expect(result).toEqual({ shouldContinue: false }); }); it("prefers the target session entry when emitting reset hooks", async () => { diff --git a/src/auto-reply/reply/commands-reset-hooks.ts b/src/auto-reply/reply/commands-reset-hooks.ts index 2e529dfb6ae..c26579e6008 100644 --- a/src/auto-reply/reply/commands-reset-hooks.ts +++ b/src/auto-reply/reply/commands-reset-hooks.ts @@ -104,7 +104,7 @@ export async function emitResetCommandHooks(params: { sessionEntry?: HandleCommandsParams["sessionEntry"]; previousSessionEntry?: HandleCommandsParams["previousSessionEntry"]; workspaceDir: string; -}): Promise { +}): Promise<{ routedReply: boolean }> { const hookEvent = createInternalHookEvent("command", params.action, params.sessionKey ?? "", { sessionEntry: params.sessionEntry, previousSessionEntry: params.previousSessionEntry, @@ -116,6 +116,7 @@ export async function emitResetCommandHooks(params: { await triggerInternalHook(hookEvent); params.command.resetHookTriggered = true; + let routedReply = false; if (hookEvent.messages.length > 0) { const channel = params.ctx.OriginatingChannel || params.command.channel; const to = params.ctx.OriginatingTo || params.command.from || params.command.to; @@ -134,6 +135,7 @@ export async function emitResetCommandHooks(params: { threadId: params.ctx.MessageThreadId, cfg: params.cfg, }); + routedReply = true; } } @@ -160,4 +162,5 @@ export async function emitResetCommandHooks(params: { } })(); } + return { routedReply }; } diff --git a/src/auto-reply/reply/commands-reset.ts b/src/auto-reply/reply/commands-reset.ts index 7f856220826..0ebb5cafdec 100644 --- a/src/auto-reply/reply/commands-reset.ts +++ b/src/auto-reply/reply/commands-reset.ts @@ -156,7 +156,7 @@ export async function maybeHandleResetCommand( const targetSessionEntry = params.sessionStore?.[params.sessionKey] ?? params.sessionEntry; - await emitResetCommandHooks({ + const hookResult = await emitResetCommandHooks({ action: commandAction, ctx: params.ctx, cfg: params.cfg, @@ -169,9 +169,13 @@ export async function maybeHandleResetCommand( if (!resetTail) { return { shouldContinue: false, - reply: { - text: commandAction === "reset" ? "✅ Session reset." : "✅ New session started.", - }, + ...(hookResult.routedReply + ? {} + : { + reply: { + text: commandAction === "reset" ? "✅ Session reset." : "✅ New session started.", + }, + }), }; } return null;