import { useNavigate } from "@tanstack/react-router" import { useQuery } from "@tanstack/react-query" import type { AgentThread } from "@/lib/agents/types" import { ReviewMainBody } from "@/components/agents/ReviewMainBody" import { api } from "@/lib/api" // The git panel's "Review" sub-tab: the PR's Open SWE review rendered inline (no // side panel / chat), with an expand affordance that opens the full review page. export function ReviewTab({ thread }: { thread: AgentThread }) { const navigate = useNavigate() const pr = thread.pr const [owner, repo] = thread.repoFullName.split("/") const number = pr?.number ?? null const enabled = Boolean(owner && repo && number !== null) const detail = useQuery({ queryKey: ["review", owner, repo, number], queryFn: () => api.getReview(owner as string, repo as string, number as number), enabled, refetchInterval: (query) => query.state.data?.status === "running" ? 5000 : false, }) const diff = useQuery({ queryKey: ["reviewDiff", owner, repo, number], queryFn: () => api.getReviewDiff(owner as string, repo as string, number as number), enabled, }) if (!enabled) { return (
Open a pull request to see its review here.
) } if (detail.isLoading) { return (
Loading review…
) } if (detail.error || !detail.data) { return (
No review for this pull request yet.
) } return ( navigate({ to: "/agents/reviews/$owner/$repo/$number", params: { owner: owner as string, repo: repo as string, number: String(number), }, }) } /> ) }