mirror of
https://github.com/anomalyco/opencode.git
synced 2026-02-01 22:48:16 +00:00
fix: resolve broken forked sessions with compactions due to missing parent-child message references (#6445)
This commit is contained in:
@@ -151,12 +151,19 @@ export namespace Session {
|
||||
directory: Instance.directory,
|
||||
})
|
||||
const msgs = await messages({ sessionID: input.sessionID })
|
||||
const idMap = new Map<string, string>()
|
||||
|
||||
for (const msg of msgs) {
|
||||
if (input.messageID && msg.info.id >= input.messageID) break
|
||||
const newID = Identifier.ascending("message")
|
||||
idMap.set(msg.info.id, newID)
|
||||
|
||||
const parentID = msg.info.role === "assistant" && msg.info.parentID ? idMap.get(msg.info.parentID) : undefined
|
||||
const cloned = await updateMessage({
|
||||
...msg.info,
|
||||
sessionID: session.id,
|
||||
id: Identifier.ascending("message"),
|
||||
id: newID,
|
||||
...(parentID && { parentID }),
|
||||
})
|
||||
|
||||
for (const part of msg.parts) {
|
||||
|
||||
Reference in New Issue
Block a user