fix(vcs): expire the conflict notice once the merge or rebase is over (#4251)

"All conflicts resolved" kept its Commit… and Abort Merge actions after the
merge was committed, and Abort Merge then reported no merge in progress. The
conflict notices (key vcs.conflicts) now expire when the repository leaves
the merge, rebase, cherry-pick, revert or am they refer to, however it ended.

Fixes #4154
This commit is contained in:
l0ng-ai
2026-11-18 18:53:43 +08:00
committed by GitHub
parent 71090202b6
commit 0fab45689f
3 changed files with 45 additions and 1 deletions
@@ -0,0 +1,32 @@
import { afterEach, beforeEach, expect, it, vi } from "vitest";
import type { BranchInfo } from "@/bindings";
import { installOperationNoticeExpiry } from "../operations";
import { useVcs } from "../store";
const { expire } = vi.hoisted(() => ({ expire: vi.fn() }));
vi.mock("@/workbench/contributions", async (original) => ({
...(await original<typeof import("@/workbench/contributions")>()),
notifications: () => ({ notify: vi.fn(), expire }),
}));
const branch = (operation: string | null) => ({ head: "main", operation }) as unknown as BranchInfo;
let dispose: () => void;
beforeEach(() => {
expire.mockClear();
useVcs.setState({ branch: branch("merge") });
dispose = installOperationNoticeExpiry();
});
afterEach(() => dispose());
it("expires the conflict notice once the merge it offers to commit or abort is over", () => {
useVcs.setState({ branch: branch("merge") });
expect(expire).not.toHaveBeenCalled();
useVcs.setState({ branch: branch(null) });
expect(expire).toHaveBeenCalledWith("vcs.conflicts");
});
it("keeps it while an operation is still in progress", () => {
useVcs.setState({ branch: branch("rebase") });
expect(expire).not.toHaveBeenCalled();
});
+2 -1
View File
@@ -20,7 +20,7 @@ import { registerVcsActions } from "./actions";
import { installChangelists } from "./changelists";
import { registerHistoryActions, trackOperationContext } from "./historyActions";
import { registerLogPaneActions } from "./logPaneActions";
import { controlLabel, controlOperation, inProgress } from "./operations";
import { controlLabel, controlOperation, inProgress, installOperationNoticeExpiry } from "./operations";
import { annotationsShown, blameSlot } from "./blame";
import { activateRevisionAnnotations } from "./annotateRevisionProvider";
import { inlineBlame } from "./inlineBlame";
@@ -195,6 +195,7 @@ export function activate(): () => void {
useCommit.setState({ signOff: workflowSettings().vcs.git.signOff });
const disposers = [
installVcsStore(),
installOperationNoticeExpiry(),
installRootSync(),
installGitLog(),
installDiagnosticsTracking(),
+11
View File
@@ -56,6 +56,17 @@ export function inProgress(op: string | null | undefined = useVcs.getState().bra
return op === "rebase" || op === "merge" || op === "cherry-pick" || op === "revert" || op === "am" ? op : null;
}
/**
* Expires the conflict notices (key `vcs.conflicts`: Merge conflicts, All conflicts resolved) once
* the merge / rebase / cherry-pick they offer to continue or abort is over, however it ended.
*/
export function installOperationNoticeExpiry(): () => void {
return useVcs.subscribe((s, prev) => {
if (inProgress(prev.branch?.operation) && !inProgress(s.branch?.operation))
notifications().expire?.("vcs.conflicts");
});
}
/** "Rebasing main", "Merging", "Cherry-picking"… for the branch widget and banner. */
export function operationTitle(op: InProgress, head: string | null): string {
if (!head)