Wire up worktree archival on thread archive and restoration on unarchive - #53215
Merged
Merged
Conversation
…ations Extend the git API with several new capabilities needed for worktree archival and restoration: - Add allow_empty flag to CommitOptions for creating WIP marker commits - Change create_worktree to accept Option<String> branch, enabling detached worktree creation when None is passed - Add head_sha() to read the current HEAD commit hash - Add update_ref() and delete_ref() for managing git references - Add stage_all_including_untracked() to stage everything before a WIP commit - Implement all new operations in FakeGitRepository with functional commit history tracking, reset support, and ref management - Update existing call sites for the new CommitOptions field and create_worktree signature
rtfeldman
force-pushed
the
persist-worktree-3-wiring
branch
3 times, most recently
from
April 6, 2026 14:35
1657263 to
4266294
Compare
rtfeldman
force-pushed
the
persist-worktree-2-archived-model
branch
from
April 6, 2026 14:51
7f05a6c to
33b4871
Compare
rtfeldman
force-pushed
the
persist-worktree-3-wiring
branch
from
April 6, 2026 14:52
4ce9048 to
0c1eb65
Compare
rtfeldman
force-pushed
the
persist-worktree-3-wiring
branch
10 times, most recently
from
April 6, 2026 18:27
253b49a to
a37b7df
Compare
This argument already gets added when calling git_binary.run()
Now creating a worktree from a detached head also has remote support
This goes against what git does internally and could cause testing bugs in the future
GitStore::stage_all already does everything this method does and updates pending_ops as well. So I'm removing this method to avoid a potential foot gun in our codebase
- resolve_commit on Repository entity: wraps revparse_batch to check if a commit SHA exists in the repo. Used during restore to verify original_commit_hash is present before attempting recovery. - repair_worktrees on GitRepository trait + RealGitRepository (runs git worktree repair) and FakeGitRepository (no-op). Used during restore when a worktree directory exists on disk but may not be in git's worktree metadata. - repair_worktrees wrapper on Repository entity.
rtfeldman
force-pushed
the
persist-worktree-2-archived-model
branch
from
April 6, 2026 20:34
33b4871 to
c2284f4
Compare
rtfeldman
force-pushed
the
persist-worktree-3-wiring
branch
from
April 6, 2026 20:34
a37b7df to
8456bbd
Compare
Adapted archive_thread to main's new structure (workspace_to_remove + archive_and_activate pattern) while preserving our fix: activating the target workspace in MultiWorkspace to prevent rebuild_contents from emitting a spurious '+ New Thread' entry on the linked worktree. Removed orphaned ArchiveStatus enum and archive_worktree function body that were superseded by main's workspace removal approach.
Rewire sidebar thread archival to start the in-flight worktree archive task again, so archiving the last thread for a linked worktree removes the worktree from disk instead of only updating sidebar state. This also makes root planning and worktree-state persistence more robust when a live linked-worktree repository handle is not already available, and strengthens the sidebar test to assert the worktree directory is actually deleted.
Restore smol::channel for the DB operations queue and archive cancellation signal, reverting the futures::channel change from e1c73e7. smol channels provide bounded backpressure and are a better fit here.
rtfeldman
marked this pull request as ready for review
April 8, 2026 17:58
mikayla-maki
approved these changes
Apr 8, 2026
rtfeldman
added a commit
that referenced
this pull request
Apr 8, 2026
…root (#53443) In `update_git_repositories`, a `.git` path outside the worktree root can occur legitimately when `.git` is a gitfile (as in linked worktrees and submodules) pointing to a directory in the parent repo. Previously this triggered a `debug_panic!`, crashing debug builds. Now we skip the path with a `debug_assert!` that it is indeed a file (not a directory), so a genuine `.git` directory outside the worktree root would still be caught in debug builds. (No release notes because this is extremely hard to encounter until #53215 lands) Release Notes: - N/A
lukemarsden
added a commit
to helixml/zed
that referenced
this pull request
Apr 9, 2026
Merge upstream zed-industries/zed main branch (7544515) into Helix fork. Notable upstream changes: - Agent V2 feature flag removal (zed-industries#52792) - Sidebar/MultiWorkspace rework (zed-industries#53096, zed-industries#53032, zed-industries#53267) - Agent panel git worktree/branch pickers (zed-industries#52979) - Language model crate refactor (zed-industries#53270) - Notification panel removal (zed-industries#50204) - Subagent permission requests (zed-industries#53428) - Worktree archival on thread archive (zed-industries#53215) - Agent layout onboarding (zed-industries#52940) - AuthRequired status for context servers (zed-industries#53396) Conflict resolutions: - crates/zed/Cargo.toml: kept external_websocket_sync feature + upstream track-project-leak - crates/agent_ui/Cargo.toml: kept external_websocket_sync feature + upstream audio feature - crates/agent_ui/src/agent_panel.rs: preserved all cfg-gated WebSocket blocks, migrated should_render_onboarding to should_render_new_user_onboarding, added upstream agent_layout_onboarding - crates/agent/src/tools/context_server_registry.rs: added AuthRequired to match arm, preserved pending_tool_loads tracking - crates/workspace/src/workspace.rs: added new upstream re-exports - crates/title_bar/src/title_bar.rs: preserved Helix connection status indicator, dropped always-hidden onboarding banner (upstream removed it too) - crates/recent_projects/src/dev_container_suggest.rs: kept suggest_dev_container check + upstream cli_auto_open - .github/workflows, assets/keymaps, assets/settings, editor, multi_workspace: took upstream Spec-Ref: helix-specs@e637a591b:001723_merge-latest-zed
github-actions Bot
pushed a commit
that referenced
this pull request
Apr 9, 2026
…root (#53443) In `update_git_repositories`, a `.git` path outside the worktree root can occur legitimately when `.git` is a gitfile (as in linked worktrees and submodules) pointing to a directory in the parent repo. Previously this triggered a `debug_panic!`, crashing debug builds. Now we skip the path with a `debug_assert!` that it is indeed a file (not a directory), so a genuine `.git` directory outside the worktree root would still be caught in debug builds. (No release notes because this is extremely hard to encounter until #53215 lands) Release Notes: - N/A
zed-zippy Bot
added a commit
that referenced
this pull request
Apr 9, 2026
…root (#53443) (cherry-pick to preview) (#53565) Cherry-pick of #53443 to preview ---- In `update_git_repositories`, a `.git` path outside the worktree root can occur legitimately when `.git` is a gitfile (as in linked worktrees and submodules) pointing to a directory in the parent repo. Previously this triggered a `debug_panic!`, crashing debug builds. Now we skip the path with a `debug_assert!` that it is indeed a file (not a directory), so a genuine `.git` directory outside the worktree root would still be caught in debug builds. (No release notes because this is extremely hard to encounter until #53215 lands) Release Notes: - N/A Co-authored-by: Richard Feldman <richard@zed.dev>
rtfeldman
added a commit
that referenced
this pull request
Apr 10, 2026
…ive (#53215) Connect the git API and archived worktree data model to the sidebar's archive/unarchive flow: - Add `thread_worktree_archive` module: orchestrates the full archive cycle (WIP commits, DB records, git refs, worktree deletion) and restore cycle (detached worktree creation, reset to recover staged/unstaged state, branch restoration) - Integrate into sidebar: `archive_thread` now persists worktree state before cleanup; `activate_archived_thread` restores worktrees via git with targeted path replacement for multi-root threads - Add pending worktree restore UI state with spinner and cancel button - Show toast on restore failure instead of silent log - Switch to surviving workspace when archiving active thread whose workspace will be deleted - Deserialize persisted `project_group_keys` on window restore - Guard `cleanup_empty_workspaces` against dropped entities - Await rollback DB operations instead of fire-and-forget Part 3 of 3 in the persist-worktree stack. Stacked on #53214. This wires up parts 1 and 2. Release Notes: - Added worktree state preservation when archiving agent threads, automatically restoring staged and unstaged changes when the thread is unarchived --------- Co-authored-by: Anthony Eid <anthony@zed.dev>
maxbrunsfeld
added a commit
that referenced
this pull request
Apr 10, 2026
Cherry-picked PRs (in order applied): 1. #53386 2. #53400 3. #53396 4. #53428 5. #53356 6. #53215 7. #53429 8. #53458 9. #53436 10. #53451 11. #53454 12. #53419 13. #53287 14. #53521 15. #53463 16. #52848 17. #53544 18. #53556 19. #53566 20. #53579 21. #53575 22. #53550 23. #53585 24. #53510 25. #53599 26. #53099 27. #53662 28. #53660 29. #53657 30. #53654 Release Notes: - N/A --------- Co-authored-by: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com> Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de> Co-authored-by: Bennet Bo Fenner <bennet@zed.dev> Co-authored-by: Nathan Sobo <nathan@zed.dev> Co-authored-by: Anthony Eid <anthony@zed.dev> Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com> Co-authored-by: Eric Holk <eric@zed.dev> Co-authored-by: Anthony Eid <hello@anthonyeid.me> Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com> Co-authored-by: Cameron Mcloughlin <cameron.studdstreet@gmail.com> Co-authored-by: Cole Miller <cole@zed.dev> Co-authored-by: Mikayla Maki <mikayla@zed.dev> Co-authored-by: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com> Co-authored-by: Katie Geer <katie@zed.dev> Co-authored-by: ojpro <contact@ojpro.me>
piper-of-dawn
pushed a commit
to piper-of-dawn/zed
that referenced
this pull request
Apr 25, 2026
…root (zed-industries#53443) In `update_git_repositories`, a `.git` path outside the worktree root can occur legitimately when `.git` is a gitfile (as in linked worktrees and submodules) pointing to a directory in the parent repo. Previously this triggered a `debug_panic!`, crashing debug builds. Now we skip the path with a `debug_assert!` that it is indeed a file (not a directory), so a genuine `.git` directory outside the worktree root would still be caught in debug builds. (No release notes because this is extremely hard to encounter until zed-industries#53215 lands) Release Notes: - N/A
piper-of-dawn
pushed a commit
to piper-of-dawn/zed
that referenced
this pull request
Apr 25, 2026
…ive (zed-industries#53215) Connect the git API and archived worktree data model to the sidebar's archive/unarchive flow: - Add `thread_worktree_archive` module: orchestrates the full archive cycle (WIP commits, DB records, git refs, worktree deletion) and restore cycle (detached worktree creation, reset to recover staged/unstaged state, branch restoration) - Integrate into sidebar: `archive_thread` now persists worktree state before cleanup; `activate_archived_thread` restores worktrees via git with targeted path replacement for multi-root threads - Add pending worktree restore UI state with spinner and cancel button - Show toast on restore failure instead of silent log - Switch to surviving workspace when archiving active thread whose workspace will be deleted - Deserialize persisted `project_group_keys` on window restore - Guard `cleanup_empty_workspaces` against dropped entities - Await rollback DB operations instead of fire-and-forget Part 3 of 3 in the persist-worktree stack. Stacked on zed-industries#53214. This wires up parts 1 and 2. Release Notes: - Added worktree state preservation when archiving agent threads, automatically restoring staged and unstaged changes when the thread is unarchived --------- Co-authored-by: Anthony Eid <anthony@zed.dev>
Zenor27
pushed a commit
to Zenor27/zed
that referenced
this pull request
Jul 4, 2026
…root (zed-industries#53443) In `update_git_repositories`, a `.git` path outside the worktree root can occur legitimately when `.git` is a gitfile (as in linked worktrees and submodules) pointing to a directory in the parent repo. Previously this triggered a `debug_panic!`, crashing debug builds. Now we skip the path with a `debug_assert!` that it is indeed a file (not a directory), so a genuine `.git` directory outside the worktree root would still be caught in debug builds. (No release notes because this is extremely hard to encounter until zed-industries#53215 lands) Release Notes: - N/A
Zenor27
pushed a commit
to Zenor27/zed
that referenced
this pull request
Jul 4, 2026
…ive (zed-industries#53215) Connect the git API and archived worktree data model to the sidebar's archive/unarchive flow: - Add `thread_worktree_archive` module: orchestrates the full archive cycle (WIP commits, DB records, git refs, worktree deletion) and restore cycle (detached worktree creation, reset to recover staged/unstaged state, branch restoration) - Integrate into sidebar: `archive_thread` now persists worktree state before cleanup; `activate_archived_thread` restores worktrees via git with targeted path replacement for multi-root threads - Add pending worktree restore UI state with spinner and cancel button - Show toast on restore failure instead of silent log - Switch to surviving workspace when archiving active thread whose workspace will be deleted - Deserialize persisted `project_group_keys` on window restore - Guard `cleanup_empty_workspaces` against dropped entities - Await rollback DB operations instead of fire-and-forget Part 3 of 3 in the persist-worktree stack. Stacked on zed-industries#53214. This wires up parts 1 and 2. Release Notes: - Added worktree state preservation when archiving agent threads, automatically restoring staged and unstaged changes when the thread is unarchived --------- Co-authored-by: Anthony Eid <anthony@zed.dev>
jonx
pushed a commit
to jonx/zed-aros
that referenced
this pull request
Jul 17, 2026
…root (zed-industries#53443) In `update_git_repositories`, a `.git` path outside the worktree root can occur legitimately when `.git` is a gitfile (as in linked worktrees and submodules) pointing to a directory in the parent repo. Previously this triggered a `debug_panic!`, crashing debug builds. Now we skip the path with a `debug_assert!` that it is indeed a file (not a directory), so a genuine `.git` directory outside the worktree root would still be caught in debug builds. (No release notes because this is extremely hard to encounter until zed-industries#53215 lands) Release Notes: - N/A
jonx
pushed a commit
to jonx/zed-aros
that referenced
this pull request
Jul 17, 2026
…ive (zed-industries#53215) Connect the git API and archived worktree data model to the sidebar's archive/unarchive flow: - Add `thread_worktree_archive` module: orchestrates the full archive cycle (WIP commits, DB records, git refs, worktree deletion) and restore cycle (detached worktree creation, reset to recover staged/unstaged state, branch restoration) - Integrate into sidebar: `archive_thread` now persists worktree state before cleanup; `activate_archived_thread` restores worktrees via git with targeted path replacement for multi-root threads - Add pending worktree restore UI state with spinner and cancel button - Show toast on restore failure instead of silent log - Switch to surviving workspace when archiving active thread whose workspace will be deleted - Deserialize persisted `project_group_keys` on window restore - Guard `cleanup_empty_workspaces` against dropped entities - Await rollback DB operations instead of fire-and-forget Part 3 of 3 in the persist-worktree stack. Stacked on zed-industries#53214. This wires up parts 1 and 2. Release Notes: - Added worktree state preservation when archiving agent threads, automatically restoring staged and unstaged changes when the thread is unarchived --------- Co-authored-by: Anthony Eid <anthony@zed.dev>
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.
Connect the git API and archived worktree data model to the sidebar's archive/unarchive flow:
thread_worktree_archivemodule: orchestrates the full archive cycle (WIP commits, DB records, git refs, worktree deletion) and restore cycle (detached worktree creation, reset to recover staged/unstaged state, branch restoration)archive_threadnow persists worktree state before cleanup;activate_archived_threadrestores worktrees via git with targeted path replacement for multi-root threadsproject_group_keyson window restorecleanup_empty_workspacesagainst dropped entitiesPart 3 of 3 in the persist-worktree stack. Stacked on #53214. This wires up parts 1 and 2.
Release Notes: