chrome-devtools-frontend 1.0.1618066 → 1.0.1621678
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.
- package/docs/checklist/README.md +8 -7
- package/eslint.config.mjs +7 -0
- package/front_end/core/sdk/NetworkManager.ts +23 -2
- package/front_end/core/sdk/ServerSentEventsProtocol.ts +1 -1
- package/front_end/entrypoints/greendev_floaty/FloatyEntrypoint.ts +119 -13
- package/front_end/generated/InspectorBackendCommands.ts +7 -7
- package/front_end/generated/SupportedCSSProperties.js +100 -100
- package/front_end/generated/protocol-mapping.d.ts +1 -9
- package/front_end/generated/protocol-proxy-api.d.ts +1 -9
- package/front_end/generated/protocol.ts +6 -1
- package/front_end/models/ai_assistance/agents/AiAgent.ts +1 -1
- package/front_end/models/ai_assistance/agents/GreenDevAgent.ts +512 -0
- package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +95 -104
- package/front_end/models/ai_assistance/agents/StylingAgent.ts +9 -16
- package/front_end/models/ai_assistance/ai_assistance.ts +2 -0
- package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +25 -4
- package/front_end/models/bindings/SymbolizedError.ts +86 -2
- package/front_end/models/issues_manager/GenericIssue.ts +50 -1
- package/front_end/models/issues_manager/descriptions/genericFormModelContextMissingToolDescription.md +5 -0
- package/front_end/models/issues_manager/descriptions/genericFormModelContextMissingToolName.md +5 -0
- package/front_end/models/issues_manager/descriptions/genericFormModelContextParameterMissingName.md +5 -0
- package/front_end/models/issues_manager/descriptions/genericFormModelContextParameterMissingTitleAndDescription.md +5 -0
- package/front_end/models/issues_manager/descriptions/genericFormModelContextRequiredParameterMissingName.md +5 -0
- package/front_end/models/javascript_metadata/NativeFunctions.js +10 -2
- package/front_end/models/stack_trace/DetailedErrorStackParser.ts +11 -3
- package/front_end/models/stack_trace/ErrorStackParser.ts +18 -0
- package/front_end/models/trace/insights/Common.ts +4 -0
- package/front_end/models/trace/insights/types.ts +1 -1
- package/front_end/models/web_mcp/WebMCPModel.ts +11 -1
- package/front_end/panels/ai_assistance/components/ChatMessage.ts +115 -3
- package/front_end/panels/ai_assistance/components/WalkthroughUtils.ts +1 -1
- package/front_end/panels/ai_assistance/components/WalkthroughView.ts +9 -2
- package/front_end/panels/application/WebMCPView.ts +217 -85
- package/front_end/panels/application/webMCPView.css +260 -199
- package/front_end/panels/browser_debugger/CategorizedBreakpointsSidebarPane.ts +9 -5
- package/front_end/panels/changes/ChangesSidebar.ts +2 -2
- package/front_end/panels/changes/ChangesView.ts +4 -7
- package/front_end/panels/console/ConsoleViewMessage.ts +1 -19
- package/front_end/panels/coverage/CoverageView.ts +4 -5
- package/front_end/panels/elements/AdoptedStyleSheetTreeElement.ts +0 -1
- package/front_end/panels/elements/ElementsPanel.ts +9 -12
- package/front_end/panels/elements/ElementsTreeElement.ts +53 -61
- package/front_end/panels/elements/PropertiesWidget.ts +1 -1
- package/front_end/panels/elements/StylePropertiesSection.ts +1 -1
- package/front_end/panels/elements/components/ElementsBreadcrumbs.ts +19 -20
- package/front_end/panels/elements/components/ElementsBreadcrumbsUtils.ts +29 -29
- package/front_end/panels/elements/components/QueryContainer.ts +5 -6
- package/front_end/panels/elements/components/components.ts +0 -2
- package/front_end/panels/emulation/MediaQueryInspector.ts +4 -7
- package/front_end/panels/mobile_throttling/NetworkThrottlingSelector.ts +47 -66
- package/front_end/panels/network/RequestConditionsDrawer.ts +6 -4
- package/front_end/panels/performance_monitor/PerformanceMonitor.ts +6 -9
- package/front_end/panels/protocol_monitor/JSONEditor.ts +2 -2
- package/front_end/panels/search/SearchView.ts +4 -7
- package/front_end/panels/sources/DebuggerPausedMessage.ts +18 -22
- package/front_end/panels/sources/ThreadsSidebarPane.ts +2 -4
- package/front_end/panels/web_audio/WebAudioView.ts +5 -4
- package/front_end/third_party/chromium/README.chromium +1 -1
- package/front_end/ui/components/icon_button/iconButton.css +1 -0
- package/front_end/ui/components/lists/list.css +4 -0
- package/front_end/ui/components/text_editor/TextEditor.ts +1 -3
- package/front_end/ui/legacy/Treeoutline.ts +5 -1
- package/front_end/ui/legacy/ViewRegistration.ts +2 -2
- package/front_end/ui/legacy/Widget.ts +9 -2
- package/front_end/ui/legacy/components/utils/Linkifier.ts +32 -11
- package/front_end/ui/visual_logging/KnownContextValues.ts +19 -0
- package/package.json +1 -1
- package/front_end/Images/src/dots-circle.svg +0 -10
- package/front_end/panels/elements/components/Helper.ts +0 -35
|
@@ -193,6 +193,31 @@ export const genericNavigationEntryMarkedSkippable = {
|
|
|
193
193
|
}],
|
|
194
194
|
};
|
|
195
195
|
|
|
196
|
+
export const genericFormModelContextMissingToolName = {
|
|
197
|
+
file: 'genericFormModelContextMissingToolName.md',
|
|
198
|
+
links: [],
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
export const genericFormModelContextMissingToolDescription = {
|
|
202
|
+
file: 'genericFormModelContextMissingToolDescription.md',
|
|
203
|
+
links: [],
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
export const genericFormModelContextParameterMissingTitleAndDescription = {
|
|
207
|
+
file: 'genericFormModelContextParameterMissingTitleAndDescription.md',
|
|
208
|
+
links: [],
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export const genericFormModelContextRequiredParameterMissingName = {
|
|
212
|
+
file: 'genericFormModelContextRequiredParameterMissingName.md',
|
|
213
|
+
links: [],
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
export const genericFormModelContextParameterMissingName = {
|
|
217
|
+
file: 'genericFormModelContextParameterMissingName.md',
|
|
218
|
+
links: [],
|
|
219
|
+
};
|
|
220
|
+
|
|
196
221
|
const issueDescriptions = new Map<Protocol.Audits.GenericIssueErrorType, LazyMarkdownIssueDescription>([
|
|
197
222
|
[Protocol.Audits.GenericIssueErrorType.FormLabelForNameError, genericFormLabelForNameError],
|
|
198
223
|
[Protocol.Audits.GenericIssueErrorType.FormInputWithNoLabelError, genericFormInputWithNoLabelError],
|
|
@@ -233,6 +258,26 @@ const issueDescriptions = new Map<Protocol.Audits.GenericIssueErrorType, LazyMar
|
|
|
233
258
|
Protocol.Audits.GenericIssueErrorType.NavigationEntryMarkedSkippable,
|
|
234
259
|
genericNavigationEntryMarkedSkippable,
|
|
235
260
|
],
|
|
261
|
+
[
|
|
262
|
+
Protocol.Audits.GenericIssueErrorType.FormModelContextMissingToolName,
|
|
263
|
+
genericFormModelContextMissingToolName,
|
|
264
|
+
],
|
|
265
|
+
[
|
|
266
|
+
Protocol.Audits.GenericIssueErrorType.FormModelContextMissingToolDescription,
|
|
267
|
+
genericFormModelContextMissingToolDescription,
|
|
268
|
+
],
|
|
269
|
+
[
|
|
270
|
+
Protocol.Audits.GenericIssueErrorType.FormModelContextParameterMissingTitleAndDescription,
|
|
271
|
+
genericFormModelContextParameterMissingTitleAndDescription,
|
|
272
|
+
],
|
|
273
|
+
[
|
|
274
|
+
Protocol.Audits.GenericIssueErrorType.FormModelContextRequiredParameterMissingName,
|
|
275
|
+
genericFormModelContextRequiredParameterMissingName,
|
|
276
|
+
],
|
|
277
|
+
[
|
|
278
|
+
Protocol.Audits.GenericIssueErrorType.FormModelContextParameterMissingName,
|
|
279
|
+
genericFormModelContextParameterMissingName,
|
|
280
|
+
],
|
|
236
281
|
]);
|
|
237
282
|
|
|
238
283
|
const issueTypes = new Map<Protocol.Audits.GenericIssueErrorType, IssueKind>([
|
|
@@ -249,5 +294,9 @@ const issueTypes = new Map<Protocol.Audits.GenericIssueErrorType, IssueKind>([
|
|
|
249
294
|
[Protocol.Audits.GenericIssueErrorType.FormLabelForMatchesNonExistingIdError, IssueKind.PAGE_ERROR],
|
|
250
295
|
[Protocol.Audits.GenericIssueErrorType.FormLabelHasNeitherForNorNestedInputError, IssueKind.IMPROVEMENT],
|
|
251
296
|
[Protocol.Audits.GenericIssueErrorType.FormInputHasWrongButWellIntendedAutocompleteValueError, IssueKind.IMPROVEMENT],
|
|
252
|
-
|
|
297
|
+
[Protocol.Audits.GenericIssueErrorType.FormModelContextMissingToolName, IssueKind.PAGE_ERROR],
|
|
298
|
+
[Protocol.Audits.GenericIssueErrorType.FormModelContextMissingToolDescription, IssueKind.PAGE_ERROR],
|
|
299
|
+
[Protocol.Audits.GenericIssueErrorType.FormModelContextParameterMissingTitleAndDescription, IssueKind.PAGE_ERROR],
|
|
300
|
+
[Protocol.Audits.GenericIssueErrorType.FormModelContextRequiredParameterMissingName, IssueKind.PAGE_ERROR],
|
|
301
|
+
[Protocol.Audits.GenericIssueErrorType.FormModelContextParameterMissingName, IssueKind.PAGE_ERROR],
|
|
253
302
|
]);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Missing tool description for a WebMCP declarative tool definition
|
|
2
|
+
|
|
3
|
+
This form is intended to be used as a WebMCP declarative tool definition, but it lacks a description explaining what the tool does. Descriptions are critical for AI models to decide when to use a given tool.
|
|
4
|
+
|
|
5
|
+
To fix this issue, provide a tool description via the `tooldescription` attribute.
|
package/front_end/models/issues_manager/descriptions/genericFormModelContextMissingToolName.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Missing tool name for a WebMCP declarative tool definition
|
|
2
|
+
|
|
3
|
+
This form is intended to be used as a WebMCP declarative tool definition, but it does not specify a name. A tool name is required for an AI model to correctly identify and invoke the tool.
|
|
4
|
+
|
|
5
|
+
To fix this issue, provide a tool name via the `toolname` attribute.
|
package/front_end/models/issues_manager/descriptions/genericFormModelContextParameterMissingName.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Parameter missing name for a WebMCP declarative tool definition
|
|
2
|
+
|
|
3
|
+
An input element within this form lacks a `name` attribute. Without a name, the AI model cannot format the parameter payload correctly when invoking the tool.
|
|
4
|
+
|
|
5
|
+
To fix this issue, ensure form parameters have a `name` attribute.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Missing parameter title and description for a WebMCP declarative tool definition
|
|
2
|
+
|
|
3
|
+
A parameter within this form (such as an `<input>` field) is missing both a title and a description. An AI model needs this metadata to understand what information should be passed to this parameter when invoking the tool.
|
|
4
|
+
|
|
5
|
+
To fix this issue, add a title and description to the form parameter.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Required parameter missing name for a WebMCP declarative tool definition
|
|
2
|
+
|
|
3
|
+
A required input element within this form lacks a `name` attribute. Without a name, the AI model cannot format the parameter payload correctly when invoking the tool.
|
|
4
|
+
|
|
5
|
+
To fix this issue, ensure all required form parameters have a `name` attribute.
|
|
@@ -7639,6 +7639,14 @@ export const NativeFunctions = [
|
|
|
7639
7639
|
name: "Sanitizer",
|
|
7640
7640
|
signatures: [["?configuration"]]
|
|
7641
7641
|
},
|
|
7642
|
+
{
|
|
7643
|
+
name: "allowProcessingInstruction",
|
|
7644
|
+
signatures: [["pi"]]
|
|
7645
|
+
},
|
|
7646
|
+
{
|
|
7647
|
+
name: "removeProcessingInstruction",
|
|
7648
|
+
signatures: [["pi"]]
|
|
7649
|
+
},
|
|
7642
7650
|
{
|
|
7643
7651
|
name: "TaskController",
|
|
7644
7652
|
signatures: [["?init"]]
|
|
@@ -8339,7 +8347,7 @@ export const NativeFunctions = [
|
|
|
8339
8347
|
},
|
|
8340
8348
|
{
|
|
8341
8349
|
name: "setConstraints",
|
|
8342
|
-
signatures: [["constraints"]]
|
|
8350
|
+
signatures: [["?constraints"]]
|
|
8343
8351
|
},
|
|
8344
8352
|
{
|
|
8345
8353
|
name: "createContext",
|
|
@@ -9353,7 +9361,7 @@ export const NativeFunctions = [
|
|
|
9353
9361
|
},
|
|
9354
9362
|
{
|
|
9355
9363
|
name: "copyElementImageToTexture",
|
|
9356
|
-
signatures: [["source","destination"],["source","width","height","destination"],["source","sx","sy","swidth","sheight","destination"]]
|
|
9364
|
+
signatures: [["source","destination"],["source","width","height","destination"],["source","sx","sy","swidth","sheight","destination"],["source","sx","sy","swidth","sheight","width","height","destination"]]
|
|
9357
9365
|
},
|
|
9358
9366
|
{
|
|
9359
9367
|
name: "multiDrawIndirect",
|
|
@@ -181,9 +181,17 @@ export function parseMessage(stack: string): string {
|
|
|
181
181
|
export function augmentRawFramesWithScriptIds(
|
|
182
182
|
rawFrames: RawFrame[], protocolStackTrace: Protocol.Runtime.StackTrace): void {
|
|
183
183
|
for (const rawFrame of rawFrames) {
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
184
|
+
const isWasm = rawFrame.parsedFrameInfo?.isWasm;
|
|
185
|
+
const protocolFrame = protocolStackTrace.callFrames.find(frame => {
|
|
186
|
+
if (isWasm) {
|
|
187
|
+
// The parser parses Wasm offsets into the `columnNumber` field. The `lineNumber` is always -1.
|
|
188
|
+
// In the protocol trace, the `lineNumber` is 0 (for Wasm) and `columnNumber` is the bytecode offset.
|
|
189
|
+
return rawFrame.url === frame.url && rawFrame.columnNumber === frame.columnNumber;
|
|
190
|
+
}
|
|
191
|
+
return rawFrame.url === frame.url && rawFrame.lineNumber === frame.lineNumber &&
|
|
192
|
+
rawFrame.columnNumber === frame.columnNumber;
|
|
193
|
+
});
|
|
194
|
+
|
|
187
195
|
if (protocolFrame) {
|
|
188
196
|
// @ts-expect-error scriptId is a readonly property.
|
|
189
197
|
rawFrame.scriptId = protocolFrame.scriptId;
|
|
@@ -21,6 +21,24 @@ export interface ParsedErrorFrame {
|
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Combines the error description (essentially the `Error#stack` property value)
|
|
26
|
+
* with the `issueSummary`.
|
|
27
|
+
*
|
|
28
|
+
* @param description the `description` property of the `Error` remote object.
|
|
29
|
+
* @param issueSummary the optional `issueSummary` of the `exceptionMetaData`.
|
|
30
|
+
* @returns the enriched description.
|
|
31
|
+
* @see https://goo.gle/devtools-reduce-network-noise-design
|
|
32
|
+
*/
|
|
33
|
+
export function concatErrorDescriptionAndIssueSummary(description: string, issueSummary: string): string {
|
|
34
|
+
// Insert the issue summary right after the error message.
|
|
35
|
+
const pos = description.indexOf('\n');
|
|
36
|
+
const prefix = pos === -1 ? description : description.substring(0, pos);
|
|
37
|
+
const suffix = pos === -1 ? '' : description.substring(pos);
|
|
38
|
+
description = `${prefix}. ${issueSummary}${suffix}`;
|
|
39
|
+
return description;
|
|
40
|
+
}
|
|
41
|
+
|
|
24
42
|
/**
|
|
25
43
|
* Takes a V8 Error#stack string and extracts source position information.
|
|
26
44
|
*
|
|
@@ -26,6 +26,10 @@ export function getInsight<InsightName extends keyof InsightModels>(
|
|
|
26
26
|
return insightSet.model[insightName];
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
export function isInsightKey(key: string): key is InsightKeys {
|
|
30
|
+
return Object.values(InsightKeys).includes(key as InsightKeys);
|
|
31
|
+
}
|
|
32
|
+
|
|
29
33
|
export function getLCP(insightSet: InsightSet):
|
|
30
34
|
{value: Types.Timing.Micro, event: Types.Events.AnyLargestContentfulPaintCandidate}|null {
|
|
31
35
|
const insight = getInsight(InsightKeys.LCP_BREAKDOWN, insightSet);
|
|
@@ -145,7 +145,7 @@ export type InsightModelErrors = {
|
|
|
145
145
|
*/
|
|
146
146
|
export type TraceInsightSets = Map<Types.Events.NavigationId, InsightSet>;
|
|
147
147
|
|
|
148
|
-
export
|
|
148
|
+
export enum InsightKeys {
|
|
149
149
|
LCP_BREAKDOWN = 'LCPBreakdown',
|
|
150
150
|
INP_BREAKDOWN = 'INPBreakdown',
|
|
151
151
|
CLS_CULPRITS = 'CLSCulprits',
|
|
@@ -90,6 +90,7 @@ export interface Call {
|
|
|
90
90
|
tool: Tool;
|
|
91
91
|
input: string;
|
|
92
92
|
result?: Result;
|
|
93
|
+
cancel: () => void;
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
export class Tool {
|
|
@@ -244,7 +245,16 @@ export class WebMCPModel extends SDK.SDKModel.SDKModel<EventTypes> implements Pr
|
|
|
244
245
|
if (!tool) {
|
|
245
246
|
return;
|
|
246
247
|
}
|
|
247
|
-
const call: Call = {
|
|
248
|
+
const call: Call = {
|
|
249
|
+
tool,
|
|
250
|
+
input: params.input,
|
|
251
|
+
invocationId: params.invocationId,
|
|
252
|
+
cancel: () => {
|
|
253
|
+
if (call.result === undefined) {
|
|
254
|
+
void this.agent.invoke_cancelInvocation({invocationId: params.invocationId});
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
};
|
|
248
258
|
this.#calls.set(params.invocationId, call);
|
|
249
259
|
this.dispatchEventToListeners(Events.TOOL_INVOKED, call);
|
|
250
260
|
}
|
|
@@ -201,6 +201,10 @@ const UIStringsNotTranslate = {
|
|
|
201
201
|
* @description Accessible label for the reveal button in the LCP breakdown widget.
|
|
202
202
|
*/
|
|
203
203
|
revealLcpBreakdown: 'Reveal LCP breakdown',
|
|
204
|
+
/**
|
|
205
|
+
* @description Accessible label for the reveal button in the render-blocking requests widget.
|
|
206
|
+
*/
|
|
207
|
+
revealRenderBlockingBreakdown: 'Reveal render-blocking requests',
|
|
204
208
|
/**
|
|
205
209
|
* @description Accessible label for the reveal button in the LCP element widget.
|
|
206
210
|
*/
|
|
@@ -221,6 +225,10 @@ const UIStringsNotTranslate = {
|
|
|
221
225
|
* @description Title for the LCP breakdown widget.
|
|
222
226
|
*/
|
|
223
227
|
lcpBreakdown: 'LCP breakdown',
|
|
228
|
+
/**
|
|
229
|
+
* @description Title for the render-blocking requests widget.
|
|
230
|
+
*/
|
|
231
|
+
renderBlockingBreakdown: 'Render-blocking requests',
|
|
224
232
|
/**
|
|
225
233
|
* @description Title for the LCP element widget.
|
|
226
234
|
*/
|
|
@@ -272,6 +280,12 @@ export interface StepPart {
|
|
|
272
280
|
step: Step;
|
|
273
281
|
}
|
|
274
282
|
|
|
283
|
+
/**
|
|
284
|
+
* Represents a part of the message that consists of one or more widgets.
|
|
285
|
+
* The agent can yield widgets directly as part of its response, separate
|
|
286
|
+
* from those returned by a specific tool call (which are encapsulated
|
|
287
|
+
* within a StepPart).
|
|
288
|
+
*/
|
|
275
289
|
export interface WidgetPart {
|
|
276
290
|
type: 'widget';
|
|
277
291
|
widgets: AiWidget[];
|
|
@@ -910,7 +924,7 @@ async function makeStylePropertiesWidget(widgetData: StylePropertiesAiWidget): P
|
|
|
910
924
|
|
|
911
925
|
async function makePerfInsightWidget(widgetData: PerfInsightAiWidget): Promise<WidgetMakerResponse|null> {
|
|
912
926
|
switch (widgetData.data.insight) {
|
|
913
|
-
case
|
|
927
|
+
case Trace.Insights.Types.InsightKeys.LCP_BREAKDOWN: {
|
|
914
928
|
const insight = widgetData.data.insightData;
|
|
915
929
|
if (!insight || !Trace.Insights.Models.LCPBreakdown.isLCPBreakdownInsight(insight)) {
|
|
916
930
|
return null;
|
|
@@ -932,6 +946,28 @@ async function makePerfInsightWidget(widgetData: PerfInsightAiWidget): Promise<W
|
|
|
932
946
|
jslogContext: 'lcp-breakdown',
|
|
933
947
|
};
|
|
934
948
|
}
|
|
949
|
+
case Trace.Insights.Types.InsightKeys.RENDER_BLOCKING: {
|
|
950
|
+
const insight = widgetData.data.insightData;
|
|
951
|
+
if (!insight || !Trace.Insights.Models.RenderBlocking.isRenderBlockingInsight(insight)) {
|
|
952
|
+
return null;
|
|
953
|
+
}
|
|
954
|
+
// clang-format off
|
|
955
|
+
const renderedWidget = html`<devtools-widget
|
|
956
|
+
class="render-blocking-widget"
|
|
957
|
+
${widget(TimelineInsights.RenderBlocking.RenderBlocking, {
|
|
958
|
+
model: insight,
|
|
959
|
+
minimal: true,
|
|
960
|
+
})}></devtools-widget>`;
|
|
961
|
+
// clang-format on
|
|
962
|
+
|
|
963
|
+
return {
|
|
964
|
+
renderedWidget,
|
|
965
|
+
revealable: new TimelineUtils.Helpers.RevealableInsight(insight),
|
|
966
|
+
accessibleRevealLabel: lockedString(UIStringsNotTranslate.revealRenderBlockingBreakdown),
|
|
967
|
+
title: lockedString(UIStringsNotTranslate.renderBlockingBreakdown),
|
|
968
|
+
jslogContext: 'render-blocking-widget',
|
|
969
|
+
};
|
|
970
|
+
}
|
|
935
971
|
default:
|
|
936
972
|
return null;
|
|
937
973
|
}
|
|
@@ -1111,8 +1147,82 @@ async function makeDomTreeWidget(widgetData: DomTreeAiWidget): Promise<WidgetMak
|
|
|
1111
1147
|
*
|
|
1112
1148
|
* This allows for a flexible and extensible system where new widget types
|
|
1113
1149
|
* can be added to the AI responses and rendered in DevTools by adding
|
|
1114
|
-
* corresponding
|
|
1150
|
+
* corresponding `make...Widget` functions and handling them here.
|
|
1151
|
+
*/
|
|
1152
|
+
/**
|
|
1153
|
+
* Generates a deterministic unique identifier for a given AiWidget based on
|
|
1154
|
+
* its name and identifying data. This signature is used for widget deduplication.
|
|
1155
|
+
*/
|
|
1156
|
+
export function getWidgetSignature(widget: AiWidget): string {
|
|
1157
|
+
switch (widget.name) {
|
|
1158
|
+
case 'COMPUTED_STYLES':
|
|
1159
|
+
return `${widget.name}:${widget.data.backendNodeId}`;
|
|
1160
|
+
case 'CORE_VITALS':
|
|
1161
|
+
return `${widget.name}:${widget.data.insightSetKey}`;
|
|
1162
|
+
case 'STYLE_PROPERTIES':
|
|
1163
|
+
return `${widget.name}:${widget.data.backendNodeId}:${widget.data.selector ?? ''}`;
|
|
1164
|
+
case 'DOM_TREE':
|
|
1165
|
+
return `${widget.name}:${widget.data.root.backendNodeId()}`;
|
|
1166
|
+
case 'PERFORMANCE_TRACE':
|
|
1167
|
+
return `${widget.name}`;
|
|
1168
|
+
case 'PERF_INSIGHT':
|
|
1169
|
+
return `${widget.name}:${widget.data.insight}:${widget.data.insightData.insightKey}:${
|
|
1170
|
+
widget.data.insightData.navigation?.args?.data?.navigationId ?? 'no-nav-id'}`;
|
|
1171
|
+
case 'TIMELINE_RANGE_SUMMARY':
|
|
1172
|
+
return `${widget.name}:${widget.data.track}:${widget.data.bounds.min}-${widget.data.bounds.max}`;
|
|
1173
|
+
case 'BOTTOM_UP_TREE':
|
|
1174
|
+
return `${widget.name}:${widget.data.bounds.min}-${widget.data.bounds.max}`;
|
|
1175
|
+
default:
|
|
1176
|
+
Platform.assertNever(widget, 'Unknown AiWidget name');
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
/**
|
|
1181
|
+
* Returns a new ModelChatMessage where widgets have been deduplicated
|
|
1182
|
+
* across all parts and steps of the message. The first occurrence of each
|
|
1183
|
+
* unique widget (determined by its signature) is preserved.
|
|
1115
1184
|
*/
|
|
1185
|
+
export function getDeduplicatedWidgetsMessage(message: ModelChatMessage): ModelChatMessage {
|
|
1186
|
+
const seenWidgets = new Set<string>();
|
|
1187
|
+
|
|
1188
|
+
const filterWidgets = (widgets: AiWidget[]): AiWidget[] => {
|
|
1189
|
+
return widgets.filter(widget => {
|
|
1190
|
+
const signature = getWidgetSignature(widget);
|
|
1191
|
+
if (seenWidgets.has(signature)) {
|
|
1192
|
+
return false;
|
|
1193
|
+
}
|
|
1194
|
+
seenWidgets.add(signature);
|
|
1195
|
+
return true;
|
|
1196
|
+
});
|
|
1197
|
+
};
|
|
1198
|
+
|
|
1199
|
+
const deduplicatedParts = message.parts.map(part => {
|
|
1200
|
+
if (part.type === 'widget') {
|
|
1201
|
+
return {
|
|
1202
|
+
...part,
|
|
1203
|
+
widgets: filterWidgets(part.widgets),
|
|
1204
|
+
};
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
if (part.type === 'step' && part.step.widgets) {
|
|
1208
|
+
return {
|
|
1209
|
+
...part,
|
|
1210
|
+
step: {
|
|
1211
|
+
...part.step,
|
|
1212
|
+
widgets: filterWidgets(part.step.widgets),
|
|
1213
|
+
},
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
return part;
|
|
1218
|
+
});
|
|
1219
|
+
|
|
1220
|
+
return {
|
|
1221
|
+
...message,
|
|
1222
|
+
parts: deduplicatedParts,
|
|
1223
|
+
};
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1116
1226
|
async function renderWidgets(
|
|
1117
1227
|
widgets: AiWidget[]|undefined, options: {wrapperClass?: string} = {}): Promise<Lit.LitTemplate> {
|
|
1118
1228
|
if (!Root.Runtime.hostConfig.devToolsAiAssistanceV2?.enabled || !widgets || widgets.length === 0) {
|
|
@@ -1464,9 +1574,11 @@ export class ChatMessage extends UI.Widget.Widget {
|
|
|
1464
1574
|
}
|
|
1465
1575
|
|
|
1466
1576
|
override performUpdate(): Promise<void>|void {
|
|
1577
|
+
const message =
|
|
1578
|
+
this.message.entity === ChatMessageEntity.MODEL ? getDeduplicatedWidgetsMessage(this.message) : this.message;
|
|
1467
1579
|
this.#view(
|
|
1468
1580
|
{
|
|
1469
|
-
message
|
|
1581
|
+
message,
|
|
1470
1582
|
isLoading: this.isLoading,
|
|
1471
1583
|
isReadOnly: this.isReadOnly,
|
|
1472
1584
|
canShowFeedbackForm: this.canShowFeedbackForm,
|
|
@@ -70,5 +70,5 @@ export function getButtonLabel(input: {
|
|
|
70
70
|
const TARGET_LENGTH = 50;
|
|
71
71
|
const {truncatedText, moreCharacters} = smartTruncate(input.prompt, TARGET_LENGTH);
|
|
72
72
|
const promptSuffix = moreCharacters > 0 ? ` (and ${moreCharacters} more characters)` : '';
|
|
73
|
-
return `${labelBase} for prompt
|
|
73
|
+
return `${labelBase} for prompt ${truncatedText}${promptSuffix}`;
|
|
74
74
|
}
|
|
@@ -12,7 +12,13 @@ import * as Lit from '../../../ui/lit/lit.js';
|
|
|
12
12
|
import * as VisualLogging from '../../../ui/visual_logging/visual_logging.js';
|
|
13
13
|
|
|
14
14
|
import chatMessageStyles from './chatMessage.css.js';
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
getDeduplicatedWidgetsMessage,
|
|
17
|
+
type ModelChatMessage,
|
|
18
|
+
renderStep,
|
|
19
|
+
type Step,
|
|
20
|
+
titleForStep
|
|
21
|
+
} from './ChatMessage.js';
|
|
16
22
|
import {getButtonLabel} from './WalkthroughUtils.js';
|
|
17
23
|
import walkthroughViewStyles from './walkthroughView.css.js';
|
|
18
24
|
|
|
@@ -411,6 +417,7 @@ export class WalkthroughView extends UI.Widget.Widget {
|
|
|
411
417
|
if (!this.#markdownRenderer) {
|
|
412
418
|
return;
|
|
413
419
|
}
|
|
420
|
+
const message = this.#message ? getDeduplicatedWidgetsMessage(this.#message) : null;
|
|
414
421
|
this.#view(
|
|
415
422
|
{
|
|
416
423
|
isLoading: this.#isLoading,
|
|
@@ -420,7 +427,7 @@ export class WalkthroughView extends UI.Widget.Widget {
|
|
|
420
427
|
isInlined: this.#isInlined,
|
|
421
428
|
isExpanded: this.#isExpanded,
|
|
422
429
|
prompt: this.#prompt,
|
|
423
|
-
message
|
|
430
|
+
message,
|
|
424
431
|
handleScroll: this.#handleScroll,
|
|
425
432
|
},
|
|
426
433
|
this.#output, this.contentElement);
|