chrome-devtools-frontend 1.0.1596260 → 1.0.1597448
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/prompts/ui-widgets.md +7 -8
- package/docs/ui_engineering.md +10 -11
- package/front_end/core/common/Console.ts +6 -6
- package/front_end/core/common/Settings.ts +12 -8
- package/front_end/core/host/InspectorFrontendHostAPI.ts +1 -0
- package/front_end/core/host/UserMetrics.ts +12 -0
- package/front_end/core/root/DevToolsContext.ts +13 -7
- package/front_end/core/root/Runtime.ts +5 -0
- package/front_end/core/sdk/FrameManager.ts +7 -8
- package/front_end/core/sdk/PageResourceLoader.ts +22 -1
- package/front_end/devtools_compatibility.js +2 -1
- package/front_end/entrypoints/greendev_floaty/FloatyEntrypoint.ts +1 -1
- package/front_end/entrypoints/main/MainImpl.ts +1 -2
- package/front_end/foundation/Universe.ts +22 -11
- package/front_end/generated/InspectorBackendCommands.ts +7 -0
- package/front_end/generated/protocol-mapping.d.ts +16 -0
- package/front_end/generated/protocol-proxy-api.d.ts +25 -0
- package/front_end/generated/protocol.ts +71 -0
- package/front_end/models/ai_assistance/AiConversation.ts +11 -95
- package/front_end/models/ai_assistance/agents/AiAgent.ts +15 -1
- package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +14 -0
- package/front_end/models/ai_assistance/agents/StylingAgent.snapshot.txt +24 -0
- package/front_end/models/ai_assistance/agents/StylingAgent.ts +289 -12
- package/front_end/models/greendev/Prototypes.ts +7 -1
- package/front_end/panels/ai_assistance/AiAssistancePanel.ts +36 -33
- package/front_end/panels/ai_assistance/PatchWidget.ts +6 -6
- package/front_end/panels/ai_assistance/components/ChatMessage.ts +28 -32
- package/front_end/panels/ai_assistance/components/ChatView.ts +6 -11
- package/front_end/panels/ai_assistance/components/StylingAgentMarkdownRenderer.ts +200 -0
- package/front_end/panels/ai_assistance/components/WalkthroughView.ts +2 -2
- package/front_end/panels/ai_assistance/components/chatMessage.css +0 -8
- package/front_end/panels/application/ServiceWorkerCacheViews.ts +1 -1
- package/front_end/panels/common/ExtensionServer.ts +15 -0
- package/front_end/panels/elements/ElementsTreeElement.ts +55 -47
- package/front_end/panels/elements/ElementsTreeOutline.ts +149 -28
- package/front_end/panels/elements/StandaloneStylesContainer.ts +48 -12
- package/front_end/panels/elements/StylePropertiesSection.ts +97 -1
- package/front_end/panels/elements/StylePropertyTreeElement.ts +16 -0
- package/front_end/panels/elements/StylesContainer.ts +1 -0
- package/front_end/panels/elements/StylesSidebarPane.ts +48 -32
- package/front_end/panels/elements/stylePropertiesTreeOutline.css +1 -1
- package/front_end/panels/lighthouse/LighthouseController.ts +13 -5
- package/front_end/panels/lighthouse/LighthousePanel.ts +30 -5
- package/front_end/panels/recorder/components/StepView.ts +0 -2
- package/front_end/panels/recorder/components/stepView.css +13 -13
- package/front_end/panels/recorder/components/timelineSection.css +6 -7
- package/front_end/panels/settings/SettingsScreen.ts +3 -2
- package/front_end/panels/timeline/TimelinePanel.ts +18 -0
- package/front_end/panels/timeline/components/CWVMetrics.ts +339 -0
- package/front_end/panels/timeline/components/Sidebar.ts +17 -0
- package/front_end/panels/timeline/components/SidebarInsightsTab.ts +10 -0
- package/front_end/panels/timeline/components/SidebarSingleInsightSet.ts +25 -267
- package/front_end/panels/timeline/components/components.ts +2 -0
- package/front_end/panels/timeline/components/cwvMetrics.css +107 -0
- package/front_end/panels/timeline/components/sidebarSingleInsightSet.css +0 -102
- package/front_end/panels/timeline/timeline-meta.ts +11 -0
- package/front_end/panels/timeline/utils/Helpers.ts +5 -1
- package/front_end/third_party/chromium/README.chromium +1 -1
- package/front_end/third_party/puppeteer/README.chromium +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Page.d.ts +7 -0
- 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.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/Page.d.ts +1 -0
- 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 +3 -0
- 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/cdp/Browser.d.ts +1 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.js +6 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Page.d.ts +1 -0
- 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 +5 -0
- 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/injected/injected.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/Mutex.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.d.ts +7 -0
- package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +14 -3
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Page.d.ts +7 -0
- 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.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/Page.d.ts +1 -0
- 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 +3 -0
- 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/cdp/Browser.d.ts +1 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.js +6 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Page.d.ts +1 -0
- 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 +5 -0
- 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/revisions.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/types.d.ts +7 -0
- package/front_end/third_party/puppeteer/package/package.json +1 -1
- package/front_end/third_party/puppeteer/package/src/api/Page.ts +8 -0
- package/front_end/third_party/puppeteer/package/src/bidi/Page.ts +4 -0
- package/front_end/third_party/puppeteer/package/src/cdp/Browser.ts +7 -0
- package/front_end/third_party/puppeteer/package/src/cdp/Page.ts +6 -0
- package/front_end/third_party/puppeteer/package/src/revisions.ts +2 -2
- package/front_end/third_party/puppeteer/package/src/util/version.ts +1 -1
- package/front_end/ui/components/text_editor/AutocompleteHistory.ts +89 -5
- package/front_end/ui/legacy/UIUtils.ts +5 -5
- package/front_end/ui/legacy/Widget.ts +33 -2
- package/front_end/ui/visual_logging/KnownContextValues.ts +2 -0
- package/package.json +1 -1
|
@@ -12,7 +12,8 @@ import type * as Platform from '../../../core/platform/platform.js';
|
|
|
12
12
|
import * as Root from '../../../core/root/root.js';
|
|
13
13
|
import * as SDK from '../../../core/sdk/sdk.js';
|
|
14
14
|
import type * as Protocol from '../../../generated/protocol.js';
|
|
15
|
-
import type {
|
|
15
|
+
import type {
|
|
16
|
+
AiWidget, ComputedStyleAiWidget, CoreVitalsAiWidget} from '../../../models/ai_assistance/agents/AiAgent.js';
|
|
16
17
|
import * as AiAssistanceModel from '../../../models/ai_assistance/ai_assistance.js';
|
|
17
18
|
import * as ComputedStyle from '../../../models/computed_style/computed_style.js';
|
|
18
19
|
import * as Marked from '../../../third_party/marked/marked.js';
|
|
@@ -25,12 +26,15 @@ import * as UI from '../../../ui/legacy/legacy.js';
|
|
|
25
26
|
import * as Lit from '../../../ui/lit/lit.js';
|
|
26
27
|
import * as VisualLogging from '../../../ui/visual_logging/visual_logging.js';
|
|
27
28
|
import * as Elements from '../../elements/elements.js';
|
|
29
|
+
import * as TimelineComponents from '../../timeline/components/components.js';
|
|
30
|
+
import * as TimelineUtils from '../../timeline/utils/utils.js';
|
|
28
31
|
|
|
29
32
|
import chatMessageStyles from './chatMessage.css.js';
|
|
30
33
|
import {walkthroughTitle, WalkthroughView} from './WalkthroughView.js';
|
|
31
34
|
|
|
32
35
|
const {html, Directives: {ref, ifDefined}} = Lit;
|
|
33
36
|
const lockedString = i18n.i18n.lockedString;
|
|
37
|
+
const {widget} = UI.Widget;
|
|
34
38
|
|
|
35
39
|
const REPORT_URL = 'https://crbug.com/364805393' as Platform.DevToolsPath.UrlString;
|
|
36
40
|
const SCROLL_ROUNDING_OFFSET = 1;
|
|
@@ -117,10 +121,6 @@ const UIStringsNotTranslate = {
|
|
|
117
121
|
* @description Gemini (do not translate)
|
|
118
122
|
*/
|
|
119
123
|
gemini: 'Gemini',
|
|
120
|
-
/**
|
|
121
|
-
* @description The fallback text when we can't find the user full name
|
|
122
|
-
*/
|
|
123
|
-
you: 'You',
|
|
124
124
|
/**
|
|
125
125
|
* @description The fallback text when a step has no title yet
|
|
126
126
|
*/
|
|
@@ -153,10 +153,6 @@ const UIStringsNotTranslate = {
|
|
|
153
153
|
* @description Alt text for the image input (displayed in the chat messages) that has been sent to the model.
|
|
154
154
|
*/
|
|
155
155
|
imageInputSentToTheModel: 'Image input sent to the model',
|
|
156
|
-
/**
|
|
157
|
-
* @description Alt text for the account avatar.
|
|
158
|
-
*/
|
|
159
|
-
accountAvatar: 'Account avatar',
|
|
160
156
|
/**
|
|
161
157
|
* @description Title for the link which wraps the image input rendered in chat messages.
|
|
162
158
|
*/
|
|
@@ -269,7 +265,6 @@ export interface MessageInput {
|
|
|
269
265
|
isReadOnly: boolean;
|
|
270
266
|
isLastMessage: boolean;
|
|
271
267
|
canShowFeedbackForm: boolean;
|
|
272
|
-
userInfo: Pick<Host.InspectorFrontendHostAPI.SyncInformation, 'accountImage'|'accountFullName'|'accountGivenName'>;
|
|
273
268
|
markdownRenderer: MarkdownLitRenderer;
|
|
274
269
|
onSuggestionClick: (suggestion: string) => void;
|
|
275
270
|
onFeedbackSubmit: (rpcId: Host.AidaClient.RpcGlobalId, rate: Host.AidaClient.Rating, feedback?: string) => void;
|
|
@@ -286,14 +281,6 @@ export interface MessageInput {
|
|
|
286
281
|
export const DEFAULT_VIEW = (input: ChatMessageViewInput, output: ViewOutput, target: HTMLElement): void => {
|
|
287
282
|
const message = input.message;
|
|
288
283
|
if (message.entity === ChatMessageEntity.USER) {
|
|
289
|
-
const givenName = AiAssistanceModel.AiUtils.isGeminiBranding() ? input.userInfo.accountGivenName : '';
|
|
290
|
-
const name = givenName || input.userInfo.accountFullName || lockedString(UIStringsNotTranslate.you);
|
|
291
|
-
const image = input.userInfo.accountImage ?
|
|
292
|
-
html`<img src="data:image/png;base64, ${input.userInfo.accountImage}" alt=${
|
|
293
|
-
UIStringsNotTranslate.accountAvatar} />` :
|
|
294
|
-
html`<devtools-icon
|
|
295
|
-
name="profile"
|
|
296
|
-
></devtools-icon>`;
|
|
297
284
|
const imageInput = message.imageInput && 'inlineData' in message.imageInput ?
|
|
298
285
|
renderImageChatMessage(message.imageInput.inlineData) :
|
|
299
286
|
Lit.nothing;
|
|
@@ -305,12 +292,6 @@ export const DEFAULT_VIEW = (input: ChatMessageViewInput, output: ViewOutput, ta
|
|
|
305
292
|
class="chat-message query ${input.isLastMessage ? 'is-last-message' : ''}"
|
|
306
293
|
jslog=${VisualLogging.section('question')}
|
|
307
294
|
>
|
|
308
|
-
<div class="message-info">
|
|
309
|
-
${image}
|
|
310
|
-
<div class="message-name">
|
|
311
|
-
<h2>${name}</h2>
|
|
312
|
-
</div>
|
|
313
|
-
</div>
|
|
314
295
|
${imageInput}
|
|
315
296
|
<div class="message-content">${renderTextAsMarkdown(message.text, input.markdownRenderer)}</div>
|
|
316
297
|
</section>
|
|
@@ -566,7 +547,7 @@ function renderWalkthroughUI(input: ChatMessageViewInput, steps: Step[]): Lit.Li
|
|
|
566
547
|
// clang-format off
|
|
567
548
|
const walkthroughInline = input.walkthrough.isInlined ? html`
|
|
568
549
|
<div class="walkthrough-container">
|
|
569
|
-
|
|
550
|
+
${widget(WalkthroughView, {
|
|
570
551
|
message: input.message as ModelChatMessage,
|
|
571
552
|
isLoading: input.isLoading && input.isLastMessage,
|
|
572
553
|
markdownRenderer: input.markdownRenderer,
|
|
@@ -574,7 +555,7 @@ function renderWalkthroughUI(input: ChatMessageViewInput, steps: Step[]): Lit.Li
|
|
|
574
555
|
isExpanded,
|
|
575
556
|
onToggle: input.walkthrough.onToggle,
|
|
576
557
|
onOpen: input.walkthrough.onOpen,
|
|
577
|
-
})}
|
|
558
|
+
})}
|
|
578
559
|
</div>
|
|
579
560
|
` : Lit.nothing;
|
|
580
561
|
|
|
@@ -696,6 +677,19 @@ async function makeComputedStyleWidget(widgetData: ComputedStyleAiWidget): Promi
|
|
|
696
677
|
return {renderedWidget: widget, revealable: new Elements.ElementsPanel.NodeComputedStyles(domNodeForId)};
|
|
697
678
|
}
|
|
698
679
|
|
|
680
|
+
async function makeCoreVitalsWidget(widgetData: CoreVitalsAiWidget): Promise<WidgetMakerResponse|null> {
|
|
681
|
+
const widgetConfig = UI.Widget.widgetConfig(TimelineComponents.CWVMetrics.CWVMetrics, {data: widgetData.data});
|
|
682
|
+
|
|
683
|
+
// clang-format off
|
|
684
|
+
const widget = html`<devtools-widget class="core-vitals-widget" .widgetConfig=${widgetConfig}></devtools-widget>`;
|
|
685
|
+
// clang-format on
|
|
686
|
+
|
|
687
|
+
return {
|
|
688
|
+
renderedWidget: widget,
|
|
689
|
+
revealable: new TimelineUtils.Helpers.RevealableCoreVitals(widgetData.data.insightSetKey)
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
|
|
699
693
|
function renderWidgetResponse(response: WidgetMakerResponse|null): Lit.LitTemplate {
|
|
700
694
|
if (response === null) {
|
|
701
695
|
return Lit.nothing;
|
|
@@ -732,10 +726,11 @@ function renderWidgetResponse(response: WidgetMakerResponse|null): Lit.LitTempla
|
|
|
732
726
|
* iterates through the `step.widgets` array. For each widget, it determines
|
|
733
727
|
* the appropriate rendering logic based on the `widgetData.name`.
|
|
734
728
|
*
|
|
735
|
-
* Currently, only 'COMPUTED_STYLES' widgets are supported. For these, the
|
|
736
|
-
* `makeComputedStyleWidget`
|
|
729
|
+
* Currently, only 'COMPUTED_STYLES' and 'CORE_VITALS' widgets are supported. For these, the
|
|
730
|
+
* `makeComputedStyleWidget` and `makeCoreVitalsWidget` functions are called to construct the necessary
|
|
737
731
|
* data and configuration for the `Elements.ComputedStyleWidget.ComputedStyleWidget`
|
|
738
|
-
*
|
|
732
|
+
* and `TimelineComponents.CWVMetrics.CWVMetrics`
|
|
733
|
+
* components. The widget is then rendered using the `<devtools-widget>`
|
|
739
734
|
* custom element, which dynamically instantiates and displays the specified
|
|
740
735
|
* UI.Widget subclass with the provided configuration.
|
|
741
736
|
*
|
|
@@ -752,6 +747,10 @@ async function renderStepWidgets(step: Step): Promise<Lit.LitTemplate> {
|
|
|
752
747
|
const response = await makeComputedStyleWidget(widgetData);
|
|
753
748
|
return renderWidgetResponse(response);
|
|
754
749
|
}
|
|
750
|
+
if (widgetData.name === 'CORE_VITALS') {
|
|
751
|
+
const response = await makeCoreVitalsWidget(widgetData);
|
|
752
|
+
return renderWidgetResponse(response);
|
|
753
|
+
}
|
|
755
754
|
return Lit.nothing;
|
|
756
755
|
}));
|
|
757
756
|
return html`${ui}`;
|
|
@@ -998,8 +997,6 @@ export class ChatMessage extends UI.Widget.Widget {
|
|
|
998
997
|
isReadOnly = false;
|
|
999
998
|
canShowFeedbackForm = false;
|
|
1000
999
|
isLastMessage = false;
|
|
1001
|
-
userInfo:
|
|
1002
|
-
Pick<Host.InspectorFrontendHostAPI.SyncInformation, 'accountImage'|'accountFullName'|'accountGivenName'> = {};
|
|
1003
1000
|
markdownRenderer!: MarkdownLitRenderer;
|
|
1004
1001
|
onSuggestionClick: (suggestion: string) => void = () => {};
|
|
1005
1002
|
onFeedbackSubmit:
|
|
@@ -1046,7 +1043,6 @@ export class ChatMessage extends UI.Widget.Widget {
|
|
|
1046
1043
|
isLoading: this.isLoading,
|
|
1047
1044
|
isReadOnly: this.isReadOnly,
|
|
1048
1045
|
canShowFeedbackForm: this.canShowFeedbackForm,
|
|
1049
|
-
userInfo: this.userInfo,
|
|
1050
1046
|
markdownRenderer: this.markdownRenderer,
|
|
1051
1047
|
isLastMessage: this.isLastMessage,
|
|
1052
1048
|
onSuggestionClick: this.onSuggestionClick,
|
|
@@ -25,6 +25,7 @@ const {
|
|
|
25
25
|
repeat,
|
|
26
26
|
classMap,
|
|
27
27
|
} = Directives;
|
|
28
|
+
const {widget} = UI.Widget;
|
|
28
29
|
|
|
29
30
|
/*
|
|
30
31
|
* Strings that don't need to be translated at this time.
|
|
@@ -67,9 +68,8 @@ export interface Props {
|
|
|
67
68
|
messages: Message[];
|
|
68
69
|
context: AiAssistanceModel.AiAgent.ConversationContext<unknown>|null;
|
|
69
70
|
isContextSelected: boolean;
|
|
70
|
-
isLoading: boolean;
|
|
71
71
|
canShowFeedbackForm: boolean;
|
|
72
|
-
|
|
72
|
+
isLoading: boolean;
|
|
73
73
|
conversationType: AiAssistanceModel.AiHistoryStorage.ConversationType;
|
|
74
74
|
isReadOnly: boolean;
|
|
75
75
|
blockedByCrossOrigin: boolean;
|
|
@@ -91,7 +91,6 @@ export interface Props {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
interface ChatWidgetInput extends Props {
|
|
94
|
-
accountGivenName: string;
|
|
95
94
|
handleScroll: (ev: Event) => void;
|
|
96
95
|
handleSuggestionClick: (title: string) => void;
|
|
97
96
|
handleMessageContainerRef: (el: Element|undefined) => void;
|
|
@@ -116,12 +115,11 @@ const DEFAULT_VIEW: View = (input, output, target) => {
|
|
|
116
115
|
${input.messages.length > 0 ? html`
|
|
117
116
|
<div class="messages-container" ${ref(input.handleMessageContainerRef)}>
|
|
118
117
|
${repeat(input.messages, message =>
|
|
119
|
-
|
|
118
|
+
widget(ChatMessage, {
|
|
120
119
|
message,
|
|
121
120
|
isLoading: input.isLoading && input.messages.at(-1) === message,
|
|
122
121
|
isReadOnly: input.isReadOnly,
|
|
123
122
|
canShowFeedbackForm: input.canShowFeedbackForm,
|
|
124
|
-
userInfo: input.userInfo,
|
|
125
123
|
markdownRenderer: input.markdownRenderer,
|
|
126
124
|
isLastMessage: input.messages.at(-1) === message,
|
|
127
125
|
onSuggestionClick: input.handleSuggestionClick,
|
|
@@ -130,14 +128,12 @@ const DEFAULT_VIEW: View = (input, output, target) => {
|
|
|
130
128
|
walkthrough: {
|
|
131
129
|
...input.walkthrough,
|
|
132
130
|
}
|
|
133
|
-
})
|
|
131
|
+
})
|
|
134
132
|
)}
|
|
135
|
-
${input.isLoading ? nothing :
|
|
136
|
-
.widgetConfig=${UI.Widget.widgetConfig(PatchWidget, {
|
|
133
|
+
${input.isLoading ? nothing : widget(PatchWidget, {
|
|
137
134
|
changeSummary: input.changeSummary ?? '',
|
|
138
135
|
changeManager: input.changeManager,
|
|
139
136
|
})}
|
|
140
|
-
></devtools-widget>`}
|
|
141
137
|
</div>
|
|
142
138
|
` : html`
|
|
143
139
|
<div class="empty-state-container">
|
|
@@ -149,7 +145,7 @@ const DEFAULT_VIEW: View = (input, output, target) => {
|
|
|
149
145
|
</div>
|
|
150
146
|
${AiAssistanceModel.AiUtils.isGeminiBranding() ?
|
|
151
147
|
html`
|
|
152
|
-
<h1 class='greeting'>Hello
|
|
148
|
+
<h1 class='greeting'>Hello</h1>
|
|
153
149
|
<p class='cta'>${lockedString(UIStringsNotTranslate.emptyStateTextGemini)}</p>
|
|
154
150
|
` : html`<h1>${lockedString(UIStringsNotTranslate.emptyStateText)}</h1>`
|
|
155
151
|
}
|
|
@@ -354,7 +350,6 @@ export class ChatView extends HTMLElement {
|
|
|
354
350
|
this.#view(
|
|
355
351
|
{
|
|
356
352
|
...this.#props,
|
|
357
|
-
accountGivenName: this.#props.userInfo.accountGivenName ?? '',
|
|
358
353
|
handleScroll: this.#handleScroll,
|
|
359
354
|
handleSuggestionClick: this.#handleSuggestionClick,
|
|
360
355
|
handleMessageContainerRef: this.#handleMessageContainerRef,
|
|
@@ -0,0 +1,200 @@
|
|
|
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 type * as Protocol from '../../../generated/protocol.js';
|
|
7
|
+
import * as Marked from '../../../third_party/marked/marked.js';
|
|
8
|
+
import type * as MarkdownView from '../../../ui/components/markdown_view/MarkdownView.js';
|
|
9
|
+
import * as Lit from '../../../ui/lit/lit.js';
|
|
10
|
+
import * as PanelsCommon from '../../common/common.js';
|
|
11
|
+
|
|
12
|
+
import {MarkdownRendererWithCodeBlock} from './MarkdownRendererWithCodeBlock.js';
|
|
13
|
+
|
|
14
|
+
const {html} = Lit.StaticHtml;
|
|
15
|
+
const {ref, createRef} = Lit.Directives;
|
|
16
|
+
|
|
17
|
+
export class StylingAgentMarkdownRenderer extends MarkdownRendererWithCodeBlock {
|
|
18
|
+
constructor(
|
|
19
|
+
private mainFrameId = '',
|
|
20
|
+
) {
|
|
21
|
+
super();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
#renderTableFromJson(data: Array<Record<string, string>>): Lit.LitTemplate|null {
|
|
25
|
+
if (!Array.isArray(data) || data.length === 0 || typeof data[0] !== 'object' || data[0] === null) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const headers = Object.keys(data[0]);
|
|
30
|
+
const requiredKeys = ['Problem', 'Element', 'NodeId', 'Details'];
|
|
31
|
+
if (!requiredKeys.every(key => headers.includes(key))) {
|
|
32
|
+
return null; // Not the expected JSON structure
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const problemIndex = headers.indexOf('Problem');
|
|
36
|
+
if (problemIndex > -1) {
|
|
37
|
+
const problemHeader = headers.splice(problemIndex, 1);
|
|
38
|
+
headers.unshift(...problemHeader);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return html`
|
|
42
|
+
<table style="width: 100%;">
|
|
43
|
+
<thead>
|
|
44
|
+
<tr>
|
|
45
|
+
${headers.map(header => html`<th style="text-align: left;">${header === 'NodeId' ? '' : header}</th>`)}
|
|
46
|
+
</tr>
|
|
47
|
+
</thead>
|
|
48
|
+
<tbody>
|
|
49
|
+
${data.flatMap(row => {
|
|
50
|
+
return html`
|
|
51
|
+
<tr>
|
|
52
|
+
${headers.map(header => {
|
|
53
|
+
if (header === 'NodeId') {
|
|
54
|
+
return html`<td>${this.#renderLinkifiedText(row[header])}</td>`;
|
|
55
|
+
}
|
|
56
|
+
if (header === 'Details') {
|
|
57
|
+
// eslint-disable-next-line @devtools/no-a-tags-in-lit
|
|
58
|
+
return html`<td><a href="#" @click=${this.#toggleDetailsRow}>Details</a></td>`;
|
|
59
|
+
}
|
|
60
|
+
return html`<td>${row[header]}</td>`;
|
|
61
|
+
})}
|
|
62
|
+
</tr>
|
|
63
|
+
<tr class="details-row" style="display: none;">
|
|
64
|
+
<td colspan=${headers.length} style="background-color: #f0f0f0; padding: 1em;">
|
|
65
|
+
<devtools-markdown-view .data=${{
|
|
66
|
+
tokens: Marked.Marked.lexer(row['Details']),
|
|
67
|
+
renderer: new StylingAgentMarkdownRenderer(this.mainFrameId),
|
|
68
|
+
} as MarkdownView.MarkdownViewData}></devtools-markdown-view>
|
|
69
|
+
</td>
|
|
70
|
+
</tr>
|
|
71
|
+
`;
|
|
72
|
+
})}
|
|
73
|
+
</tbody>
|
|
74
|
+
</table>
|
|
75
|
+
<br><div>To investigate these problems, please click one of the provided links (above), to set as context, and ask me further questions about the problem.</div>
|
|
76
|
+
`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
override templateForToken(token: Marked.Marked.MarkedToken): Lit.LitTemplate|null {
|
|
80
|
+
if (token.type === 'code') {
|
|
81
|
+
try {
|
|
82
|
+
const data = JSON.parse(token.text);
|
|
83
|
+
const table = this.#renderTableFromJson(data);
|
|
84
|
+
if (table) {
|
|
85
|
+
return table;
|
|
86
|
+
}
|
|
87
|
+
} catch {
|
|
88
|
+
// Not a JSON object, fallback to default rendering.
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (token.type === 'link' && token.href.startsWith('#')) {
|
|
93
|
+
let nodeId = undefined;
|
|
94
|
+
if (token.href.startsWith('#node-')) {
|
|
95
|
+
nodeId = Number(token.href.replace('#node-', '')) as Protocol.DOM.BackendNodeId;
|
|
96
|
+
} else if (token.href.startsWith('#')) {
|
|
97
|
+
// So often does it ignore requests to prepend nodes with node-, frustratingly.
|
|
98
|
+
nodeId = Number(token.href.replace('#', '')) as Protocol.DOM.BackendNodeId;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (nodeId) {
|
|
102
|
+
const templateRef = createRef();
|
|
103
|
+
void this.#linkifyNode(nodeId, token.text).then(node => {
|
|
104
|
+
if (!templateRef.value || !node) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
templateRef.value.textContent = '';
|
|
109
|
+
templateRef.value.append(node);
|
|
110
|
+
});
|
|
111
|
+
return html`<span ${ref(templateRef)}>${token.text}</span>`;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return super.templateForToken(token);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
#toggleDetailsRow(e: Event): void {
|
|
119
|
+
e.preventDefault();
|
|
120
|
+
const link = e.target as HTMLAnchorElement;
|
|
121
|
+
const currentRow = link.closest('tr');
|
|
122
|
+
if (!currentRow) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const detailsRow = currentRow.nextElementSibling as HTMLTableRowElement | null;
|
|
126
|
+
if (detailsRow?.classList.contains('details-row')) {
|
|
127
|
+
if (detailsRow.style.display === 'none') {
|
|
128
|
+
detailsRow.style.display = 'table-row';
|
|
129
|
+
link.textContent = 'Hide';
|
|
130
|
+
} else {
|
|
131
|
+
detailsRow.style.display = 'none';
|
|
132
|
+
link.textContent = 'Details';
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
#renderLinkifiedText(text: string): Lit.LitTemplate {
|
|
138
|
+
if (text.indexOf(',') === -1) {
|
|
139
|
+
const nodeId = Number(text) as Protocol.DOM.BackendNodeId;
|
|
140
|
+
if (isNaN(nodeId)) {
|
|
141
|
+
// Not a number, return as is.
|
|
142
|
+
return html`${text}`;
|
|
143
|
+
}
|
|
144
|
+
return this.#renderSingleLink(nodeId);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Check for comma separated list.
|
|
148
|
+
const nodeIdsStr = text.split(',').map(s => s.trim()).filter(Boolean);
|
|
149
|
+
return html`${nodeIdsStr.map(idStr => {
|
|
150
|
+
const nodeId = Number(idStr) as Protocol.DOM.BackendNodeId;
|
|
151
|
+
if (isNaN(nodeId)) {
|
|
152
|
+
return html`<div>${idStr}</div>`;
|
|
153
|
+
}
|
|
154
|
+
return html`<div>${this.#renderSingleLink(nodeId)}</div>`;
|
|
155
|
+
})}`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
#renderSingleLink(nodeId: Protocol.DOM.BackendNodeId): Lit.LitTemplate {
|
|
159
|
+
const label = `link`;
|
|
160
|
+
const templateRef = createRef();
|
|
161
|
+
void this.#linkifyNode(nodeId, label).then(node => {
|
|
162
|
+
if (!templateRef.value) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
templateRef.value.textContent = '';
|
|
166
|
+
if (node) {
|
|
167
|
+
templateRef.value.append(node);
|
|
168
|
+
} else {
|
|
169
|
+
// Fallback to plain text if linkification fails
|
|
170
|
+
templateRef.value.append(document.createTextNode(label));
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
// Placeholder for async link
|
|
174
|
+
return html`<span ${ref(templateRef)}>${label}</span>`;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
async #linkifyNode(backendNodeId: Protocol.DOM.BackendNodeId, label: string): Promise<Node|undefined> {
|
|
178
|
+
if (backendNodeId === undefined) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const target = SDK.TargetManager.TargetManager.instance().primaryPageTarget();
|
|
183
|
+
const domModel = target?.model(SDK.DOMModel.DOMModel);
|
|
184
|
+
if (!domModel) {
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
const domNodesMap = await domModel.pushNodesByBackendIdsToFrontend(new Set([backendNodeId]));
|
|
188
|
+
const node = domNodesMap?.get(backendNodeId);
|
|
189
|
+
if (!node) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (node.frameId() !== this.mainFrameId) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const linkedNode = PanelsCommon.DOMLinkifier.Linkifier.instance().linkify(node, {textContent: label});
|
|
198
|
+
return linkedNode;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
@@ -25,7 +25,7 @@ const UIStrings = {
|
|
|
25
25
|
/**
|
|
26
26
|
* @description Title for the walkthrough view.
|
|
27
27
|
*/
|
|
28
|
-
title: '
|
|
28
|
+
title: 'Agent walkthrough',
|
|
29
29
|
/**
|
|
30
30
|
* @description Title for the button that shows the walkthrough when there are no widgets in the walkthrough.
|
|
31
31
|
*/
|
|
@@ -101,7 +101,7 @@ function renderSidebarWalkthrough(input: ViewInput, stepsOutput: Lit.LitTemplate
|
|
|
101
101
|
<devtools-button
|
|
102
102
|
.data=${{
|
|
103
103
|
variant: Buttons.Button.Variant.TOOLBAR,
|
|
104
|
-
iconName: '
|
|
104
|
+
iconName: 'cross',
|
|
105
105
|
title: i18nString(UIStrings.close),
|
|
106
106
|
jslogContext: 'close-walkthrough',
|
|
107
107
|
} as Buttons.Button.ButtonData}
|
|
@@ -143,14 +143,6 @@
|
|
|
143
143
|
gap: var(--sys-size-4);
|
|
144
144
|
font: var(--sys-typescale-body4-bold);
|
|
145
145
|
|
|
146
|
-
img {
|
|
147
|
-
border: 0;
|
|
148
|
-
border-radius: var(--sys-shape-corner-full);
|
|
149
|
-
display: block;
|
|
150
|
-
height: var(--sys-size-9);
|
|
151
|
-
width: var(--sys-size-9);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
146
|
h2 {
|
|
155
147
|
font: var(--sys-typescale-body4-bold);
|
|
156
148
|
}
|
|
@@ -178,7 +178,7 @@ export class ServiceWorkerCacheView extends UI.View.SimpleView {
|
|
|
178
178
|
this.dataGrid = this.createDataGrid();
|
|
179
179
|
const dataGridWidget = this.dataGrid.asWidget();
|
|
180
180
|
this.splitWidget.setSidebarWidget(dataGridWidget);
|
|
181
|
-
dataGridWidget.setMinimumSize(0,
|
|
181
|
+
dataGridWidget.setMinimumSize(0, 100);
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
override wasShown(): void {
|
|
@@ -1574,6 +1574,21 @@ export class ExtensionServer extends Common.ObjectWrapper.ObjectWrapper<EventTyp
|
|
|
1574
1574
|
return this.status.E_FAILED('Permission denied');
|
|
1575
1575
|
}
|
|
1576
1576
|
|
|
1577
|
+
try {
|
|
1578
|
+
const parsedUrl = new URL(frame.url);
|
|
1579
|
+
let targetType = Host.UserMetrics.ExtensionEvalTarget.WEB_PAGE;
|
|
1580
|
+
if (parsedUrl.protocol === 'chrome-extension:') {
|
|
1581
|
+
if (parsedUrl.origin === securityOrigin) {
|
|
1582
|
+
targetType = Host.UserMetrics.ExtensionEvalTarget.SAME_EXTENSION;
|
|
1583
|
+
} else {
|
|
1584
|
+
targetType = Host.UserMetrics.ExtensionEvalTarget.OTHER_EXTENSION;
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
Host.userMetrics.extensionEvalTarget(targetType);
|
|
1588
|
+
} catch {
|
|
1589
|
+
// Ignore invalid URLs.
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1577
1592
|
void context
|
|
1578
1593
|
.evaluate(
|
|
1579
1594
|
{
|