chrome-devtools-frontend 1.0.1515446 → 1.0.1515988
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/contributing/infrastructure.md +131 -82
- package/front_end/Tests.js +3 -29
- package/front_end/core/common/Progress.ts +73 -55
- package/front_end/core/host/UserMetrics.ts +0 -1
- package/front_end/core/protocol_client/InspectorBackend.ts +2 -0
- package/front_end/core/root/Runtime.ts +0 -1
- package/front_end/core/sdk/CSSMatchedStyles.ts +12 -10
- package/front_end/core/sdk/CSSModel.ts +1 -31
- package/front_end/core/sdk/CSSPropertyParserMatchers.ts +27 -7
- package/front_end/core/sdk/DebuggerModel.ts +1 -31
- package/front_end/core/sdk/EnhancedTracesParser.ts +81 -50
- package/front_end/core/sdk/NetworkManager.ts +1 -31
- package/front_end/core/sdk/NetworkRequest.ts +1 -31
- package/front_end/core/sdk/RehydratingConnection.snapshot.txt +1003 -0
- package/front_end/core/sdk/RehydratingConnection.ts +13 -18
- package/front_end/core/sdk/RehydratingObject.ts +8 -31
- package/front_end/core/sdk/RemoteObject.ts +1 -31
- package/front_end/core/sdk/ResourceTreeModel.ts +1 -31
- package/front_end/core/sdk/RuntimeModel.ts +1 -31
- package/front_end/core/sdk/ServiceWorkerManager.ts +1 -31
- package/front_end/core/sdk/SourceMap.ts +1 -31
- package/front_end/core/sdk/TraceObject.ts +8 -3
- package/front_end/entrypoints/main/MainImpl.ts +0 -2
- package/front_end/entrypoints/main/main-meta.ts +2 -2
- package/front_end/generated/InspectorBackendCommands.js +4 -4
- package/front_end/generated/SupportedCSSProperties.js +12 -0
- package/front_end/generated/protocol.ts +10 -1
- package/front_end/models/ai_assistance/AiHistoryStorage.ts +1 -3
- package/front_end/models/ai_assistance/ConversationHandler.ts +4 -6
- package/front_end/models/ai_assistance/agents/AiAgent.ts +4 -1
- package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +107 -72
- package/front_end/models/ai_assistance/agents/PerformanceAnnotationsAgent.ts +2 -2
- package/front_end/models/ai_assistance/agents/StylingAgent.ts +2 -2
- package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.snapshot.txt +178 -85
- package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.ts +308 -218
- package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.snapshot.txt +161 -97
- package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.ts +78 -58
- package/front_end/models/ai_assistance/data_formatters/UnitFormatters.ts +10 -1
- package/front_end/models/ai_assistance/performance/AIContext.ts +19 -21
- package/front_end/models/ai_code_completion/AiCodeCompletion.ts +123 -55
- package/front_end/models/bindings/ContentProviderBasedProject.ts +6 -4
- package/front_end/models/breakpoints/BreakpointManager.ts +3 -3
- package/front_end/models/har/Writer.ts +11 -11
- package/front_end/models/javascript_metadata/NativeFunctions.js +7 -7
- package/front_end/models/persistence/FileSystemWorkspaceBinding.ts +3 -3
- package/front_end/models/persistence/IsolatedFileSystem.ts +4 -4
- package/front_end/models/persistence/IsolatedFileSystemManager.ts +7 -7
- package/front_end/models/persistence/PersistenceImpl.ts +8 -8
- package/front_end/models/persistence/PlatformFileSystem.ts +1 -1
- package/front_end/models/text_utils/TextUtils.ts +26 -0
- package/front_end/models/trace/ModelImpl.ts +2 -16
- package/front_end/models/trace/Processor.ts +14 -8
- package/front_end/models/trace/handlers/AuctionWorkletsHandler.ts +4 -4
- package/front_end/models/trace/handlers/FramesHandler.ts +2 -2
- package/front_end/models/trace/handlers/LayoutShiftsHandler.ts +7 -10
- package/front_end/models/trace/handlers/MetaHandler.ts +11 -9
- package/front_end/models/trace/handlers/ScreenshotsHandler.ts +1 -1
- package/front_end/models/trace/handlers/ScriptsHandler.ts +5 -5
- package/front_end/models/trace/handlers/UserInteractionsHandler.ts +2 -14
- package/front_end/models/trace/handlers/UserTimingsHandler.ts +3 -4
- package/front_end/models/trace/insights/CLSCulprits.ts +1 -1
- package/front_end/models/trace/insights/DocumentLatency.ts +8 -7
- package/front_end/models/trace/insights/DuplicatedJavaScript.ts +1 -1
- package/front_end/models/trace/insights/INPBreakdown.ts +1 -1
- package/front_end/models/trace/insights/ImageDelivery.ts +1 -1
- package/front_end/models/trace/insights/LCPBreakdown.ts +1 -1
- package/front_end/models/trace/insights/LCPDiscovery.ts +1 -1
- package/front_end/models/trace/insights/ModernHTTP.ts +1 -1
- package/front_end/models/trace/insights/NetworkDependencyTree.ts +1 -1
- package/front_end/models/trace/insights/RenderBlocking.ts +1 -1
- package/front_end/models/trace/insights/types.ts +2 -0
- package/front_end/models/trace/types/Configuration.ts +12 -0
- package/front_end/models/trace/types/TraceEvents.ts +41 -64
- package/front_end/models/trace_source_maps_resolver/trace_source_maps_resolver.ts +1 -1
- package/front_end/panels/ai_assistance/AiAssistancePanel.ts +21 -99
- package/front_end/panels/application/ServiceWorkersView.ts +0 -1
- package/front_end/panels/application/components/BackForwardCacheStrings.ts +8 -2
- package/front_end/panels/browser_debugger/CategorizedBreakpointsSidebarPane.ts +2 -3
- package/front_end/panels/common/BadgeNotification.ts +10 -8
- package/front_end/panels/common/GdpSignUpDialog.ts +30 -14
- package/front_end/panels/common/gdpSignUpDialog.css +4 -0
- package/front_end/panels/console/ConsoleView.ts +23 -28
- package/front_end/panels/console/ConsoleViewport.ts +2 -2
- package/front_end/panels/console/consoleView.css +11 -1
- package/front_end/panels/coverage/CoverageView.ts +2 -2
- package/front_end/panels/elements/ElementsTreeOutline.ts +2 -2
- package/front_end/panels/elements/StyleEditorWidget.ts +8 -19
- package/front_end/panels/elements/StylePropertyTreeElement.ts +39 -25
- package/front_end/panels/elements/StylesSidebarPane.ts +2 -2
- package/front_end/panels/elements/stylePropertiesTreeOutline.css +4 -3
- package/front_end/panels/layer_viewer/Layers3DView.ts +2 -2
- package/front_end/panels/layers/LayerTreeModel.ts +3 -3
- package/front_end/panels/mobile_throttling/ThrottlingSettingsTab.ts +4 -4
- package/front_end/panels/network/NetworkLogView.ts +1 -1
- package/front_end/panels/network/NetworkLogViewColumns.ts +3 -3
- package/front_end/panels/network/NetworkSearchScope.ts +6 -6
- package/front_end/panels/search/SearchView.ts +220 -159
- package/front_end/panels/settings/components/SyncSection.ts +64 -10
- package/front_end/panels/settings/components/syncSection.css +6 -0
- package/front_end/panels/sources/AiCodeCompletionPlugin.ts +1 -4
- package/front_end/panels/sources/SourcesSearchScope.ts +4 -4
- package/front_end/panels/sources/TabbedEditorContainer.ts +5 -5
- package/front_end/panels/timeline/TimelineFlameChartDataProvider.ts +10 -5
- package/front_end/panels/timeline/TimelineFlameChartView.ts +18 -15
- package/front_end/panels/timeline/TimelinePanel.ts +41 -22
- package/front_end/panels/timeline/TracingLayerTree.ts +4 -5
- package/front_end/panels/timeline/components/ExportTraceOptions.ts +37 -22
- package/front_end/panels/timeline/components/insights/BaseInsightComponent.ts +17 -7
- package/front_end/panels/webauthn/WebauthnPane.ts +1 -1
- package/front_end/third_party/axe-core/README.chromium +1 -0
- package/front_end/third_party/chromium/README.chromium +1 -1
- package/front_end/third_party/codemirror/README.chromium +1 -0
- package/front_end/third_party/codemirror.next/README.chromium +1 -0
- package/front_end/third_party/csp_evaluator/README.chromium +1 -0
- package/front_end/third_party/diff/README.chromium +1 -0
- package/front_end/third_party/i18n/README.chromium +1 -0
- package/front_end/third_party/intl-messageformat/README.chromium +1 -0
- package/front_end/third_party/json5/README.chromium +1 -0
- package/front_end/third_party/legacy-javascript/README.chromium +1 -0
- package/front_end/third_party/lighthouse/README.chromium +1 -0
- package/front_end/third_party/lit/README.chromium +1 -0
- package/front_end/third_party/marked/README.chromium +1 -0
- package/front_end/third_party/puppeteer/README.chromium +2 -2
- package/front_end/third_party/puppeteer/package/README.md +6 -3
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Browser.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Page.d.ts +11 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Page.js +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/Page.d.ts +5 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/Page.js +30 -8
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/BrowsingContext.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/BrowsingContext.js +1 -3
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/BrowsingContext.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/Realm.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkManager.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkManager.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkManager.js +8 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkManager.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Page.d.ts +5 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Page.js +8 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/generated/version.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/generated/version.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/injected/injected.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserLauncher.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserLauncher.js +5 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserLauncher.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/Mutex.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.d.ts +12 -2
- package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +22 -8
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Browser.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Page.d.ts +11 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Page.js +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/Page.d.ts +5 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/Page.js +30 -8
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/BrowsingContext.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/BrowsingContext.js +1 -3
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/BrowsingContext.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkManager.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkManager.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkManager.js +8 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkManager.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Page.d.ts +5 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Page.js +8 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/generated/version.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/generated/version.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserLauncher.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserLauncher.js +5 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserLauncher.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/types.d.ts +12 -2
- package/front_end/third_party/puppeteer/package/package.json +4 -4
- package/front_end/third_party/puppeteer/package/src/api/Browser.ts +1 -1
- package/front_end/third_party/puppeteer/package/src/api/Page.ts +13 -2
- package/front_end/third_party/puppeteer/package/src/bidi/Page.ts +50 -8
- package/front_end/third_party/puppeteer/package/src/bidi/core/BrowsingContext.ts +0 -1
- package/front_end/third_party/puppeteer/package/src/cdp/NetworkManager.ts +8 -1
- package/front_end/third_party/puppeteer/package/src/cdp/Page.ts +21 -5
- package/front_end/third_party/puppeteer/package/src/generated/version.ts +1 -1
- package/front_end/third_party/puppeteer/package/src/node/BrowserLauncher.ts +12 -0
- package/front_end/third_party/puppeteer-replay/README.chromium +1 -0
- package/front_end/third_party/third-party-web/README.chromium +1 -0
- package/front_end/third_party/vscode.web-custom-data/README.chromium +1 -0
- package/front_end/third_party/wasmparser/README.chromium +1 -0
- package/front_end/third_party/web-vitals/README.chromium +1 -0
- package/front_end/ui/components/text_editor/config.ts +66 -16
- package/front_end/ui/components/tooltips/Tooltip.ts +17 -1
- package/front_end/ui/legacy/ContextMenu.ts +2 -2
- package/front_end/ui/legacy/GlassPane.ts +7 -3
- package/front_end/ui/legacy/ProgressIndicator.ts +33 -21
- package/front_end/ui/legacy/TabbedPane.ts +2 -2
- package/front_end/ui/legacy/Treeoutline.ts +10 -5
- package/front_end/ui/legacy/UIUtils.ts +42 -10
- package/front_end/ui/legacy/components/color_picker/Spectrum.ts +14 -14
- package/front_end/ui/legacy/components/data_grid/DataGrid.ts +6 -6
- package/front_end/ui/legacy/components/data_grid/DataGridElement.ts +4 -2
- package/front_end/ui/legacy/components/perf_ui/FlameChart.ts +3 -29
- package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +14 -14
- package/front_end/ui/visual_logging/Debugging.ts +24 -12
- package/front_end/ui/visual_logging/KnownContextValues.ts +3 -0
- package/inspector_overlay/highlight_common.ts +1 -27
- package/inspector_overlay/highlight_grid_common.ts +1 -27
- package/inspector_overlay/tool_highlight.ts +1 -27
- package/inspector_overlay/tool_persistent.ts +1 -27
- package/inspector_overlay/tool_source_order.ts +1 -27
- package/package.json +3 -3
@@ -50,7 +50,7 @@ export interface ExternalPerformanceAIConversationData {
|
|
50
50
|
}
|
51
51
|
|
52
52
|
export interface ExternalPerformanceRequestParameters {
|
53
|
-
conversationType: ConversationType.
|
53
|
+
conversationType: ConversationType.PERFORMANCE;
|
54
54
|
prompt: string;
|
55
55
|
data: ExternalPerformanceAIConversationData;
|
56
56
|
}
|
@@ -201,7 +201,7 @@ export class ConversationHandler {
|
|
201
201
|
case ConversationType.STYLING: {
|
202
202
|
return await this.#handleExternalStylingConversation(parameters.prompt, parameters.selector);
|
203
203
|
}
|
204
|
-
case ConversationType.
|
204
|
+
case ConversationType.PERFORMANCE:
|
205
205
|
return await this.#handleExternalPerformanceConversation(parameters.prompt, parameters.data);
|
206
206
|
case ConversationType.NETWORK:
|
207
207
|
if (!parameters.requestUrl) {
|
@@ -348,10 +348,8 @@ export class ConversationHandler {
|
|
348
348
|
agent = new FileAgent(options);
|
349
349
|
break;
|
350
350
|
}
|
351
|
-
case ConversationType.
|
352
|
-
|
353
|
-
case ConversationType.PERFORMANCE_CALL_TREE: {
|
354
|
-
agent = new PerformanceAgent(options, conversationType);
|
351
|
+
case ConversationType.PERFORMANCE: {
|
352
|
+
agent = new PerformanceAgent(options);
|
355
353
|
break;
|
356
354
|
}
|
357
355
|
}
|
@@ -148,6 +148,9 @@ export interface ConversationSuggestion {
|
|
148
148
|
jslogContext?: string;
|
149
149
|
}
|
150
150
|
|
151
|
+
/** At least one. */
|
152
|
+
export type ConversationSuggestions = [ConversationSuggestion, ...ConversationSuggestion[]];
|
153
|
+
|
151
154
|
export const enum ExternalRequestResponseType {
|
152
155
|
ANSWER = 'answer',
|
153
156
|
NOTIFICATION = 'notification',
|
@@ -196,7 +199,7 @@ export abstract class ConversationContext<T> {
|
|
196
199
|
return;
|
197
200
|
}
|
198
201
|
|
199
|
-
async getSuggestions(): Promise<
|
202
|
+
async getSuggestions(): Promise<ConversationSuggestions|undefined> {
|
200
203
|
return;
|
201
204
|
}
|
202
205
|
}
|
@@ -4,6 +4,7 @@
|
|
4
4
|
|
5
5
|
import '../../../ui/components/icon_button/icon_button.js';
|
6
6
|
|
7
|
+
import * as Common from '../../../core/common/common.js';
|
7
8
|
import * as Host from '../../../core/host/host.js';
|
8
9
|
import * as i18n from '../../../core/i18n/i18n.js';
|
9
10
|
import * as Platform from '../../../core/platform/platform.js';
|
@@ -11,7 +12,7 @@ import * as Root from '../../../core/root/root.js';
|
|
11
12
|
import * as SDK from '../../../core/sdk/sdk.js';
|
12
13
|
import * as Tracing from '../../../services/tracing/tracing.js';
|
13
14
|
import * as Trace from '../../trace/trace.js';
|
14
|
-
import
|
15
|
+
import {ConversationType} from '../AiHistoryStorage.js';
|
15
16
|
import {
|
16
17
|
PerformanceInsightFormatter,
|
17
18
|
TraceEventFormatter,
|
@@ -22,11 +23,10 @@ import {AICallTree} from '../performance/AICallTree.js';
|
|
22
23
|
import {AgentFocus} from '../performance/AIContext.js';
|
23
24
|
|
24
25
|
import {
|
25
|
-
type AgentOptions,
|
26
26
|
AiAgent,
|
27
27
|
type ContextResponse,
|
28
28
|
ConversationContext,
|
29
|
-
type
|
29
|
+
type ConversationSuggestions,
|
30
30
|
type ParsedResponse,
|
31
31
|
type RequestOptions,
|
32
32
|
type ResponseData,
|
@@ -38,7 +38,6 @@ const UIStringsNotTranslated = {
|
|
38
38
|
*@description Shown when the agent is investigating a trace
|
39
39
|
*/
|
40
40
|
analyzingTrace: 'Analyzing trace',
|
41
|
-
analyzingCallTree: 'Analyzing call tree',
|
42
41
|
/**
|
43
42
|
* @description Shown when the agent is investigating network activity
|
44
43
|
*/
|
@@ -82,6 +81,7 @@ The 3 main performance metrics are:
|
|
82
81
|
|
83
82
|
Trace events referenced in the information given to you will be marked with an \`eventKey\`. For example: \`LCP element: <img src="..."> (eventKey: r-123, ts: 123456)\`
|
84
83
|
You can use this key with \`getEventByKey\` to get more information about that trace event. For example: \`getEventByKey('r-123')\`
|
84
|
+
You can also use this key with \`selectEventByKey\` to show the user a specific event
|
85
85
|
|
86
86
|
## Step-by-step instructions for debugging performance issues
|
87
87
|
|
@@ -173,6 +173,7 @@ export class PerformanceTraceContext extends ConversationContext<AgentFocus> {
|
|
173
173
|
}
|
174
174
|
|
175
175
|
#focus: AgentFocus;
|
176
|
+
external = false;
|
176
177
|
|
177
178
|
constructor(focus: AgentFocus) {
|
178
179
|
super();
|
@@ -196,51 +197,75 @@ export class PerformanceTraceContext extends ConversationContext<AgentFocus> {
|
|
196
197
|
url = new URL(focus.parsedTrace.data.Meta.mainFrameURL);
|
197
198
|
}
|
198
199
|
|
199
|
-
|
200
|
+
const parts = [`Trace: ${url.hostname}`];
|
201
|
+
if (focus.insight) {
|
202
|
+
parts.push(focus.insight.title);
|
203
|
+
}
|
204
|
+
if (focus.callTree) {
|
205
|
+
const node = focus.callTree.selectedNode ?? focus.callTree.rootNode;
|
206
|
+
parts.push(Trace.Name.forEntry(node.event));
|
207
|
+
}
|
208
|
+
return parts.join(' – ');
|
200
209
|
}
|
201
210
|
|
202
211
|
/**
|
203
212
|
* Presents the default suggestions that are shown when the user first clicks
|
204
213
|
* "Ask AI".
|
205
214
|
*/
|
206
|
-
override async getSuggestions(): Promise<
|
207
|
-
const
|
215
|
+
override async getSuggestions(): Promise<ConversationSuggestions|undefined> {
|
216
|
+
const data = this.#focus.data;
|
217
|
+
|
218
|
+
if (data.callTree) {
|
219
|
+
return [
|
220
|
+
{title: 'What\'s the purpose of this work?', jslogContext: 'performance-default'},
|
221
|
+
{title: 'Where is time being spent?', jslogContext: 'performance-default'},
|
222
|
+
{title: 'How can I optimize this?', jslogContext: 'performance-default'},
|
223
|
+
];
|
224
|
+
}
|
208
225
|
|
209
|
-
if (
|
210
|
-
return;
|
226
|
+
if (data.insight) {
|
227
|
+
return new PerformanceInsightFormatter(data.parsedTrace, data.insight).getSuggestions();
|
211
228
|
}
|
212
229
|
|
213
|
-
|
230
|
+
const suggestions: ConversationSuggestions =
|
231
|
+
[{title: 'What performance issues exist with my page?', jslogContext: 'performance-default'}];
|
232
|
+
|
233
|
+
if (data.insightSet) {
|
234
|
+
const lcp = data.insightSet ? Trace.Insights.Common.getLCP(data.insightSet) : null;
|
235
|
+
const cls = data.insightSet ? Trace.Insights.Common.getCLS(data.insightSet) : null;
|
236
|
+
const inp = data.insightSet ? Trace.Insights.Common.getINP(data.insightSet) : null;
|
237
|
+
|
238
|
+
const ModelHandlers = Trace.Handlers.ModelHandlers;
|
239
|
+
const GOOD = Trace.Handlers.ModelHandlers.PageLoadMetrics.ScoreClassification.GOOD;
|
240
|
+
|
241
|
+
if (lcp && ModelHandlers.PageLoadMetrics.scoreClassificationForLargestContentfulPaint(lcp.value) !== GOOD) {
|
242
|
+
suggestions.push({title: 'How can I improve LCP?', jslogContext: 'performance-default'});
|
243
|
+
}
|
244
|
+
if (inp && ModelHandlers.UserInteractions.scoreClassificationForInteractionToNextPaint(inp.value) !== GOOD) {
|
245
|
+
suggestions.push({title: 'How can I improve INP?', jslogContext: 'performance-default'});
|
246
|
+
}
|
247
|
+
if (cls && ModelHandlers.LayoutShifts.scoreClassificationForLayoutShift(cls.value) !== GOOD) {
|
248
|
+
suggestions.push({title: 'How can I improve CLS?', jslogContext: 'performance-default'});
|
249
|
+
}
|
250
|
+
}
|
251
|
+
|
252
|
+
return suggestions;
|
214
253
|
}
|
215
254
|
}
|
216
255
|
|
217
256
|
// 16k Tokens * ~4 char per token.
|
218
257
|
const MAX_FUNCTION_RESULT_BYTE_LENGTH = 16384 * 4;
|
219
258
|
|
220
|
-
/**
|
221
|
-
* Union of all the performance conversation types, which are all implemented by this file.
|
222
|
-
* This temporary until all Performance Panel AI features use the "Full" type. go/chrome-devtools:more-powerful-performance-agent-design
|
223
|
-
*/
|
224
|
-
type PerformanceConversationType =
|
225
|
-
ConversationType.PERFORMANCE_FULL|ConversationType.PERFORMANCE_CALL_TREE|ConversationType.PERFORMANCE_INSIGHT;
|
226
|
-
|
227
259
|
/**
|
228
260
|
* One agent instance handles one conversation. Create a new agent
|
229
261
|
* instance for a new conversation.
|
230
262
|
*/
|
231
263
|
export class PerformanceAgent extends AiAgent<AgentFocus> {
|
232
|
-
// TODO: would make more sense on AgentOptions
|
233
|
-
#conversationType: PerformanceConversationType;
|
234
264
|
#formatter: PerformanceTraceFormatter|null = null;
|
235
265
|
#lastInsightForEnhancedQuery: Trace.Insights.Types.InsightModel|undefined;
|
236
266
|
#eventsSerializer = new Trace.EventsSerializer.EventsSerializer();
|
237
267
|
#lastFocusHandledForContextDetails: AgentFocus|null = null;
|
238
268
|
|
239
|
-
constructor(opts: AgentOptions, conversationType: PerformanceConversationType) {
|
240
|
-
super(opts);
|
241
|
-
this.#conversationType = conversationType;
|
242
|
-
}
|
243
|
-
|
244
269
|
/**
|
245
270
|
* Cache of all function calls made by the agent. This allows us to include (as a
|
246
271
|
* fact) every function call to conversation requests, allowing the AI to access
|
@@ -285,7 +310,7 @@ export class PerformanceAgent extends AiAgent<AgentFocus> {
|
|
285
310
|
}
|
286
311
|
|
287
312
|
getConversationType(): ConversationType {
|
288
|
-
return
|
313
|
+
return ConversationType.PERFORMANCE;
|
289
314
|
}
|
290
315
|
|
291
316
|
#lookupEvent(key: Trace.Types.File.SerializableKey): Trace.Types.Events.Event|null {
|
@@ -318,31 +343,16 @@ export class PerformanceAgent extends AiAgent<AgentFocus> {
|
|
318
343
|
|
319
344
|
this.#lastFocusHandledForContextDetails = focus;
|
320
345
|
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
};
|
332
|
-
} else if (focus.data.type === 'call-tree') {
|
333
|
-
yield {
|
334
|
-
type: ResponseType.CONTEXT,
|
335
|
-
title: lockedString(UIStringsNotTranslated.analyzingCallTree),
|
336
|
-
details: [
|
337
|
-
{
|
338
|
-
title: 'Selected call tree',
|
339
|
-
text: focus.data.callTree.serialize(),
|
340
|
-
},
|
341
|
-
],
|
342
|
-
};
|
343
|
-
} else {
|
344
|
-
Platform.assertNever(focus.data, 'Unknown agent focus');
|
345
|
-
}
|
346
|
+
yield {
|
347
|
+
type: ResponseType.CONTEXT,
|
348
|
+
title: lockedString(UIStringsNotTranslated.analyzingTrace),
|
349
|
+
details: [
|
350
|
+
{
|
351
|
+
title: 'Trace',
|
352
|
+
text: this.#formatter?.formatTraceSummary() ?? '',
|
353
|
+
},
|
354
|
+
],
|
355
|
+
};
|
346
356
|
}
|
347
357
|
|
348
358
|
#callTreeContextSet = new WeakSet();
|
@@ -368,7 +378,7 @@ export class PerformanceAgent extends AiAgent<AgentFocus> {
|
|
368
378
|
return super.parseTextResponse(response);
|
369
379
|
}
|
370
380
|
|
371
|
-
override async enhanceQuery(query: string, context:
|
381
|
+
override async enhanceQuery(query: string, context: PerformanceTraceContext|null): Promise<string> {
|
372
382
|
if (!context) {
|
373
383
|
this.clearDeclaredFunctions();
|
374
384
|
return query;
|
@@ -378,12 +388,9 @@ export class PerformanceAgent extends AiAgent<AgentFocus> {
|
|
378
388
|
this.#declareFunctions(context);
|
379
389
|
|
380
390
|
const focus = context.getItem();
|
391
|
+
const selected: string[] = [];
|
381
392
|
|
382
|
-
if (focus.data.
|
383
|
-
return query;
|
384
|
-
}
|
385
|
-
|
386
|
-
if (focus.data.type === 'call-tree') {
|
393
|
+
if (focus.data.callTree) {
|
387
394
|
// If this is a followup chat about the same call tree, don't include the call tree serialization again.
|
388
395
|
// We don't need to repeat it and we'd rather have more the context window space.
|
389
396
|
let contextString = '';
|
@@ -392,17 +399,12 @@ export class PerformanceAgent extends AiAgent<AgentFocus> {
|
|
392
399
|
this.#callTreeContextSet.add(focus.data.callTree);
|
393
400
|
}
|
394
401
|
|
395
|
-
if (
|
396
|
-
|
402
|
+
if (contextString) {
|
403
|
+
selected.push(`User selected the following call tree:\n\n${contextString}\n\n`);
|
397
404
|
}
|
398
|
-
|
399
|
-
let enhancedQuery = '';
|
400
|
-
enhancedQuery += `User selected the following call tree:\n\n${contextString}\n\n`;
|
401
|
-
enhancedQuery += `# User query\n\n${query}`;
|
402
|
-
return enhancedQuery;
|
403
405
|
}
|
404
406
|
|
405
|
-
if (focus.data.
|
407
|
+
if (focus.data.insight) {
|
406
408
|
// We only need to add Insight info to a prompt when the context changes. For example:
|
407
409
|
// User clicks Insight A. We need to send info on Insight A with the prompt.
|
408
410
|
// User asks follow up question. We do not need to resend Insight A with the prompt.
|
@@ -411,17 +413,17 @@ export class PerformanceAgent extends AiAgent<AgentFocus> {
|
|
411
413
|
const includeInsightInfo = focus.data.insight !== this.#lastInsightForEnhancedQuery;
|
412
414
|
this.#lastInsightForEnhancedQuery = focus.data.insight;
|
413
415
|
|
414
|
-
if (
|
415
|
-
|
416
|
+
if (includeInsightInfo) {
|
417
|
+
selected.push(`User selected the ${focus.data.insight.insightKey} insight.\n\n`);
|
416
418
|
}
|
419
|
+
}
|
417
420
|
|
418
|
-
|
419
|
-
|
420
|
-
enhancedQuery += `# User query\n\n${query}`;
|
421
|
-
return enhancedQuery;
|
421
|
+
if (!selected.length) {
|
422
|
+
return query;
|
422
423
|
}
|
423
424
|
|
424
|
-
|
425
|
+
selected.push(`# User query\n\n${query}`);
|
426
|
+
return selected.join('');
|
425
427
|
}
|
426
428
|
|
427
429
|
override async * run(initialQuery: string, options: {
|
@@ -552,7 +554,7 @@ export class PerformanceAgent extends AiAgent<AgentFocus> {
|
|
552
554
|
this.#functionCallCacheForFocus.set(focus, cache);
|
553
555
|
}
|
554
556
|
|
555
|
-
#declareFunctions(context:
|
557
|
+
#declareFunctions(context: PerformanceTraceContext): void {
|
556
558
|
const focus = context.getItem();
|
557
559
|
const {parsedTrace, insightSet} = focus.data;
|
558
560
|
|
@@ -840,5 +842,38 @@ export class PerformanceAgent extends AiAgent<AgentFocus> {
|
|
840
842
|
|
841
843
|
});
|
842
844
|
}
|
845
|
+
|
846
|
+
if (!context.external) {
|
847
|
+
this.declareFunction<{eventKey: string}, {success: boolean}>('selectEventByKey', {
|
848
|
+
description:
|
849
|
+
'Selects the event in the flamechart for the user. If the user asks to show them something, it\'s likely a good idea to call this function.',
|
850
|
+
parameters: {
|
851
|
+
type: Host.AidaClient.ParametersTypes.OBJECT,
|
852
|
+
description: '',
|
853
|
+
nullable: false,
|
854
|
+
properties: {
|
855
|
+
eventKey: {
|
856
|
+
type: Host.AidaClient.ParametersTypes.STRING,
|
857
|
+
description: 'The key for the event.',
|
858
|
+
nullable: false,
|
859
|
+
}
|
860
|
+
},
|
861
|
+
},
|
862
|
+
displayInfoFromArgs: params => {
|
863
|
+
return {title: lockedString('Selecting event…'), action: `selectEventByKey('${params.eventKey}')`};
|
864
|
+
},
|
865
|
+
handler: async params => {
|
866
|
+
debugLog('Function call: selectEventByKey', params);
|
867
|
+
const event = this.#lookupEvent(params.eventKey as Trace.Types.File.SerializableKey);
|
868
|
+
if (!event) {
|
869
|
+
return {error: 'Invalid eventKey'};
|
870
|
+
}
|
871
|
+
|
872
|
+
const revealable = new SDK.TraceObject.RevealableEvent(event);
|
873
|
+
await Common.Revealer.reveal(revealable);
|
874
|
+
return {result: {success: true}};
|
875
|
+
},
|
876
|
+
});
|
877
|
+
}
|
843
878
|
}
|
844
879
|
}
|
@@ -116,7 +116,7 @@ export class PerformanceAnnotationsAgent extends AiAgent<AgentFocus> {
|
|
116
116
|
}
|
117
117
|
|
118
118
|
const focus = context.getItem();
|
119
|
-
if (focus.data.
|
119
|
+
if (!focus.data.callTree) {
|
120
120
|
throw new Error('unexpected context');
|
121
121
|
}
|
122
122
|
|
@@ -140,7 +140,7 @@ export class PerformanceAnnotationsAgent extends AiAgent<AgentFocus> {
|
|
140
140
|
}
|
141
141
|
|
142
142
|
const focus = context.getItem();
|
143
|
-
if (focus.data.
|
143
|
+
if (!focus.data.callTree) {
|
144
144
|
throw new Error('unexpected context');
|
145
145
|
}
|
146
146
|
|
@@ -18,7 +18,7 @@ import {
|
|
18
18
|
AiAgent,
|
19
19
|
type ContextResponse,
|
20
20
|
ConversationContext,
|
21
|
-
type
|
21
|
+
type ConversationSuggestions,
|
22
22
|
type FunctionCallHandlerResult,
|
23
23
|
MultimodalInputType,
|
24
24
|
type ParsedResponse,
|
@@ -182,7 +182,7 @@ export class NodeContext extends ConversationContext<SDK.DOMModel.DOMNode> {
|
|
182
182
|
throw new Error('Not implemented');
|
183
183
|
}
|
184
184
|
|
185
|
-
override async getSuggestions(): Promise<
|
185
|
+
override async getSuggestions(): Promise<ConversationSuggestions|undefined> {
|
186
186
|
const layoutProps = await this.#node.domModel().cssModel().getLayoutPropertiesFromComputedStyle(this.#node.id);
|
187
187
|
|
188
188
|
if (!layoutProps) {
|