chrome-devtools-frontend 1.0.1604514 → 1.0.1605390

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 (80) hide show
  1. package/AUTHORS +1 -0
  2. package/front_end/Images/src/dots-circle.svg +10 -0
  3. package/front_end/Tests.js +23 -7
  4. package/front_end/core/host/AidaClient.ts +114 -63
  5. package/front_end/core/host/AidaGcaTranslation.ts +6 -0
  6. package/front_end/core/host/GcaClient.ts +112 -0
  7. package/front_end/core/host/UserMetrics.ts +0 -1
  8. package/front_end/core/host/host.ts +2 -0
  9. package/front_end/core/root/ExperimentNames.ts +0 -1
  10. package/front_end/core/root/Runtime.ts +5 -0
  11. package/front_end/core/sdk/AutofillModel.ts +3 -2
  12. package/front_end/core/sdk/CSSModel.ts +3 -4
  13. package/front_end/core/sdk/CSSProperty.ts +1 -1
  14. package/front_end/core/sdk/ConsoleModel.ts +15 -13
  15. package/front_end/core/sdk/CookieModel.ts +5 -4
  16. package/front_end/core/sdk/DOMDebuggerModel.ts +20 -14
  17. package/front_end/core/sdk/DebuggerModel.ts +21 -36
  18. package/front_end/core/sdk/EventBreakpointsModel.ts +16 -6
  19. package/front_end/core/sdk/IsolateManager.ts +12 -7
  20. package/front_end/core/sdk/WebMCPModel.ts +57 -2
  21. package/front_end/entrypoints/main/MainImpl.ts +0 -4
  22. package/front_end/models/ai_assistance/agents/AiAgent.ts +9 -1
  23. package/front_end/models/ai_assistance/agents/ConversationSummaryAgent.ts +10 -9
  24. package/front_end/models/ai_assistance/agents/ExecuteJavascript.ts +301 -0
  25. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +50 -25
  26. package/front_end/models/ai_assistance/agents/StylingAgent.ts +12 -264
  27. package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.snapshot.txt +1 -1
  28. package/front_end/models/emulation/DeviceModeModel.ts +21 -26
  29. package/front_end/models/trace/insights/LCPDiscovery.ts +14 -6
  30. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +2 -17
  31. package/front_end/panels/ai_assistance/components/ChatMessage.ts +165 -65
  32. package/front_end/panels/ai_assistance/components/ChatView.ts +2 -13
  33. package/front_end/panels/ai_assistance/components/ExportForAgentsDialog.ts +1 -1
  34. package/front_end/panels/ai_assistance/components/chatMessage.css +48 -2
  35. package/front_end/panels/ai_assistance/components/chatView.css +0 -8
  36. package/front_end/panels/application/ApplicationPanelSidebar.ts +6 -0
  37. package/front_end/panels/application/IndexedDBViews.ts +0 -9
  38. package/front_end/panels/application/WebMCPTreeElement.ts +35 -0
  39. package/front_end/panels/application/WebMCPView.ts +468 -0
  40. package/front_end/panels/application/application.ts +4 -0
  41. package/front_end/panels/application/webMCPView.css +90 -0
  42. package/front_end/panels/common/aiCodeCompletionSummaryToolbar.css +1 -1
  43. package/front_end/panels/console/consoleView.css +4 -0
  44. package/front_end/panels/elements/ElementsTreeOutline.ts +87 -0
  45. package/front_end/panels/elements/StylesAiCodeCompletionProvider.ts +23 -2
  46. package/front_end/panels/elements/StylesSidebarPane.ts +85 -20
  47. package/front_end/panels/elements/elementsPanel.css +14 -0
  48. package/front_end/panels/elements/elementsTreeOutline.css +21 -0
  49. package/front_end/panels/network/NetworkLogViewColumns.ts +3 -3
  50. package/front_end/panels/profiler/HeapDetachedElementsView.ts +0 -4
  51. package/front_end/panels/profiler/HeapProfileView.ts +0 -4
  52. package/front_end/panels/profiler/HeapProfilerPanel.ts +4 -13
  53. package/front_end/panels/profiler/HeapSnapshotView.ts +12 -16
  54. package/front_end/panels/profiler/ProfileHeader.ts +0 -11
  55. package/front_end/panels/profiler/ProfileTypeRegistry.ts +4 -12
  56. package/front_end/panels/profiler/ProfileView.ts +1 -6
  57. package/front_end/panels/profiler/ProfilesPanel.ts +60 -7
  58. package/front_end/panels/recorder/components/recordingView.css +0 -6
  59. package/front_end/panels/sensors/SensorsView.ts +28 -59
  60. package/front_end/panels/timeline/EventsTimelineTreeView.ts +3 -3
  61. package/front_end/panels/timeline/ThirdPartyTreeView.ts +37 -38
  62. package/front_end/panels/timeline/TimelineDetailsView.ts +47 -41
  63. package/front_end/panels/timeline/TimelinePanel.ts +11 -0
  64. package/front_end/panels/timeline/TimelineTreeView.ts +149 -60
  65. package/front_end/panels/timeline/components/CWVMetrics.ts +18 -2
  66. package/front_end/panels/timeline/components/LiveMetricsView.ts +839 -783
  67. package/front_end/panels/timeline/thirdPartyTreeView.css +2 -2
  68. package/front_end/panels/timeline/timeline-meta.ts +11 -0
  69. package/front_end/panels/timeline/utils/Helpers.ts +5 -0
  70. package/front_end/ui/components/buttons/button.css +2 -2
  71. package/front_end/ui/components/text_editor/AiCodeCompletionProvider.ts +0 -11
  72. package/front_end/ui/legacy/FilterBar.ts +2 -0
  73. package/front_end/ui/legacy/InspectorDrawerView.ts +206 -0
  74. package/front_end/ui/legacy/InspectorView.ts +41 -91
  75. package/front_end/ui/legacy/SplitWidget.ts +33 -27
  76. package/front_end/ui/legacy/ViewManager.ts +14 -5
  77. package/front_end/ui/legacy/Widget.ts +36 -28
  78. package/front_end/ui/legacy/inspectorDrawerTabbedPane.css +5 -0
  79. package/front_end/ui/visual_logging/KnownContextValues.ts +8 -1
  80. package/package.json +1 -1
@@ -72,6 +72,11 @@ const UIStrings = {
72
72
  * @example {3} PH1
73
73
  */
74
74
  showAllNodesDMore: 'Show all nodes ({PH1} more)',
75
+ /**
76
+ * @description Text for a button to show all truncated lines in the tree.
77
+ * @example {5} PH1
78
+ */
79
+ showAllLines: 'Show all ({PH1} lines)',
75
80
  /**
76
81
  * @description Text for popover that directs to Issues panel
77
82
  */
@@ -98,6 +103,7 @@ interface ViewInput {
98
103
  expandRoot?: boolean;
99
104
  visibleWidth?: number;
100
105
  visible?: boolean;
106
+ maxRowsShown?: number;
101
107
  wrap: boolean;
102
108
  showSelectionOnKeyboardFocus: boolean;
103
109
  preventTabOrder: boolean;
@@ -134,6 +140,12 @@ export const DEFAULT_VIEW = (input: ViewInput, output: ViewOutput, target: HTMLE
134
140
  ElementsTreeOutline.Events.ElementsTreeUpdated, input.onElementsTreeUpdated, this);
135
141
  output.elementsTreeOutline.addEventListener(UI.TreeOutline.Events.ElementExpanded, input.onElementExpanded, this);
136
142
  output.elementsTreeOutline.addEventListener(UI.TreeOutline.Events.ElementCollapsed, input.onElementCollapsed, this);
143
+ output.elementsTreeOutline.addEventListener(ElementsTreeOutline.Events.ShowAllRows, () => {
144
+ if (output.elementsTreeOutline?.maxRowsShown) {
145
+ // Set max to undefined to show all rows
146
+ output.elementsTreeOutline.maxRowsShown = undefined;
147
+ }
148
+ }, this);
137
149
  target.appendChild(output.elementsTreeOutline.element);
138
150
  }
139
151
 
@@ -150,6 +162,7 @@ export const DEFAULT_VIEW = (input: ViewInput, output: ViewOutput, target: HTMLE
150
162
  if (input.visible !== undefined) {
151
163
  output.elementsTreeOutline.setVisible(input.visible);
152
164
  }
165
+ output.elementsTreeOutline.maxRowsShown = input.maxRowsShown;
153
166
  output.elementsTreeOutline.setWordWrap(input.wrap);
154
167
  output.elementsTreeOutline.setShowSelectionOnKeyboardFocus(input.showSelectionOnKeyboardFocus, input.preventTabOrder);
155
168
  if (input.deindentSingleNode) {
@@ -234,6 +247,17 @@ export class DOMTreeWidget extends UI.Widget.Widget {
234
247
  #visible = false;
235
248
  #visibleWidth?: number;
236
249
  #wrap = false;
250
+ #maxRows?: number;
251
+
252
+ // If maxRows is undefined, all rows are shown. If it is set to a number, only that many rows are shown.
253
+ set maxRows(maxRows: number|undefined) {
254
+ this.#maxRows = maxRows;
255
+ this.requestUpdate();
256
+ }
257
+
258
+ get maxRows(): number|undefined {
259
+ return this.#maxRows;
260
+ }
237
261
 
238
262
  set visibleWidth(width: number) {
239
263
  this.#visibleWidth = width;
@@ -402,6 +426,7 @@ export class DOMTreeWidget extends UI.Widget.Widget {
402
426
  }
403
427
 
404
428
  override performUpdate(): void {
429
+ const firstRender = !this.#viewOutput.elementsTreeOutline;
405
430
  this.#view(
406
431
  {
407
432
  omitRootDOMNode: this.omitRootDOMNode,
@@ -416,6 +441,7 @@ export class DOMTreeWidget extends UI.Widget.Widget {
416
441
  visibleWidth: this.#visibleWidth,
417
442
  visible: this.#visible,
418
443
  wrap: this.#wrap,
444
+ maxRowsShown: this.#maxRows,
419
445
  showSelectionOnKeyboardFocus: this.showSelectionOnKeyboardFocus,
420
446
  preventTabOrder: this.preventTabOrder,
421
447
  deindentSingleNode: this.deindentSingleNode,
@@ -437,6 +463,11 @@ export class DOMTreeWidget extends UI.Widget.Widget {
437
463
  },
438
464
  },
439
465
  this.#viewOutput, this.contentElement);
466
+ if (firstRender && this.#viewOutput.elementsTreeOutline) {
467
+ this.#viewOutput.elementsTreeOutline.addEventListener(ElementsTreeOutline.Events.ShowAllRows, () => {
468
+ this.maxRows = undefined;
469
+ });
470
+ }
440
471
  }
441
472
 
442
473
  modelAdded(domModel: SDK.DOMModel.DOMModel): void {
@@ -597,6 +628,8 @@ export class ElementsTreeOutline extends
597
628
  showAIButton: boolean;
598
629
  disableEdits: boolean;
599
630
  expandRoot: boolean;
631
+ #maxRowsShown?: number;
632
+ #showAllButton?: HTMLElement;
600
633
 
601
634
  constructor(
602
635
  omitRootDOMNode?: boolean, selectEnabled?: boolean, hideGutter?: boolean, maxTreeDepth?: number,
@@ -1030,6 +1063,58 @@ export class ElementsTreeOutline extends
1030
1063
  }
1031
1064
  }
1032
1065
 
1066
+ set maxRowsShown(maxRows: number|undefined) {
1067
+ this.#maxRowsShown = maxRows;
1068
+ this.#updateShowAllButton();
1069
+ }
1070
+
1071
+ #updateShowAllButton(): void {
1072
+ const container = this.shadowRoot.querySelector('.elements-disclosure') as HTMLElement;
1073
+ if (!container) {
1074
+ return;
1075
+ }
1076
+ if (!this.#maxRowsShown) {
1077
+ this.#showAllButton?.classList.add('hidden');
1078
+ container.style.removeProperty('--max-rows');
1079
+ container.classList.remove('elements-tree-truncated');
1080
+ return;
1081
+ }
1082
+
1083
+ container.style.setProperty('--max-rows', String(this.#maxRowsShown));
1084
+ container.classList.add('elements-tree-truncated');
1085
+
1086
+ // We use a microtask to wait for rendering so all node lines are rendered.
1087
+ window.requestAnimationFrame(() => {
1088
+ // The container has a max-height (based on --max-rows). If the total content height
1089
+ // (scrollHeight) is greater than the visible height (clientHeight), it means
1090
+ // some rows are hidden due to truncation, and we should show the "Show all" button.
1091
+ const isOverflowing = container.scrollHeight > container.clientHeight;
1092
+ if (!isOverflowing) {
1093
+ return;
1094
+ }
1095
+ if (!this.#showAllButton) {
1096
+ this.#showAllButton = UI.UIUtils.createTextButton('', () => {
1097
+ this.dispatchEventToListeners(ElementsTreeOutline.Events.ShowAllRows);
1098
+ this.dispatchEventToListeners(UI.TreeOutline.Events.ElementExpanded, this.rootElement());
1099
+ }, {
1100
+ jslogContext: 'show-all-nodes',
1101
+ });
1102
+ this.#showAllButton.classList.add('elements-tree-show-all');
1103
+ this.shadowRoot.appendChild(this.#showAllButton);
1104
+ }
1105
+ this.#showAllButton.classList.remove('hidden');
1106
+ const computedStyle = window.getComputedStyle(container);
1107
+ const lineHeight = parseFloat(computedStyle.lineHeight) || 16;
1108
+ const truncatedLines = Math.round((container.scrollHeight - container.clientHeight) / lineHeight);
1109
+
1110
+ if (truncatedLines > 0) {
1111
+ this.#showAllButton.textContent = i18nString(UIStrings.showAllLines, {PH1: truncatedLines});
1112
+ } else {
1113
+ this.#showAllButton?.classList.add('hidden');
1114
+ }
1115
+ });
1116
+ }
1117
+
1033
1118
  highlightAdoptedStyleSheet(adoptedStyleSheet: SDK.DOMModel.AdoptedStyleSheet): void {
1034
1119
  const parentDOMNode =
1035
1120
  !this.includeRootDOMNode && adoptedStyleSheet.parent === this.rootDOMNode && this.rootDOMNode ?
@@ -2219,12 +2304,14 @@ export namespace ElementsTreeOutline {
2219
2304
  /* eslint-disable @typescript-eslint/naming-convention -- Used by web_tests. */
2220
2305
  SelectedNodeChanged = 'SelectedNodeChanged',
2221
2306
  ElementsTreeUpdated = 'ElementsTreeUpdated',
2307
+ ShowAllRows = 'ShowAllRows',
2222
2308
  /* eslint-enable @typescript-eslint/naming-convention */
2223
2309
  }
2224
2310
 
2225
2311
  export interface EventTypes {
2226
2312
  [Events.SelectedNodeChanged]: {node: SDK.DOMModel.DOMNode|null, focus: boolean};
2227
2313
  [Events.ElementsTreeUpdated]: SDK.DOMModel.DOMNode[];
2314
+ [Events.ShowAllRows]: void;
2228
2315
  }
2229
2316
  }
2230
2317
 
@@ -16,6 +16,18 @@ export class StylesAiCodeCompletionProvider {
16
16
  #aiCodeCompletion?: AiCodeCompletion.AiCodeCompletion.AiCodeCompletion;
17
17
  #aiCodeCompletionConfig?: TextEditor.AiCodeCompletionProvider.AiCodeCompletionConfig;
18
18
 
19
+ getCompletionHint?: () => string | null;
20
+ setAiAutoCompletion?: (args: {
21
+ text: string,
22
+ from: number,
23
+ startTime: number,
24
+ onImpression: (rpcGlobalId: Host.AidaClient.RpcGlobalId, latency: number, sampleId?: number) => void,
25
+ clearCachedRequest: () => void,
26
+ citations: Host.AidaClient.Citation[],
27
+ rpcGlobalId?: Host.AidaClient.RpcGlobalId,
28
+ sampleId?: number,
29
+ }|null) => void;
30
+
19
31
  #boundOnUpdateAiCodeCompletionState = this.#updateAiCodeCompletionState.bind(this);
20
32
 
21
33
  private constructor(aiCodeCompletionConfig: TextEditor.AiCodeCompletionProvider.AiCodeCompletionConfig) {
@@ -123,7 +135,7 @@ export class StylesAiCodeCompletionProvider {
123
135
  return;
124
136
  }
125
137
 
126
- this.#aiCodeCompletionConfig?.setAiAutoCompletion?.({
138
+ this.setAiAutoCompletion?.({
127
139
  text: currentPropertyString + aidaSuggestion.suggestionText,
128
140
  from: cursorPosition,
129
141
  rpcGlobalId: aidaSuggestion.rpcGlobalId,
@@ -131,6 +143,7 @@ export class StylesAiCodeCompletionProvider {
131
143
  startTime,
132
144
  clearCachedRequest: this.clearCache.bind(this),
133
145
  onImpression: this.#aiCodeCompletion.registerUserImpression.bind(this.#aiCodeCompletion),
146
+ citations: aidaSuggestion.citations,
134
147
  });
135
148
  }
136
149
 
@@ -206,7 +219,7 @@ export class StylesAiCodeCompletionProvider {
206
219
  return null;
207
220
  }
208
221
 
209
- const completionHint = this.#aiCodeCompletionConfig?.getCompletionHint?.();
222
+ const completionHint = this.getCompletionHint?.();
210
223
  if (!completionHint) {
211
224
  return response.generatedSamples[0];
212
225
  }
@@ -216,4 +229,12 @@ export class StylesAiCodeCompletionProvider {
216
229
  clearCache(): void {
217
230
  this.#aiCodeCompletion?.clearCachedRequest();
218
231
  }
232
+
233
+ onSuggestionAccepted(
234
+ citations: Host.AidaClient.Citation[], rpcGlobalId?: Host.AidaClient.RpcGlobalId, sampleId?: number): void {
235
+ this.#aiCodeCompletionConfig?.onSuggestionAccepted(citations);
236
+ if (rpcGlobalId) {
237
+ this.#aiCodeCompletion?.registerUserAcceptance(rpcGlobalId, sampleId);
238
+ }
239
+ }
219
240
  }
@@ -169,6 +169,10 @@ const HIGHLIGHTABLE_PROPERTIES = [
169
169
  {mode: 'flexibility', properties: ['flex', 'flex-basis', 'flex-grow', 'flex-shrink']},
170
170
  ];
171
171
 
172
+ const DISCLAIMER_TOOLTIP_ID = 'styles-ai-code-completion-disclaimer-tooltip';
173
+ const SPINNER_TOOLTIP_ID = 'styles-ai-code-completion-spinner-tooltip';
174
+ const CITATIONS_TOOLTIP_ID = 'styles-ai-code-completion-citations-tooltip';
175
+
172
176
  export class StylesSidebarPane extends Common.ObjectWrapper.eventMixin<EventTypes, typeof ElementsSidebarPane>(
173
177
  ElementsSidebarPane) implements StylesContainer {
174
178
  private matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles|null = null;
@@ -214,6 +218,11 @@ export class StylesSidebarPane extends Common.ObjectWrapper.eventMixin<EventType
214
218
  #updateAbortController?: AbortController;
215
219
  #updateComputedStylesAbortController?: AbortController;
216
220
 
221
+ aiCodeCompletionConfig?: TextEditor.AiCodeCompletionProvider.AiCodeCompletionConfig;
222
+ aiCodeCompletionProvider?: StylesAiCodeCompletionProvider.StylesAiCodeCompletionProvider;
223
+ #aiCodeCompletionSummaryToolbarContainer?: HTMLElement;
224
+ #aiCodeCompletionSummaryToolbar?: PanelsCommon.AiCodeCompletionSummaryToolbar;
225
+
217
226
  constructor(computedStyleModel: ComputedStyle.ComputedStyleModel.ComputedStyleModel) {
218
227
  super(computedStyleModel, {delegatesFocus: true});
219
228
  this.setMinimumSize(96, 26);
@@ -259,6 +268,26 @@ export class StylesSidebarPane extends Common.ObjectWrapper.eventMixin<EventType
259
268
  this.#scheduleResetUpdateIfNotEditing();
260
269
  }
261
270
  });
271
+
272
+ const devtoolsLocale = i18n.DevToolsLocale.DevToolsLocale.instance();
273
+ if (AiCodeCompletion.AiCodeCompletion.AiCodeCompletion.isAiCodeCompletionStylesEnabled(devtoolsLocale.locale)) {
274
+ this.aiCodeCompletionConfig = {
275
+ completionContext: {},
276
+ generationContext: {},
277
+ onFeatureEnabled: () => {
278
+ this.#createAiCodeCompletionSummaryToolbar();
279
+ },
280
+ onFeatureDisabled: () => {
281
+ this.#cleanupAiCodeCompletion();
282
+ },
283
+ onSuggestionAccepted: this.#onAiCodeCompletionSuggestionAccepted.bind(this),
284
+ onRequestTriggered: this.#onAiCodeCompletionRequestTriggered.bind(this),
285
+ onResponseReceived: this.#onAiCodeCompletionResponseReceived.bind(this),
286
+ panel: AiCodeCompletion.AiCodeCompletion.ContextFlavor.STYLES,
287
+ };
288
+ this.aiCodeCompletionProvider =
289
+ StylesAiCodeCompletionProvider.StylesAiCodeCompletionProvider.createInstance(this.aiCodeCompletionConfig);
290
+ }
262
291
  }
263
292
 
264
293
  get webCustomData(): WebCustomData|undefined {
@@ -1528,6 +1557,45 @@ export class StylesSidebarPane extends Common.ObjectWrapper.eventMixin<EventType
1528
1557
 
1529
1558
  return button;
1530
1559
  }
1560
+
1561
+ #cleanupAiCodeCompletion(): void {
1562
+ this.#aiCodeCompletionSummaryToolbarContainer?.remove();
1563
+ this.#aiCodeCompletionSummaryToolbarContainer = undefined;
1564
+ this.#aiCodeCompletionSummaryToolbar = undefined;
1565
+ }
1566
+
1567
+ #createAiCodeCompletionSummaryToolbar(): void {
1568
+ if (this.#aiCodeCompletionSummaryToolbar) {
1569
+ return;
1570
+ }
1571
+ this.#aiCodeCompletionSummaryToolbar = new PanelsCommon.AiCodeCompletionSummaryToolbar({
1572
+ citationsTooltipId: CITATIONS_TOOLTIP_ID,
1573
+ disclaimerTooltipId: DISCLAIMER_TOOLTIP_ID,
1574
+ spinnerTooltipId: SPINNER_TOOLTIP_ID,
1575
+ panel: AiCodeCompletion.AiCodeCompletion.ContextFlavor.STYLES,
1576
+ });
1577
+ const containingPane = this.contentElement.enclosingNodeOrSelfWithClass('style-panes-wrapper') as HTMLElement;
1578
+ this.#aiCodeCompletionSummaryToolbarContainer =
1579
+ containingPane.createChild('div', 'ai-code-completion-summary-toolbar-container');
1580
+ this.#aiCodeCompletionSummaryToolbarContainer.role = 'toolbar';
1581
+ this.#aiCodeCompletionSummaryToolbar.show(this.#aiCodeCompletionSummaryToolbarContainer, undefined, true);
1582
+ }
1583
+
1584
+ #onAiCodeCompletionSuggestionAccepted(citations: Host.AidaClient.Citation[]): void {
1585
+ if (!this.#aiCodeCompletionSummaryToolbar || citations.length === 0) {
1586
+ return;
1587
+ }
1588
+ const citationsUri = citations.map(citation => citation.uri).filter((uri): uri is string => Boolean(uri));
1589
+ this.#aiCodeCompletionSummaryToolbar.updateCitations(citationsUri);
1590
+ }
1591
+
1592
+ #onAiCodeCompletionRequestTriggered(): void {
1593
+ this.#aiCodeCompletionSummaryToolbar?.setLoading(true);
1594
+ }
1595
+
1596
+ #onAiCodeCompletionResponseReceived(): void {
1597
+ this.#aiCodeCompletionSummaryToolbar?.setLoading(false);
1598
+ }
1531
1599
  }
1532
1600
 
1533
1601
  export const enum Events {
@@ -1757,8 +1825,9 @@ export class CSSPropertyPrompt extends UI.TextPrompt.TextPrompt {
1757
1825
  private treeElement: StylePropertyTreeElement;
1758
1826
  private isEditingName: boolean;
1759
1827
  private readonly cssVariables: string[];
1760
- aiCodeCompletionConfig?: TextEditor.AiCodeCompletionProvider.AiCodeCompletionConfig;
1761
1828
  aiCodeCompletionProvider?: StylesAiCodeCompletionProvider.StylesAiCodeCompletionProvider;
1829
+ private activeAiSuggestionInfo?:
1830
+ {citations: Host.AidaClient.Citation[], rpcGlobalId?: Host.AidaClient.RpcGlobalId, sampleId?: number};
1762
1831
 
1763
1832
  #debouncedTriggerAiCodeCompletion = Common.Debouncer.debounce(() => {
1764
1833
  void this.triggerAiCodeCompletion();
@@ -1822,25 +1891,13 @@ export class CSSPropertyPrompt extends UI.TextPrompt.TextPrompt {
1822
1891
  }
1823
1892
  }
1824
1893
 
1825
- const devtoolsLocale = i18n.DevToolsLocale.DevToolsLocale.instance();
1826
- if (AiCodeCompletion.AiCodeCompletion.AiCodeCompletion.isAiCodeCompletionStylesEnabled(devtoolsLocale.locale)) {
1827
- this.aiCodeCompletionConfig = {
1828
- completionContext: {},
1829
- generationContext: {},
1830
- onFeatureEnabled: () => {},
1831
- onFeatureDisabled: () => {},
1832
- onSuggestionAccepted: () => {},
1833
- onRequestTriggered: () => {},
1834
- onResponseReceived: () => {},
1835
- panel: AiCodeCompletion.AiCodeCompletion.ContextFlavor.STYLES,
1836
- getCompletionHint: this.getCompletionHint.bind(this),
1837
- getCurrentText: () => {
1838
- return this.text();
1839
- },
1840
- setAiAutoCompletion: this.setAiAutoCompletion.bind(this),
1841
- };
1842
- this.aiCodeCompletionProvider =
1843
- StylesAiCodeCompletionProvider.StylesAiCodeCompletionProvider.createInstance(this.aiCodeCompletionConfig);
1894
+ const stylesContainer = this.treeElement.stylesContainer();
1895
+ if (stylesContainer instanceof StylesSidebarPane) {
1896
+ this.aiCodeCompletionProvider = stylesContainer.aiCodeCompletionProvider;
1897
+ if (this.aiCodeCompletionProvider) {
1898
+ this.aiCodeCompletionProvider.getCompletionHint = this.getCompletionHint.bind(this);
1899
+ this.aiCodeCompletionProvider.setAiAutoCompletion = this.setAiAutoCompletion.bind(this);
1900
+ }
1844
1901
  }
1845
1902
  }
1846
1903
 
@@ -2192,11 +2249,13 @@ export class CSSPropertyPrompt extends UI.TextPrompt.TextPrompt {
2192
2249
  startTime: number,
2193
2250
  onImpression: (rpcGlobalId: Host.AidaClient.RpcGlobalId, latency: number, sampleId?: number) => void,
2194
2251
  clearCachedRequest: () => void,
2252
+ citations: Host.AidaClient.Citation[],
2195
2253
  rpcGlobalId?: Host.AidaClient.RpcGlobalId,
2196
2254
  sampleId?: number,
2197
2255
  }|null): void {
2198
2256
  if (!args) {
2199
2257
  this.treeElement.section().activeAiSuggestion = undefined;
2258
+ this.activeAiSuggestionInfo = undefined;
2200
2259
  return;
2201
2260
  }
2202
2261
 
@@ -2207,6 +2266,7 @@ export class CSSPropertyPrompt extends UI.TextPrompt.TextPrompt {
2207
2266
  clearCachedRequest: args.clearCachedRequest,
2208
2267
  cssProperty: this.treeElement.property,
2209
2268
  };
2269
+ this.activeAiSuggestionInfo = {citations: args.citations, rpcGlobalId: args.rpcGlobalId, sampleId: args.sampleId};
2210
2270
  const latency = performance.now() - args.startTime;
2211
2271
  if (args.rpcGlobalId) {
2212
2272
  args.onImpression(args.rpcGlobalId, latency, args.sampleId);
@@ -2305,6 +2365,11 @@ export class CSSPropertyPrompt extends UI.TextPrompt.TextPrompt {
2305
2365
 
2306
2366
  async commitAiSuggestion(): Promise<void> {
2307
2367
  await this.treeElement.section().commitActiveAiSuggestion();
2368
+ if (this.activeAiSuggestionInfo) {
2369
+ this.aiCodeCompletionProvider?.onSuggestionAccepted(
2370
+ this.activeAiSuggestionInfo.citations, this.activeAiSuggestionInfo.rpcGlobalId,
2371
+ this.activeAiSuggestionInfo.sampleId);
2372
+ }
2308
2373
  // Clear state and return
2309
2374
  this.setAiAutoCompletion(null);
2310
2375
  }
@@ -47,6 +47,20 @@
47
47
  border-bottom: 1px solid var(--sys-color-divider);
48
48
  }
49
49
 
50
+ .style-panes-wrapper > div:has(+ .ai-code-completion-summary-toolbar-container) {
51
+ border-bottom: 0;
52
+ }
53
+
54
+ .style-panes-wrapper .ai-code-completion-summary-toolbar-container {
55
+ container-type: inline-size;
56
+ flex-shrink: 0;
57
+ overflow: hidden;
58
+ position: fixed;
59
+ bottom: 0;
60
+ background-color: var(--sys-color-cdt-base-container);
61
+ width: 100%;
62
+ }
63
+
50
64
  #elements-content:not(.elements-wrap) > div {
51
65
  display: inline-block;
52
66
  min-width: 100%;
@@ -402,3 +402,24 @@ li.hovered:not(.always-parent) + ol.children:not(.shadow-root) {
402
402
  .ad-provenance-tooltip-content {
403
403
  padding-left: 16px;
404
404
  }
405
+
406
+ .elements-disclosure.elements-tree-truncated {
407
+ /* 1.36 is the line-height, 15px is the min-height */
408
+ max-height: calc(var(--max-rows) * 1.36em + 5px);
409
+ overflow: hidden;
410
+ }
411
+
412
+ .elements-tree-show-all {
413
+ border: none;
414
+ color: var(--sys-color-primary);
415
+ cursor: pointer;
416
+ display: block;
417
+ font-size: 12px;
418
+ padding: 4px 12px;
419
+ text-align: center;
420
+ width: 100%;
421
+ }
422
+
423
+ .elements-tree-show-all.hidden {
424
+ display: none;
425
+ }
@@ -236,13 +236,13 @@ export class NetworkLogViewColumns {
236
236
  const title = columnConfig.title instanceof Function ? columnConfig.title() : columnConfig.title;
237
237
  return {
238
238
  id: columnConfig.id,
239
- title,
239
+ title: title as Common.UIString.LocalizedString,
240
240
  sortable: columnConfig.sortable,
241
241
  align: columnConfig.align,
242
242
  nonSelectable: columnConfig.nonSelectable,
243
243
  weight: columnConfig.weight,
244
244
  allowInSortByEvenWhenHidden: columnConfig.allowInSortByEvenWhenHidden,
245
- } as DataGrid.DataGrid.ColumnDescriptor;
245
+ };
246
246
  }
247
247
 
248
248
  wasShown(): void {
@@ -1251,7 +1251,7 @@ export interface Descriptor {
1251
1251
  hideableGroup: string|null;
1252
1252
  nonSelectable: boolean;
1253
1253
  sortable: boolean;
1254
- align?: string|null;
1254
+ align?: DataGrid.DataGrid.Align|null;
1255
1255
  isResponseHeader: boolean;
1256
1256
  isRequestHeader: boolean;
1257
1257
  sortingFunction: (arg0: NetworkNode, arg1: NetworkNode) => number | undefined;
@@ -182,10 +182,6 @@ export class DetachedElementsProfileHeader extends WritableProfileHeader {
182
182
  this.#heapProfilerModel = heapProfilerModel;
183
183
  }
184
184
 
185
- override createView(dataDisplayDelegate: DataDisplayDelegate): DetachedElementsProfileView {
186
- return new DetachedElementsProfileView(dataDisplayDelegate, this);
187
- }
188
-
189
185
  heapProfilerModel(): SDK.HeapProfilerModel.HeapProfilerModel|null {
190
186
  return this.#heapProfilerModel;
191
187
  }
@@ -487,10 +487,6 @@ export class SamplingHeapProfileHeader extends WritableProfileHeader {
487
487
  };
488
488
  }
489
489
 
490
- override createView(): HeapProfileView {
491
- return new HeapProfileView(this);
492
- }
493
-
494
490
  protocolProfile(): Protocol.HeapProfiler.SamplingHeapProfile {
495
491
  return this.protocolProfileInternal;
496
492
  }
@@ -8,9 +8,7 @@ import type * as SDK from '../../core/sdk/sdk.js';
8
8
  import * as UI from '../../ui/legacy/legacy.js';
9
9
 
10
10
  import type {HeapSnapshotView} from './HeapSnapshotView.js';
11
- import type {ProfileType} from './ProfileHeader.js';
12
11
  import {ProfilesPanel} from './ProfilesPanel.js';
13
- import {instance} from './ProfileTypeRegistry.js';
14
12
 
15
13
  const UIStrings = {
16
14
  /**
@@ -20,18 +18,12 @@ const UIStrings = {
20
18
  } as const;
21
19
  const str_ = i18n.i18n.registerUIStrings('panels/profiler/HeapProfilerPanel.ts', UIStrings);
22
20
  const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
21
+
23
22
  let heapProfilerPanelInstance: HeapProfilerPanel;
24
23
  export class HeapProfilerPanel extends ProfilesPanel implements UI.ContextMenu.Provider<SDK.RemoteObject.RemoteObject>,
25
24
  UI.ActionRegistration.ActionDelegate {
26
25
  constructor() {
27
- const registry = instance;
28
- const profileTypes = [
29
- registry.heapSnapshotProfileType,
30
- registry.trackingHeapSnapshotProfileType,
31
- registry.samplingHeapProfileType,
32
- registry.detachedElementProfileType,
33
- ];
34
- super('heap-profiler', profileTypes as ProfileType[], 'profiler.heap-toggle-recording');
26
+ super('heap-profiler', 'profiler.heap-toggle-recording');
35
27
  }
36
28
 
37
29
  static instance(): HeapProfilerPanel {
@@ -52,7 +44,7 @@ export class HeapProfilerPanel extends ProfilesPanel implements UI.ContextMenu.P
52
44
  }
53
45
  const objectId = object.objectId;
54
46
 
55
- const heapProfiles = instance.heapSnapshotProfileType.getProfiles();
47
+ const heapProfiles = ProfilesPanel.registry.heapSnapshotProfileType.getProfiles();
56
48
  if (!heapProfiles.length) {
57
49
  return;
58
50
  }
@@ -97,8 +89,7 @@ export class HeapProfilerPanel extends ProfilesPanel implements UI.ContextMenu.P
97
89
  }
98
90
 
99
91
  override showObject(snapshotObjectId: string, perspectiveName: string): void {
100
- const registry = instance;
101
- const heapProfiles = registry.heapSnapshotProfileType.getProfiles();
92
+ const heapProfiles = ProfilesPanel.registry.heapSnapshotProfileType.getProfiles();
102
93
  for (let i = 0; i < heapProfiles.length; i++) {
103
94
  const profile = heapProfiles[i];
104
95
  // FIXME: allow to choose snapshot if there are several options.
@@ -45,8 +45,7 @@ import {
45
45
  ProfileHeader,
46
46
  ProfileType,
47
47
  } from './ProfileHeader.js';
48
- import {ProfileSidebarTreeElement} from './ProfileSidebarTreeElement.js';
49
- import {instance} from './ProfileTypeRegistry.js';
48
+ import type {ProfileTypeRegistry} from './ProfileTypeRegistry.js';
50
49
 
51
50
  const UIStrings = {
52
51
  /**
@@ -271,7 +270,7 @@ const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
271
270
  const moduleUIstr_ = i18n.i18n.registerUIStrings('panels/profiler/ModuleUIStrings.ts', ModuleUIStrings.UIStrings);
272
271
  const moduleI18nString = i18n.i18n.getLocalizedString.bind(undefined, moduleUIstr_);
273
272
  export class HeapSnapshotView extends UI.View.SimpleView implements DataDisplayDelegate, UI.SearchableView.Searchable {
274
- searchResults: number[];
273
+ searchResults: number[] = [];
275
274
  profile: HeapProfileHeader;
276
275
  readonly linkifier: Components.Linkifier.Linkifier;
277
276
  readonly parentDataDisplayDelegate: DataDisplayDelegate;
@@ -310,6 +309,7 @@ export class HeapSnapshotView extends UI.View.SimpleView implements DataDisplayD
310
309
  trackingOverviewGrid?: HeapTimelineOverview;
311
310
  currentSearchResultIndex = -1;
312
311
  currentSearch?: HeapSnapshotModel.HeapSnapshotModel.SearchConfig;
312
+ #registry: ProfileTypeRegistry;
313
313
 
314
314
  get currentQuery(): string|undefined {
315
315
  return this.currentSearch?.query;
@@ -320,13 +320,17 @@ export class HeapSnapshotView extends UI.View.SimpleView implements DataDisplayD
320
320
  }
321
321
  }
322
322
 
323
- constructor(dataDisplayDelegate: DataDisplayDelegate, profile: HeapProfileHeader) {
323
+ constructor(
324
+ dataDisplayDelegate: DataDisplayDelegate,
325
+ profile: HeapProfileHeader,
326
+ registry: ProfileTypeRegistry,
327
+ ) {
324
328
  super({
325
329
  title: i18nString(UIStrings.heapSnapshot),
326
330
  viewId: 'heap-snapshot',
327
331
  });
328
332
 
329
- this.searchResults = [];
333
+ this.#registry = registry;
330
334
 
331
335
  this.element.classList.add('heap-snapshot-view');
332
336
  this.profile = profile;
@@ -340,7 +344,7 @@ export class HeapSnapshotView extends UI.View.SimpleView implements DataDisplayD
340
344
  if (isHeapTimeline) {
341
345
  this.createOverview();
342
346
  }
343
- const hasAllocationStacks = instance.trackingHeapSnapshotProfileType.recordAllocationStacksSetting().get();
347
+ const hasAllocationStacks = registry.trackingHeapSnapshotProfileType.recordAllocationStacksSetting().get();
344
348
 
345
349
  this.parentDataDisplayDelegate = dataDisplayDelegate;
346
350
 
@@ -425,7 +429,7 @@ export class HeapSnapshotView extends UI.View.SimpleView implements DataDisplayD
425
429
  this.perspectives = [];
426
430
  this.comparisonPerspective = new ComparisonPerspective();
427
431
  this.perspectives.push(new SummaryPerspective());
428
- if (profile.profileType() !== instance.trackingHeapSnapshotProfileType) {
432
+ if (profile.profileType() !== this.#registry.trackingHeapSnapshotProfileType) {
429
433
  this.perspectives.push(this.comparisonPerspective);
430
434
  }
431
435
  this.perspectives.push(new ContainmentPerspective());
@@ -621,7 +625,7 @@ export class HeapSnapshotView extends UI.View.SimpleView implements DataDisplayD
621
625
 
622
626
  override async toolbarItems(): Promise<UI.Toolbar.ToolbarItem[]> {
623
627
  const result: UI.Toolbar.ToolbarItem[] = [this.perspectiveSelect, this.classNameFilter];
624
- if (this.profile.profileType() !== instance.trackingHeapSnapshotProfileType) {
628
+ if (this.profile.profileType() !== this.#registry.trackingHeapSnapshotProfileType) {
625
629
  result.push(this.baseSelect, this.filterSelect);
626
630
  }
627
631
  result.push(this.selectedSizeText);
@@ -1680,14 +1684,6 @@ export class HeapProfileHeader extends ProfileHeader {
1680
1684
  return await this.snapshotProxy.getLocation(nodeIndex);
1681
1685
  }
1682
1686
 
1683
- override createSidebarTreeElement(dataDisplayDelegate: DataDisplayDelegate): ProfileSidebarTreeElement {
1684
- return new ProfileSidebarTreeElement(dataDisplayDelegate, this, 'heap-snapshot-sidebar-tree-item');
1685
- }
1686
-
1687
- override createView(dataDisplayDelegate: DataDisplayDelegate): HeapSnapshotView {
1688
- return new HeapSnapshotView(dataDisplayDelegate, this);
1689
- }
1690
-
1691
1687
  prepareToLoad(): void {
1692
1688
  console.assert(!this.receiver, 'Already loading');
1693
1689
  this.setupWorker();
@@ -34,17 +34,6 @@ export class ProfileHeader extends Common.ObjectWrapper.ObjectWrapper<EventTypes
34
34
  this.dispatchEventToListeners(Events.UPDATE_STATUS, new StatusUpdate(subtitle, wait));
35
35
  }
36
36
 
37
- /**
38
- * Must be implemented by subclasses.
39
- */
40
- createSidebarTreeElement(_dataDisplayDelegate: DataDisplayDelegate): UI.TreeOutline.TreeElement {
41
- throw new Error('Not implemented.');
42
- }
43
-
44
- createView(_dataDisplayDelegate: DataDisplayDelegate): UI.Widget.Widget {
45
- throw new Error('Not implemented.');
46
- }
47
-
48
37
  removeTempFile(): void {
49
38
  if (this.tempFile) {
50
39
  this.tempFile.remove();
@@ -2,21 +2,13 @@
2
2
  // Use of this source code is governed by a BSD-style license that can be
3
3
  // found in the LICENSE file.
4
4
 
5
- import {DetachedElementsProfileType} from './HeapDetachedElementsView.js';
6
- import {SamplingHeapProfileType} from './HeapProfileView.js';
7
- import {HeapSnapshotProfileType, TrackingHeapSnapshotProfileType} from './HeapSnapshotView.js';
5
+ import type {DetachedElementsProfileType} from './HeapDetachedElementsView.js';
6
+ import type {SamplingHeapProfileType} from './HeapProfileView.js';
7
+ import type {HeapSnapshotProfileType, TrackingHeapSnapshotProfileType} from './HeapSnapshotView.js';
8
8
 
9
- export class ProfileTypeRegistry {
9
+ export interface ProfileTypeRegistry {
10
10
  heapSnapshotProfileType: HeapSnapshotProfileType;
11
11
  samplingHeapProfileType: SamplingHeapProfileType;
12
12
  trackingHeapSnapshotProfileType: TrackingHeapSnapshotProfileType;
13
13
  detachedElementProfileType: DetachedElementsProfileType;
14
- constructor() {
15
- this.heapSnapshotProfileType = new HeapSnapshotProfileType();
16
- this.samplingHeapProfileType = new SamplingHeapProfileType();
17
- this.trackingHeapSnapshotProfileType = new TrackingHeapSnapshotProfileType();
18
- this.detachedElementProfileType = new DetachedElementsProfileType();
19
- }
20
14
  }
21
-
22
- export const instance = new ProfileTypeRegistry();