fix(client): address conversation assembly review findings

This commit is contained in:
imccyu
2026-08-09 17:02:20 +08:00
parent 522acc7432
commit 8723a0e15f
7 changed files with 128 additions and 20 deletions
@@ -238,7 +238,7 @@ export class ConversationNodeAssembler {
}
this.applyPendingMatches(pending, affected)
this.replayContexts(affected)
if ((fresh.length > 0 || previousHasMore !== hasMore) && this.replayDependencies()) {
if ((this.revised.size > 0 || previousHasMore !== hasMore) && this.replayDependencies()) {
publication = 'immediate'
}
if (changedLocations.size > 0) publication = 'immediate'
@@ -563,18 +563,18 @@ export class ConversationNodeAssembler {
private replayRevisedDependents(): boolean {
const pending = [...this.revised]
const replayed = new Set<InternalContext>()
const affected = new Set<InternalContext>()
for (let index = 0; index < pending.length; index++) {
const dependency = pending[index]
if (dependency === undefined) continue
for (const dependent of this.dependents.get(dependency.key) ?? []) {
if (replayed.has(dependent)) continue
replayed.add(dependent)
this.replayContext(dependent)
if (affected.has(dependent)) continue
affected.add(dependent)
pending.push(dependent)
}
}
return replayed.size > 0
this.replayContexts(affected)
return affected.size > 0
}
private readerFor(
@@ -344,6 +344,7 @@ export class Session implements SessionFace {
// §D.2 continuity assertion: on violation drop the page fail-soft rather than render an out-of-order stream.
console.error(`[web-runtime] history page discontinuous: tail seq ${tail?.event.seq} vs baseSeq ${this.baseSeq}`)
this.hasMore = false
this.conversation.prepend([], false)
return
}
this.events = [...older.map(e => e.event), ...this.events]