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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user