feat: add workspace rewind checkpoints - #2785
Conversation
🦋 Changeset detectedLatest commit: 90f2c2d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 90f2c2d890
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const availability = await resolveUndoAvailability(host); | ||
| const checkpointCount = await store.availableCount(); | ||
| const maxCount = Math.min(availability.maxCount, checkpointCount); |
There was a problem hiding this comment.
Keep rewind checkpoints aligned with mid-turn steers
This assumes the newest workspace checkpoints line up one-for-one with the newest undo anchors, but the streaming steerMessage() path still appends user transcript entries and calls session.steer directly without capturing a checkpoint. In a session with prompt A checkpointed and then a mid-turn steer B, /rewind 1 can offer B while prepareRewind(1) applies A's before-image and undoHistory(1) only removes B, restoring files too far back. Capture or invalidate checkpoints for the streaming steer path before using checkpointCount as an alignment guarantee.
Useful? React with 👍 / 👎.
|
Thank you for your interest in contributing to Kimi Code. For new features, please discuss first. We are not currently accepting pull requests for new features. |
Related Issue
Resolve #108
Problem
/undorestores conversation context, but files written by tool calls remain changed. Users therefore cannot safely rewind a turn as a unit, especially when the workspace is not a Git repository or already contains unrelated uncommitted work.What changed
/rewind [count], which previews and restores both conversation history and workspace files to their state before the selected prompt./undocontext-only while discarding the corresponding filesystem checkpoints so the two histories cannot become misaligned.The checkpoint store retains at most 20 turns and enforces limits of 50,000 files, 512 MiB per checkpoint, and 64 MiB per file. A failed checkpoint capture does not block the prompt, but it invalidates rewind alignment so stale state cannot be applied.
Verification
pnpm sherifpassed.The full TUI message-flow suite otherwise reported six existing feedback attachment/media failures; the same failure was reproduced from an independent clean worktree without this change.
Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.