fix: Consecutive Cmd+N no longer spawns agent in wrong project#147
fix: Consecutive Cmd+N no longer spawns agent in wrong project#1472witstudios merged 2 commits intomainfrom
Conversation
Guard updateActiveProject against nil lookups so activeProjectRoot is preserved when the worktree/agent isn't in the data model yet (daemon responds before manifest refresh). Also set activeProjectRoot explicitly in createWorktree/createAgent callbacks since the ProjectState already knows the correct project root. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughGuarded activeProjectRoot assignments: updateActiveProject(for:) only assigns when a matching project is found; createAgent and createWorktree now set appState?.activeProjectRoot to the current projectRoot when daemon responses succeed. Tests added to ensure unknown agent/worktree IDs do not clear activeProjectRoot. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: adfdcc6ccb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
If a project is removed between the create request and daemon response, unconditionally setting activeProjectRoot would leave a stale root that can't be resolved, breaking Cmd+N until manual reselection. Only set activeProjectRoot when the project still exists in appState.projects. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2witstudios
left a comment
There was a problem hiding this comment.
Re: P2 comment on stale project root in spawn callback — Agreed and addressed in 76319f4. Both createAgent and createWorktree callbacks now guard with if self.appState?.projectState(forRoot: self.projectRoot) \!= nil before setting activeProjectRoot, so a removed project can't be resurrected by a late daemon response.
Summary
updateActiveProjectagainst nil lookups soactiveProjectRootis preserved when the entity isn't in the data model yet (daemon responds before manifest refresh)activeProjectRootexplicitly increateWorktree/createAgentcallbacks since theProjectStatealready knows the correct project rootactiveProjectRootwhenprojectState(forRoot:)confirms the project still existsTest plan
ActiveProjectRoutingTestsin Xcode — all 10 tests pass (8 existing + 2 new)🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests