The best way to control Claude Code, Codex and more from any computer or phone
fix(web): thread details PR merge uses the last selected merge method (#22399)
Tristan Knight committed
Oct 21, 2026 at 23:10 UTC
a35066d9f21616056bc438c894573900ebe87352
4 files changed
+55
-13
apps/web/src/components/chat/ThreadDetailsPrRow.browser.test.tsx
+42
-2
@@ -6,6 +6,7 @@ import { expect, it, vi } from "vite-plus/test";
6
const state = vi.hoisted(() => ({
7
status: "success" as PullRequestCheck["status"],
8
extraStatus: null as PullRequestCheck["status"] | null,
9
+ mergeMethods: ["merge"] as Array<"merge" | "squash" | "rebase">,
10
perform: vi.fn(),
11
newThread: vi.fn(),
12
prepareThread: vi.fn(),
@@ -45,9 +46,13 @@ const queryData = () => ({
46
description: null,
47
url: null,
48
})),
48
- capabilities: { actions: ["merge"], mergeMethods: ["merge"] },
49
+ capabilities: { actions: ["merge"], mergeMethods: state.mergeMethods },
50
viewerPermissions: { actions: ["merge"] },
50
- mergeCapabilities: { merge: true, squash: false, rebase: false },
51
+ mergeCapabilities: {
52
+ merge: state.mergeMethods.includes("merge"),
53
+ squash: state.mergeMethods.includes("squash"),
54
+ rebase: state.mergeMethods.includes("rebase"),
55
+ },
56
});
57
vi.mock(import("~/state/query"), async (importOriginal) => ({
58
...(await importOriginal()),
@@ -96,8 +101,41 @@ vi.mock(import("../ui/toast"), async (original) => {
101
});
102
103
import { act, render as renderUi } from "../../../test/render";
104
+import { useUiStateStore } from "~/uiStateStore";
105
import { ThreadDetailsPrRow } from "./ThreadDetailsPrRow";
106
107
+it("merges with the last selected merge method", async () => {
108
+ await using screen = await setup();
109
+ const { container } = screen;
110
+ state.mergeMethods = ["merge", "squash"];
111
+ useUiStateStore.getState().setPullRequestMergeMethod("squash");
112
+ await act(async () => {
113
+ await screen.rerender(
114
+ <ThreadDetailsPrRow
115
+ environmentId={EnvironmentId.make("environment")}
116
+ pr={null}
117
+ number={1}
118
+ status={null}
119
+ project={null}
120
+ label="Test PR"
121
+ openAriaLabel="Open PR"
122
+ onOpen={vi.fn()}
123
+ />,
124
+ );
125
+ });
126
+ const clickMerge = async (scope: ParentNode) =>
127
+ await act(async () => {
128
+ [...scope.querySelectorAll("button")]
129
+ .find((button) => button.textContent?.trim() === "Merge")!
130
+ .click();
131
+ });
132
+ await clickMerge(container);
133
+ const dialog = document.querySelector('[role="alertdialog"]')!;
134
+ expect(dialog.textContent).toContain("using squash");
135
+ await clickMerge(dialog);
136
+ expect(state.perform).toHaveBeenCalledWith("merge", "squash");
137
+});
138
+
139
it("requires a new merge click after passing checks become pending and pass again", async () => {
140
await using screen = await setup();
141
const { container } = screen;
@@ -152,5 +190,7 @@ async function setup() {
190
191
state.status = "success";
192
state.extraStatus = null;
193
+ state.mergeMethods = ["merge"];
194
+ useUiStateStore.getState().setPullRequestMergeMethod("merge");
195
return renderUi(null);
196
}
apps/web/src/components/chat/ThreadDetailsPrRow.tsx
+12
-3
@@ -21,6 +21,7 @@ import { usePullRequestChecksRefresh } from "~/hooks/usePullRequestChecksRefresh
21
import { cn } from "~/lib/utils";
22
import { useServerConfigs } from "~/state/entities";
23
import { pullRequestEnvironment } from "~/state/pullRequests";
24
+import { useUiStateStore } from "~/uiStateStore";
25
import {
26
useEnvironmentQueryIsNewer,
27
useEnvironmentQueryRefresh,
@@ -33,7 +34,7 @@ import {
34
classifyPullRequestChecks,
35
describePullRequestChecks,
36
isPullRequestConflicting,
36
- resolveSelectedMergeMethod,
37
+ resolvePullRequestMergeMethod,
38
allowedPullRequestMergeMethods,
39
resolveThreadPanelPullRequestAction,
40
} from "../pullRequest/pullRequestDetail.logic";
@@ -46,6 +47,7 @@ import {
47
} from "../pullRequest/pullRequestPresentation";
48
import {
49
usePullRequestActionRunner,
50
+ usePullRequestDefaultMergeMethodResolver,
51
usePullRequestHandoffs,
52
} from "../pullRequest/usePullRequestActions";
53
import {
@@ -166,6 +168,11 @@ export function ThreadDetailsPrRow({
168
},
169
});
170
const { handoff, startHandoff } = usePullRequestHandoffs({ environmentId, detail });
171
+ const lastSelectedMergeMethod = useUiStateStore((state) => state.pullRequestMergeMethod);
172
+ const resolveProjectDefaultMergeMethod = usePullRequestDefaultMergeMethodResolver(
173
+ environmentId,
174
+ (project?.id as ProjectId | undefined) ?? null,
175
+ );
176
const [confirmingMerge, setConfirmingMerge] = useState(false);
177
178
const rowAction = resolveThreadPanelPullRequestAction(detail);
@@ -175,9 +182,11 @@ export function ThreadDetailsPrRow({
182
const conflicting = isPullRequestConflicting(detail);
183
const checksState = detail === null ? "none" : classifyPullRequestChecks(detail.checks);
184
const checksRollup = detail === null ? null : pullRequestChecksState(detail.checks);
178
- const selectedMergeMethod = resolveSelectedMergeMethod(
185
+ const selectedMergeMethod = resolvePullRequestMergeMethod(
186
allowedPullRequestMergeMethods(detail),
180
- "merge",
187
+ null,
188
+ resolveProjectDefaultMergeMethod(),
189
+ lastSelectedMergeMethod,
190
);
191
192
const startResolveConflicts = () => {
apps/web/src/components/pullRequest/pullRequestDetail.logic.ts
-7
@@ -292,13 +292,6 @@ export function allowedPullRequestMergeMethods(
292
: detail.capabilities.mergeMethods.filter((method) => detail.mergeCapabilities[method]);
293
}
294
295
-export function resolveSelectedMergeMethod(
296
- allowedMergeMethods: ReadonlyArray<PullRequestMergeMethod>,
297
- preferred: PullRequestMergeMethod,
298
-): PullRequestMergeMethod {
299
- return allowedMergeMethods.includes(preferred) ? preferred : (allowedMergeMethods[0] ?? "merge");
300
-}
301
-
295
function canPerformPullRequestAction(
296
detail: Pick<PullRequestActionableDetail, "capabilities" | "viewerPermissions"> | null,
297
action: PullRequestAction,
apps/web/src/components/pullRequest/usePullRequestActions.ts
+1
-1
@@ -42,7 +42,7 @@ import { pullRequestEntryKey, type EnvironmentPullRequestEntry } from "./pullReq
42
43
export function usePullRequestDefaultMergeMethodResolver(
44
environmentId: EnvironmentId,
45
- projectId: ProjectId,
45
+ projectId: ProjectId | null,
46
) {
47
const projectDefault = useEnvironmentSettings(
48
environmentId,