From a74db2cdd0e33c7aa6e1312afd8b7b58244040ca Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 24 Dec 2025 19:52:20 -0600 Subject: [PATCH] Simplify indicator logic in GitSyncButton --- src/components/git-sync/GitSyncButton.tsx | 50 +++++++++++++++-------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/src/components/git-sync/GitSyncButton.tsx b/src/components/git-sync/GitSyncButton.tsx index 450080da..7e2cc6da 100644 --- a/src/components/git-sync/GitSyncButton.tsx +++ b/src/components/git-sync/GitSyncButton.tsx @@ -16,18 +16,29 @@ export function GitSyncButton({ projectId, className }: GitSyncButtonProps) { const { data: gitStatus, isLoading: isGitStatusLoading } = useGitStatus(projectId); - // Determine if we have a remote configured - const originRemote = gitStatus?.remotes.find(r => r.name === 'origin'); - const hasRemote = !!originRemote; + // Determine which indicator to show (only one at a time) + const renderIndicator = () => { + if (isGitStatusLoading || !gitStatus) return null; - // Check for unsynced changes (ahead or behind remote) - const hasUnsyncedChanges = !isGitStatusLoading && hasRemote && gitStatus?.remoteBranchExists && ((gitStatus?.ahead ?? 0) > 0 || (gitStatus?.behind ?? 0) > 0); + const originRemote = gitStatus.remotes.find(r => r.name === 'origin'); + const hasRemote = !!originRemote; - // Determine if we need to show the indicator dot - // Yellow indicator for unsynced changes takes precedence - // Purple indicator if no origin remote is configured, UNLESS there are less than 2 commits - const showYellowIndicator = hasUnsyncedChanges; - const showPurpleIndicator = !isGitStatusLoading && !hasRemote && (gitStatus?.totalCommits ?? 0) >= 2 && !showYellowIndicator; + const { remoteBranchExists, ahead, behind, totalCommits } = gitStatus; + + // Yellow indicator: unsynced changes (ahead or behind remote) - highest priority + const hasUnsyncedChanges = hasRemote && remoteBranchExists && (ahead > 0 || behind > 0); + if (hasUnsyncedChanges) { + return ; + } + + // Purple indicator: no remote configured, but has commits - lower priority + const needsRemote = !hasRemote && totalCommits >= 2; + if (needsRemote) { + return ; + } + + return null; + }; return ( @@ -39,12 +50,7 @@ export function GitSyncButton({ projectId, className }: GitSyncButtonProps) { aria-label="Sync with Git" > - {showYellowIndicator && ( - - )} - {showPurpleIndicator && ( - - )} + {renderIndicator()} ); } + +function IndicatorDot({ color }: { color: 'primary' | 'yellow' }) { + return ( + + ); +} \ No newline at end of file