chrome-devtools-frontend 1.0.1590494 → 1.0.1592129

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 (79) hide show
  1. package/docs/ui_engineering.md +34 -1
  2. package/front_end/core/common/Gzip.ts +17 -2
  3. package/front_end/core/host/AidaClient.ts +38 -15
  4. package/front_end/core/host/DispatchHttpRequestClient.ts +7 -4
  5. package/front_end/core/host/InspectorFrontendHostAPI.ts +2 -0
  6. package/front_end/core/host/UserMetrics.ts +2 -1
  7. package/front_end/core/root/ExperimentNames.ts +1 -0
  8. package/front_end/core/root/Runtime.ts +5 -0
  9. package/front_end/core/sdk/CSSMetadata.ts +18 -0
  10. package/front_end/core/sdk/EmulationModel.ts +6 -1
  11. package/front_end/core/sdk/NetworkManager.ts +49 -2
  12. package/front_end/core/sdk/NetworkRequest.ts +4 -0
  13. package/front_end/core/sdk/RuntimeModel.ts +2 -1
  14. package/front_end/core/sdk/sdk-meta.ts +26 -0
  15. package/front_end/entrypoints/inspector_main/RenderingOptions.ts +34 -5
  16. package/front_end/entrypoints/main/MainImpl.ts +8 -0
  17. package/front_end/generated/InspectorBackendCommands.ts +1 -0
  18. package/front_end/generated/protocol-mapping.d.ts +10 -0
  19. package/front_end/generated/protocol-proxy-api.d.ts +8 -0
  20. package/front_end/generated/protocol.ts +6 -2
  21. package/front_end/models/ai_assistance/AiConversation.ts +9 -0
  22. package/front_end/models/ai_assistance/AiHistoryStorage.ts +1 -0
  23. package/front_end/models/ai_assistance/agents/AiAgent.ts +6 -1
  24. package/front_end/models/ai_assistance/agents/BreakpointDebuggerAgent.ts +722 -0
  25. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +1 -1
  26. package/front_end/models/ai_assistance/ai_assistance.ts +2 -0
  27. package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.snapshot.txt +12 -12
  28. package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.ts +7 -7
  29. package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.snapshot.txt +7 -7
  30. package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.ts +1 -1
  31. package/front_end/models/greendev/Prototypes.ts +7 -1
  32. package/front_end/models/javascript_metadata/NativeFunctions.js +5 -1
  33. package/front_end/models/trace/handlers/NetworkRequestsHandler.ts +3 -3
  34. package/front_end/models/trace/helpers/Network.ts +1 -1
  35. package/front_end/models/trace/insights/NetworkDependencyTree.ts +1 -1
  36. package/front_end/models/trace/insights/RenderBlocking.ts +5 -5
  37. package/front_end/models/trace/lantern/metrics/FirstContentfulPaint.ts +6 -6
  38. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +63 -0
  39. package/front_end/panels/ai_assistance/README.md +14 -0
  40. package/front_end/panels/ai_assistance/components/ChatInput.ts +1 -4
  41. package/front_end/panels/ai_assistance/components/ChatMessage.ts +45 -27
  42. package/front_end/panels/ai_assistance/components/chatInput.css +0 -8
  43. package/front_end/panels/ai_assistance/components/chatMessage.css +6 -0
  44. package/front_end/panels/browser_debugger/CategorizedBreakpointsSidebarPane.ts +25 -46
  45. package/front_end/panels/common/AiCodeGenerationTeaser.ts +9 -4
  46. package/front_end/panels/console/ConsoleViewMessage.ts +100 -4
  47. package/front_end/panels/elements/ComputedStyleWidget.ts +46 -18
  48. package/front_end/panels/elements/ElementsPanel.ts +2 -2
  49. package/front_end/panels/elements/StyleEditorWidget.ts +10 -2
  50. package/front_end/panels/elements/StylePropertyTreeElement.ts +1 -1
  51. package/front_end/panels/elements/StylesContainer.ts +2 -0
  52. package/front_end/panels/elements/StylesSidebarPane.ts +8 -0
  53. package/front_end/panels/network/NetworkDataGridNode.ts +1 -1
  54. package/front_end/panels/network/NetworkLogViewColumns.ts +1 -1
  55. package/front_end/panels/network/RequestPayloadView.ts +7 -6
  56. package/front_end/panels/network/RequestTimingView.ts +3 -3
  57. package/front_end/panels/search/SearchResultsPane.ts +2 -1
  58. package/front_end/panels/settings/SettingsScreen.ts +3 -2
  59. package/front_end/panels/settings/WorkspaceSettingsTab.ts +1 -1
  60. package/front_end/panels/sources/BreakpointsView.ts +1 -1
  61. package/front_end/panels/sources/CallStackSidebarPane.ts +1 -1
  62. package/front_end/panels/timeline/NetworkTrackAppender.ts +1 -1
  63. package/front_end/panels/timeline/components/IgnoreListSetting.ts +0 -1
  64. package/front_end/panels/timeline/components/NetworkRequestDetails.ts +4 -4
  65. package/front_end/panels/timeline/components/NetworkRequestTooltip.ts +2 -2
  66. package/front_end/panels/timeline/components/SidebarAnnotationsTab.ts +4 -4
  67. package/front_end/third_party/chromium/README.chromium +4 -2
  68. package/front_end/third_party/lighthouse/lighthouse-dt-bundle.js +5 -1
  69. package/front_end/third_party/lighthouse/locales/en-GB.json +2 -2
  70. package/front_end/third_party/lighthouse/locales/en-US.json +2 -2
  71. package/front_end/ui/components/text_editor/AiCodeGenerationProvider.ts +1 -1
  72. package/front_end/ui/legacy/Treeoutline.ts +39 -0
  73. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +31 -8
  74. package/front_end/ui/legacy/components/object_ui/RemoteObjectPreviewFormatter.ts +10 -3
  75. package/front_end/ui/legacy/components/source_frame/XMLView.ts +20 -5
  76. package/front_end/ui/visual_logging/Debugging.ts +51 -34
  77. package/front_end/ui/visual_logging/KnownContextValues.ts +7 -1
  78. package/front_end/ui/visual_logging/LoggingEvents.ts +5 -2
  79. package/package.json +1 -1
@@ -386,12 +386,15 @@ function renderTextAsMarkdown(text: string, markdownRenderer: MarkdownLitRendere
386
386
  // clang-format on
387
387
  }
388
388
 
389
+ function titleForStep(step: Step): string {
390
+ return step.title ?? `${lockedString(UIStringsNotTranslate.investigating)}…`;
391
+ }
392
+
389
393
  function renderTitle(step: Step): Lit.LitTemplate {
390
394
  const paused =
391
395
  step.sideEffect ? html`<span class="paused">${lockedString(UIStringsNotTranslate.paused)}: </span>` : Lit.nothing;
392
- const actionTitle = step.title ?? `${lockedString(UIStringsNotTranslate.investigating)}…`;
393
396
 
394
- return html`<span class="title">${paused}${actionTitle}</span>`;
397
+ return html`<span class="title">${paused}${titleForStep(step)}</span>`;
395
398
  }
396
399
 
397
400
  function renderStepCode(step: Step): Lit.LitTemplate {
@@ -470,6 +473,41 @@ function renderStepDetails({
470
473
  // clang-format on
471
474
  }
472
475
 
476
+ function renderWalkthroughSidebarButton(
477
+ input: ChatMessageViewInput,
478
+ lastStep: Step,
479
+ ): Lit.LitTemplate {
480
+ const {message, walkthrough} = input;
481
+ if (walkthrough.isInlined) {
482
+ return Lit.nothing;
483
+ }
484
+ const title = input.isLoading ? titleForStep(lastStep) : lockedString(UIStringsNotTranslate.showThinking);
485
+
486
+ // clang-format off
487
+ return html`
488
+ <div class="walkthrough-toggle-container">
489
+ ${input.isLoading ? html`<devtools-spinner></devtools-spinner>` : Lit.nothing}
490
+ <devtools-button
491
+ .variant=${Buttons.Button.Variant.OUTLINED}
492
+ .size=${Buttons.Button.Size.SMALL}
493
+ .title=${lastStep.isLoading ? titleForStep(lastStep) : lockedString(UIStringsNotTranslate.showThinking)}
494
+ .jslogContext=${walkthrough.isExpanded ? 'ai-hide-walkthrough-sidebar' : 'ai-show-walkthrough-sidebar'}
495
+ data-show-walkthrough
496
+ @click=${() => {
497
+ if(walkthrough.isExpanded) {
498
+ walkthrough.onToggle(false);
499
+ } else {
500
+ // Can't just toggle the visibility here; we need to ensure we
501
+ // update the state with this message as the user could have had
502
+ // the walkthrough open with an alternative message.
503
+ walkthrough.onOpen(message as ModelChatMessage);
504
+ }
505
+ }}
506
+ >${title}</devtools-button>
507
+ </div>
508
+ `;
509
+ // clang-format on
510
+ }
473
511
  /**
474
512
  * Responsible for rendering the AI Walkthrough UI. This can take different
475
513
  * shapes and involve different parts depending on if the walkthrough is
@@ -477,36 +515,16 @@ function renderStepDetails({
477
515
  * view them.
478
516
  */
479
517
  function renderWalkthroughUI(input: ChatMessageViewInput, steps: Step[]): Lit.LitTemplate {
480
- if (steps.length === 0) {
518
+ const lastStep = steps.at(-1);
519
+ if (!lastStep) {
520
+ // No steps = no walkthrough UI in the chat view.
481
521
  return Lit.nothing;
482
522
  }
483
-
484
523
  const sideEffectSteps = steps.filter(s => s.sideEffect);
485
-
486
524
  // If the walkthrough is in the sidebar, we render a button into the
487
525
  // ChatView to open it.
488
- // clang-format off
489
- const openWalkThroughSidebarButton = !input.walkthrough.isInlined ? html`
490
- <div class="walkthrough-toggle-container">
491
- <devtools-button
492
- .variant=${Buttons.Button.Variant.OUTLINED}
493
- .size=${Buttons.Button.Size.SMALL}
494
- .title=${lockedString(UIStringsNotTranslate.showThinking)}
495
- .jslogContext=${'ai-show-walkthrough'}
496
- @click=${() => {
497
- if(input.walkthrough.isExpanded) {
498
- input.walkthrough.onToggle(false);
499
- } else {
500
- // Can't just toggle the visibility here; we need to ensure we
501
- // update the state with this message as the user could have had
502
- // the walkthrough open with an alternative message.
503
- input.walkthrough.onOpen(input.message as ModelChatMessage);
504
- }
505
- }}
506
- >${lockedString(UIStringsNotTranslate.showThinking)}</devtools-button>
507
- </div>
508
- ` : Lit.nothing;
509
- // clang-format on
526
+ const openWalkThroughSidebarButton =
527
+ !input.walkthrough.isInlined ? renderWalkthroughSidebarButton(input, lastStep) : Lit.nothing;
510
528
 
511
529
  // If there are side-effect steps, and the walkthrough is not open, we render
512
530
  // those inline so that the user can see them and approve them.
@@ -248,14 +248,6 @@
248
248
  vertical-align: middle;
249
249
  }
250
250
 
251
- &.has-picker-behavior {
252
- overflow: visible;
253
-
254
- .title {
255
- overflow: visible;
256
- }
257
- }
258
-
259
251
  &:focus-visible {
260
252
  outline: 2px solid var(--sys-color-state-focus-ring);
261
253
  }
@@ -348,4 +348,10 @@
348
348
  display: flex;
349
349
  gap: var(--sys-size-4);
350
350
  }
351
+
352
+ .walkthrough-toggle-container {
353
+ display: flex;
354
+ gap: var(--sys-size-4);
355
+ align-items: center;
356
+ }
351
357
  }
@@ -127,10 +127,8 @@ const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
127
127
  const i18nLazyString = i18n.i18n.getLazilyComputedLocalizedString.bind(undefined, str_);
128
128
 
129
129
  const {html, render} = Lit;
130
+ const {ifExpanded} = UI.TreeOutline;
130
131
 
131
- interface ViewOutput {
132
- userExpandedCategories: Set<SDK.CategorizedBreakpoint.Category>;
133
- }
134
132
  interface ViewInput {
135
133
  onFilterChanged: (filterText: string|null) => void;
136
134
  onBreakpointChange: (breakpoint: SDK.CategorizedBreakpoint.CategorizedBreakpoint, enabled: boolean) => void;
@@ -139,14 +137,14 @@ interface ViewInput {
139
137
  onSpaceKeyDown: () => void;
140
138
 
141
139
  filterText: string|null;
142
- userExpandedCategories: Set<SDK.CategorizedBreakpoint.Category>;
140
+ onExpandCollapse: () => void;
143
141
  highlightedItem: SDK.CategorizedBreakpoint.CategorizedBreakpoint|null;
144
142
  categories: Map<SDK.CategorizedBreakpoint.Category, SDK.CategorizedBreakpoint.CategorizedBreakpoint[]>;
145
143
  sortedCategoryNames: SDK.CategorizedBreakpoint.Category[];
146
144
  }
147
145
 
148
146
  export type View = typeof DEFAULT_VIEW;
149
- export const DEFAULT_VIEW = (input: ViewInput, output: ViewOutput, target: HTMLElement): void => {
147
+ export const DEFAULT_VIEW = (input: ViewInput, output: undefined, target: HTMLElement): void => {
150
148
  const shouldExpandCategory = (breakpoints: SDK.CategorizedBreakpoint.CategorizedBreakpoint[]): boolean =>
151
149
  Boolean(input.filterText) || (input.highlightedItem && breakpoints.includes(input.highlightedItem)) ||
152
150
  breakpoints.some(breakpoint => breakpoint.enabled());
@@ -193,23 +191,6 @@ export const DEFAULT_VIEW = (input: ViewInput, output: ViewOutput, target: HTMLE
193
191
  'source-code': true,
194
192
  'breakpoint-hit': input.highlightedItem === breakpoint,
195
193
  });
196
- const onExpand =
197
- (category: SDK.CategorizedBreakpoint.Category, {detail: {expanded}}: UI.TreeOutline.TreeViewElement.ExpandEvent):
198
- void => {
199
- const breakpoints = category && input.categories.get(category);
200
- if (!breakpoints) {
201
- return;
202
- }
203
- if (shouldExpandCategory(breakpoints)) {
204
- // Basically ignore expand/collapse when the category is expanded by default.
205
- return;
206
- }
207
- if (expanded) {
208
- output.userExpandedCategories.add(category);
209
- } else {
210
- output.userExpandedCategories.delete(category);
211
- }
212
- };
213
194
 
214
195
  const onKeyDown = (e: KeyboardEvent): void => {
215
196
  if (e.key === ' ') {
@@ -232,13 +213,13 @@ export const DEFAULT_VIEW = (input: ViewInput, output: ViewOutput, target: HTMLE
232
213
  <ul role="tree">
233
214
  ${filteredCategories.map(([category, breakpoints]) => html`
234
215
  <li @select=${() => input.onItemSelected(category)}
235
- @expand=${(e: UI.TreeOutline.TreeViewElement.ExpandEvent) => onExpand(category, e)}
216
+ @expand=${() => input.onExpandCollapse()}
236
217
  role="treeitem"
237
218
  jslog-context=${category}
238
219
  aria-checked=${breakpoints.some(breakpoint => breakpoint.enabled())
239
220
  ? breakpoints.some(breakpoint => !breakpoint.enabled()) ? 'mixed' : true
240
221
  : false}
241
- ?open=${shouldExpandCategory(breakpoints) || input.userExpandedCategories.has(category)}>
222
+ ?open=${shouldExpandCategory(breakpoints)}>
242
223
  <style>${categorizedBreakpointsSidebarPaneStyles}</style>
243
224
  <devtools-checkbox
244
225
  class="small"
@@ -250,22 +231,22 @@ export const DEFAULT_VIEW = (input: ViewInput, output: ViewOutput, target: HTMLE
250
231
  @change=${(e: Event) => onCheckboxClicked(e, category)}
251
232
  >${getLocalizedCategory(category)}</devtools-checkbox>
252
233
  <ul role="group">
253
- ${breakpoints.map(breakpoint => html`
254
- <li @select=${() => input.onItemSelected(breakpoint)}
255
- role="treeitem"
256
- aria-checked=${breakpoint.enabled()}
257
- jslog-context=${Platform.StringUtilities.toKebabCase(breakpoint.name)}>
258
- <div ?hidden=${breakpoint !== input.highlightedItem} class="breakpoint-hit-marker"></div>
259
- <devtools-checkbox
260
- class=${classes(breakpoint)}
261
- tabIndex=-1
262
- title=${Sources.CategorizedBreakpointL10n.getLocalizedBreakpointName(breakpoint.name)}
263
- ?checked=${breakpoint.enabled()}
264
- aria-description=${breakpoint === input.highlightedItem ? i18nString(UIStrings.breakpointHit)
265
- : Lit.nothing}
266
- @change=${(e: Event) => onCheckboxClicked(e, breakpoint)}
267
- >${Sources.CategorizedBreakpointL10n.getLocalizedBreakpointName(breakpoint.name)}</devtools-checkbox>
268
- </li>`)}
234
+ ${ifExpanded(html`${breakpoints.map(breakpoint => html`
235
+ <li @select=${() => input.onItemSelected(breakpoint)}
236
+ role="treeitem"
237
+ aria-checked=${breakpoint.enabled()}
238
+ jslog-context=${Platform.StringUtilities.toKebabCase(breakpoint.name)}>
239
+ <div ?hidden=${breakpoint !== input.highlightedItem} class="breakpoint-hit-marker"></div>
240
+ <devtools-checkbox
241
+ class=${classes(breakpoint)}
242
+ tabIndex=-1
243
+ title=${Sources.CategorizedBreakpointL10n.getLocalizedBreakpointName(breakpoint.name)}
244
+ ?checked=${breakpoint.enabled()}
245
+ aria-description=${breakpoint === input.highlightedItem ? i18nString(UIStrings.breakpointHit)
246
+ : Lit.nothing}
247
+ @change=${(e: Event) => onCheckboxClicked(e, breakpoint)}
248
+ >${Sources.CategorizedBreakpointL10n.getLocalizedBreakpointName(breakpoint.name)}</devtools-checkbox>
249
+ </li>`)}`)}
269
250
  </ul>
270
251
  </li>`)}
271
252
  </ul>`}>
@@ -282,7 +263,6 @@ export abstract class CategorizedBreakpointsSidebarPane extends UI.Widget.VBox {
282
263
  #highlightedItem: SDK.CategorizedBreakpoint.CategorizedBreakpoint|null = null;
283
264
  #filterText: string|null = null;
284
265
  #view: View;
285
- #userExpandedCategories = new Set<SDK.CategorizedBreakpoint.Category>();
286
266
  #selectedItem: SDK.CategorizedBreakpoint.Category|SDK.CategorizedBreakpoint.CategorizedBreakpoint|null = null;
287
267
  constructor(
288
268
  breakpoints: SDK.CategorizedBreakpoint.CategorizedBreakpoint[], jslog: string, viewId: string,
@@ -375,12 +355,11 @@ export abstract class CategorizedBreakpointsSidebarPane extends UI.Widget.VBox {
375
355
  sortedCategoryNames: this.#sortedCategories,
376
356
  categories: this.categories,
377
357
  highlightedItem: this.#highlightedItem,
378
- userExpandedCategories: this.#userExpandedCategories,
379
- };
380
- const output: ViewOutput = {
381
- userExpandedCategories: this.#userExpandedCategories,
358
+ onExpandCollapse: () => {
359
+ this.requestUpdate();
360
+ },
382
361
  };
383
- this.#view(input, output, this.contentElement);
362
+ this.#view(input, undefined, this.contentElement);
384
363
  }
385
364
  }
386
365
 
@@ -56,6 +56,11 @@ const UIStringsNotTranslate = {
56
56
  * @description Text for teaser for discoverability.
57
57
  */
58
58
  writeACommentToGenerateCode: 'Write a comment to generate code',
59
+ /**
60
+ * @description Text for teaser for discoverability.
61
+ */
62
+ writeACommentToGenerateCodeInConsole:
63
+ 'Write a comment to generate code. Try typing: \'// add red borders to all the divs\'.',
59
64
  /**
60
65
  * @description Text for teaser when suggestion has been generated.
61
66
  */
@@ -257,9 +262,10 @@ export const DEFAULT_VIEW: View = (input, output, target) => {
257
262
  break;
258
263
  }
259
264
  const newBadge = UI.UIUtils.maybeCreateNewBadge(PROMOTION_ID);
260
- teaserLabel = newBadge ?
261
- html`${lockedString(UIStringsNotTranslate.writeACommentToGenerateCode)}&nbsp;${newBadge}` :
262
- nothing;
265
+ const teaserText = input.panel === AiCodeCompletion.AiCodeCompletion.ContextFlavor.CONSOLE ?
266
+ lockedString(UIStringsNotTranslate.writeACommentToGenerateCodeInConsole) :
267
+ lockedString(UIStringsNotTranslate.writeACommentToGenerateCode);
268
+ teaserLabel = newBadge ? html`${teaserText}&nbsp;${newBadge}` : nothing;
263
269
  break;
264
270
  }
265
271
 
@@ -310,7 +316,6 @@ export const DEFAULT_VIEW: View = (input, output, target) => {
310
316
  // clang-format on
311
317
  };
312
318
 
313
- // TODO(b/448063927): Add "Dont show again" for discovery teaser.
314
319
  export class AiCodeGenerationTeaser extends UI.Widget.Widget {
315
320
  readonly #view: View;
316
321
  #viewOutput: ViewOutput = {};
@@ -42,6 +42,8 @@ import * as SDK from '../../core/sdk/sdk.js';
42
42
  import * as Protocol from '../../generated/protocol.js';
43
43
  import * as AiAssistanceModel from '../../models/ai_assistance/ai_assistance.js';
44
44
  import * as Bindings from '../../models/bindings/bindings.js';
45
+ import * as Breakpoints from '../../models/breakpoints/breakpoints.js';
46
+ import * as Greendev from '../../models/greendev/greendev.js';
45
47
  import type * as IssuesManager from '../../models/issues_manager/issues_manager.js';
46
48
  import * as Logs from '../../models/logs/logs.js';
47
49
  import * as TextUtils from '../../models/text_utils/text_utils.js';
@@ -59,6 +61,7 @@ import * as Components from '../../ui/legacy/components/utils/utils.js';
59
61
  import * as UI from '../../ui/legacy/legacy.js';
60
62
  import {render} from '../../ui/lit/lit.js';
61
63
  import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
64
+ import * as AiAssistancePanel from '../ai_assistance/ai_assistance.js';
62
65
 
63
66
  import {format, updateStyle} from './ConsoleFormat.js';
64
67
  import {ConsoleInsightTeaser} from './ConsoleInsightTeaser.js';
@@ -864,11 +867,17 @@ export class ConsoleViewMessage implements ConsoleViewportElement {
864
867
  private formatParameterAsObject(obj: SDK.RemoteObject.RemoteObject, includePreview?: boolean): HTMLElement {
865
868
  const titleElement = document.createElement('span');
866
869
  titleElement.classList.add('console-object');
870
+ const renderPreview = (includeNullOrUndefined: boolean): void => {
871
+ if (obj.preview) {
872
+ titleElement.classList.add('console-object-preview');
873
+ /* eslint-disable-next-line @devtools/no-lit-render-outside-of-view */
874
+ render(this.previewFormatter.renderObjectPreview(obj.preview, includeNullOrUndefined), titleElement);
875
+ ObjectUI.ObjectPropertiesSection.ObjectPropertiesSection.appendMemoryIcon(titleElement, obj);
876
+ }
877
+ };
878
+
867
879
  if (includePreview && obj.preview) {
868
- titleElement.classList.add('console-object-preview');
869
- /* eslint-disable-next-line @devtools/no-lit-render-outside-of-view */
870
- render(this.previewFormatter.renderObjectPreview(obj.preview), titleElement);
871
- ObjectUI.ObjectPropertiesSection.ObjectPropertiesSection.appendMemoryIcon(titleElement, obj);
880
+ renderPreview(true);
872
881
  } else if (obj.type === 'function') {
873
882
  const functionElement = titleElement.createChild('span');
874
883
  void ObjectUI.ObjectPropertiesSection.ObjectPropertiesSection.formatObjectAsFunction(obj, functionElement, false);
@@ -898,6 +907,9 @@ export class ConsoleViewMessage implements ConsoleViewportElement {
898
907
  section.addEventListener(UI.TreeOutline.Events.ElementAttached, this.messageResized);
899
908
  section.addEventListener(UI.TreeOutline.Events.ElementExpanded, this.messageResized);
900
909
  section.addEventListener(UI.TreeOutline.Events.ElementCollapsed, this.messageResized);
910
+ section.root.addEventListener(
911
+ ObjectUI.ObjectPropertiesSection.ObjectTreeNodeBase.Events.FILTER_CHANGED,
912
+ () => renderPreview(section.root.includeNullOrUndefinedValues));
901
913
  return section.element;
902
914
  }
903
915
 
@@ -1496,6 +1508,11 @@ export class ConsoleViewMessage implements ConsoleViewportElement {
1496
1508
  this.consoleRowWrapper.append(this.#createHoverButton());
1497
1509
  }
1498
1510
 
1511
+ const breakpointAgentEnabled = Greendev.Prototypes.instance().isEnabled('breakpointDebuggerAgent');
1512
+ if (breakpointAgentEnabled && this.message.level === Protocol.Log.LogEntryLevel.Error) {
1513
+ this.consoleRowWrapper.append(this.#createBreakpointButton());
1514
+ }
1515
+
1499
1516
  if (this.repeatCountInternal > 1) {
1500
1517
  this.showRepeatCountElement();
1501
1518
  }
@@ -1586,6 +1603,85 @@ export class ConsoleViewMessage implements ConsoleViewportElement {
1586
1603
  return button;
1587
1604
  }
1588
1605
 
1606
+ #createBreakpointButton(): HTMLButtonElement {
1607
+ const button = document.createElement('button');
1608
+
1609
+ const icon = new Icon();
1610
+ icon.name = 'bug';
1611
+ icon.style.color = 'var(--devtools-icon-color)';
1612
+ icon.classList.add('medium');
1613
+ button.append(icon);
1614
+
1615
+ const label = document.createElement('div');
1616
+ label.classList.add('button-label');
1617
+ const text = document.createElement('div');
1618
+ text.innerText = 'Debug with breakpoint AI';
1619
+ label.append(text);
1620
+ button.append(label);
1621
+ button.classList.add('hover-button');
1622
+ // Offset the button to the left of the existing one (24px width + 6px right + gap)
1623
+ if (this.shouldShowInsights()) {
1624
+ button.style.right = '36px';
1625
+ }
1626
+ button.ariaLabel = 'Debug with breakpoint AI';
1627
+ button.tabIndex = 0;
1628
+
1629
+ button.onclick = async (event: Event) => {
1630
+ event.stopPropagation();
1631
+ const runtimeModel = this.message.runtimeModel();
1632
+ if (!runtimeModel) {
1633
+ return;
1634
+ }
1635
+ const debuggerModel = runtimeModel.debuggerModel();
1636
+ const debuggerWorkspaceBinding = Bindings.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance();
1637
+ let uiLocation: Workspace.UISourceCode.UILocation|null = null;
1638
+
1639
+ // 1. Try stack trace latest called line
1640
+ if (this.message.stackTrace?.callFrames.length) {
1641
+ const callFrame = this.message.stackTrace.callFrames[0];
1642
+ if (callFrame.scriptId) {
1643
+ const script = debuggerModel.scriptForId(callFrame.scriptId);
1644
+ if (script) {
1645
+ const rawLocation = new SDK.DebuggerModel.Location(
1646
+ debuggerModel, callFrame.scriptId, callFrame.lineNumber, callFrame.columnNumber);
1647
+ uiLocation = await debuggerWorkspaceBinding.rawLocationToUILocation(rawLocation);
1648
+ }
1649
+ }
1650
+ }
1651
+
1652
+ // 2. Try scriptId on message
1653
+ if (!uiLocation && this.message.scriptId) {
1654
+ const script = debuggerModel.scriptForId(this.message.scriptId);
1655
+ if (script) {
1656
+ const rawLocation = new SDK.DebuggerModel.Location(
1657
+ debuggerModel, this.message.scriptId, this.message.line, this.message.column);
1658
+ uiLocation = await debuggerWorkspaceBinding.rawLocationToUILocation(rawLocation);
1659
+ }
1660
+ }
1661
+
1662
+ // 3. Try URL
1663
+ if (!uiLocation && this.message.url) {
1664
+ const uiSourceCode = Workspace.Workspace.WorkspaceImpl.instance().uiSourceCodeForURL(this.message.url);
1665
+ if (uiSourceCode) {
1666
+ uiLocation = uiSourceCode.uiLocation(this.message.line, this.message.column);
1667
+ }
1668
+ }
1669
+
1670
+ if (uiLocation) {
1671
+ await Common.Revealer.reveal(uiLocation);
1672
+ const breakpointManager = Breakpoints.BreakpointManager.BreakpointManager.instance();
1673
+ await breakpointManager.setBreakpoint(
1674
+ uiLocation.uiSourceCode, uiLocation.lineNumber, uiLocation.columnNumber,
1675
+ Breakpoints.BreakpointManager.EMPTY_BREAKPOINT_CONDITION, /* enabled */ true,
1676
+ /* isLogpoint */ false, Breakpoints.BreakpointManager.BreakpointOrigin.OTHER);
1677
+ const aiPanel = await AiAssistancePanel.AiAssistancePanel.instance();
1678
+ void aiPanel.handleBreakpointConversation(uiLocation);
1679
+ }
1680
+ };
1681
+
1682
+ return button;
1683
+ }
1684
+
1589
1685
  private shouldRenderAsWarning(): boolean {
1590
1686
  return (this.message.level === Protocol.Log.LogEntryLevel.Verbose ||
1591
1687
  this.message.level === Protocol.Log.LogEntryLevel.Info) &&
@@ -299,7 +299,7 @@ export class ComputedStyleWidget extends UI.Widget.VBox {
299
299
  #matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles|null = null;
300
300
  private readonly showInheritedComputedStylePropertiesSetting: Common.Settings.Setting<boolean>;
301
301
  private readonly groupComputedStylesSetting: Common.Settings.Setting<boolean>;
302
- private filterRegex: RegExp|null;
302
+ private filterRegex: RegExp|null = null;
303
303
  private readonly linkifier: Components.Linkifier.Linkifier;
304
304
  private readonly imagePreviewPopover: ImagePreviewPopover;
305
305
  /**
@@ -324,9 +324,16 @@ export class ComputedStyleWidget extends UI.Widget.VBox {
324
324
  #computedStylesTree = new TreeOutline.TreeOutline.TreeOutline<ComputedStyleData>();
325
325
  #treeData?: TreeOutline.TreeOutline.TreeOutlineData<ComputedStyleData>;
326
326
  readonly #view: View;
327
+
328
+ /**
329
+ * TODO(b/407751272): the state here is confusing (3 instance variables relating to filtering).
330
+ * There is also a bug where the Toolbar Input's regex flag cannot be
331
+ * controlled, so if you set a regex filter here, the toolbar might not
332
+ * reflect it.
333
+ */
327
334
  #filterText = '';
328
- #isRegex = false;
329
- #includeToolbar = true;
335
+ #filterIsRegex = false;
336
+ #allowUserControl = true;
330
337
 
331
338
  constructor() {
332
339
  super({useShadowDom: true});
@@ -361,12 +368,31 @@ export class ComputedStyleWidget extends UI.Widget.VBox {
361
368
  this.#computedStylesTree.classList.toggle('computed-narrow', isNarrow);
362
369
  }
363
370
 
364
- get includeToolbar(): boolean {
365
- return this.#includeToolbar;
371
+ get filterText(): string {
372
+ return this.#filterText;
373
+ }
374
+
375
+ get filterIsRegex(): boolean {
376
+ return this.#filterIsRegex;
377
+ }
378
+
379
+ set filterText(newFilter: RegExp|string) {
380
+ if (typeof newFilter === 'string') {
381
+ this.#filterText = newFilter;
382
+ this.#filterIsRegex = false;
383
+ } else {
384
+ this.#filterText = newFilter.source;
385
+ this.#filterIsRegex = true;
386
+ }
387
+ this.requestUpdate();
388
+ }
389
+
390
+ get allowUserControl(): boolean {
391
+ return this.#allowUserControl;
366
392
  }
367
393
 
368
- set includeToolbar(x: boolean) {
369
- this.#includeToolbar = x;
394
+ set allowUserControl(inc: boolean) {
395
+ this.#allowUserControl = inc;
370
396
  this.requestUpdate();
371
397
  }
372
398
 
@@ -377,7 +403,7 @@ export class ComputedStyleWidget extends UI.Widget.VBox {
377
403
  this.#view(
378
404
  {
379
405
  computedStylesTree: this.#computedStylesTree,
380
- includeToolbar: this.#includeToolbar,
406
+ includeToolbar: this.#allowUserControl,
381
407
  hasMatches,
382
408
  showInheritedComputedStylePropertiesSetting: this.showInheritedComputedStylePropertiesSetting,
383
409
  groupComputedStylesSetting: this.groupComputedStylesSetting,
@@ -415,6 +441,14 @@ export class ComputedStyleWidget extends UI.Widget.VBox {
415
441
  this.requestUpdate();
416
442
  }
417
443
 
444
+ #shouldGroupStyles(): boolean {
445
+ return this.#allowUserControl && this.groupComputedStylesSetting.get();
446
+ }
447
+
448
+ #shouldShowAllStyles(): boolean {
449
+ return this.#allowUserControl && this.showInheritedComputedStylePropertiesSetting.get();
450
+ }
451
+
418
452
  override async performUpdate(): Promise<void> {
419
453
  const nodeStyles = this.#nodeStyle;
420
454
  const matchedStyles = this.#matchedStyles;
@@ -422,8 +456,7 @@ export class ComputedStyleWidget extends UI.Widget.VBox {
422
456
  this.#updateView({hasMatches: false});
423
457
  return;
424
458
  }
425
- const shouldGroupComputedStyles = this.groupComputedStylesSetting.get();
426
- if (shouldGroupComputedStyles) {
459
+ if (this.#shouldGroupStyles()) {
427
460
  await this.rebuildGroupedList(nodeStyles, matchedStyles);
428
461
  } else {
429
462
  await this.rebuildAlphabeticalList(nodeStyles, matchedStyles);
@@ -446,7 +479,7 @@ export class ComputedStyleWidget extends UI.Widget.VBox {
446
479
  const node = nodeStyle.node;
447
480
  const propertyTraces = this.computePropertyTraces(matchedStyles);
448
481
  const nonInheritedProperties = this.computeNonInheritedProperties(matchedStyles);
449
- const showInherited = this.showInheritedComputedStylePropertiesSetting.get();
482
+ const showInherited = this.#shouldShowAllStyles();
450
483
  const tree: Array<TreeOutline.TreeOutlineUtils.TreeNode<ComputedStyleData>> = [];
451
484
  for (const propertyName of uniqueProperties) {
452
485
  const propertyValue = nodeStyle.computedStyle.get(propertyName) || '';
@@ -668,7 +701,7 @@ export class ComputedStyleWidget extends UI.Widget.VBox {
668
701
  if (!text) {
669
702
  return null;
670
703
  }
671
- if (this.#isRegex) {
704
+ if (this.#filterIsRegex) {
672
705
  try {
673
706
  return new RegExp(text, 'i');
674
707
  } catch {
@@ -679,7 +712,7 @@ export class ComputedStyleWidget extends UI.Widget.VBox {
679
712
  }
680
713
 
681
714
  private async onRegexToggled(): Promise<void> {
682
- this.#isRegex = !this.#isRegex;
715
+ this.#filterIsRegex = !this.#filterIsRegex;
683
716
  await this.filterComputedStyles(this.#buildFilterRegex(this.#filterText));
684
717
  }
685
718
 
@@ -701,11 +734,6 @@ export class ComputedStyleWidget extends UI.Widget.VBox {
701
734
  return this.filterAlphabeticalList();
702
735
  }
703
736
 
704
- setFilterInput(text: string): void {
705
- this.#filterText = text;
706
- this.requestUpdate();
707
- }
708
-
709
737
  private nodeFilter(node: TreeOutline.TreeOutlineUtils.TreeNode<ComputedStyleData>): boolean {
710
738
  const regex = this.filterRegex;
711
739
  const data = node.treeNodeData;
@@ -1030,7 +1030,7 @@ export class ElementsPanel extends UI.Panel.Panel implements UI.SearchableView.S
1030
1030
  }
1031
1031
 
1032
1032
  if (showPanel) {
1033
- await UI.ViewManager.ViewManager.instance().showView('elements', false, !focus);
1033
+ await UI.ViewManager.ViewManager.instance().showView('elements', false, !focusNode);
1034
1034
  }
1035
1035
  this.selectDOMNode(node, focusNode);
1036
1036
  delete this.omitDefaultSelection;
@@ -1048,7 +1048,7 @@ export class ElementsPanel extends UI.Panel.Panel implements UI.SearchableView.S
1048
1048
  this.omitDefaultSelection = true;
1049
1049
 
1050
1050
  if (showPanel) {
1051
- await UI.ViewManager.ViewManager.instance().showView('elements', false, !focus);
1051
+ await UI.ViewManager.ViewManager.instance().showView('elements', false, !focusNode);
1052
1052
  }
1053
1053
  this.selectDOMNode(nodeToReveal, focusNode);
1054
1054
  delete this.omitDefaultSelection;
@@ -57,7 +57,7 @@ export class StyleEditorWidget extends UI.Widget.VBox {
57
57
  target.property.value = event.data.value;
58
58
  target.updateTitle();
59
59
  await target.applyStyleText(target.renderedPropertyText(), false);
60
- await this.render();
60
+ this.requestUpdate();
61
61
  }
62
62
 
63
63
  async onPropertyDeselected(event: PropertyDeselectedEvent): Promise<void> {
@@ -66,7 +66,7 @@ export class StyleEditorWidget extends UI.Widget.VBox {
66
66
  }
67
67
  const target = ensureTreeElementForProperty(this.section, event.data.name);
68
68
  await target.applyStyleText('', false);
69
- await this.render();
69
+ this.requestUpdate();
70
70
  }
71
71
 
72
72
  bindContext(stylesContainer: StylesContainer, section: StylePropertiesSection): void {
@@ -102,6 +102,11 @@ export class StyleEditorWidget extends UI.Widget.VBox {
102
102
  };
103
103
  }
104
104
 
105
+ override async performUpdate(): Promise<void> {
106
+ await super.performUpdate();
107
+ await this.render();
108
+ }
109
+
105
110
  static instance(): StyleEditorWidget {
106
111
  if (!instance) {
107
112
  instance = new StyleEditorWidget();
@@ -138,11 +143,14 @@ export class StyleEditorWidget extends UI.Widget.VBox {
138
143
  const onScroll = (): void => {
139
144
  popoverHelper.hide(true);
140
145
  };
146
+ const onStylesUpdateCompleted = widget.requestUpdate.bind(widget);
147
+ stylesContainer.addStyleUpdateListener(onStylesUpdateCompleted);
141
148
  popoverHelper.show(widget, triggerButton, () => {
142
149
  widget.unbindContext();
143
150
  if (scrollerElement) {
144
151
  scrollerElement.removeEventListener('scroll', onScroll);
145
152
  }
153
+ stylesContainer.removeStyleUpdateListener(onStylesUpdateCompleted);
146
154
  });
147
155
  if (scrollerElement) {
148
156
  scrollerElement.addEventListener('scroll', onScroll);
@@ -2896,7 +2896,7 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
2896
2896
  const regex = new RegExp(propertyNamePattern, 'i');
2897
2897
  await computedStyleWidget.filterComputedStyles(regex);
2898
2898
 
2899
- computedStyleWidget.setFilterInput(this.property.name);
2899
+ computedStyleWidget.filterText = this.property.name;
2900
2900
  }
2901
2901
 
2902
2902
  private copyCssDeclarationAsJs(): void {
@@ -54,4 +54,6 @@ export interface StylesContainer {
54
54
  jumpToFontPaletteDefinition(paletteName: string): void;
55
55
  jumpToDeclaration(valueSource: SDK.CSSMatchedStyles.CSSValueSource): void;
56
56
  setActiveProperty(treeElement: StylePropertyTreeElement|null): void;
57
+ addStyleUpdateListener(listener: () => void): void;
58
+ removeStyleUpdateListener(listener: () => void): void;
57
59
  }