The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 25, 11:00 UTC
Fix PR CTAs and quick action after push
Co-authored-by: codex <codex@users.noreply.github.com>
Julius Marminge committed
Mar 2, 2026 at 20:04 UTC
f11764c517732b1c02057f28ff1a10f03f8157da
3 files changed
+53
-10
apps/web/src/components/GitActionsControl.logic.test.ts
+21
-4
@@ -250,15 +250,20 @@ describe("when: branch is clean, ahead, and has no open PR", () => {
250
});
251
252
describe("when: branch is clean, up to date, and has no open PR", () => {
253
- it("resolveQuickAction returns disabled no-action state", () => {
253
+ it("resolveQuickAction offers create PR", () => {
254
const quick = resolveQuickAction(
255
status({ aheadCount: 0, behindCount: 0, hasWorkingTreeChanges: false, pr: null }),
256
false,
257
);
258
- assert.deepInclude(quick, { kind: "show_hint", label: "Commit", disabled: true });
258
+ assert.deepInclude(quick, {
259
+ kind: "run_action",
260
+ action: "commit_push_pr",
261
+ label: "Create PR",
262
+ disabled: false,
263
+ });
264
});
265
261
- it("buildMenuItems disables commit, push, and create PR", () => {
266
+ it("buildMenuItems enables create PR and keeps commit/push disabled", () => {
267
const items = buildMenuItems(status({ aheadCount: 0, behindCount: 0, pr: null }), false);
268
assert.deepEqual(items, [
269
{
@@ -280,13 +285,25 @@ describe("when: branch is clean, up to date, and has no open PR", () => {
285
{
286
id: "pr",
287
label: "Create PR",
283
- disabled: true,
288
+ disabled: false,
289
icon: "pr",
290
kind: "open_dialog",
291
dialogAction: "create_pr",
292
},
293
]);
294
});
295
+
296
+ it("buildMenuItems keeps create PR disabled on default branch", () => {
297
+ const items = buildMenuItems(status({ branch: "main", aheadCount: 0, behindCount: 0 }), false, true);
298
+ assert.deepEqual(items[2], {
299
+ id: "pr",
300
+ label: "Create PR",
301
+ disabled: true,
302
+ icon: "pr",
303
+ kind: "open_dialog",
304
+ dialogAction: "create_pr",
305
+ });
306
+ });
307
});
308
309
describe("when: branch is behind upstream", () => {
apps/web/src/components/GitActionsControl.logic.ts
+13
-2
@@ -113,6 +113,7 @@ export function summarizeGitResult(result: GitRunStackedActionResult): {
113
export function buildMenuItems(
114
gitStatus: GitStatusResult | null,
115
isBusy: boolean,
116
+ isDefaultBranch = false,
117
): GitActionMenuItem[] {
118
if (!gitStatus) return [];
119
@@ -127,8 +128,9 @@ export function buildMenuItems(
128
hasBranch &&
129
!hasChanges &&
130
!hasOpenPr &&
130
- gitStatus.aheadCount > 0 &&
131
- !isBehind;
131
+ !isBehind &&
132
+ !isDefaultBranch &&
133
+ (gitStatus.aheadCount > 0 || gitStatus.hasUpstream);
134
const canOpenPr = !isBusy && hasOpenPr;
135
136
return [
@@ -265,6 +267,15 @@ export function resolveQuickAction(
267
};
268
}
269
270
+ if (!hasOpenPr && !isDefaultBranch && gitStatus.hasUpstream) {
271
+ return {
272
+ label: "Create PR",
273
+ disabled: false,
274
+ kind: "run_action",
275
+ action: "commit_push_pr",
276
+ };
277
+ }
278
+
279
if (hasOpenPr && gitStatus.hasUpstream) {
280
return { label: "Open PR", disabled: false, kind: "open_pr" };
281
}
apps/web/src/components/GitActionsControl.tsx
+19
-4
@@ -180,10 +180,19 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
180
const current = branchList?.branches.find((branch) => branch.name === branchName);
181
return current?.isDefault ?? (branchName === "main" || branchName === "master");
182
}, [branchList?.branches, gitStatusForActions?.branch]);
183
+ const isDefaultBranchName = useCallback(
184
+ (branchName: string | null | undefined) => {
185
+ if (!branchName) return false;
186
+ const defaultBranchName = branchList?.branches.find((branch) => branch.isDefault)?.name;
187
+ if (defaultBranchName) return branchName === defaultBranchName;
188
+ return branchName === "main" || branchName === "master";
189
+ },
190
+ [branchList?.branches],
191
+ );
192
193
const gitActionMenuItems = useMemo(
185
- () => buildMenuItems(gitStatusForActions, isGitActionRunning),
186
- [gitStatusForActions, isGitActionRunning],
194
+ () => buildMenuItems(gitStatusForActions, isGitActionRunning, isDefaultBranch),
195
+ [gitStatusForActions, isGitActionRunning, isDefaultBranch],
196
);
197
const quickAction = useMemo(
198
() => resolveQuickAction(gitStatusForActions, isGitActionRunning, isDefaultBranch),
@@ -237,6 +246,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
246
onConfirmed,
247
skipDefaultBranchPrompt = false,
248
featureBranch = false,
249
+ isDefaultBranchOverride,
250
}: {
251
action: GitStackedAction;
252
commitMessage?: string;
@@ -244,10 +254,12 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
254
onConfirmed?: () => void;
255
skipDefaultBranchPrompt?: boolean;
256
featureBranch?: boolean;
257
+ isDefaultBranchOverride?: boolean;
258
}) => {
259
const actionStatus = gitStatusForActions;
249
- const actionIsDefaultBranch = featureBranch ? false : isDefaultBranch;
260
const actionBranch = actionStatus?.branch ?? null;
261
+ const actionIsDefaultBranch =
262
+ isDefaultBranchOverride ?? (featureBranch ? false : isDefaultBranchName(actionBranch));
263
const includesCommit =
264
!forcePushOnlyProgress && (action === "commit" || !!actionStatus?.hasWorkingTreeChanges);
265
if (
@@ -348,6 +360,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
360
forcePushOnlyProgress: true,
361
onConfirmed: closeResultToast,
362
...(featureBranch ? { skipDefaultBranchPrompt: true } : {}),
363
+ ...(featureBranch ? { isDefaultBranchOverride: false } : {}),
364
});
365
},
366
},
@@ -374,6 +387,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
387
action: "commit_push_pr",
388
forcePushOnlyProgress: true,
389
...(featureBranch ? { skipDefaultBranchPrompt: true } : {}),
390
+ ...(featureBranch ? { isDefaultBranchOverride: false } : {}),
391
});
392
},
393
},
@@ -392,7 +406,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
406
},
407
408
[
395
- isDefaultBranch,
409
+ isDefaultBranchName,
410
runImmediateGitActionMutation,
411
setPendingDefaultBranchAction,
412
threadToastData,
@@ -410,6 +424,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
424
forcePushOnlyProgress,
425
...(onConfirmed ? { onConfirmed } : {}),
426
skipDefaultBranchPrompt: true,
427
+ isDefaultBranchOverride: true,
428
});
429
}, [pendingDefaultBranchAction, runGitActionWithToast]);
430