chrome-devtools-frontend 1.0.1583146 → 1.0.1585664

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 (119) hide show
  1. package/front_end/core/host/InspectorFrontendHostAPI.ts +1 -0
  2. package/front_end/core/host/InspectorFrontendHostStub.ts +2 -0
  3. package/front_end/core/root/Runtime.ts +12 -6
  4. package/front_end/core/sdk/CSSMatchedStyles.ts +3 -0
  5. package/front_end/core/sdk/CSSMetadata.ts +3 -0
  6. package/front_end/entrypoints/main/MainImpl.ts +1 -0
  7. package/front_end/generated/Deprecation.ts +21 -0
  8. package/front_end/generated/InspectorBackendCommands.ts +5 -3
  9. package/front_end/generated/SupportedCSSProperties.js +10 -4
  10. package/front_end/generated/protocol-mapping.d.ts +2 -1
  11. package/front_end/generated/protocol-proxy-api.d.ts +2 -1
  12. package/front_end/generated/protocol.ts +14 -0
  13. package/front_end/models/ai_assistance/AiConversation.ts +34 -2
  14. package/front_end/models/ai_assistance/BuiltInAi.ts +1 -2
  15. package/front_end/models/ai_assistance/agents/AiAgent.ts +3 -10
  16. package/front_end/models/ai_assistance/agents/ContextSelectionAgent.snapshot.txt +1 -1
  17. package/front_end/models/ai_assistance/agents/ContextSelectionAgent.ts +17 -9
  18. package/front_end/models/ai_assistance/agents/StylingAgent.snapshot.txt +0 -24
  19. package/front_end/models/ai_code_completion/AiCodeCompletion.ts +12 -0
  20. package/front_end/models/ai_code_generation/AiCodeGeneration.ts +5 -0
  21. package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +16 -8
  22. package/front_end/models/computed_style/ComputedStyleModel.ts +20 -15
  23. package/front_end/models/greendev/Prototypes.ts +1 -5
  24. package/front_end/models/issues_manager/CorsIssue.ts +2 -9
  25. package/front_end/models/issues_manager/descriptions/corsLocalNetworkAccessPermissionDenied.md +2 -2
  26. package/front_end/models/javascript_metadata/NativeFunctions.js +20 -0
  27. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +13 -36
  28. package/front_end/panels/ai_assistance/components/ChatInput.ts +73 -95
  29. package/front_end/panels/ai_assistance/components/ChatView.ts +13 -2
  30. package/front_end/panels/application/FrameDetailsView.ts +4 -9
  31. package/front_end/panels/common/AiCodeGenerationTeaser.ts +10 -0
  32. package/front_end/panels/console/ConsoleView.ts +1 -2
  33. package/front_end/panels/console/ConsoleViewMessage.ts +19 -12
  34. package/front_end/panels/elements/ComputedStyleWidget.ts +41 -21
  35. package/front_end/panels/elements/ElementsPanel.ts +18 -5
  36. package/front_end/panels/elements/ElementsTreeElement.ts +173 -169
  37. package/front_end/panels/elements/NodeStackTraceWidget.ts +3 -13
  38. package/front_end/panels/elements/StylesAiCodeCompletionProvider.ts +69 -0
  39. package/front_end/panels/elements/computedStyleWidget.css +1 -6
  40. package/front_end/panels/elements/elements.ts +3 -1
  41. package/front_end/panels/issues/AffectedResourcesView.ts +1 -2
  42. package/front_end/panels/network/NetworkDataGridNode.ts +0 -8
  43. package/front_end/panels/network/RequestConditionsDrawer.ts +138 -112
  44. package/front_end/panels/network/RequestInitiatorView.ts +2 -10
  45. package/front_end/panels/settings/SettingsScreen.ts +12 -4
  46. package/front_end/panels/snippets/SnippetsQuickOpen.ts +6 -9
  47. package/front_end/panels/sources/CallStackSidebarPane.ts +4 -6
  48. package/front_end/panels/sources/DebuggerPlugin.ts +2 -1
  49. package/front_end/panels/sources/GoToLineQuickOpen.ts +0 -4
  50. package/front_end/panels/sources/OpenFileQuickOpen.ts +0 -4
  51. package/front_end/panels/sources/OutlineQuickOpen.ts +0 -4
  52. package/front_end/panels/sources/WatchExpressionsSidebarPane.ts +3 -1
  53. package/front_end/panels/sources/sources-meta.ts +9 -6
  54. package/front_end/panels/timeline/TimelineFlameChartView.ts +0 -12
  55. package/front_end/panels/timeline/TimelinePanel.ts +35 -15
  56. package/front_end/panels/timeline/TimelineUIUtils.ts +2 -6
  57. package/front_end/panels/timeline/components/Sidebar.ts +21 -0
  58. package/front_end/panels/timeline/components/insights/BaseInsightComponent.ts +1 -20
  59. package/front_end/panels/timeline/components/insights/InsightRenderer.ts +0 -1
  60. package/front_end/third_party/chromium/README.chromium +1 -1
  61. package/front_end/third_party/puppeteer/README.chromium +2 -2
  62. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/BrowsingContext.d.ts +1 -1
  63. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/BrowsingContext.d.ts.map +1 -1
  64. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/BrowsingContext.js +1 -1
  65. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/BrowsingContext.js.map +1 -1
  66. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/ChromeLauncher.d.ts.map +1 -1
  67. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/ChromeLauncher.js +2 -3
  68. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/ChromeLauncher.js.map +1 -1
  69. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.d.ts +2 -2
  70. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js +2 -2
  71. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/encoding.d.ts.map +1 -1
  72. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/encoding.js +5 -3
  73. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/encoding.js.map +1 -1
  74. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.d.ts +1 -1
  75. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.js +1 -1
  76. package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +8 -6
  77. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/BrowsingContext.d.ts +1 -1
  78. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/BrowsingContext.d.ts.map +1 -1
  79. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/BrowsingContext.js +1 -1
  80. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/BrowsingContext.js.map +1 -1
  81. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/ChromeLauncher.d.ts.map +1 -1
  82. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/ChromeLauncher.js +2 -3
  83. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/ChromeLauncher.js.map +1 -1
  84. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.d.ts +2 -2
  85. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js +2 -2
  86. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/encoding.d.ts.map +1 -1
  87. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/encoding.js +5 -3
  88. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/encoding.js.map +1 -1
  89. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.d.ts +1 -1
  90. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.js +1 -1
  91. package/front_end/third_party/puppeteer/package/package.json +4 -4
  92. package/front_end/third_party/puppeteer/package/src/bidi/Page.ts +1 -1
  93. package/front_end/third_party/puppeteer/package/src/bidi/core/BrowsingContext.ts +2 -2
  94. package/front_end/third_party/puppeteer/package/src/node/ChromeLauncher.ts +4 -3
  95. package/front_end/third_party/puppeteer/package/src/revisions.ts +2 -2
  96. package/front_end/third_party/puppeteer/package/src/util/encoding.ts +5 -3
  97. package/front_end/third_party/puppeteer/package/src/util/version.ts +1 -1
  98. package/front_end/ui/components/linkifier/LinkifierImpl.ts +3 -0
  99. package/front_end/ui/components/linkifier/LinkifierUtils.ts +3 -0
  100. package/front_end/ui/components/text_editor/AiCodeGenerationParser.ts +29 -7
  101. package/front_end/ui/components/text_editor/AiCodeGenerationProvider.ts +34 -18
  102. package/front_end/ui/legacy/InspectorView.ts +41 -15
  103. package/front_end/ui/legacy/UIUtils.ts +30 -6
  104. package/front_end/ui/legacy/components/quick_open/CommandMenu.ts +4 -3
  105. package/front_end/ui/legacy/components/quick_open/FilteredListWidget.ts +2 -1
  106. package/front_end/ui/legacy/components/quick_open/HelpQuickOpen.ts +8 -2
  107. package/front_end/ui/legacy/components/quick_open/QuickOpen.ts +8 -8
  108. package/front_end/ui/legacy/components/utils/JSPresentationUtils.ts +20 -150
  109. package/front_end/ui/legacy/components/utils/Linkifier.ts +120 -87
  110. package/front_end/ui/legacy/components/utils/jsUtils.css +0 -9
  111. package/front_end/ui/legacy/legacy.ts +0 -2
  112. package/front_end/ui/visual_logging/KnownContextValues.ts +3 -0
  113. package/mcp/HostBindings.ts +3 -0
  114. package/package.json +1 -1
  115. package/front_end/models/issues_manager/descriptions/corsInsecurePrivateNetwork.md +0 -10
  116. package/front_end/models/issues_manager/descriptions/corsPreflightAllowPrivateNetworkError.md +0 -10
  117. package/front_end/models/issues_manager/descriptions/corsPrivateNetworkPermissionDenied.md +0 -10
  118. package/front_end/ui/legacy/Floaty.ts +0 -438
  119. package/front_end/ui/legacy/floaty.css +0 -77
@@ -1,438 +0,0 @@
1
- // Copyright 2025 The Chromium Authors
2
- // Use of this source code is governed by a BSD-style license that can be
3
- // found in the LICENSE file.
4
-
5
- import * as i18n from '../../core/i18n/i18n.js';
6
- import * as Platform from '../../core/platform/platform.js';
7
- import * as SDK from '../../core/sdk/sdk.js';
8
- import type * as Protocol from '../../generated/protocol.js';
9
- import * as GreenDev from '../../models/greendev/greendev.js';
10
- import * as Logs from '../../models/logs/logs.js';
11
- import * as Trace from '../../models/trace/trace.js';
12
- import * as Buttons from '../components/buttons/buttons.js';
13
- import {html, render, type TemplateResult} from '../lit/lit.js';
14
-
15
- import {Context} from './Context.js';
16
- import floatyStyles from './floaty.css.js';
17
- import {Widget} from './Widget.js';
18
-
19
- let instance: Floaty|null = null;
20
-
21
- export const enum FloatyContextTypes {
22
- ELEMENT_NODE_ID = 'ELEMENT_NODE_ID',
23
- NETWORK_REQUEST = 'NETWORK_REQUEST',
24
- PERFORMANCE_EVENT = 'PERFORMANCE_EVENT',
25
- PERFORMANCE_INSIGHT = 'PERFORMANCE_INSIGHT'
26
- }
27
-
28
- export type FloatyContextSelection = SDK.DOMModel.DOMNode|SDK.NetworkRequest.NetworkRequest|
29
- {event: Trace.Types.Events.Event, traceStartTime: Trace.Types.Timing.Micro}|
30
- {insight: Trace.Insights.Types.InsightModel, trace: Trace.TraceModel.ParsedTrace};
31
-
32
- const enum State {
33
- READONLY = 'readonly',
34
- INSPECT_MODE = 'inspect',
35
- }
36
-
37
- export class FloatyFlavor {
38
- selectedContexts: FloatyContextSelection[] = [];
39
-
40
- constructor(contexts: Set<FloatyContextSelection>) {
41
- this.selectedContexts = Array.from(contexts);
42
- }
43
- }
44
-
45
- export class Floaty {
46
- static defaultVisibility = false;
47
-
48
- #container: HTMLElement;
49
- #floaty: FloatyUI;
50
-
51
- #boundKeyDown = this.#onKeyShortcut.bind(this);
52
-
53
- static exists(): boolean {
54
- return instance !== null;
55
- }
56
-
57
- static instance(opts: {
58
- forceNew: boolean|null,
59
- document: Document|null,
60
- } = {forceNew: null, document: null}): Floaty {
61
- if (instance) {
62
- return instance;
63
- }
64
- if (!opts.document) {
65
- throw new Error('document required');
66
- }
67
- instance = new Floaty(opts.document);
68
- return instance;
69
- }
70
-
71
- private constructor(document: Document) {
72
- // eslint-disable-next-line @devtools/no-imperative-dom-api
73
- this.#container = document.createElement('div');
74
- this.#container.classList.add('floaty-container');
75
- this.#floaty = new FloatyUI();
76
- this.#floaty.markAsRoot();
77
- this.#insertIntoDOM();
78
- }
79
-
80
- #onKeyShortcut(e: KeyboardEvent): void {
81
- const origin = e.composedPath().at(0);
82
- // If the user was typing into an input field, don't make it trigger the Floaty.
83
- if (origin && (origin instanceof HTMLTextAreaElement || origin instanceof HTMLInputElement)) {
84
- return;
85
- }
86
- if (e.key === 'f') {
87
- this.open();
88
- }
89
- }
90
-
91
- #insertIntoDOM(): void {
92
- if (GreenDev.Prototypes.instance().isEnabled('inDevToolsFloaty')) {
93
- this.#floaty.show(this.#container);
94
- document.body.appendChild(this.#container);
95
- document.body.addEventListener('keydown', this.#boundKeyDown);
96
- }
97
- }
98
-
99
- setDevToolsRect(rect: DOMRect): void {
100
- this.#floaty.devtoolsRect = rect;
101
- }
102
-
103
- open(): void {
104
- this.#floaty.open = true;
105
- }
106
-
107
- registerClick(input: Readonly<FloatyClickInput>): void {
108
- if (this.#floaty.state !== State.INSPECT_MODE) {
109
- return;
110
- }
111
-
112
- const type = input.type; // Switching on type, rather than input.type, means TS narrows it properly.
113
- switch (type) {
114
- case FloatyContextTypes.ELEMENT_NODE_ID: {
115
- const mainTarget = SDK.TargetManager.TargetManager.instance().primaryPageTarget();
116
- if (!mainTarget) {
117
- return;
118
- }
119
- const domModel = mainTarget.model(SDK.DOMModel.DOMModel);
120
- const node = domModel?.nodeForId(input.data.nodeId);
121
- if (node) {
122
- this.#floaty.addSelectedContext(node);
123
- }
124
- break;
125
- }
126
- case FloatyContextTypes.NETWORK_REQUEST: {
127
- const networkRequests = Logs.NetworkLog.NetworkLog.instance().requestsForId(input.data.requestId);
128
- for (const req of networkRequests) {
129
- this.#floaty.addSelectedContext(req);
130
- }
131
- break;
132
- }
133
- case FloatyContextTypes.PERFORMANCE_EVENT: {
134
- this.#floaty.addSelectedContext(input.data);
135
- break;
136
- }
137
- case FloatyContextTypes.PERFORMANCE_INSIGHT: {
138
- this.#floaty.addSelectedContext(input.data);
139
- break;
140
- }
141
- default:
142
- Platform.assertNever(type, 'Unsupported Floaty Context type');
143
- }
144
- }
145
-
146
- inInspectMode(): boolean {
147
- return this.#floaty.state === State.INSPECT_MODE;
148
- }
149
-
150
- deleteContext(context: FloatyContextSelection): void {
151
- this.#floaty.removeSelectedContext(context);
152
- }
153
- }
154
-
155
- type FloatyClickInput = {
156
- type: FloatyContextTypes.ELEMENT_NODE_ID,
157
- data: {nodeId: Protocol.DOM.NodeId},
158
- }|{
159
- type: FloatyContextTypes.NETWORK_REQUEST,
160
- data: {requestId: string},
161
- }|{
162
- type: FloatyContextTypes.PERFORMANCE_EVENT,
163
- data: {event: Trace.Types.Events.Event, traceStartTime: Trace.Types.Timing.Micro},
164
- }|{
165
- type: FloatyContextTypes.PERFORMANCE_INSIGHT,
166
- data: {
167
- insight: Trace.Insights.Types.InsightModel,
168
- trace: Trace.TraceModel.ParsedTrace,
169
- },
170
- };
171
-
172
- export function onFloatyOpen(): void {
173
- if (!GreenDev.Prototypes.instance().isEnabled('inDevToolsFloaty')) {
174
- return;
175
- }
176
- Floaty.instance().open();
177
- }
178
-
179
- export function onFloatyContextDelete(context: FloatyContextSelection): void {
180
- if (!GreenDev.Prototypes.instance().isEnabled('inDevToolsFloaty')) {
181
- return;
182
- }
183
- Floaty.instance().deleteContext(context);
184
- }
185
-
186
- /**
187
- * Registers a click to the Floaty.
188
- * @returns true if the element was added to the floaty context, and false
189
- * otherwise. This lets callers determine if this should override the default
190
- * click behaviour.
191
- */
192
- export function onFloatyClick(input: FloatyClickInput): boolean {
193
- if (!GreenDev.Prototypes.instance().isEnabled('inDevToolsFloaty')) {
194
- return false;
195
- }
196
- const floaty = Floaty.instance();
197
- if (floaty.inInspectMode()) {
198
- floaty.registerClick(input);
199
- return true;
200
- }
201
- return false;
202
- }
203
-
204
- export class FloatyUI extends Widget {
205
- #view: (input: ViewInput, output: null, target: HTMLElement) => void;
206
- #dialog: HTMLDialogElement|null = null;
207
- #initialMouseX = 0;
208
- #initialMouseY = 0;
209
- #initialDialogLeft = 0;
210
- #initialDialogTop = 0;
211
- #devtoolsRect: DOMRect|null = null;
212
- #selectedContexts = new Set<FloatyContextSelection>();
213
- #open = Floaty.defaultVisibility;
214
- #state = State.READONLY;
215
-
216
- constructor(element?: HTMLElement, view = VIEW) {
217
- super(element);
218
- this.#view = view;
219
- }
220
-
221
- get devtoolsRect(): DOMRect|null {
222
- return this.#devtoolsRect;
223
- }
224
-
225
- get state(): State {
226
- return this.#state;
227
- }
228
-
229
- set state(x: State) {
230
- this.#state = x;
231
- this.requestUpdate();
232
- }
233
-
234
- set devtoolsRect(rect: DOMRect) {
235
- this.#devtoolsRect = rect;
236
- this.#repositionWithNewRect(rect);
237
- this.requestUpdate();
238
- }
239
-
240
- addSelectedContext(context: FloatyContextSelection): void {
241
- if (this.#selectedContexts.has(context)) {
242
- return;
243
- }
244
-
245
- this.#selectedContexts.add(context);
246
- Context.instance().setFlavor(FloatyFlavor, new FloatyFlavor(this.#selectedContexts));
247
- this.requestUpdate();
248
- }
249
-
250
- removeSelectedContext(context: FloatyContextSelection): void {
251
- this.#selectedContexts.delete(context);
252
- this.#state = State.READONLY;
253
- Context.instance().setFlavor(FloatyFlavor, new FloatyFlavor(this.#selectedContexts));
254
- this.requestUpdate();
255
- }
256
-
257
- get open(): boolean {
258
- return this.#open;
259
- }
260
-
261
- set open(open: boolean) {
262
- this.#open = open;
263
- this.requestUpdate();
264
- }
265
-
266
- override wasShown(): void {
267
- super.wasShown();
268
- this.requestUpdate();
269
- }
270
-
271
- #repositionWithNewRect(rect: DOMRect): void {
272
- if (!this.#dialog) {
273
- return;
274
- }
275
- const computedStyle = window.getComputedStyle(this.#dialog);
276
- const currentLeft = parseInt(computedStyle.left, 10);
277
- const currentTop = parseInt(computedStyle.top, 10);
278
- this.#dialog.style.left = `${Math.max(currentLeft, rect.left)}px`;
279
- this.#dialog.style.top = `${Math.max(currentTop, rect.top)}px`;
280
- }
281
-
282
- #onInspectClick(): void {
283
- if (this.#state === State.INSPECT_MODE) {
284
- this.#state = State.READONLY;
285
- } else {
286
- this.#state = State.INSPECT_MODE;
287
- }
288
- this.requestUpdate();
289
- }
290
-
291
- #onDialogClose(e: PointerEvent): void {
292
- e.preventDefault();
293
- this.#open = false;
294
- this.requestUpdate();
295
- }
296
-
297
- #onContextDelete(context: FloatyContextSelection): (e: MouseEvent) => void {
298
- return e => {
299
- e.preventDefault();
300
- this.removeSelectedContext(context);
301
- };
302
- }
303
-
304
- override performUpdate(): void {
305
- this.#view(
306
- {
307
- open: this.open,
308
- onDragStart: this.#onDragStart,
309
- selectedContexts: this.#selectedContexts,
310
- state: this.#state,
311
- onInspectClick: this.#onInspectClick.bind(this),
312
- onDialogClose: this.#onDialogClose.bind(this),
313
- onContextDelete: this.#onContextDelete.bind(this)
314
- },
315
- null, this.contentElement);
316
- this.#dialog = this.contentElement.querySelector('dialog');
317
- }
318
-
319
- #onDragStart = (event: MouseEvent): void => {
320
- if (!this.#dialog) {
321
- return;
322
- }
323
- this.#initialMouseX = event.clientX;
324
- this.#initialMouseY = event.clientY;
325
- const computedStyle = window.getComputedStyle(this.#dialog);
326
- this.#initialDialogLeft = parseInt(computedStyle.left, 10);
327
- this.#initialDialogTop = parseInt(computedStyle.top, 10);
328
-
329
- document.addEventListener('mousemove', this.#onDrag);
330
- document.addEventListener('mouseup', this.#onDragEnd);
331
- };
332
-
333
- #onDrag = (event: MouseEvent): void => {
334
- if (!this.#dialog) {
335
- return;
336
- }
337
- const deltaX = event.clientX - this.#initialMouseX;
338
- const deltaY = event.clientY - this.#initialMouseY;
339
-
340
- const minLeft = this.#devtoolsRect?.left ?? 0;
341
- const minTop = this.#devtoolsRect?.top ?? 0;
342
- const newLeft = Math.max(minLeft, this.#initialDialogLeft + deltaX);
343
- const newTop = Math.max(minTop, this.#initialDialogTop + deltaY);
344
- this.#dialog.style.left = `${newLeft}px`;
345
- this.#dialog.style.top = `${newTop}px`;
346
- };
347
-
348
- #onDragEnd = (): void => {
349
- document.removeEventListener('mousemove', this.#onDrag);
350
- document.removeEventListener('mouseup', this.#onDragEnd);
351
- };
352
- }
353
-
354
- interface ViewInput {
355
- onDragStart: (event: MouseEvent) => void;
356
- selectedContexts: ReadonlySet<FloatyContextSelection>;
357
- open: boolean;
358
- state: State;
359
- onInspectClick: () => void;
360
- onDialogClose: (e: PointerEvent) => void;
361
- onContextDelete: (item: FloatyContextSelection) => (e: MouseEvent) => void;
362
- }
363
-
364
- const VIEW = (input: ViewInput, _output: null, target: HTMLElement): void => {
365
- const contexts = Array.from(input.selectedContexts);
366
- // clang-format off
367
- render(html`
368
- <style>${floatyStyles}</style>
369
- <dialog ?open=${input.open} @mousedown=${input.onDragStart}>
370
- <header>
371
- <span>DevTools context picker</span>
372
- <devtools-button
373
- class="close-button"
374
- @click=${input.onDialogClose}
375
- .data=${{
376
- variant: Buttons.Button.Variant.TOOLBAR,
377
- iconName: 'cross',
378
- title: 'Close',
379
- size: Buttons.Button.Size.SMALL,
380
- } as Buttons.Button.ButtonData}
381
- ></devtools-button>
382
- </header>
383
- <section class="body">
384
- <section class="contexts">
385
- ${contexts.length === 0 ? html`
386
- <span class="no-context">Select items to add them to the AI agent's context.</span>
387
- ` : html`
388
- <ul class="floaty-contexts">
389
- ${contexts.map(context => {
390
- return html`<li>
391
- <span class="context-item">
392
- ${floatyContextToUI(context)}
393
- </span>
394
- <devtools-button
395
- class="close-button"
396
- @click=${input.onContextDelete(context)}
397
- .data=${{
398
- variant: Buttons.Button.Variant.TOOLBAR,
399
- iconName: 'cross',
400
- title: 'Delete',
401
- size: Buttons.Button.Size.SMALL,
402
- } as Buttons.Button.ButtonData}
403
- ></devtools-button>
404
- </li>`;
405
- })}
406
- </ul>
407
- `}
408
- </section>
409
- <section class="actions">
410
- <devtools-button title="Select" @click=${input.onInspectClick}
411
- .active=${input.state === State.INSPECT_MODE}
412
- .variant=${Buttons.Button.Variant.TONAL} .iconName=${'select-element'}
413
- >Select</devtools-button>
414
- </devtools-toolbar>
415
- </section>
416
- </section>
417
- </dialog>`,
418
- target);
419
- // clang-format on
420
- };
421
-
422
- function floatyContextToUI(context: FloatyContextSelection): TemplateResult {
423
- if (context instanceof SDK.NetworkRequest.NetworkRequest) {
424
- return html`${context.url()}`;
425
- }
426
- if (context instanceof SDK.DOMModel.DOMNode) {
427
- return html`${context.simpleSelector()}`;
428
- }
429
- if ('insight' in context) {
430
- return html`Insight: ${context.insight.title}`;
431
- }
432
- if ('event' in context && 'traceStartTime' in context) {
433
- const time = Trace.Types.Timing.Micro(context.event.ts - context.traceStartTime);
434
- return html`${context.event.name} @ ${i18n.TimeUtilities.formatMicroSecondsAsMillisFixed(time)}`;
435
- }
436
-
437
- Platform.assertNever(context, '');
438
- }
@@ -1,77 +0,0 @@
1
- /*
2
- * Copyright 2025 The Chromium Authors
3
- * Use of this source code is governed by a BSD-style license that can be
4
- * found in the LICENSE file.
5
- */
6
-
7
- dialog {
8
- position: absolute;
9
- top: 20px;
10
- left: 20px;
11
- max-width: 400px;
12
- min-width: 200px;
13
- min-height: 100px;
14
- max-height: 400px;
15
- overflow-y: auto;
16
- margin: 0;
17
- padding: 0;
18
- box-shadow: var(--drop-shadow);
19
- background: var(--sys-color-tonal-container);
20
- border-radius: var(--sys-shape-corner-medium-small);
21
- border: none;
22
- flex-direction: column;
23
-
24
- header {
25
- padding: var(--sys-size-6);
26
-
27
- span {
28
- font: var(--sys-typescale-headline5);
29
- }
30
-
31
- display: flex;
32
- align-items: flex-start;
33
-
34
- .close-button {
35
- margin-left: auto;
36
- }
37
- }
38
-
39
- section.body {
40
- border-radius: var(--sys-shape-corner-medium-small);
41
- background: var(--sys-color-surface);
42
- height: 100%;
43
- padding: var(--sys-size-6);
44
- }
45
-
46
- .floaty-contexts {
47
- padding: 0;
48
- margin: 0;
49
- display: flex;
50
- flex-direction: column;
51
- gap: 5px;
52
-
53
- li {
54
- overflow: hidden;
55
- text-overflow: ellipsis;
56
- padding: var(--sys-size-2) var(--sys-size-3);
57
- border-radius: var(--sys-shape-corner-extra-small);
58
- border: 1px solid var(--sys-color-tonal-outline);
59
- font: var(--sys-typescale-monospace-regular);
60
- display: flex;
61
- align-items: center;
62
- justify-content: flex-start;
63
-
64
- devtools-button {
65
- margin-left: auto;
66
- }
67
- }
68
- }
69
-
70
- section.actions {
71
- margin-top: var(--sys-size-7);
72
- }
73
- }
74
-
75
- dialog[open] {
76
- display: flex;
77
- }