mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-17 20:21:13 +00:00
fix: prefer target entry for status wrapper
This commit is contained in:
@@ -221,6 +221,41 @@ describe("info command handlers", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("prefers the target session entry when routing /status", async () => {
|
||||
const params = buildInfoParams(
|
||||
"/status",
|
||||
{
|
||||
commands: { text: true },
|
||||
channels: { whatsapp: { allowFrom: ["*"] } },
|
||||
} as OpenClawConfig,
|
||||
);
|
||||
params.sessionEntry = {
|
||||
sessionId: "wrapper-session",
|
||||
updatedAt: Date.now(),
|
||||
parentSessionKey: "wrapper-parent",
|
||||
} as HandleCommandsParams["sessionEntry"];
|
||||
params.sessionStore = {
|
||||
"agent:main:whatsapp:direct:12345": {
|
||||
sessionId: "target-session",
|
||||
updatedAt: Date.now(),
|
||||
parentSessionKey: "target-parent",
|
||||
},
|
||||
};
|
||||
|
||||
const statusResult = await handleStatusCommand(params, true);
|
||||
|
||||
expect(statusResult?.shouldContinue).toBe(false);
|
||||
expect(vi.mocked(buildStatusReply)).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
sessionEntry: expect.objectContaining({
|
||||
sessionId: "target-session",
|
||||
parentSessionKey: "target-parent",
|
||||
}),
|
||||
parentSessionKey: "target-parent",
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("uses the canonical target session agent when listing /commands", async () => {
|
||||
const { handleCommandsListCommand } = await import("./commands-info.js");
|
||||
const params = buildInfoParams("/commands", {
|
||||
|
||||
@@ -188,12 +188,13 @@ export const handleStatusCommand: CommandHandler = async (params, allowTextComma
|
||||
);
|
||||
return { shouldContinue: false };
|
||||
}
|
||||
const targetSessionEntry = params.sessionStore?.[params.sessionKey] ?? params.sessionEntry;
|
||||
const reply = await buildStatusReply({
|
||||
cfg: params.cfg,
|
||||
command: params.command,
|
||||
sessionEntry: params.sessionEntry,
|
||||
sessionEntry: targetSessionEntry,
|
||||
sessionKey: params.sessionKey,
|
||||
parentSessionKey: params.sessionEntry?.parentSessionKey ?? params.ctx.ParentSessionKey,
|
||||
parentSessionKey: targetSessionEntry?.parentSessionKey ?? params.ctx.ParentSessionKey,
|
||||
sessionScope: params.sessionScope,
|
||||
storePath: params.storePath,
|
||||
provider: params.provider,
|
||||
|
||||
Reference in New Issue
Block a user