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)
This commit is contained in:
parent
49dafd3c91
commit
07da116671
@ -7,6 +7,8 @@ import type { StoredToolPart, ToolResultInfo } from "./tool-part-types"
|
|||||||
import { isSqliteBackend } from "../../shared/opencode-storage-detection"
|
import { isSqliteBackend } from "../../shared/opencode-storage-detection"
|
||||||
import { log } from "../../shared/logger"
|
import { log } from "../../shared/logger"
|
||||||
|
|
||||||
|
let hasLoggedTruncateWarning = false
|
||||||
|
|
||||||
export function findToolResultsBySize(sessionID: string): ToolResultInfo[] {
|
export function findToolResultsBySize(sessionID: string): ToolResultInfo[] {
|
||||||
const messageIds = getMessageIds(sessionID)
|
const messageIds = getMessageIds(sessionID)
|
||||||
const results: ToolResultInfo[] = []
|
const results: ToolResultInfo[] = []
|
||||||
@ -51,7 +53,10 @@ export function truncateToolResult(partPath: string): {
|
|||||||
originalSize?: number
|
originalSize?: number
|
||||||
} {
|
} {
|
||||||
if (isSqliteBackend()) {
|
if (isSqliteBackend()) {
|
||||||
|
if (!hasLoggedTruncateWarning) {
|
||||||
log("[context-window-recovery] Disabled on SQLite backend: truncateToolResult")
|
log("[context-window-recovery] Disabled on SQLite backend: truncateToolResult")
|
||||||
|
hasLoggedTruncateWarning = true
|
||||||
|
}
|
||||||
return { success: false }
|
return { success: false }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { existsSync, readdirSync } from "node:fs"
|
|||||||
import { join } from "node:path"
|
import { join } from "node:path"
|
||||||
import { getOpenCodeStorageDir } from "./data-path"
|
import { getOpenCodeStorageDir } from "./data-path"
|
||||||
import { isSqliteBackend } from "./opencode-storage-detection"
|
import { isSqliteBackend } from "./opencode-storage-detection"
|
||||||
|
import { log } from "./logger"
|
||||||
|
|
||||||
const MESSAGE_STORAGE = join(getOpenCodeStorageDir(), "message")
|
const MESSAGE_STORAGE = join(getOpenCodeStorageDir(), "message")
|
||||||
|
|
||||||
@ -22,9 +23,10 @@ export function getMessageDir(sessionID: string): string | null {
|
|||||||
return sessionPath
|
return sessionPath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} catch (error) {
|
||||||
|
log(`Error reading message directory: ${error}`)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user