fix: load services for worktree projects after directory is created#88
fix: load services for worktree projects after directory is created#88JanTvrdik wants to merge 1 commit intocontember:mainfrom
Conversation
When a worktree is created with deferred hooks, the project is registered in the workspace before the directory exists on disk. The service loading observer would attempt to load services (finding nothing since the directory doesn't exist yet) and mark the project as known, never retrying once the directory was ready. Skip service loading for projects whose directory doesn't exist yet, so they get picked up on the next workspace notification after the worktree directory is created and fire_worktree_hooks runs. Co-Authored-By: Claude Code
There was a problem hiding this comment.
Pull request overview
Fixes service discovery for deferred worktree projects by avoiding “one-shot” service loading before the worktree directory exists on disk, ensuring services are loaded once the directory becomes available.
Changes:
- Skip service loading for projects whose directory does not yet exist (deferred worktrees) during initial load and workspace-change observation.
- Track
known_project_idsbased on successfully-attempted loads/unloads (insert on load, remove on unload) instead of blindly replacing withcurrent_ids.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Load services for new projects (or deferred worktrees whose directory now exists) | ||
| for (id, path, saved_terminals) in &local_projects { | ||
| if !known.contains(id) { | ||
| // Skip projects whose directory doesn't exist yet (deferred worktrees). | ||
| if !std::path::Path::new(path).exists() { | ||
| continue; | ||
| } | ||
| service_manager.update(cx, |sm, cx| { | ||
| sm.load_project_services(id, path, saved_terminals, cx); | ||
| }); | ||
| known.insert(id.clone()); | ||
| } |
There was a problem hiding this comment.
This workspace→service loading observer logic is now diverging from the nearly-identical implementation in src/app/headless.rs. To avoid inconsistent behavior between GUI and headless modes (and future drift), consider either applying the same deferred-directory Path::exists() handling there as well, or extracting the shared project-service sync logic into a helper used by both call sites.
Summary
okena.yamlordocker-compose.yml(directory doesn't exist yet), and mark the project as "known" — never retrying once the directory was ready.fire_worktree_hooksruns and the directory is available.Test plan
docker-compose.yml, create a worktree from it, verify Services section appears in the sidebar for the worktree projectCo-Authored-By: Claude Code