Wire up agent worktree creation, cleanup, and integration tests - #49145
Closed
rtfeldman wants to merge 8 commits into
Closed
Wire up agent worktree creation, cleanup, and integration tests#49145rtfeldman wants to merge 8 commits into
rtfeldman wants to merge 8 commits into
Conversation
Add remove_worktree() and rename_worktree() to the GitRepository trait with RealGitRepository implementations that shell out to git worktree remove/move. Implement all 4 worktree methods (worktrees, create_worktree, remove_worktree, rename_worktree) on FakeGitRepository backed by FakeGitRepositoryState, with simulated_create_worktree_error for test-time fault injection. Add set_create_worktree_error() helper on FakeFs. Tests: test_parse_worktrees_from_str, test_create_and_list_worktrees, test_remove_worktree, test_remove_worktree_force, test_rename_worktree, test_create_worktree (real git), test_fake_worktree_lifecycle (fake).
Add GitRemoveWorktree and GitRenameWorktree proto messages (envelope fields 423, 424) with request handlers in GitStore for both local and remote execution. Register RPC handlers in collab. Tests: test_repository_remove_worktree_local, test_repository_rename_worktree_local, test_repository_remove_worktree_remote_roundtrip, test_repository_rename_worktree_remote_roundtrip.
Add agent_worktree_directory to GitSettings for configuring where agent worktrees are stored (default: Zed data dir). Remove Copy derive from GitSettings/GitContentSettings (incompatible with String field) and fix downstream .as_ref().unwrap() call sites. Define AgentGitWorktreeInfo (branch, worktree_path, base_ref) and add it to DbThread + DbThreadMetadata for persistence and session list display. Tests: test_git_worktree_info_roundtrip, test_session_list_includes_worktree_meta.
… main Restore disable_ai field on ProjectSettingsContent and search_on_input on SearchSettings. Add .as_ref() before .unwrap() on Option<GitSettings> in project_panel and outline_panel since GitSettings no longer derives Copy.
Add 'Start Thread In...' dropdown to the agent panel toolbar, gated behind AgentV2FeatureFlag, with 'Local Project' and 'New Worktree' options. The 'New Worktree' option is disabled when there's no git repo or in collab. Add WorktreeCreationStatus enum for displaying creation progress/errors. Render worktree branch labels on ACP history rows using thread metadata. Tests: test_worktree_branch_from_meta, test_history_row_displays_worktree.
… into richard/ai-35-agent-worktree-orchestration-cleanup-lifecycle
Implement the full worktree creation flow: on NewThread with NewWorktree target, create a git worktree, trust the path, open it as a new workspace in the MultiWorkspace, and start an agent thread there. Roll back the git worktree if any post-creation step fails. Implement cleanup: when a worktree thread is deleted, remove the workspace from MultiWorkspace and clean up the git worktree. Support both single thread and bulk deletion. Tests: test_new_worktree_thread_creation_flow, test_thread_target_local_project, test_create_agent_worktree_failure, test_create_agent_worktree_rollback, test_cleanup_agent_worktree, plus branch name and path resolution unit tests.
- Add ToggleAgentPane action to zed_actions::agent module - Fix borrow checker: clone active_thread entity before updating - Fix type mismatch: use .map() instead of .and_then() for title_editor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wire up the full agent worktree orchestration layer: creation flow, failure handling with rollback, and cleanup lifecycle.
Creation flow
When a user starts a new thread with the NewWorktree target:
GitWorktreeStoreproto APIMultiWorkspaceIf any post-creation step fails, the git worktree is rolled back automatically.
Cleanup lifecycle
When a worktree thread is deleted:
MultiWorkspaceSupports both single thread and bulk deletion.
Tests
13 new tests covering the full lifecycle:
test_new_worktree_thread_creation_flowtest_thread_target_local_projecttest_create_agent_worktree_failuretest_create_agent_worktree_rollbacktest_cleanup_agent_worktreeDependencies
This PR depends on all 4 prior PRs in the stacked diff series:
Once PRs 1-4 land, this PR's diff will reduce to just the orchestration layer.
Closes AI-35
Release Notes: