fix(auto-reply): avoid duplicate reset hook acknowledgements · openclaw/openclaw@3ee5490
steipete
·
2026-04-28
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -251,7 +251,7 @@ describe("handleCommands reset hooks", () => {
|
251 | 251 | }, |
252 | 252 | ); |
253 | 253 | |
254 | | -await maybeHandleResetCommand(params); |
| 254 | +const result = await maybeHandleResetCommand(params); |
255 | 255 | |
256 | 256 | expect(routeReplyMock).toHaveBeenCalledWith( |
257 | 257 | expect.objectContaining({ |
@@ -262,6 +262,7 @@ describe("handleCommands reset hooks", () => {
|
262 | 262 | threadId: "thread-1", |
263 | 263 | }), |
264 | 264 | ); |
| 265 | +expect(result).toEqual({ shouldContinue: false }); |
265 | 266 | }); |
266 | 267 | |
267 | 268 | it("prefers the target session entry when emitting reset hooks", async () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -104,7 +104,7 @@ export async function emitResetCommandHooks(params: {
|
104 | 104 | sessionEntry?: HandleCommandsParams["sessionEntry"]; |
105 | 105 | previousSessionEntry?: HandleCommandsParams["previousSessionEntry"]; |
106 | 106 | workspaceDir: string; |
107 | | -}): Promise<void> { |
| 107 | +}): Promise<{ routedReply: boolean }> { |
108 | 108 | const hookEvent = createInternalHookEvent("command", params.action, params.sessionKey ?? "", { |
109 | 109 | sessionEntry: params.sessionEntry, |
110 | 110 | previousSessionEntry: params.previousSessionEntry, |
@@ -116,6 +116,7 @@ export async function emitResetCommandHooks(params: {
|
116 | 116 | await triggerInternalHook(hookEvent); |
117 | 117 | params.command.resetHookTriggered = true; |
118 | 118 | |
| 119 | +let routedReply = false; |
119 | 120 | if (hookEvent.messages.length > 0) { |
120 | 121 | const channel = params.ctx.OriginatingChannel || params.command.channel; |
121 | 122 | const to = params.ctx.OriginatingTo || params.command.from || params.command.to; |
@@ -134,6 +135,7 @@ export async function emitResetCommandHooks(params: {
|
134 | 135 | threadId: params.ctx.MessageThreadId, |
135 | 136 | cfg: params.cfg, |
136 | 137 | }); |
| 138 | +routedReply = true; |
137 | 139 | } |
138 | 140 | } |
139 | 141 | |
@@ -160,4 +162,5 @@ export async function emitResetCommandHooks(params: {
|
160 | 162 | } |
161 | 163 | })(); |
162 | 164 | } |
| 165 | +return { routedReply }; |
163 | 166 | } |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -156,7 +156,7 @@ export async function maybeHandleResetCommand(
|
156 | 156 | |
157 | 157 | const targetSessionEntry = params.sessionStore?.[params.sessionKey] ?? params.sessionEntry; |
158 | 158 | |
159 | | -await emitResetCommandHooks({ |
| 159 | +const hookResult = await emitResetCommandHooks({ |
160 | 160 | action: commandAction, |
161 | 161 | ctx: params.ctx, |
162 | 162 | cfg: params.cfg, |
@@ -169,9 +169,13 @@ export async function maybeHandleResetCommand(
|
169 | 169 | if (!resetTail) { |
170 | 170 | return { |
171 | 171 | shouldContinue: false, |
172 | | -reply: { |
173 | | -text: commandAction === "reset" ? "✅ Session reset." : "✅ New session started.", |
174 | | -}, |
| 172 | + ...(hookResult.routedReply |
| 173 | + ? {} |
| 174 | + : { |
| 175 | +reply: { |
| 176 | +text: commandAction === "reset" ? "✅ Session reset." : "✅ New session started.", |
| 177 | +}, |
| 178 | +}), |
175 | 179 | }; |
176 | 180 | } |
177 | 181 | return null; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。