mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-03 06:50:22 +00:00
fix: prefer target entry for btw command
This commit is contained in:
@@ -227,4 +227,34 @@ describe("handleBtwCommand", () => {
|
|||||||
reply: { text: "resolved fallback", btw: { question: "what changed?" } },
|
reply: { text: "resolved fallback", btw: { question: "what changed?" } },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("prefers the target session entry for side-question context", async () => {
|
||||||
|
const params = buildParams("/btw what changed?");
|
||||||
|
params.sessionKey = "agent:worker-1:whatsapp:direct:12345";
|
||||||
|
params.sessionEntry = {
|
||||||
|
sessionId: "wrapper-session",
|
||||||
|
updatedAt: Date.now(),
|
||||||
|
};
|
||||||
|
params.sessionStore = {
|
||||||
|
"agent:worker-1:whatsapp:direct:12345": {
|
||||||
|
sessionId: "target-session",
|
||||||
|
updatedAt: Date.now(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
runBtwSideQuestionMock.mockResolvedValue({ text: "target context" });
|
||||||
|
|
||||||
|
const result = await handleBtwCommand(params, true);
|
||||||
|
|
||||||
|
expect(runBtwSideQuestionMock).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
sessionEntry: expect.objectContaining({
|
||||||
|
sessionId: "target-session",
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
expect(result).toEqual({
|
||||||
|
shouldContinue: false,
|
||||||
|
reply: { text: "target context", btw: { question: "what changed?" } },
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -26,7 +26,9 @@ export const handleBtwCommand: CommandHandler = async (params, allowTextCommands
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!params.sessionEntry?.sessionId) {
|
const targetSessionEntry = params.sessionStore?.[params.sessionKey] ?? params.sessionEntry;
|
||||||
|
|
||||||
|
if (!targetSessionEntry?.sessionId) {
|
||||||
return {
|
return {
|
||||||
shouldContinue: false,
|
shouldContinue: false,
|
||||||
reply: { text: "⚠️ /btw requires an active session with existing context." },
|
reply: { text: "⚠️ /btw requires an active session with existing context." },
|
||||||
@@ -56,7 +58,7 @@ export const handleBtwCommand: CommandHandler = async (params, allowTextCommands
|
|||||||
provider: params.provider,
|
provider: params.provider,
|
||||||
model: params.model,
|
model: params.model,
|
||||||
question,
|
question,
|
||||||
sessionEntry: params.sessionEntry,
|
sessionEntry: targetSessionEntry,
|
||||||
sessionStore: params.sessionStore,
|
sessionStore: params.sessionStore,
|
||||||
sessionKey: params.sessionKey,
|
sessionKey: params.sessionKey,
|
||||||
storePath: params.storePath,
|
storePath: params.storePath,
|
||||||
|
|||||||
Reference in New Issue
Block a user