fix(opencode): fall back to opened directory when stored worktree is missing - #47326
Open
zbh-lzu wants to merge 2 commits into
Open
fix(opencode): fall back to opened directory when stored worktree is missing#47326zbh-lzu wants to merge 2 commits into
zbh-lzu wants to merge 2 commits into
Conversation
Contributor
|
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. |
Author
|
Hi, friendly ping on this one. It's the server-side half of #46330 — #46713 fixed the frontend consumer and #47642 added the manual update API, but the stored worktree still isn't healed automatically when a project is reopened from its new location. Also, the required workflows (e2e / typecheck / unit) are still awaiting maintainer approval to run — would you mind approving them? Happy to make any changes if needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Fixes #46330. That issue was closed by #46713, which fixed one frontend consumer, but the server still persists the stale project.worktree row.
Type of change
What does this PR do?
When a project directory is moved or renamed,
project.idstays the same (it is derived from the git remote / root commit), sofromDirectoryreuses the existing row and keeps its oldworktreevalue — a path that no longer exists. Every consumer that resolves through that column (project list, session list project info, desktop) then opens a missing directory, and prompts fail with ENOENT or die silently.This PR makes
fromDirectorycheck whether the storedworktreeexists on disk: if it is gone, fall back to the directory being opened and persist that through the existing upsert. When the storedworktreestill exists (a second clone of the same repo), behavior is unchanged.How did you verify your code works?
Project.fromDirectory: "replaces missing stored worktree with the opened directory" fails ondevand passes with this change; "keeps stored worktree when another clone exists on disk" pins the second-clone behavior.packages/opencode/test/project/suite passes (91 tests, 0 fail),typecheckand prettier clean.worktreeinprojecttable — project shows "no git" and all prompts fail with ENOENT #46330: moved a repo on disk, pointedproject.worktreeback at the old path via sqlite, reopened the project through the API — worktree self-heals to the new path and new sessions attach to the right project instead of falling intoglobal.Screenshots / recordings
N/A (server-side only).
Checklist