Fix revert checkpoint ordering and checkpoint hydration retry loop

- Swap filesystem restore and thread rollback order in revertToCheckpoint
  so a filesystem restore failure doesn't leave the thread irreversibly
  rolled back while the UI still shows pre-revert state.

- Stop deleting the dedup ref key on ensureSession failure in the
  checkpoint hydration effect, preventing an unbounded retry loop when
  the backend is unreachable.
This commit is contained in:
Cursor Agent committed 2026-02-18 08:43:24 +00:00
1 parent 92e6389519
commit 5a6696b233
2 files changed
+17 -9

No files matched your search

+9 -6
View File
@@ -330,12 +330,6 @@ export class ProviderManager extends EventEmitter<ProviderManagerEvents> {
}
}
const requestedRollbackTurns = currentTurnCount - input.turnCount;
const afterSnapshot =
requestedRollbackTurns > 0
? await this.codex.rollbackThread(input.sessionId, requestedRollbackTurns)
: beforeSnapshot;
if (checkpointCwd) {
const restored = await this.filesystemCheckpointStore.restoreCheckpoint({
cwd: checkpointCwd,
@@ -347,6 +341,15 @@ export class ProviderManager extends EventEmitter<ProviderManagerEvents> {
`Filesystem checkpoint is unavailable for turn ${input.turnCount} in thread ${beforeSnapshot.threadId}.`,
);
}
}
const requestedRollbackTurns = currentTurnCount - input.turnCount;
const afterSnapshot =
requestedRollbackTurns > 0
? await this.codex.rollbackThread(input.sessionId, requestedRollbackTurns)
: beforeSnapshot;
if (checkpointCwd) {
await this.filesystemCheckpointStore.pruneAfterTurn({
cwd: checkpointCwd,
threadId: afterSnapshot.threadId,
+8 -3
View File
@@ -960,9 +960,14 @@ export default function ChatView() {
}
checkpointHydrationSessionRequestRef.current.add(requestKey);
setThreadError(activeThreadId, null);
void ensureSession().finally(() => {
checkpointHydrationSessionRequestRef.current.delete(requestKey);
});
void ensureSession().then(
() => {
checkpointHydrationSessionRequestRef.current.delete(requestKey);
},
() => {
// Keep the ref key so the effect does not retry indefinitely on failure.
},
);
}, [
activeThreadId,
activeThreadRuntimeId,