Skip to content

fix(core): skip Git worktree discovery for non-Git directories - #58025

Closed
xiaoheiai4719-collab wants to merge 2 commits into
anomalyco:devfrom
xiaoheiai4719-collab:plain-worktree-discovery
Closed

xiaoheiai4719-collab wants to merge 2 commits into
anomalyco:devfrom
xiaoheiai4719-collab:plain-worktree-discovery

Conversation

@xiaoheiai4719-collab

Copy link
Copy Markdown

Issue for this PR

Closes #57989

Type of change

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

What does this PR do?

Return an empty Git worktree list for an existing non-Git directory, so ordinary project refresh does not log DirectoryUnavailableError. Missing directories still fail; create/remove are unchanged.

Git.repo.discover already returns undefined for an unresolvable Git marker, so that case also returns an empty list. No new catch hides errors from Git.worktree.list.

How did you verify your code works?

Real filesystem/Git regressions: 3 failures before, 40 passes after. The focused suite passes 400/400 with ten repeats on pinned Bun 1.4.2; it also passed 400/400 under full-suite load on Bun 1.4.3. From packages/core: bun run script/test.ts test/worktree.test.ts --rerun-each 10.

Core typecheck and the complete root lint plus 34 typecheck tasks pass (serial, Bun 1.4.3).

Full core tests on Bun 1.4.3: 6,710 passed, 39 skipped, 10 failed. The same ten failures reproduce with unchanged production source on both Bun versions: patch permissions, VCS initialization, six daemon socket cases, and two configuration-discovery cases. Full-suite qualification is incomplete; these are not claimed as passes. Linux only; Windows was not run.

AI-assisted implementation and command execution; the publication owner has not personally rerun these checks.

Screenshots / recordings

No UI change.

Checklist

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

@hellvyn

hellvyn commented Oct 31, 2026

Copy link
Copy Markdown

Verified on Windows 11 (build 26300) by applying this PR's two commits on top of current dev (956e41f). I cherry-picked them since the PR base (248bfbe) is older.

  • With only the new tests applied (no source change): 37 pass, 3 fail — "lists no Git worktrees for an existing non-git directory", "refreshes a non-git project without discovery warnings", "lists no worktrees when Git discovery cannot resolve a marker".
  • With the fix applied: test/worktree.test.ts 40 pass, 0 fail.
  • bun typecheck in packages/core: no type errors. oxlint is clean on the two changed files. Five other test files that touch worktrees (plugin/worktree, session-move, tool-opencode, shared-schema, config/skill): 0 failures.

Real-world context: my own opencode.log on this machine (2.1.x/2.2.x) has 177 worktree discovery failed ... error=Worktree.DirectoryUnavailableError warnings (strategy=git), all for ordinary non-git folders opened as projects, still occurring today. I only ran the tests with the patch; I did not re-run the full desktop app against those folders.

The change is small and behaves as described. It's still a draft with no review since Oct 22, so happy to re-run anything if useful.

@github-actions

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.

Log spam: "worktree discovery failed … Worktree.DirectoryUnavailableError" for non-git projects

2 participants