Skip to content

feat: delete a worktree from the Space actions menu - #328

Merged
kbwo merged 2 commits into
mainfrom
feature/space-delete-worktree
Aug 30, 2026
Merged

kbwo merged 2 commits into
mainfrom
feature/space-delete-worktree

Conversation

@kbwo

@kbwo kbwo commented Aug 22, 2026

Copy link
Copy Markdown
Owner

Why

Deleting a worktree required the D screen, which lists every worktree and makes you locate the one that is already highlighted in the menu. Space now opens the row actions for the highlighted worktree and can delete it directly.

What changed

  • Space works on any worktree row, not only rows that have a session. Rename/Close are session-specific and stay hidden when the row has no session, so the menu title switches to "Worktree Actions".
  • The delete entry is hidden when the worktree cannot be deleted (the main worktree, and the worktree containing the current working directory) instead of being shown and rejected. That rule moved into isDeletableWorktree() in src/utils/worktreeUtils.ts, and the existing D screen now uses it too, so both paths share one source.
  • Choosing it reuses the existing confirmation and deletion path: DeleteConfirmation (uncommitted-changes warning, branch option, Cancel selected by default) followed by handleDeleteWorktrees, which kills the worktree's sessions before removing it. On failure this flow returns to the menu with the error, because the multi-select delete screen was never opened here.
  • The Dashboard entry point into the actions menu has only a session and no worktree, so it offers no deletion.

MenuAction.sessionActions now carries the Worktree instead of a bare worktreePath (the path is read from it, so the two no longer duplicate each other).

Verification

  • bun run lint, bun run typecheck: pass.
  • bun run test: 1788 passed. The *.submodule.test.ts files fail in beforeAll in my local environment because git config --global protocol.file.allow always cannot write ~/.gitconfig there; this is unrelated to the change (the prebuilt, unmodified dist copies of those tests fail identically). CI should run them normally.
  • New tests: src/components/SessionActions.test.tsx (which entries are offered, hotkey dispatch), a Menu.test.tsx case for Space on a session-less row, and isDeletableWorktree cases in src/utils/worktreeUtils.test.ts.
  • Not verified by driving the actual TUI.

🤖 Generated with Claude Code

kbwo and others added 2 commits August 22, 2026 18:00
Deleting a worktree required the D screen, which lists every worktree and
makes you find the one already highlighted in the menu. Space now opens the
actions menu for the highlighted row and offers deleting that worktree
directly.

- Space opens the actions menu for any worktree row, not only rows with a
  session. Rename/Close are session-specific and stay hidden without one,
  so the menu title switches to "Worktree Actions".
- The delete entry is hidden for worktrees that cannot be deleted (main
  worktree, and the worktree containing the current working directory)
  rather than shown and rejected. That rule moves into
  isDeletableWorktree() so the D screen and the new entry share one source.
- Choosing it reuses DeleteConfirmation (uncommitted-changes warning,
  branch option, Cancel-by-default) and then the existing deletion path,
  which kills the worktree's sessions first. A failure returns to the menu
  with the error, since the multi-select screen was never opened here.

The Dashboard entry point into the actions menu has only a session, no
worktree, so it offers no deletion.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Conflicts came from #324, which added a "Directory: <path>" line to the
session actions menu and a required worktreePath prop for it.

- SessionActions keeps main's worktreePath prop and dedicated directory
  line, alongside the hasSession / canDeleteWorktree props of this branch.
  sessionLabel becomes optional, since a worktree row without a session has
  no session name to show and the path already has its own line.
- App passes both: the label is main's session name / "Session #N" for a
  session row and undefined for a session-less one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@kbwo
kbwo marked this pull request as ready for review August 30, 2026 13:07
@kbwo
kbwo merged commit aad95bf into main Aug 30, 2026
1 check passed
@kbwo
kbwo deleted the feature/space-delete-worktree branch August 30, 2026 13:08
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.

1 participant