mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-14 10:41:23 +00:00
fix: prefer persisted parent session in status
This commit is contained in:
@@ -2,6 +2,8 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import type { MsgContext } from "../templating.js";
|
||||
import { handleContextCommand } from "./commands-context-command.js";
|
||||
import { handleStatusCommand } from "./commands-info.js";
|
||||
import { buildStatusReply } from "./commands-status.js";
|
||||
import type { HandleCommandsParams } from "./commands-types.js";
|
||||
import { handleWhoamiCommand } from "./commands-whoami.js";
|
||||
|
||||
@@ -11,6 +13,10 @@ vi.mock("./commands-context-report.js", () => ({
|
||||
buildContextReply: buildContextReplyMock,
|
||||
}));
|
||||
|
||||
vi.mock("./commands-status.js", () => ({
|
||||
buildStatusReply: vi.fn(async () => ({ text: "status reply" })),
|
||||
}));
|
||||
|
||||
function buildInfoParams(
|
||||
commandBodyNormalized: string,
|
||||
cfg: OpenClawConfig,
|
||||
@@ -134,4 +140,32 @@ describe("info command handlers", () => {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("prefers the persisted session parent when routing /status context", async () => {
|
||||
const params = buildInfoParams(
|
||||
"/status",
|
||||
{
|
||||
commands: { text: true },
|
||||
channels: { whatsapp: { allowFrom: ["*"] } },
|
||||
} as OpenClawConfig,
|
||||
{
|
||||
ParentSessionKey: undefined,
|
||||
},
|
||||
);
|
||||
params.sessionEntry = {
|
||||
sessionId: "session-1",
|
||||
updatedAt: Date.now(),
|
||||
parentSessionKey: "discord:group:parent-room",
|
||||
} as HandleCommandsParams["sessionEntry"];
|
||||
|
||||
const statusResult = await handleStatusCommand(params, true);
|
||||
|
||||
expect(statusResult?.shouldContinue).toBe(false);
|
||||
|
||||
expect(vi.mocked(buildStatusReply)).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
parentSessionKey: "discord:group:parent-room",
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -189,7 +189,7 @@ export const handleStatusCommand: CommandHandler = async (params, allowTextComma
|
||||
command: params.command,
|
||||
sessionEntry: params.sessionEntry,
|
||||
sessionKey: params.sessionKey,
|
||||
parentSessionKey: params.ctx.ParentSessionKey,
|
||||
parentSessionKey: params.sessionEntry?.parentSessionKey ?? params.ctx.ParentSessionKey,
|
||||
sessionScope: params.sessionScope,
|
||||
provider: params.provider,
|
||||
model: params.model,
|
||||
|
||||
Reference in New Issue
Block a user