fix: enforce message snapshot invariants
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import { Context, Service } from 'cordis'
|
||||
import { Session, type SessionId } from '@deepseek-ai/dsh-session'
|
||||
import { Session, snapshotSessionEvent, type SessionId } from '@deepseek-ai/dsh-session'
|
||||
import { foldSessionTitle } from '@deepseek-ai/dsh-session-title'
|
||||
import type { SessionTitleSnapshot } from '@deepseek-ai/dsh-session-title'
|
||||
import type {
|
||||
@@ -45,7 +45,6 @@ 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'
|
||||
@@ -147,7 +146,7 @@ export abstract class SessionQueryService extends Service {
|
||||
new Session(sessionId, loaded.events, loaded.header)
|
||||
return {
|
||||
session: structuredClone(loaded.header),
|
||||
events: loaded.events.map(snapshotEvent),
|
||||
events: loaded.events.map(snapshotSessionEvent),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,9 +330,11 @@ 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 targetSnapshot = snapshotSessionEvent(target)
|
||||
const events = loaded.events.slice(startSeq, endSeq + 1)
|
||||
.map(event => event === target ? targetSnapshot : snapshotEvent(event))
|
||||
.map(event => event === target
|
||||
? targetSnapshot
|
||||
: snapshotSessionEvent(event))
|
||||
return {
|
||||
session: structuredClone(loaded.header),
|
||||
target: targetSnapshot,
|
||||
|
||||
Reference in New Issue
Block a user