fix(opencode): use chronological message boundaries (#40991)
Co-authored-by: Dax <mail@thdxr.com>
This commit is contained in:
committed by
GitHub
parent
d468201952
commit
a54a693af2
@@ -71,7 +71,8 @@ const layer = Layer.effect(
|
||||
if (session.revert?.snapshot) yield* snap.restore(session.revert.snapshot)
|
||||
yield* snap.revert(patches)
|
||||
if (rev.snapshot) rev.diff = yield* snap.diff(rev.snapshot)
|
||||
const range = all.filter((msg) => msg.info.id >= rev.messageID)
|
||||
const index = all.findIndex((msg) => msg.info.id === rev.messageID)
|
||||
const range = index < 0 ? [] : all.slice(index)
|
||||
const diffs = yield* summary.computeDiff({ messages: range })
|
||||
yield* storage.write(["session_diff", input.sessionID], diffs).pipe(Effect.ignore)
|
||||
yield* events.publish(Session.Event.Diff, { sessionID: input.sessionID, diff: diffs })
|
||||
@@ -102,20 +103,9 @@ const layer = Layer.effect(
|
||||
const sessionID = session.id
|
||||
const msgs = yield* sessions.messages({ sessionID }).pipe(Effect.orDie)
|
||||
const messageID = session.revert.messageID
|
||||
const remove = [] as SessionV1.WithParts[]
|
||||
let target: SessionV1.WithParts | undefined
|
||||
for (const msg of msgs) {
|
||||
if (msg.info.id < messageID) continue
|
||||
if (msg.info.id > messageID) {
|
||||
remove.push(msg)
|
||||
continue
|
||||
}
|
||||
if (session.revert.partID) {
|
||||
target = msg
|
||||
continue
|
||||
}
|
||||
remove.push(msg)
|
||||
}
|
||||
const index = msgs.findIndex((msg) => msg.info.id === messageID)
|
||||
const target = index < 0 ? undefined : msgs[index]
|
||||
const remove = index < 0 ? [] : msgs.slice(index + (session.revert.partID ? 1 : 0))
|
||||
for (const msg of remove) {
|
||||
yield* sessions.removeMessage({ sessionID, messageID: msg.info.id })
|
||||
}
|
||||
|
||||
@@ -703,9 +703,9 @@ const layer: Layer.Layer<
|
||||
})
|
||||
const msgs = yield* messages({ sessionID: input.sessionID })
|
||||
const idMap = new Map<string, MessageID>()
|
||||
const target = input.messageID ? msgs.findIndex((msg) => msg.info.id === input.messageID) : msgs.length
|
||||
|
||||
for (const msg of msgs) {
|
||||
if (input.messageID && msg.info.id >= input.messageID) break
|
||||
for (const msg of msgs.slice(0, target < 0 ? msgs.length : target)) {
|
||||
const newID = MessageID.ascending()
|
||||
idMap.set(msg.info.id, newID)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user