Skip to content

Commit 4a07531

Browse files
devakoneclaude
andcommitted
fix: disable Get Vibe button while analysis job is running
Use the global JobsContext to track active jobs per repo so the button stays disabled for the entire duration of a running analysis, not just during the initial API call. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 35b92d1 commit 4a07531

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

apps/web/src/app/vibes/VibesClient.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ChevronRight, ChevronDown } from "lucide-react";
77
import { wrappedTheme } from "@/lib/theme";
88
import { toast } from "@/components/ui/use-toast";
99
import { ToastAction } from "@/components/ui/toast";
10+
import { useJobs } from "@/contexts/JobsContext";
1011

1112
type VibeVersion = {
1213
jobId: string;
@@ -40,9 +41,17 @@ function formatDate(dateStr: string | null): string {
4041

4142
export 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

Comments
 (0)