From 5fa1fd2676c6363f799926ed23466c4a1d9e1c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D1=80=D0=BE=D0=B4=D0=B8=D0=BD=20=D0=A0=D0=BE?= =?UTF-8?q?=D0=BC=D0=B0=D0=BD?= Date: Sat, 26 Sep 2026 01:16:19 +0300 Subject: [PATCH] fix: proactively check session existence before use MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Используем ctx.session.get({ sessionID }) для проверки существования сессии в OpenCode ДО отправки prompt. Если сессия удалена/невалидна — создаём новую. Убрана реактивная обработка Session.NotFoundError. --- index.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) 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}`)