Skip to content

fix(opencode): resolve snapshots from git subdirectories#29705

Open
MuoDoo wants to merge 1 commit into
anomalyco:devfrom
MuoDoo:snapshot-subdirectory-cwd-fix
Open

fix(opencode): resolve snapshots from git subdirectories#29705
MuoDoo wants to merge 1 commit into
anomalyco:devfrom
MuoDoo:snapshot-subdirectory-cwd-fix

Conversation

@MuoDoo
Copy link
Copy Markdown

@MuoDoo MuoDoo commented May 28, 2026

Issue for this PR

Closes #27688

Type of change

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

What does this PR do?

When opencode is launched from a git subdirectory, snapshot candidate paths can be worktree-relative while later pathspec operations run from the launch directory. This can make git resolve paths like src/file.txt under src/src/file.txt and fail to record the snapshot.

This PR resolves pathspec-consuming snapshot operations from the worktree root, makes untracked file paths worktree-relative, and adds a regression test for launching from a subdirectory.

Related prior attempts: #27737, #28131.

How did you verify your code works?

  • bun test test/snapshot/snapshot.test.ts --timeout 30000
  • bun typecheck

Screenshots / recordings

N/A, not a UI change.

Checklist

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

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

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

I found potential related PRs that address similar snapshot/git subdirectory issues:

  1. PR snapshot: fix cwd for git commands in subdirs #28131 - snapshot: fix cwd for git commands in subdirs

    • Related to fixing git command execution in subdirectories
  2. PR fix(snapshot): run git from worktree, not launch directory #27737 - fix(snapshot): run git from worktree, not launch directory

    • Directly addresses running git from the correct worktree location

These PRs appear to address similar or overlapping concerns about resolving git operations from the correct directory context when working in subdirectories. You may want to review these to ensure there's no duplication of effort.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Snapshot fails when opencode is opened in a git subdirectory (snapshot service cwd mismatch)

1 participant