chrome-devtools-frontend 1.0.1733843 → 1.0.1736236

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/.agents/rules/tests/test-view-and-presenter-isolation.md +4 -4
  2. package/.agents/rules/ui-and-widgets/ui-declarative-tree-and-prompt-patterns.md +61 -0
  3. package/.agents/rules/ui-and-widgets/ui-lit-declarative-templates-and-directives.md +11 -7
  4. package/.agents/rules/ui-and-widgets/ui-modern-component-and-encapsulation-standards.md +13 -4
  5. package/.agents/rules/ui-and-widgets/ui-pure-view-and-presenter-separation.md +31 -2
  6. package/.agents/rules/ui-and-widgets/ui-reactive-widget-update-lifecycle.md +23 -4
  7. package/.agents/rules/ui-and-widgets/ui-widget-dom-and-listener-lifecycle.md +34 -3
  8. package/.agents/skills/code-review/SKILL.md +27 -0
  9. package/.agents/skills/devtools-uistrings/SKILL.md +147 -0
  10. package/.agents/skills/ui-eng-vision-local-lit-renderer/SKILL.md +27 -1
  11. package/.agents/skills/ui-eng-vision-orchestrator/SKILL.md +100 -0
  12. package/.agents/skills/ui-eng-vision-test-scaffolder/SKILL.md +16 -0
  13. package/.agents/skills/ui-eng-vision-widget-promoter/SKILL.md +13 -2
  14. package/.agents/skills/ui-widgets/SKILL.md +25 -25
  15. package/DIR_METADATA +8 -1
  16. package/docs/cookbook/localization.md +1 -1
  17. package/docs/ui_engineering.md +24 -0
  18. package/eslint.config.mjs +0 -1
  19. package/front_end/application_tokens.css +1 -1
  20. package/front_end/core/host/AidaClient.ts +147 -202
  21. package/front_end/core/host/AidaClientTypes.ts +9 -0
  22. package/front_end/core/host/AidaErrors.ts +416 -0
  23. package/front_end/core/host/AidaGcaTranslation.ts +11 -0
  24. package/front_end/core/host/InspectorFrontendHostAPI.ts +9 -2
  25. package/front_end/core/host/UserMetrics.ts +25 -0
  26. package/front_end/core/host/UserMetricsEnums.ts +25 -0
  27. package/front_end/core/host/host.ts +3 -1
  28. package/front_end/core/i18n/collect-ui-strings.js +20 -0
  29. package/front_end/core/root/Runtime.ts +12 -0
  30. package/front_end/core/sdk/CPUThrottlingManager.ts +3 -0
  31. package/front_end/core/sdk/EnhancedTracesParser.ts +8 -4
  32. package/front_end/core/sdk/NetworkManager.ts +0 -6
  33. package/front_end/core/sdk/OverlayModel.ts +0 -6
  34. package/front_end/core/sdk/PreloadingModel.ts +30 -13
  35. package/front_end/core/sdk/PrivateVerificationTokensModel.ts +0 -18
  36. package/front_end/core/sdk/RehydratingConnection.ts +5 -2
  37. package/front_end/core/sdk/ResourceTreeModel.ts +0 -42
  38. package/front_end/core/sdk/ScreenCaptureModel.ts +0 -84
  39. package/front_end/core/sdk/ServiceWorkerCacheModel.ts +0 -15
  40. package/front_end/core/sdk/StorageBucketsModel.ts +0 -15
  41. package/front_end/devtools_compatibility.js +57 -2
  42. package/front_end/entrypoints/formatter_worker/ScopeParser.ts +4 -2
  43. package/front_end/entrypoints/inspector_main/RenderingOptions.ts +203 -127
  44. package/front_end/entrypoints/inspector_main/renderingOptions.css +5 -0
  45. package/front_end/entrypoints/node_app/app/NodeMain.ts +0 -9
  46. package/front_end/entrypoints/node_app/app/nodeConnectionsPanel.css +0 -22
  47. package/front_end/generated/InspectorBackendCommands.ts +1 -1
  48. package/front_end/generated/SupportedCSSProperties.ts +0 -136
  49. package/front_end/generated/protocol-proxy-api.d.ts +231 -231
  50. package/front_end/generated/protocol.ts +1 -0
  51. package/front_end/models/ai_assistance/AiAgent2.ts +4 -1
  52. package/front_end/models/ai_assistance/ChangeManager.ts +3 -1
  53. package/front_end/models/ai_assistance/DOMHelpers.ts +118 -3
  54. package/front_end/models/ai_assistance/ExtensionScope.ts +31 -24
  55. package/front_end/models/ai_assistance/agents/AiAgent.ts +6 -0
  56. package/front_end/models/ai_assistance/agents/PerformanceAgent.snapshot.txt +13 -13
  57. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +1 -1
  58. package/front_end/models/ai_assistance/ai_assistance.ts +2 -0
  59. package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.snapshot.txt +18 -8
  60. package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.ts +2 -2
  61. package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.snapshot.txt +103 -81
  62. package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.ts +15 -203
  63. package/front_end/models/ai_assistance/injected.ts +6 -1
  64. package/front_end/models/ai_assistance/skills/lighthouse.md +1 -1
  65. package/front_end/models/ai_assistance/skills/styling.md +8 -10
  66. package/front_end/models/ai_assistance/tools/GetTraceEventByKey.ts +1 -1
  67. package/front_end/models/ai_assistance/tools/SetElementStyles.ts +288 -0
  68. package/front_end/models/ai_assistance/tools/Tool.ts +1 -0
  69. package/front_end/models/ai_assistance/tools/ToolRegistry.ts +3 -0
  70. package/front_end/models/bindings/ResourceScriptMapping.ts +64 -16
  71. package/front_end/models/comment_manager/CD4ABridge.ts +12 -2
  72. package/front_end/models/comment_manager/CommentManager.ts +24 -4
  73. package/front_end/models/javascript_metadata/NativeFunctions.ts +41 -1
  74. package/front_end/models/project_settings/ProjectSettingsModel.ts +1 -1
  75. package/front_end/models/trace/handlers/FlowsHandler.ts +10 -0
  76. package/front_end/models/trace/handlers/SamplesHandler.ts +3 -2
  77. package/front_end/models/trace/handlers/ScriptsHandler.ts +25 -26
  78. package/front_end/models/trace/helpers/TreeHelpers.ts +4 -0
  79. package/front_end/models/trace/insights/DuplicatedJavaScript.ts +1 -2
  80. package/front_end/models/trace/types/TraceEvents.ts +21 -22
  81. package/front_end/panels/ai_assistance/components/ChatMessage.ts +9 -1
  82. package/front_end/panels/ai_assistance/components/chatInput.css +4 -4
  83. package/front_end/panels/animation/AnimationTimeline.ts +3 -3
  84. package/front_end/panels/animation/animationTimeline.css +6 -4
  85. package/front_end/panels/application/IndexedDBModel.ts +0 -15
  86. package/front_end/panels/application/appManifestView.css +2 -5
  87. package/front_end/panels/application/components/backForwardCacheView.css +1 -5
  88. package/front_end/panels/application/components/serviceWorkerRouterView.css +2 -2
  89. package/front_end/panels/application/preloading/components/PreloadingString.ts +7 -0
  90. package/front_end/panels/comments/CommentsPane.ts +12 -7
  91. package/front_end/panels/comments/commentsPane.css +16 -2
  92. package/front_end/panels/common/CommentsOverlayWidget.ts +16 -10
  93. package/front_end/panels/common/CommentsStatusBarPill.ts +12 -5
  94. package/front_end/panels/common/commentsOverlay.css +7 -1
  95. package/front_end/panels/common/commentsStatusBarPill.css +30 -0
  96. package/front_end/panels/console/consolePrompt.css +0 -12
  97. package/front_end/panels/console/consoleView.css +2 -2
  98. package/front_end/panels/developer_resources/developerResourcesView.css +4 -3
  99. package/front_end/panels/elements/DOMTreeWidget.ts +29 -9
  100. package/front_end/panels/elements/StylePropertyTreeElement.ts +2 -1
  101. package/front_end/panels/elements/components/CSSHintDetailsView.ts +12 -5
  102. package/front_end/panels/elements/components/cssVariableValueView.css +1 -1
  103. package/front_end/panels/elements/components/elementsBreadcrumbs.css +2 -2
  104. package/front_end/panels/elements/domTreeWidget.css +6 -1
  105. package/front_end/panels/elements/elementsPanel.css +0 -6
  106. package/front_end/panels/elements/layoutPane.css +1 -1
  107. package/front_end/panels/elements/metricsSidebarPane.css +1 -1
  108. package/front_end/panels/elements/platformFontsWidget.css +1 -1
  109. package/front_end/panels/elements/stylesSidebarPane.css +0 -10
  110. package/front_end/panels/emulation/deviceModeView.css +6 -7
  111. package/front_end/panels/explain/components/consoleInsight.css +4 -4
  112. package/front_end/panels/issues/issuesTree.css +1 -26
  113. package/front_end/panels/lighthouse/lighthouseStartView.css +2 -2
  114. package/front_end/panels/linear_memory_inspector/components/linearMemoryInspector.css +1 -1
  115. package/front_end/panels/media/TickingFlameChart.ts +20 -3
  116. package/front_end/panels/media/playerMessagesView.css +2 -2
  117. package/front_end/panels/mobile_throttling/ThrottlingSettingsTab.ts +24 -5
  118. package/front_end/panels/mobile_throttling/throttlingSettingsTab.css +1 -6
  119. package/front_end/panels/network/networkLogView.css +2 -2
  120. package/front_end/panels/network/networkTimingTable.css +1 -1
  121. package/front_end/panels/performance_monitor/performanceMonitor.css +0 -4
  122. package/front_end/panels/protocol_monitor/JSONEditor.css +1 -1
  123. package/front_end/panels/protocol_monitor/JSONEditor.ts +4 -2
  124. package/front_end/panels/recorder/recorderPanel.css +3 -3
  125. package/front_end/panels/recorder/recordingListView.css +1 -1
  126. package/front_end/panels/screencast/screencastView.css +1 -1
  127. package/front_end/panels/search/searchResultsPane.css +1 -1
  128. package/front_end/panels/security/SecurityModel.ts +0 -6
  129. package/front_end/panels/security/SecurityPanel.ts +120 -108
  130. package/front_end/panels/security/originView.css +1 -1
  131. package/front_end/panels/sensors/locationsSettingsTab.css +3 -3
  132. package/front_end/panels/settings/EditFileSystemView.ts +159 -104
  133. package/front_end/panels/settings/editFileSystemView.css +30 -4
  134. package/front_end/panels/settings/emulation/devicesSettingsTab.css +0 -52
  135. package/front_end/panels/settings/settingsScreen.css +0 -7
  136. package/front_end/panels/sources/CallStackSidebarPane.ts +339 -221
  137. package/front_end/panels/sources/NavigatorView.ts +95 -8
  138. package/front_end/panels/sources/ThreadsSidebarPane.ts +8 -4
  139. package/front_end/panels/sources/breakpointsView.css +1 -3
  140. package/front_end/panels/sources/callStackSidebarPane.css +4 -0
  141. package/front_end/panels/sources/components/HeadersView.ts +15 -2
  142. package/front_end/panels/sources/watchExpressionsSidebarPane.css +0 -1
  143. package/front_end/panels/timeline/CountersGraph.ts +0 -4
  144. package/front_end/panels/timeline/TimelineLoader.ts +16 -6
  145. package/front_end/panels/timeline/TimelinePanel.ts +20 -12
  146. package/front_end/panels/timeline/TimelineUIUtils.ts +1 -1
  147. package/front_end/panels/timeline/components/DetailsView.ts +2 -1
  148. package/front_end/panels/timeline/components/cwvMetrics.css +1 -1
  149. package/front_end/panels/timeline/components/metricCard.css +1 -1
  150. package/front_end/panels/timeline/components/sidebarAnnotationsTab.css +4 -4
  151. package/front_end/panels/timeline/timelineFlameChartView.css +1 -1
  152. package/front_end/panels/webauthn/WebauthnPane.ts +13 -14
  153. package/front_end/panels/webauthn/webauthnPane.css +1 -1
  154. package/front_end/third_party/chromium/README.chromium +1 -1
  155. package/front_end/ui/comments/CommentOverlayManager.ts +34 -18
  156. package/front_end/ui/components/icon_button/FileSourceIcon.ts +6 -0
  157. package/front_end/ui/components/input/textInput.css +1 -1
  158. package/front_end/ui/components/panel_introduction_steps/panelIntroductionSteps.css +6 -4
  159. package/front_end/ui/components/suggestion_input/suggestionInput.css +2 -2
  160. package/front_end/ui/components/text_editor/AiCodeGenerationTeaser.ts +14 -2
  161. package/front_end/ui/legacy/DockController.ts +17 -4
  162. package/front_end/ui/legacy/Treeoutline.ts +2 -2
  163. package/front_end/ui/legacy/UIUtils.ts +148 -10
  164. package/front_end/ui/legacy/components/inline_editor/bezierEditor.css +3 -2
  165. package/front_end/ui/legacy/components/perf_ui/chartViewport.css +2 -2
  166. package/front_end/ui/legacy/components/perf_ui/filmStripView.css +2 -2
  167. package/front_end/ui/legacy/components/perf_ui/pieChart.css +1 -1
  168. package/front_end/ui/legacy/components/quick_open/filteredListWidget.css +5 -4
  169. package/front_end/ui/legacy/components/source_frame/imageView.css +1 -1
  170. package/front_end/ui/legacy/components/utils/TargetDetachedDialog.ts +0 -3
  171. package/front_end/ui/legacy/components/utils/imagePreview.css +1 -1
  172. package/front_end/ui/legacy/inspectorCommon.css +1 -14
  173. package/front_end/ui/legacy/inspectorDrawerTabbedPane.css +3 -2
  174. package/front_end/ui/legacy/listWidget.css +0 -18
  175. package/front_end/ui/legacy/theme_support/ThemeSupport.ts +44 -9
  176. package/front_end/ui/lit/strip-whitespace.ts +1 -1
  177. package/front_end/ui/visual_logging/KnownContextValues.ts +1 -0
  178. package/package.json +3 -3
  179. package/front_end/generated/Deprecation.ts +0 -471
  180. package/front_end/panels/accessibility/axBreadcrumbs.css +0 -155
  181. package/front_end/panels/network/requestHeadersTree.css +0 -226
  182. package/front_end/panels/recorder/startView.css +0 -38
  183. package/front_end/panels/security/ipProtectionView.css +0 -141
  184. package/front_end/ui/legacy/components/inline_editor/animationNameSwatch.css +0 -27
@@ -14855,6 +14855,7 @@ export namespace Page {
14855
14855
  PublickeyCredentialsRemoteClientDataJson = 'publickey-credentials-remote-client-data-json',
14856
14856
  Rewriter = 'rewriter',
14857
14857
  ScreenWakeLock = 'screen-wake-lock',
14858
+ SemanticEmbedder = 'semantic-embedder',
14858
14859
  Serial = 'serial',
14859
14860
  SmartCard = 'smart-card',
14860
14861
  SpeakerSelection = 'speaker-selection',
@@ -67,11 +67,14 @@ Your role is to help web developers debug, analyze, and optimize web application
67
67
  * **Informational or exploratory questions** (e.g., asking what a network request, script, element, or storage entry is or does):
68
68
  - Answer directly and concisely in 1–2 short paragraphs or a compact list of key facts.
69
69
  - Do NOT include "**Root Cause**" or "**Suggestions**" sections, and do not add unrequested optimization advice when nothing is broken.
70
- * **Debugging or optimization questions** (e.g., asking why something fails, renders incorrectly, or is slow, or how to improve/fix it):
70
+ * **Debugging or optimization questions (without live page modifications)** (e.g., asking why something fails, renders incorrectly, or is slow, or how to improve/fix it when you have NOT modified the live page):
71
71
  - **Root Cause(s)**: Point out the root cause(s) of the problem.
72
72
  - Example: "**Root Cause**: [reason]" or "**Root Causes**:" followed by a bulleted list.
73
73
  - **Suggestion(s)**: List actionable solution suggestion(s) in order of impact.
74
74
  - Example: "**Suggestion**: [Suggestion]" or "**Suggestions**:" followed by a bulleted list.
75
+ * **Turns where you modified the live page** (e.g., after applying CSS or DOM changes to the inspected page):
76
+ - **Root Cause(s)** (include when diagnosing a bug): Point out the root cause(s) of the problem.
77
+ - **Applied Live Changes**: Detail the changes you applied to the live page (including the modified CSS properties or HTML attributes), note that these live changes are temporary and will reset on page reload, and ask the user to verify the result before updating their source code. Do NOT use "**Suggestion(s)**" or "**Suggested fix**" headings when you have already modified the live page.
75
78
 
76
79
  # Follow-up Suggestions
77
80
  * At the end of your response, call the \`suggestFollowUps\` function to provide 1 to 3 relevant, concise follow-up queries or actions for the user.
@@ -8,7 +8,9 @@ import * as SDK from '../../core/sdk/sdk.js';
8
8
  import type * as Protocol from '../../generated/protocol.js';
9
9
 
10
10
  export interface Change {
11
- groupId: string;
11
+ // Optional identifier (such as an agent or conversation ID) to group changes;
12
+ // omitted by callers that do not scope style changes to a specific group.
13
+ groupId?: string;
12
14
  // Selector used by the page or a simple selector as the fallback.
13
15
  selector: string;
14
16
  className: string;
@@ -52,20 +52,51 @@ export function stringifyObjectOnThePage(this: unknown): string {
52
52
  });
53
53
  }
54
54
 
55
+ const DISALLOWED_CSS_URL_FUNCTION_REGEX = /(?:^|[^a-zA-Z0-9_-])(?:-webkit-image-set|image-set|url|src)\s*\(/i;
56
+
57
+ function isDisallowedCssValue(value: string): boolean {
58
+ // Reject CSS backslash escapes (`\`) and comment openers (`/*`) outright.
59
+ // Unparsed declarations (`var()`, `if()`) preserve raw escapes in CSSOM
60
+ // serialization, and stripping `/*...*/` with a regex can join adjacent
61
+ // tokens or delete text across quoted strings.
62
+ return value.includes('\\') || value.includes('/*') || DISALLOWED_CSS_URL_FUNCTION_REGEX.test(value);
63
+ }
64
+
65
+ /**
66
+ * Sanitizes a record of CSS property declarations against the browser's CSS
67
+ * parser and rejects URL-referencing values.
68
+ *
69
+ * 1. Converts camelCase property names to kebab-case.
70
+ * 2. Drops empty values and values containing CSS backslash escapes (`\`),
71
+ * comment openers (`/*`), or external URL functions (`url()`,
72
+ * `image-set()`, `-webkit-image-set()`, `src()`) so style edits cannot
73
+ * trigger outbound network requests.
74
+ * 3. Validates the remaining declarations with `CSSStyleSheet` so unknown
75
+ * property names and invalid property values are omitted, and re-checks
76
+ * serialized CSSOM values against `DISALLOWED_CSS_URL_FUNCTION_REGEX`.
77
+ */
55
78
  export async function sanitizeStyleChanges(selector: string,
56
79
  styles: Record<string, string>): Promise<Record<string, string>> {
57
80
  const cssStyleValue: string[] = [];
58
81
  const changedStyles: string[] = [];
59
82
  const kebabStyles = Platform.StringUtilities.toKebabCaseKeys(styles);
60
83
  for (const [style, value] of Object.entries(kebabStyles)) {
61
- // Build up the CSS style
84
+ // Reject values that reference external URLs or use CSS escapes/comments
85
+ // so style changes cannot trigger outbound network requests.
86
+ if (!value.trim() || isDisallowedCssValue(value)) {
87
+ continue;
88
+ }
89
+ // Build up the CSS style.
62
90
  cssStyleValue.push(`${style}: ${value};`);
63
91
  // Keep track of what style changed to query later.
64
92
  changedStyles.push(style);
65
93
  }
66
94
 
95
+ // CSSStyleSheet is unavailable when foundation_unittests run in Node.js;
96
+ // fall back to returning the filtered kebab-case styles without browser CSS
97
+ // validation.
67
98
  if (typeof CSSStyleSheet === 'undefined' || typeof CSSStyleRule === 'undefined') {
68
- return kebabStyles;
99
+ return Object.fromEntries(changedStyles.map(style => [style, kebabStyles[style]]));
69
100
  }
70
101
 
71
102
  const styleSheet = new CSSStyleSheet({disabled: true});
@@ -79,7 +110,10 @@ export async function sanitizeStyleChanges(selector: string,
79
110
  }
80
111
  for (const style of changedStyles) {
81
112
  const value = cssRule.style.getPropertyValue(style);
82
- if (value) {
113
+ // Re-check Blink's serialized CSSOM value against URL functions only;
114
+ // Pass 1 already blocked raw `\` and `/*`, while CSSOM legitimately
115
+ // inserts `\"` when canonicalizing quoted strings (such as `'"AI"'`).
116
+ if (value && !DISALLOWED_CSS_URL_FUNCTION_REGEX.test(value)) {
83
117
  sanitizedStyles[style] = value;
84
118
  }
85
119
  }
@@ -88,6 +122,87 @@ export async function sanitizeStyleChanges(selector: string,
88
122
  return sanitizedStyles;
89
123
  }
90
124
 
125
+ /**
126
+ * Removes inline `style` declarations that match the provided CSS properties.
127
+ *
128
+ * Pre-existing inline declarations for modified properties (which have higher
129
+ * CSS specificity than class rules in `ChangeManager`) must be stripped so the
130
+ * class rule takes effect. This mirrors `el.style[key] = null` in the
131
+ * page-injected `setElementStyles` function (`injected.ts`).
132
+ */
133
+ export function removeInlineStyleProperties(
134
+ inlineStyle: string,
135
+ styles: Record<string, string>,
136
+ ): string {
137
+ // Normalize property names (e.g. `backgroundColor` -> `background-color`)
138
+ // because CSSStyleDeclaration#removeProperty requires kebab-case names.
139
+ const kebabStyles = Platform.StringUtilities.toKebabCaseKeys(styles);
140
+
141
+ // CSSStyleSheet is only undefined when foundation_unittests run in bare
142
+ // Node.js (`--node-unit-tests`); fall back to string-splitting in that
143
+ // test runner. In Chrome, execution always continues to CSSStyleSheet below.
144
+ if (typeof CSSStyleSheet === 'undefined' || typeof CSSStyleRule === 'undefined') {
145
+ const declarations = inlineStyle.split(';').map(decl => decl.trim()).filter(Boolean).filter(decl => {
146
+ const colonIndex = decl.indexOf(':');
147
+ return colonIndex !== -1 && !(decl.slice(0, colonIndex).trim() in kebabStyles);
148
+ });
149
+ return declarations.length > 0 ? `${declarations.join('; ')};` : '';
150
+ }
151
+
152
+ // CSSStyleDeclaration cannot be constructed directly (`new CSSStyleDeclaration()`
153
+ // throws). Create a detached CSSStyleSheet with a dummy `* {}` rule so we can
154
+ // use `cssRule.style` as an off-DOM CSSStyleDeclaration parser.
155
+ const styleSheet = new CSSStyleSheet({disabled: true});
156
+ styleSheet.replaceSync('* {}');
157
+ const cssRule = styleSheet.cssRules[0];
158
+ if (!(cssRule instanceof CSSStyleRule)) {
159
+ return '';
160
+ }
161
+
162
+ // Parse the element's raw `style="..."` attribute string into the dummy rule,
163
+ // remove each property being modified by the AI (matching `el.style[key] = null`
164
+ // in V1), and serialize the remaining inline declarations back to a string.
165
+ cssRule.style.cssText = inlineStyle;
166
+ for (const key of Object.keys(kebabStyles)) {
167
+ cssRule.style.removeProperty(key);
168
+ }
169
+ return cssRule.style.cssText;
170
+ }
171
+
172
+ /**
173
+ * Adopts a `CSSStyleSheet` containing the `ChangeManager` rules into the
174
+ * target element's enclosing `ShadowRoot`.
175
+ *
176
+ * `ChangeManager` injects rules into the document-level inspector stylesheet,
177
+ * which does not pierce Shadow DOM. This function is evaluated on the target
178
+ * element in the inspected page via `RemoteObject#callFunction` (mirroring the
179
+ * `adoptedStyleSheets` logic in `injected.ts`), so it must remain completely
180
+ * self-contained and cannot reference DevTools frontend state.
181
+ */
182
+ export function adoptStyleSheetInShadowRoot(this: Object, prefix: string, styleChanges: string): void {
183
+ if (!(this instanceof Element)) {
184
+ return;
185
+ }
186
+ const rootNode = this.getRootNode();
187
+ if (!(rootNode instanceof ShadowRoot)) {
188
+ return;
189
+ }
190
+ // eslint-disable-next-line @devtools/no-adopted-style-sheets
191
+ const stylesheets = rootNode.adoptedStyleSheets;
192
+ for (const sheet of stylesheets) {
193
+ for (const rule of sheet.cssRules) {
194
+ if (rule instanceof CSSStyleRule && rule.selectorText.startsWith(`.${prefix}`)) {
195
+ sheet.replaceSync(styleChanges);
196
+ return;
197
+ }
198
+ }
199
+ }
200
+ const stylesheet = new CSSStyleSheet();
201
+ stylesheet.replaceSync(styleChanges);
202
+ // eslint-disable-next-line @devtools/no-adopted-style-sheets
203
+ rootNode.adoptedStyleSheets = [...stylesheets, stylesheet];
204
+ }
205
+
91
206
  export function dispatchAiAssistanceDoneEvent(): void {
92
207
  if (typeof window !== 'undefined') {
93
208
  window.dispatchEvent(new CustomEvent('aiassistancedone'));
@@ -223,6 +223,23 @@ export class ExtensionScope {
223
223
  return node.localName() || node.nodeName().toLowerCase();
224
224
  }
225
225
 
226
+ /**
227
+ * Derives a CSS selector for `node`, preferring the selector from the
228
+ * element's primary matched CSS rule in `matchedStyles` and falling back to
229
+ * the node's tag/id/class attributes when no matched rule selector applies.
230
+ */
231
+ static getSelectorForElement(
232
+ node: SDK.DOMModel.DOMNode,
233
+ matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles|null,
234
+ ): string {
235
+ if (!matchedStyles) {
236
+ return ExtensionScope.getSelectorForNode(node);
237
+ }
238
+ const styleRule = ExtensionScope.getStyleRuleFromMatchesStyles(matchedStyles);
239
+ const selector = styleRule ? ExtensionScope.getSelectorsFromStyleRule(styleRule, matchedStyles) : null;
240
+ return selector || ExtensionScope.getSelectorForNode(node);
241
+ }
242
+
226
243
  async #computeContextFromElement(remoteObject: SDK.RemoteObject.RemoteObject): Promise<ElementContext> {
227
244
  if (!remoteObject.objectId) {
228
245
  throw new Error('DOMModel is not found');
@@ -243,38 +260,28 @@ export class ExtensionScope {
243
260
  throw new Error('Node is not found');
244
261
  }
245
262
 
263
+ let matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles|null = null;
246
264
  try {
247
- const matchedStyles = await cssModel.getMatchedStyles(node.id);
248
-
249
- if (!matchedStyles) {
250
- throw new Error('No matching styles');
251
- }
252
-
253
- const styleRule = ExtensionScope.getStyleRuleFromMatchesStyles(matchedStyles);
254
-
255
- if (!styleRule) {
256
- throw new Error('No style rule found');
257
- }
258
-
259
- const selector = ExtensionScope.getSelectorsFromStyleRule(styleRule, matchedStyles);
260
-
261
- if (!selector) {
262
- throw new Error('No selector found');
263
- }
264
-
265
- return {
266
- selector,
267
- };
265
+ matchedStyles = await cssModel.getMatchedStyles(node.id);
268
266
  } catch {
269
- // no-op to allow the fallback below to run.
267
+ // Leave matchedStyles as null so getSelectorForElement falls back to a
268
+ // simple tag/id/class selector (`getSelectorForNode`).
270
269
  }
271
270
 
272
- // Fallback
273
271
  return {
274
- selector: ExtensionScope.getSelectorForNode(node),
272
+ selector: ExtensionScope.getSelectorForElement(node, matchedStyles),
275
273
  };
276
274
  }
277
275
 
276
+ /**
277
+ * Handles the runtime binding callback from the V1 page-injected
278
+ * `setElementStyles` function (`injected.ts`).
279
+ *
280
+ * `SetElementStylesTool` (`tools/SetElementStyles.ts`) is the V2 SDK-based
281
+ * equivalent of this flow and is designed to be behaviorally identical. Any
282
+ * functional changes here must stay in sync with `SetElementStylesTool` until
283
+ * V1 is removed (b/581814240).
284
+ */
278
285
  async #bindingCalled(executionContext: SDK.RuntimeModel.ExecutionContext, event: {
279
286
  data: Protocol.Runtime.BindingCalledEvent,
280
287
  }): Promise<void> {
@@ -790,6 +790,8 @@ export abstract class AiAgent<T> {
790
790
  readonly #structuredLog: Array<{
791
791
  request: Host.AidaClient.DoConversationRequest,
792
792
  aidaResponse: Host.AidaClient.DoConversationResponse,
793
+ requestTimestamp: number,
794
+ responseTimestamp: number,
793
795
  }> = [];
794
796
 
795
797
  /**
@@ -1598,6 +1600,7 @@ export abstract class AiAgent<T> {
1598
1600
  let aidaResponse: Host.AidaClient.DoConversationResponse|undefined = undefined;
1599
1601
  let rpcId: Host.AidaClient.RpcGlobalId|undefined;
1600
1602
 
1603
+ const requestTimestamp = Math.floor(Date.now() * 1000);
1601
1604
  for await (aidaResponse of this.#aidaClient.doConversation(request, options)) {
1602
1605
  if (aidaResponse.functionCalls?.length) {
1603
1606
  yield {
@@ -1618,9 +1621,12 @@ export abstract class AiAgent<T> {
1618
1621
  }
1619
1622
 
1620
1623
  if (isDebugMode() && aidaResponse) {
1624
+ const responseTimestamp = Math.floor(Date.now() * 1000);
1621
1625
  this.#structuredLog.push({
1622
1626
  request: structuredClone(request),
1623
1627
  aidaResponse,
1628
+ requestTimestamp,
1629
+ responseTimestamp,
1624
1630
  });
1625
1631
  try {
1626
1632
  Platform.HostRuntime.HOST_RUNTIME.getLocalStorage()?.setItem('aiAssistanceStructuredLog',
@@ -98,20 +98,20 @@ Content:
98
98
  "allUrls = [0: https://web.dev/, 1: https://fonts.gstatic.com/s/roboto/v30/KFOlCnqEu92Fr1MmEU9fCxc4AMP6lbBP.woff2, 2: https://fonts.gstatic.com/s/roboto/v30/KFOlCnqEu92Fr1MmEU9fBxc4AMP6lbBP.woff2, 3: https://fonts.gstatic.com/s/roboto/v30/KFOlCnqEu92Fr1MmEU9fABc4AMP6lbBP.woff2, 4: https://fonts.gstatic.com/s/roboto/v30/KFOlCnqEu92Fr1MmEU9fChc4AMP6lbBP.woff2, 5: https://fonts.gstatic.com/s/materialicons/v142/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2, 6: https://fonts.gstatic.com/s/roboto/v30/KFOlCnqEu92Fr1MmEU9fBBc4AMP6lQ.woff2, 7: https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu4mxKKTU1Kg.woff2, 8: https://web.dev/_pwa/web/manifest.json, 9: https://fonts.googleapis.com/css?family=Google+Sans:400,500|Roboto:400,400italic,500,500italic,700,700italic|Roboto+Mono:400,500,700&display=swap, 10: https://fonts.gstatic.com/s/googlesans/v59/4UasrENHsxJlGDuGo1OIlJfC6l_24rlCK1Yo_Iqcsih3SAyH6cAwhX9RPjIUvbQoi-E.woff2, 11: https://fonts.googleapis.com/css2?family=Material+Icons&family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=block, 12: https://www.gstatic.com/devrel-devsite/prod/vafe2e13ca17bb026e70df42a2ead1c8192750e86a12923a88eda839025dabf95/web/css/app.css, 13: https://web.dev/extras.css]",
99
99
  "",
100
100
  "0;s-7302;1 ms;2 ms;568 ms;569 ms;568 ms;15 ms;0.5 ms;200;text/html;VeryHigh;VeryHigh;VeryHigh;f;unknown;t;;[];[content-security-policy: base-uri 'self'; object-src 'none'; script-src 'strict-dynamic' 'unsafe-inline' https: http: 'nonce-pLl1WHuNABXXiQLLmUesvDyvzBJZdE' 'unsafe-eval'; report-uri https://csp.withgoogle.com/csp/devsite/v2|content-encoding: gzip|x-content-type-options: nosniff|date: Mon, 29 Apr 2024 11:01:15 GMT|strict-transport-security: max-age=63072000; includeSubdomains; preload|alt-svc: h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000|content-length: <redacted>|x-xss-protection: 0|pragma: no-cache|last-modified: Fri, 26 Apr 2024 16:43:17 GMT|server: Google Frontend|vary: Cookie, Accept-Encoding|x-frame-options: SAMEORIGIN|content-type: text/html; charset=utf-8|x-cloud-trace-context: <redacted>|cache-control: no-cache, must-revalidate|expires: 0]",
101
- "1;s-49309;1,395 ms;1,402 ms;1,415 ms;1,423 ms;28 ms;94 μs;9 ms;200;font/woff2;VeryHigh;VeryHigh;VeryHigh;f;unknown;t;;[];[content-length: <redacted>|last-modified: Wed, 11 May 2022 19:24:58 GMT|content-type: font/woff2|cache-control: public, max-age=31536000|expires: Thu, 24 Apr 2025 15:02:33 GMT]",
102
- "2;s-46519;1,348 ms;1,355 ms;1,361 ms;1,423 ms;75 ms;73 μs;62 ms;200;font/woff2;VeryHigh;VeryHigh;VeryHigh;f;unknown;t;;[];[content-length: <redacted>|last-modified: Wed, 11 May 2022 19:24:41 GMT|content-type: font/woff2|cache-control: public, max-age=31536000|expires: Tue, 29 Apr 2025 03:50:51 GMT]",
103
- "3;s-46196;1,331 ms;1,339 ms;1,355 ms;1,420 ms;89 ms;0.1 ms;65 ms;200;font/woff2;VeryHigh;VeryHigh;VeryHigh;f;unknown;t;;[];[content-length: <redacted>|last-modified: Wed, 11 May 2022 19:24:39 GMT|content-type: font/woff2|cache-control: public, max-age=31536000|expires: Sat, 26 Apr 2025 20:29:46 GMT]",
104
- "4;s-45814;1,326 ms;1,331 ms;1,348 ms;1,419 ms;93 ms;77 μs;71 ms;200;font/woff2;VeryHigh;VeryHigh;VeryHigh;f;unknown;t;;[];[content-length: <redacted>|last-modified: Wed, 11 May 2022 19:24:56 GMT|content-type: font/woff2|cache-control: public, max-age=31536000|expires: Fri, 25 Apr 2025 13:27:47 GMT]",
105
- "5;s-44751;1,286 ms;1,307 ms;1,343 ms;1,416 ms;130 ms;1 ms;73 ms;200;font/woff2;VeryHigh;VeryHigh;VeryHigh;f;unknown;t;;[];[content-length: <redacted>|last-modified: Mon, 08 Apr 2024 19:04:51 GMT|content-type: font/woff2|cache-control: public, max-age=31536000|expires: Sat, 26 Apr 2025 09:49:05 GMT]",
106
- "6;s-44728;1,285 ms;1,307 ms;1,343 ms;1,406 ms;120 ms;1 ms;62 ms;200;font/woff2;VeryHigh;VeryHigh;VeryHigh;f;unknown;t;;[];[content-length: <redacted>|last-modified: Wed, 11 May 2022 19:24:53 GMT|content-type: font/woff2|cache-control: public, max-age=31536000|expires: Mon, 28 Apr 2025 21:44:44 GMT]",
107
- "7;s-44701;1,284 ms;1,300 ms;1,339 ms;1,405 ms;120 ms;0.2 ms;65 ms;200;font/woff2;VeryHigh;VeryHigh;VeryHigh;f;unknown;t;;[];[content-length: <redacted>|last-modified: Wed, 11 May 2022 19:24:50 GMT|content-type: font/woff2|cache-control: public, max-age=31536000|expires: Fri, 25 Apr 2025 09:35:28 GMT]",
101
+ "1;s-49309;1,395 ms;1,402 ms;1,415 ms;1,423 ms;28 ms;94 μs;9 ms;200;font/woff2;VeryHigh;VeryHigh;VeryHigh;f;unknown;t;;[];[date: Wed, 24 Apr 2024 15:02:33 GMT|x-content-type-options: nosniff|age: 417214|content-security-policy-report-only: <redacted>|cross-origin-resource-policy: <redacted>|alt-svc: h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000|content-length: <redacted>|x-xss-protection: 0|last-modified: Wed, 11 May 2022 19:24:58 GMT|server: sffe|cross-origin-opener-policy: <redacted>|report-to: {\"group\":\"apps-themes\",\"max_age\":2592000,\"endpoints\":[{\"url\":\"https://csp.withgoogle.com/csp/report-to/apps-themes\"}]}|content-type: font/woff2|access-control-allow-origin: *|cache-control: public, max-age=31536000|accept-ranges: bytes|timing-allow-origin: *|expires: Thu, 24 Apr 2025 15:02:33 GMT]",
102
+ "2;s-46519;1,348 ms;1,355 ms;1,361 ms;1,423 ms;75 ms;73 μs;62 ms;200;font/woff2;VeryHigh;VeryHigh;VeryHigh;f;unknown;t;;[];[date: Mon, 29 Apr 2024 03:50:51 GMT|x-content-type-options: nosniff|age: 25516|content-security-policy-report-only: <redacted>|cross-origin-resource-policy: <redacted>|alt-svc: h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000|content-length: <redacted>|x-xss-protection: 0|last-modified: Wed, 11 May 2022 19:24:41 GMT|server: sffe|cross-origin-opener-policy: <redacted>|report-to: {\"group\":\"apps-themes\",\"max_age\":2592000,\"endpoints\":[{\"url\":\"https://csp.withgoogle.com/csp/report-to/apps-themes\"}]}|content-type: font/woff2|access-control-allow-origin: *|cache-control: public, max-age=31536000|accept-ranges: bytes|timing-allow-origin: *|expires: Tue, 29 Apr 2025 03:50:51 GMT]",
103
+ "3;s-46196;1,331 ms;1,339 ms;1,355 ms;1,420 ms;89 ms;0.1 ms;65 ms;200;font/woff2;VeryHigh;VeryHigh;VeryHigh;f;unknown;t;;[];[date: Fri, 26 Apr 2024 20:29:46 GMT|x-content-type-options: nosniff|age: 224781|content-security-policy-report-only: <redacted>|cross-origin-resource-policy: <redacted>|alt-svc: h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000|content-length: <redacted>|x-xss-protection: 0|last-modified: Wed, 11 May 2022 19:24:39 GMT|server: sffe|cross-origin-opener-policy: <redacted>|report-to: {\"group\":\"apps-themes\",\"max_age\":2592000,\"endpoints\":[{\"url\":\"https://csp.withgoogle.com/csp/report-to/apps-themes\"}]}|content-type: font/woff2|access-control-allow-origin: *|cache-control: public, max-age=31536000|accept-ranges: bytes|timing-allow-origin: *|expires: Sat, 26 Apr 2025 20:29:46 GMT]",
104
+ "4;s-45814;1,326 ms;1,331 ms;1,348 ms;1,419 ms;93 ms;77 μs;71 ms;200;font/woff2;VeryHigh;VeryHigh;VeryHigh;f;unknown;t;;[];[date: Thu, 25 Apr 2024 13:27:47 GMT|x-content-type-options: nosniff|age: 336500|content-security-policy-report-only: <redacted>|cross-origin-resource-policy: <redacted>|alt-svc: h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000|content-length: <redacted>|x-xss-protection: 0|last-modified: Wed, 11 May 2022 19:24:56 GMT|server: sffe|cross-origin-opener-policy: <redacted>|report-to: {\"group\":\"apps-themes\",\"max_age\":2592000,\"endpoints\":[{\"url\":\"https://csp.withgoogle.com/csp/report-to/apps-themes\"}]}|content-type: font/woff2|access-control-allow-origin: *|cache-control: public, max-age=31536000|accept-ranges: bytes|timing-allow-origin: *|expires: Fri, 25 Apr 2025 13:27:47 GMT]",
105
+ "5;s-44751;1,286 ms;1,307 ms;1,343 ms;1,416 ms;130 ms;1 ms;73 ms;200;font/woff2;VeryHigh;VeryHigh;VeryHigh;f;unknown;t;;[];[date: Fri, 26 Apr 2024 09:49:05 GMT|x-content-type-options: nosniff|age: 263222|content-security-policy-report-only: <redacted>|cross-origin-resource-policy: <redacted>|alt-svc: h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000|content-length: <redacted>|x-xss-protection: 0|last-modified: Mon, 08 Apr 2024 19:04:51 GMT|server: sffe|cross-origin-opener-policy: <redacted>|report-to: {\"group\":\"apps-themes\",\"max_age\":2592000,\"endpoints\":[{\"url\":\"https://csp.withgoogle.com/csp/report-to/apps-themes\"}]}|content-type: font/woff2|access-control-allow-origin: *|cache-control: public, max-age=31536000|accept-ranges: bytes|timing-allow-origin: *|expires: Sat, 26 Apr 2025 09:49:05 GMT]",
106
+ "6;s-44728;1,285 ms;1,307 ms;1,343 ms;1,406 ms;120 ms;1 ms;62 ms;200;font/woff2;VeryHigh;VeryHigh;VeryHigh;f;unknown;t;;[];[date: Sun, 28 Apr 2024 21:44:44 GMT|x-content-type-options: nosniff|age: 47483|content-security-policy-report-only: <redacted>|cross-origin-resource-policy: <redacted>|alt-svc: h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000|content-length: <redacted>|x-xss-protection: 0|last-modified: Wed, 11 May 2022 19:24:53 GMT|server: sffe|cross-origin-opener-policy: <redacted>|report-to: {\"group\":\"apps-themes\",\"max_age\":2592000,\"endpoints\":[{\"url\":\"https://csp.withgoogle.com/csp/report-to/apps-themes\"}]}|content-type: font/woff2|access-control-allow-origin: *|cache-control: public, max-age=31536000|accept-ranges: bytes|timing-allow-origin: *|expires: Mon, 28 Apr 2025 21:44:44 GMT]",
107
+ "7;s-44701;1,284 ms;1,300 ms;1,339 ms;1,405 ms;120 ms;0.2 ms;65 ms;200;font/woff2;VeryHigh;VeryHigh;VeryHigh;f;unknown;t;;[];[date: Thu, 25 Apr 2024 09:35:28 GMT|x-content-type-options: nosniff|age: 350439|content-security-policy-report-only: <redacted>|cross-origin-resource-policy: <redacted>|alt-svc: h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000|content-length: <redacted>|x-xss-protection: 0|last-modified: Wed, 11 May 2022 19:24:50 GMT|server: sffe|cross-origin-opener-policy: <redacted>|report-to: {\"group\":\"apps-themes\",\"max_age\":2592000,\"endpoints\":[{\"url\":\"https://csp.withgoogle.com/csp/report-to/apps-themes\"}]}|content-type: font/woff2|access-control-allow-origin: *|cache-control: public, max-age=31536000|accept-ranges: bytes|timing-allow-origin: *|expires: Fri, 25 Apr 2025 09:35:28 GMT]",
108
108
  "8;s-43119;1,751 ms;1,751 ms;1,771 ms;1,771 ms;20 ms;27 μs;0.2 ms;200;application/json;Medium;Medium;Medium;f;unknown;t;0;[];[date: Sun, 28 Apr 2024 14:07:49 GMT|last-modified: Wed, 24 Apr 2024 11:02:59 GMT|server: Google Frontend|age: 75208|content-type: application/json|x-cloud-trace-context: <redacted>|cache-control: public, max-age=86400|alt-svc: h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000|content-length: <redacted>]",
109
- "9;s-7695;557 ms;557 ms;597 ms;597 ms;40 ms;3 ms;0.6 ms;200;text/css;VeryHigh;VeryHigh;VeryHigh;t;unknown;t;0;[];[last-modified: Mon, 29 Apr 2024 10:51:49 GMT|content-type: text/css; charset=utf-8|cache-control: private, max-age=86400, stale-while-revalidate=604800|expires: Mon, 29 Apr 2024 11:01:15 GMT]",
110
- "7;s-34909;770 ms;770 ms;771 ms;776 ms;6 ms;40 μs;5 ms;200;font/woff2;VeryHigh;VeryHigh;VeryHigh;f;unknown;t;;[];[content-type: font/woff2|cache-control: public, max-age=31536000|expires: Fri, 25 Oct 2024 10:46:00 GMT|content-length: <redacted>|last-modified: Wed, 11 May 2022 19:24:50 GMT]",
111
- "10;s-11121;602 ms;602 ms;603 ms;611 ms;9 ms;27 μs;8 ms;200;font/woff2;VeryHigh;VeryHigh;VeryHigh;f;unknown;t;;[];[content-length: <redacted>|last-modified: Wed, 24 Apr 2024 23:37:14 GMT|content-type: font/woff2|cache-control: public, max-age=31536000|expires: Fri, 25 Apr 2025 15:44:03 GMT]",
112
- "11;s-7703;557 ms;557 ms;597 ms;597 ms;40 ms;90 μs;0.1 ms;200;text/css;VeryHigh;VeryHigh;VeryHigh;t;unknown;t;0;[];[last-modified: Mon, 29 Apr 2024 11:01:15 GMT|content-type: text/css; charset=utf-8|cache-control: private, max-age=86400, stale-while-revalidate=604800|expires: Mon, 29 Apr 2024 11:01:15 GMT]",
113
- "5;s-11334;606 ms;606 ms;607 ms;615 ms;9 ms;30 μs;8 ms;200;font/woff2;VeryHigh;VeryHigh;VeryHigh;f;unknown;t;11;[];[content-length: <redacted>|last-modified: Mon, 08 Apr 2024 19:04:51 GMT|content-type: font/woff2|cache-control: public, max-age=31536000|expires: Sat, 26 Apr 2025 09:49:05 GMT]",
114
- "12;s-7722;557 ms;557 ms;562 ms;568 ms;11 ms;0.5 ms;6 ms;200;text/css;VeryHigh;VeryHigh;VeryHigh;t;unknown;t;0;[];[content-length: <redacted>|last-modified: Thu, 25 Apr 2024 19:58:26 GMT|content-type: text/css|cache-control: public, max-age=31536000|expires: Tue, 29 Apr 2025 10:56:02 GMT]",
109
+ "9;s-7695;557 ms;557 ms;597 ms;597 ms;40 ms;3 ms;0.6 ms;200;text/css;VeryHigh;VeryHigh;VeryHigh;t;unknown;t;0;[];[date: Mon, 29 Apr 2024 11:01:15 GMT|content-encoding: gzip|x-content-type-options: nosniff|strict-transport-security: max-age=31536000|cross-origin-resource-policy: <redacted>|alt-svc: h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000|x-xss-protection: 0|last-modified: Mon, 29 Apr 2024 10:51:49 GMT|server: ESF|cross-origin-opener-policy: <redacted>|x-frame-options: SAMEORIGIN|content-type: text/css; charset=utf-8|access-control-allow-origin: *|cache-control: private, max-age=86400, stale-while-revalidate=604800|timing-allow-origin: *|link: <https://fonts.gstatic.com>; rel=preconnect; crossorigin|expires: Mon, 29 Apr 2024 11:01:15 GMT]",
110
+ "7;s-34909;770 ms;770 ms;771 ms;776 ms;6 ms;40 μs;5 ms;200;font/woff2;VeryHigh;VeryHigh;VeryHigh;f;unknown;t;;[];[x-google-security-signals: <redacted>|x-google-gfe-service-trace: <redacted>|content-security-policy-report-only: <redacted>|x-google-scs-row-timestamp: <redacted>|x-google-gfe-response-code-details-trace: <redacted>|cross-origin-resource-policy: <redacted>|x-google-scs-row-key: <redacted>|content-type: font/woff2|access-control-allow-origin: *|x-google-data-version: <redacted>|cache-control: public, max-age=31536000|x-google-gfe-backend-request-info: <redacted>|x-google-dos-service-trace: <redacted>|x-google-backends: <redacted>|date: Thu, 26 Oct 2023 10:46:00 GMT|x-content-type-options: nosniff|expires: Fri, 25 Oct 2024 10:46:00 GMT|x-google-gfe-version: <redacted>|x-google-netmon-label: <redacted>|alt-svc: h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000|content-length: <redacted>|x-google-service: <redacted>|x-xss-protection: 0|x-google-gfe-handshake-trace: <redacted>|x-google-shellfish-status: <redacted>|last-modified: Wed, 11 May 2022 19:24:50 GMT|server: sffe|cross-origin-opener-policy: <redacted>|report-to: {\"group\":\"apps-themes\",\"max_age\":2592000,\"endpoints\":[{\"url\":\"https://csp.withgoogle.com/csp/report-to/apps-themes\"}]}|x-google-gfe-request-trace: <redacted>|accept-ranges: bytes|timing-allow-origin: *|x-google-scs-repo: <redacted>]",
111
+ "10;s-11121;602 ms;602 ms;603 ms;611 ms;9 ms;27 μs;8 ms;200;font/woff2;VeryHigh;VeryHigh;VeryHigh;f;unknown;t;;[];[date: Thu, 25 Apr 2024 15:44:03 GMT|x-content-type-options: nosniff|age: 328319|content-security-policy-report-only: <redacted>|cross-origin-resource-policy: <redacted>|alt-svc: h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000|content-length: <redacted>|x-xss-protection: 0|last-modified: Wed, 24 Apr 2024 23:37:14 GMT|server: sffe|cross-origin-opener-policy: <redacted>|report-to: {\"group\":\"apps-themes\",\"max_age\":2592000,\"endpoints\":[{\"url\":\"https://csp.withgoogle.com/csp/report-to/apps-themes\"}]}|content-type: font/woff2|access-control-allow-origin: *|cache-control: public, max-age=31536000|accept-ranges: bytes|timing-allow-origin: *|expires: Fri, 25 Apr 2025 15:44:03 GMT]",
112
+ "11;s-7703;557 ms;557 ms;597 ms;597 ms;40 ms;90 μs;0.1 ms;200;text/css;VeryHigh;VeryHigh;VeryHigh;t;unknown;t;0;[];[date: Mon, 29 Apr 2024 11:01:15 GMT|content-encoding: gzip|x-content-type-options: nosniff|strict-transport-security: max-age=31536000|cross-origin-resource-policy: <redacted>|alt-svc: h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000|x-xss-protection: 0|last-modified: Mon, 29 Apr 2024 11:01:15 GMT|server: ESF|cross-origin-opener-policy: <redacted>|x-frame-options: SAMEORIGIN|content-type: text/css; charset=utf-8|access-control-allow-origin: *|cache-control: private, max-age=86400, stale-while-revalidate=604800|timing-allow-origin: *|link: <https://fonts.gstatic.com>; rel=preconnect; crossorigin|expires: Mon, 29 Apr 2024 11:01:15 GMT]",
113
+ "5;s-11334;606 ms;606 ms;607 ms;615 ms;9 ms;30 μs;8 ms;200;font/woff2;VeryHigh;VeryHigh;VeryHigh;f;unknown;t;11;[];[date: Fri, 26 Apr 2024 09:49:05 GMT|x-content-type-options: nosniff|age: 263217|content-security-policy-report-only: <redacted>|cross-origin-resource-policy: <redacted>|alt-svc: h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000|content-length: <redacted>|x-xss-protection: 0|last-modified: Mon, 08 Apr 2024 19:04:51 GMT|server: sffe|cross-origin-opener-policy: <redacted>|report-to: {\"group\":\"apps-themes\",\"max_age\":2592000,\"endpoints\":[{\"url\":\"https://csp.withgoogle.com/csp/report-to/apps-themes\"}]}|content-type: font/woff2|access-control-allow-origin: *|cache-control: public, max-age=31536000|accept-ranges: bytes|timing-allow-origin: *|expires: Sat, 26 Apr 2025 09:49:05 GMT]",
114
+ "12;s-7722;557 ms;557 ms;562 ms;568 ms;11 ms;0.5 ms;6 ms;200;text/css;VeryHigh;VeryHigh;VeryHigh;t;unknown;t;0;[];[date: Mon, 29 Apr 2024 10:56:02 GMT|content-encoding: gzip|x-content-type-options: nosniff|age: 256|content-security-policy-report-only: <redacted>|cross-origin-resource-policy: <redacted>|alt-svc: h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000|content-length: <redacted>|x-xss-protection: 0|last-modified: Thu, 25 Apr 2024 19:58:26 GMT|server: sffe|cross-origin-opener-policy: <redacted>|vary: Accept-Encoding|report-to: {\"group\":\"devrel-devsite\",\"max_age\":2592000,\"endpoints\":[{\"url\":\"https://csp.withgoogle.com/csp/report-to/devrel-devsite\"}]}|content-type: text/css|access-control-allow-origin: *|cache-control: public, max-age=31536000|accept-ranges: bytes|expires: Tue, 29 Apr 2025 10:56:02 GMT]",
115
115
  "13;s-7737;557 ms;557 ms;561 ms;561 ms;4 ms;0.4 ms;0.2 ms;200;text/css;VeryHigh;VeryHigh;VeryHigh;t;unknown;t;0;[];[content-security-policy: base-uri 'self'; object-src 'none'; script-src 'strict-dynamic' 'unsafe-inline' https: http: 'nonce-laTwEoovJjOKcMoBUjSFaYO6rrF8dU' 'unsafe-eval'; report-uri https://csp.withgoogle.com/csp/devsite/v2|content-encoding: gzip|x-content-type-options: nosniff|date: Mon, 29 Apr 2024 11:00:18 GMT|strict-transport-security: max-age=63072000; includeSubdomains; preload|alt-svc: h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000|content-length: <redacted>|x-xss-protection: 0|pragma: no-cache|last-modified: Tue, 19 Mar 2024 18:37:07 GMT|server: Google Frontend|vary: Cookie, Accept-Encoding|x-frame-options: SAMEORIGIN|content-type: text/css|x-cloud-trace-context: <redacted>|cache-control: no-cache, must-revalidate|expires: 0]",
116
116
  "",
117
117
  "# Main thread bottom-up summary",
@@ -818,7 +818,7 @@ export class PerformanceAgent extends AiAgent<AgentFocus> {
818
818
  }
819
819
 
820
820
  // TODO(b/425270067): Format in the same way that "Summary" detail tab does.
821
- const details = formatEventForAI(event, parsedTrace);
821
+ const details = formatEventForAI(event);
822
822
 
823
823
  const key = `getEventByKey('${params.eventKey}')`;
824
824
  this.#cacheFunctionResult(focus, key, details);
@@ -64,6 +64,7 @@ import * as RecordPerformanceTrace from './tools/RecordPerformanceTrace.js';
64
64
  import * as ResolveDevtoolsNodePath from './tools/ResolveDevtoolsNodePath.js';
65
65
  import * as RunLighthouse from './tools/RunLighthouse.js';
66
66
  import * as SelectTraceEventByKey from './tools/SelectTraceEventByKey.js';
67
+ import * as SetElementStyles from './tools/SetElementStyles.js';
67
68
  import * as Tool from './tools/Tool.js';
68
69
  import * as ToolRegistry from './tools/ToolRegistry.js';
69
70
 
@@ -131,6 +132,7 @@ export {
131
132
  ResolveDevtoolsNodePath,
132
133
  RunLighthouse,
133
134
  SelectTraceEventByKey,
135
+ SetElementStyles,
134
136
  Skill,
135
137
  SkillRegistry,
136
138
  StorageAgent,
@@ -30,10 +30,20 @@ From a service worker: No
30
30
  Initiators (root request to the request that directly loaded this one): file:///Users/cjamcl/surge/misc/display-dpr/index.html
31
31
  Response headers
32
32
  - cache-control: max-age=31536000, public
33
+ - x-via: <redacted>
34
+ - etag: <redacted>
35
+ - x-guest-hostname: <redacted>
36
+ - access-control-allow-methods: *
33
37
  - expires: Wed, 08 Jul 2026 17:27:17 GMT
38
+ - x-cdn-cache-status: <redacted>
39
+ - accept-ranges: bytes
40
+ - x-static-config: <redacted>
34
41
  - content-length: <redacted>
42
+ - date: Tue, 08 Jul 2025 17:27:29 GMT
35
43
  - content-type: image/webp
36
44
  - last-modified: Mon, 27 Jan 2025 17:50:34 GMT
45
+ - server: Apache
46
+ - access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, Authorization
37
47
 
38
48
  We can break this time down into the 4 subparts that combine to make the LCP time:
39
49
 
@@ -155,7 +165,7 @@ Network requests data:
155
165
 
156
166
  allUrls = [0: https://code.jquery.com/jquery-3.7.1.js, 1: http://localhost:8000/, 2: http://localhost:8000/render-blocking-stylesheet.css, 3: http://localhost:8000/render-blocking-script.js]
157
167
 
158
- 0;s-1920;581 ms;585 ms;1,943 ms;1,944 ms;1,363 ms;776 ms;1 ms;200;application/javascript;High;High;High;t;h2;f;1;[];[content-type: application/javascript; charset=utf-8|last-modified: Fri, 18 Oct 1991 12:00:00 GMT|cache-control: public, max-age=31536000, stale-while-revalidate=604800|content-length: <redacted>]
168
+ 0;s-1920;581 ms;585 ms;1,943 ms;1,944 ms;1,363 ms;776 ms;1 ms;200;application/javascript;High;High;High;t;h2;f;1;[];[content-encoding: gzip|etag: <redacted>|age: 3975412|x-cache: <redacted>|date: Fri, 07 Mar 2025 15:02:28 GMT|content-type: application/javascript; charset=utf-8|vary: Accept-Encoding|x-cache-hits: <redacted>|last-modified: Fri, 18 Oct 1991 12:00:00 GMT|x-served-by: <redacted>|cache-control: public, max-age=31536000, stale-while-revalidate=604800|x-timer: <redacted>|via: 1.1 varnish, 1.1 varnish|accept-ranges: bytes|access-control-allow-origin: *|content-length: <redacted>|server: nginx]
159
169
  2;s-1924;582 ms;583 ms;1,193 ms;1,193 ms;612 ms;0.2 ms;0.2 ms;200;text/css;VeryHigh;VeryHigh;VeryHigh;t;http/1.0;f;1;[];[Content-Length: <redacted>|Date: Fri, 07 Mar 2025 15:02:28 GMT|Content-type: text/css|Last-Modified: Fri, 07 Mar 2025 14:58:07 GMT|Server: SimpleHTTP/0.6 Python/3.9.6]
160
170
  3;s-1922;582 ms;583 ms;1,177 ms;1,178 ms;596 ms;0.4 ms;1 ms;200;text/javascript;High;High;High;t;http/1.0;f;1;[];[Content-Length: <redacted>|Date: Fri, 07 Mar 2025 15:02:28 GMT|Content-type: text/javascript|Last-Modified: Fri, 07 Mar 2025 15:00:28 GMT|Server: SimpleHTTP/0.6 Python/3.9.6]
161
171
 
@@ -622,13 +632,13 @@ Network requests data:
622
632
 
623
633
  allUrls = [0: https://ads.jetpackdigital.com/sites/_uploads/1742278386bg_opt_640x350-avif.avif, 1: http://localhost/old-http.html, 2: https://ads.jetpackdigital.com/sites/_uploads/1583540859Play.png, 3: https://ads.jetpackdigital.com/sites/_uploads/1583540859Muted.png, 4: https://ads.jetpackdigital.com/h5media/sites/_uploads/1742363510mm_allthefeels_20_mob.mp4, 5: https://ads.jetpackdigital.com/sites/_uploads/1583540860Pause.png, 6: https://ads.jetpackdigital.com/tracking_pixel.gif?8852762616, 7: https://ads.jetpackdigital.com/tracking_pixel.gif?7753243273]
624
634
 
625
- 0;s-1285;8 ms;12 ms;26 ms;26 ms;18 ms;2 ms;93 μs;200;image/avif;Low;Low;Low;f;http/1.1;f;1;[];[Content-Length: <redacted>|Last-Modified: Tue, 18 Mar 2025 06:13:07 GMT|Content-Type: image/avif]
626
- 2;s-1298;8 ms;13 ms;24 ms;24 ms;16 ms;0.6 ms;0.3 ms;200;image/png;Low;Low;Low;f;http/1.1;f;1;[];[Content-Length: <redacted>|Last-Modified: Tue, 24 Jan 2023 19:05:17 GMT|Content-Type: image/png]
627
- 3;s-1312;8 ms;13 ms;25 ms;25 ms;17 ms;1 ms;0.3 ms;200;image/png;Low;Low;Low;f;http/1.1;f;1;[];[Content-Length: <redacted>|Last-Modified: Tue, 24 Jan 2023 19:05:17 GMT|Content-Type: image/png]
628
- 4;s-1329;8 ms;13 ms;24 ms;24 ms;16 ms;0.4 ms;11 μs;200;video/mp4;Low;Low;Low;f;http/1.1;f;1;[];[Content-Length: <redacted>|Last-Modified: Wed, 19 Mar 2025 05:51:52 GMT|Content-Type: video/mp4]
629
- 5;s-1336;8 ms;13 ms;25 ms;25 ms;17 ms;1 ms;0.3 ms;200;image/png;Low;Low;Low;f;http/1.1;f;1;[];[Content-Length: <redacted>|Last-Modified: Tue, 24 Jan 2023 19:05:18 GMT|Content-Type: image/png]
630
- 6;s-1338;8 ms;24 ms;39 ms;39 ms;30 ms;0.1 ms;0.2 ms;200;image/gif;Low;Low;Low;f;http/1.1;f;1;[];[Content-Length: <redacted>|Last-Modified: Tue, 24 Jan 2023 19:54:47 GMT|Content-Type: image/gif]
631
- 7;s-1341;8 ms;25 ms;38 ms;38 ms;30 ms;0.2 ms;0.2 ms;200;image/gif;Low;Low;Low;f;http/1.1;f;1;[];[Content-Length: <redacted>|Last-Modified: Tue, 24 Jan 2023 19:54:47 GMT|Content-Type: image/gif]
635
+ 0;s-1285;8 ms;12 ms;26 ms;26 ms;18 ms;2 ms;93 μs;200;image/avif;Low;Low;Low;f;http/1.1;f;1;[];[x-amz-id-2: <redacted>|ETag: <redacted>|Connection: keep-alive|Access-Control-Allow-Methods: GET,HEAD,POST|x-amz-request-id: <redacted>|Accept-Ranges: bytes|Access-Control-Allow-Origin: *|Content-Length: <redacted>|Date: Thu, 20 Mar 2025 19:45:22 GMT|Last-Modified: Tue, 18 Mar 2025 06:13:07 GMT|Content-Type: image/avif|Server: AmazonS3|x-amz-server-side-encryption: <redacted>]
636
+ 2;s-1298;8 ms;13 ms;24 ms;24 ms;16 ms;0.6 ms;0.3 ms;200;image/png;Low;Low;Low;f;http/1.1;f;1;[];[x-amz-id-2: <redacted>|ETag: <redacted>|Connection: keep-alive|Access-Control-Allow-Methods: GET,HEAD,POST|x-amz-request-id: <redacted>|Accept-Ranges: bytes|Access-Control-Allow-Origin: *|Content-Length: <redacted>|Date: Thu, 20 Mar 2025 19:45:22 GMT|Last-Modified: Tue, 24 Jan 2023 19:05:17 GMT|Content-Type: image/png|Server: AmazonS3|x-amz-server-side-encryption: <redacted>]
637
+ 3;s-1312;8 ms;13 ms;25 ms;25 ms;17 ms;1 ms;0.3 ms;200;image/png;Low;Low;Low;f;http/1.1;f;1;[];[x-amz-id-2: <redacted>|ETag: <redacted>|Connection: keep-alive|Access-Control-Allow-Methods: GET,HEAD,POST|x-amz-request-id: <redacted>|Accept-Ranges: bytes|Access-Control-Allow-Origin: *|Content-Length: <redacted>|Date: Thu, 20 Mar 2025 19:45:22 GMT|Last-Modified: Tue, 24 Jan 2023 19:05:17 GMT|Content-Type: image/png|Server: AmazonS3|x-amz-server-side-encryption: <redacted>]
638
+ 4;s-1329;8 ms;13 ms;24 ms;24 ms;16 ms;0.4 ms;11 μs;200;video/mp4;Low;Low;Low;f;http/1.1;f;1;[];[x-amz-id-2: <redacted>|ETag: <redacted>|Connection: keep-alive|Access-Control-Allow-Methods: GET,HEAD,POST|x-amz-request-id: <redacted>|Accept-Ranges: bytes|Access-Control-Allow-Origin: *|Content-Length: <redacted>|Date: Thu, 20 Mar 2025 19:45:22 GMT|Last-Modified: Wed, 19 Mar 2025 05:51:52 GMT|Content-Type: video/mp4|Server: AmazonS3|x-amz-server-side-encryption: <redacted>]
639
+ 5;s-1336;8 ms;13 ms;25 ms;25 ms;17 ms;1 ms;0.3 ms;200;image/png;Low;Low;Low;f;http/1.1;f;1;[];[x-amz-id-2: <redacted>|ETag: <redacted>|Connection: keep-alive|Access-Control-Allow-Methods: GET,HEAD,POST|x-amz-request-id: <redacted>|Accept-Ranges: bytes|Access-Control-Allow-Origin: *|Content-Length: <redacted>|Date: Thu, 20 Mar 2025 19:45:22 GMT|Last-Modified: Tue, 24 Jan 2023 19:05:18 GMT|Content-Type: image/png|Server: AmazonS3|x-amz-server-side-encryption: <redacted>]
640
+ 6;s-1338;8 ms;24 ms;39 ms;39 ms;30 ms;0.1 ms;0.2 ms;200;image/gif;Low;Low;Low;f;http/1.1;f;1;[];[x-amz-id-2: <redacted>|x-amz-meta-jets3t-original-file-date-iso8601: <redacted>|ETag: <redacted>|x-amz-meta-md5-hash: <redacted>|Connection: keep-alive|Access-Control-Allow-Methods: GET,HEAD,POST|x-amz-request-id: <redacted>|Accept-Ranges: bytes|Access-Control-Allow-Origin: *|Content-Length: <redacted>|Date: Thu, 20 Mar 2025 19:45:22 GMT|Last-Modified: Tue, 24 Jan 2023 19:54:47 GMT|Content-Type: image/gif|Server: AmazonS3|x-amz-server-side-encryption: <redacted>]
641
+ 7;s-1341;8 ms;25 ms;38 ms;38 ms;30 ms;0.2 ms;0.2 ms;200;image/gif;Low;Low;Low;f;http/1.1;f;1;[];[x-amz-id-2: <redacted>|x-amz-meta-jets3t-original-file-date-iso8601: <redacted>|ETag: <redacted>|x-amz-meta-md5-hash: <redacted>|Connection: keep-alive|Access-Control-Allow-Methods: GET,HEAD,POST|x-amz-request-id: <redacted>|Accept-Ranges: bytes|Access-Control-Allow-Origin: *|Content-Length: <redacted>|Date: Thu, 20 Mar 2025 19:45:22 GMT|Last-Modified: Tue, 24 Jan 2023 19:54:47 GMT|Content-Type: image/gif|Server: AmazonS3|x-amz-server-side-encryption: <redacted>]
632
642
 
633
643
  ## Estimated savings: FCP 0 ms, LCP 0 ms
634
644
 
@@ -72,7 +72,7 @@ export class PerformanceInsightFormatter {
72
72
  }
73
73
 
74
74
  #formatRequestUrl(request: Trace.Types.Events.SyntheticNetworkRequest): string {
75
- return `${this.#traceFormatter.formatRequestUrl(request)} ${this.#traceFormatter.serializeEvent(request)}`;
75
+ return `${request.args.data.url} ${this.#traceFormatter.serializeEvent(request)}`;
76
76
  }
77
77
 
78
78
  #formatScriptUrl(script: Trace.Handlers.ModelHandlers.Scripts.Script): string {
@@ -466,7 +466,7 @@ Duplication grouped by Node modules: ${filesFormatted}`;
466
466
  for (const font of insight.fonts) {
467
467
  let fontName = font.name;
468
468
  if (!fontName) {
469
- const url = new Common.ParsedURL.ParsedURL(this.#traceFormatter.formatRequestUrl(font.request));
469
+ const url = new Common.ParsedURL.ParsedURL(font.request.args.data.url);
470
470
  fontName = url.isValid ? url.lastPathComponent : '(not available)';
471
471
  }
472
472
  output += `\n - Font name: ${fontName}, URL: ${