fix(app): Fix flaky e2e CI: refresh workspace dirs before canOpen check in navigateToProject#24641
Open
HaleTom wants to merge 9 commits into
Open
fix(app): Fix flaky e2e CI: refresh workspace dirs before canOpen check in navigateToProject#24641HaleTom wants to merge 9 commits into
HaleTom wants to merge 9 commits into
Conversation
…oject When switching projects after enabling workspaces, navigateToProject would fail to find the workspace directory in dirs (computed from project.sandboxes) because sandbox population is asynchronous. This caused openSession to return false and navigate to the wrong URL, flaking the e2e project-switch test on Windows CI where the async gap is wider. Fix: call refreshDirs before canOpen checks in openSession, ensuring the worktree list is fetched from the SDK when the cached dirs don't include the target directory.
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a race in project switching where workspace directories may not yet be present in the cached dirs list, causing session restoration to fail intermittently (notably on Windows CI).
Changes:
- Refreshes workspace directory listings before
canOpen()checks when opening a remembered/latest session. - Refreshes directory listings for the “resolve session via SDK” path to handle sessions that live in newly-enabled workspaces.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Per Copilot review feedback on PR anomalyco#24641: refreshDirs() already returns canOpen(), so calling canOpen() again immediately after is redundant. Use the boolean return directly to simplify the control flow.
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Author
|
@rekram1-node pinging you as this is may still be blocking some PRs and I saw you recently merge a related PR. Issues related:
|
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.
Issue for this PR
Closes #14461
Type of change
What does this PR do?
Fixes an intermittent e2e test failure in
projects-switch.spec.tsline 90 (toHaveURL), which flakes on Windows CI.Root cause: When switching back to a project after enabling workspaces,
navigateToProjectcomputesdirsfromproject.sandboxes. But sandbox population is asynchronous — the test just enabled workspaces, andproject.sandboxesmay not yet include the workspace directory. SocanOpen(target.directory)returnsfalsefor the workspace dir,openSessionbails silently, and the function falls through to navigate to the wrong URL. ThetoHaveURLassertion catches this intermediate wrong state.This is Windows-specific because
worktree.listandfsmonitorare slower on Windows, widening the async gap between "workspaces enabled" and "sandboxes populated."Fix: Call
ensureDirOpenable(target.directory)before anycanOpencheck insideopenSession.ensureDirOpenablefetches the worktree list from the SDK when the cacheddirsdon't include the target directory, ensuring the workspace dir is always available before the check. It returns thecanOpenresult directly, so the call site uses its boolean return as the guard.Also added
ensureDirOpenable(resolved.directory)for the SDK session resolution path, where the resolved session might be in a workspace dir not yet indirs.How did you verify your code works?
bun typecheckpassesnavigateToProject→openSession→canOpenchainworktree.liston WindowsRelated Issues
Checklist