Skip to content

fix(tui): hide new worktree action for projects without git - #55326

Open
vergiLgood1 wants to merge 4 commits into
anomalyco:devfrom
vergiLgood1:fix-worktree-non-git
Open

vergiLgood1 wants to merge 4 commits into
anomalyco:devfrom
vergiLgood1:fix-worktree-non-git

Conversation

@vergiLgood1

@vergiLgood1 vergiLgood1 commented Oct 14, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #55215

Type of change

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

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's vcs is git. The dialog also calls project.sync() on open, so vcs is 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?

  • Added a case to packages/tui/test/cli/tui/prompt-move.test.tsx: "new" is shown for a git project and hidden for a project without vcs. It fails without the fix and passes with it.
  • The worktree fixtures are git projects, so they now declare 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.tsx passes.
  • bun typecheck passes in packages/tui.

Screenshots / recordings

Covered by the before/after screenshots already posted in review.

Checklist

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

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.
@github-actions

Copy link
Copy Markdown
Contributor

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

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Before

After

Screenshot

selection: "none",
onTrigger: () => void create(),
},
...(sessionData.project.get(props.projectID)?.vcs === "git"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

vergiLgood1 and others added 3 commits October 16, 2026 17:42
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.

This branch has not been deployed

No deployments
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.

TUI offers worktree creation for a project with no VCS, then fails with HTTP 400

1 participant