@devries-cameron20 / t3code-1 / commits / 8c9af5418a
Fork 0

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

fix(web): disable the git actions menu when nothing in it is usable (#31972)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

CursedApple committed Nov 11, 2026 at 09:45 UTC 8c9af5418a3344e7a2063c12be18cafd1a79ad60
3 files changed +62 -9
apps/web/src/components/GitActionsControl.logic.test.ts
+24
@@ -4,6 +4,7 @@ import { resolveAutoFeatureBranchName } from "@t3tools/shared/git";
4 import { assert, describe, it } from "vite-plus/test";
5 import {
6 buildMenuItems,
7 + hasUsableGitMenuContent,
8 requiresDefaultBranchConfirmation,
9 resolveChangesTotals,
10 resolveDefaultBranchActionDialogCopy,
@@ -77,6 +78,29 @@ describe("when: ref is clean, up to date, and has no open PR", () => {
78 false,
79 );
80 });
81 +
82 + it("offers the actions menu only when something in it is usable", () => {
83 + const hasContent = (
84 + gitStatus: VcsStatusResult,
85 + overrides: Partial<Parameters<typeof hasUsableGitMenuContent>[0]> = {},
86 + ) =>
87 + hasUsableGitMenuContent({
88 + menuItems: buildMenuItems(gitStatus, false, gitStatus.hasPrimaryRemote),
89 + canWriteSourceControl: true,
90 + canPublishRepository: false,
91 + hasNotice: false,
92 + ...overrides,
93 + });
94 + const clean = status();
95 + const dirty = status({ hasWorkingTreeChanges: true });
96 +
97 + assert.isFalse(hasContent(clean));
98 + assert.isTrue(hasContent(dirty));
99 + assert.isTrue(hasContent(status({ aheadCount: 1 })));
100 + assert.isFalse(hasContent(dirty, { canWriteSourceControl: false }));
101 + assert.isTrue(hasContent(status({ hasPrimaryRemote: false }), { canPublishRepository: true }));
102 + assert.isTrue(hasContent(clean, { hasNotice: true }));
103 + });
104 });
105
106 describe("when: on default ref without open PR", () => {
apps/web/src/components/GitActionsControl.logic.ts
+13
@@ -174,6 +174,19 @@ export function buildMenuItems(
174 ];
175 }
176
177 +export function hasUsableGitMenuContent(input: {
178 + readonly menuItems: readonly GitActionMenuItem[];
179 + readonly canWriteSourceControl: boolean;
180 + readonly canPublishRepository: boolean;
181 + readonly hasNotice: boolean;
182 +}): boolean {
183 + return (
184 + input.canPublishRepository ||
185 + input.hasNotice ||
186 + (input.canWriteSourceControl && input.menuItems.some((item) => !item.disabled))
187 + );
188 +}
189 +
190 export function resolveQuickAction(
191 gitStatus: VcsStatusResult | null,
192 isBusy: boolean,
apps/web/src/components/GitActionsControl.tsx
+25 -9
@@ -46,6 +46,7 @@ import {
46 buildMenuItems,
47 formatGitActionElapsed,
48 GIT_ACTION_SUCCESS_VISIBLE_MS,
49 + hasUsableGitMenuContent,
50 type GitActionProgressPresentation,
51 type GitActionIconName,
52 type GitActionMenuItem,
@@ -1395,6 +1396,23 @@ export default function GitActionsControl({
1396
1397 const canPublishRepository =
1398 canWriteSourceControl && isRepo && gitStatusForActions !== null && !hasPrimaryRemote;
1399 + const isDetachedHead = gitStatusForActions?.refName === null;
1400 + const isCleanAndBehind =
1401 + gitStatusForActions !== null &&
1402 + gitStatusForActions.refName !== null &&
1403 + !gitStatusForActions.hasWorkingTreeChanges &&
1404 + gitStatusForActions.behindCount > 0 &&
1405 + gitStatusForActions.aheadCount === 0;
1406 + const hasGitMenuContent = hasUsableGitMenuContent({
1407 + menuItems: gitActionMenuItems,
1408 + canWriteSourceControl,
1409 + canPublishRepository,
1410 + hasNotice: isDetachedHead || isCleanAndBehind || Boolean(gitStatusError),
1411 + });
1412 +
1413 + // A disabled menu cannot refresh on open, and terminal edits or commits publish no status.
1414 + const refreshStatusForEmptyMenu = () =>
1415 + requestVcsStatusRefresh(refreshVcsStatus, activeEnvironmentId, gitCwd);
1416
1417 const initializeGit = () => {
1418 void (async () => {
@@ -1466,19 +1484,15 @@ export default function GitActionsControl({
1484 <MenuItemLabel>Publish repository...</MenuItemLabel>
1485 </MenuItem>
1486 ) : null}
1469 - {gitStatusForActions?.refName === null && (
1487 + {isDetachedHead && (
1488 <p className="px-2 py-1.5 text-xs text-warning">
1489 Detached HEAD: create and check out a branch to enable push and{" "}
1490 {changeRequestTerminology.singular} actions.
1491 </p>
1492 )}
1475 - {gitStatusForActions &&
1476 - gitStatusForActions.refName !== null &&
1477 - !gitStatusForActions.hasWorkingTreeChanges &&
1478 - gitStatusForActions.behindCount > 0 &&
1479 - gitStatusForActions.aheadCount === 0 && (
1480 - <p className="px-2 py-1.5 text-xs text-warning">Behind upstream. Pull/rebase first.</p>
1481 - )}
1493 + {isCleanAndBehind && (
1494 + <p className="px-2 py-1.5 text-xs text-warning">Behind upstream. Pull/rebase first.</p>
1495 + )}
1496 {gitStatusError && <p className="px-2 py-1.5 text-xs text-destructive">{gitStatusError}</p>}
1497 </>
1498 );
@@ -1506,6 +1520,8 @@ export default function GitActionsControl({
1520 role="group"
1521 aria-label="Git actions"
1522 ref={panelAnchorRef}
1523 + onPointerEnter={hasGitMenuContent ? undefined : refreshStatusForEmptyMenu}
1524 + onFocus={hasGitMenuContent ? undefined : refreshStatusForEmptyMenu}
1525 className={cn(
1526 "shrink-0",
1527 THREAD_DETAILS_PANEL_SPLIT_GROUP_CLASS,
@@ -1613,7 +1629,7 @@ export default function GitActionsControl({
1629 panel
1630 />
1631 }
1616 - disabled={isGitActionRunning}
1632 + disabled={isGitActionRunning || !hasGitMenuContent}
1633 >
1634 <ChevronDownIcon
1635 aria-hidden="true"