fix: 收口上下文压缩生命周期边界
This commit is contained in:
@@ -674,8 +674,18 @@ export function hydrateOpenCodeSession(
|
||||
const snapshotOrder = [...next.compactionOrder];
|
||||
snapshotOrder.forEach((id, index) => {
|
||||
const snapshotEvent = next.compactionsById[id];
|
||||
const existingID = snapshotEvent.nativePartID
|
||||
? findCompactionId(current ?? state, { nativePartID: snapshotEvent.nativePartID })
|
||||
const existingID = current
|
||||
? findCompactionId(current, { id: snapshotEvent.id })
|
||||
?? (snapshotEvent.nativePartID
|
||||
? findCompactionId(current, { nativePartID: snapshotEvent.nativePartID })
|
||||
: undefined)
|
||||
?? (snapshotEvent.anchorPartID
|
||||
? [...current.compactionOrder].reverse().find((candidateID) => {
|
||||
const candidate = current.compactionsById[candidateID];
|
||||
return candidate?.anchorPartID === snapshotEvent.anchorPartID
|
||||
&& candidate.anchorMessageID === snapshotEvent.anchorMessageID;
|
||||
})
|
||||
: undefined)
|
||||
: undefined;
|
||||
const pendingID = !existingID && snapshotEvent.source === 'manual'
|
||||
? [...(current?.compactionOrder ?? [])].reverse().find((candidateID) => {
|
||||
@@ -694,10 +704,10 @@ export function hydrateOpenCodeSession(
|
||||
const preservedID = existingID ?? pendingID;
|
||||
const existing = preservedID ? current?.compactionsById[preservedID] : undefined;
|
||||
const idToUse = preservedID ?? id;
|
||||
const isLatestActive = status !== 'idle' && index === snapshotOrder.length - 1;
|
||||
const completed = existing?.status === 'completed'
|
||||
|| snapshotEvent.completedAt !== undefined
|
||||
|| !isLatestActive;
|
||||
|| status === 'idle'
|
||||
|| existing?.status !== 'running';
|
||||
if (idToUse !== id) {
|
||||
const compactionsById = { ...next.compactionsById };
|
||||
delete compactionsById[id];
|
||||
|
||||
Reference in New Issue
Block a user