@devries-cameron20 / t3code-1 / commits / ebe44d03a5
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Revert git action button logic toward main behavior

Co-authored-by: codex <codex@users.noreply.github.com>

Julius Marminge committed Mar 2, 2026 at 20:17 UTC ebe44d03a5fa6c34fdae2a67d53ef2ed6ba32737
3 files changed +46 -69
apps/web/src/components/GitActionsControl.logic.test.ts
+7 -24
@@ -250,20 +250,15 @@ 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 offers create PR", () => {
253 + it("resolveQuickAction returns disabled no-action state", () => {
254 const quick = resolveQuickAction(
255 status({ aheadCount: 0, behindCount: 0, hasWorkingTreeChanges: false, pr: null }),
256 false,
257 );
258 - assert.deepInclude(quick, {
259 - kind: "run_action",
260 - action: "commit_push_pr",
261 - label: "Create PR",
262 - disabled: false,
263 - });
258 + assert.deepInclude(quick, { kind: "show_hint", label: "Commit", disabled: true });
259 });
260
266 - it("buildMenuItems enables create PR and keeps commit/push disabled", () => {
261 + it("buildMenuItems disables commit, push, and create PR", () => {
262 const items = buildMenuItems(status({ aheadCount: 0, behindCount: 0, pr: null }), false);
263 assert.deepEqual(items, [
264 {
@@ -285,25 +280,13 @@ describe("when: branch is clean, up to date, and has no open PR", () => {
280 {
281 id: "pr",
282 label: "Create PR",
288 - disabled: false,
283 + disabled: true,
284 icon: "pr",
285 kind: "open_dialog",
286 dialogAction: "create_pr",
287 },
288 ]);
289 });
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 - });
290 });
291
292 describe("when: branch is behind upstream", () => {
@@ -365,7 +348,7 @@ describe("when: working tree has local changes", () => {
348 });
349 });
350
368 - it("resolveQuickAction keeps full commit/push/pr flow on non-default branches even when PR exists", () => {
351 + it("resolveQuickAction returns commit and push when open PR exists", () => {
352 const quick = resolveQuickAction(
353 status({
354 hasWorkingTreeChanges: true,
@@ -382,8 +365,8 @@ describe("when: working tree has local changes", () => {
365 );
366 assert.deepInclude(quick, {
367 kind: "run_action",
385 - action: "commit_push_pr",
386 - label: "Commit, push & create PR",
368 + action: "commit_push",
369 + label: "Commit & push",
370 });
371 });
372
apps/web/src/components/GitActionsControl.logic.ts
+3 -14
@@ -113,7 +113,6 @@ export function summarizeGitResult(result: GitRunStackedActionResult): {
113 export function buildMenuItems(
114 gitStatus: GitStatusResult | null,
115 isBusy: boolean,
116 - isDefaultBranch = false,
116 ): GitActionMenuItem[] {
117 if (!gitStatus) return [];
118
@@ -128,9 +127,8 @@ export function buildMenuItems(
127 hasBranch &&
128 !hasChanges &&
129 !hasOpenPr &&
131 - !isBehind &&
132 - !isDefaultBranch &&
133 - (gitStatus.aheadCount > 0 || gitStatus.hasUpstream);
130 + gitStatus.aheadCount > 0 &&
131 + !isBehind;
132 const canOpenPr = !isBusy && hasOpenPr;
133
134 return [
@@ -204,7 +202,7 @@ export function resolveQuickAction(
202 }
203
204 if (hasChanges) {
207 - if (isDefaultBranch) {
205 + if (hasOpenPr || isDefaultBranch) {
206 return { label: "Commit & push", disabled: false, kind: "run_action", action: "commit_push" };
207 }
208 return {
@@ -267,15 +265,6 @@ export function resolveQuickAction(
265 };
266 }
267
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 -
268 if (hasOpenPr && gitStatus.hasUpstream) {
269 return { label: "Open PR", disabled: false, kind: "open_pr" };
270 }
apps/web/src/components/GitActionsControl.tsx
+36 -31
@@ -57,6 +57,8 @@ interface PendingDefaultBranchAction {
57 onConfirmed?: () => void;
58 }
59
60 +type GitActionToastId = ReturnType<typeof toastManager.add>;
61 +
62 function getMenuActionDisabledReason(
63 item: GitActionMenuItem,
64 gitStatus: GitStatusResult | null,
@@ -180,19 +182,10 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
182 const current = branchList?.branches.find((branch) => branch.name === branchName);
183 return current?.isDefault ?? (branchName === "main" || branchName === "master");
184 }, [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 - );
185
186 const gitActionMenuItems = useMemo(
194 - () => buildMenuItems(gitStatusForActions, isGitActionRunning, isDefaultBranch),
195 - [gitStatusForActions, isGitActionRunning, isDefaultBranch],
187 + () => buildMenuItems(gitStatusForActions, isGitActionRunning),
188 + [gitStatusForActions, isGitActionRunning],
189 );
190 const quickAction = useMemo(
191 () => resolveQuickAction(gitStatusForActions, isGitActionRunning, isDefaultBranch),
@@ -245,26 +238,28 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
238 forcePushOnlyProgress = false,
239 onConfirmed,
240 skipDefaultBranchPrompt = false,
241 + statusOverride,
242 featureBranch = false,
243 isDefaultBranchOverride,
244 + progressToastId,
245 }: {
246 action: GitStackedAction;
247 commitMessage?: string;
248 forcePushOnlyProgress?: boolean;
249 onConfirmed?: () => void;
250 skipDefaultBranchPrompt?: boolean;
251 + statusOverride?: GitStatusResult | null;
252 featureBranch?: boolean;
253 isDefaultBranchOverride?: boolean;
254 + progressToastId?: GitActionToastId;
255 }) => {
259 - const actionStatus = gitStatusForActions;
256 + const actionStatus = statusOverride ?? gitStatusForActions;
257 const actionBranch = actionStatus?.branch ?? null;
261 - const actionIsDefaultBranch =
262 - isDefaultBranchOverride ?? (featureBranch ? false : isDefaultBranchName(actionBranch));
258 + const actionIsDefaultBranch = isDefaultBranchOverride ?? (featureBranch ? false : isDefaultBranch);
259 const includesCommit =
260 !forcePushOnlyProgress && (action === "commit" || !!actionStatus?.hasWorkingTreeChanges);
261 if (
262 !skipDefaultBranchPrompt &&
267 - !featureBranch &&
263 requiresDefaultBranchConfirmation(action, actionIsDefaultBranch) &&
264 actionBranch
265 ) {
@@ -292,17 +287,28 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
287 featureBranch,
288 ...(pushTarget ? { pushTarget } : {}),
289 });
295 - const progressToastId = toastManager.add({
296 - type: "loading",
297 - title: progressStages[0] ?? "Running git action...",
298 - timeout: 0,
299 - data: threadToastData,
300 - });
290 + const resolvedProgressToastId =
291 + progressToastId ??
292 + toastManager.add({
293 + type: "loading",
294 + title: progressStages[0] ?? "Running git action...",
295 + timeout: 0,
296 + data: threadToastData,
297 + });
298 +
299 + if (progressToastId) {
300 + toastManager.update(progressToastId, {
301 + type: "loading",
302 + title: progressStages[0] ?? "Running git action...",
303 + timeout: 0,
304 + data: threadToastData,
305 + });
306 + }
307
308 let stageIndex = 0;
309 const stageInterval = setInterval(() => {
310 stageIndex = Math.min(stageIndex + 1, progressStages.length - 1);
305 - toastManager.update(progressToastId, {
311 + toastManager.update(resolvedProgressToastId, {
312 title: progressStages[stageIndex] ?? "Running git action...",
313 type: "loading",
314 timeout: 0,
@@ -338,10 +344,10 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
344 result.push.status === "pushed" &&
345 !actionIsDefaultBranch;
346 const closeResultToast = () => {
341 - toastManager.close(progressToastId);
347 + toastManager.close(resolvedProgressToastId);
348 };
349
344 - toastManager.update(progressToastId, {
350 + toastManager.update(resolvedProgressToastId, {
351 type: "success",
352 title: resultToast.title,
353 description: resultToast.description,
@@ -359,8 +365,8 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
365 action: "commit_push",
366 forcePushOnlyProgress: true,
367 onConfirmed: closeResultToast,
362 - ...(featureBranch ? { skipDefaultBranchPrompt: true } : {}),
363 - ...(featureBranch ? { isDefaultBranchOverride: false } : {}),
368 + statusOverride: actionStatus,
369 + isDefaultBranchOverride: actionIsDefaultBranch,
370 });
371 },
372 },
@@ -386,8 +392,8 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
392 void runGitActionWithToast({
393 action: "commit_push_pr",
394 forcePushOnlyProgress: true,
389 - ...(featureBranch ? { skipDefaultBranchPrompt: true } : {}),
390 - ...(featureBranch ? { isDefaultBranchOverride: false } : {}),
395 + statusOverride: actionStatus,
396 + isDefaultBranchOverride: actionIsDefaultBranch,
397 });
398 },
399 },
@@ -396,7 +402,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
402 });
403 } catch (err) {
404 stopProgressUpdates();
399 - toastManager.update(progressToastId, {
405 + toastManager.update(resolvedProgressToastId, {
406 type: "error",
407 title: "Action failed",
408 description: err instanceof Error ? err.message : "An error occurred.",
@@ -406,7 +412,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
412 },
413
414 [
409 - isDefaultBranchName,
415 + isDefaultBranch,
416 runImmediateGitActionMutation,
417 setPendingDefaultBranchAction,
418 threadToastData,
@@ -424,7 +430,6 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
430 forcePushOnlyProgress,
431 ...(onConfirmed ? { onConfirmed } : {}),
432 skipDefaultBranchPrompt: true,
427 - isDefaultBranchOverride: true,
433 });
434 }, [pendingDefaultBranchAction, runGitActionWithToast]);
435