chrome-devtools-frontend 1.0.1730971 → 1.0.1732418

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 (153) hide show
  1. package/front_end/Tests.js +20 -0
  2. package/front_end/core/host/AidaClient.ts +47 -3
  3. package/front_end/core/host/AidaClientTypes.ts +8 -1
  4. package/front_end/core/host/AidaGcaTranslation.ts +1 -1
  5. package/front_end/core/sdk/NetworkManager.ts +2 -1
  6. package/front_end/generated/Deprecation.ts +0 -8
  7. package/front_end/generated/InspectorBackendCommands.ts +2 -1
  8. package/front_end/generated/protocol.ts +9 -0
  9. package/front_end/models/ai_assistance/agents/StylingAgent.snapshot.txt +1 -1
  10. package/front_end/models/ai_assistance/contexts/LighthouseContext.snapshot.txt +6 -1
  11. package/front_end/models/ai_assistance/contexts/LighthouseContext.ts +4 -3
  12. package/front_end/models/ai_assistance/data_formatters/LighthouseFormatter.snapshot.txt +91 -11
  13. package/front_end/models/ai_assistance/data_formatters/LighthouseFormatter.ts +90 -43
  14. package/front_end/models/ai_assistance/skills/styling.md +4 -2
  15. package/front_end/models/ai_assistance/tools/ExecuteJavaScript.ts +31 -36
  16. package/front_end/models/bindings/CompilerScriptMapping.ts +0 -1
  17. package/front_end/models/bindings/DebuggerLanguagePlugins.ts +0 -1
  18. package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +0 -1
  19. package/front_end/models/har/HARFormat.ts +1 -0
  20. package/front_end/models/har/Importer.ts +7 -1
  21. package/front_end/models/har/Log.snapshot.txt +2 -0
  22. package/front_end/models/har/Log.ts +2 -0
  23. package/front_end/models/javascript_metadata/NativeFunctions.ts +0 -4
  24. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +1 -1
  25. package/front_end/panels/ai_assistance/components/ChatInput.ts +2 -0
  26. package/front_end/panels/ai_assistance/components/chatInput.css +1 -1
  27. package/front_end/panels/ai_assistance/components/exploreWidget.css +1 -1
  28. package/front_end/panels/animation/animationTimeline.css +11 -9
  29. package/front_end/panels/application/IndexedDBViews.ts +2 -2
  30. package/front_end/panels/application/PrivateVerificationTokensView.ts +217 -9
  31. package/front_end/panels/application/ServiceWorkerCacheViews.ts +1 -1
  32. package/front_end/panels/application/ServiceWorkersView.ts +1 -1
  33. package/front_end/panels/application/StorageView.ts +1 -1
  34. package/front_end/panels/application/appManifestView.css +0 -6
  35. package/front_end/panels/application/backgroundServiceView.css +0 -21
  36. package/front_end/panels/application/components/backForwardCacheView.css +1 -9
  37. package/front_end/panels/application/components/endpointsGrid.css +1 -1
  38. package/front_end/panels/application/components/permissionsPolicySection.css +1 -1
  39. package/front_end/panels/application/cookieItemsView.css +0 -1
  40. package/front_end/panels/application/frameDetailsReportView.css +0 -10
  41. package/front_end/panels/application/indexedDBViews.css +0 -6
  42. package/front_end/panels/application/privateVerificationTokensView.css +12 -0
  43. package/front_end/panels/application/resourcesPanel.css +0 -14
  44. package/front_end/panels/application/serviceWorkerUpdateCycleView.css +4 -4
  45. package/front_end/panels/application/serviceWorkersView.css +1 -1
  46. package/front_end/panels/changes/CombinedDiffView.ts +1 -1
  47. package/front_end/panels/comments/CommentsPane.ts +5 -0
  48. package/front_end/panels/common/CommentsOverlayWidget.ts +337 -117
  49. package/front_end/panels/console/consoleView.css +5 -3
  50. package/front_end/panels/coverage/CoverageView.ts +0 -1
  51. package/front_end/panels/coverage/coverageView.css +4 -3
  52. package/front_end/panels/css_overview/CSSOverviewCompletedView.ts +0 -1
  53. package/front_end/panels/elements/AccessibilityTreeView.ts +1 -1
  54. package/front_end/panels/elements/CSSValueTraceView.ts +2 -4
  55. package/front_end/panels/elements/DOMTreeContextMenu.ts +1 -1
  56. package/front_end/panels/elements/DOMTreeWidget.ts +14 -0
  57. package/front_end/panels/elements/MetricsSidebarPane.ts +1 -1
  58. package/front_end/panels/elements/PlatformFontsWidget.ts +0 -1
  59. package/front_end/panels/elements/PropertiesWidget.ts +1 -1
  60. package/front_end/panels/elements/StylesSidebarPane.ts +2 -0
  61. package/front_end/panels/elements/WebCustomData.ts +1 -1
  62. package/front_end/panels/elements/components/cssHintDetailsView.css +1 -1
  63. package/front_end/panels/elements/components/cssVariableValueView.css +3 -1
  64. package/front_end/panels/elements/components/elementsTreeExpandButton.css +3 -2
  65. package/front_end/panels/elements/components/stylePropertyEditor.css +2 -2
  66. package/front_end/panels/elements/layoutPane.css +1 -1
  67. package/front_end/panels/elements/metricsSidebarPane.css +4 -4
  68. package/front_end/panels/elements/platformFontsWidget.css +1 -1
  69. package/front_end/panels/elements/stylesSidebarPane.css +1 -1
  70. package/front_end/panels/emulation/DeviceModeView.ts +4 -3
  71. package/front_end/panels/emulation/deviceModeView.css +6 -7
  72. package/front_end/panels/event_listeners/eventListenersView.css +4 -4
  73. package/front_end/panels/explain/components/consoleInsight.css +3 -18
  74. package/front_end/panels/issues/issuesTree.css +5 -6
  75. package/front_end/panels/layer_viewer/LayerDetailsView.ts +4 -2
  76. package/front_end/panels/layer_viewer/TransformController.ts +106 -54
  77. package/front_end/panels/lighthouse/lighthousePanel.css +4 -7
  78. package/front_end/panels/lighthouse/lighthouseStartView.css +1 -2
  79. package/front_end/panels/linear_memory_inspector/components/linearMemoryHighlightChipList.css +4 -4
  80. package/front_end/panels/media/EventTimelineView.ts +1 -4
  81. package/front_end/panels/media/TickingFlameChart.ts +3 -2
  82. package/front_end/panels/media/playerListView.css +6 -3
  83. package/front_end/panels/media/playerMessagesView.css +2 -2
  84. package/front_end/panels/mobile_throttling/ThrottlingSettingsTab.ts +1 -1
  85. package/front_end/panels/mobile_throttling/throttlingSettingsTab.css +5 -7
  86. package/front_end/panels/network/NetworkConfigView.ts +1 -1
  87. package/front_end/panels/network/binaryResourceView.css +0 -7
  88. package/front_end/panels/network/networkLogView.css +0 -7
  89. package/front_end/panels/network/networkTimingTable.css +2 -2
  90. package/front_end/panels/network/requestConditionsDrawer.css +1 -24
  91. package/front_end/panels/performance_monitor/PerformanceMonitor.ts +1 -1
  92. package/front_end/panels/performance_monitor/performanceMonitor.css +1 -1
  93. package/front_end/panels/protocol_monitor/JSONEditor.ts +1 -1
  94. package/front_end/panels/protocol_monitor/protocolMonitor.css +1 -1
  95. package/front_end/panels/recorder/extensionView.css +1 -1
  96. package/front_end/panels/recorder/recorderPanel.css +3 -3
  97. package/front_end/panels/recorder/recordingListView.css +1 -1
  98. package/front_end/panels/recorder/stepEditor.css +2 -2
  99. package/front_end/panels/recorder/stepView.css +0 -24
  100. package/front_end/panels/screencast/screencastView.css +2 -1
  101. package/front_end/panels/search/searchView.css +4 -3
  102. package/front_end/panels/security/SecurityPanelSidebar.ts +0 -1
  103. package/front_end/panels/security/mainView.css +1 -1
  104. package/front_end/panels/security/originView.css +0 -4
  105. package/front_end/panels/settings/FrameworkIgnoreListSettingsTab.ts +2 -1
  106. package/front_end/panels/sources/WatchExpressionsSidebarPane.ts +1 -2
  107. package/front_end/panels/sources/breakpointsView.css +0 -1
  108. package/front_end/panels/sources/tabbedEditorContainer.css +1 -1
  109. package/front_end/panels/sources/watchExpressionsSidebarPane.css +2 -2
  110. package/front_end/panels/timeline/TimelineSelectorStatsView.ts +1 -1
  111. package/front_end/panels/timeline/components/OriginMap.ts +1 -1
  112. package/front_end/panels/timeline/components/fieldSettingsDialog.css +1 -1
  113. package/front_end/panels/timeline/components/metricCard.css +1 -1
  114. package/front_end/panels/timeline/components/networkRequestDetails.css +0 -1
  115. package/front_end/panels/timeline/components/networkRequestTooltip.css +2 -2
  116. package/front_end/panels/timeline/timelineFlamechartPopover.css +1 -1
  117. package/front_end/panels/timeline/timelineHistoryManager.css +1 -1
  118. package/front_end/panels/timeline/timelineMiniMap.css +1 -1
  119. package/front_end/panels/timeline/timelineStatusDialog.css +1 -1
  120. package/front_end/panels/web_audio/webAudio.css +0 -20
  121. package/front_end/third_party/chromium/README.chromium +1 -1
  122. package/front_end/ui/comments/CommentAnchorResolver.ts +166 -8
  123. package/front_end/ui/comments/CommentOverlayManager.ts +17 -2
  124. package/front_end/ui/components/diff_view/diffView.css +1 -1
  125. package/front_end/ui/components/markdown_view/markdownView.css +1 -1
  126. package/front_end/ui/components/menus/Menu.ts +1 -1
  127. package/front_end/ui/components/menus/menuItem.css +1 -1
  128. package/front_end/ui/components/panel_feedback/panelFeedback.css +2 -2
  129. package/front_end/ui/components/panel_introduction_steps/panelIntroductionSteps.css +1 -1
  130. package/front_end/ui/components/report_view/reportValue.css +5 -2
  131. package/front_end/ui/components/suggestion_input/suggestionInput.css +4 -4
  132. package/front_end/ui/legacy/ContextMenu.ts +3 -0
  133. package/front_end/ui/legacy/GlassPane.ts +3 -3
  134. package/front_end/ui/legacy/SoftContextMenu.ts +7 -1
  135. package/front_end/ui/legacy/components/data_grid/DataGrid.ts +2 -0
  136. package/front_end/ui/legacy/components/inline_editor/bezierEditor.css +7 -6
  137. package/front_end/ui/legacy/components/inline_editor/cssAngleEditor.css +3 -3
  138. package/front_end/ui/legacy/components/perf_ui/flameChart.css +7 -6
  139. package/front_end/ui/legacy/components/perf_ui/overviewGrid.css +4 -3
  140. package/front_end/ui/legacy/components/perf_ui/pieChart.css +3 -3
  141. package/front_end/ui/legacy/components/source_frame/imageView.css +4 -4
  142. package/front_end/ui/legacy/components/utils/jsUtils.css +2 -1
  143. package/front_end/ui/legacy/dropTarget.css +1 -1
  144. package/front_end/ui/legacy/filter.css +4 -3
  145. package/front_end/ui/legacy/inspectorCommon.css +8 -23
  146. package/front_end/ui/legacy/inspectorDrawerTabbedPane.css +1 -1
  147. package/front_end/ui/legacy/suggestBox.css +2 -1
  148. package/front_end/ui/legacy/toolbar.css +2 -1
  149. package/front_end/ui/legacy/treeoutline.css +5 -4
  150. package/front_end/ui/legacy/viewContainers.css +2 -1
  151. package/front_end/ui/visual_logging/KnownContextValues.ts +7 -0
  152. package/inspector_overlay/highlight_anchor.ts +8 -11
  153. package/package.json +1 -1
@@ -29,7 +29,20 @@ const {
29
29
  Directives: {classMap, repeat, styleMap},
30
30
  } = Lit;
31
31
 
32
- export interface ViewInput {
32
+ /** Actions on the comments of a single thread shown in a popup. */
33
+ export interface ThreadActions {
34
+ onAddComment: (text: string) => void;
35
+ onDeleteQueuedComment: () => void;
36
+ onQueueComment: (text: string) => void;
37
+ onSaveEdit: (text: string) => void;
38
+ onStartEdit: () => void;
39
+ }
40
+
41
+ /**
42
+ * The flat `ThreadActions` act on `activeThread`; `hoveredActions` act on
43
+ * `hoveredThread`.
44
+ */
45
+ export interface ViewInput extends ThreadActions {
33
46
  pins: Comments.CommentOverlayManager.PinPositionData[];
34
47
  /**
35
48
  * Highlight of the currently open thread. Null when no thread is open, so
@@ -39,15 +52,30 @@ export interface ViewInput {
39
52
  hoverHighlight: Comments.CommentOverlayManager.HoverHighlightData|null;
40
53
  commentMode: boolean;
41
54
  onPinClick: (threadId: string) => void;
55
+ onPinMouseEnter: (threadId: string) => void;
56
+ onPinMouseLeave: () => void;
57
+ onPopupMouseEnter: () => void;
58
+ onPopupMouseLeave: () => void;
59
+ /**
60
+ * Called when the user interacts with the hover preview popup (focus or
61
+ * mouse down). Makes the previewed thread the open thread, unless a draft
62
+ * is open.
63
+ */
64
+ onPopupInteract: () => void;
65
+ /** Thread opened by the user (pin click, drawer, or draft). */
42
66
  activeThread: CommentManager.CommentManager.CommentThread|null;
43
67
  activePin: Comments.CommentOverlayManager.PinPositionData|null;
44
68
  fallbackPosition?: {left: number, top: number}|null;
45
69
  title: Title;
46
- onAddComment: (text: string) => void;
47
- onDeleteQueuedComment: () => void;
48
- onQueueComment: (text: string) => void;
49
- onSaveEdit: (text: string) => void;
50
- onStartEdit: () => void;
70
+ /**
71
+ * Thread previewed because its pin is hovered. Shown together with
72
+ * `activeThread`, and never the same thread.
73
+ */
74
+ hoveredThread: CommentManager.CommentManager.CommentThread|null;
75
+ hoveredPin: Comments.CommentOverlayManager.PinPositionData|null;
76
+ hoveredHighlight: Comments.CommentOverlayManager.HighlightRectData|null;
77
+ hoveredTitle: Title;
78
+ hoveredActions: ThreadActions;
51
79
  }
52
80
 
53
81
  export type View = (
@@ -61,10 +89,74 @@ const PIN_HEIGHT = 30;
61
89
  const POPUP_WIDTH = 288;
62
90
  const POPUP_HEIGHT = 220;
63
91
  const AUTO_CLOSE_DELAY_MS = 2000;
92
+ /**
93
+ * Grace period before hiding a hover preview, so the cursor can travel from
94
+ * the pin to the popup without the popup disappearing.
95
+ */
96
+ const HOVER_HIDE_DELAY_MS = 150;
64
97
  const COMMENTS_VIEW_ID = 'comments';
65
98
 
99
+ interface PopupItem {
100
+ thread: CommentManager.CommentManager.CommentThread;
101
+ position: {left: number, top: number};
102
+ /** False when placed at a drawer row (`fallbackPosition`) instead of a pin. */
103
+ anchoredToPin: boolean;
104
+ title: Title;
105
+ actions: ThreadActions;
106
+ isHoverPreview: boolean;
107
+ }
108
+
109
+ function getPopupItems(input: ViewInput): PopupItem[] {
110
+ const items: PopupItem[] = [];
111
+ const activePosition = input.activePin ?? input.fallbackPosition;
112
+ if (input.activeThread && activePosition) {
113
+ items.push({
114
+ thread: input.activeThread,
115
+ position: activePosition,
116
+ anchoredToPin: Boolean(input.activePin),
117
+ title: input.title,
118
+ actions: input,
119
+ isHoverPreview: false,
120
+ });
121
+ }
122
+ if (input.hoveredThread && input.hoveredPin) {
123
+ items.push({
124
+ thread: input.hoveredThread,
125
+ position: input.hoveredPin,
126
+ anchoredToPin: true,
127
+ title: input.hoveredTitle,
128
+ actions: input.hoveredActions,
129
+ isHoverPreview: true,
130
+ });
131
+ }
132
+ return items;
133
+ }
134
+
135
+ function renderAnchorHighlight(
136
+ thread: CommentManager.CommentManager.CommentThread|null,
137
+ highlight: Comments.CommentOverlayManager.HighlightRectData|null,
138
+ ): Lit.TemplateResult|typeof nothing {
139
+ if (!thread || !highlight?.visible) {
140
+ return nothing;
141
+ }
142
+ // clang-format off
143
+ return html`
144
+ <div
145
+ class=${classMap({
146
+ 'comment-anchor-highlight': true,
147
+ resolved: thread.status === 'RESOLVED',
148
+ })}
149
+ style=${styleMap({
150
+ transform: `translate3d(${highlight.left}px, ${highlight.top}px, 0)`,
151
+ width: `${highlight.width}px`,
152
+ height: `${highlight.height}px`,
153
+ })}>
154
+ </div>
155
+ `;
156
+ // clang-format on
157
+ }
158
+
66
159
  const DEFAULT_VIEW: View = (input: ViewInput, _output: undefined, target: HTMLElement): void => {
67
- const popupPosition = input.activePin ?? input.fallbackPosition;
68
160
  // clang-format off
69
161
  render(html`
70
162
  <style>${commentsOverlayStyles}</style>
@@ -79,19 +171,8 @@ const DEFAULT_VIEW: View = (input: ViewInput, _output: undefined, target: HTMLEl
79
171
  })}>
80
172
  </div>
81
173
  ` : nothing}
82
- ${input.activeHighlight?.visible && input.activeThread ? html`
83
- <div
84
- class=${classMap({
85
- 'comment-anchor-highlight': true,
86
- resolved: input.activeThread.status === 'RESOLVED',
87
- })}
88
- style=${styleMap({
89
- transform: `translate3d(${input.activeHighlight.left}px, ${input.activeHighlight.top}px, 0)`,
90
- width: `${input.activeHighlight.width}px`,
91
- height: `${input.activeHighlight.height}px`,
92
- })}>
93
- </div>
94
- ` : nothing}
174
+ ${renderAnchorHighlight(input.activeThread, input.activeHighlight)}
175
+ ${renderAnchorHighlight(input.hoveredThread, input.hoveredHighlight)}
95
176
  ${repeat(
96
177
  input.pins.filter(p => p.visible),
97
178
  p => p.id,
@@ -102,13 +183,17 @@ const DEFAULT_VIEW: View = (input: ViewInput, _output: undefined, target: HTMLEl
102
183
  style=${styleMap({
103
184
  transform: `translate3d(${p.left}px, ${p.top}px, 0)`,
104
185
  })}
105
- @click=${() => input.onPinClick(p.id)}>
186
+ @click=${() => input.onPinClick(p.id)}
187
+ @mouseenter=${() => input.onPinMouseEnter(p.id)}
188
+ @mouseleave=${input.onPinMouseLeave}>
106
189
  <div class="comment-cursor"></div>
107
190
  </div>
108
191
  `,
109
192
  )}
110
- ${popupPosition && input.activeThread ? repeat(
111
- [{position: popupPosition, thread: input.activeThread}],
193
+ ${repeat(
194
+ getPopupItems(input),
195
+ // Keyed by thread so that the popup DOM (and focus) is kept when a
196
+ // hover preview becomes the open thread.
112
197
  item => item.thread.id,
113
198
  item => {
114
199
  // Clamp horizontal position so the popup stays within the viewport with POPUP_MARGIN padding.
@@ -116,34 +201,38 @@ const DEFAULT_VIEW: View = (input: ViewInput, _output: undefined, target: HTMLEl
116
201
  Math.max(POPUP_MARGIN, item.position.left),
117
202
  Math.max(POPUP_MARGIN, target.clientWidth - POPUP_WIDTH - POPUP_MARGIN),
118
203
  );
119
- // When anchored to a pin (`activePin`), place the popup below the pin (`top + PIN_HEIGHT`).
204
+ // When anchored to a pin, place the popup below the pin (`top + PIN_HEIGHT`).
120
205
  // When unanchored (`fallbackPosition` from a drawer row), place the anchor point just above
121
206
  // the row (`top - POPUP_MARGIN`) and shift the popup up by its own height via `translateY(-100%)`.
122
- const topOffset = input.activePin ? item.position.top + PIN_HEIGHT : item.position.top - POPUP_MARGIN;
123
- const maxTop = target.clientHeight - (input.activePin ? POPUP_HEIGHT : POPUP_MARGIN);
207
+ const topOffset = item.anchoredToPin ? item.position.top + PIN_HEIGHT : item.position.top - POPUP_MARGIN;
208
+ const maxTop = target.clientHeight - (item.anchoredToPin ? POPUP_HEIGHT : POPUP_MARGIN);
124
209
  const popupTop = Math.min(Math.max(POPUP_MARGIN, topOffset), Math.max(POPUP_MARGIN, maxTop));
125
210
  return html`
126
211
  <div
127
212
  class="comment-popup-widget"
128
213
  style=${styleMap({
129
- transform: `translate3d(${popupLeft}px, ${popupTop}px, 0)${input.activePin ? '' : ' translateY(-100%)'}`,
130
- })}>
214
+ transform: `translate3d(${popupLeft}px, ${popupTop}px, 0)${item.anchoredToPin ? '' : ' translateY(-100%)'}`,
215
+ })}
216
+ @mouseenter=${item.isHoverPreview ? input.onPopupMouseEnter : nothing}
217
+ @mouseleave=${item.isHoverPreview ? input.onPopupMouseLeave : nothing}
218
+ @mousedown=${item.isHoverPreview ? input.onPopupInteract : nothing}
219
+ @focusin=${item.isHoverPreview ? input.onPopupInteract : nothing}>
131
220
  ${UI.Widget.widget(CommentThreadWidget, {
132
- title: input.title,
221
+ title: item.title,
133
222
  comments: [...item.thread.comments],
134
223
  status: item.thread.status,
135
224
  transmitted: item.thread.transmitted,
136
- onAddComment: input.onAddComment,
137
- onDeleteQueuedComment: input.onDeleteQueuedComment,
138
- onQueueComment: input.onQueueComment,
139
- onSaveEdit: input.onSaveEdit,
140
- onStartEdit: input.onStartEdit,
225
+ onAddComment: item.actions.onAddComment,
226
+ onDeleteQueuedComment: item.actions.onDeleteQueuedComment,
227
+ onQueueComment: item.actions.onQueueComment,
228
+ onSaveEdit: item.actions.onSaveEdit,
229
+ onStartEdit: item.actions.onStartEdit,
141
230
  elementRemoved: item.thread.isOrphaned,
142
231
  })}
143
232
  </div>
144
233
  `;
145
234
  },
146
- ) : nothing}
235
+ )}
147
236
  </div>
148
237
  `, target);
149
238
  // clang-format on
@@ -164,27 +253,57 @@ export class CommentsOverlayWidget extends UI.Widget.Widget {
164
253
  readonly #commentManager: CommentManager.CommentManager.CommentManager;
165
254
  #commentOverlayManager: Comments.CommentOverlayManager.CommentOverlayManager;
166
255
  #activeThreadId: string|null = null;
256
+ /**
257
+ * Thread previewed because its pin (or its preview popup) is hovered. Shown
258
+ * next to the open thread; never equal to `#activeThreadId`.
259
+ */
260
+ #hoveredThreadId: string|null = null;
261
+ #hoverHideTimeoutId: number|null = null;
167
262
  #fallbackPosition: {left: number, top: number}|null = null;
168
263
  #closeTimeoutId: number|null = null;
169
- #cachedTitle: Title = {text: ''};
170
- #cachedTitleAnchor: CommentManager.CommentManager.CommentAnchorSignature|null = null;
264
+ readonly #titleCache = new WeakMap<CommentManager.CommentManager.CommentAnchorSignature, Title>();
265
+
266
+ #getThread(threadId: string|null): CommentManager.CommentManager.CommentThread|null {
267
+ return threadId ? this.#commentManager.getCommentThread(threadId) ?? null : null;
268
+ }
171
269
 
172
270
  #setActiveThreadId(threadId: string|null): void {
173
271
  this.#fallbackPosition = null;
174
272
  if (this.#activeThreadId !== threadId) {
175
273
  this.#clearCloseTimeout();
274
+ this.#clearHover();
176
275
  this.#activeThreadId = threadId;
177
- if (threadId && this.isShowing()) {
178
- document.documentElement.addEventListener('keydown', this.#onKeyDown);
179
- document.documentElement.addEventListener('click', this.#onClickOutside, {capture: true});
180
- } else {
181
- document.documentElement.removeEventListener('keydown', this.#onKeyDown);
182
- document.documentElement.removeEventListener('click', this.#onClickOutside, {capture: true});
183
- }
276
+ this.#updateDocumentListeners();
184
277
  this.#markActiveThreadResponseSeen();
185
278
  }
186
279
  }
187
280
 
281
+ /**
282
+ * Escape is handled while a thread is open or comment mode is on. The
283
+ * listener is registered in the capture phase so that, in comment mode, the
284
+ * first Escape exits the mode before any panel-level Escape handling (or the
285
+ * drawer toggle) sees it. When neither applies the listener is removed and
286
+ * Escape keeps its default DevTools behavior.
287
+ */
288
+ #updateDocumentListeners(): void {
289
+ const isShowing = this.isShowing();
290
+ if (isShowing && (this.#activeThreadId || this.#commentManager.isCommentMode())) {
291
+ document.addEventListener('keydown', this.#onKeyDown, {capture: true});
292
+ } else {
293
+ document.removeEventListener('keydown', this.#onKeyDown, {capture: true});
294
+ }
295
+ if (isShowing && this.#activeThreadId) {
296
+ document.addEventListener('click', this.#onClickOutside, {capture: true});
297
+ } else {
298
+ document.removeEventListener('click', this.#onClickOutside, {capture: true});
299
+ }
300
+ }
301
+
302
+ #removeDocumentListeners(): void {
303
+ document.removeEventListener('keydown', this.#onKeyDown, {capture: true});
304
+ document.removeEventListener('click', this.#onClickOutside, {capture: true});
305
+ }
306
+
188
307
  /**
189
308
  * The open thread shows the agent response, so the developer has seen it.
190
309
  */
@@ -241,18 +360,15 @@ export class CommentsOverlayWidget extends UI.Widget.Widget {
241
360
  this.#onAgentAttachedChanged,
242
361
  this,
243
362
  );
244
- if (this.#activeThreadId) {
245
- document.documentElement.addEventListener('keydown', this.#onKeyDown);
246
- document.documentElement.addEventListener('click', this.#onClickOutside, {capture: true});
247
- }
363
+ this.#updateDocumentListeners();
248
364
 
249
365
  this.requestUpdate();
250
366
  }
251
367
 
252
368
  override willHide(): void {
253
369
  this.#clearCloseTimeout();
254
- document.documentElement.removeEventListener('keydown', this.#onKeyDown);
255
- document.documentElement.removeEventListener('click', this.#onClickOutside, {capture: true});
370
+ this.#clearHover();
371
+ this.#removeDocumentListeners();
256
372
  this.#commentOverlayManager.stop();
257
373
  this.#commentOverlayManager.removeEventListener(
258
374
  Comments.CommentOverlayManager.Events.POSITIONS_UPDATED,
@@ -291,6 +407,63 @@ export class CommentsOverlayWidget extends UI.Widget.Widget {
291
407
  }
292
408
  }
293
409
 
410
+ #clearHoverHideTimeout(): void {
411
+ if (this.#hoverHideTimeoutId !== null) {
412
+ window.clearTimeout(this.#hoverHideTimeoutId);
413
+ this.#hoverHideTimeoutId = null;
414
+ }
415
+ }
416
+
417
+ #clearHover(): void {
418
+ this.#clearHoverHideTimeout();
419
+ this.#hoveredThreadId = null;
420
+ }
421
+
422
+ #handlePinMouseEnter = (threadId: string): void => {
423
+ this.#clearHoverHideTimeout();
424
+ if (threadId === this.#activeThreadId) {
425
+ // The open thread is already shown; drop any preview of another pin.
426
+ if (this.#hoveredThreadId) {
427
+ this.#clearHover();
428
+ this.requestUpdate();
429
+ }
430
+ return;
431
+ }
432
+ if (this.#hoveredThreadId === threadId) {
433
+ return;
434
+ }
435
+ this.#hoveredThreadId = threadId;
436
+ this.requestUpdate();
437
+ };
438
+
439
+ #scheduleHoverHide = (): void => {
440
+ if (!this.#hoveredThreadId) {
441
+ return;
442
+ }
443
+ this.#clearHoverHideTimeout();
444
+ this.#hoverHideTimeoutId = window.setTimeout(() => {
445
+ this.#hoverHideTimeoutId = null;
446
+ this.#hoveredThreadId = null;
447
+ this.requestUpdate();
448
+ }, HOVER_HIDE_DELAY_MS);
449
+ };
450
+
451
+ #handlePopupMouseEnter = (): void => {
452
+ this.#clearHoverHideTimeout();
453
+ };
454
+
455
+ #handlePopupInteract = (): void => {
456
+ if (!this.#hoveredThreadId) {
457
+ return;
458
+ }
459
+ // Never discard an unsent draft by interacting with a preview.
460
+ if (this.#getThread(this.#activeThreadId)?.status === 'DRAFT') {
461
+ return;
462
+ }
463
+ this.#setActiveThreadId(this.#hoveredThreadId);
464
+ this.requestUpdate();
465
+ };
466
+
294
467
  #onAgentAttachedChanged(
295
468
  event: Common.EventTarget.EventTargetEvent<
296
469
  CommentManager.CommentManager.EventTypes[CommentManager.CommentManager.Events.AGENT_ATTACHED_CHANGED]>,
@@ -309,6 +482,7 @@ export class CommentsOverlayWidget extends UI.Widget.Widget {
309
482
  if (!isModeActive) {
310
483
  this.#setActiveThreadId(null);
311
484
  }
485
+ this.#updateDocumentListeners();
312
486
  const action = UI.ActionRegistry.ActionRegistry.instance().getAction(
313
487
  'comments.toggle-comment-mode',
314
488
  );
@@ -323,6 +497,9 @@ export class CommentsOverlayWidget extends UI.Widget.Widget {
323
497
  } else if (this.#activeThreadId && !this.#commentManager.getCommentThread(this.#activeThreadId)) {
324
498
  this.#setActiveThreadId(null);
325
499
  }
500
+ if (this.#hoveredThreadId && !this.#commentManager.getCommentThread(this.#hoveredThreadId)) {
501
+ this.#clearHover();
502
+ }
326
503
  }
327
504
 
328
505
  #onPositionsUpdated(
@@ -356,29 +533,28 @@ export class CommentsOverlayWidget extends UI.Widget.Widget {
356
533
  this.#renderDisconnectedView();
357
534
  return true;
358
535
  }
359
- const activeThread =
360
- this.#activeThreadId ? this.#commentManager.getCommentThread(this.#activeThreadId) ?? null : null;
361
- const anchor = activeThread?.anchor ?? null;
362
- if (anchor === null) {
363
- this.#cachedTitleAnchor = null;
364
- this.#cachedTitle = {text: ''};
365
- this.#renderWithTitle(activeThread, this.#cachedTitle);
366
- return true;
367
- }
368
- if (anchor === this.#cachedTitleAnchor) {
369
- this.#renderWithTitle(activeThread, this.#cachedTitle);
370
- return true;
536
+ const activeThread = this.#getThread(this.#activeThreadId);
537
+ const hoveredThread = this.#getThread(this.#hoveredThreadId);
538
+ const title = this.#getCachedTitle(activeThread);
539
+ const hoveredTitle = this.#getCachedTitle(hoveredThread);
540
+ if (!title || !hoveredTitle) {
541
+ return false;
371
542
  }
372
- return false;
543
+ this.#renderView(activeThread, title, hoveredThread, hoveredTitle);
544
+ return true;
373
545
  }
374
546
 
375
- async #getOrComputeTitle(anchor: CommentManager.CommentManager.CommentAnchorSignature|null): Promise<Title> {
376
- if (anchor === this.#cachedTitleAnchor) {
377
- return this.#cachedTitle;
547
+ #getCachedTitle(thread: CommentManager.CommentManager.CommentThread|null): Title|undefined {
548
+ return thread ? this.#titleCache.get(thread.anchor) : {text: ''};
549
+ }
550
+
551
+ async #getOrComputeTitle(thread: CommentManager.CommentManager.CommentThread|null): Promise<Title> {
552
+ const cached = this.#getCachedTitle(thread);
553
+ if (cached || !thread) {
554
+ return cached ?? {text: ''};
378
555
  }
379
- const title = anchor ? await computeCommentTitle(anchor) : {text: ''};
380
- this.#cachedTitleAnchor = anchor;
381
- this.#cachedTitle = title;
556
+ const title = await computeCommentTitle(thread.anchor);
557
+ this.#titleCache.set(thread.anchor, title);
382
558
  return title;
383
559
  }
384
560
 
@@ -405,10 +581,23 @@ export class CommentsOverlayWidget extends UI.Widget.Widget {
405
581
  this.requestUpdate();
406
582
  };
407
583
 
584
+ /**
585
+ * Escape priority: an open thread closes first; otherwise, in comment mode,
586
+ * Escape exits comment mode. Open dialogs keep handling their own Escape.
587
+ */
408
588
  #onKeyDown = (event: KeyboardEvent): void => {
409
- if (this.#activeThreadId && event.key === 'Escape' && !event.isComposing) {
589
+ if (event.key !== 'Escape' || event.isComposing || !UI.KeyboardShortcut.KeyboardShortcut.hasNoModifiers(event) ||
590
+ UI.Dialog.Dialog.hasInstance()) {
591
+ return;
592
+ }
593
+ if (this.#activeThreadId) {
410
594
  event.consume(true);
411
595
  this.#handleCloseCommentThread();
596
+ return;
597
+ }
598
+ if (this.#commentManager.isCommentMode()) {
599
+ event.consume(true);
600
+ setCommentModeByUser(this.#commentManager, false);
412
601
  }
413
602
  };
414
603
 
@@ -420,6 +609,13 @@ export class CommentsOverlayWidget extends UI.Widget.Widget {
420
609
  };
421
610
 
422
611
  #renderDisconnectedView(): void {
612
+ const noopActions: ThreadActions = {
613
+ onAddComment: () => {},
614
+ onDeleteQueuedComment: () => {},
615
+ onQueueComment: () => {},
616
+ onSaveEdit: () => {},
617
+ onStartEdit: () => {},
618
+ };
423
619
  this.#view(
424
620
  {
425
621
  pins: [],
@@ -427,68 +623,95 @@ export class CommentsOverlayWidget extends UI.Widget.Widget {
427
623
  hoverHighlight: null,
428
624
  commentMode: false,
429
625
  onPinClick: this.#handlePinClick,
626
+ onPinMouseEnter: this.#handlePinMouseEnter,
627
+ onPinMouseLeave: this.#scheduleHoverHide,
628
+ onPopupMouseEnter: this.#handlePopupMouseEnter,
629
+ onPopupMouseLeave: this.#scheduleHoverHide,
630
+ onPopupInteract: this.#handlePopupInteract,
430
631
  activeThread: null,
431
632
  activePin: null,
432
633
  title: {text: ''},
433
- onAddComment: () => {},
434
- onDeleteQueuedComment: () => {},
435
- onQueueComment: () => {},
436
- onSaveEdit: () => {},
437
- onStartEdit: () => {},
634
+ hoveredThread: null,
635
+ hoveredPin: null,
636
+ hoveredHighlight: null,
637
+ hoveredTitle: {text: ''},
638
+ hoveredActions: noopActions,
639
+ ...noopActions,
438
640
  },
439
641
  undefined,
440
642
  this.contentElement,
441
643
  );
442
644
  }
443
645
 
444
- #renderWithTitle(
445
- activeThread: CommentManager.CommentManager.CommentThread|null,
446
- title: Title,
447
- ): void {
448
- const pins = this.#commentOverlayManager.getPinPositions();
449
- const activePin = this.#activeThreadId ? pins.find(p => p.id === this.#activeThreadId) ?? null : null;
450
- const activeHighlight =
451
- this.#activeThreadId ? this.#commentOverlayManager.getHighlight(this.#activeThreadId) ?? null : null;
452
-
453
- const viewInput: ViewInput = {
454
- pins,
455
- activeHighlight,
456
- hoverHighlight: this.#commentOverlayManager.getHoverHighlight(),
457
- commentMode: this.#commentManager.isCommentMode(),
458
- onPinClick: this.#handlePinClick,
459
- activeThread,
460
- activePin,
461
- fallbackPosition: this.#fallbackPosition,
462
- title,
646
+ #createThreadActions(thread: CommentManager.CommentManager.CommentThread|null): ThreadActions {
647
+ return {
463
648
  onAddComment: (text: string) => {
464
- if (!activeThread) {
649
+ if (!thread) {
465
650
  return;
466
651
  }
467
- activeThread.sendToAgent(text);
468
- this.#scheduleAutoClose(activeThread.id);
652
+ thread.sendToAgent(text);
653
+ this.#scheduleAutoClose(thread.id);
469
654
  },
470
655
  onDeleteQueuedComment: () => {
471
- if (!activeThread) {
656
+ if (!thread) {
472
657
  return;
473
658
  }
474
659
 
475
- this.#commentOverlayManager.removeCommentThread(activeThread.id);
660
+ this.#commentOverlayManager.removeCommentThread(thread.id);
476
661
  },
477
662
  onQueueComment: (text: string) => {
478
- if (!activeThread) {
663
+ if (!thread) {
479
664
  return;
480
665
  }
481
- activeThread.save(text);
482
- this.#scheduleAutoClose(activeThread.id);
666
+ thread.save(text);
667
+ this.#scheduleAutoClose(thread.id);
483
668
  },
484
669
  onSaveEdit: (text: string) => {
485
- if (!activeThread) {
670
+ if (!thread) {
486
671
  return;
487
672
  }
488
- activeThread.editComment(text);
673
+ thread.editComment(text);
489
674
  },
490
675
  onStartEdit: () => this.#clearCloseTimeout(),
491
676
  };
677
+ }
678
+
679
+ #renderView(
680
+ activeThread: CommentManager.CommentManager.CommentThread|null,
681
+ title: Title,
682
+ hoveredThread: CommentManager.CommentManager.CommentThread|null,
683
+ hoveredTitle: Title,
684
+ ): void {
685
+ const pins = this.#commentOverlayManager.getPinPositions();
686
+ const findPin =
687
+ (thread: CommentManager.CommentManager.CommentThread|null): Comments.CommentOverlayManager.PinPositionData|
688
+ null => thread ? pins.find(p => p.id === thread.id) ?? null : null;
689
+ const findHighlight =
690
+ (thread: CommentManager.CommentManager.CommentThread|null): Comments.CommentOverlayManager.HighlightRectData|
691
+ null => thread ? this.#commentOverlayManager.getHighlight(thread.id) ?? null : null;
692
+
693
+ const viewInput: ViewInput = {
694
+ pins,
695
+ activeHighlight: findHighlight(activeThread),
696
+ hoverHighlight: this.#commentOverlayManager.getHoverHighlight(),
697
+ commentMode: this.#commentManager.isCommentMode(),
698
+ onPinClick: this.#handlePinClick,
699
+ onPinMouseEnter: this.#handlePinMouseEnter,
700
+ onPinMouseLeave: this.#scheduleHoverHide,
701
+ onPopupMouseEnter: this.#handlePopupMouseEnter,
702
+ onPopupMouseLeave: this.#scheduleHoverHide,
703
+ onPopupInteract: this.#handlePopupInteract,
704
+ activeThread,
705
+ activePin: findPin(activeThread),
706
+ fallbackPosition: this.#fallbackPosition,
707
+ title,
708
+ hoveredThread,
709
+ hoveredPin: findPin(hoveredThread),
710
+ hoveredHighlight: findHighlight(hoveredThread),
711
+ hoveredTitle,
712
+ hoveredActions: this.#createThreadActions(hoveredThread),
713
+ ...this.#createThreadActions(activeThread),
714
+ };
492
715
  this.#view(viewInput, undefined, this.contentElement);
493
716
  }
494
717
 
@@ -509,22 +732,19 @@ export class CommentsOverlayWidget extends UI.Widget.Widget {
509
732
  return;
510
733
  }
511
734
 
512
- const activeThread =
513
- this.#activeThreadId ? this.#commentManager.getCommentThread(this.#activeThreadId) ?? null : null;
514
- const anchor = activeThread?.anchor ?? null;
515
- let title: Title;
516
- if (anchor === null) {
517
- this.#cachedTitleAnchor = null;
518
- this.#cachedTitle = {text: ''};
519
- title = this.#cachedTitle;
520
- } else if (anchor === this.#cachedTitleAnchor) {
521
- title = this.#cachedTitle;
522
- } else {
523
- title = await this.#getOrComputeTitle(anchor);
735
+ const activeThread = this.#getThread(this.#activeThreadId);
736
+ const hoveredThread = this.#getThread(this.#hoveredThreadId);
737
+ let title = this.#getCachedTitle(activeThread);
738
+ let hoveredTitle = this.#getCachedTitle(hoveredThread);
739
+ if (!title || !hoveredTitle) {
740
+ [title, hoveredTitle] = await Promise.all([
741
+ this.#getOrComputeTitle(activeThread),
742
+ this.#getOrComputeTitle(hoveredThread),
743
+ ]);
524
744
  signal?.throwIfAborted();
525
745
  }
526
746
 
527
- this.#renderWithTitle(activeThread, title);
747
+ this.#renderView(activeThread, title, hoveredThread, hoveredTitle);
528
748
  }
529
749
 
530
750
  openThread(threadId: string, fallbackPosition?: {left: number, top: number}): void {
@@ -103,7 +103,9 @@
103
103
  position: relative;
104
104
  padding: var(--sys-size-1) var(--sys-size-10) var(--sys-size-1) 0;
105
105
  margin-left: var(--sys-size-11);
106
- min-height: 18px;
106
+ /* 16px (--sys-size-8) single-line content/medium-icon box
107
+ * + 2 * 1px (--sys-size-1) top & bottom padding */
108
+ min-height: calc(var(--sys-size-8) + 2 * var(--sys-size-1));
107
109
  flex: auto;
108
110
  display: flex;
109
111
  align-items: flex-end;
@@ -117,7 +119,7 @@
117
119
  color: var(--sys-color-token-subtle);
118
120
  user-select: none;
119
121
  flex: none;
120
- margin-right: 5px;
122
+ margin-right: var(--sys-size-3);
121
123
  }
122
124
 
123
125
  .message-level-icon,
@@ -200,7 +202,7 @@
200
202
  display: flex;
201
203
  flex-direction: column;
202
204
  margin: var(--sys-size-3);
203
- border-radius: 5px;
205
+ border-radius: var(--sys-shape-corner-extra-small);
204
206
 
205
207
  /* Console ANSI color */
206
208
  --console-color-black: #000;
@@ -306,7 +306,6 @@ export class CoverageView extends UI.Widget.VBox<ShadowRoot> {
306
306
  useShadowDom: 'pure',
307
307
  delegatesFocus: true,
308
308
  });
309
- this.registerRequiredCSS(coverageViewStyles);
310
309
  this.#view = view;
311
310
 
312
311
  this.#model = null;