Skip to content

Commit 5e6608e

Browse files
Connor ClarkDevtools-frontend LUCI CQ
authored andcommitted
[RPP] Add links to new docs
Also add to the AI insights formatter. Fixed: 393453175, 428813446 Change-Id: I4c889d12b5b34215447c074527bfd4f01409c81d Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7017635 Auto-Submit: Connor Clark <[email protected]> Reviewed-by: Paul Irish <[email protected]> Commit-Queue: Connor Clark <[email protected]>
1 parent 951bae2 commit 5e6608e

24 files changed

+171
-88
lines changed

front_end/models/ai_assistance/agents/PerformanceAgent.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ const FAKE_LCP_MODEL = {
211211
strings: {},
212212
title: 'LCP breakdown' as Common.UIString.LocalizedString,
213213
description: 'some description' as Common.UIString.LocalizedString,
214+
docs: '',
214215
category: Trace.Insights.Types.InsightCategory.ALL,
215216
state: 'fail',
216217
frameId: '123',
@@ -220,6 +221,7 @@ const FAKE_INP_MODEL = {
220221
strings: {},
221222
title: 'INP breakdown' as Common.UIString.LocalizedString,
222223
description: 'some description' as Common.UIString.LocalizedString,
224+
docs: '',
223225
category: Trace.Insights.Types.InsightCategory.ALL,
224226
state: 'fail',
225227
frameId: '123',

front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.snapshot.txt

Lines changed: 43 additions & 8 deletions
Large diffs are not rendered by default.

front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.ts

Lines changed: 50 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,55 +1009,73 @@ ${this.#links()}`;
10091009
}
10101010

10111011
#links(): string {
1012+
const links = [];
1013+
1014+
if (this.#insight.docs) {
1015+
links.push(this.#insight.docs);
1016+
}
1017+
10121018
switch (this.#insight.insightKey) {
10131019
case 'CLSCulprits':
1014-
return `- https://web.dev/articles/cls
1015-
- https://web.dev/articles/optimize-cls`;
1020+
links.push('https://web.dev/articles/cls');
1021+
links.push('https://web.dev/articles/optimize-cls');
1022+
break;
10161023
case 'DocumentLatency':
1017-
return '- https://web.dev/articles/optimize-ttfb';
1024+
links.push('https://web.dev/articles/optimize-ttfb');
1025+
break;
10181026
case 'DOMSize':
1019-
return '- https://developer.chrome.com/docs/lighthouse/performance/dom-size/';
1020-
case 'DuplicatedJavaScript':
1021-
return '';
1027+
links.push('https://developer.chrome.com/docs/lighthouse/performance/dom-size/');
1028+
break;
10221029
case 'FontDisplay':
1023-
return `- https://web.dev/articles/preload-optional-fonts
1024-
- https://fonts.google.com/knowledge/glossary/foit
1025-
- https://developer.chrome.com/blog/font-fallbacks`;
1030+
links.push('https://web.dev/articles/preload-optional-fonts');
1031+
links.push('https://fonts.google.com/knowledge/glossary/foit');
1032+
links.push('https://developer.chrome.com/blog/font-fallbacks');
1033+
break;
10261034
case 'ForcedReflow':
1027-
return '- https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing#avoid-forced-synchronous-layouts';
1035+
links.push(
1036+
'https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing#avoid-forced-synchronous-layouts');
1037+
break;
10281038
case 'ImageDelivery':
1029-
return '- https://developer.chrome.com/docs/lighthouse/performance/uses-optimized-images/';
1039+
links.push('https://developer.chrome.com/docs/lighthouse/performance/uses-optimized-images/');
1040+
break;
10301041
case 'INPBreakdown':
1031-
return `- https://web.dev/articles/inp
1032-
- https://web.dev/explore/how-to-optimize-inp
1033-
- https://web.dev/articles/optimize-long-tasks
1034-
- https://web.dev/articles/avoid-large-complex-layouts-and-layout-thrashing`;
1035-
case 'LCPDiscovery':
1036-
return `- https://web.dev/articles/lcp
1037-
- https://web.dev/articles/optimize-lcp`;
1042+
links.push('https://web.dev/articles/inp');
1043+
links.push('https://web.dev/explore/how-to-optimize-inp');
1044+
links.push('https://web.dev/articles/optimize-long-tasks');
1045+
links.push('https://web.dev/articles/avoid-large-complex-layouts-and-layout-thrashing');
1046+
break;
10381047
case 'LCPBreakdown':
1039-
return `- https://web.dev/articles/lcp
1040-
- https://web.dev/articles/optimize-lcp`;
1041-
case 'NetworkDependencyTree':
1042-
return `- https://web.dev/learn/performance/understanding-the-critical-path
1043-
- https://developer.chrome.com/docs/lighthouse/performance/uses-rel-preconnect/`;
1048+
case 'LCPDiscovery':
10441049
case 'RenderBlocking':
1045-
return `- https://web.dev/articles/lcp
1046-
- https://web.dev/articles/optimize-lcp`;
1050+
links.push('https://web.dev/articles/lcp');
1051+
links.push('https://web.dev/articles/optimize-lcp');
1052+
break;
1053+
case 'NetworkDependencyTree':
1054+
links.push('https://web.dev/learn/performance/understanding-the-critical-path');
1055+
links.push('https://developer.chrome.com/docs/lighthouse/performance/uses-rel-preconnect/');
1056+
break;
10471057
case 'SlowCSSSelector':
1048-
return '- https://developer.chrome.com/docs/devtools/performance/selector-stats';
1058+
links.push('https://developer.chrome.com/docs/devtools/performance/selector-stats');
1059+
break;
10491060
case 'ThirdParties':
1050-
return '- https://web.dev/articles/optimizing-content-efficiency-loading-third-party-javascript/';
1061+
links.push('https://web.dev/articles/optimizing-content-efficiency-loading-third-party-javascript/');
1062+
break;
10511063
case 'Viewport':
1052-
return '- https://developer.chrome.com/blog/300ms-tap-delay-gone-away/';
1064+
links.push('https://developer.chrome.com/blog/300ms-tap-delay-gone-away/');
1065+
break;
10531066
case 'Cache':
1054-
return '- https://web.dev/uses-long-cache-ttl/';
1067+
links.push('https://web.dev/uses-long-cache-ttl/');
1068+
break;
10551069
case 'ModernHTTP':
1056-
return '- https://developer.chrome.com/docs/lighthouse/best-practices/uses-http2';
1070+
links.push('https://developer.chrome.com/docs/lighthouse/best-practices/uses-http2');
1071+
break;
10571072
case 'LegacyJavaScript':
1058-
return `- https://web.dev/articles/baseline-and-polyfills
1059-
- https://philipwalton.com/articles/the-state-of-es5-on-the-web/`;
1073+
links.push('https://web.dev/articles/baseline-and-polyfills');
1074+
links.push('https://philipwalton.com/articles/the-state-of-es5-on-the-web/');
1075+
break;
10601076
}
1077+
1078+
return links.map(link => '- ' + link).join('\n');
10611079
}
10621080

10631081
#description(): string {

0 commit comments

Comments
 (0)