@@ -46,6 +46,7 @@ import {
4646 buildMenuItems ,
4747 formatGitActionElapsed ,
4848 GIT_ACTION_SUCCESS_VISIBLE_MS ,
49+ hasUsableGitMenuContent ,
4950 type GitActionProgressPresentation ,
5051 type GitActionIconName ,
5152 type GitActionMenuItem ,
@@ -1395,6 +1396,23 @@ export default function GitActionsControl({
13951396
13961397 const canPublishRepository =
13971398 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 ) ;
13981416
13991417 const initializeGit = ( ) => {
14001418 void ( async ( ) => {
@@ -1466,19 +1484,15 @@ export default function GitActionsControl({
14661484 < MenuItemLabel > Publish repository...</ MenuItemLabel >
14671485 </ MenuItem >
14681486 ) : null }
1469- { gitStatusForActions ?. refName === null && (
1487+ { isDetachedHead && (
14701488 < p className = "px-2 py-1.5 text-xs text-warning" >
14711489 Detached HEAD: create and check out a branch to enable push and{ " " }
14721490 { changeRequestTerminology . singular } actions.
14731491 </ p >
14741492 ) }
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+ ) }
14821496 { gitStatusError && < p className = "px-2 py-1.5 text-xs text-destructive" > { gitStatusError } </ p > }
14831497 </ >
14841498 ) ;
@@ -1506,6 +1520,8 @@ export default function GitActionsControl({
15061520 role = "group"
15071521 aria-label = "Git actions"
15081522 ref = { panelAnchorRef }
1523+ onPointerEnter = { hasGitMenuContent ? undefined : refreshStatusForEmptyMenu }
1524+ onFocus = { hasGitMenuContent ? undefined : refreshStatusForEmptyMenu }
15091525 className = { cn (
15101526 "shrink-0" ,
15111527 THREAD_DETAILS_PANEL_SPLIT_GROUP_CLASS ,
@@ -1613,7 +1629,7 @@ export default function GitActionsControl({
16131629 panel
16141630 />
16151631 }
1616- disabled = { isGitActionRunning }
1632+ disabled = { isGitActionRunning || ! hasGitMenuContent }
16171633 >
16181634 < ChevronDownIcon
16191635 aria-hidden = "true"
0 commit comments