Skip to content

Commit eadd2d5

Browse files
Connor ClarkDevtools-frontend LUCI CQ
authored andcommitted
[RPP] Hide insight set if there is nothing to show
Bug: 371615739 Change-Id: I8a635201f36bb34870dfb3d3105f99dab4fca1d6 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6037380 Reviewed-by: Adam Raine <[email protected]> Auto-Submit: Connor Clark <[email protected]> Commit-Queue: Adam Raine <[email protected]>
1 parent 58f31bc commit eadd2d5

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

front_end/models/trace/insights/CLSCulprits.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,12 +422,19 @@ function getFontRootCauses(
422422

423423
function finalize(partialModel: Omit<CLSCulpritsInsightModel, 'title'|'description'|'category'|'shouldShow'>):
424424
CLSCulpritsInsightModel {
425+
let maxScore = 0;
426+
for (const cluster of partialModel.clusters) {
427+
if (cluster.clusterCumulativeScore > maxScore) {
428+
maxScore = cluster.clusterCumulativeScore;
429+
}
430+
}
431+
425432
return {
426433
title: i18nString(UIStrings.title),
427434
description: i18nString(UIStrings.description),
428435
category: InsightCategory.CLS,
429-
// TODO: getTopCulprits in component needs to move to model so this can be set here.
430-
shouldShow: true,
436+
// TODO: getTopCulprits in component needs to move to model so this can be set properly here.
437+
shouldShow: maxScore > 0,
431438
...partialModel,
432439
};
433440
}

front_end/panels/timeline/TimelinePanel.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1949,7 +1949,19 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
19491949

19501950
this.#setActiveInsight(null);
19511951

1952-
const traceInsightsSets = this.#traceEngineModel.traceInsights(traceIndex);
1952+
let traceInsightsSets = this.#traceEngineModel.traceInsights(traceIndex);
1953+
if (traceInsightsSets) {
1954+
// Omit insight sets that don't have anything of interest to show to the user.
1955+
const filteredTraceInsightsSets = new Map();
1956+
for (const [key, insightSet] of traceInsightsSets) {
1957+
if (Object.values(insightSet.model).some(model => model.shouldShow)) {
1958+
filteredTraceInsightsSets.set(key, insightSet);
1959+
}
1960+
}
1961+
1962+
traceInsightsSets = filteredTraceInsightsSets.size ? filteredTraceInsightsSets : null;
1963+
}
1964+
19531965
this.flameChart.setInsights(traceInsightsSets, this.#eventToRelatedInsights);
19541966
this.#sideBar.setInsights(traceInsightsSets);
19551967

36.9 KB
Loading

0 commit comments

Comments
 (0)