chrome-devtools-frontend 1.0.1604514 → 1.0.1605390
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AUTHORS +1 -0
- package/front_end/Images/src/dots-circle.svg +10 -0
- package/front_end/Tests.js +23 -7
- package/front_end/core/host/AidaClient.ts +114 -63
- package/front_end/core/host/AidaGcaTranslation.ts +6 -0
- package/front_end/core/host/GcaClient.ts +112 -0
- package/front_end/core/host/UserMetrics.ts +0 -1
- package/front_end/core/host/host.ts +2 -0
- package/front_end/core/root/ExperimentNames.ts +0 -1
- package/front_end/core/root/Runtime.ts +5 -0
- package/front_end/core/sdk/AutofillModel.ts +3 -2
- package/front_end/core/sdk/CSSModel.ts +3 -4
- package/front_end/core/sdk/CSSProperty.ts +1 -1
- package/front_end/core/sdk/ConsoleModel.ts +15 -13
- package/front_end/core/sdk/CookieModel.ts +5 -4
- package/front_end/core/sdk/DOMDebuggerModel.ts +20 -14
- package/front_end/core/sdk/DebuggerModel.ts +21 -36
- package/front_end/core/sdk/EventBreakpointsModel.ts +16 -6
- package/front_end/core/sdk/IsolateManager.ts +12 -7
- package/front_end/core/sdk/WebMCPModel.ts +57 -2
- package/front_end/entrypoints/main/MainImpl.ts +0 -4
- package/front_end/models/ai_assistance/agents/AiAgent.ts +9 -1
- package/front_end/models/ai_assistance/agents/ConversationSummaryAgent.ts +10 -9
- package/front_end/models/ai_assistance/agents/ExecuteJavascript.ts +301 -0
- package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +50 -25
- package/front_end/models/ai_assistance/agents/StylingAgent.ts +12 -264
- package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.snapshot.txt +1 -1
- package/front_end/models/emulation/DeviceModeModel.ts +21 -26
- package/front_end/models/trace/insights/LCPDiscovery.ts +14 -6
- package/front_end/panels/ai_assistance/AiAssistancePanel.ts +2 -17
- package/front_end/panels/ai_assistance/components/ChatMessage.ts +165 -65
- package/front_end/panels/ai_assistance/components/ChatView.ts +2 -13
- package/front_end/panels/ai_assistance/components/ExportForAgentsDialog.ts +1 -1
- package/front_end/panels/ai_assistance/components/chatMessage.css +48 -2
- package/front_end/panels/ai_assistance/components/chatView.css +0 -8
- package/front_end/panels/application/ApplicationPanelSidebar.ts +6 -0
- package/front_end/panels/application/IndexedDBViews.ts +0 -9
- package/front_end/panels/application/WebMCPTreeElement.ts +35 -0
- package/front_end/panels/application/WebMCPView.ts +468 -0
- package/front_end/panels/application/application.ts +4 -0
- package/front_end/panels/application/webMCPView.css +90 -0
- package/front_end/panels/common/aiCodeCompletionSummaryToolbar.css +1 -1
- package/front_end/panels/console/consoleView.css +4 -0
- package/front_end/panels/elements/ElementsTreeOutline.ts +87 -0
- package/front_end/panels/elements/StylesAiCodeCompletionProvider.ts +23 -2
- package/front_end/panels/elements/StylesSidebarPane.ts +85 -20
- package/front_end/panels/elements/elementsPanel.css +14 -0
- package/front_end/panels/elements/elementsTreeOutline.css +21 -0
- package/front_end/panels/network/NetworkLogViewColumns.ts +3 -3
- package/front_end/panels/profiler/HeapDetachedElementsView.ts +0 -4
- package/front_end/panels/profiler/HeapProfileView.ts +0 -4
- package/front_end/panels/profiler/HeapProfilerPanel.ts +4 -13
- package/front_end/panels/profiler/HeapSnapshotView.ts +12 -16
- package/front_end/panels/profiler/ProfileHeader.ts +0 -11
- package/front_end/panels/profiler/ProfileTypeRegistry.ts +4 -12
- package/front_end/panels/profiler/ProfileView.ts +1 -6
- package/front_end/panels/profiler/ProfilesPanel.ts +60 -7
- package/front_end/panels/recorder/components/recordingView.css +0 -6
- package/front_end/panels/sensors/SensorsView.ts +28 -59
- package/front_end/panels/timeline/EventsTimelineTreeView.ts +3 -3
- package/front_end/panels/timeline/ThirdPartyTreeView.ts +37 -38
- package/front_end/panels/timeline/TimelineDetailsView.ts +47 -41
- package/front_end/panels/timeline/TimelinePanel.ts +11 -0
- package/front_end/panels/timeline/TimelineTreeView.ts +149 -60
- package/front_end/panels/timeline/components/CWVMetrics.ts +18 -2
- package/front_end/panels/timeline/components/LiveMetricsView.ts +839 -783
- package/front_end/panels/timeline/thirdPartyTreeView.css +2 -2
- package/front_end/panels/timeline/timeline-meta.ts +11 -0
- package/front_end/panels/timeline/utils/Helpers.ts +5 -0
- package/front_end/ui/components/buttons/button.css +2 -2
- package/front_end/ui/components/text_editor/AiCodeCompletionProvider.ts +0 -11
- package/front_end/ui/legacy/FilterBar.ts +2 -0
- package/front_end/ui/legacy/InspectorDrawerView.ts +206 -0
- package/front_end/ui/legacy/InspectorView.ts +41 -91
- package/front_end/ui/legacy/SplitWidget.ts +33 -27
- package/front_end/ui/legacy/ViewManager.ts +14 -5
- package/front_end/ui/legacy/Widget.ts +36 -28
- package/front_end/ui/legacy/inspectorDrawerTabbedPane.css +5 -0
- package/front_end/ui/visual_logging/KnownContextValues.ts +8 -1
- package/package.json +1 -1
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
// Copyright 2026 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 Host from '../../../core/host/host.js';
|
|
6
|
+
import * as i18n from '../../../core/i18n/i18n.js';
|
|
7
|
+
import * as Platform from '../../../core/platform/platform.js';
|
|
8
|
+
import * as Root from '../../../core/root/root.js';
|
|
9
|
+
import * as SDK from '../../../core/sdk/sdk.js';
|
|
10
|
+
import type {ChangeManager} from '../ChangeManager.js';
|
|
11
|
+
import {debugLog} from '../debug.js';
|
|
12
|
+
import {EvaluateAction, formatError, SideEffectError} from '../EvaluateAction.js';
|
|
13
|
+
import {FREESTYLER_WORLD_NAME} from '../injected.js';
|
|
14
|
+
|
|
15
|
+
import type {FunctionCallHandlerResult, FunctionDeclaration, FunctionHandlerOptions} from './AiAgent.js';
|
|
16
|
+
|
|
17
|
+
const lockedString = i18n.i18n.lockedString;
|
|
18
|
+
|
|
19
|
+
export function executeJavaScriptFunction(executor: JavascriptExecutor): FunctionDeclaration<
|
|
20
|
+
{
|
|
21
|
+
title: string,
|
|
22
|
+
explanation: string,
|
|
23
|
+
code: string,
|
|
24
|
+
},
|
|
25
|
+
unknown> {
|
|
26
|
+
return {
|
|
27
|
+
description:
|
|
28
|
+
'This function allows you to run JavaScript code on the inspected page to access the element styles and page content.\nCall this function to gather additional information or modify the page state. Call this function enough times to investigate the user request.',
|
|
29
|
+
parameters: {
|
|
30
|
+
type: Host.AidaClient.ParametersTypes.OBJECT,
|
|
31
|
+
description: '',
|
|
32
|
+
nullable: false,
|
|
33
|
+
properties: {
|
|
34
|
+
code: {
|
|
35
|
+
type: Host.AidaClient.ParametersTypes.STRING,
|
|
36
|
+
description:
|
|
37
|
+
`JavaScript code snippet to run on the inspected page. Make sure the code is formatted for readability.
|
|
38
|
+
|
|
39
|
+
# Instructions
|
|
40
|
+
|
|
41
|
+
* To return data, define a top-level \`data\` variable and populate it with data you want to get. Only JSON-serializable objects can be assigned to \`data\`.
|
|
42
|
+
* If you modify styles on an element, ALWAYS call the pre-defined global \`async setElementStyles(el: Element, styles: object)\` function. This function is an internal mechanism for you and should never be presented as a command/advice to the user.
|
|
43
|
+
* **CRITICAL** Only get styles that might be relevant to the user request.
|
|
44
|
+
* **CRITICAL** Never assume a selector for the elements unless you verified your knowledge.
|
|
45
|
+
* **CRITICAL** Consider that \`data\` variable from the previous function calls are not available in a new function call.
|
|
46
|
+
|
|
47
|
+
For example, the code to change element styles:
|
|
48
|
+
|
|
49
|
+
\`\`\`
|
|
50
|
+
await setElementStyles($0, {
|
|
51
|
+
color: 'blue',
|
|
52
|
+
});
|
|
53
|
+
\`\`\`
|
|
54
|
+
|
|
55
|
+
For example, the code to get overlapping elements:
|
|
56
|
+
|
|
57
|
+
\`\`\`
|
|
58
|
+
const data = {
|
|
59
|
+
overlappingElements: Array.from(document.querySelectorAll('*'))
|
|
60
|
+
.filter(el => {
|
|
61
|
+
const rect = el.getBoundingClientRect();
|
|
62
|
+
const popupRect = $0.getBoundingClientRect();
|
|
63
|
+
return (
|
|
64
|
+
el !== $0 &&
|
|
65
|
+
rect.left < popupRect.right &&
|
|
66
|
+
rect.right > popupRect.left &&
|
|
67
|
+
rect.top < popupRect.bottom &&
|
|
68
|
+
rect.bottom > popupRect.top
|
|
69
|
+
);
|
|
70
|
+
})
|
|
71
|
+
.map(el => ({
|
|
72
|
+
tagName: el.tagName,
|
|
73
|
+
id: el.id,
|
|
74
|
+
className: el.className,
|
|
75
|
+
zIndex: window.getComputedStyle(el)['z-index']
|
|
76
|
+
}))
|
|
77
|
+
};
|
|
78
|
+
\`\`\`
|
|
79
|
+
`,
|
|
80
|
+
},
|
|
81
|
+
explanation: {
|
|
82
|
+
type: Host.AidaClient.ParametersTypes.STRING,
|
|
83
|
+
description: 'Explain why you want to run this code',
|
|
84
|
+
},
|
|
85
|
+
title: {
|
|
86
|
+
type: Host.AidaClient.ParametersTypes.STRING,
|
|
87
|
+
description: 'Provide a summary of what the code does. For example, "Checking related element styles".',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
required: ['code', 'explanation', 'title']
|
|
91
|
+
},
|
|
92
|
+
displayInfoFromArgs: params => {
|
|
93
|
+
return {
|
|
94
|
+
title: params.title,
|
|
95
|
+
thought: params.explanation,
|
|
96
|
+
action: params.code,
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
handler: async (
|
|
100
|
+
params,
|
|
101
|
+
options,
|
|
102
|
+
) => {
|
|
103
|
+
return await executor.executeAction(params.code, options);
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export async function executeJsCode(
|
|
109
|
+
functionDeclaration: string,
|
|
110
|
+
{throwOnSideEffect, contextNode}: {throwOnSideEffect: boolean, contextNode: SDK.DOMModel.DOMNode|null}):
|
|
111
|
+
Promise<string> {
|
|
112
|
+
if (!contextNode) {
|
|
113
|
+
throw new Error('Cannot execute JavaScript because of missing context node');
|
|
114
|
+
}
|
|
115
|
+
const target = contextNode.domModel().target();
|
|
116
|
+
|
|
117
|
+
if (!target) {
|
|
118
|
+
throw new Error('Target is not found for executing code');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const resourceTreeModel = target.model(SDK.ResourceTreeModel.ResourceTreeModel);
|
|
122
|
+
const frameId = contextNode.frameId() ?? resourceTreeModel?.mainFrame?.id;
|
|
123
|
+
|
|
124
|
+
if (!frameId) {
|
|
125
|
+
throw new Error('Main frame is not found for executing code');
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const runtimeModel = target.model(SDK.RuntimeModel.RuntimeModel);
|
|
129
|
+
const pageAgent = target.pageAgent();
|
|
130
|
+
|
|
131
|
+
// This returns previously created world if it exists for the frame.
|
|
132
|
+
const {executionContextId} = await pageAgent.invoke_createIsolatedWorld({frameId, worldName: FREESTYLER_WORLD_NAME});
|
|
133
|
+
const executionContext = runtimeModel?.executionContext(executionContextId);
|
|
134
|
+
if (!executionContext) {
|
|
135
|
+
throw new Error('Execution context is not found for executing code');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (executionContext.debuggerModel.selectedCallFrame()) {
|
|
139
|
+
return formatError('Cannot evaluate JavaScript because the execution is paused on a breakpoint.');
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const remoteObject = await contextNode.resolveToObject(undefined, executionContextId);
|
|
143
|
+
if (!remoteObject) {
|
|
144
|
+
throw new Error('Cannot execute JavaScript because remote object cannot be resolved');
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return await EvaluateAction.execute(functionDeclaration, [remoteObject], executionContext, {throwOnSideEffect});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const MAX_OBSERVATION_BYTE_LENGTH = 25_000;
|
|
151
|
+
const OBSERVATION_TIMEOUT = 5_000;
|
|
152
|
+
|
|
153
|
+
export interface JavascriptExecutorOptions {
|
|
154
|
+
readonly executionMode: Root.Runtime.HostConfigFreestylerExecutionMode;
|
|
155
|
+
readonly getContextNode: () => SDK.DOMModel.DOMNode | null;
|
|
156
|
+
readonly createExtensionScope: (changes: ChangeManager) => {
|
|
157
|
+
install(): Promise<void>, uninstall(): Promise<void>,
|
|
158
|
+
};
|
|
159
|
+
readonly changes: ChangeManager;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export class JavascriptExecutor {
|
|
163
|
+
#options: JavascriptExecutorOptions;
|
|
164
|
+
#execJs: typeof executeJsCode;
|
|
165
|
+
|
|
166
|
+
constructor(options: JavascriptExecutorOptions, execJs: typeof executeJsCode = executeJsCode) {
|
|
167
|
+
this.#options = options;
|
|
168
|
+
this.#execJs = execJs;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async executeAction(action: string, options?: FunctionHandlerOptions): Promise<FunctionCallHandlerResult<unknown>> {
|
|
172
|
+
debugLog(`Action to execute: ${action}`);
|
|
173
|
+
|
|
174
|
+
if (options?.approved === false) {
|
|
175
|
+
return {
|
|
176
|
+
error: 'Error: User denied code execution with side effects.',
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (this.#options.executionMode === Root.Runtime.HostConfigFreestylerExecutionMode.NO_SCRIPTS) {
|
|
181
|
+
return {
|
|
182
|
+
error: 'Error: JavaScript execution is currently disabled.',
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const selectedNode = this.#options.getContextNode();
|
|
187
|
+
if (!selectedNode) {
|
|
188
|
+
return {error: 'Error: no selected node found.'};
|
|
189
|
+
}
|
|
190
|
+
const target = selectedNode.domModel().target();
|
|
191
|
+
if (target.model(SDK.DebuggerModel.DebuggerModel)?.selectedCallFrame()) {
|
|
192
|
+
return {
|
|
193
|
+
error: 'Error: Cannot evaluate JavaScript because the execution is paused on a breakpoint.',
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const scope = this.#options.createExtensionScope(this.#options.changes);
|
|
198
|
+
await scope.install();
|
|
199
|
+
try {
|
|
200
|
+
let throwOnSideEffect = true;
|
|
201
|
+
if (options?.approved) {
|
|
202
|
+
throwOnSideEffect = false;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const result = await this.generateObservation(action, {throwOnSideEffect});
|
|
206
|
+
debugLog(`Action result: ${JSON.stringify(result)}`);
|
|
207
|
+
if (result.sideEffect) {
|
|
208
|
+
if (this.#options.executionMode ===
|
|
209
|
+
Root.Runtime.HostConfigFreestylerExecutionMode.SIDE_EFFECT_FREE_SCRIPTS_ONLY) {
|
|
210
|
+
return {
|
|
211
|
+
error: 'Error: JavaScript execution that modifies the page is currently disabled.',
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (options?.signal?.aborted) {
|
|
216
|
+
return {
|
|
217
|
+
error: 'Error: evaluation has been cancelled',
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return {
|
|
222
|
+
requiresApproval: true,
|
|
223
|
+
description: lockedString('This code may modify page content. Continue?'),
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
if (result.canceled) {
|
|
227
|
+
return {
|
|
228
|
+
error: result.observation,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return {
|
|
233
|
+
result: result.observation,
|
|
234
|
+
};
|
|
235
|
+
} finally {
|
|
236
|
+
await scope.uninstall();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
async generateObservation(
|
|
241
|
+
action: string,
|
|
242
|
+
{
|
|
243
|
+
throwOnSideEffect,
|
|
244
|
+
}: {
|
|
245
|
+
throwOnSideEffect: boolean,
|
|
246
|
+
},
|
|
247
|
+
): Promise<{
|
|
248
|
+
observation: string,
|
|
249
|
+
sideEffect: boolean,
|
|
250
|
+
canceled: boolean,
|
|
251
|
+
}> {
|
|
252
|
+
const functionDeclaration = `async function ($0) {
|
|
253
|
+
try {
|
|
254
|
+
${action}
|
|
255
|
+
;
|
|
256
|
+
return ((typeof data !== "undefined") ? data : undefined);
|
|
257
|
+
} catch (error) {
|
|
258
|
+
return error;
|
|
259
|
+
}
|
|
260
|
+
}`;
|
|
261
|
+
try {
|
|
262
|
+
const result = await Promise.race([
|
|
263
|
+
this.#execJs(
|
|
264
|
+
functionDeclaration,
|
|
265
|
+
{
|
|
266
|
+
throwOnSideEffect,
|
|
267
|
+
contextNode: this.#options.getContextNode(),
|
|
268
|
+
},
|
|
269
|
+
),
|
|
270
|
+
new Promise<never>((_, reject) => {
|
|
271
|
+
setTimeout(
|
|
272
|
+
() => reject(new Error('Script execution exceeded the maximum allowed time.')), OBSERVATION_TIMEOUT);
|
|
273
|
+
}),
|
|
274
|
+
]);
|
|
275
|
+
const byteCount = Platform.StringUtilities.countWtf8Bytes(result);
|
|
276
|
+
Host.userMetrics.freestylerEvalResponseSize(byteCount);
|
|
277
|
+
if (byteCount > MAX_OBSERVATION_BYTE_LENGTH) {
|
|
278
|
+
throw new Error('Output exceeded the maximum allowed length.');
|
|
279
|
+
}
|
|
280
|
+
return {
|
|
281
|
+
observation: result,
|
|
282
|
+
sideEffect: false,
|
|
283
|
+
canceled: false,
|
|
284
|
+
};
|
|
285
|
+
} catch (error) {
|
|
286
|
+
if (error instanceof SideEffectError) {
|
|
287
|
+
return {
|
|
288
|
+
observation: error.message,
|
|
289
|
+
sideEffect: true,
|
|
290
|
+
canceled: false,
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return {
|
|
295
|
+
observation: `Error: ${error.message}`,
|
|
296
|
+
sideEffect: false,
|
|
297
|
+
canceled: false,
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
@@ -82,7 +82,7 @@ Your primary goal is to provide actionable advice to web developers about their
|
|
|
82
82
|
|
|
83
83
|
You will be provided a summary of a trace: some performance metrics; the most critical network requests; a bottom-up call graph summary; and a brief overview of available insights. Each insight has information about potential performance issues with the page.
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
Always call getInsightDetails to gather more data on an insight or the actual LCP element BEFORE mentioning any specific details about them.
|
|
86
86
|
|
|
87
87
|
You have functions available to learn more about the trace. Use these to confirm hypotheses, or to further explore the trace when diagnosing performance issues.
|
|
88
88
|
|
|
@@ -105,23 +105,41 @@ Note: if the user asks a specific question about the trace (such as "What is my
|
|
|
105
105
|
|
|
106
106
|
### Step 1: Determine a performance problem to investigate
|
|
107
107
|
|
|
108
|
+
- If the trace summary indicates that the main performance metrics (LCP, INP, CLS) are all within good thresholds, acknowledge this to the user. In this case, let the user know that they can try recording a trace with mobile emulation and throttling options and show them how.
|
|
108
109
|
- With help from the user, determine what performance problem to focus on.
|
|
109
|
-
- If the user is not specific about what problem to investigate, help them by doing a investigation yourself. Present to the user options with 1-sentence summaries. Mention what performance metrics each option impacts. Call as many functions and confirm the data thoroughly: never present an option without being certain it is a real performance issue.
|
|
110
|
-
-
|
|
111
|
-
- Don't present more than 2 options.
|
|
110
|
+
- If the user is not specific about what problem to investigate, help them by doing a investigation yourself focus on performance improvements for better LCP, INP and CLS. Present to the user options with 1-sentence summaries. Mention what performance metrics each option impacts. Call as many functions and confirm the data thoroughly: never present an option without being certain it is a real performance issue.
|
|
111
|
+
- Focus on identifying the problem in Step 1 and save solution suggestions for Step 2.
|
|
112
112
|
- Once a performance problem has been identified for investigation, move on to step 2.
|
|
113
113
|
|
|
114
|
+
#### Response Structure
|
|
115
|
+
|
|
116
|
+
- Rank the options from most impactful to least impactful, and present them to the user in that order.
|
|
117
|
+
- Limit the number of performance problem options presented to the user to a maximum of 2.
|
|
118
|
+
|
|
114
119
|
### Step 2: Suggest solutions
|
|
115
120
|
|
|
116
121
|
- Suggest solutions to remedy the identified performance problem. Be as specific as possible, using data from the trace via the provided functions to back up everything you say. You should prefer specific solutions, but absent any specific solution you may suggest general solutions (such as from an insight's documentation links).
|
|
117
122
|
- If you are unsure, be honest and present information that can be helpful for further investigation.
|
|
118
123
|
- A good first step to discover solutions is to consider the insights, but you should also validate all potential advice by analyzing the trace until you are confident about the root cause of a performance issue.
|
|
119
124
|
|
|
125
|
+
#### Response Structure
|
|
126
|
+
|
|
127
|
+
- If available, point out the root cause(s) of the problem.
|
|
128
|
+
- Example: "**Root Cause**: The page is slow because of [reason]."
|
|
129
|
+
- Example: "**Root Causes**:"
|
|
130
|
+
- [Reason 1]
|
|
131
|
+
- [Reason 2]
|
|
132
|
+
- if applicable, list actionable solution suggestion(s) in order of impact:
|
|
133
|
+
- Example: "**Suggestion**: [Suggestion 1]
|
|
134
|
+
- Example: "**Suggestions**:"
|
|
135
|
+
- [Suggestion 1]
|
|
136
|
+
- [Suggestion 2]
|
|
137
|
+
|
|
120
138
|
## Guidelines
|
|
121
139
|
|
|
122
140
|
- Use the provided functions to get detailed performance data. Prioritize functions that provide context relevant to the performance issue being investigated.
|
|
123
141
|
- Before finalizing your advice, look over it and validate using any relevant functions. If something seems off, refine the advice before giving it to the user.
|
|
124
|
-
-
|
|
142
|
+
- Base your analysis and advice solely on the data retrieved through the provided functions. Always use the provided functions to gather sufficient data when needed.
|
|
125
143
|
- Use the track summary functions to get high-level detail about portions of the trace. For the \`bounds\` parameter, default to using the bounds of the trace. Never specifically ask the user for a bounds. You can use more narrow bounds (such as the bounds relevant to a specific insight) when appropriate. Narrow the bounds given functions when possible.
|
|
126
144
|
- Use \`getEventByKey\` to get data on a specific trace event. This is great for root-cause analysis or validating any assumptions.
|
|
127
145
|
- Provide clear, actionable recommendations. Avoid technical jargon unless necessary, and explain any technical terms used.
|
|
@@ -147,15 +165,6 @@ Adhere to the following critical requirements:
|
|
|
147
165
|
- If asked about sensitive topics (religion, race, politics, sexuality, gender, etc.), respond with: "My expertise is limited to website performance analysis. I cannot provide information on that topic.".
|
|
148
166
|
- Do not provide answers on non-web-development topics, such as legal, financial, medical, or personal advice.
|
|
149
167
|
- Use the precision of Strunk & White, the brevity of Hemingway, and the simple clarity of Vonnegut. Don't add repeated information, and keep the whole answer short.
|
|
150
|
-
|
|
151
|
-
## Response Structure
|
|
152
|
-
|
|
153
|
-
- If available, point out the root cause of the problem. It may be a bullet point list.
|
|
154
|
-
- Example: "**Root Cause**: The page is slow because of [reason]."
|
|
155
|
-
- if applicable, list actionable solution suggestion(s) in order of impact:
|
|
156
|
-
- Example: "**Suggestions**:
|
|
157
|
-
- [Suggestion 1]
|
|
158
|
-
- [Suggestion 2]
|
|
159
168
|
`;
|
|
160
169
|
};
|
|
161
170
|
|
|
@@ -166,7 +175,7 @@ When referring to a trace event that has a corresponding \`eventKey\`, annotate
|
|
|
166
175
|
- When referring to a URL for which you know the eventKey of: [https://www.example.com](#s-1827)
|
|
167
176
|
- Never show the eventKey (like "eventKey: s-1852"); instead, use a markdown link as described above.
|
|
168
177
|
|
|
169
|
-
When asking the user to make a choice between
|
|
178
|
+
When asking the user to make a choice between options, output a list of choices at the end of your text response. The format is \`SUGGESTIONS: ["suggestion1", "suggestion2", "suggestion3"]\`. This MUST start on a newline, and be a single line.
|
|
170
179
|
`;
|
|
171
180
|
|
|
172
181
|
const buildExtraPreambleWhenFreshTrace = (): string => {
|
|
@@ -231,8 +240,13 @@ export class PerformanceTraceContext extends ConversationContext<AgentFocus> {
|
|
|
231
240
|
}
|
|
232
241
|
|
|
233
242
|
override getOrigin(): string {
|
|
234
|
-
|
|
235
|
-
|
|
243
|
+
try {
|
|
244
|
+
const url = new URL(this.#focus.parsedTrace.data.Meta.mainFrameURL);
|
|
245
|
+
return url.origin;
|
|
246
|
+
} catch {
|
|
247
|
+
const {min, max} = this.#focus.parsedTrace.data.Meta.traceBounds;
|
|
248
|
+
return `trace-${min}-${max}`;
|
|
249
|
+
}
|
|
236
250
|
}
|
|
237
251
|
|
|
238
252
|
override getItem(): AgentFocus {
|
|
@@ -953,16 +967,27 @@ export class PerformanceAgent extends AiAgent<AgentFocus> {
|
|
|
953
967
|
|
|
954
968
|
const key = `getMainThreadTrackSummary({min: ${bounds.min}, max: ${bounds.max}})`;
|
|
955
969
|
this.#cacheFunctionResult(focus, key, summary);
|
|
970
|
+
const widgets: AiWidget[] = [];
|
|
971
|
+
widgets.push({
|
|
972
|
+
name: 'TIMELINE_RANGE_SUMMARY',
|
|
973
|
+
data: {
|
|
974
|
+
parsedTrace,
|
|
975
|
+
bounds,
|
|
976
|
+
track: 'main',
|
|
977
|
+
},
|
|
978
|
+
});
|
|
979
|
+
|
|
980
|
+
widgets.push({
|
|
981
|
+
name: 'BOTTOM_UP_TREE',
|
|
982
|
+
data: {
|
|
983
|
+
bounds,
|
|
984
|
+
parsedTrace,
|
|
985
|
+
},
|
|
986
|
+
});
|
|
987
|
+
|
|
956
988
|
return {
|
|
957
989
|
result: {summary},
|
|
958
|
-
widgets
|
|
959
|
-
name: 'TIMELINE_RANGE_SUMMARY',
|
|
960
|
-
data: {
|
|
961
|
-
parsedTrace,
|
|
962
|
-
bounds,
|
|
963
|
-
track: 'main',
|
|
964
|
-
},
|
|
965
|
-
}],
|
|
990
|
+
widgets,
|
|
966
991
|
};
|
|
967
992
|
},
|
|
968
993
|
|