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
@@ -23,6 +23,15 @@ export function getSessionID(properties: EventProperties): string | undefined {
const infoSessionId = info?.sessionId
if (typeof infoSessionId === "string" && infoSessionId.length > 0) return infoSessionId
const part = properties?.part
if (isRecord(part)) {
const partSessionID = part.sessionID
if (typeof partSessionID === "string" && partSessionID.length > 0) return partSessionID
const partSessionId = part.sessionId
if (typeof partSessionId === "string" && partSessionId.length > 0) return partSessionId
}
return undefined
}