chrome-devtools-frontend 1.0.1696961 → 1.0.1697998
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/.geminiignore +0 -1
- package/.stylelintignore +2 -0
- package/front_end/core/common/Color.ts +5 -2
- package/front_end/core/common/VersionController.ts +5 -1
- package/front_end/core/host/InspectorFrontendHostAPI.ts +16 -3
- package/front_end/core/host/InspectorFrontendHostStub.ts +3 -2
- package/front_end/core/host/ResourceLoader.ts +1 -2
- package/front_end/core/platform/api/HostRuntime.ts +1 -0
- package/front_end/core/platform/browser/HostRuntime.ts +4 -0
- package/front_end/core/platform/node/HostRuntime.ts +5 -0
- package/front_end/core/root/Runtime.ts +5 -0
- package/front_end/core/sdk/AnimationModel.ts +9 -1
- package/front_end/core/sdk/DOMModel.ts +13 -0
- package/front_end/core/sdk/SourceMapScopeChainEntry.ts +9 -6
- package/front_end/core/sdk/SourceMapScopesInfo.ts +3 -1
- package/front_end/foundation/Universe.ts +8 -0
- package/front_end/generated/InspectorBackendCommands.ts +4 -1
- package/front_end/generated/protocol-mapping.d.ts +19 -0
- package/front_end/generated/protocol-proxy-api.d.ts +15 -0
- package/front_end/generated/protocol.ts +43 -2
- package/front_end/models/ai_assistance/AiAgent2.ts +20 -18
- package/front_end/models/ai_assistance/AiConversation.ts +38 -12
- package/front_end/models/ai_assistance/agents/AccessibilityAgent.ts +9 -2
- package/front_end/models/ai_assistance/agents/ContextSelectionAgent.ts +26 -0
- package/front_end/models/ai_assistance/agents/StylingAgent.ts +13 -4
- package/front_end/models/ai_assistance/ai_assistance.ts +4 -4
- package/front_end/models/ai_assistance/skills/performance.md +4 -3
- package/front_end/models/ai_assistance/tools/CookieUtils.ts +10 -8
- package/front_end/models/ai_assistance/tools/ExecuteJavaScript.ts +1 -1
- package/front_end/models/ai_assistance/tools/GetElementAccessibilityDetails.ts +1 -3
- package/front_end/models/ai_assistance/tools/GetNetworkRequestDetails.ts +9 -8
- package/front_end/models/ai_assistance/tools/GetSourceContent.ts +5 -6
- package/front_end/models/ai_assistance/tools/GetStorageValues.ts +6 -25
- package/front_end/models/ai_assistance/tools/GetStyles.ts +1 -3
- package/front_end/models/ai_assistance/tools/{GetFunctionCode.ts → GetTraceFunctionCode.ts} +26 -13
- package/front_end/models/ai_assistance/tools/{GetResourceContent.ts → GetTraceResourceContent.ts} +31 -11
- package/front_end/models/ai_assistance/tools/ListNetworkRequests.ts +7 -6
- package/front_end/models/ai_assistance/tools/ListPageOrigins.ts +8 -5
- package/front_end/models/ai_assistance/tools/ListSources.ts +8 -10
- package/front_end/models/ai_assistance/tools/ListStorageKeys.ts +6 -25
- package/front_end/models/ai_assistance/tools/README.md +5 -3
- package/front_end/models/ai_assistance/tools/ResolveDevtoolsNodePath.ts +1 -2
- package/front_end/models/ai_assistance/tools/Tool.ts +54 -16
- package/front_end/models/ai_assistance/tools/ToolRegistry.ts +6 -6
- package/front_end/models/change_tracker/ChangeTracker.ts +89 -0
- package/front_end/models/change_tracker/change_tracker.ts +9 -0
- package/front_end/models/elements/DOMChanges.ts +238 -0
- package/front_end/models/elements/elements.ts +2 -0
- package/front_end/models/issues_manager/MarkdownIssueDescription.ts +2 -2
- package/front_end/models/live-metrics/LiveMetrics.ts +1 -2
- package/front_end/models/trace/ModelImpl.ts +0 -6
- package/front_end/models/trace/Processor.ts +4 -7
- package/front_end/models/trace/helpers/Timing.ts +2 -1
- package/front_end/models/trace/types/Overlays.ts +12 -1
- package/front_end/panels/accessibility/AccessibilityAnnouncementRecordingView.ts +67 -19
- package/front_end/panels/ai_assistance/AiAssistancePanel.ts +3 -1
- package/front_end/panels/ai_assistance/components/MarkdownRendererWithCodeBlock.ts +25 -5
- package/front_end/panels/application/IndexedDBViews.ts +1 -1
- package/front_end/panels/browser_debugger/ObjectEventListenersSidebarPane.ts +2 -3
- package/front_end/panels/elements/DOMTreeContextMenu.ts +16 -23
- package/front_end/panels/elements/ElementsTreeElement.ts +384 -79
- package/front_end/panels/elements/ElementsTreeOutline.ts +541 -82
- package/front_end/panels/elements/EventListenersWidget.ts +0 -1
- package/front_end/panels/event_listeners/EventListenersView.ts +241 -297
- package/front_end/panels/linear_memory_inspector/LinearMemoryInspectorController.ts +1 -1
- package/front_end/panels/mobile_throttling/ThrottlingSettingsTab.ts +10 -2
- package/front_end/panels/network/NetworkConfigView.ts +141 -116
- package/front_end/panels/network/NetworkPanel.ts +140 -52
- package/front_end/panels/network/RequestHeadersView.ts +65 -32
- package/front_end/panels/network/components/RequestHeadersView.css +7 -1
- package/front_end/panels/network/forward/BackendLinking.ts +52 -0
- package/front_end/panels/network/forward/forward.ts +2 -0
- package/front_end/panels/settings/BackendLinkingSettingsTab.ts +308 -0
- package/front_end/panels/settings/backendLinkingSettingsTab.css +78 -0
- package/front_end/panels/settings/settings-meta.ts +25 -0
- package/front_end/panels/settings/settings.ts +2 -0
- package/front_end/panels/timeline/README.md +3 -2
- package/front_end/panels/timeline/TimelineFlameChartView.ts +23 -2
- package/front_end/panels/timeline/TimelineTreeView.ts +11 -1
- package/front_end/panels/timeline/overlays/OverlaysImpl.ts +64 -4
- package/front_end/panels/timeline/timelineFlameChartView.css +47 -0
- package/front_end/panels/whats_new/ReleaseNoteText.ts +8 -8
- package/front_end/panels/whats_new/resources/WNDT.md +6 -6
- 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/es5-iife/puppeteer-core-browser.d.ts +6 -0
- package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +5 -8
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Coverage.d.ts +6 -0
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Coverage.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Coverage.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/ScreenRecording.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/ScreenRecording.js +1 -5
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/ScreenRecording.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/revisions.d.ts +3 -3
- package/front_end/third_party/puppeteer/package/lib/puppeteer/revisions.js +3 -3
- package/front_end/third_party/puppeteer/package/lib/puppeteer/revisions.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/util/version.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/util/version.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/types.d.ts +6 -0
- package/front_end/third_party/puppeteer/package/package.json +2 -2
- package/front_end/third_party/puppeteer/package/src/cdp/Coverage.ts +6 -0
- package/front_end/third_party/puppeteer/package/src/cdp/ScreenRecording.ts +3 -7
- package/front_end/third_party/puppeteer/package/src/revisions.ts +3 -3
- package/front_end/third_party/puppeteer/package/src/util/version.ts +1 -1
- package/front_end/third_party/web-vitals/README.chromium +2 -2
- package/front_end/third_party/web-vitals/package/dist/modules/attribution/onINP.js +8 -5
- package/front_end/third_party/web-vitals/package/package.json +1 -1
- package/front_end/third_party/web-vitals/package/src/attribution/onINP.ts +8 -4
- package/front_end/third_party/web-vitals/rebuild.sh +2 -2
- package/front_end/ui/comments/CommentOverlayManager.ts +169 -40
- package/front_end/ui/comments/CommentThreadWidget.ts +221 -0
- package/front_end/ui/comments/CommentsOverlayWidget.ts +124 -12
- package/front_end/ui/comments/commentThreadWidget.css +173 -0
- package/front_end/ui/comments/comments.ts +2 -0
- package/front_end/ui/comments/commentsOverlay.css +6 -0
- package/front_end/ui/legacy/ContextMenu.ts +19 -0
- package/front_end/ui/legacy/SoftContextMenu.ts +6 -0
- package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +1 -1
- package/front_end/ui/legacy/components/perf_ui/FlameChart.ts +66 -22
- package/front_end/ui/visual_logging/KnownContextValues.ts +4 -0
- package/package.json +9 -8
|
@@ -0,0 +1,221 @@
|
|
|
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 '../components/tooltips/tooltips.js';
|
|
6
|
+
|
|
7
|
+
import * as i18n from '../../core/i18n/i18n.js';
|
|
8
|
+
import type * as CommentManager from '../../models/comment_manager/comment_manager.js';
|
|
9
|
+
import * as UI from '../../ui/legacy/legacy.js';
|
|
10
|
+
import * as Lit from '../../ui/lit/lit.js';
|
|
11
|
+
import * as Input from '../components/input/input.js';
|
|
12
|
+
import * as MarkdownView from '../components/markdown_view/markdown_view.js';
|
|
13
|
+
|
|
14
|
+
import commentThreadWidgetStyles from './commentThreadWidget.css.js';
|
|
15
|
+
|
|
16
|
+
const {html, render, Directives: {createRef, ref}} = Lit;
|
|
17
|
+
|
|
18
|
+
const UIStrings = {
|
|
19
|
+
/**
|
|
20
|
+
* @description Link text in the info tooltip for learning more about comments sent to the agent.
|
|
21
|
+
*/
|
|
22
|
+
learnMore: 'Learn more',
|
|
23
|
+
/**
|
|
24
|
+
* @description Text next to the checkmark in the comment thread header indicating that comments have been sent to
|
|
25
|
+
* the agent.
|
|
26
|
+
*/
|
|
27
|
+
sent: 'Sent',
|
|
28
|
+
/**
|
|
29
|
+
* @description Alt text for the checkmark icon in the comment thread header indicating that comments have been sent
|
|
30
|
+
* to the agent.
|
|
31
|
+
*/
|
|
32
|
+
sentCheckmark: 'Sent checkmark',
|
|
33
|
+
/**
|
|
34
|
+
* @description Label for the agent response section in the comment thread.
|
|
35
|
+
*/
|
|
36
|
+
response: 'Response:',
|
|
37
|
+
/**
|
|
38
|
+
* @description Label for the aria-label of the add comment button.
|
|
39
|
+
*/
|
|
40
|
+
addCommentButton: 'Add comment',
|
|
41
|
+
/**
|
|
42
|
+
* @description aria-label for the comment text area.
|
|
43
|
+
*/
|
|
44
|
+
commentInputAriaLabel: 'Comment input',
|
|
45
|
+
} as const;
|
|
46
|
+
|
|
47
|
+
const UIStringsNotTranslate = {
|
|
48
|
+
/**
|
|
49
|
+
* @description Disclaimer text in the comment thread info tooltip.
|
|
50
|
+
*/
|
|
51
|
+
inputDisclaimer:
|
|
52
|
+
'Comment strings, DOM hierarchy snippets, tracked CSS and DOM changes, Visual Element (VE) paths and signatures, and tracked presenter changes are sent to the connected third-party agent to assist with debugging and code updates.',
|
|
53
|
+
} as const;
|
|
54
|
+
|
|
55
|
+
const str_ = i18n.i18n.registerUIStrings('ui/comments/CommentThreadWidget.ts', UIStrings);
|
|
56
|
+
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
|
|
57
|
+
const lockedString = i18n.i18n.lockedString;
|
|
58
|
+
|
|
59
|
+
export interface ViewInput {
|
|
60
|
+
title: string;
|
|
61
|
+
comments: CommentManager.CommentManager.Comment[];
|
|
62
|
+
commentText: string;
|
|
63
|
+
textAreaRef: Lit.Directives.Ref<HTMLTextAreaElement>;
|
|
64
|
+
onLearnMoreClick: () => void;
|
|
65
|
+
onAddComment: (text: string) => void;
|
|
66
|
+
onCommentTextChange: (event: Event) => void;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type ViewOutput = undefined;
|
|
70
|
+
|
|
71
|
+
export const DEFAULT_VIEW = (input: ViewInput, _output: ViewOutput, target: HTMLElement): void => {
|
|
72
|
+
const hasComment = input.comments.length > 0;
|
|
73
|
+
|
|
74
|
+
// clang-format off
|
|
75
|
+
render(html`
|
|
76
|
+
<style>${Input.textInputStyles}${commentThreadWidgetStyles}</style>
|
|
77
|
+
<div class="comment-thread-widget ${hasComment ? 'submitted' : ''}">
|
|
78
|
+
<div class="header">
|
|
79
|
+
<span class="selected-item">
|
|
80
|
+
<span class="selected-item-text">${input.title}</span>
|
|
81
|
+
</span>
|
|
82
|
+
${hasComment ? html`
|
|
83
|
+
<div class="sent-status">
|
|
84
|
+
<devtools-icon
|
|
85
|
+
class="check-icon"
|
|
86
|
+
name="checkmark"
|
|
87
|
+
aria-label=${i18nString(UIStrings.sentCheckmark)}>
|
|
88
|
+
</devtools-icon>
|
|
89
|
+
<span>${i18nString(UIStrings.sent)}</span>
|
|
90
|
+
</div>
|
|
91
|
+
` : Lit.nothing}
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
${hasComment ? html`
|
|
95
|
+
${input.comments.map(comment => comment.author === 'DEVELOPER' ? html`
|
|
96
|
+
<div class="comment-text">
|
|
97
|
+
${comment.text}
|
|
98
|
+
</div>
|
|
99
|
+
` : html`
|
|
100
|
+
<div class="agent-response">
|
|
101
|
+
<div class="elbow"></div>
|
|
102
|
+
<div class="response-content">
|
|
103
|
+
<div class="response-header">${i18nString(UIStrings.response)}</div>
|
|
104
|
+
${MarkdownView.MarkdownView.renderTextAsMarkdown(
|
|
105
|
+
comment.text,
|
|
106
|
+
new MarkdownView.MarkdownView.MarkdownInsightRenderer(),
|
|
107
|
+
)}
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
`)}
|
|
111
|
+
` : Lit.nothing}
|
|
112
|
+
|
|
113
|
+
${!hasComment ? html`
|
|
114
|
+
<textarea
|
|
115
|
+
${ref(input.textAreaRef)}
|
|
116
|
+
class="devtools-text-input input"
|
|
117
|
+
rows="1"
|
|
118
|
+
aria-label=${i18nString(UIStrings.commentInputAriaLabel)}
|
|
119
|
+
.value=${input.commentText}
|
|
120
|
+
@input=${input.onCommentTextChange}
|
|
121
|
+
@keydown=${(event: KeyboardEvent) => {
|
|
122
|
+
if (event.key === 'Enter' && !event.shiftKey && !event.isComposing) {
|
|
123
|
+
event.preventDefault();
|
|
124
|
+
input.onAddComment(input.commentText);
|
|
125
|
+
}
|
|
126
|
+
}}
|
|
127
|
+
></textarea>
|
|
128
|
+
<div class="footer">
|
|
129
|
+
<devtools-icon
|
|
130
|
+
class="info-icon"
|
|
131
|
+
name="info"
|
|
132
|
+
aria-label="Info"
|
|
133
|
+
aria-details="comment-thread-info-tooltip"
|
|
134
|
+
tabindex="0"
|
|
135
|
+
></devtools-icon>
|
|
136
|
+
<devtools-tooltip
|
|
137
|
+
id="comment-thread-info-tooltip"
|
|
138
|
+
variant="rich"
|
|
139
|
+
>
|
|
140
|
+
<div class="info-tooltip-container">
|
|
141
|
+
${lockedString(UIStringsNotTranslate.inputDisclaimer)}
|
|
142
|
+
<button
|
|
143
|
+
class="tooltip-link"
|
|
144
|
+
role="link"
|
|
145
|
+
@click=${input.onLearnMoreClick}
|
|
146
|
+
>${i18nString(UIStrings.learnMore)}</button>
|
|
147
|
+
</div>
|
|
148
|
+
</devtools-tooltip>
|
|
149
|
+
<devtools-button
|
|
150
|
+
aria-label=${i18nString(UIStrings.addCommentButton)}
|
|
151
|
+
.disabled=${!input.commentText.trim()}
|
|
152
|
+
@click=${() => input.onAddComment(input.commentText)}>
|
|
153
|
+
${i18nString(UIStrings.addCommentButton)}
|
|
154
|
+
</devtools-button>
|
|
155
|
+
</div>
|
|
156
|
+
` : Lit.nothing}
|
|
157
|
+
</div>
|
|
158
|
+
`, target);
|
|
159
|
+
// clang-format on
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
type View = typeof DEFAULT_VIEW;
|
|
163
|
+
|
|
164
|
+
export class CommentThreadWidget extends UI.Widget.Widget {
|
|
165
|
+
title = 'Comment Thread';
|
|
166
|
+
#comments: CommentManager.CommentManager.Comment[] = [];
|
|
167
|
+
#commentText = '';
|
|
168
|
+
#textAreaRef = createRef<HTMLTextAreaElement>();
|
|
169
|
+
#view: View;
|
|
170
|
+
onAddComment?: (text: string) => void;
|
|
171
|
+
|
|
172
|
+
constructor(element?: HTMLElement, view: View = DEFAULT_VIEW) {
|
|
173
|
+
super(element);
|
|
174
|
+
this.#view = view;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
override wasShown(): void {
|
|
178
|
+
super.wasShown();
|
|
179
|
+
this.requestUpdate();
|
|
180
|
+
void this.updateComplete.then(() => {
|
|
181
|
+
this.#textAreaRef.value?.focus({preventScroll: true});
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
set comments(comments: CommentManager.CommentManager.Comment[]) {
|
|
186
|
+
this.#comments = comments;
|
|
187
|
+
this.requestUpdate();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
#handleLearnMoreClick = (): void => {
|
|
191
|
+
// TODO: wire up the learn more click
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
#handleAddComment = (text: string): void => {
|
|
195
|
+
const commentText = text.trim();
|
|
196
|
+
if (commentText && this.onAddComment) {
|
|
197
|
+
this.onAddComment(commentText);
|
|
198
|
+
this.#commentText = '';
|
|
199
|
+
this.requestUpdate();
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
#handleCommentTextChange = (event: Event): void => {
|
|
204
|
+
const input = event.target as HTMLTextAreaElement;
|
|
205
|
+
this.#commentText = input.value;
|
|
206
|
+
this.requestUpdate();
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
override performUpdate(): void {
|
|
210
|
+
const viewInput: ViewInput = {
|
|
211
|
+
title: this.title,
|
|
212
|
+
comments: this.#comments,
|
|
213
|
+
commentText: this.#commentText,
|
|
214
|
+
textAreaRef: this.#textAreaRef,
|
|
215
|
+
onLearnMoreClick: this.#handleLearnMoreClick,
|
|
216
|
+
onAddComment: this.#handleAddComment,
|
|
217
|
+
onCommentTextChange: this.#handleCommentTextChange,
|
|
218
|
+
};
|
|
219
|
+
this.#view(viewInput, undefined, this.contentElement);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
@@ -13,21 +13,45 @@ import {
|
|
|
13
13
|
Events as CommentOverlayManagerEvents,
|
|
14
14
|
type HighlightRectData,
|
|
15
15
|
type HoverHighlightData,
|
|
16
|
+
type PendingHighlightRectData,
|
|
17
|
+
type PendingPinPositionData,
|
|
16
18
|
type PinPositionData,
|
|
17
19
|
} from './CommentOverlayManager.js';
|
|
18
20
|
import commentsOverlayStyles from './commentsOverlay.css.js';
|
|
21
|
+
import {CommentThreadWidget} from './CommentThreadWidget.js';
|
|
19
22
|
|
|
20
|
-
const {
|
|
23
|
+
const {
|
|
24
|
+
html,
|
|
25
|
+
render,
|
|
26
|
+
nothing,
|
|
27
|
+
Directives: {repeat, styleMap},
|
|
28
|
+
} = Lit;
|
|
29
|
+
|
|
30
|
+
export type ViewHighlightRectData = HighlightRectData|PendingHighlightRectData;
|
|
21
31
|
|
|
22
32
|
export interface ViewInput {
|
|
23
33
|
pins: PinPositionData[];
|
|
24
|
-
|
|
34
|
+
pendingPin: PendingPinPositionData|null;
|
|
35
|
+
highlights: ViewHighlightRectData[];
|
|
25
36
|
hoverHighlight: HoverHighlightData|null;
|
|
26
37
|
commentMode: boolean;
|
|
27
38
|
onPinClick: (threadId: string) => void;
|
|
39
|
+
activeThread: CommentManager.CommentManager.CommentThread|null;
|
|
40
|
+
activePin: PinPositionData|PendingPinPositionData|null;
|
|
41
|
+
activeTargetKey: unknown;
|
|
42
|
+
onAddComment: (text: string) => void;
|
|
28
43
|
}
|
|
29
44
|
|
|
30
|
-
export type View = (
|
|
45
|
+
export type View = (
|
|
46
|
+
input: ViewInput,
|
|
47
|
+
output: undefined,
|
|
48
|
+
target: HTMLElement,
|
|
49
|
+
) => void;
|
|
50
|
+
|
|
51
|
+
const POPUP_MARGIN = 8;
|
|
52
|
+
const PIN_HEIGHT = 30;
|
|
53
|
+
const POPUP_WIDTH = 288;
|
|
54
|
+
const POPUP_HEIGHT = 220;
|
|
31
55
|
|
|
32
56
|
const DEFAULT_VIEW: View = (input: ViewInput, _output: undefined, target: HTMLElement): void => {
|
|
33
57
|
// clang-format off
|
|
@@ -48,7 +72,7 @@ const DEFAULT_VIEW: View = (input: ViewInput, _output: undefined, target: HTMLEl
|
|
|
48
72
|
${input.highlights.map(h => h.visible ? html`
|
|
49
73
|
<div
|
|
50
74
|
class="comment-anchor-highlight"
|
|
51
|
-
data-comment-id=${h.id}
|
|
75
|
+
data-comment-id=${('id' in h && h.id) || nothing}
|
|
52
76
|
style=${styleMap({
|
|
53
77
|
top: `${h.top}px`,
|
|
54
78
|
left: `${h.left}px`,
|
|
@@ -57,6 +81,16 @@ const DEFAULT_VIEW: View = (input: ViewInput, _output: undefined, target: HTMLEl
|
|
|
57
81
|
})}>
|
|
58
82
|
</div>
|
|
59
83
|
` : nothing)}
|
|
84
|
+
${input.pendingPin && input.pendingPin.visible ? html`
|
|
85
|
+
<div
|
|
86
|
+
class="comment-pin"
|
|
87
|
+
style=${styleMap({
|
|
88
|
+
top: `${input.pendingPin.top}px`,
|
|
89
|
+
left: `${input.pendingPin.left}px`,
|
|
90
|
+
})}>
|
|
91
|
+
<div class="comment-cursor">${input.pendingPin.index}</div>
|
|
92
|
+
</div>
|
|
93
|
+
` : nothing}
|
|
60
94
|
${input.pins.map(p => p.visible ? html`
|
|
61
95
|
<div
|
|
62
96
|
class="comment-pin"
|
|
@@ -69,25 +103,54 @@ const DEFAULT_VIEW: View = (input: ViewInput, _output: undefined, target: HTMLEl
|
|
|
69
103
|
<div class="comment-cursor">${p.index}</div>
|
|
70
104
|
</div>
|
|
71
105
|
` : nothing)}
|
|
106
|
+
${input.activePin ? repeat(
|
|
107
|
+
[{pin: input.activePin, key: input.activeTargetKey}],
|
|
108
|
+
item => item.key,
|
|
109
|
+
item => html`
|
|
110
|
+
<div
|
|
111
|
+
class="comment-popup-widget"
|
|
112
|
+
style=${styleMap({
|
|
113
|
+
top: `${Math.min(
|
|
114
|
+
Math.max(POPUP_MARGIN, item.pin.top + PIN_HEIGHT),
|
|
115
|
+
Math.max(POPUP_MARGIN, target.clientHeight - POPUP_HEIGHT),
|
|
116
|
+
)}px`,
|
|
117
|
+
left: `${Math.min(
|
|
118
|
+
Math.max(POPUP_MARGIN, item.pin.left),
|
|
119
|
+
Math.max(POPUP_MARGIN, target.clientWidth - POPUP_WIDTH - POPUP_MARGIN),
|
|
120
|
+
)}px`,
|
|
121
|
+
})}>
|
|
122
|
+
${UI.Widget.widget(CommentThreadWidget, {
|
|
123
|
+
comments: input.activeThread ? [...input.activeThread.comments] : [],
|
|
124
|
+
onAddComment: input.onAddComment,
|
|
125
|
+
})}
|
|
126
|
+
</div>
|
|
127
|
+
`,
|
|
128
|
+
) : nothing}
|
|
72
129
|
</div>
|
|
73
130
|
`, target);
|
|
74
131
|
// clang-format on
|
|
75
132
|
};
|
|
76
133
|
|
|
77
134
|
export class CommentsOverlayWidget extends UI.Widget.Widget {
|
|
135
|
+
static override readonly INJECT: readonly[typeof CommentManager.CommentManager.CommentManager] =
|
|
136
|
+
[CommentManager.CommentManager.CommentManager] as const;
|
|
137
|
+
|
|
78
138
|
readonly #view: View;
|
|
79
139
|
readonly #commentManager: CommentManager.CommentManager.CommentManager;
|
|
80
140
|
#commentOverlayManager: CommentOverlayManager;
|
|
141
|
+
#activeThreadId: string|null = null;
|
|
81
142
|
|
|
82
143
|
constructor(
|
|
83
144
|
element: HTMLElement|undefined,
|
|
84
|
-
commentManager:
|
|
145
|
+
[commentManager]: UI.Widget.WidgetDependencies<typeof CommentsOverlayWidget>,
|
|
85
146
|
view: View = DEFAULT_VIEW,
|
|
86
147
|
) {
|
|
87
148
|
super(element, {useShadowDom: false});
|
|
88
149
|
this.#view = view;
|
|
89
150
|
this.#commentManager = commentManager;
|
|
90
|
-
this.#commentOverlayManager = new CommentOverlayManager(
|
|
151
|
+
this.#commentOverlayManager = new CommentOverlayManager(
|
|
152
|
+
this.#commentManager,
|
|
153
|
+
);
|
|
91
154
|
}
|
|
92
155
|
|
|
93
156
|
setOverlayManagerForTest(overlayManager: CommentOverlayManager): void {
|
|
@@ -154,24 +217,68 @@ export class CommentsOverlayWidget extends UI.Widget.Widget {
|
|
|
154
217
|
CommentManager.CommentManager.EventTypes[CommentManager.CommentManager.Events.COMMENT_MODE_CHANGED]>,
|
|
155
218
|
): void {
|
|
156
219
|
const isModeActive = event.data;
|
|
157
|
-
const action = UI.ActionRegistry.ActionRegistry.instance().getAction(
|
|
220
|
+
const action = UI.ActionRegistry.ActionRegistry.instance().getAction(
|
|
221
|
+
'comments.toggle-comment-mode',
|
|
222
|
+
);
|
|
158
223
|
action?.setToggled(isModeActive);
|
|
159
224
|
this.requestUpdate();
|
|
160
225
|
}
|
|
161
226
|
|
|
162
227
|
#onStateChanged(): void {
|
|
228
|
+
if (this.#commentOverlayManager.getPendingDraft()) {
|
|
229
|
+
this.#activeThreadId = null;
|
|
230
|
+
}
|
|
163
231
|
this.requestUpdate();
|
|
164
232
|
}
|
|
165
233
|
|
|
166
|
-
#handlePinClick = (
|
|
234
|
+
#handlePinClick = (threadId: string): void => {
|
|
235
|
+
this.#commentOverlayManager.clearPendingAnchor();
|
|
236
|
+
if (this.#activeThreadId === threadId) {
|
|
237
|
+
this.#activeThreadId = null;
|
|
238
|
+
} else {
|
|
239
|
+
this.#activeThreadId = threadId;
|
|
240
|
+
}
|
|
241
|
+
this.requestUpdate();
|
|
242
|
+
};
|
|
167
243
|
|
|
168
244
|
override performUpdate(): void {
|
|
245
|
+
const pins = this.#commentOverlayManager.getPinPositions();
|
|
246
|
+
const draft = this.#commentOverlayManager.getPendingDraft();
|
|
247
|
+
const pendingPin = draft?.pin ?? null;
|
|
248
|
+
const highlights: ViewHighlightRectData[] = [
|
|
249
|
+
...this.#commentOverlayManager.getHighlightRects(),
|
|
250
|
+
];
|
|
251
|
+
|
|
252
|
+
if (draft?.highlight) {
|
|
253
|
+
highlights.push(draft.highlight);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
let activePin: PinPositionData|PendingPinPositionData|null = null;
|
|
257
|
+
let activeThread: CommentManager.CommentManager.CommentThread|null = null;
|
|
258
|
+
if (pendingPin) {
|
|
259
|
+
activePin = pendingPin;
|
|
260
|
+
} else if (this.#activeThreadId) {
|
|
261
|
+
activePin = pins.find(p => p.id === this.#activeThreadId) ?? null;
|
|
262
|
+
activeThread = this.#commentManager.getCommentThread(this.#activeThreadId) ?? null;
|
|
263
|
+
}
|
|
264
|
+
|
|
169
265
|
const viewInput: ViewInput = {
|
|
170
|
-
pins
|
|
171
|
-
|
|
266
|
+
pins,
|
|
267
|
+
pendingPin,
|
|
268
|
+
highlights,
|
|
172
269
|
hoverHighlight: this.#commentOverlayManager.getHoverHighlight(),
|
|
173
270
|
commentMode: this.#commentManager.isCommentMode(),
|
|
174
271
|
onPinClick: this.#handlePinClick,
|
|
272
|
+
activeThread,
|
|
273
|
+
activePin,
|
|
274
|
+
activeTargetKey: draft ?? activeThread,
|
|
275
|
+
onAddComment: (text: string) => {
|
|
276
|
+
const pendingDraft = this.#commentOverlayManager.getPendingDraft();
|
|
277
|
+
|
|
278
|
+
if (pendingDraft) {
|
|
279
|
+
this.#commentOverlayManager.createComment(pendingDraft.element, text, {pendingDraft});
|
|
280
|
+
}
|
|
281
|
+
},
|
|
175
282
|
};
|
|
176
283
|
this.#view(viewInput, undefined, this.contentElement);
|
|
177
284
|
}
|
|
@@ -192,11 +299,16 @@ export class ActionDelegate implements UI.ActionRegistration.ActionDelegate {
|
|
|
192
299
|
handleAction(_context: UI.Context.Context, actionId: string): boolean {
|
|
193
300
|
if (actionId === 'comments.toggle-comment-mode') {
|
|
194
301
|
if (!widgetInstance) {
|
|
195
|
-
widgetInstance = new CommentsOverlayWidget(
|
|
302
|
+
widgetInstance = new CommentsOverlayWidget(
|
|
303
|
+
undefined,
|
|
304
|
+
[this.#commentManager],
|
|
305
|
+
);
|
|
196
306
|
widgetInstance.markAsRoot();
|
|
197
307
|
widgetInstance.show(document.body);
|
|
198
308
|
}
|
|
199
|
-
this.#commentManager.setCommentMode(
|
|
309
|
+
this.#commentManager.setCommentMode(
|
|
310
|
+
!this.#commentManager.isCommentMode(),
|
|
311
|
+
);
|
|
200
312
|
return true;
|
|
201
313
|
}
|
|
202
314
|
return false;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 The Chromium Authors
|
|
3
|
+
* Use of this source code is governed by a BSD-style license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
@scope to (devtools-widget > *) {
|
|
8
|
+
.comment-thread-widget {
|
|
9
|
+
display: flex;
|
|
10
|
+
width: var(--sys-size-30);
|
|
11
|
+
padding: var(--sys-size-8);
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
align-items: flex-start;
|
|
14
|
+
gap: var(--sys-size-4);
|
|
15
|
+
border-radius: var(--sys-shape-corner-medium);
|
|
16
|
+
background: var(--sys-color-base);
|
|
17
|
+
box-shadow: var(--sys-elevation-level2);
|
|
18
|
+
cursor: default;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.comment-thread-widget.submitted {
|
|
22
|
+
background: var(--sys-color-surface2);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.header {
|
|
26
|
+
display: flex;
|
|
27
|
+
width: 100%;
|
|
28
|
+
justify-content: space-between;
|
|
29
|
+
align-items: center;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.sent-status {
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
gap: var(--sys-size-2);
|
|
36
|
+
font-size: var(--sys-typescale-body5-size);
|
|
37
|
+
color: var(--sys-color-on-surface-subtle);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.check-icon {
|
|
41
|
+
width: var(--sys-size-7);
|
|
42
|
+
height: var(--sys-size-7);
|
|
43
|
+
color: var(--sys-color-on-surface-subtle);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.selected-item {
|
|
47
|
+
display: flex;
|
|
48
|
+
height: calc(var(--sys-size-8) + var(--sys-size-2));
|
|
49
|
+
padding: var(--sys-size-2) var(--sys-size-4) var(--sys-size-2) var(--sys-size-3);
|
|
50
|
+
align-items: center;
|
|
51
|
+
border-radius: var(--sys-shape-corner-extra-small);
|
|
52
|
+
border: var(--sys-size-1) solid var(--sys-color-divider);
|
|
53
|
+
background: var(--sys-color-base);
|
|
54
|
+
font-family: var(--source-code-font-family);
|
|
55
|
+
font-size: var(--monospace-font-size);
|
|
56
|
+
color: var(--sys-color-token-tag);
|
|
57
|
+
overflow: hidden;
|
|
58
|
+
max-width: 100%;
|
|
59
|
+
min-width: 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.comment-text {
|
|
63
|
+
width: 100%;
|
|
64
|
+
font-family: var(--default-font-family);
|
|
65
|
+
font-size: var(--sys-typescale-body4-size);
|
|
66
|
+
color: var(--sys-color-on-surface-subtle);
|
|
67
|
+
line-height: var(--sys-size-9);
|
|
68
|
+
overflow-wrap: break-word;
|
|
69
|
+
white-space: pre-wrap;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.agent-response {
|
|
73
|
+
display: flex;
|
|
74
|
+
gap: var(--sys-size-2);
|
|
75
|
+
margin-top: var(--sys-size-4);
|
|
76
|
+
width: 100%;
|
|
77
|
+
align-items: flex-start;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.elbow {
|
|
81
|
+
width: var(--sys-size-6);
|
|
82
|
+
height: var(--sys-size-6);
|
|
83
|
+
margin-left: var(--sys-size-3);
|
|
84
|
+
margin-right: var(--sys-size-3);
|
|
85
|
+
border-left: var(--sys-size-1) solid var(--sys-color-neutral-outline);
|
|
86
|
+
border-bottom: var(--sys-size-1) solid var(--sys-color-neutral-outline);
|
|
87
|
+
border-bottom-left-radius: var(--sys-size-6);
|
|
88
|
+
flex-shrink: 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.response-content {
|
|
92
|
+
display: flex;
|
|
93
|
+
flex-direction: column;
|
|
94
|
+
flex: 1;
|
|
95
|
+
min-width: 0;
|
|
96
|
+
|
|
97
|
+
--code-block-background-color: var(--sys-color-base);
|
|
98
|
+
--code-background-color: var(--sys-color-base);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.response-header {
|
|
102
|
+
font-weight: bold;
|
|
103
|
+
margin-bottom: var(--sys-size-2);
|
|
104
|
+
font-family: var(--default-font-family);
|
|
105
|
+
font-size: var(--sys-typescale-body5-size);
|
|
106
|
+
line-height: var(--sys-size-8);
|
|
107
|
+
color: var(--sys-color-on-surface-subtle);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.response-content devtools-markdown-view {
|
|
111
|
+
font-family: var(--default-font-family);
|
|
112
|
+
font-size: var(--sys-typescale-body4-size);
|
|
113
|
+
color: var(--sys-color-on-surface-subtle);
|
|
114
|
+
line-height: var(--sys-size-9);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.input {
|
|
118
|
+
height: auto;
|
|
119
|
+
min-height: var(--sys-size-14);
|
|
120
|
+
max-height: var(--sys-size-27);
|
|
121
|
+
field-sizing: content;
|
|
122
|
+
resize: none;
|
|
123
|
+
scrollbar-width: none;
|
|
124
|
+
padding: var(--sys-size-5) var(--sys-size-8);
|
|
125
|
+
border-radius: var(--sys-shape-corner-small);
|
|
126
|
+
border: var(--sys-size-1) solid var(--sys-color-outline);
|
|
127
|
+
background: var(--sys-color-base);
|
|
128
|
+
font-family: var(--default-font-family);
|
|
129
|
+
font-size: var(--sys-typescale-body5-size);
|
|
130
|
+
line-height: var(--sys-size-9);
|
|
131
|
+
letter-spacing: 0;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.input::placeholder {
|
|
135
|
+
color: var(--sys-color-on-surface-subtle);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.footer {
|
|
139
|
+
display: flex;
|
|
140
|
+
width: 100%;
|
|
141
|
+
justify-content: flex-end;
|
|
142
|
+
align-items: center;
|
|
143
|
+
gap: var(--sys-size-5);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.info-icon {
|
|
147
|
+
color: var(--sys-color-on-surface-subtle);
|
|
148
|
+
cursor: pointer;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.info-tooltip-container {
|
|
152
|
+
max-width: var(--sys-size-28);
|
|
153
|
+
padding: var(--sys-size-4) var(--sys-size-5);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.tooltip-link {
|
|
157
|
+
display: block;
|
|
158
|
+
margin-top: var(--sys-size-4);
|
|
159
|
+
color: var(--sys-color-primary);
|
|
160
|
+
padding-left: 0;
|
|
161
|
+
background: none;
|
|
162
|
+
border: none;
|
|
163
|
+
font: inherit;
|
|
164
|
+
text-decoration: underline;
|
|
165
|
+
cursor: pointer;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.selected-item-text {
|
|
169
|
+
overflow: hidden;
|
|
170
|
+
white-space: nowrap;
|
|
171
|
+
text-overflow: ellipsis;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -6,10 +6,12 @@ import * as CommentAnchorResolver from './CommentAnchorResolver.js';
|
|
|
6
6
|
import * as CommentOverlayManager from './CommentOverlayManager.js';
|
|
7
7
|
import * as CommentsOverlayWidget from './CommentsOverlayWidget.js';
|
|
8
8
|
import * as CommentsStatusBarPill from './CommentsStatusBarPill.js';
|
|
9
|
+
import * as CommentThreadWidget from './CommentThreadWidget.js';
|
|
9
10
|
|
|
10
11
|
export {
|
|
11
12
|
CommentAnchorResolver,
|
|
12
13
|
CommentOverlayManager,
|
|
13
14
|
CommentsOverlayWidget,
|
|
14
15
|
CommentsStatusBarPill,
|
|
16
|
+
CommentThreadWidget,
|
|
15
17
|
};
|