From 07da116671526f1c93fae534d2d209482208ef99 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Sat, 14 Feb 2026 18:53:58 +0900 Subject: [PATCH] fix: address Cubic review comments (P2/P3 issues) - Fix empty catch block in opencode-message-dir.ts (P2) - Add log deduplication for truncateToolResult to prevent spam (P3) --- .../tool-result-storage.ts | 7 ++++++- src/shared/opencode-message-dir.ts | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/hooks/anthropic-context-window-limit-recovery/tool-result-storage.ts b/src/hooks/anthropic-context-window-limit-recovery/tool-result-storage.ts index b171132e..c1af7df6 100644 --- a/src/hooks/anthropic-context-window-limit-recovery/tool-result-storage.ts +++ b/src/hooks/anthropic-context-window-limit-recovery/tool-result-storage.ts @@ -7,6 +7,8 @@ import type { StoredToolPart, ToolResultInfo } from "./tool-part-types" import { isSqliteBackend } from "../../shared/opencode-storage-detection" import { log } from "../../shared/logger" +let hasLoggedTruncateWarning = false + export function findToolResultsBySize(sessionID: string): ToolResultInfo[] { const messageIds = getMessageIds(sessionID) const results: ToolResultInfo[] = [] @@ -51,7 +53,10 @@ export function truncateToolResult(partPath: string): { originalSize?: number } { if (isSqliteBackend()) { - log("[context-window-recovery] Disabled on SQLite backend: truncateToolResult") + if (!hasLoggedTruncateWarning) { + log("[context-window-recovery] Disabled on SQLite backend: truncateToolResult") + hasLoggedTruncateWarning = true + } return { success: false } } diff --git a/src/shared/opencode-message-dir.ts b/src/shared/opencode-message-dir.ts index 86bdb220..7e9e94dc 100644 --- a/src/shared/opencode-message-dir.ts +++ b/src/shared/opencode-message-dir.ts @@ -2,6 +2,7 @@ import { existsSync, readdirSync } from "node:fs" import { join } from "node:path" import { getOpenCodeStorageDir } from "./data-path" import { isSqliteBackend } from "./opencode-storage-detection" +import { log } from "./logger" const MESSAGE_STORAGE = join(getOpenCodeStorageDir(), "message") @@ -22,9 +23,10 @@ export function getMessageDir(sessionID: string): string | null { return sessionPath } } - } catch { - return null - } +} catch (error) { + log(`Error reading message directory: ${error}`) + return null +} return null } \ No newline at end of file