Skip to content

Commit 8d9f042

Browse files
committed
fix(git): add missing refreshGitStatus to stashDrop and handle persistent dirty worktree errors
- Add refreshGitStatus(input.cwd) to the gitStashDrop WS handler so clients see updated stash state after a drop, matching all other git mutation handlers. - Detect when stashAndCheckout fails because ignored files still conflict (stash -u doesn't capture .gitignore'd files) and show an actionable error instead of a confusing dirty-worktree message.
1 parent c8b0687 commit 8d9f042

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

apps/server/src/ws.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -798,9 +798,11 @@ const makeWsRpcLayer = (currentSessionId: AuthSessionId) =>
798798
{ "rpc.aggregate": "git" },
799799
),
800800
[WS_METHODS.gitStashDrop]: (input) =>
801-
observeRpcEffect(WS_METHODS.gitStashDrop, git.stashDrop(input.cwd), {
802-
"rpc.aggregate": "git",
803-
}),
801+
observeRpcEffect(
802+
WS_METHODS.gitStashDrop,
803+
git.stashDrop(input.cwd).pipe(Effect.tap(() => refreshGitStatus(input.cwd))),
804+
{ "rpc.aggregate": "git" },
805+
),
804806
[WS_METHODS.gitInit]: (input) =>
805807
observeRpcEffect(
806808
WS_METHODS.gitInit,

apps/web/src/components/BranchToolbarBranchSelector.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ function handleCheckoutError(
157157
},
158158
},
159159
});
160+
} else if (parseDirtyWorktreeError(stashError)) {
161+
toastManager.add({
162+
type: "error",
163+
title: "Cannot switch branches.",
164+
description:
165+
"Some conflicting files are not covered by git stash (e.g., files in .gitignore). Remove or move them manually before switching.",
166+
});
160167
} else {
161168
toastManager.add({
162169
type: "error",

0 commit comments

Comments
 (0)