fix: prefer target entry for status wrapper

This commit is contained in:
Tak Hoffman
2026-04-10 21:04:01 -05:00
parent e5e95f30ea
commit 2fe860b803
2 changed files with 38 additions and 2 deletions

View File

@@ -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", {

View File

@@ -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,