Fix "Cannot delete a branch that is applied" error in branches view#13736
Merged
Conversation
This was referenced May 9, 2026
Contributor
There was a problem hiding this comment.
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Telemetry from v0.19.10 showed users hitting a
delete_local_brancherror when clicking delete on branches in the branches page.The apply/delete buttons in
BranchesView.sveltewere guarded by!inWorkspace, whereinWorkspacecomes frombranch.stack?.inWorkspace. When a branch has no stack association (branch.stackisnull),inWorkspaceisundefined, and!undefinedis 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 isfalse(not applied) orundefined(no stack).