From 62cc045dcbbffcb39c1553f1cc537beb72f159a5 Mon Sep 17 00:00:00 2001 From: Dorian Villet Date: Fri, 13 Nov 2026 15:13:54 +0100 Subject: [PATCH 1/3] fix(finish): offer Close task when the branch holds no work When a task's work went out on another branch (a PR on that branch merged, say), the task's own branch has no commits and Finish had no way out: the merged PR is ignored because it is not this branch's, and the local flow only offered Close task once commits had landed. Merge stayed disabled on "No commits on this branch yet", and Push stayed on offer. A branch with no commits since the base and no uncommitted changes, on the task's branch, now counts as having nothing left to merge: the footer says Close task, Push and Create PR are hidden, and a quiet notice says why. Co-Authored-By: Claude Opus 5.5 --- src/components/FinishDialog.client.test.tsx | 65 ++++++++++++++++----- src/components/FinishDialog.tsx | 17 +++--- src/components/MergeSection.tsx | 26 ++++++++- src/components/merge-state.ts | 19 ++++-- 4 files changed, 100 insertions(+), 27 deletions(-) diff --git a/src/components/FinishDialog.client.test.tsx b/src/components/FinishDialog.client.test.tsx index 7f1a9ee6f..856a82111 100644 --- a/src/components/FinishDialog.client.test.tsx +++ b/src/components/FinishDialog.client.test.tsx @@ -681,20 +681,6 @@ describe('FinishDialog merge blocker', () => { ); }); - it('says next to the disabled merge button why it is disabled', async () => { - mockInvoke((channel) => { - if (channel === IPC.GetBranchLog) return ''; - if (channel === IPC.CheckMergeStatus) return { conflicting_files: [], main_ahead_count: 0 }; - return { current_branch: 'task/parent', has_committed_changes: false }; - }); - mount(); - await flush(); - expect(confirmButton()?.disabled).toBe(true); - expect(document.querySelector('[data-testid="footer-note"]')?.textContent).toBe( - 'No commits on this branch yet.', - ); - }); - it('asks for a commit when the changes are not committed yet', async () => { mockInvoke((channel) => { if (channel === IPC.GetBranchLog) return ''; @@ -750,6 +736,57 @@ describe('FinishDialog with the branch already on the base', () => { }); }); +describe('FinishDialog with no work on the branch', () => { + it('says nothing is left to merge and offers to close the task', async () => { + mockInvoke((channel) => { + if (channel === IPC.GetBranchLog) return ''; + if (channel === IPC.CheckMergeStatus) + return { + conflicting_files: [], + main_ahead_count: 3, + remote: 'unpushed', + target_uncommitted: { path: '/repo', files: ['a.ts'], overlap: ['a.ts'] }, + }; + return { + current_branch: 'task/parent', + has_committed_changes: false, + has_uncommitted_changes: false, + }; + }); + const handlers = mount(); + await flush(); + expect(document.body.textContent).toContain( + 'Nothing on this branch: it has no commits and no uncommitted changes, so nothing is left to merge.', + ); + expect(document.querySelector('[data-testid="target-uncommitted"]')).toBeNull(); + // An empty branch has nothing to push or to open a PR with. + expect(document.querySelector('section[aria-label="Pull request"]')).toBeNull(); + expect( + [...document.querySelectorAll('button')].some((b) => b.textContent?.trim() === 'Push'), + ).toBe(false); + expect(document.querySelector('[data-testid="footer-note"]')?.textContent).toBe(''); + expect(confirmButton()?.textContent).toBe('Close task'); + expect(confirmButton()?.disabled).toBe(false); + confirmButton()?.click(); + expect(mergeTask).not.toHaveBeenCalled(); + expect(handlers.onCloseTask).toHaveBeenCalled(); + }); + + it("does not offer to close while the worktree is off the task's branch", async () => { + mockInvoke((channel) => { + if (channel === IPC.GetBranchLog) return ''; + if (channel === IPC.CheckMergeStatus) return { conflicting_files: [], main_ahead_count: 0 }; + // The other branch may hold the task's work. + return { current_branch: 'task/other', has_committed_changes: false }; + }); + mount(); + await flush(); + expect(document.body.textContent).not.toContain('nothing is left to merge'); + expect(confirmButton()?.textContent).not.toBe('Close task'); + expect(confirmButton()?.disabled).toBe(true); + }); +}); + describe('FinishDialog with landed commits on another branch', () => { it("does not call the task landed while the worktree is off the task's branch", async () => { mockInvoke((channel) => { diff --git a/src/components/FinishDialog.tsx b/src/components/FinishDialog.tsx index eac2330cf..153dadfa5 100644 --- a/src/components/FinishDialog.tsx +++ b/src/components/FinishDialog.tsx @@ -129,9 +129,12 @@ export function FinishDialog(props: FinishDialogProps) { headSha: () => (merge.worktreeStatus.error ? null : merge.worktreeStatus()?.head_sha), }); const prMerging = () => pr.busy() === 'merge'; - // Merged on GitHub, or the commits reached the base another way, such as a - // cherry-pick: either way closing the task is all that is left. - const landed = () => pr.mode() === 'merged' || (pr.mode() === 'local' && merge.alreadyLanded()); + // The commits reached the base another way, such as a cherry-pick, or the + // branch holds no work, such as when it went out on another branch. + const nothingLeft = () => merge.alreadyLanded() || merge.nothingToMerge(); + // Merged on GitHub, or nothing left to merge locally: either way closing the + // task is all that is left. + const landed = () => pr.mode() === 'merged' || (pr.mode() === 'local' && nothingLeft()); // A PR merges on GitHub, so a base that moved on locally matters only where // it conflicts or GitHub asks for the branch to be updated. const showBaseSync = () => { @@ -175,7 +178,7 @@ export function FinishDialog(props: FinishDialogProps) { // A local merge uses local commits, so pushing is only on offer, never required. const offerPush = () => pr.mode() === 'local' && - !merge.alreadyLanded() && + !nothingLeft() && (remote() === 'unpushed' || remote() === 'differs'); // Undefined while loading; a loaded status without a remote means there is no origin. const createPrRemote = () => @@ -441,11 +444,11 @@ export function FinishDialog(props: FinishDialogProps) { {retroBox()} {/* Without a PR the section only offers one, where the PR shows once it exists; - without an origin, or with the work on the base already, it needs no word on PRs. */} + without an origin, or with nothing left to merge, it needs no word on PRs. */} + setCreatePrOpen(true)} @@ -470,7 +473,7 @@ export function FinishDialog(props: FinishDialogProps) { diff --git a/src/components/MergeSection.tsx b/src/components/MergeSection.tsx index d293217c8..4cf6316df 100644 --- a/src/components/MergeSection.tsx +++ b/src/components/MergeSection.tsx @@ -118,6 +118,22 @@ export function MergeBlockers(props: MergeSectionProps & { showBaseSync: boolean nothing is left to merge. + +
+ Nothing on this branch: it has no commits and no uncommitted changes, so nothing is left + to merge. +
+
- {/* No merge runs once the branch has landed, so the base checkout's changes do not matter. */} - + {/* No merge runs once the branch has landed or holds nothing, so the base checkout's changes do not matter. */} + {(target) => (
mergeStatus()?.already_landed === true && !hasBranchMismatch(); + /** The task's branch holds no work at all, committed or not, such as when + * that work went out on another branch. A merge commit counts as work: it + * can carry changes of its own. */ + const nothingToMerge = () => { + const status = worktreeStatus(); + return ( + !!status && + !status.has_committed_changes && + !status.has_uncommitted_changes && + !hasBranchMismatch() + ); + }; /** Uncommitted changes in the base checkout; the merge sets them aside. */ const targetUncommitted = () => mergeStatus()?.target_uncommitted; /** The task's uncommitted files the base changed too: they block bringing it in. */ @@ -151,10 +163,8 @@ export function createMergeState(props: MergeStateProps) { const mergeBlocker = (): string | undefined => { if (!worktreeStatus()) return 'Checking the branch…'; if (hasBranchMismatch()) return "The worktree is not on this task's branch."; - if (!hasCommittedChangesToMerge()) - return worktreeStatus()?.has_uncommitted_changes - ? 'Commit the changes to merge them.' - : 'No commits on this branch yet.'; + // A branch with no work at all is nothingToMerge, which offers Close task instead. + if (!hasCommittedChangesToMerge()) return 'Commit the changes to merge them.'; if (hasConflicts()) return `Resolve the conflicts with ${baseBranchName()} first.`; if (targetUncommitted()?.overlap.length) return `Commit or stash the changes in ${baseBranchName()} that this merge touches.`; @@ -271,6 +281,7 @@ export function createMergeState(props: MergeStateProps) { commitCount, hasConflicts, alreadyLanded, + nothingToMerge, targetUncommitted, uncommittedOverlap, hasCommittedChangesToMerge, From 42ee440ee7e5a790e5d6fcd0a843c4dea6063c29 Mon Sep 17 00:00:00 2001 From: Dorian Villet Date: Fri, 13 Nov 2026 15:24:26 +0100 Subject: [PATCH 2/3] style(finish): format offerPush Co-Authored-By: Claude Opus 5.5 --- src/components/FinishDialog.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/FinishDialog.tsx b/src/components/FinishDialog.tsx index 153dadfa5..defe5698c 100644 --- a/src/components/FinishDialog.tsx +++ b/src/components/FinishDialog.tsx @@ -177,9 +177,7 @@ export function FinishDialog(props: FinishDialogProps) { const pushFirst = () => pr.mode() === 'pr' && pr.headDiffers(); // A local merge uses local commits, so pushing is only on offer, never required. const offerPush = () => - pr.mode() === 'local' && - !nothingLeft() && - (remote() === 'unpushed' || remote() === 'differs'); + pr.mode() === 'local' && !nothingLeft() && (remote() === 'unpushed' || remote() === 'differs'); // Undefined while loading; a loaded status without a remote means there is no origin. const createPrRemote = () => merge.mergeStatus.loading || merge.mergeStatus.error || !merge.mergeStatus() From aac5b8e42d63bfc72d0d18449ed9832a62c53ae8 Mon Sep 17 00:00:00 2001 From: Dorian Villet Date: Fri, 13 Nov 2026 15:44:39 +0100 Subject: [PATCH 3/3] fix(finish): drop the nothing-to-merge warning on an empty branch The empty branch's quiet notice already says nothing is left to merge, and Close task is the way out, so the warning-tinted "Nothing to merge" banner beside it repeated the notice with urgency it no longer has. It still shows when changes are only uncommitted. Co-Authored-By: Claude Opus 5.5 --- src/components/FinishDialog.client.test.tsx | 2 ++ src/components/MergeSection.tsx | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/FinishDialog.client.test.tsx b/src/components/FinishDialog.client.test.tsx index 856a82111..a834ce660 100644 --- a/src/components/FinishDialog.client.test.tsx +++ b/src/components/FinishDialog.client.test.tsx @@ -759,6 +759,8 @@ describe('FinishDialog with no work on the branch', () => { 'Nothing on this branch: it has no commits and no uncommitted changes, so nothing is left to merge.', ); expect(document.querySelector('[data-testid="target-uncommitted"]')).toBeNull(); + // The quiet notice says it all; no warning that the merge has nothing to bring in. + expect(document.body.textContent).not.toContain('Nothing to merge:'); // An empty branch has nothing to push or to open a PR with. expect(document.querySelector('section[aria-label="Pull request"]')).toBeNull(); expect( diff --git a/src/components/MergeSection.tsx b/src/components/MergeSection.tsx index 4cf6316df..86a8ea881 100644 --- a/src/components/MergeSection.tsx +++ b/src/components/MergeSection.tsx @@ -178,7 +178,14 @@ export function MergeBlockers(props: MergeSectionProps & { showBaseSync: boolean
)}
- + {/* A branch with no work at all has the quiet notice above: closing is the way out, nothing needs attention. */} +