fix(app): Fix flaky e2e CI: refresh workspace dirs before canOpen check in navigateToProject#24641
fix(app): Fix flaky e2e CI: refresh workspace dirs before canOpen check in navigateToProject#24641HaleTom 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.
|
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. |
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.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
@rekram1-node pinging you as this is may still be blocking some PRs and I saw you recently merge a related PR. Issues related:
|
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
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