Skip to content

fix(opencode): avoid treating separate clones as sandboxes - #40599

Closed
quanzhuo wants to merge 1 commit into
anomalyco:devfrom
quanzhuo:issues/39605
Closed

fix(opencode): avoid treating separate clones as sandboxes#40599
quanzhuo wants to merge 1 commit into
anomalyco:devfrom
quanzhuo:issues/39605

Conversation

@quanzhuo

@quanzhuo quanzhuo commented Aug 5, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #39605

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This fixes a case where opening separate clones of the same git repository could make the app treat the second clone as a sandbox/worktree of the first one.

Project IDs can be shared across separate clones when they have the same normalized origin remote. Before this change, any later directory with the same project ID and a different path was added to sandboxes. That is correct for linked git worktrees, but not for independent clones. As a result, the UI could reuse workspace/branch state from the first directory when opening the second one.

The fix only adds a directory to sandboxes when it is a real linked git worktree, detected by the git common directory living outside the opened worktree. Independent clones keep their shared project ID, but are no longer treated as sandboxes of each other.

How did you verify your code works?

  • Added a regression test for two separate clones of the same repo.
  • Ran bun test test/project/project.test.ts from packages/opencode.
  • Ran bun typecheck.

Screenshots / recordings

Not applicable. This is a backend project/worktree classification fix.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

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

I found several related PRs, but they appear to be addressing different iterations of this same problem:

Related PRs (not direct duplicates):

  1. fix (core): Multiple clones of same repo are different projects #35311 - fix (core): Multiple clones of same repo are different projects

    • Similar concept: handles multiple clones of the same repo being treated as separate projects
  2. fix(app): resolve a session's project by directory, not by shared ID #39666 - fix(app): resolve a session's project by directory, not by shared ID

    • Related to session/project resolution by directory vs shared ID
  3. fix(core): include git store hash in project ID to distinguish indepe… #29977 - fix(core): include git store hash in project ID to distinguish indepe…

    • Historical fix attempting to distinguish independent clones via git store hash
  4. fix(project): repair split project IDs across worktrees #14287 - fix(project): repair split project IDs across worktrees

    • Historical worktree project ID handling

These PRs suggest this is an area with iterative fixes over time, but no current active duplicate PR addressing the exact same issue (treating separate clones as sandboxes) was found. PR #40599 appears to be a fresh take on this problem.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

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:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When opening a project via GUI in different directories, issues may arise.

1 participant