Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkpoint service #626

Merged
merged 1 commit into from
Feb 8, 2025
Merged

Checkpoint service #626

merged 1 commit into from
Feb 8, 2025

Conversation

cte
Copy link
Collaborator

@cte cte commented Jan 28, 2025

Description

Currently Cline has a nice "checkpoints" feature (see demo) that allows you to revert your VSCode workspace to a point in time in the chat history. It does this by creating a "shadow" repository that is completely isolated from the current repo (if any).

An alternative approach that I'm exploring here is to use a separate branch to more space efficiently store checkpoints that can be restored using git restore.

I consulted o1 Pro about the differences between these approaches, and here's what it thinks:

  1. Quick Summary of the Approaches

“Hidden/Worktree Branch” in the Same Repo:
Pros
• Integrates directly with the user’s existing repository, so merges, logs, and reverts can all happen in one place.
• No duplication or copying files out to another folder—Git takes care of the branching/worktree logic.
• If the user is Git-savvy, they can see the AI commits or bring them into main with a normal merge.

Cons
• Potential to “pollute” or complicate the user’s main repo with ephemeral commits unless carefully managed (hidden branch, separate worktree).
• If you do the stash/unstash approach, you risk conflicts and stash merges in the user’s main environment.

“Shadow Repo” (Entirely Separate .git):
Pros
• Completely isolates the user’s main repository from the AI checkpoint logic. There’s zero chance of messing up or cluttering their primary .git or branches.
• You don’t need the user’s main workspace to be under Git at all. Your extension has full control over the “shadow” .git.
• It can be simpler in the sense that you own the entire flow: no stashing, no merges to user branches, no prying into user commits.

Cons
• You’re effectively maintaining two parallel copies of the user’s code. You must keep them in sync if your AI or the user wants consistent states.
• Reverting from a checkpoint means copying those versions back into the user’s workspace. If the user made manual edits in the meantime, you might end up overwriting them or writing a custom merge routine.
• It’s not integrated with the user’s normal Git history. They won’t see these AI commits with git log in the main project.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Checklist:

  • My code follows the patterns of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

Additional context

Related Issues

Reviewers


Important

Introduces CheckpointService to manage VSCode workspace checkpoints using Git, with comprehensive tests for various scenarios.

  • New Feature:
    • Introduces CheckpointService in CheckpointService.ts to manage VSCode workspace checkpoints using Git.
    • Uses a hidden branch to store checkpoints, allowing restoration via git restore.
    • Handles stashing and applying changes, including untracked files.
  • Behavior:
    • saveCheckpoint() stashes changes, resets hidden branch, applies stash, and commits.
    • restoreCheckpoint() restores workspace to a specified checkpoint.
    • Throws error if not on the main branch during operations.
  • Testing:
    • Comprehensive tests in CheckpointService.test.ts for creating, restoring, and handling edge cases like untracked files and branch mismatches.
    • Tests ensure correct diff generation, file state preservation, and error handling.

This description was created by Ellipsis for 2bff829. It will automatically update as commits are pushed.

Copy link

changeset-bot bot commented Jan 28, 2025

⚠️ No Changeset found

Latest commit: 2bff829

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@cte cte force-pushed the cte/checkpoints branch 3 times, most recently from 54c28a9 to 2eb3637 Compare February 4, 2025 23:01
@cte cte changed the title [WIP] Checkpoints [WIP] Checkpoints service Feb 4, 2025
@cte cte marked this pull request as ready for review February 5, 2025 00:14
@cte cte changed the title [WIP] Checkpoints service Checkpoints service Feb 5, 2025
@cte cte changed the title Checkpoints service Checkpoint service Feb 5, 2025
@cte cte mentioned this pull request Feb 5, 2025
19 tasks
@cte cte force-pushed the cte/checkpoints branch 2 times, most recently from 6cac8ce to 21724e2 Compare February 5, 2025 07:08
@RooVetGit RooVetGit deleted a comment from ellipsis-dev bot Feb 5, 2025
@RooVetGit RooVetGit deleted a comment from ellipsis-dev bot Feb 5, 2025
Comment on lines +34 to +41
* Saving a checkpoint:
* - Current changes are stashed (including untracked files).
* - The hidden branch is reset to match main.
* - Stashed changes are applied and committed as a checkpoint on the hidden
* branch.
* - We return to the main branch with the original state restored.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this cause any kind of visible flicker or file change event to be emitted? Just wondering about any potential impact on things that watch for file changes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question; we should check for this while we dogfood the feature.

@cte cte force-pushed the cte/checkpoints branch from c66c377 to 6718255 Compare February 7, 2025 07:53
@RooVetGit RooVetGit deleted a comment from ellipsis-dev bot Feb 7, 2025
@cte cte force-pushed the cte/checkpoints branch from 51a32b9 to 2bff829 Compare February 8, 2025 06:24
@cte cte merged commit 910bdf1 into main Feb 8, 2025
6 checks passed
@cte cte deleted the cte/checkpoints branch February 8, 2025 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants