chrome-devtools-frontend 1.0.1602543 → 1.0.1604514
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/.agents/skills/version-control/SKILL.md +17 -2
- package/front_end/core/host/AidaClient.ts +39 -462
- package/front_end/core/host/AidaClientTypes.ts +470 -0
- package/front_end/core/host/AidaGcaTranslation.ts +225 -122
- package/front_end/core/host/GcaTypes.ts +107 -155
- package/front_end/core/protocol_client/DevToolsCDPConnection.ts +1 -1
- package/front_end/core/sdk/DOMModel.ts +24 -22
- package/front_end/core/sdk/EmulationModel.ts +21 -23
- package/front_end/core/sdk/HeapProfilerModel.ts +4 -7
- package/front_end/core/sdk/NetworkManager.ts +35 -28
- package/front_end/core/sdk/OverlayModel.ts +23 -23
- package/front_end/core/sdk/OverlayPersistentHighlighter.ts +13 -10
- package/front_end/core/sdk/PreloadingModel.ts +3 -4
- package/front_end/core/sdk/RuntimeModel.ts +5 -5
- package/front_end/core/sdk/ServiceWorkerManager.ts +6 -5
- package/front_end/core/sdk/SourceMapScopesInfo.ts +93 -63
- package/front_end/core/sdk/TargetManager.ts +5 -0
- package/front_end/core/sdk/WebMCPModel.ts +6 -0
- package/front_end/entrypoints/formatter_worker/FormatterWorker.ts +1 -3
- package/front_end/entrypoints/heap_snapshot_worker/AllocationProfile.ts +22 -48
- package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshot.ts +1 -1
- package/front_end/generated/InspectorBackendCommands.ts +7 -0
- package/front_end/generated/SupportedCSSProperties.js +68 -2
- package/front_end/generated/protocol-mapping.d.ts +15 -0
- package/front_end/generated/protocol-proxy-api.d.ts +24 -0
- package/front_end/generated/protocol.ts +79 -0
- package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +16 -5
- package/front_end/models/ai_assistance/data_formatters/LighthouseFormatter.snapshot.txt +60 -9
- package/front_end/models/ai_assistance/data_formatters/LighthouseFormatter.ts +71 -15
- package/front_end/models/bindings/TempFile.ts +1 -4
- package/front_end/models/extensions/ExtensionAPI.ts +1 -1
- package/front_end/models/heap_snapshot_model/HeapSnapshotModel.ts +34 -47
- package/front_end/models/javascript_metadata/NativeFunctions.js +12 -8
- package/front_end/models/lighthouse/LighthouseReporterTypes.ts +10 -8
- package/front_end/panels/ai_assistance/AiAssistancePanel.ts +91 -21
- package/front_end/panels/ai_assistance/components/ChatMessage.ts +90 -32
- package/front_end/panels/ai_assistance/components/ChatView.ts +3 -2
- package/front_end/panels/ai_assistance/components/WalkthroughView.ts +65 -17
- package/front_end/panels/ai_assistance/components/chatMessage.css +33 -7
- package/front_end/panels/ai_assistance/components/walkthroughView.css +35 -5
- package/front_end/panels/common/ThrottlingUtils.ts +46 -0
- package/front_end/panels/common/common.ts +1 -0
- package/front_end/panels/elements/ComputedStyleWidget.ts +11 -1
- package/front_end/panels/elements/ElementsTreeElement.ts +91 -13
- package/front_end/panels/elements/StandaloneStylesContainer.ts +0 -3
- package/front_end/panels/elements/StylePropertiesSection.ts +0 -49
- package/front_end/panels/elements/StylesContainer.ts +0 -1
- package/front_end/panels/elements/StylesSidebarPane.ts +32 -7
- package/front_end/panels/elements/elementsTreeOutline.css +18 -0
- package/front_end/panels/mobile_throttling/NetworkThrottlingSelector.ts +14 -0
- package/front_end/panels/profiler/HeapSnapshotDataGrids.ts +15 -19
- package/front_end/panels/profiler/HeapSnapshotGridNodes.ts +4 -2
- package/front_end/panels/profiler/HeapSnapshotProxy.ts +12 -16
- package/front_end/panels/profiler/HeapSnapshotView.ts +3 -10
- package/front_end/panels/profiler/ProfileView.ts +0 -9
- package/front_end/panels/profiler/ProfilesPanel.ts +5 -7
- package/front_end/panels/sensors/SensorsView.ts +0 -2
- package/front_end/panels/settings/keybindsSettingsTab.css +25 -31
- package/front_end/panels/timeline/ThirdPartyTreeView.ts +8 -0
- package/front_end/panels/timeline/TimelinePanel.ts +15 -5
- package/front_end/panels/timeline/components/FieldSettingsDialog.ts +5 -9
- package/front_end/panels/timeline/components/LiveMetricsView.ts +36 -65
- package/front_end/panels/timeline/components/OriginMap.ts +176 -159
- package/front_end/panels/timeline/components/liveMetricsView.css +4 -0
- package/front_end/panels/timeline/components/originMap.css +4 -51
- package/front_end/panels/timeline/thirdPartyTreeView.css +6 -0
- package/front_end/panels/timeline/timeline-meta.ts +11 -0
- package/front_end/panels/timeline/utils/Helpers.ts +5 -25
- package/front_end/third_party/acorn/README.chromium +1 -0
- package/front_end/third_party/chromium/README.chromium +1 -1
- package/front_end/ui/components/{list → lists}/List.ts +1 -1
- package/front_end/ui/components/{list → lists}/list.css +0 -1
- package/front_end/ui/legacy/components/data_grid/DataGridElement.ts +3 -3
- package/package.json +1 -1
- /package/front_end/ui/components/{list → lists}/lists.ts +0 -0
|
@@ -18,6 +18,7 @@ import type {
|
|
|
18
18
|
import * as AiAssistanceModel from '../../../models/ai_assistance/ai_assistance.js';
|
|
19
19
|
import * as ComputedStyle from '../../../models/computed_style/computed_style.js';
|
|
20
20
|
import * as Trace from '../../../models/trace/trace.js';
|
|
21
|
+
import * as PanelsCommon from '../../../panels/common/common.js';
|
|
21
22
|
import * as Marked from '../../../third_party/marked/marked.js';
|
|
22
23
|
import * as Buttons from '../../../ui/components/buttons/buttons.js';
|
|
23
24
|
import * as Input from '../../../ui/components/input/input.js';
|
|
@@ -35,7 +36,7 @@ import * as TimelineUtils from '../../timeline/utils/utils.js';
|
|
|
35
36
|
import {PanelUtils} from '../../utils/utils.js';
|
|
36
37
|
|
|
37
38
|
import chatMessageStyles from './chatMessage.css.js';
|
|
38
|
-
import {walkthroughTitle, WalkthroughView} from './WalkthroughView.js';
|
|
39
|
+
import {walkthroughCloseTitle, walkthroughTitle, WalkthroughView} from './WalkthroughView.js';
|
|
39
40
|
|
|
40
41
|
const {html, Directives: {ref, ifDefined}} = Lit;
|
|
41
42
|
const lockedString = i18n.i18n.lockedString;
|
|
@@ -48,7 +49,6 @@ const SCROLL_ROUNDING_OFFSET = 1;
|
|
|
48
49
|
* Strings that don't need to be translated at this time.
|
|
49
50
|
*/
|
|
50
51
|
const UIStringsNotTranslate = {
|
|
51
|
-
|
|
52
52
|
/**
|
|
53
53
|
* @description The title of the button that allows submitting positive
|
|
54
54
|
* feedback about the response for AI assistance.
|
|
@@ -170,11 +170,6 @@ const UIStringsNotTranslate = {
|
|
|
170
170
|
* @description Alt text for image when it is not available.
|
|
171
171
|
*/
|
|
172
172
|
imageUnavailable: 'Image unavailable',
|
|
173
|
-
/**
|
|
174
|
-
* @description Title for the button that shows the thinking process (walkthrough).
|
|
175
|
-
*/
|
|
176
|
-
showThinking: 'Show thinking',
|
|
177
|
-
|
|
178
173
|
/**
|
|
179
174
|
* @description Title for the button that takes the user into other DevTools panels to reveal items the AI references.
|
|
180
175
|
*/
|
|
@@ -182,7 +177,23 @@ const UIStringsNotTranslate = {
|
|
|
182
177
|
/**
|
|
183
178
|
* @description Title used for revealing the performance trace.
|
|
184
179
|
*/
|
|
185
|
-
revealTrace: 'Reveal trace'
|
|
180
|
+
revealTrace: 'Reveal trace',
|
|
181
|
+
/**
|
|
182
|
+
* @description Title for the core web vitals widget.
|
|
183
|
+
*/
|
|
184
|
+
coreVitals: 'Core Web Vitals',
|
|
185
|
+
/**
|
|
186
|
+
* @description Title for the LCP breakdown widget.
|
|
187
|
+
*/
|
|
188
|
+
lcpBreakdown: 'LCP breakdown',
|
|
189
|
+
/**
|
|
190
|
+
* @description Title for the LCP element widget.
|
|
191
|
+
*/
|
|
192
|
+
lcpElement: 'LCP element',
|
|
193
|
+
/**
|
|
194
|
+
* @description Title for the performance summary widget.
|
|
195
|
+
*/
|
|
196
|
+
performanceSummary: 'Performance summary'
|
|
186
197
|
} as const;
|
|
187
198
|
|
|
188
199
|
export interface Step {
|
|
@@ -290,9 +301,10 @@ export interface MessageInput {
|
|
|
290
301
|
walkthrough: {
|
|
291
302
|
onOpen: (message: ModelChatMessage) => void,
|
|
292
303
|
isExpanded: boolean,
|
|
293
|
-
onToggle: (isOpen: boolean) => void,
|
|
304
|
+
onToggle: (isOpen: boolean, message: ModelChatMessage) => void,
|
|
294
305
|
isInlined: boolean,
|
|
295
|
-
|
|
306
|
+
activeSidebarMessage: ModelChatMessage|null,
|
|
307
|
+
inlineExpandedMessages: ModelChatMessage[],
|
|
296
308
|
};
|
|
297
309
|
}
|
|
298
310
|
|
|
@@ -496,25 +508,31 @@ function renderWalkthroughSidebarButton(
|
|
|
496
508
|
}
|
|
497
509
|
|
|
498
510
|
const hasOneStepWithWidget = steps.some(step => step.widgets?.length);
|
|
499
|
-
const
|
|
511
|
+
const isExpanded = walkthrough.isExpanded && input.message === input.walkthrough.activeSidebarMessage;
|
|
512
|
+
const title = isExpanded ? walkthroughCloseTitle({hasWidgets: hasOneStepWithWidget}) : walkthroughTitle({
|
|
500
513
|
isLoading: input.isLoading,
|
|
501
514
|
hasWidgets: hasOneStepWithWidget,
|
|
502
515
|
lastStep,
|
|
503
516
|
});
|
|
504
517
|
|
|
518
|
+
// The button should be tonal when there are widgets, but we only
|
|
519
|
+
// want to change it visually at the end once everything has stopped
|
|
520
|
+
// loading.
|
|
521
|
+
const variant = hasOneStepWithWidget && !input.isLoading ? Buttons.Button.Variant.TONAL : Buttons.Button.Variant.TEXT;
|
|
522
|
+
|
|
505
523
|
// clang-format off
|
|
506
524
|
return html`
|
|
507
525
|
<div class="walkthrough-toggle-container">
|
|
508
526
|
${input.isLoading ? html`<devtools-spinner></devtools-spinner>` : Lit.nothing}
|
|
509
527
|
<devtools-button
|
|
510
|
-
.variant=${
|
|
528
|
+
.variant=${variant}
|
|
511
529
|
.size=${Buttons.Button.Size.SMALL}
|
|
512
|
-
.title=${lastStep.isLoading ? titleForStep(lastStep) :
|
|
530
|
+
.title=${lastStep.isLoading ? titleForStep(lastStep) : title}
|
|
513
531
|
.jslogContext=${walkthrough.isExpanded ? 'ai-hide-walkthrough-sidebar' : 'ai-show-walkthrough-sidebar'}
|
|
514
532
|
data-show-walkthrough
|
|
515
533
|
@click=${() => {
|
|
516
|
-
if(walkthrough.
|
|
517
|
-
walkthrough.onToggle(false);
|
|
534
|
+
if(walkthrough.activeSidebarMessage === input.message && walkthrough.isExpanded) {
|
|
535
|
+
walkthrough.onToggle(false, message as ModelChatMessage);
|
|
518
536
|
} else {
|
|
519
537
|
// Can't just toggle the visibility here; we need to ensure we
|
|
520
538
|
// update the state with this message as the user could have had
|
|
@@ -522,7 +540,9 @@ function renderWalkthroughSidebarButton(
|
|
|
522
540
|
walkthrough.onOpen(message as ModelChatMessage);
|
|
523
541
|
}
|
|
524
542
|
}}
|
|
525
|
-
|
|
543
|
+
>
|
|
544
|
+
${title}<devtools-icon class="chevron" .name=${'chevron-right'}></devtools-icon>
|
|
545
|
+
</devtools-button>
|
|
526
546
|
</div>
|
|
527
547
|
`;
|
|
528
548
|
// clang-format on
|
|
@@ -548,7 +568,9 @@ function renderWalkthroughUI(input: ChatMessageViewInput, steps: Step[]): Lit.Li
|
|
|
548
568
|
// A message's walkthrough is considered expanded if the walkthrough is
|
|
549
569
|
// open and it is specifically targeting this message. This is necessary
|
|
550
570
|
// because the walkthrough state is shared across all messages in the chat.
|
|
551
|
-
const isExpanded =
|
|
571
|
+
const isExpanded = input.walkthrough.isInlined ?
|
|
572
|
+
input.walkthrough.inlineExpandedMessages.includes(input.message as ModelChatMessage) :
|
|
573
|
+
(input.walkthrough.isExpanded && input.walkthrough.activeSidebarMessage === input.message);
|
|
552
574
|
|
|
553
575
|
// When a side-effect step is present, it's shown in the main chat UI if the
|
|
554
576
|
// walkthrough is closed, allowing the user to approve it without opening
|
|
@@ -657,7 +679,8 @@ interface WidgetMakerResponse {
|
|
|
657
679
|
renderedWidget: Lit.LitTemplate|null;
|
|
658
680
|
revealable: unknown;
|
|
659
681
|
customRevealTitle?: Platform.UIString.LocalizedString;
|
|
660
|
-
|
|
682
|
+
// Can be null if the widget is only used to add the Reveal CTA.
|
|
683
|
+
title: Lit.LitTemplate|Platform.UIString.LocalizedString|null;
|
|
661
684
|
}
|
|
662
685
|
|
|
663
686
|
const nodeCache = new Map<Protocol.DOM.BackendNodeId, SDK.DOMModel.DOMNode>();
|
|
@@ -696,11 +719,20 @@ async function makeComputedStyleWidget(widgetData: ComputedStyleAiWidget): Promi
|
|
|
696
719
|
// This disables showing the nested traces and detailed information in the widget.
|
|
697
720
|
propertyTraces: null,
|
|
698
721
|
allowUserControl: false,
|
|
699
|
-
filterText: new RegExp(widgetData.data.properties.join('|'), 'i')
|
|
722
|
+
filterText: new RegExp(widgetData.data.properties.join('|'), 'i'),
|
|
723
|
+
enableNarrowViewResizing: false,
|
|
700
724
|
})}></devtools-widget>`;
|
|
701
725
|
// clang-format on
|
|
702
726
|
|
|
703
|
-
return {
|
|
727
|
+
return {
|
|
728
|
+
renderedWidget,
|
|
729
|
+
revealable: new Elements.ElementsPanel.NodeComputedStyles(domNodeForId),
|
|
730
|
+
title: html`<devtools-widget
|
|
731
|
+
${widget(PanelsCommon.DOMLinkifier.DOMNodeLink, {
|
|
732
|
+
node: domNodeForId,
|
|
733
|
+
})}
|
|
734
|
+
></devtools-widget>`,
|
|
735
|
+
};
|
|
704
736
|
}
|
|
705
737
|
|
|
706
738
|
async function makeCoreVitalsWidget(widgetData: CoreVitalsAiWidget): Promise<WidgetMakerResponse|null> {
|
|
@@ -710,7 +742,11 @@ async function makeCoreVitalsWidget(widgetData: CoreVitalsAiWidget): Promise<Wid
|
|
|
710
742
|
</devtools-widget>`;
|
|
711
743
|
// clang-format on
|
|
712
744
|
|
|
713
|
-
return {
|
|
745
|
+
return {
|
|
746
|
+
renderedWidget,
|
|
747
|
+
revealable: new TimelineUtils.Helpers.RevealableCoreVitals(widgetData.data.insightSetKey),
|
|
748
|
+
title: lockedString(UIStringsNotTranslate.coreVitals),
|
|
749
|
+
};
|
|
714
750
|
}
|
|
715
751
|
|
|
716
752
|
async function makeStylePropertiesWidget(widgetData: StylePropertiesAiWidget): Promise<WidgetMakerResponse|null> {
|
|
@@ -729,7 +765,15 @@ async function makeStylePropertiesWidget(widgetData: StylePropertiesAiWidget): P
|
|
|
729
765
|
</devtools-widget>`;
|
|
730
766
|
// clang-format on
|
|
731
767
|
|
|
732
|
-
return {
|
|
768
|
+
return {
|
|
769
|
+
renderedWidget,
|
|
770
|
+
revealable: domNodeForId,
|
|
771
|
+
title: html`<devtools-widget
|
|
772
|
+
${widget(PanelsCommon.DOMLinkifier.DOMNodeLink, {
|
|
773
|
+
node: domNodeForId,
|
|
774
|
+
})}
|
|
775
|
+
></devtools-widget>`,
|
|
776
|
+
};
|
|
733
777
|
}
|
|
734
778
|
|
|
735
779
|
async function makeLcpBreakdownWidget(widgetData: LcpBreakdownAiWidget): Promise<WidgetMakerResponse|null> {
|
|
@@ -747,7 +791,11 @@ async function makeLcpBreakdownWidget(widgetData: LcpBreakdownAiWidget): Promise
|
|
|
747
791
|
})}></devtools-widget>`;
|
|
748
792
|
// clang-format on
|
|
749
793
|
|
|
750
|
-
return {
|
|
794
|
+
return {
|
|
795
|
+
renderedWidget,
|
|
796
|
+
revealable: new TimelineUtils.Helpers.RevealableInsight(insight),
|
|
797
|
+
title: lockedString(UIStringsNotTranslate.lcpBreakdown),
|
|
798
|
+
};
|
|
751
799
|
}
|
|
752
800
|
|
|
753
801
|
function renderWidgetResponse(response: WidgetMakerResponse|null): Lit.LitTemplate {
|
|
@@ -768,19 +816,21 @@ function renderWidgetResponse(response: WidgetMakerResponse|null): Lit.LitTempla
|
|
|
768
816
|
});
|
|
769
817
|
|
|
770
818
|
const revealButton = html`
|
|
771
|
-
<devtools-button class="widget-reveal"
|
|
772
|
-
.iconName=${'tab-move'}
|
|
819
|
+
<devtools-button class="widget-reveal-button"
|
|
773
820
|
.variant=${Buttons.Button.Variant.TEXT}
|
|
774
821
|
@click=${onReveal}
|
|
775
|
-
|
|
822
|
+
>
|
|
823
|
+
${response.customRevealTitle ?? lockedString(UIStringsNotTranslate.reveal)}
|
|
824
|
+
<devtools-icon name='tab-move'></devtools-icon>
|
|
825
|
+
</devtools-button>
|
|
776
826
|
`;
|
|
777
827
|
|
|
778
828
|
// clang-format off
|
|
779
829
|
return html`
|
|
780
830
|
<div class=${classes}>
|
|
781
|
-
${response.
|
|
831
|
+
${response.title ? html`
|
|
782
832
|
<div class="widget-header">
|
|
783
|
-
<div class="widget-name">${response.
|
|
833
|
+
<div class="widget-name">${response.title}</div>
|
|
784
834
|
<div class="widget-reveal-container">
|
|
785
835
|
${revealButton}
|
|
786
836
|
</div>
|
|
@@ -791,7 +841,7 @@ function renderWidgetResponse(response: WidgetMakerResponse|null): Lit.LitTempla
|
|
|
791
841
|
${response.renderedWidget}
|
|
792
842
|
</div>` : Lit.nothing
|
|
793
843
|
}
|
|
794
|
-
${!response.
|
|
844
|
+
${!response.title ? html`
|
|
795
845
|
<div class="widget-reveal-container">
|
|
796
846
|
${revealButton}
|
|
797
847
|
</div>
|
|
@@ -804,6 +854,7 @@ function renderWidgetResponse(response: WidgetMakerResponse|null): Lit.LitTempla
|
|
|
804
854
|
async function makePerformanceTraceWidget(widgetData: PerformanceTraceAiWidget): Promise<WidgetMakerResponse|null> {
|
|
805
855
|
return {
|
|
806
856
|
renderedWidget: null,
|
|
857
|
+
title: null,
|
|
807
858
|
revealable: new Timeline.TimelinePanel.ParsedTraceRevealable(widgetData.data.parsedTrace),
|
|
808
859
|
customRevealTitle: lockedString(UIStringsNotTranslate.revealTrace),
|
|
809
860
|
};
|
|
@@ -863,7 +914,7 @@ async function makeDomTreeWidget(widgetData: DomTreeAiWidget): Promise<WidgetMak
|
|
|
863
914
|
return {
|
|
864
915
|
renderedWidget,
|
|
865
916
|
revealable: new SDK.DOMModel.DeferredDOMNode(root.domModel().target(), root.backendNodeId()),
|
|
866
|
-
|
|
917
|
+
title: lockedString(UIStringsNotTranslate.lcpElement),
|
|
867
918
|
};
|
|
868
919
|
}
|
|
869
920
|
|
|
@@ -1180,7 +1231,8 @@ export class ChatMessage extends UI.Widget.Widget {
|
|
|
1180
1231
|
onToggle: () => {},
|
|
1181
1232
|
isInlined: false,
|
|
1182
1233
|
isExpanded: false,
|
|
1183
|
-
|
|
1234
|
+
activeSidebarMessage: null,
|
|
1235
|
+
inlineExpandedMessages: [],
|
|
1184
1236
|
};
|
|
1185
1237
|
|
|
1186
1238
|
#suggestionsResizeObserver = new ResizeObserver(() => this.#handleSuggestionsScrollOrResize());
|
|
@@ -1359,6 +1411,7 @@ async function makeTimelineRangeSummaryWidget(widgetData: TimelineRangeSummaryAi
|
|
|
1359
1411
|
const thirdPartyTree = new Timeline.ThirdPartyTreeView.ThirdPartyTreeViewWidget();
|
|
1360
1412
|
const mapper = new Trace.EntityMapper.EntityMapper(parsedTrace);
|
|
1361
1413
|
thirdPartyTree.setModelWithEvents(eventsArray, parsedTrace, mapper);
|
|
1414
|
+
thirdPartyTree.updateContents(Timeline.TimelineSelection.selectionFromRangeMicroSeconds(bounds.min, bounds.max));
|
|
1362
1415
|
thirdPartyTree.refreshTree(true);
|
|
1363
1416
|
|
|
1364
1417
|
// clang-format off
|
|
@@ -1371,11 +1424,16 @@ async function makeTimelineRangeSummaryWidget(widgetData: TimelineRangeSummaryAi
|
|
|
1371
1424
|
startTime: Trace.Helpers.Timing.microToMilli(bounds.min),
|
|
1372
1425
|
endTime: Trace.Helpers.Timing.microToMilli(bounds.max),
|
|
1373
1426
|
thirdPartyTreeTemplate: html`<devtools-performance-third-party-tree-view
|
|
1427
|
+
max-rows="10"
|
|
1374
1428
|
.treeView=${thirdPartyTree}></devtools-performance-third-party-tree-view>`,
|
|
1375
1429
|
} as TimelineComponents.TimelineRangeSummaryView.TimelineRangeSummaryViewData,
|
|
1376
1430
|
})}
|
|
1377
1431
|
></devtools-widget>`;
|
|
1378
1432
|
// clang-format on
|
|
1379
1433
|
|
|
1380
|
-
return {
|
|
1434
|
+
return {
|
|
1435
|
+
renderedWidget: template,
|
|
1436
|
+
revealable: new TimelineUtils.Helpers.RevealableTimeRange(bounds),
|
|
1437
|
+
title: lockedString(UIStringsNotTranslate.performanceSummary),
|
|
1438
|
+
};
|
|
1381
1439
|
}
|
|
@@ -88,10 +88,11 @@ export interface Props {
|
|
|
88
88
|
generateConversationSummary: (markdown: string) => Promise<string>;
|
|
89
89
|
walkthrough: {
|
|
90
90
|
onOpen: (message: ModelChatMessage) => void,
|
|
91
|
-
onToggle: (isOpen: boolean) => void,
|
|
91
|
+
onToggle: (isOpen: boolean, message: ModelChatMessage) => void,
|
|
92
92
|
isExpanded: boolean,
|
|
93
93
|
isInlined: boolean,
|
|
94
|
-
|
|
94
|
+
activeSidebarMessage: ModelChatMessage|null,
|
|
95
|
+
inlineExpandedMessages: ModelChatMessage[],
|
|
95
96
|
};
|
|
96
97
|
}
|
|
97
98
|
|
|
@@ -36,6 +36,14 @@ const UIStrings = {
|
|
|
36
36
|
* @description Title for the button that shows the walkthrough when there are widgets in the walkthrough.
|
|
37
37
|
*/
|
|
38
38
|
showAgentWalkthrough: 'Show agent walkthrough',
|
|
39
|
+
/**
|
|
40
|
+
* @description Title for the button that hides the walkthrough when there are no widgets in the walkthrough.
|
|
41
|
+
*/
|
|
42
|
+
hideThinking: 'Hide thinking',
|
|
43
|
+
/**
|
|
44
|
+
* @description Title for the button that hides the walkthrough when there are widgets in the walkthrough.
|
|
45
|
+
*/
|
|
46
|
+
hideAgentWalkthrough: 'Hide agent walkthrough',
|
|
39
47
|
} as const;
|
|
40
48
|
const str_ = i18n.i18n.registerUIStrings('panels/ai_assistance/components/WalkthroughView.ts', UIStrings);
|
|
41
49
|
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
|
|
@@ -46,7 +54,7 @@ export interface ViewInput {
|
|
|
46
54
|
markdownRenderer: MarkdownLitRenderer;
|
|
47
55
|
isInlined: boolean;
|
|
48
56
|
isExpanded: boolean;
|
|
49
|
-
onToggle: (isOpen: boolean) => void;
|
|
57
|
+
onToggle: (isOpen: boolean, message: ModelChatMessage) => void;
|
|
50
58
|
onOpen: (message: ModelChatMessage) => void;
|
|
51
59
|
handleScroll: (ev: Event) => void;
|
|
52
60
|
}
|
|
@@ -70,6 +78,19 @@ export function walkthroughTitle(input: {
|
|
|
70
78
|
return lockedString(UIStrings.showThinking);
|
|
71
79
|
}
|
|
72
80
|
|
|
81
|
+
export function walkthroughCloseTitle(input: {
|
|
82
|
+
hasWidgets: boolean,
|
|
83
|
+
isInlined?: boolean,
|
|
84
|
+
}): string {
|
|
85
|
+
if (input.isInlined) {
|
|
86
|
+
return i18nString(UIStrings.title);
|
|
87
|
+
}
|
|
88
|
+
if (input.hasWidgets) {
|
|
89
|
+
return lockedString(UIStrings.hideAgentWalkthrough);
|
|
90
|
+
}
|
|
91
|
+
return lockedString(UIStrings.hideThinking);
|
|
92
|
+
}
|
|
93
|
+
|
|
73
94
|
function renderInlineWalkthrough(input: ViewInput, stepsOutput: Lit.LitTemplate, steps: Step[]): Lit.LitTemplate {
|
|
74
95
|
const lastStep = steps.at(-1);
|
|
75
96
|
if (!input.isInlined || !lastStep) {
|
|
@@ -78,10 +99,13 @@ function renderInlineWalkthrough(input: ViewInput, stepsOutput: Lit.LitTemplate,
|
|
|
78
99
|
|
|
79
100
|
function onToggle(event: Event): void {
|
|
80
101
|
const isOpen = (event.target as HTMLDetailsElement).open;
|
|
81
|
-
if (
|
|
102
|
+
if (!input.message) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (isOpen) {
|
|
82
106
|
input.onOpen(input.message);
|
|
83
107
|
} else {
|
|
84
|
-
input.onToggle(isOpen);
|
|
108
|
+
input.onToggle(isOpen, input.message);
|
|
85
109
|
}
|
|
86
110
|
}
|
|
87
111
|
|
|
@@ -90,10 +114,10 @@ function renderInlineWalkthrough(input: ViewInput, stepsOutput: Lit.LitTemplate,
|
|
|
90
114
|
// clang-format off
|
|
91
115
|
return html`
|
|
92
116
|
<details class="walkthrough-inline" ?open=${input.isExpanded} @toggle=${onToggle}>
|
|
93
|
-
<summary>
|
|
117
|
+
<summary ?data-has-widgets=${!input.isLoading && hasWidgets}>
|
|
94
118
|
${input.isLoading ? html`<devtools-spinner></devtools-spinner>` : Lit.nothing}
|
|
95
|
-
${walkthroughTitle({isLoading: input.isLoading, lastStep, hasWidgets})}
|
|
96
|
-
<devtools-icon name="chevron-
|
|
119
|
+
${input.isExpanded ? walkthroughCloseTitle({hasWidgets, isInlined: true}) : walkthroughTitle({isLoading: input.isLoading, lastStep, hasWidgets})}
|
|
120
|
+
<devtools-icon name="chevron-right"></devtools-icon>
|
|
97
121
|
</summary>
|
|
98
122
|
${stepsOutput}
|
|
99
123
|
</details>
|
|
@@ -118,7 +142,11 @@ function renderSidebarWalkthrough(input: ViewInput, stepsOutput: Lit.LitTemplate
|
|
|
118
142
|
title: i18nString(UIStrings.close),
|
|
119
143
|
jslogContext: 'close-walkthrough',
|
|
120
144
|
} as Buttons.Button.ButtonData}
|
|
121
|
-
@click=${() =>
|
|
145
|
+
@click=${() => {
|
|
146
|
+
if (input.message) {
|
|
147
|
+
input.onToggle(false, input.message);
|
|
148
|
+
}
|
|
149
|
+
}}
|
|
122
150
|
></devtools-button>
|
|
123
151
|
</div>
|
|
124
152
|
${stepsOutput}
|
|
@@ -182,11 +210,9 @@ export class WalkthroughView extends UI.Widget.Widget {
|
|
|
182
210
|
#view: View;
|
|
183
211
|
|
|
184
212
|
#message: ModelChatMessage|null = null;
|
|
185
|
-
// TODO(b/487921187): fix loading state - also unsure if we need this vs
|
|
186
|
-
// looking at the loading state in the message's steps.
|
|
187
213
|
#isLoading = false;
|
|
188
214
|
#markdownRenderer: MarkdownLitRenderer|null = null;
|
|
189
|
-
#onToggle: (isOpen: boolean) => void = () => {};
|
|
215
|
+
#onToggle: (isOpen: boolean, message: ModelChatMessage) => void = () => {};
|
|
190
216
|
#onOpen: (message: ModelChatMessage) => void = () => {};
|
|
191
217
|
#isInlined = false;
|
|
192
218
|
#isExpanded = false;
|
|
@@ -196,6 +222,7 @@ export class WalkthroughView extends UI.Widget.Widget {
|
|
|
196
222
|
|
|
197
223
|
#output: ViewOutput = {};
|
|
198
224
|
#stepsContainerResizeObserver = new ResizeObserver(() => this.#handleStepsContainerResize());
|
|
225
|
+
#lastStepsContainerWidth = 0;
|
|
199
226
|
|
|
200
227
|
constructor(element?: HTMLElement, view: View = DEFAULT_VIEW) {
|
|
201
228
|
super(element);
|
|
@@ -218,12 +245,27 @@ export class WalkthroughView extends UI.Widget.Widget {
|
|
|
218
245
|
}
|
|
219
246
|
}
|
|
220
247
|
|
|
221
|
-
override onResize(): void {
|
|
222
|
-
this.#handleStepsContainerResize();
|
|
223
|
-
}
|
|
224
|
-
|
|
225
248
|
#handleStepsContainerResize(): void {
|
|
226
|
-
|
|
249
|
+
const width = this.#output.stepsContainer?.offsetWidth ?? 0;
|
|
250
|
+
/**
|
|
251
|
+
* If the width has changed, it's likely due to a manual resize (e.g., the
|
|
252
|
+
* user dragging the sidebar). In these cases, we want to avoid jumping the
|
|
253
|
+
* scroll position to the bottom, as it can be jarring for the user. We
|
|
254
|
+
* only auto-scroll if the width remains the same, meaning only the height
|
|
255
|
+
* has changed (likely due to new content being added).
|
|
256
|
+
*/
|
|
257
|
+
if (width !== this.#lastStepsContainerWidth) {
|
|
258
|
+
this.#lastStepsContainerWidth = width;
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* We only want to auto-scroll if the walkthrough is "live", which means it's
|
|
264
|
+
* currently loading. If it's not loading, it's a walkthrough for a previous
|
|
265
|
+
* message, and we don't want to jump the user to the bottom if they've
|
|
266
|
+
* scrolled away.
|
|
267
|
+
*/
|
|
268
|
+
if (!this.#pinScrollToBottom || !this.#isLoading) {
|
|
227
269
|
return;
|
|
228
270
|
}
|
|
229
271
|
|
|
@@ -304,7 +346,7 @@ export class WalkthroughView extends UI.Widget.Widget {
|
|
|
304
346
|
this.requestUpdate();
|
|
305
347
|
}
|
|
306
348
|
|
|
307
|
-
set onToggle(onToggle: (isOpen: boolean) => void) {
|
|
349
|
+
set onToggle(onToggle: (isOpen: boolean, message: ModelChatMessage) => void) {
|
|
308
350
|
this.#onToggle = onToggle;
|
|
309
351
|
this.requestUpdate();
|
|
310
352
|
}
|
|
@@ -338,7 +380,13 @@ export class WalkthroughView extends UI.Widget.Widget {
|
|
|
338
380
|
|
|
339
381
|
this.#registerResizeObservers();
|
|
340
382
|
|
|
341
|
-
|
|
383
|
+
/**
|
|
384
|
+
* We only want to auto-scroll if the walkthrough is "live", which means it's
|
|
385
|
+
* currently loading. If it's not loading, it's a walkthrough for a previous
|
|
386
|
+
* message, and we don't want to jump the user to the bottom if they've
|
|
387
|
+
* scrolled away.
|
|
388
|
+
*/
|
|
389
|
+
if (this.#pinScrollToBottom && this.#isLoading) {
|
|
342
390
|
this.scrollToBottom();
|
|
343
391
|
}
|
|
344
392
|
}
|
|
@@ -346,6 +346,13 @@
|
|
|
346
346
|
display: flex;
|
|
347
347
|
gap: var(--sys-size-4);
|
|
348
348
|
align-items: center;
|
|
349
|
+
|
|
350
|
+
.chevron {
|
|
351
|
+
color: var(--sys-color-primary);
|
|
352
|
+
width: var(--sys-size-8);
|
|
353
|
+
height: var(--sys-size-8);
|
|
354
|
+
margin-left: var(--sys-size-2);
|
|
355
|
+
}
|
|
349
356
|
}
|
|
350
357
|
|
|
351
358
|
|
|
@@ -372,18 +379,18 @@
|
|
|
372
379
|
gap: var(--sys-size-5);
|
|
373
380
|
}
|
|
374
381
|
|
|
375
|
-
|
|
376
382
|
.widget-header {
|
|
377
383
|
display: flex;
|
|
378
384
|
justify-content: space-between;
|
|
385
|
+
height: var(--sys-size-11);
|
|
379
386
|
align-items: center;
|
|
380
387
|
background: var(--sys-color-surface5);
|
|
381
388
|
padding: var(--sys-size-2) var(--sys-size-4);
|
|
382
|
-
border-top-left-radius: var(--sys-shape-corner-
|
|
383
|
-
border-top-right-radius: var(--sys-shape-corner-
|
|
389
|
+
border-top-left-radius: var(--sys-shape-corner-small);
|
|
390
|
+
border-top-right-radius: var(--sys-shape-corner-small);
|
|
384
391
|
|
|
385
392
|
.widget-name {
|
|
386
|
-
font: var(--sys-typescale-
|
|
393
|
+
font: var(--sys-typescale-body4-regular);
|
|
387
394
|
}
|
|
388
395
|
|
|
389
396
|
.widget-reveal-container {
|
|
@@ -393,10 +400,29 @@
|
|
|
393
400
|
}
|
|
394
401
|
}
|
|
395
402
|
|
|
403
|
+
.widget-reveal-button {
|
|
404
|
+
display: flex;
|
|
405
|
+
align-items: center;
|
|
406
|
+
|
|
407
|
+
devtools-icon {
|
|
408
|
+
margin-left: var(--sys-size-3);
|
|
409
|
+
color: var(--sys-color-primary);
|
|
410
|
+
width: var(--sys-size-8);
|
|
411
|
+
height: var(--sys-size-8);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
.widget-and-revealer-container {
|
|
417
|
+
width: 100%;
|
|
418
|
+
min-width: var(--sys-size-30);
|
|
419
|
+
max-width: var(--sys-size-33);
|
|
420
|
+
}
|
|
421
|
+
|
|
396
422
|
.widget-reveal-container {
|
|
397
423
|
background: var(--sys-color-surface5);
|
|
398
|
-
border-bottom-right-radius: var(--sys-shape-corner-
|
|
399
|
-
border-bottom-left-radius: var(--sys-shape-corner-
|
|
424
|
+
border-bottom-right-radius: var(--sys-shape-corner-small);
|
|
425
|
+
border-bottom-left-radius: var(--sys-shape-corner-small);
|
|
400
426
|
padding: 0 var(--sys-size-4) var(--sys-size-4) 0;
|
|
401
427
|
}
|
|
402
428
|
|
|
@@ -406,7 +432,7 @@
|
|
|
406
432
|
}
|
|
407
433
|
|
|
408
434
|
.widget-content-container {
|
|
409
|
-
padding: var(--sys-size-4);
|
|
435
|
+
padding: var(--sys-size-4) var(--sys-size-5);
|
|
410
436
|
border-top-left-radius: var(--sys-shape-corner-medium);
|
|
411
437
|
border-top-right-radius: var(--sys-shape-corner-medium);
|
|
412
438
|
overflow-x: auto;
|
|
@@ -100,25 +100,45 @@
|
|
|
100
100
|
.walkthrough-inline {
|
|
101
101
|
border-radius: var(--sys-size-5);
|
|
102
102
|
overflow: hidden;
|
|
103
|
-
background-color: var(--sys-color-
|
|
103
|
+
background-color: var(--sys-color-surface2);
|
|
104
104
|
width: fit-content;
|
|
105
105
|
|
|
106
106
|
&[open] {
|
|
107
107
|
width: auto;
|
|
108
|
+
background-color: var(--sys-color-surface1);
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
.walkthrough-inline > summary {
|
|
112
113
|
display: flex;
|
|
113
114
|
align-items: center;
|
|
114
|
-
padding:
|
|
115
|
+
padding: 0 var(--sys-size-6);
|
|
115
116
|
cursor: pointer;
|
|
116
117
|
background-color: transparent;
|
|
118
|
+
/* The same height as a DevTools Button */
|
|
119
|
+
height: var(--sys-size-11);
|
|
117
120
|
font: var(--sys-typescale-body4-regular);
|
|
121
|
+
font-weight:var(--ref-typeface-weight-medium);
|
|
118
122
|
user-select: none;
|
|
119
123
|
list-style: none; /* Hide default triangle */
|
|
120
124
|
justify-content: flex-start;
|
|
121
125
|
gap: var(--sys-size-4);
|
|
126
|
+
color: var(--sys-color-primary);
|
|
127
|
+
|
|
128
|
+
devtools-icon {
|
|
129
|
+
color: var(--sys-color-primary);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/* Align the summary to look like the tonal button */
|
|
133
|
+
&[data-has-widgets] {
|
|
134
|
+
background: var(--sys-color-tonal-container);
|
|
135
|
+
color: var(--sys-color-on-tonal-container);
|
|
136
|
+
border-radius: var(--sys-shape-corner-full);
|
|
137
|
+
|
|
138
|
+
devtools-icon {
|
|
139
|
+
color: var(--sys-color-on-tonal-container);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
122
142
|
}
|
|
123
143
|
|
|
124
144
|
.walkthrough-inline > summary::-webkit-details-marker {
|
|
@@ -131,8 +151,6 @@
|
|
|
131
151
|
|
|
132
152
|
.walkthrough-inline .steps-container {
|
|
133
153
|
padding: var(--sys-size-6);
|
|
134
|
-
max-height: 300px; /* Limit height for inline view */
|
|
135
|
-
overflow-y: auto;
|
|
136
154
|
border-top: 1px solid var(--sys-color-divider);
|
|
137
155
|
background-color: transparent;
|
|
138
156
|
}
|
|
@@ -141,9 +159,21 @@
|
|
|
141
159
|
width: var(--sys-size-8);
|
|
142
160
|
height: var(--sys-size-8);
|
|
143
161
|
transition: transform 0.2s;
|
|
162
|
+
margin-left: auto;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.walkthrough-inline[open] > summary {
|
|
166
|
+
border-radius: var(--sys-shape-corner-medium-small);
|
|
167
|
+
border-bottom-right-radius: 0;
|
|
168
|
+
border-bottom-left-radius: 0;
|
|
169
|
+
background: var(--sys-color-surface5);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.walkthrough-inline .step {
|
|
173
|
+
background-color: var(--sys-color-surface5);
|
|
144
174
|
}
|
|
145
175
|
|
|
146
176
|
.walkthrough-inline[open] > summary > devtools-icon {
|
|
147
|
-
transform: rotate(
|
|
177
|
+
transform: rotate(270deg);
|
|
148
178
|
}
|
|
149
179
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
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 SDK from '../../core/sdk/sdk.js';
|
|
6
|
+
import * as CrUXManager from '../../models/crux-manager/crux-manager.js';
|
|
7
|
+
|
|
8
|
+
export interface ThrottlingRecommendations {
|
|
9
|
+
cpuOption: SDK.CPUThrottlingManager.CPUThrottlingOption|null;
|
|
10
|
+
networkConditions: SDK.NetworkManager.Conditions|null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Computes the recommended CPU and network throttling presets based on CrUX
|
|
15
|
+
* field metric data.
|
|
16
|
+
*/
|
|
17
|
+
export function getThrottlingRecommendations(): ThrottlingRecommendations {
|
|
18
|
+
const cruxManager = CrUXManager.CrUXManager.instance();
|
|
19
|
+
const roundTripTimeMetricData = cruxManager.getSelectedFieldMetricData('round_trip_time');
|
|
20
|
+
|
|
21
|
+
let cpuOption: SDK.CPUThrottlingManager.CPUThrottlingOption =
|
|
22
|
+
SDK.CPUThrottlingManager.CalibratedMidTierMobileThrottlingOption;
|
|
23
|
+
if (cpuOption.rate() === 0) {
|
|
24
|
+
cpuOption = SDK.CPUThrottlingManager.MidTierThrottlingOption;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const networkConditions = getRecommendedNetworkConditions(roundTripTimeMetricData);
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
cpuOption,
|
|
31
|
+
networkConditions,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Computes the recommended network throttling preset based on CrUX RTT field
|
|
37
|
+
* metric data. Returns null if no RTT data is available or no preset matches.
|
|
38
|
+
*/
|
|
39
|
+
export function getRecommendedNetworkConditions(roundTripTimeMetricData?: CrUXManager.MetricResponse):
|
|
40
|
+
SDK.NetworkManager.Conditions|null {
|
|
41
|
+
if (roundTripTimeMetricData?.percentiles) {
|
|
42
|
+
const rtt = Number(roundTripTimeMetricData.percentiles.p75);
|
|
43
|
+
return SDK.NetworkManager.getRecommendedNetworkPreset(rtt);
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
@@ -109,5 +109,6 @@ export * as ExtensionServer from './ExtensionServer.js';
|
|
|
109
109
|
export * as ExtensionView from './ExtensionView.js';
|
|
110
110
|
export * as PersistenceUtils from './PersistenceUtils.js';
|
|
111
111
|
export * as DOMLinkifier from './DOMLinkifier.js';
|
|
112
|
+
export * as ThrottlingUtils from './ThrottlingUtils.js';
|
|
112
113
|
export * as ExtensionIframe from './ExtensionView.js';
|
|
113
114
|
export {CopyChangesToPrompt} from './CopyChangesToPrompt.js';
|