fix(keyword-detector): use session state for agent-specific ultrawork templates
Bug: When switching from Prometheus to Sisyphus, the Prometheus ultrawork template was still injected because: 1. setSessionAgent() only sets on first call, ignoring subsequent updates 2. keyword-detector relied solely on input.agent which could be stale Fix: - Use updateSessionAgent() instead of setSessionAgent() in index.ts - keyword-detector now uses getSessionAgent() as primary source, fallback to input.agent - Added tests for agent switch scenario
This commit is contained in:
+3
-2
@@ -51,6 +51,7 @@ import {
|
||||
setMainSession,
|
||||
getMainSessionID,
|
||||
setSessionAgent,
|
||||
updateSessionAgent,
|
||||
clearSessionAgent,
|
||||
} from "./features/claude-code-session-state";
|
||||
import {
|
||||
@@ -309,7 +310,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
|
||||
|
||||
"chat.message": async (input, output) => {
|
||||
if (input.agent) {
|
||||
setSessionAgent(input.sessionID, input.agent);
|
||||
updateSessionAgent(input.sessionID, input.agent);
|
||||
}
|
||||
|
||||
const message = (output as { message: { variant?: string } }).message
|
||||
@@ -450,7 +451,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
|
||||
const agent = info?.agent as string | undefined;
|
||||
const role = info?.role as string | undefined;
|
||||
if (sessionID && agent && role === "user") {
|
||||
setSessionAgent(sessionID, agent);
|
||||
updateSessionAgent(sessionID, agent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user