fix(plugin): normalize event session ids

Handle OpenCode session events that carry the session ID under properties.info.id or properties.info.sessionID so background tasks and continuation hooks do not miss idle/error/delete events.

Add regression coverage for nested session.idle events completing background tasks and waking continuation hooks.
This commit is contained in:
YeonGyu-Kim
2026-05-12 11:48:18 +09:00
parent 67f90a819e
commit 4da48555ee
51 changed files with 740 additions and 254 deletions
+4 -3
View File
@@ -2,6 +2,7 @@ import { detectThinkKeyword, extractPromptText } from "./detector"
import { isAlreadyHighVariant } from "./switcher"
import type { ThinkModeState } from "./types"
import { log } from "../../shared"
import { resolveSessionEventID } from "../../shared/event-session-id"
const thinkModeState = new Map<string, ThinkModeState>()
@@ -66,9 +67,9 @@ export function createThinkModeHook() {
event: async ({ event }: { event: { type: string; properties?: unknown } }) => {
if (event.type === "session.deleted") {
const props = event.properties as { info?: { id?: string } } | undefined
if (props?.info?.id) {
thinkModeState.delete(props.info.id)
const sessionID = resolveSessionEventID(event.properties)
if (sessionID) {
thinkModeState.delete(sessionID)
}
}
},