Skip to content

Commit 577e759

Browse files
authored
Merge pull request #13737 from gitbutlerapp/mg-branch-64
Fix stuck UI after unapply failure
2 parents 9696258 + 442b983 commit 577e759

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

apps/desktop/src/components/branch/BranchHeaderContextMenu.svelte

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,11 @@
342342
testId={TestId.BranchHeaderContextMenu_UnapplyBranch}
343343
disabled={isReadOnly}
344344
onclick={async () => {
345-
await stackService.unapply({ projectId, stackId });
346-
close();
345+
try {
346+
await stackService.unapply({ projectId, stackId });
347+
} finally {
348+
close();
349+
}
347350
}}
348351
/>
349352
</ContextMenuSection>

apps/desktop/src/components/stack/StackDragHandle.svelte

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,16 @@
8888
async function unapplyStack() {
8989
if (!stackId) return;
9090
91-
await stackService.unapply({
92-
projectId,
93-
stackId,
94-
});
95-
96-
// Refetch to update the UI
97-
await stacksQuery.result.refetch();
91+
try {
92+
await stackService.unapply({
93+
projectId,
94+
stackId,
95+
});
96+
} finally {
97+
// Always refetch to clear stale stacks from the UI,
98+
// even if the unapply failed (e.g. branch already removed).
99+
await stacksQuery.result.refetch();
100+
}
98101
}
99102
</script>
100103

0 commit comments

Comments
 (0)