From 247dc0481e2d85be3a96025becb93ff482f33864 Mon Sep 17 00:00:00 2001 From: jwcrystal <121911854+jwcrystal@users.noreply.github.com> Date: Wed, 22 Apr 2026 04:03:27 +0800 Subject: [PATCH] fix: allow git checkout with uncommitted files (#945) --- packages/ui/src/components/views/GitView.tsx | 10 +++------- packages/ui/src/sync/session-worktree-contract.ts | 12 +----------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/packages/ui/src/components/views/GitView.tsx b/packages/ui/src/components/views/GitView.tsx index 56048061..a306bbad 100644 --- a/packages/ui/src/components/views/GitView.tsx +++ b/packages/ui/src/components/views/GitView.tsx @@ -1057,10 +1057,6 @@ export const GitView: React.FC = () => { }, [currentDirectory, selectedPaths, settingsGitmojiEnabled, gitmojiEmojis, scrollActionPanelToBottom]); const formatBlockingReason = (reason: ReturnType[number]): string => { - if (reason.reason === 'dirty') { - const count = typeof reason.dirtyFiles === 'number' ? reason.dirtyFiles : null; - return count != null ? `${count} uncommitted file${count === 1 ? '' : 's'}` : 'uncommitted changes'; - } if (reason.reason === 'attention') { return `${reason.attentionReason} in progress`; } @@ -1073,7 +1069,7 @@ export const GitView: React.FC = () => { const handleCreateBranch = async (branchName: string, remote?: GitRemote) => { if (!currentDirectory || !status) return; - const blockingReasons = getMutationBlockingReasons(worktreeAttachment ?? null, status); + const blockingReasons = getMutationBlockingReasons(worktreeAttachment); if (blockingReasons.length > 0) { toast.error(`Cannot create branch: ${formatBlockingReason(blockingReasons[0])}`); return; @@ -1127,7 +1123,7 @@ export const GitView: React.FC = () => { const handleRenameBranch = async (oldName: string, newName: string) => { if (!currentDirectory) return; - const blockingReasons = getMutationBlockingReasons(worktreeAttachment ?? null, status); + const blockingReasons = getMutationBlockingReasons(worktreeAttachment); if (blockingReasons.length > 0) { toast.error(`Cannot rename branch: ${formatBlockingReason(blockingReasons[0])}`); return; @@ -1149,7 +1145,7 @@ export const GitView: React.FC = () => { if (!currentDirectory) return; // Block mutation if worktree is in an attention-required state - const blockingReasons = getMutationBlockingReasons(worktreeAttachment ?? null, status); + const blockingReasons = getMutationBlockingReasons(worktreeAttachment); if (blockingReasons.length > 0) { toast.error(`Cannot checkout: ${formatBlockingReason(blockingReasons[0])}`); return; diff --git a/packages/ui/src/sync/session-worktree-contract.ts b/packages/ui/src/sync/session-worktree-contract.ts index 933193b4..556a82f1 100644 --- a/packages/ui/src/sync/session-worktree-contract.ts +++ b/packages/ui/src/sync/session-worktree-contract.ts @@ -167,24 +167,14 @@ export function getSessionWorktreeRepairActions( } export type MutationBlockingReason = - | { reason: 'dirty'; dirtyFiles?: number } | { reason: 'attention'; attentionReason: NonNullable } | { reason: 'missing' } | { reason: 'invalid' }; -export type GitStatusForBlocking = { - isClean: boolean; - files?: unknown[]; -}; - export function getMutationBlockingReasons( - attachment: SessionWorktreeAttachment | null | undefined, - gitStatus?: GitStatusForBlocking | null + attachment: SessionWorktreeAttachment | null | undefined ): MutationBlockingReason[] { const reasons: MutationBlockingReason[] = []; - if (gitStatus && !gitStatus.isClean) { - reasons.push({ reason: 'dirty', dirtyFiles: Array.isArray(gitStatus.files) ? gitStatus.files.length : undefined }); - } if (!attachment) return reasons; if (attachment.worktreeStatus === 'missing') { reasons.push({ reason: 'missing' });