Repository navigation
fix: Prevent stale worktree refreshes hiding new worktrees - #5266
nexusjuniorai wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughThis pull request prevents race conditions in overlapping worktree refresh operations. It introduces per-repository refresh request tracking via module-level state and helper functions, updates 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
|
Sorry, it is working properly now, please close this if not useful |
|
Hi @nexusjuniorai — thanks for this, and for the follow-up note that it looks resolved on your end. The out-of-order worktree-refresh race (an older overlapping scan resolving last and clobbering a newer agent-created worktree) is now handled on Closing as resolved — thank you for the contribution and the careful writeup. 🙏 |
Summary
Prevent overlapping worktree refreshes from letting an older detected-list response overwrite newer renderer state. This keeps agent-created worktrees visible as soon as the latest refresh sees them, instead of disappearing until another worktree event such as deletion refreshes the list again.
Screenshots
No visual change
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildScoped checks run:
pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/store/slices/worktrees.test.tspnpm exec vitest run --config config/vitest.config.ts src/renderer/src/store/slices/worktrees.test.ts -t "keeps a newer worktree refresh"pnpm exec oxlint src/renderer/src/store/slices/worktrees.ts src/renderer/src/store/slices/worktrees.test.tspnpm run typecheck:webpnpm exec oxfmt --check src/renderer/src/store/slices/worktrees.ts src/renderer/src/store/slices/worktrees.test.tsgit diff --checkAI Review Report
Codex diagnosed and reviewed the refresh path around
fetchWorktrees, watcher/runtime refresh events, and the existing create-worktree race comments. The main risk checked was whether stale out-of-order scans could clobber a newer scan that already included the agent-created worktree; the added regression reproduced that failure before the fix. The review also checked that the change is renderer store state only and does not touch shortcuts, shortcut labels, path separators, shell behavior, or Electron platform APIs, so the behavior is cross-platform for macOS, Linux, and Windows.Security Audit
No new input handling, command execution, filesystem path handling, authentication, secrets, dependencies, or IPC channels were added. The change only ignores stale renderer refresh responses when a newer refresh for the same repo exists. Existing IPC/RPC worktree detection payloads keep the same shape and trust boundary. No security follow-up needed.
Notes
The branch had zero commits ahead of
origin/mainbefore the fix commit. Direct push tostablyai/orcawas denied for the authenticated GitHub account, so the PR head branch isnexusjuniorai:fix/worktree-refresh-agent-createdtargetingstablyai/orca:main.