Skip to content

fix(checkpoint): ignore out-of-workspace rewind snapshots#4274

Open
GTC2080 wants to merge 1 commit into
esengine:main-v2from
GTC2080:GTC/fix-code-only-rewind
Open

fix(checkpoint): ignore out-of-workspace rewind snapshots#4274
GTC2080 wants to merge 1 commit into
esengine:main-v2from
GTC2080:GTC/fix-code-only-rewind

Conversation

@GTC2080

@GTC2080 GTC2080 commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Closes #4246

Problem

Code-only rewind can fail on Windows with an error like rewind code: checkpoint path ... escapes workspace ... when a checkpoint contains a path outside the active project root. In that state the desktop shows the rewind action, but the restore aborts before the user's project files are rolled back.

Root cause

Checkpoint snapshots recorded writer-preview paths verbatim. In project tabs, that allowed absolute paths outside WorkspaceRoot (for example Reasonix-managed project or memory files) to be persisted beside normal workspace edits. RestoreCode later rejected those paths with the workspace escape guard, which is safe but made one out-of-scope snapshot fail the whole code rewind. Existing sessions could keep hitting the same failure because the bad path was already persisted.

Fix

  • Normalize in-workspace snapshot paths to workspace-relative slash paths before storing them.
  • Skip new snapshots whose preview path is outside the checkpoint workspace root.
  • Keep the restore-time escape guard, but skip legacy out-of-workspace checkpoint entries instead of failing the entire restore.
  • Switch the root containment check to filepath.Rel, avoiding fragile string-prefix comparisons.

Validation

  • go test ./internal/checkpoint -run 'TestRestoreSkipsPersistedPathEscape|TestSnapshotSkipsOutsideWorkspaceWithoutBreakingRestore|TestSnapshotStoresWorkspaceRelativePaths' -count=1
  • Clean detached worktree at this commit:
    • gofmt -l .
    • git diff --check HEAD^ HEAD
    • go test ./...
    • go test ./... in desktop/
    • go vet ./...
    • go vet ./... in desktop/
    • go build ./...
    • go build ./... in desktop/
    • npm run test:all in desktop/frontend
    • npm run build in desktop/frontend

@github-actions github-actions Bot added the v2 Go rewrite (1.x) — main-v2 branch, active development label Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 回滚代码失败

1 participant