fix(webui): settle completed turns across reconnect paths

Separate named completion facts from history adoption, preserve newer and anonymous activity, and keep one mounted whole-snapshot adopter. Unify explicit-ID lifecycle/content closure without discarding uncovered content.

Cover the real client/hooks reconnect and selection races, await asynchronous browser fixture startup, and retain current-policy bounded TLC models and missing-evidence limits. Archive historical/candidate verification separately.
This commit is contained in:
chengyongru authored and chengyongru committed 2026-11-17 17:59:01 +08:00
1 parent 9e499ad539
commit 53a556585e
34 files changed
+1891 -46

No files matched your search

+2 -3
View File
@@ -92,7 +92,7 @@ function makeClient() {
getRunGeneration: lifecycle.getRunGeneration.bind(lifecycle),
canReconcileCanonicalCompletion,
reconcileCanonicalCompletion,
settleFragmentRunLifecycle: vi.fn(lifecycle.settleFragmentRunLifecycle.bind(lifecycle)),
settleCompletedRunLifecycle: vi.fn(lifecycle.settleCompletedRunLifecycle.bind(lifecycle)),
fenceCanonicalCompletedTurns: lifecycle.fenceCanonicalCompletedTurns.bind(lifecycle),
getGoalState: lifecycle.getGoalState.bind(lifecycle),
onTranscript: lifecycle.onTranscript.bind(lifecycle),
@@ -266,9 +266,8 @@ function publishReconnectCompletion(
const generation = client.getRunGeneration(chatId);
const { completedTurnIds, snapshot } = persistedCanonicalRunState(body);
expect(client.canReconcileCanonicalCompletion(chatId, generation, completedTurnIds, snapshot)).toBe(true);
// useReconnectRuns publishes synchronously before settling/fencing the ledger.
// A mounted transcript takes over reconciliation from the recovery reader.
webuiThreadCache.set(`websocket:${chatId}`, body);
expect(client.reconcileCanonicalCompletion(chatId, generation, completedTurnIds, snapshot)).toBe(true);
}
function httpJson(body: unknown) {