fix: re-read fresh messages before empty scan & dedup isRecord import

- Re-read messages from SDK after injectTextPartAsync to prevent stale
  snapshot from causing duplicate placeholder injection (P2)
- Replace local isRecord with shared import from record-type-guard (P3)
This commit is contained in:
YeonGyu-Kim 2026-02-16 15:23:43 +09:00
parent c799584e61
commit 106cd5c8b1
2 changed files with 3 additions and 5 deletions

View File

@ -91,7 +91,8 @@ export async function recoverEmptyContentMessageFromSDK(
}
}
const emptyMessageIDs = findEmptyMessagesFromSDK(messages)
const freshMessages = await readMessagesFromSDK(client, sessionID)
const emptyMessageIDs = findEmptyMessagesFromSDK(freshMessages)
for (const messageID of emptyMessageIDs) {
if (
await dependencies.replaceEmptyTextPartsAsync(

View File

@ -4,13 +4,10 @@ import type { PluginInput } from "@opencode-ai/plugin"
import type { StoredMessageMeta } from "../types"
import { getMessageDir } from "./message-dir"
import { isSqliteBackend } from "../../../shared"
import { isRecord } from "../../../shared/record-type-guard"
type OpencodeClient = PluginInput["client"]
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null
}
function normalizeSDKMessage(
sessionID: string,
value: unknown