From 19f504fcfac710388f4f8a340b84bbdf588b174e Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Sun, 28 Dec 2025 14:34:03 +0900 Subject: [PATCH] fix(session-recovery): improve empty message index search with expanded range MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Expand the search range when finding empty messages by index to better handle API index vs storage index mismatches. This increases robustness when searching for messages to sanitize with more fallback indices. 🤖 Generated with assistance of OhMyOpenCode (https://github.com/code-yeongyu/oh-my-opencode) --- src/hooks/session-recovery/storage.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/hooks/session-recovery/storage.ts b/src/hooks/session-recovery/storage.ts index 17be4d3..7b00ffc 100644 --- a/src/hooks/session-recovery/storage.ts +++ b/src/hooks/session-recovery/storage.ts @@ -135,7 +135,16 @@ export function findEmptyMessageByIndex(sessionID: string, targetIndex: number): const messages = readMessages(sessionID) // API index may differ from storage index due to system messages - const indicesToTry = [targetIndex, targetIndex - 1, targetIndex - 2] + const indicesToTry = [ + targetIndex, + targetIndex - 1, + targetIndex + 1, + targetIndex - 2, + targetIndex + 2, + targetIndex - 3, + targetIndex - 4, + targetIndex - 5, + ] for (const idx of indicesToTry) { if (idx < 0 || idx >= messages.length) continue