Add default-branch safeguard with auto feature-branch fallback#131

merged15
main
codething/2b37f0ce
openedMar 1, 2026byJJulius Marminge
View on GitHubTwo-way sync enabledPR last imported Oct 21, 2026

Summary

  • Add a default-branch safety flow that can auto-generate a feature branch name (feature/stacked-YYYYMMDD with numeric suffixes on conflicts).
  • Introduce and test resolveAutoFeatureBranchName logic for deterministic branch naming and collision handling.
  • Simplify git branch handling to local branches only in server/core contracts and UI consumers.
  • Remove remote-branch-specific parsing, deduping, checkout fallback heuristics, and related tests.
  • Tighten branch and diff UI behavior (badge display simplification and diff panel interaction/layout cleanup).

Testing

  • Added unit tests for resolveAutoFeatureBranchName in apps/web/src/components/GitActionsControl.logic.test.ts (base-name and suffix-collision scenarios).
  • Updated branch-toolbar tests to reflect removal of remote-branch dedupe helpers.
  • Not run: full lint/test suite in this PR context.

Note

Medium Risk Changes core git status/push logic and UI action flows around upstreamless branches and default-branch operations, which could alter when pushes are skipped or upstreams are auto-set. Risk is moderated by added integration/unit tests but still impacts common git workflows.

Overview Improves upstream-less branch handling by computing aheadCount against a resolved base branch (configured branch.<name>.gh-merge-base, origin/HEAD, or main/master) when no upstream is set, and using that to drive statusDetails and pushCurrentBranch decisions.

Updates push behavior to skip when there’s no local delta and the remote branch already exists, and to auto-push with -u origin <branch> when no upstream exists but the branch needs publishing; adds server tests covering these edge cases and a manager test for creating a PR from a no-upstream branch.

Adjusts the web git actions UI to allow push/PR actions without an upstream, adds a default-branch confirmation dialog with improved copy plus an option to auto-create/checkout a dated feature branch (feature/stacked-YYYYMMDD[-N]) and continue the action; includes new unit tests for the naming and dialog-copy logic.

Written by Cursor Bugbot for commit 839feaf2506bb36274f4ead5ad777efb8d422482. This will update automatically on new commits. Configure here.

Note

Add a default-branch safeguard and auto feature-branch fallback by updating GitCore.pushCurrentBranch and GitActionsControl to compute ahead counts without upstream and gate push/PR flows on main/master

Introduce base-branch resolution and ahead-count computation for no-upstream branches in apps/server/src/git/Layers/GitCore.ts, adjust push behavior to skip or set upstream based on remote presence, and add UI flows to confirm actions on the default branch with auto feature-branch naming in apps/web/src/components/GitActionsControl.tsx.

📍Where to Start

Start with GitCore.readStatusDetails and GitCore.pushCurrentBranch in GitCore.ts, then review the default-branch confirmation flow in GitActionsControl.tsx.

Macroscope summarized 839feaf.

Added 1 commit

  • Add default-branch safeguard with auto feature branch fallback1d34656
Synced from GitHub

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codething/2b37f0ce

Comment @coderabbitai help to get the list of available commands and usage tips.

Added 3 commits

  • Enable push/PR actions for branches without upstream4dfc28f
  • Add coverage for no-upstream default-branch quick actions57ebd79
  • Require ahead commits before offering Create PR on untracked branchesa059886
Ccursor[bot]reviewed · 2 inline threadsMar 1, 2026
Synced from GitHub

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Autofix Details

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: PR disabled reason inconsistent with updated canCreatePr logic
    • Removed the stale !gitStatus.hasUpstream check from getMenuActionDisabledReason so that when a branch has no upstream and no commits ahead, the correct message "No local commits to include in a PR" is shown instead of the misleading upstream message.
  • ✅ Fixed: Duplicated branch-checkout-and-continue logic across callbacks
    • Extracted the shared checkout-toast-chain pattern into a checkoutNewBranchAndRunAction helper callback, reducing both checkoutFeatureBranchAndContinuePendingAction and runDialogActionOnNewBranch to thin wrappers that delegate to it.

Create PR

Or push these changes by commenting:

1@cursor push 175f39a882
Preview (pingdotgg/t3code@175f39a882)
diff
1diff --git a/apps/web/src/components/GitActionsControl.tsx b/apps/web/src/components/GitActionsControl.tsx
2--- a/apps/web/src/components/GitActionsControl.tsx
3+++ b/apps/web/src/components/GitActionsControl.tsx
4@@ -105,9 +105,6 @@
5 if (hasChanges) {
6 return "Commit local changes before creating a PR.";
7 }
8- if (!gitStatus.hasUpstream) {
9- return "Set an upstream branch before creating a PR.";
10- }
11 if (!isAhead) {
12 return "No local commits to include in a PR.";
13 }
14@@ -314,7 +311,8 @@
15 stopProgressUpdates();
16 const resultToast = summarizeGitResult(result);
17
18- const existingOpenPrUrl = actionStatus?.pr?.state === "open" ? actionStatus.pr.url : undefined;
19+ const existingOpenPrUrl =
20+ actionStatus?.pr?.state === "open" ? actionStatus.pr.url : undefined;
21 const prUrl = result.pr.url ?? existingOpenPrUrl;
22 const shouldOfferPushCta = action === "commit" && result.commit.status === "created";
23 const shouldOfferOpenPrCta =
24@@ -406,96 +404,72 @@
25 });
26 }, [pendingDefaultBranchAction, runGitActionWithToast]);
27
28+ const checkoutNewBranchAndRunAction = useCallback(
29+ (actionParams: {
30+ action: GitStackedAction;
31+ commitMessage?: string;
32+ forcePushOnlyProgress?: boolean;
33+ onConfirmed?: () => void;
34+ }) => {
35+ const branchName = resolveAutoFeatureBranchName(
36+ branchList?.branches.map((branch) => branch.name) ?? [],
37+ );
38+
39+ const checkoutPromise = createBranchAndCheckoutMutation.mutateAsync(branchName);
40+ toastManager.promise(checkoutPromise, {
41+ loading: { title: `Creating ${branchName}...`, data: threadToastData },
42+ success: () => ({
43+ title: `Checked out ${branchName}`,
44+ data: threadToastData,
45+ }),
46+ error: (error) => ({
47+ title: "Failed to checkout feature branch",
48+ description: error instanceof Error ? error.message : "An error occurred.",
49+ data: threadToastData,
50+ }),
51+ });
52+
53+ void checkoutPromise
54+ .then(() => {
55+ const statusOverride = gitStatusForActions
56+ ? { ...gitStatusForActions, branch: branchName, pr: null }
57+ : null;
58+ return runGitActionWithToast({
59+ ...actionParams,
60+ skipDefaultBranchPrompt: true,
61+ statusOverride,
62+ isDefaultBranchOverride: false,
63+ });
64+ })
65+ .catch(() => undefined);
66+ },
67+ [
68+ branchList?.branches,
69+ createBranchAndCheckoutMutation,
70+ gitStatusForActions,
71+ runGitActionWithToast,
72+ threadToastData,
73+ ],
74+ );
75+
76 const checkoutFeatureBranchAndContinuePendingAction = useCallback(() => {
77 if (!pendingDefaultBranchAction) return;
78 const pendingAction = pendingDefaultBranchAction;
79- const branchName = resolveAutoFeatureBranchName(branchList?.branches.map((branch) => branch.name) ?? []);
80 setPendingDefaultBranchAction(null);
81+ checkoutNewBranchAndRunAction(pendingAction);
82+ }, [pendingDefaultBranchAction, checkoutNewBranchAndRunAction]);
83
84- const checkoutPromise = createBranchAndCheckoutMutation.mutateAsync(branchName);
85- toastManager.promise(checkoutPromise, {
86- loading: { title: `Creating ${branchName}...`, data: threadToastData },
87- success: () => ({
88- title: `Checked out ${branchName}`,
89- data: threadToastData,
90- }),
91- error: (error) => ({
92- title: "Failed to checkout feature branch",
93- description: error instanceof Error ? error.message : "An error occurred.",
94- data: threadToastData,
95- }),
96- });
97-
98- void checkoutPromise
99- .then(() => {
100- const statusOverride = gitStatusForActions
101- ? { ...gitStatusForActions, branch: branchName, pr: null }
102- : null;
103- return runGitActionWithToast({
104- ...pendingAction,
105- skipDefaultBranchPrompt: true,
106- statusOverride,
107- isDefaultBranchOverride: false,
108- });
109- })
110- .catch(() => undefined);
111- }, [
112- branchList?.branches,
113- createBranchAndCheckoutMutation,
114- gitStatusForActions,
115- pendingDefaultBranchAction,
116- runGitActionWithToast,
117- threadToastData,
118- ]);
119-
120 const runDialogActionOnNewBranch = useCallback(() => {
121 if (!isCommitDialogOpen) return;
122- const action: GitStackedAction = "commit";
123 const commitMessage = dialogCommitMessage.trim();
124- const branchName = resolveAutoFeatureBranchName(branchList?.branches.map((branch) => branch.name) ?? []);
125-
126 setIsCommitDialogOpen(false);
127 setDialogCommitMessage("");
128-
129- const checkoutPromise = createBranchAndCheckoutMutation.mutateAsync(branchName);
130- toastManager.promise(checkoutPromise, {
131- loading: { title: `Creating ${branchName}...`, data: threadToastData },
132- success: () => ({
133- title: `Checked out ${branchName}`,
134- data: threadToastData,
135- }),
136- error: (error) => ({
137- title: "Failed to checkout feature branch",
138- description: error instanceof Error ? error.message : "An error occurred.",
139- data: threadToastData,
140- }),
141+ checkoutNewBranchAndRunAction({
142+ action: "commit",
143+ ...(commitMessage ? { commitMessage } : {}),
144 });
145+ }, [isCommitDialogOpen, dialogCommitMessage, checkoutNewBranchAndRunAction]);
146
147- void checkoutPromise
148- .then(() => {
149- const statusOverride = gitStatusForActions
150- ? { ...gitStatusForActions, branch: branchName, pr: null }
151- : null;
152- return runGitActionWithToast({
153- action,
154- ...(commitMessage ? { commitMessage } : {}),
155- skipDefaultBranchPrompt: true,
156- statusOverride,
157- isDefaultBranchOverride: false,
158- });
159- })
160- .catch(() => undefined);
161- }, [
162- branchList?.branches,
163- createBranchAndCheckoutMutation,
164- dialogCommitMessage,
165- gitStatusForActions,
166- isCommitDialogOpen,
167- runGitActionWithToast,
168- setIsCommitDialogOpen,
169- threadToastData,
170- ]);
171-
172 const runQuickAction = useCallback(() => {
173 if (quickAction.kind === "open_pr") {
174 void openExistingPr();
175@@ -738,7 +712,9 @@
176 <div className="grid grid-cols-[auto_1fr] items-center gap-x-2 gap-y-1">
177 <span className="text-muted-foreground">Branch</span>
178 <span className="flex items-center justify-between gap-2">
179- <span className="font-medium">{gitStatusForActions?.branch ?? "(detached HEAD)"}</span>
180+ <span className="font-medium">
181+ {gitStatusForActions?.branch ?? "(detached HEAD)"}
182+ </span>
183 {isDefaultBranch && (
184 <span className="text-right text-warning text-xs">Warning: default branch</span>
185 )}
……@@ -94,28 +105,26 @@ function getMenuActionDisabledReason(
106117 return "Create PR is currently unavailable.";
107118}
108119
109-const DIALOG_TITLE_BY_ACTION = {
Ccursor[bot]on line 109 (old)Mar 1, 2026

PR disabled reason inconsistent with updated canCreatePr logic

Medium Severity

The !gitStatus.hasUpstream check in getMenuActionDisabledReason was moved before the !isAhead check, but canCreatePr in buildMenuItems no longer requires hasUpstream. When a branch has no upstream and no commits ahead (!hasUpstream && aheadCount === 0), the tooltip now reads "Set an upstream branch before creating a PR" — but the actual blocker is having no commits ahead, and setting an upstream wouldn't enable the PR button. The old ordering checked !isAhead first, which gave the correct message.

Additional Locations (1)

Fix in Cursor Fix in Web

apps/web/src/components/GitActionsControl.tsxline 449Outdated · a059886Open thread
……@@ -365,17 +388,114 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
446+ pendingDefaultBranchAction,
447+ runGitActionWithToast,
448+ threadToastData,
449+ ]);

Duplicated branch-checkout-and-continue logic across callbacks

Low Severity

checkoutFeatureBranchAndContinuePendingAction and runDialogActionOnNewBranch duplicate ~25 lines of nearly identical logic: resolving a feature branch name, calling createBranchAndCheckoutMutation.mutateAsync, setting up the same toast messages, building a statusOverride with the new branch name and pr: null, and chaining runGitActionWithToast with skipDefaultBranchPrompt and isDefaultBranchOverride: false. Extracting the shared checkout-toast-chain pattern into a helper would reduce the duplication.

Additional Locations (1)

Fix in Cursor Fix in Web

Added 1 commit

  • Handle no-upstream branches by comparing commits against base79f636a
apps/server/src/git/Layers/GitCore.tsline 547Outdated · 79f636aOpen thread
……@@ -452,7 +544,7 @@ const makeGitCore = Effect.gen(function* () {
453545 }
454546
455- if (details.hasUpstream && details.aheadCount === 0 && details.behindCount === 0) {
547+ if (details.aheadCount === 0 && details.behindCount === 0) {
MmacroscopeappBoton line 547Mar 1, 2026

🟡 Medium Layers/GitCore.ts:547

The condition removed the details.hasUpstream check. Now a new branch with no upstream and aheadCount === 0 (e.g., initial branch with no base to compare against) will incorrectly return skipped_up_to_date instead of pushing with -u. Consider restoring details.hasUpstream && to the condition.

✅ Resolved in 839feaf2506bb36274f4ead5ad777efb8d422482

Added 2 commits

  • refactor: dedupe git action new-branch flow425b32f
  • fix: avoid no-upstream push skip when base cannot be resolved0697ff8
Ccursor[bot]reviewed · 1 inline threadMar 1, 2026
Synced from GitHub

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Stale closure in toast CTA after feature-branch checkout
    • Added a useRef that always points to the latest runGitActionWithToast, and updated the toast CTA onClick handlers (Push and Create PR) to call via the ref instead of the stale closure, ensuring they always use current isDefaultBranch and gitStatusForActions values.

Create PR

Or push these changes by commenting:

1@cursor push c2a5cab307
Preview (pingdotgg/t3code@c2a5cab307)
diff
1diff --git a/apps/web/src/components/GitActionsControl.tsx b/apps/web/src/components/GitActionsControl.tsx
2--- a/apps/web/src/components/GitActionsControl.tsx
3+++ b/apps/web/src/components/GitActionsControl.tsx
4@@ -1,6 +1,6 @@
5 import { type GitStatusResult, type GitStackedAction, type ThreadId } from "@t3tools/contracts";
6 import { useIsMutating, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
7-import { useCallback, useEffect, useMemo, useState } from "react";
8+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
9 import { ChevronDownIcon, CloudUploadIcon, GitCommitIcon, InfoIcon } from "lucide-react";
10 import { GitHubIcon } from "./Icons";
11 import {
12@@ -308,7 +308,8 @@
13 stopProgressUpdates();
14 const resultToast = summarizeGitResult(result);
15
16- const existingOpenPrUrl = actionStatus?.pr?.state === "open" ? actionStatus.pr.url : undefined;
17+ const existingOpenPrUrl =
18+ actionStatus?.pr?.state === "open" ? actionStatus.pr.url : undefined;
19 const prUrl = result.pr.url ?? existingOpenPrUrl;
20 const shouldOfferPushCta = action === "commit" && result.commit.status === "created";
21 const shouldOfferOpenPrCta =
22@@ -338,7 +339,7 @@
23 actionProps: {
24 children: "Push",
25 onClick: () => {
26- void runGitActionWithToast({
27+ void runGitActionWithToastRef.current({
28 action: "commit_push",
29 forcePushOnlyProgress: true,
30 onConfirmed: closeResultToast,
31@@ -364,7 +365,7 @@
32 children: "Create PR",
33 onClick: () => {
34 closeResultToast();
35- void runGitActionWithToast({ action: "commit_push_pr" });
36+ void runGitActionWithToastRef.current({ action: "commit_push_pr" });
37 },
38 },
39 }
40@@ -390,6 +391,9 @@
41 ],
42 );
43
44+ const runGitActionWithToastRef = useRef(runGitActionWithToast);
45+ runGitActionWithToastRef.current = runGitActionWithToast;
46+
47 const continuePendingDefaultBranchAction = useCallback(() => {
48 if (!pendingDefaultBranchAction) return;
49 const pendingAction = pendingDefaultBranchAction;
50@@ -710,7 +714,9 @@
51 <div className="grid grid-cols-[auto_1fr] items-center gap-x-2 gap-y-1">
52 <span className="text-muted-foreground">Branch</span>
53 <span className="flex items-center justify-between gap-2">
54- <span className="font-medium">{gitStatusForActions?.branch ?? "(detached HEAD)"}</span>
55+ <span className="font-medium">
56+ {gitStatusForActions?.branch ?? "(detached HEAD)"}
57+ </span>
58 {isDefaultBranch && (
59 <span className="text-right text-warning text-xs">Warning: default branch</span>
60 )}
……@@ -365,17 +382,92 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
365382 },
366383
367384 [
368- gitStatusForActions?.branch,
Ccursor[bot]on line 368 (old)Mar 1, 2026

Stale closure in toast CTA after feature-branch checkout

Medium Severity

The "Create PR" toast CTA calls runGitActionWithToast through a closure that captures stale isDefaultBranch and gitStatusForActions values. After the feature-branch checkout flow (default-branch dialog → "Checkout feature branch & continue" → commit & push succeeds), the toast CTA still holds the old closure where isDefaultBranch is true and gitStatusForActions refers to the original default branch. Clicking "Create PR" then incorrectly re-triggers the default-branch confirmation dialog with the wrong branch name, or may create a spurious second feature branch if the user picks "Checkout feature branch" again. The old code used the stable setActiveDialogAction state setter here, which didn't suffer from this stale-capture issue.

Additional Locations (1)

Fix in Cursor Fix in Web

Added 1 commit

  • fix: keep toast CTA git actions on the active feature brancha511de3
Ccursor[bot]reviewed · 1 inline threadMar 1, 2026
Synced from GitHub

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Base branch lookup ignores remote-tracking refs
    • Added a fallback check for refs/remotes/origin/ in resolveBaseBranchForNoUpstream so that when a base branch exists only as a remote-tracking ref, it returns origin/ instead of null.

Create PR

Or push these changes by commenting:

1@cursor push 09e1d6f726
Preview (pingdotgg/t3code@09e1d6f726)
diff
1diff --git a/apps/server/src/git/Layers/GitCore.ts b/apps/server/src/git/Layers/GitCore.ts
2--- a/apps/server/src/git/Layers/GitCore.ts
3+++ b/apps/server/src/git/Layers/GitCore.ts
4@@ -314,6 +314,16 @@
5 if (yield* branchExists(cwd, candidate)) {
6 return candidate;
7 }
8+
9+ const remoteResult = yield* executeGit(
10+ "GitCore.resolveBaseBranchForNoUpstream.remoteRefCheck",
11+ cwd,
12+ ["show-ref", "--verify", "--quiet", `refs/remotes/origin/${candidate}`],
13+ { allowNonZeroExit: true },
14+ );
15+ if (remoteResult.code === 0) {
16+ return `origin/${candidate}`;
17+ }
18 }
19
20 return null;
apps/server/src/git/Layers/GitCore.tsline 288Outdated · a511de3Open thread
……@@ -259,6 +270,79 @@ const makeGitCore = Effect.gen(function* () {
285+ const branchExists = (cwd: string, branch: string): Effect.Effect<boolean, GitCommandError> =>
286+ executeGit("GitCore.branchExists", cwd, ["show-ref", "--verify", "--quiet", `refs/heads/${branch}`], {
287+ allowNonZeroExit: true,
288+ }).pipe(Effect.map((result) => result.code === 0));

Base branch lookup ignores remote-tracking refs

Medium Severity

branchExists checks only refs/heads/ (local branches), but resolveDefaultBranchName derives the candidate name from refs/remotes/origin/HEAD. In repos where the default branch exists only as a remote-tracking ref (e.g., origin/main without a local main), resolveBaseBranchForNoUpstream fails to find any candidate, causing computeAheadCountAgainstBase to return 0. This makes the UI show "No local commits to push" and disable push/PR actions even when the feature branch has commits ahead of origin/main.

Additional Locations (1)

Fix in Cursor Fix in Web

Added 1 commit

  • fix: resolve no-upstream base from origin tracking branches7475e52
Ccursor[bot]reviewed · 1 inline threadMar 1, 2026
Synced from GitHub

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Commit message not cleared after dialog submission
    • Added the missing setDialogCommitMessage("") call in runDialogAction to match the reset behavior of all other dialog close paths.

Create PR

Or push these changes by commenting:

1@cursor push 671782ab19
Preview (pingdotgg/t3code@671782ab19)
diff
1diff --git a/apps/web/src/components/GitActionsControl.tsx b/apps/web/src/components/GitActionsControl.tsx
2--- a/apps/web/src/components/GitActionsControl.tsx
3+++ b/apps/web/src/components/GitActionsControl.tsx
4@@ -538,6 +538,7 @@
5 if (!isCommitDialogOpen) return;
6 const commitMessage = dialogCommitMessage.trim();
7 setIsCommitDialogOpen(false);
8+ setDialogCommitMessage("");
9 void runGitActionWithToast({
10 action: "commit",
11 ...(commitMessage ? { commitMessage } : {}),
apps/web/src/components/GitActionsControl.tsxline 545Outdated · 7475e52Open thread
……@@ -427,30 +525,24 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
451- ...(forcePushOnlyProgress ? { forcePushOnlyProgress } : {}),
452544 });
453- }, [activeDialogAction, dialogCommitMessage, runGitActionWithToast]);
545+ }, [dialogCommitMessage, isCommitDialogOpen, runGitActionWithToast, setIsCommitDialogOpen]);

Commit message not cleared after dialog submission

Medium Severity

runDialogAction calls setIsCommitDialogOpen(false) but omits the setDialogCommitMessage("") call. Since Base UI's controlled Dialog does not fire onOpenChange for programmatic state changes, the commit message state persists. The next time the commit dialog opens, the old message appears pre-filled. Every other close path (runDialogActionOnNewBranch, the Cancel button, and the onOpenChange handler for user-initiated dismissals) properly resets dialogCommitMessage.

Additional Locations (1)

Fix in Cursor Fix in Web

Added 1 commit

  • test: use dynamic default branch in remote-base-ahead case3a81ca2
Ccursor[bot]reviewed · 1 inline threadMar 2, 2026
Synced from GitHub

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Dialog describes "commit" for push-only actions on default branch
    • Replaced the static DEFAULT_BRANCH_ACTION_DESCRIPTION record with a resolveDefaultBranchDialogWording function that adapts the dialog title, description, and confirm button label based on whether there are actual working tree changes, so push-only scenarios show "Push to default branch?" instead of commit-centric language.

Create PR

Or push these changes by commenting:

1@cursor push 9bcf132a10
Preview (pingdotgg/t3code@9bcf132a10)
diff
1diff --git a/apps/web/src/components/GitActionsControl.tsx b/apps/web/src/components/GitActionsControl.tsx
2--- a/apps/web/src/components/GitActionsControl.tsx
3+++ b/apps/web/src/components/GitActionsControl.tsx
4@@ -115,11 +115,28 @@
5 const COMMIT_DIALOG_DESCRIPTION =
6 "Review and confirm your commit. Leave the message blank to auto-generate one.";
7
8-const DEFAULT_BRANCH_ACTION_DESCRIPTION: Record<GitStackedAction, string> = {
9- commit: "commit changes",
10- commit_push: "commit and push changes",
11- commit_push_pr: "commit, push, and create a PR",
12-};
13+function resolveDefaultBranchDialogWording(
14+ action: GitStackedAction,
15+ hasWorkingTreeChanges: boolean,
16+): { title: string; description: string; confirmLabel: string } {
17+ if (hasWorkingTreeChanges) {
18+ return {
19+ title: "Commit to default branch?",
20+ description:
21+ action === "commit_push_pr"
22+ ? "commit, push, and create a PR"
23+ : action === "commit_push"
24+ ? "commit and push changes"
25+ : "commit changes",
26+ confirmLabel: "Commit to",
27+ };
28+ }
29+ return {
30+ title: "Push to default branch?",
31+ description: action === "commit_push_pr" ? "push and create a PR" : "push changes",
32+ confirmLabel: "Push to",
33+ };
34+}
35
36 function GitActionItemIcon({ icon }: { icon: GitActionIconName }) {
37 if (icon === "commit") return <GitCommitIcon />;
38@@ -203,6 +220,17 @@
39 ? (quickAction.hint ?? "This action is currently unavailable.")
40 : null;
41
42+ const defaultBranchDialogWording = useMemo(
43+ () =>
44+ pendingDefaultBranchAction
45+ ? resolveDefaultBranchDialogWording(
46+ pendingDefaultBranchAction.action,
47+ !!gitStatusForActions?.hasWorkingTreeChanges,
48+ )
49+ : null,
50+ [pendingDefaultBranchAction, gitStatusForActions?.hasWorkingTreeChanges],
51+ );
52+
53 const openExistingPr = useCallback(async () => {
54 const api = readNativeApi();
55 if (!api) {
56@@ -308,7 +336,8 @@
57 stopProgressUpdates();
58 const resultToast = summarizeGitResult(result);
59
60- const existingOpenPrUrl = actionStatus?.pr?.state === "open" ? actionStatus.pr.url : undefined;
61+ const existingOpenPrUrl =
62+ actionStatus?.pr?.state === "open" ? actionStatus.pr.url : undefined;
63 const prUrl = result.pr.url ?? existingOpenPrUrl;
64 const shouldOfferPushCta = action === "commit" && result.commit.status === "created";
65 const shouldOfferOpenPrCta =
66@@ -716,7 +745,9 @@
67 <div className="grid grid-cols-[auto_1fr] items-center gap-x-2 gap-y-1">
68 <span className="text-muted-foreground">Branch</span>
69 <span className="flex items-center justify-between gap-2">
70- <span className="font-medium">{gitStatusForActions?.branch ?? "(detached HEAD)"}</span>
71+ <span className="font-medium">
72+ {gitStatusForActions?.branch ?? "(detached HEAD)"}
73+ </span>
74 {isDefaultBranch && (
75 <span className="text-right text-warning text-xs">Warning: default branch</span>
76 )}
77@@ -801,14 +832,13 @@
78 >
79 <DialogPopup>
80 <DialogHeader>
81- <DialogTitle>Commit to default branch?</DialogTitle>
82+ <DialogTitle>
83+ {defaultBranchDialogWording?.title ?? "Push to default branch?"}
84+ </DialogTitle>
85 <DialogDescription>
86- This action will{" "}
87- {pendingDefaultBranchAction
88- ? DEFAULT_BRANCH_ACTION_DESCRIPTION[pendingDefaultBranchAction.action]
89- : "push changes"}{" "}
90- on "{gitStatusForActions?.branch ?? "default"}". You can continue on this branch or
91- create a feature branch and run the same action there.
92+ This action will {defaultBranchDialogWording?.description ?? "push changes"} on "
93+ {gitStatusForActions?.branch ?? "default"}". You can continue on this branch or create
94+ a feature branch and run the same action there.
95 </DialogDescription>
96 </DialogHeader>
97 <DialogFooter>
98@@ -816,7 +846,8 @@
99 Abort
100 </Button>
101 <Button variant="outline" size="sm" onClick={continuePendingDefaultBranchAction}>
102- Commit to {gitStatusForActions?.branch ?? "default"}
103+ {defaultBranchDialogWording?.confirmLabel ?? "Push to"}{" "}
104+ {gitStatusForActions?.branch ?? "default"}
105 </Button>
106 <Button size="sm" onClick={checkoutFeatureBranchAndContinuePendingAction}>
107 Checkout feature branch & continue
apps/web/src/components/GitActionsControl.tsxline 819Outdated · 3a81ca2Open thread
……@@ -707,35 +760,66 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
816+ Abort
817+ </Button>
818+ <Button variant="outline" size="sm" onClick={continuePendingDefaultBranchAction}>
819+ Commit to {gitStatusForActions?.branch ?? "default"}

Dialog describes "commit" for push-only actions on default branch

Low Severity

The default-branch confirmation dialog title says "Commit to default branch?" and button says "Commit to {branch}" regardless of the actual action. When the user triggers a push-only action (clean working tree, just ahead), the resolveQuickAction returns action: "commit_push" with label "Push", but the dialog title and DEFAULT_BRANCH_ACTION_DESCRIPTION still say "commit and push changes." The user clicked "Push" expecting no commit, but the dialog implies changes will be committed. Similarly, "Create PR" from the menu triggers commit_push_pr and the dialog says "commit, push, and create a PR" even though there's nothing to commit.

Additional Locations (1)

Fix in Cursor Fix in Web

Added 1 commit

  • fix: make default-branch confirmation copy action-awarebb7c9c7
Ccursor[bot]reviewed · 1 inline threadMar 2, 2026
Synced from GitHub

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Status override omits hasUpstream reset after branch checkout
    • Added hasUpstream: false, aheadCount: 0, and behindCount: 0 to the statusOverride so a newly created branch correctly reflects that it has no upstream tracking.

Create PR

Or push these changes by commenting:

1@cursor push 96ecc90a4b
Preview (pingdotgg/t3code@96ecc90a4b)
diff
1diff --git a/apps/web/src/components/GitActionsControl.tsx b/apps/web/src/components/GitActionsControl.tsx
2--- a/apps/web/src/components/GitActionsControl.tsx
3+++ b/apps/web/src/components/GitActionsControl.tsx
4@@ -445,7 +445,14 @@
5 void checkoutPromise
6 .then(() => {
7 const statusOverride = gitStatusForActions
8- ? { ...gitStatusForActions, branch: branchName, pr: null }
9+ ? {
10+ ...gitStatusForActions,
11+ branch: branchName,
12+ pr: null,
13+ hasUpstream: false,
14+ aheadCount: 0,
15+ behindCount: 0,
16+ }
17 : null;
18 return runGitActionWithToast({
19 ...actionParams,
apps/web/src/components/GitActionsControl.tsxline 449Outdated · bb7c9c7Open thread
……@@ -365,17 +396,100 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
446+ .then(() => {
447+ const statusOverride = gitStatusForActions
448+ ? { ...gitStatusForActions, branch: branchName, pr: null }
449+ : null;

Status override omits hasUpstream reset after branch checkout

Low Severity

The statusOverride in checkoutNewBranchAndRunAction spreads gitStatusForActions and overrides branch and pr, but doesn't set hasUpstream: false. A newly created branch never has an upstream, yet the override inherits the previous branch's hasUpstream value (which could be true if the user was on main). While hasUpstream from actionStatus isn't currently read in runGitActionWithToast, this creates a semantically incorrect state object that could silently cause bugs if future code starts checking actionStatus?.hasUpstream.

Fix in Cursor Fix in Web

Added 3 commits

  • Fix: reset hasUpstream, aheadCount, behindCount in statusOverride after branch checkout522d929
  • fix: widen default-branch action dialoge4ab109
  • fix: reuse git action toast after feature-branch checkout075df4e
Ccursor[bot]reviewed · 2 inline threadsMar 2, 2026
Synced from GitHub

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: Feature-branch fallback silently skips push for no-change scenarios
    • Added a remoteBranchExists check so the comparableBaseBranch guard only returns skipped_up_to_date when the branch already exists on the remote, ensuring newly created feature branches are always pushed.
  • ✅ Fixed: Unreachable commit case in dialog copy function
    • Removed the dead input.action === "commit" branch from resolveDefaultBranchActionDialogCopy since requiresDefaultBranchConfirmation only returns true for commit_push and commit_push_pr.

Create PR

Or push these changes by commenting:

1@cursor push 9c881ee5f3
Preview (pingdotgg/t3code@9c881ee5f3)
diff
1diff --git a/apps/server/src/git/Layers/GitCore.ts b/apps/server/src/git/Layers/GitCore.ts
2--- a/apps/server/src/git/Layers/GitCore.ts
3+++ b/apps/server/src/git/Layers/GitCore.ts
4@@ -581,7 +581,10 @@
5 const comparableBaseBranch = yield* resolveBaseBranchForNoUpstream(cwd, branch).pipe(
6 Effect.catch(() => Effect.succeed(null)),
7 );
8- if (comparableBaseBranch) {
9+ const branchExistsOnRemote = yield* remoteBranchExists(cwd, branch).pipe(
10+ Effect.catch(() => Effect.succeed(false)),
11+ );
12+ if (comparableBaseBranch && branchExistsOnRemote) {
13 return {
14 status: "skipped_up_to_date" as const,
15 branch,
16
17diff --git a/apps/web/src/components/GitActionsControl.logic.ts b/apps/web/src/components/GitActionsControl.logic.ts
18--- a/apps/web/src/components/GitActionsControl.logic.ts
19+++ b/apps/web/src/components/GitActionsControl.logic.ts
20@@ -290,14 +290,6 @@
21 const branchLabel = input.branchName;
22 const suffix = ` on "${branchLabel}". You can continue on this branch or create a feature branch and run the same action there.`;
23
24- if (input.action === "commit") {
25- return {
26- title: "Commit to default branch?",
27- description: `This action will commit changes${suffix}`,
28- continueLabel: `Commit to ${branchLabel}`,
29- };
30- }
31-
32 if (input.action === "commit_push") {
33 if (input.includesCommit) {
34 return {
apps/server/src/git/Layers/GitCore.tsline 589Outdated · 075df4eOpen thread
……@@ -452,12 +568,25 @@ const makeGitCore = Effect.gen(function* () {
586+ status: "skipped_up_to_date" as const,
587+ branch,
588+ };
589+ }

Feature-branch fallback silently skips push for no-change scenarios

Medium Severity

When the user is on the default branch with commits ahead of upstream but no working tree changes, clicking "Checkout feature branch & continue" in the confirmation dialog creates the branch but silently skips the push. The new feature branch shares all commits with the local default branch, so computeAheadCountAgainstBase returns 0. The comparableBaseBranch guard in pushCurrentBranch then returns skipped_up_to_date, even though the remote branch doesn't exist yet. The dialog promises "run the same action there" but the result is just a "Done" toast with nothing pushed.

Additional Locations (1)

Fix in Cursor Fix in Web

apps/web/src/components/GitActionsControl.logic.tsline 299Outdated · 075df4eOpen thread
……@@ -252,3 +281,75 @@ export function requiresDefaultBranchConfirmation(
296+ description: `This action will commit changes${suffix}`,
297+ continueLabel: `Commit to ${branchLabel}`,
298+ };
299+ }

Unreachable commit case in dialog copy function

Low Severity

The input.action === "commit" branch in resolveDefaultBranchActionDialogCopy is dead code. The requiresDefaultBranchConfirmation function returns false for the "commit" action, so setPendingDefaultBranchAction is never called with action: "commit", making this branch unreachable in production.

Fix in Cursor Fix in Web

Added 1 commit

  • fix: address latest git action review feedback839feaf
……@@ -365,17 +415,109 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
510+ const commitMessage = dialogCommitMessage.trim();
511+
512+ setIsCommitDialogOpen(false);
513+ setDialogCommitMessage("");
MmacroscopeappBoton line 513Mar 2, 2026

🟡 Medium components/GitActionsControl.tsx:513

Consider deferring setDialogCommitMessage("") until after checkoutNewBranchAndRunAction succeeds, otherwise the user's commit message is lost if branch creation fails.

🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
text
1In file apps/web/src/components/GitActionsControl.tsx around line 513:
2
3Consider deferring `setDialogCommitMessage("")` until after `checkoutNewBranchAndRunAction` succeeds, otherwise the user's commit message is lost if branch creation fails.
4
5Evidence trail:
6apps/web/src/components/GitActionsControl.tsx lines 508-519: `runDialogActionOnNewBranch` clears dialog state at lines 512-513 before calling `checkoutNewBranchAndRunAction` at lines 515-518.
7apps/web/src/components/GitActionsControl.tsx lines 439-494: `checkoutNewBranchAndRunAction` is async - it starts `createBranchAndCheckoutMutation.mutateAsync()` at line 450 and handles results via `.then()/.catch()` (lines 458-485).
8apps/web/src/components/GitActionsControl.tsx lines 478-485: The `.catch()` handler shows an error toast but does not restore the cleared commit message state.