@@ -2,7 +2,7 @@ import dayjs from "dayjs";
22import { useSession } from "next-auth/react" ;
33import { IssueLabelApiResponse } from "pages/api/issue/[label]" ;
44import useSWR from "swr" ;
5- import { isFailure , IsJobInProgress } from "../lib/JobClassifierUtil" ;
5+ import { IsJobInProgress } from "../lib/JobClassifierUtil" ;
66import { isFailedJob , transformJobName } from "../lib/jobUtils" ;
77import { IssueData , JobData } from "../lib/types" ;
88import CopyLink from "./CopyLink" ;
@@ -206,18 +206,18 @@ function formatUnstableJobBody() {
206206}
207207
208208function UnstableJob ( { job, label } : { job : JobData ; label : string } ) {
209- const swrKey = isFailure ( job . conclusion ) ? `/api/issue/${ label } ` : null ;
210- const { data : issues } = useSWR < IssueLabelApiResponse > ( swrKey , fetcher , {
211- // Set a 60s cache for the request, so that lots of tooltip hovers don't
212- // spam the backend. Since actually mutating the state (through filing a
213- // disable issue) is a pretty heavy operation, 60s of staleness is fine.
214- dedupingInterval : 60 * 1000 ,
215- refreshInterval : 60 * 1000 , // refresh every minute
216- } ) ;
217-
218- if ( ! isFailure ( job . conclusion ) ) {
219- return null ;
220- }
209+ const swrKey = `/api/issue/${ label } ` ;
210+ const { data : issues , isLoading } = useSWR < IssueLabelApiResponse > (
211+ swrKey ,
212+ fetcher ,
213+ {
214+ // Set a 60s cache for the request, so that lots of tooltip hovers don't
215+ // spam the backend. Since actually mutating the state (through filing a
216+ // disable issue) is a pretty heavy operation, 60s of staleness is fine.
217+ dedupingInterval : 60 * 1000 ,
218+ refreshInterval : 60 * 1000 , // refresh every minute
219+ }
220+ ) ;
221221
222222 const jobName = transformJobName ( job . name ) ;
223223 // Ignore invalid job name
@@ -226,10 +226,16 @@ function UnstableJob({ job, label }: { job: JobData; label: string }) {
226226 }
227227
228228 // If we don't yet have any data, show a loading state.
229- if ( issues === undefined ) {
229+ if ( isLoading ) {
230230 return < span > checking for disable jobs</ span > ;
231231 }
232232
233+ if ( issues === undefined ) {
234+ // Usually this means that it's loading but add this check just in case it
235+ // actually returns undefined somehow and hide it from users.
236+ return null ;
237+ }
238+
233239 // At this point, we should show something. Search the existing disable issues
234240 // for a matching one.
235241 const issueTitle = `UNSTABLE ${ jobName } ` ;
@@ -238,6 +244,11 @@ function UnstableJob({ job, label }: { job: JobData; label: string }) {
238244 const matchingIssues = issues . filter ( ( issue ) =>
239245 issueTitle . includes ( issue . title )
240246 ) ;
247+
248+ if ( matchingIssues . length == 0 ) {
249+ return null ;
250+ }
251+
241252 const repo = job . repo ?? "pytorch/pytorch" ;
242253
243254 return (
0 commit comments