mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-21 13:44:03 +00:00
fix: prefer target entry for reset hooks
This commit is contained in:
@@ -255,4 +255,36 @@ describe("handleCommands reset hooks", () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("prefers the target session entry when emitting reset hooks", async () => {
|
||||
const params = buildResetParams(
|
||||
"/reset",
|
||||
{
|
||||
commands: { text: true },
|
||||
channels: { whatsapp: { allowFrom: ["*"] } },
|
||||
} as OpenClawConfig,
|
||||
);
|
||||
params.sessionEntry = {
|
||||
sessionId: "wrapper-session",
|
||||
updatedAt: Date.now(),
|
||||
} as HandleCommandsParams["sessionEntry"];
|
||||
params.sessionStore = {
|
||||
"agent:main:main": {
|
||||
sessionId: "target-session",
|
||||
updatedAt: Date.now(),
|
||||
},
|
||||
};
|
||||
|
||||
await maybeHandleResetCommand(params);
|
||||
|
||||
expect(triggerInternalHookMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
context: expect.objectContaining({
|
||||
sessionEntry: expect.objectContaining({
|
||||
sessionId: "target-session",
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -66,13 +66,15 @@ export async function maybeHandleResetCommand(
|
||||
};
|
||||
}
|
||||
|
||||
const targetSessionEntry = params.sessionStore?.[params.sessionKey] ?? params.sessionEntry;
|
||||
|
||||
await emitResetCommandHooks({
|
||||
action: commandAction,
|
||||
ctx: params.ctx,
|
||||
cfg: params.cfg,
|
||||
command: params.command,
|
||||
sessionKey: params.sessionKey,
|
||||
sessionEntry: params.sessionEntry,
|
||||
sessionEntry: targetSessionEntry,
|
||||
previousSessionEntry: params.previousSessionEntry,
|
||||
workspaceDir: params.workspaceDir,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user