Skip to content

fix(app): navigate to selected directory instead of project root when opening sandbox - #33678

Closed
bytethm wants to merge 1 commit into
anomalyco:devfrom
bytethm:fix-sandbox-navigate
Closed

fix(app): navigate to selected directory instead of project root when opening sandbox#33678
bytethm wants to merge 1 commit into
anomalyco:devfrom
bytethm:fix-sandbox-navigate

Conversation

@bytethm

@bytethm bytethm commented Jun 24, 2026

Copy link
Copy Markdown

Description

When a user opens a directory that belongs to an existing project as a sandbox (e.g., a copied repo with the same git root hash), the app navigates to the project's primary worktree instead of the user-selected directory.

This happens because navigateToProject always navigates to root (the project's worktree from projectRoot()) rather than the directory parameter that was passed in.

Root Cause

  • Two separate git repos (e.g. MCP-FRAMEWORKS and MCP-FRAMEWORKS_copy) share the same git root hash
  • ProjectV2.resolve generates the same project ID for both
  • Project.fromDirectory preserves the existing worktree and adds the new directory as a sandbox
  • projectRoot() returns the project worktree, not the sandbox path
  • navigateToProject used the worktree as the final navigation target

Fix

Changed the final navigation fallback in navigateToProject from root (project worktree) to directory (the user's actual selected directory). Existing session navigation already correctly uses target.directory, so only the fallback (when no existing session is found) was affected.

Verification

  • bun turbo typecheck passes on all 24 packages

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jun 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

The search results show PR #33678 (the current PR) plus a related PR that might be relevant:

Potentially Related PR:

However, this appears to be a different issue—#30685 focuses on stale project roots, while #33678 fixes the fallback navigation target in navigateToProject. They could be complementary fixes to the same navigation system.

No duplicate PRs found

@bytethm

bytethm commented Jun 24, 2026

Copy link
Copy Markdown
Author

撤回,需要进一步排查根因

@bytethm bytethm closed this Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:compliance This means the issue will auto-close after 2 hours. needs:issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant