fix(chat): preserve fresh compaction state across reconnect history
This commit is contained in:
@@ -68,3 +68,17 @@ test("authoritative history cannot erase fresh compaction replayed after reconne
|
||||
assert.deepEqual(synced.messages,[{id:"native-history",role:"user",parts:[]}]);
|
||||
assert.equal(historyResync(reset,{messages:[]},{preserveActivity:true}).compaction,null);
|
||||
});
|
||||
|
||||
test("native turn identity protects compaction and allows the reattached turn to settle", () => {
|
||||
const original={...newChatThread("session-1"),running:true,nativeTurnId:"new-turn"};
|
||||
const old={...compact("running"),native_turn_id:"old-turn"};
|
||||
assert.equal(applyChatEvent(original,old,100),original);
|
||||
const reset=resumedThread(original);
|
||||
assert.equal(reset.nativeTurnId,"");
|
||||
const replay=applyChatEvent(reset,{...compact("running"),native_turn_id:"current-turn"},200);
|
||||
assert.equal(replay.nativeTurnId,"current-turn");
|
||||
assert.equal(applyChatEvent(replay,{...compact("completed"),native_turn_id:"old-turn"},300),replay);
|
||||
const ended=applyChatEvent(replay,{kind:"step",step:{status:"ended",turn_id:"current-turn"}},400);
|
||||
assert.equal(ended.running,false);
|
||||
assert.equal(ended.compaction,null);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user