Repository navigation
fix(tui): hide new worktree action for projects without git - #55326
vergiLgood1 wants to merge 4 commits into
Conversation
Creating a worktree in a non-git project always failed with HTTP 400. Show the action only for git projects, and sync project data when the dialog opens so the VCS type is known.
|
The following comment was made by an LLM, it may be inaccurate: |
There was a problem hiding this comment.
Looks good. I reproduced #55215 on the base by running the TUI from source with opencode-drive: in a plain folder, /worktrees shows new ctrl+a. With this change, "new" is gone and ctrl+a does nothing in a folder with no VCS. In a git repository "new" still appears once the project data loads. bun run typecheck in packages/tui passes.
The public API is unchanged: this only touches the TUI.
One thing to consider, though it doesn't block the merge: the check is git-only, so it will also hide "new" for any plugin worktree strategy that works without git (see the inline comment). The other entry point, dialog-open.tsx, is already reachable only for git projects, so it doesn't need the same change.
Related: #51672
| selection: "none", | ||
| onTrigger: () => void create(), | ||
| }, | ||
| ...(sessionData.project.get(props.projectID)?.vcs === "git" |
There was a problem hiding this comment.
Not blocking: plugins can register their own worktree strategies (WorktreeStrategies.Editor.add), and some may work in projects without git (see #51672). Checking vcs === "git" in the TUI hides "new" for those projects too. It matches the existing check in dialog-open.tsx, so it is fine for now. Longer term, a "worktrees supported" flag from the server, based on the strategy it selects, would be more accurate than checking only for git.
The worktree fixtures are git projects, so mark them as such. The new case checks the action is hidden when the project has no vcs.



Issue for this PR
Closes #55215
Type of change
What does this PR do?
The Worktrees dialog always showed "new", but creating a worktree only works for git projects. For a non-git project it failed with
HTTP 400. The action now appears only when the project'svcsisgit. The dialog also callsproject.sync()on open, sovcsis known when the dialog is opened directly.This matches the existing git check in
dialog-open.tsx. As noted in review, plugin worktree strategies that do not need git would be hidden too; a server-side "worktrees supported" flag would be more accurate later.How did you verify your code works?
packages/tui/test/cli/tui/prompt-move.test.tsx: "new" is shown for a git project and hidden for a project withoutvcs. It fails without the fix and passes with it.vcs: "git". Without that, the existing worktree tests in the same file fail.bun test test/cli/tui/prompt-move.test.tsx test/cli/tui/dialog-open.test.tsxpasses.bun typecheckpasses inpackages/tui.Screenshots / recordings
Covered by the before/after screenshots already posted in review.
Checklist