From ef65f405e8c7715d293f79847df58772d10c65c6 Mon Sep 17 00:00:00 2001 From: Kenny Date: Wed, 14 Jan 2026 21:17:41 -0500 Subject: [PATCH] fix: clean up session cursor state on session deletion Add resetMessageCursor call in session.deleted handler to prevent unbounded memory growth from orphaned cursor entries. --- src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index c4f3bb25..9f4871ef 100644 --- a/src/index.ts +++ b/src/index.ts @@ -73,7 +73,7 @@ import { BackgroundManager } from "./features/background-agent"; import { SkillMcpManager } from "./features/skill-mcp-manager"; import { initTaskToastManager } from "./features/task-toast-manager"; import { type HookName } from "./config"; -import { log, detectExternalNotificationPlugin, getNotificationConflictWarning } from "./shared"; +import { log, detectExternalNotificationPlugin, getNotificationConflictWarning, resetMessageCursor } from "./shared"; import { loadPluginConfig } from "./plugin-config"; import { createModelCacheState, getModelLimit } from "./plugin-state"; import { createConfigHandler } from "./plugin-handlers"; @@ -445,6 +445,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => { } if (sessionInfo?.id) { clearSessionAgent(sessionInfo.id); + resetMessageCursor(sessionInfo.id); firstMessageVariantGate.clear(sessionInfo.id); await skillMcpManager.disconnectSession(sessionInfo.id); await lspManager.cleanupTempDirectoryClients();