fix: require explicit system event session keys
This commit is contained in:
@@ -14,6 +14,8 @@ import {
|
||||
import { drainSystemEvents } from "../infra/system-events.js";
|
||||
import { getReplyFromConfig } from "./reply.js";
|
||||
|
||||
const MAIN_SESSION_KEY = "agent:main:main";
|
||||
|
||||
vi.mock("../agents/pi-embedded.js", () => ({
|
||||
abortEmbeddedPiRun: vi.fn().mockReturnValue(false),
|
||||
runEmbeddedPiAgent: vi.fn(),
|
||||
@@ -1390,7 +1392,7 @@ describe("directive behavior", () => {
|
||||
|
||||
it("queues a system event when switching models", async () => {
|
||||
await withTempHome(async (home) => {
|
||||
drainSystemEvents();
|
||||
drainSystemEvents(MAIN_SESSION_KEY);
|
||||
vi.mocked(runEmbeddedPiAgent).mockReset();
|
||||
const storePath = path.join(home, "sessions.json");
|
||||
|
||||
@@ -1412,7 +1414,7 @@ describe("directive behavior", () => {
|
||||
},
|
||||
);
|
||||
|
||||
const events = drainSystemEvents();
|
||||
const events = drainSystemEvents(MAIN_SESSION_KEY);
|
||||
expect(events).toContain(
|
||||
"Model switched to Opus (anthropic/claude-opus-4-5).",
|
||||
);
|
||||
|
||||
@@ -111,7 +111,7 @@ export async function buildStatusReply(params: {
|
||||
cfg: ClawdbotConfig;
|
||||
command: CommandContext;
|
||||
sessionEntry?: SessionEntry;
|
||||
sessionKey?: string;
|
||||
sessionKey: string;
|
||||
sessionScope?: SessionScope;
|
||||
provider: string;
|
||||
model: string;
|
||||
@@ -390,7 +390,7 @@ export async function handleCommands(params: {
|
||||
directives: InlineDirectives;
|
||||
sessionEntry?: SessionEntry;
|
||||
sessionStore?: Record<string, SessionEntry>;
|
||||
sessionKey?: string;
|
||||
sessionKey: string;
|
||||
storePath?: string;
|
||||
sessionScope?: SessionScope;
|
||||
workspaceDir: string;
|
||||
@@ -815,7 +815,7 @@ export async function handleCommands(params: {
|
||||
const line = reason
|
||||
? `${compactLabel}: ${reason} • ${contextSummary}`
|
||||
: `${compactLabel} • ${contextSummary}`;
|
||||
enqueueSystemEvent(line);
|
||||
enqueueSystemEvent(line, { sessionKey });
|
||||
return { shouldContinue: false, reply: { text: `⚙️ ${line}` } };
|
||||
}
|
||||
|
||||
|
||||
@@ -447,7 +447,7 @@ export async function handleDirectiveOnly(params: {
|
||||
directives: InlineDirectives;
|
||||
sessionEntry?: SessionEntry;
|
||||
sessionStore?: Record<string, SessionEntry>;
|
||||
sessionKey?: string;
|
||||
sessionKey: string;
|
||||
storePath?: string;
|
||||
elevatedEnabled: boolean;
|
||||
elevatedAllowed: boolean;
|
||||
@@ -836,6 +836,7 @@ export async function handleDirectiveOnly(params: {
|
||||
enqueueSystemEvent(
|
||||
formatModelSwitchEvent(nextLabel, modelSelection.alias),
|
||||
{
|
||||
sessionKey,
|
||||
contextKey: `model:${nextLabel}`,
|
||||
},
|
||||
);
|
||||
@@ -1103,6 +1104,7 @@ export async function persistInlineDirectives(params: {
|
||||
enqueueSystemEvent(
|
||||
formatModelSwitchEvent(nextLabel, resolved.alias),
|
||||
{
|
||||
sessionKey,
|
||||
contextKey: `model:${nextLabel}`,
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user