From fefa97cb217c3a2472b8e91f8cc8e2bae19c6afb Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 30 Dec 2025 14:41:02 -0600 Subject: [PATCH] Add indicator check to GitSyncButton --- src/components/git-sync/GitSyncButton.tsx | 30 ++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/components/git-sync/GitSyncButton.tsx b/src/components/git-sync/GitSyncButton.tsx index ad8bc1ca..a1b22f18 100644 --- a/src/components/git-sync/GitSyncButton.tsx +++ b/src/components/git-sync/GitSyncButton.tsx @@ -1,5 +1,5 @@ -import { useState } from 'react'; -import { CloudUpload, Loader2 } from 'lucide-react'; +import { useState, useEffect, useRef } from 'react'; +import { CloudUpload, Loader2, Check } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'; import { useGitStatus } from '@/hooks/useGitStatus'; @@ -15,6 +15,7 @@ interface GitSyncButtonProps { export function GitSyncButton({ projectId, className }: GitSyncButtonProps) { const [open, setOpen] = useState(false); + const [syncSuccess, setSyncSuccess] = useState(false); const { data: gitStatus, isLoading: isGitStatusLoading } = useGitStatus(projectId); const { getError, getState } = useGitSyncState(); @@ -24,10 +25,27 @@ export function GitSyncButton({ projectId, className }: GitSyncButtonProps) { const hasError = !!getError(dir); const gitSyncState = getState(dir); const isGitActionOccurring = gitSyncState?.isActive ?? false; + const prevIsGitActionOccurring = useRef(isGitActionOccurring); + + // Detect when a git action completes successfully + useEffect(() => { + // If we were syncing and now we're not, and there's no error, show success + if (prevIsGitActionOccurring.current && !isGitActionOccurring && !hasError) { + setSyncSuccess(true); + const timer = setTimeout(() => setSyncSuccess(false), 2500); + return () => clearTimeout(timer); + } + prevIsGitActionOccurring.current = isGitActionOccurring; + }, [isGitActionOccurring, hasError]); // Determine which indicator to show (only one at a time, in priority order) const renderIndicator = () => { - // Spinner: git action occurring - highest priority + // Checkmark: sync just completed successfully - highest priority + if (syncSuccess) { + return ; + } + + // Spinner: git action occurring - second priority if (isGitActionOccurring) { return ; } @@ -100,4 +118,10 @@ function IndicatorSpinner() { return ( ); +} + +function IndicatorCheck() { + return ( + + ); } \ No newline at end of file