Skip to content

fix(remove): suppress remote-delete prompt for --yes/--non-interactive/--dry-run#21

Merged
epodivilov merged 2 commits into
mainfrom
fix/remove-non-interactive-remote-prompt
Jun 20, 2026
Merged

fix(remove): suppress remote-delete prompt for --yes/--non-interactive/--dry-run#21
epodivilov merged 2 commits into
mainfrom
fix/remove-non-interactive-remote-prompt

Conversation

@epodivilov

Copy link
Copy Markdown
Owner

What

wt remove <branch> --delete-branch --force --yes still prompted "Also delete remote branch?" interactively, blocking agent/CI callers. --dry-run had the same problem: the prompt fired before the plan was printed, so dry-run wasn't fully non-interactive either.

Why

resolveDeleteRemoteBranch only short-circuited on ui.nonInteractive. --yes and --dry-run weren't honored, so any caller that hadn't also set the global --non-interactive flag (or didn't pass --delete-remote-branch explicitly) would hang on the confirm prompt.

Fix — resolution rule

Documented at the resolvers in src/cli/resolve-params.ts and in the CLI help text:

  1. Explicit --delete-branch / --delete-remote-branch flag wins.
  2. Config value (remove.deleteBranch / remove.deleteRemoteBranch) is consulted next.
  3. If --yes, global --non-interactive, or --dry-run — default to false. Destructive defaults require explicit opt-in, so agents/CI never accidentally delete branches or remote refs.
  4. Otherwise, prompt the user.

Applied symmetrically to resolveDeleteBranch so the local-branch prompt follows the same contract. The dry-run plan now reflects the resolved (non-interactive) decision — e.g. Would delete branch "feature" (local) instead of asking first.

Tests

Extended src/cli/commands/remove.test.ts with the non-interactive path coverage:

  • --yes with --delete-branch (no --delete-remote-branch) → no confirm call, remote not touched.
  • --non-interactive with --delete-branch → no confirm call, remote not touched.
  • --dry-run with --delete-branch → no confirm call, plan reads "(local)" only.
  • --yes with explicit --delete-remote-branch → no confirm call, remote IS deleted (opt-in respected).

Checks

  • pnpm typecheck — green
  • pnpm lint — green
  • pnpm test — 497 pass / 0 fail

Reference

Closes Vikunja #49 (id 311).

…e/--dry-run

Running `wt remove <branch> --delete-branch --yes` still prompted "Also
delete remote branch?" because resolveDeleteRemoteBranch only short-
circuited on ui.nonInteractive. That blocks agent/CI callers. --dry-run
had the same problem: the prompt fired before the plan was printed.

Resolution rule (now documented at the resolvers and in CLI help):
  1. explicit --delete-branch / --delete-remote-branch wins
  2. config value (remove.deleteBranch / remove.deleteRemoteBranch)
  3. --yes, global --non-interactive, or --dry-run → default to false
     (destructive defaults must require explicit opt-in)
  4. otherwise prompt

Applied symmetrically to resolveDeleteBranch — same non-interactive
contract for the local-branch prompt.

Closes Vikunja #49 (id 311).
Review of PR #21 (Vikunja #49) flagged two follow-ups:

1. Test gap: all four new tests in the non-interactive describe block
   passed `delete-branch: true`, so resolution short-circuited at step 1
   (explicit flag wins) and the new yes-gate in `resolveDeleteBranch`
   was never exercised. Added three cases:
   - `--yes` alone (no flag, no config) → no prompt, no branch delete
   - `--yes` with explicit `--delete-remote-branch=false` (opt-out beats yes-gate)
   - `--yes` with config `remove.deleteRemoteBranch=true` (config beats yes-gate)

2. Help-text drift: the three new `--help` strings stuffed the same
   `--yes/--non-interactive/--dry-run` triplet into every flag, breaking
   the codebase's short-imperative style. Hoisted the caveat once into
   the `--yes` description and reverted `--delete-branch` /
   `--delete-remote-branch` to their original one-liners.

Also tweaked the resolution-order comment: bullet 3 said "default to
false" but the resolvers actually return false AND skip the prompt;
reworded to match.
@epodivilov epodivilov merged commit 46eb02b into main Jun 20, 2026
1 check passed
@epodivilov epodivilov deleted the fix/remove-non-interactive-remote-prompt branch June 20, 2026 21:31
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