@@ -7,6 +7,7 @@ import { ChevronRight, ChevronDown } from "lucide-react";
77import { wrappedTheme } from "@/lib/theme" ;
88import { toast } from "@/components/ui/use-toast" ;
99import { ToastAction } from "@/components/ui/toast" ;
10+ import { useJobs } from "@/contexts/JobsContext" ;
1011
1112type VibeVersion = {
1213 jobId : string ;
@@ -40,9 +41,17 @@ function formatDate(dateStr: string | null): string {
4041
4142export default function VibesClient ( { repos } : VibesClientProps ) {
4243 const router = useRouter ( ) ;
44+ const { jobs, refreshJobs } = useJobs ( ) ;
4345 const [ expandedRepos , setExpandedRepos ] = useState < Set < string > > ( new Set ( ) ) ;
4446 const [ loadingRepoId , setLoadingRepoId ] = useState < string | null > ( null ) ;
4547
48+ const activeJobRepoIds = new Set (
49+ jobs
50+ . filter ( ( j ) => j . status === "pending" || j . status === "running" || j . status === "queued" )
51+ . map ( ( j ) => j . repoId )
52+ . filter ( ( id ) : id is string => id !== null )
53+ ) ;
54+
4655 const toggleExpanded = ( repoId : string ) => {
4756 setExpandedRepos ( ( prev ) => {
4857 const next = new Set ( prev ) ;
@@ -79,6 +88,7 @@ export default function VibesClient({ repos }: VibesClientProps) {
7988 </ ToastAction >
8089 ) ,
8190 } ) ;
91+ await refreshJobs ( ) ;
8292 router . refresh ( ) ;
8393 } catch ( e ) {
8494 toast ( {
@@ -114,6 +124,8 @@ export default function VibesClient({ repos }: VibesClientProps) {
114124 { repos . map ( ( repo ) => {
115125 const isExpanded = expandedRepos . has ( repo . repoId ) ;
116126 const isLoading = loadingRepoId === repo . repoId ;
127+ const hasActiveJob = activeJobRepoIds . has ( repo . repoId ) ;
128+ const isBusy = isLoading || hasActiveJob ;
117129
118130 return (
119131 < div key = { repo . repoId } >
@@ -169,20 +181,20 @@ export default function VibesClient({ repos }: VibesClientProps) {
169181 < button
170182 type = "button"
171183 onClick = { ( ) => startAnalysis ( repo . repoId , repo . repoName ) }
172- disabled = { isLoading }
184+ disabled = { isBusy }
173185 className = "rounded-full border border-zinc-300/80 bg-white/70 px-3 py-1 text-sm font-semibold text-zinc-950 shadow-sm backdrop-blur transition hover:bg-white disabled:opacity-60"
174186 >
175- { isLoading ? "Starting..." : "Re-run" }
187+ { hasActiveJob ? "Analyzing…" : isLoading ? "Starting..." : "Re-run" }
176188 </ button >
177189 </ >
178190 ) : (
179191 < button
180192 type = "button"
181193 onClick = { ( ) => startAnalysis ( repo . repoId , repo . repoName ) }
182- disabled = { isLoading }
194+ disabled = { isBusy }
183195 className = { `${ wrappedTheme . primaryButtonSm } disabled:opacity-60` }
184196 >
185- { isLoading ? "Starting..." : "Get Vibe" }
197+ { hasActiveJob ? "Analyzing…" : isLoading ? "Starting..." : "Get Vibe" }
186198 </ button >
187199 ) }
188200 </ div >
0 commit comments