Files
oh-my-opencode/src/shared/event-session-id.test.ts
T
YeonGyu-Kim 4da48555ee 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.
2026-05-12 12:32:26 +09:00

41 lines
1.2 KiB
TypeScript

import { describe, expect, test } from "bun:test"
import { resolveMessageEventSessionID, resolveSessionEventID } from "./event-session-id"
describe("event session id resolvers", () => {
test("#given legacy message.part.updated properties #when resolving message session id #then part.sessionID is used", () => {
const sessionID = resolveMessageEventSessionID({
part: {
id: "part-1",
messageID: "msg-1",
sessionID: "ses-part-only",
type: "text",
text: "working",
},
})
expect(sessionID).toBe("ses-part-only")
})
test("#given message.updated info id #when resolving message session id #then message id is not mistaken for session id", () => {
const sessionID = resolveMessageEventSessionID({
info: {
id: "msg-not-session",
role: "assistant",
},
})
expect(sessionID).toBeUndefined()
})
test("#given legacy session lifecycle properties #when resolving session id #then info.id is used", () => {
const sessionID = resolveSessionEventID({
info: {
id: "ses-legacy-info-id",
},
})
expect(sessionID).toBe("ses-legacy-info-id")
})
})