diff --git a/index.ts b/index.ts index 29beaee..687c67e 100644 --- a/index.ts +++ b/index.ts @@ -144,6 +144,17 @@ async function runPlugin(ctx: any, options: any, dataDir: string) { let opencodeSessionId = session.opencodeSessionId + // If we have a session ID from the map, verify it exists in OpenCode + if (opencodeSessionId) { + try { + await ctx.session.get({ sessionID: opencodeSessionId }) + log(`Using existing OpenCode session ${opencodeSessionId}`) + } catch (getErr: any) { + log(`Session ${opencodeSessionId} not found in OpenCode, creating new one`) + opencodeSessionId = "" + } + } + // If no session ID yet, create one if (!opencodeSessionId) { log(`Creating new OpenCode session for ${roomId}:${threadRootId}`)