fix: complete immutable message migration

This commit is contained in:
_Kerman
2026-07-28 14:15:23 +08:00
parent f5ec71f5b1
commit 350c296cff
27 changed files with 231 additions and 60 deletions

View File

@@ -45,6 +45,7 @@ import {
materializeSessionResultFilters,
} from './filters.ts'
import * as tracing from './tracing.ts'
import { snapshotEvent } from './snapshot.ts'
export type * from './types.ts'
export { SessionSearchCursor } from './cursor.ts'
@@ -146,7 +147,7 @@ export abstract class SessionQueryService extends Service {
new Session(sessionId, loaded.events, loaded.header)
return {
session: structuredClone(loaded.header),
events: loaded.events.map(event => structuredClone(event)),
events: loaded.events.map(snapshotEvent),
}
}
@@ -330,10 +331,13 @@ export abstract class SessionQueryService extends Service {
}
const startSeq = Math.max(0, seq - before)
const endSeq = Math.min(loaded.events.length - 1, seq + after)
const targetSnapshot = snapshotEvent(target)
const events = loaded.events.slice(startSeq, endSeq + 1)
.map(event => event === target ? targetSnapshot : snapshotEvent(event))
return {
session: loaded.header,
target,
events: loaded.events.slice(startSeq, endSeq + 1),
session: structuredClone(loaded.header),
target: targetSnapshot,
events,
startSeq,
endSeq,
}