The best way to control Claude Code, Codex and more from any computer or phone
fix(mobile): merging a PR uses the project's default merge method (#29857)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Alex Southwell committed
Nov 15, 2026 at 02:25 UTC
d3d7ad9a61e112224ddd1b6daa9f19d9cdae4243
3 files changed
+44
-9
apps/mobile/src/features/pull-requests/PullRequestMergeControls.tsx
+13
-9
@@ -3,12 +3,14 @@ import { useAtomRefresh, useAtomSet, useAtomValue } from "@effect/atom-react";
3
import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
4
import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
5
import type { PullRequestDetail, PullRequestMergeMethod } from "@t3tools/contracts";
6
+import { resolveProjectSettings } from "@t3tools/shared/projectSettings";
7
import { AsyncResult } from "effect/reactivity";
8
import { useRef, useState } from "react";
9
import { View } from "react-native";
10
import { AppText as Text } from "../../components/ui/AppText";
11
import { Button } from "../../components/ui/Button";
12
import { SplitButton } from "../../components/ui/SplitButton";
13
+import { useEnvironmentServerConfig } from "../../state/entities";
14
import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences";
15
import { composerPullRequests } from "../../state/pull-requests";
16
import { useAtomCommand } from "../../state/use-atom-command";
@@ -19,6 +21,7 @@ import {
21
MERGE_METHODS,
22
PR_ACTION_ICONS,
23
pullRequestActionLabel,
24
+ resolveMergeMethod,
25
} from "./pullRequestActions";
26
import { pullRequestStackMerge, singlePullRequestMergeAllowed } from "./pullRequestStack";
27
import { pullRequestTarget, type PullRequestParams } from "./usePullRequestDiff";
@@ -39,6 +42,7 @@ export function PullRequestMergeControls(props: {
42
const permissions = usePullRequestPermissions(props.params, pr);
43
const stateAction = usePullRequestAction(props.params, pr);
44
const preferences = useAtomValue(mobilePreferencesAtom);
45
+ const serverSettings = useEnvironmentServerConfig(target.environmentId)?.settings;
46
const savePreferences = useAtomSet(updateMobilePreferencesAtom);
47
const runAction = useAtomCommand(composerPullRequests.runAction, { reportFailure: false });
48
const refreshDetail = useAtomRefresh(composerPullRequests.detail(target));
@@ -47,15 +51,15 @@ export function PullRequestMergeControls(props: {
51
const [busy, setBusy] = useState(false);
52
const pending = useRef(false);
53
const methods = allowedMergeMethods(pr);
50
- const preferred =
51
- selectedMethod ??
52
- (AsyncResult.isSuccess(preferences) ? preferences.value.pullRequestMergeMethod : undefined) ??
53
- "squash";
54
- const method = methods.includes(preferred)
55
- ? preferred
56
- : methods.includes("squash")
57
- ? "squash"
58
- : methods[0];
54
+ const method = resolveMergeMethod(
55
+ pr,
56
+ selectedMethod,
57
+ serverSettings
58
+ ? resolveProjectSettings(serverSettings, target.input.projectId).settings
59
+ .pullRequestMergeMethod
60
+ : null,
61
+ AsyncResult.isSuccess(preferences) ? preferences.value.pullRequestMergeMethod : undefined,
62
+ );
63
const scope = stack.stack ? pullRequestStackMerge(stack.stack, pr.number, terminology) : null;
64
const canMergeSingle = singlePullRequestMergeAllowed({
65
supportsStackActions: stack.supportsStackActions,
apps/mobile/src/features/pull-requests/pullRequestActions.test.ts
+17
@@ -5,6 +5,7 @@ import {
5
canPerformPullRequestAction,
6
mergeUnavailableReason,
7
pullRequestActionLabel,
8
+ resolveMergeMethod,
9
} from "./pullRequestActions";
10
11
const GITHUB = sourceControlClients.get("github").changeRequest;
@@ -65,6 +66,22 @@ describe("mobile pull request actions", () => {
66
expect(mergeUnavailableReason(pr, true, GITHUB)).toContain("conflicts");
67
});
68
69
+ it("picks the chosen, project default, then last used merge method the repository allows", () => {
70
+ const pr = detail();
71
+ expect(resolveMergeMethod(pr, null, "merge", "squash")).toBe("merge");
72
+ expect(resolveMergeMethod(pr, "squash", "merge", "merge")).toBe("squash");
73
+ expect(resolveMergeMethod(pr, null, "rebase", "merge")).toBe("merge");
74
+ expect(resolveMergeMethod(pr, null, null, undefined)).toBe("squash");
75
+ expect(
76
+ resolveMergeMethod(
77
+ detail({ mergeCapabilities: { merge: true, squash: false, rebase: false } }),
78
+ null,
79
+ null,
80
+ "rebase",
81
+ ),
82
+ ).toBe("merge");
83
+ });
84
+
85
it("names the change request with its host's term", () => {
86
expect(pullRequestActionLabel("close", GITHUB)).toBe("Close pull request");
87
expect(pullRequestActionLabel("close", GITLAB)).toBe("Close merge request");
apps/mobile/src/features/pull-requests/pullRequestActions.ts
+14
@@ -87,6 +87,20 @@ export function allowedMergeMethods(pr: ActionDetail) {
87
return pr.capabilities.mergeMethods.filter((method) => pr.mergeCapabilities[method]);
88
}
89
90
+export function resolveMergeMethod(
91
+ pr: ActionDetail,
92
+ selected: PullRequestMergeMethod | null,
93
+ projectDefault: PullRequestMergeMethod | null,
94
+ lastUsed: PullRequestMergeMethod | undefined,
95
+) {
96
+ const methods = allowedMergeMethods(pr);
97
+ return (
98
+ [selected, projectDefault, lastUsed, "squash" as const].find(
99
+ (method) => method != null && methods.includes(method),
100
+ ) ?? methods[0]
101
+ );
102
+}
103
+
104
export function allowedUpdateMethods(pr: ActionDetail) {
105
return (pr.capabilities.updateMethods ?? []).filter((method) =>
106
pr.viewerPermissions.updateMethods?.includes(method),