Skip to content

Fix "Cannot delete a branch that is applied" error in branches view#13736

Merged
mtsgrd merged 1 commit into
masterfrom
mg-branch-63
May 9, 2026
Merged

Fix "Cannot delete a branch that is applied" error in branches view#13736
mtsgrd merged 1 commit into
masterfrom
mg-branch-63

Conversation

@mtsgrd
Copy link
Copy Markdown
Contributor

@mtsgrd mtsgrd commented May 9, 2026

Telemetry from v0.19.10 showed users hitting a delete_local_branch error when clicking delete on branches in the branches page.

The apply/delete buttons in BranchesView.svelte were guarded by !inWorkspace, where inWorkspace comes from branch.stack?.inWorkspace. When a branch has no stack association (branch.stack is null), inWorkspace is undefined, and !undefined is truthy — so the buttons appeared for branches the backend still considers applied.

Changed the guard to inWorkspace !== true, which correctly hides buttons only when the branch is known to be in the workspace, and shows them when the status is false (not applied) or undefined (no stack).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the branches view UI logic that decides whether “Apply to workspace” / “Delete local” actions are shown for a selected branch, aiming to prevent users from attempting to delete branches that are applied in the workspace.

Changes:

  • Adjusted the conditional that guards rendering of branch action buttons in BranchesView.svelte.

<!-- Apply branch -->

{#if branchName && !inWorkspace}
{#if branchName && inWorkspace !== true}
Telemetry showed users hitting a `delete_local_branch` error when
clicking delete on branches in the branches page.

The apply/delete buttons in `BranchesView.svelte` were guarded by
`!inWorkspace`, where `inWorkspace` comes from `branch.stack?.inWorkspace`.
When a branch has no stack association (`branch.stack` is `null`),
`inWorkspace` is `undefined`, and `!undefined` is truthy — so the
buttons appeared for branches the backend still considers applied.

Changed the guard to `inWorkspace !== true`, which correctly hides
buttons only when the branch is known to be in the workspace, and
shows them when the status is `false` (not applied) or `undefined`
(no stack).
@mtsgrd mtsgrd changed the base branch from head-didnt-match-head to master May 9, 2026 20:11
@mtsgrd mtsgrd merged commit 68f8864 into master May 9, 2026
36 checks passed
@mtsgrd mtsgrd deleted the mg-branch-63 branch May 9, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants