Skip to content

Fix project context eviction during in-flight project open#454

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-correctness-bugs-dfd6
Draft

Fix project context eviction during in-flight project open#454
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-correctness-bugs-dfd6

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 31, 2026

Bug and impact

During a slow project open (new window with projectRoot, or switching repos), the desktop could tear down the freshly initialized project context before the window was rebound. The user would see a failed or empty project open, broken IPC, or subtle state corruption after what looked like a successful init.

Trigger: Open a large project in a new window (or switch projects) while another window action schedules context rebalance — e.g. closing a tab, mobile sync handoff, or focus change. If init completes but bindWindowToProject has not run yet, rebalance treated the new root as idle.

Root cause

PR #453 added pendingLocalProjectRoots for runtime IPC authorization during open, but rootsBoundToWindows() — used by rebalanceProjectContexts() — still only counted bound windowProjectRoots / tab roots. In-flight opens and mobile-sync context warmups (projectInitPromises) were invisible to rebalance.

Fix

  • Extend the active-root set to include pending window roots and keys in projectInitPromises.
  • Extract collectRootsBoundToWindows() with unit tests.

Validation

  • npx vitest run src/main/services/projects/projectContextRoots.test.ts (2 tests passed)

Complements #453; distinct from open automation PRs on Files v2 / runtime IPC null guards.

Open in Web View Automation 

rootsBoundToWindows() only counted bound window/tab roots. During a slow
project open (init finished but window not yet rebound), background rebalance
could treat the new context as idle and close it — breaking the open flow.

Include pending window roots (from #453) and in-flight init promise keys in
the active-root set used for rebalance retention.

Co-authored-by: Arul Sharma <arul28@users.noreply.github.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
ade Ignored Ignored May 31, 2026 8:07am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant