Fix stuck UI after unapply failure#13737
Merged
Merged
Conversation
This was referenced May 9, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Ensures the desktop UI recovers cleanly when stackService.unapply() fails by moving UI cleanup actions into finally blocks, preventing stuck context menus and stale stack lists after backend errors.
Changes:
- Always close the branch header context menu even if
unapply()throws. - Always refetch stacks after an unapply attempt so stale stacks don’t remain visible.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| apps/desktop/src/components/stack/StackDragHandle.svelte | Wraps unapply() in try/finally to refetch stacks even on failure. |
| apps/desktop/src/components/branch/BranchHeaderContextMenu.svelte | Wraps unapply() in try/finally to ensure the menu closes even on failure. |
When `stackService.unapply()` fails, the UI gets stuck — context menus stay open and stale stacks remain visible because the cleanup code only ran on the success path. In `BranchHeaderContextMenu.svelte`, `close()` was called sequentially after `await unapply()`, and in `StackDragHandle.svelte`, `stacksQuery.result.refetch()` was likewise awaited after the call. An error in either case meant cleanup never executed. Wrapped both call sites in `try/finally` so cleanup always runs regardless of whether the backend call succeeds or fails.
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.
When
stackService.unapply()fails (e.g. branch already removed, backend error), the UI gets stuck — context menus stay open and stale stacks remain visible because the cleanup code only ran on the success path.In
BranchHeaderContextMenu.svelte,close()was called sequentially afterawait unapply(), and inStackDragHandle.svelte,stacksQuery.result.refetch()was likewise awaited after the call. An error in either case meant cleanup never executed.Wrapped both call sites in
try/finallyso cleanup always runs regardless of whether the backend call succeeds or fails.