-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: Conversation Forking - Explore 'What If?' Without Context Contamination #9792
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
base: main
Are you sure you want to change the base?
Conversation
- Add fork_conversation tool to allow forking conversations at any point - Create independent task with copied workspace files - Add fork metadata fields to HistoryItem for tracking relationships - Implement workspace copying logic with common ignore patterns - Add TaskForked event for tracking fork operations This allows users to explore 'what if' scenarios without contaminating the main conversation context, addressing issue #9790
- Add fork_conversation tool to enable forking conversations at any point - Create ForkConversationTool class to handle fork operations - Implement forkConversation method in ClineProvider for workspace copying - Add fork metadata fields to HistoryItem for tracking relationships - Update tool configurations and type definitions - Add TaskForked event for fork tracking - Update test snapshots to include new tool This feature allows users to fork their current conversation at any point, creating a new task with its own workspace copy. This enables exploration of alternative approaches without affecting the original task. Addresses #9790
Review completed. Found 2 issues that need attention:
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
| await this.updateTaskHistory(forkedHistoryItem) | ||
|
|
||
| // 7) Switch to the forked workspace | ||
| this.currentWorkspacePath = targetDirectory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workspace path is permanently changed here without any restoration mechanism. If the fork operation fails after this point (e.g., during task creation at line 3404), or even if it succeeds, the provider's workspace path remains pointing to the forked directory instead of the original. This breaks the invariant that the provider's cwd should match the actual VSCode workspace.
Consider either: (1) not changing currentWorkspacePath at all since the forked task has its own workspace path in its history item, or (2) wrapping this in a try-finally block to restore the original path, or (3) only changing it temporarily within the task creation scope.
Fix it with Roo Code or mention @roomote and request a fix.
| try { | ||
| // Try rsync first (more efficient) | ||
| await execAsync(`rsync -av ${excludeArgs} "${source}/" "${target}/"`) | ||
| this.log(`[copyWorkspaceFiles] Successfully copied workspace using rsync`) | ||
| } catch (rsyncError) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The shell command execution lacks proper error handling for common failure scenarios. The rsync command could fail due to: (1) insufficient disk space in the target directory, (2) permission denied errors when copying certain files, (3) the source directory being on a network mount that becomes unavailable, or (4) hitting filesystem limits (inode exhaustion, path length limits on Windows).
The current implementation only catches the error and re-throws it with a generic message. Consider adding specific error handling for these cases and providing actionable error messages to the user (e.g., "Insufficient disk space", "Permission denied for file X"). Also consider checking available disk space before attempting the copy.
Fix it with Roo Code or mention @roomote and request a fix.
Summary
This PR implements conversation forking functionality as requested in #9790. Users can now fork their current conversation at any point, creating a new independent task with its own workspace copy.
What's Changed
Core Implementation
fork_conversationtool to enable forking conversations at any pointForkConversationToolclass to handle fork operationsforkConversationmethod inClineProviderfor workspace copyingHistoryItemfor tracking relationshipsTaskForkedevent for fork trackingTechnical Details
How It Works
Users can fork their conversation using the
fork_conversationtool with optional parameters:message_index: The index of the message to fork from (defaults to current point)target_directory: Where to create the forked workspace (defaults to timestamped directory)Testing
Next Steps
Addresses #9790
Feedback Welcome
This is a draft PR for initial review. Looking forward to feedback on the implementation approach and any suggestions for improvements.