fix: proactively check session existence before use
Используем ctx.session.get({ sessionID }) для проверки существования
сессии в OpenCode ДО отправки prompt. Если сессия удалена/невалидна —
создаём новую. Убрана реактивная обработка Session.NotFoundError.
This commit is contained in:
parent
c95ac899d2
commit
5fa1fd2676
11
index.ts
11
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}`)
|
||||
|
|
|
|||
Loading…
Reference in New Issue