Skip to content

Commit c62e321

Browse files
authored
[HUD] Add "Hide green columns" checkbox (#6441)
This PR adds a "Hide green columns" checkbox to the PyTorch HUD interface that filters out columns without any failures. When enabled, only jobs or job groups with at least one failure across all displayed commits will be shown, reducing visual noise and helping users focus on problematic areas. Implementation Details: - Added a new local storage preference using the existing preference system - Preprocessed failure data for efficient filtering and better performance - Added checkbox next to existing view options in the HUD UI - Works seamlessly with both grouped and ungrouped views This feature helps developers spot issues more quickly by eliminating the visual noise of successful builds. --- generated with claude code in three iterations: Total cost: $2.69
1 parent 60ef721 commit c62e321

File tree

3 files changed

+88
-10
lines changed

3 files changed

+88
-10
lines changed

torchci/lib/JobClassifierUtil.ts

+33-1
Original file line numberDiff line numberDiff line change
@@ -330,13 +330,45 @@ export function getGroupingData(
330330
) {
331331
// Construct Job Groupping Mapping
332332
const groupNameMapping = new Map<string, Array<string>>(); // group -> [job names]
333+
334+
// Track which jobs have failures
335+
const jobsWithFailures = new Set<string>();
336+
337+
// First pass: check failures for each job across all commits
338+
for (const name of jobNames) {
339+
// Check if this job has failures in any commit
340+
const hasFailure = shaGrid.some((row) => {
341+
const job = row.nameToJobs.get(name);
342+
return job && isFailure(job.conclusion);
343+
});
344+
345+
if (hasFailure) {
346+
jobsWithFailures.add(name);
347+
}
348+
}
349+
350+
// Second pass: group jobs
333351
for (const name of jobNames) {
334352
const groupName = classifyGroup(name, showUnstableGroup, unstableIssues);
335353
const jobsInGroup = groupNameMapping.get(groupName) ?? [];
336354
jobsInGroup.push(name);
337355
groupNameMapping.set(groupName, jobsInGroup);
338356
}
339-
return { shaGrid, groupNameMapping };
357+
358+
// Calculate which groups have failures
359+
const groupsWithFailures = new Set<string>();
360+
for (const [groupName, jobs] of groupNameMapping.entries()) {
361+
if (jobs.some((jobName) => jobsWithFailures.has(jobName))) {
362+
groupsWithFailures.add(groupName);
363+
}
364+
}
365+
366+
return {
367+
shaGrid,
368+
groupNameMapping,
369+
jobsWithFailures,
370+
groupsWithFailures,
371+
};
340372
}
341373

342374
export function isPersistentGroup(name: string) {

torchci/lib/useGroupingPreference.tsx

+12
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,15 @@ export function useMonsterFailuresPreference(): [
6565
);
6666
return [state, setState];
6767
}
68+
69+
export function useHideGreenColumnsPreference(): [
70+
boolean,
71+
(_hideGreenColumnsValue: boolean) => void
72+
] {
73+
const [state, setState] = usePreference(
74+
"hideGreenColumns",
75+
/*override*/ undefined,
76+
/*default*/ false
77+
);
78+
return [state, setState];
79+
}

torchci/pages/hud/[repoOwner]/[repoName]/[branch]/[[...page]].tsx

+43-9
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
} from "lib/types";
4040
import {
4141
useGroupingPreference,
42+
useHideGreenColumnsPreference,
4243
useMonsterFailuresPreference,
4344
usePreference,
4445
} from "lib/useGroupingPreference";
@@ -289,6 +290,8 @@ function GroupFilterableHudTable({
289290
setUseGrouping,
290291
hideUnstable,
291292
setHideUnstable,
293+
hideGreenColumns,
294+
setHideGreenColumns,
292295
}: {
293296
params: HudParams;
294297
children: React.ReactNode;
@@ -297,6 +300,8 @@ function GroupFilterableHudTable({
297300
setUseGrouping: any;
298301
hideUnstable: boolean;
299302
setHideUnstable: any;
303+
hideGreenColumns: boolean;
304+
setHideGreenColumns: any;
300305
}) {
301306
const { jobFilter, handleSubmit } = useTableFilter(params);
302307
const headerNames = groupNames;
@@ -321,6 +326,12 @@ function GroupFilterableHudTable({
321326
checkBoxName="hideUnstable"
322327
labelText={"Hide unstable jobs"}
323328
/>
329+
<CheckBoxSelector
330+
value={hideGreenColumns}
331+
setValue={(value) => setHideGreenColumns(value)}
332+
checkBoxName="hideGreenColumns"
333+
labelText={"Hide green columns"}
334+
/>
324335
<CheckBoxSelector
325336
value={mergeLF}
326337
setValue={setMergeLF}
@@ -557,16 +568,19 @@ function GroupedHudTable({
557568
);
558569

559570
const [hideUnstable, setHideUnstable] = usePreference("hideUnstable");
571+
const [hideGreenColumns, setHideGreenColumns] =
572+
useHideGreenColumnsPreference();
560573
const [useGrouping, setUseGrouping] = useGroupingPreference(
561574
params.nameFilter
562575
);
563576

564-
const { shaGrid, groupNameMapping } = getGroupingData(
565-
data,
566-
jobNames,
567-
(!useGrouping && hideUnstable) || (useGrouping && !hideUnstable),
568-
unstableIssuesData ?? []
569-
);
577+
const { shaGrid, groupNameMapping, jobsWithFailures, groupsWithFailures } =
578+
getGroupingData(
579+
data,
580+
jobNames,
581+
(!useGrouping && hideUnstable) || (useGrouping && !hideUnstable),
582+
unstableIssuesData ?? []
583+
);
570584

571585
const [expandedGroups, setExpandedGroups] = useState(new Set<string>());
572586

@@ -617,9 +631,27 @@ function GroupedHudTable({
617631
}
618632
});
619633
}
620-
names = names.filter((name) =>
621-
passesGroupFilter(jobFilter, name, groupNameMapping)
622-
);
634+
635+
names = names.filter((name) => {
636+
// Filter by job filter text first
637+
if (!passesGroupFilter(jobFilter, name, groupNameMapping)) {
638+
return false;
639+
}
640+
641+
// If hiding green columns, filter out names that don't have any failed jobs
642+
if (hideGreenColumns) {
643+
// For group names, check if any job in the group has failures
644+
if (groupNameMapping.has(name)) {
645+
return groupsWithFailures.has(name);
646+
}
647+
// For individual job names, check if this job has failures
648+
else {
649+
return jobsWithFailures.has(name);
650+
}
651+
}
652+
653+
return true;
654+
});
623655

624656
return (
625657
<GroupingContext.Provider
@@ -632,6 +664,8 @@ function GroupedHudTable({
632664
setUseGrouping={setUseGrouping}
633665
hideUnstable={hideUnstable}
634666
setHideUnstable={setHideUnstable}
667+
hideGreenColumns={hideGreenColumns}
668+
setHideGreenColumns={setHideGreenColumns}
635669
>
636670
<HudTableBody
637671
shaGrid={shaGrid}

0 commit comments

Comments
 (0)