diff --git a/frontend/src/components/repo/BranchSwitcher.tsx b/frontend/src/components/repo/BranchSwitcher.tsx index 78d0b717..3365042a 100644 --- a/frontend/src/components/repo/BranchSwitcher.tsx +++ b/frontend/src/components/repo/BranchSwitcher.tsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useState, useCallback } from "react"; import { Button } from "@/components/ui/button"; import { DropdownMenu, @@ -28,12 +28,19 @@ export function BranchSwitcher({ repoId, currentBranch, isWorktree, repoUrl, rep const queryClient = useQueryClient(); const { data: gitStatus } = useGitStatus(repoId); - const { data: branches, isLoading: branchesLoading } = useQuery({ + const { data: branches, isLoading: branchesLoading, refetch: refetchBranches } = useQuery({ queryKey: ["branches", repoId], queryFn: () => listBranches(repoId), enabled: !!repoId, + staleTime: 1000 * 30, }); + const handleDropdownOpenChange = useCallback((open: boolean) => { + if (open && repoId) { + refetchBranches(); + } + }, [repoId, refetchBranches]); + const switchBranchMutation = useMutation({ mutationFn: (branch: string) => switchBranch(repoId, branch), onSuccess: () => { @@ -48,7 +55,7 @@ export function BranchSwitcher({ repoId, currentBranch, isWorktree, repoUrl, rep return ( <> - +