chrome-devtools-frontend 1.0.1562614 → 1.0.1563104
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/front_end/core/sdk/Target.ts +3 -1
- package/front_end/models/ai_code_generation/AiCodeGeneration.ts +13 -5
- package/front_end/models/javascript_metadata/NativeFunctions.js +1 -17
- package/front_end/panels/common/AiCodeGenerationTeaser.ts +144 -15
- package/front_end/panels/common/aiCodeGenerationTeaser.css +34 -0
- package/front_end/panels/event_listeners/EventListenersView.ts +2 -1
- package/front_end/third_party/chromium/README.chromium +1 -1
- package/front_end/ui/components/text_editor/AiCodeCompletionTeaserPlaceholder.ts +4 -0
- package/front_end/ui/components/text_editor/AiCodeGenerationProvider.ts +21 -2
- package/front_end/ui/legacy/components/utils/Linkifier.ts +3 -2
- package/front_end/ui/visual_logging/KnownContextValues.ts +1 -0
- package/package.json +1 -1
|
@@ -66,7 +66,9 @@ export class Target extends ProtocolClient.InspectorBackend.TargetBase {
|
|
|
66
66
|
this.#capabilitiesMask = Capability.JS | Capability.LOG | Capability.NETWORK | Capability.TARGET |
|
|
67
67
|
Capability.INSPECTOR | Capability.IO | Capability.EVENT_BREAKPOINTS;
|
|
68
68
|
if (parentTarget?.type() !== Type.FRAME) {
|
|
69
|
-
|
|
69
|
+
// TODO(crbug.com/406991275): This should also grant the `STORAGE` capability, but first the
|
|
70
|
+
// crashers in https://crbug.com/466134219 have to be resolved.
|
|
71
|
+
this.#capabilitiesMask |= Capability.BROWSER;
|
|
70
72
|
}
|
|
71
73
|
break;
|
|
72
74
|
case Type.SHARED_WORKER:
|
|
@@ -13,9 +13,15 @@ Your role is to act as an expert pair programmer within the Chrome DevTools envi
|
|
|
13
13
|
|
|
14
14
|
**Core Directives (Adhere to these strictly):**
|
|
15
15
|
|
|
16
|
-
1.
|
|
17
|
-
*
|
|
18
|
-
*
|
|
16
|
+
1. **Language and Quality:**
|
|
17
|
+
* Generate code that is modern, efficient, and idiomatic for the inferred language (e.g., modern JavaScript/ES6+, semantic HTML5, efficient CSS).
|
|
18
|
+
* Where appropriate, include basic error handling (e.g., for API calls).
|
|
19
|
+
* Determine the programming language from the user's prompt.
|
|
20
|
+
|
|
21
|
+
2. **Output Format (Strict):**
|
|
22
|
+
* **Return ONLY code blocks.** * Do NOT include any introductory text, explanations, or concluding remarks.
|
|
23
|
+
* Do NOT provide step-by-step guides or descriptions of how the code works.
|
|
24
|
+
* Inline comments within the code are permitted and encouraged for clarity.
|
|
19
25
|
`;
|
|
20
26
|
|
|
21
27
|
export const additionalContextForConsole = `
|
|
@@ -59,6 +65,10 @@ export class AiCodeGeneration {
|
|
|
59
65
|
function validTemperature(temperature: number|undefined): number|undefined {
|
|
60
66
|
return typeof temperature === 'number' && temperature >= 0 ? temperature : undefined;
|
|
61
67
|
}
|
|
68
|
+
|
|
69
|
+
// Workaround: Combine preamble and target language into the main prompt to enforce instructions.
|
|
70
|
+
// The API and model ignores system-level instructions provided in the preamble field of the request.
|
|
71
|
+
prompt = preamble + prompt + '\n**Target Language:** ' + inferenceLanguage;
|
|
62
72
|
return {
|
|
63
73
|
client: Host.AidaClient.CLIENT_NAME,
|
|
64
74
|
preamble,
|
|
@@ -70,10 +80,8 @@ export class AiCodeGeneration {
|
|
|
70
80
|
},
|
|
71
81
|
use_case: Host.AidaClient.UseCase.CODE_GENERATION,
|
|
72
82
|
options: {
|
|
73
|
-
inference_language: inferenceLanguage,
|
|
74
83
|
temperature: validTemperature(this.#options.temperature),
|
|
75
84
|
model_id: this.#options.modelId || undefined,
|
|
76
|
-
expect_code_output: true,
|
|
77
85
|
},
|
|
78
86
|
metadata: {
|
|
79
87
|
disable_user_content_logging: !(this.#serverSideLoggingEnabled ?? false),
|
|
@@ -6663,18 +6663,6 @@ export const NativeFunctions = [
|
|
|
6663
6663
|
name: "moveBefore",
|
|
6664
6664
|
signatures: [["node","child"]]
|
|
6665
6665
|
},
|
|
6666
|
-
{
|
|
6667
|
-
name: "patchBetween",
|
|
6668
|
-
signatures: [["prev_child","next_child"]]
|
|
6669
|
-
},
|
|
6670
|
-
{
|
|
6671
|
-
name: "patchAfter",
|
|
6672
|
-
signatures: [["ref"]]
|
|
6673
|
-
},
|
|
6674
|
-
{
|
|
6675
|
-
name: "patchBefore",
|
|
6676
|
-
signatures: [["ref"]]
|
|
6677
|
-
},
|
|
6678
6666
|
{
|
|
6679
6667
|
name: "QuotaExceededError",
|
|
6680
6668
|
signatures: [["?message","?options"]]
|
|
@@ -7193,10 +7181,6 @@ export const NativeFunctions = [
|
|
|
7193
7181
|
name: "setMenuListOptionsBoundsInAXTree",
|
|
7194
7182
|
signatures: [["options_bounds","children_updated"]]
|
|
7195
7183
|
},
|
|
7196
|
-
{
|
|
7197
|
-
name: "PatchEvent",
|
|
7198
|
-
signatures: [["type","init"]]
|
|
7199
|
-
},
|
|
7200
7184
|
{
|
|
7201
7185
|
name: "allowsFeature",
|
|
7202
7186
|
signatures: [["feature","?origin"]]
|
|
@@ -9088,7 +9072,7 @@ export const NativeFunctions = [
|
|
|
9088
9072
|
},
|
|
9089
9073
|
{
|
|
9090
9074
|
name: "copyElementImageToTexture",
|
|
9091
|
-
signatures: [["source","destination"],["source","width","height","destination"]]
|
|
9075
|
+
signatures: [["source","destination"],["source","width","height","destination"],["source","sx","sy","swidth","sheight","destination"]]
|
|
9092
9076
|
},
|
|
9093
9077
|
{
|
|
9094
9078
|
name: "setIndexBuffer",
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
// Copyright 2025 The Chromium Authors
|
|
2
2
|
// Use of this source code is governed by a BSD-style license that can be
|
|
3
3
|
// found in the LICENSE file.
|
|
4
|
+
import '../../ui/components/tooltips/tooltips.js';
|
|
4
5
|
|
|
5
6
|
import * as Host from '../../core/host/host.js';
|
|
6
7
|
import * as i18n from '../../core/i18n/i18n.js';
|
|
8
|
+
import * as Root from '../../core/root/root.js';
|
|
9
|
+
import * as AiCodeCompletion from '../../models/ai_code_completion/ai_code_completion.js';
|
|
10
|
+
import * as Buttons from '../../ui/components/buttons/buttons.js';
|
|
7
11
|
import * as UI from '../../ui/legacy/legacy.js';
|
|
8
|
-
import {html, nothing, render} from '../../ui/lit/lit.js';
|
|
12
|
+
import {Directives, html, nothing, render} from '../../ui/lit/lit.js';
|
|
13
|
+
import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
|
|
9
14
|
|
|
10
15
|
import styles from './aiCodeGenerationTeaser.css.js';
|
|
11
16
|
|
|
@@ -13,11 +18,11 @@ const UIStringsNotTranslate = {
|
|
|
13
18
|
/**
|
|
14
19
|
* @description Text for teaser to generate code.
|
|
15
20
|
*/
|
|
16
|
-
ctrlItoGenerateCode: '
|
|
21
|
+
ctrlItoGenerateCode: 'Ctrl+I to generate code',
|
|
17
22
|
/**
|
|
18
23
|
* @description Text for teaser to generate code in Mac.
|
|
19
24
|
*/
|
|
20
|
-
cmdItoGenerateCode: '
|
|
25
|
+
cmdItoGenerateCode: 'Cmd+I to generate code',
|
|
21
26
|
/**
|
|
22
27
|
* Text for teaser when generating suggestion.
|
|
23
28
|
*/
|
|
@@ -26,6 +31,34 @@ const UIStringsNotTranslate = {
|
|
|
26
31
|
* Text for teaser for discoverability.
|
|
27
32
|
*/
|
|
28
33
|
writeACommentToGenerateCode: 'Write a comment to generate code',
|
|
34
|
+
/**
|
|
35
|
+
* @description Text for tooltip shown on hovering over "Relevant Data" in the disclaimer text for AI code generation in Console panel.
|
|
36
|
+
*/
|
|
37
|
+
tooltipDisclaimerTextForAiCodeGenerationInConsole:
|
|
38
|
+
'To generate code suggestions, your console input and the history of your current console session are shared with Google. This data may be seen by human reviewers to improve this feature.',
|
|
39
|
+
/**
|
|
40
|
+
* @description Text for tooltip shown on hovering over "Relevant Data" in the disclaimer text for AI code generation in Console panel.
|
|
41
|
+
*/
|
|
42
|
+
tooltipDisclaimerTextForAiCodeGenerationNoLoggingInConsole:
|
|
43
|
+
'To generate code suggestions, your console input and the history of your current console session are shared with Google. This data will not be used to improve Google’s AI models. Your organization may change these settings at any time.',
|
|
44
|
+
/**
|
|
45
|
+
* @description Text for tooltip shown on hovering over "Relevant Data" in the disclaimer text for AI code generation in Sources panel.
|
|
46
|
+
*/
|
|
47
|
+
tooltipDisclaimerTextForAiCodeGenerationInSources:
|
|
48
|
+
'To generate code suggestions, the contents of the currently open file are shared with Google. This data may be seen by human reviewers to improve this feature.',
|
|
49
|
+
/**
|
|
50
|
+
* @description Text for tooltip shown on hovering over "Relevant Data" in the disclaimer text for AI code generation in Sources panel.
|
|
51
|
+
*/
|
|
52
|
+
tooltipDisclaimerTextForAiCodeGenerationNoLoggingInSources:
|
|
53
|
+
'To generate code suggestions, the contents of the currently open file are shared with Google. This data will not be used to improve Google’s AI models. Your organization may change these settings at any time.',
|
|
54
|
+
/**
|
|
55
|
+
* @description Text for tooltip button which redirects to AI settings
|
|
56
|
+
*/
|
|
57
|
+
manageInSettings: 'Manage in settings',
|
|
58
|
+
/**
|
|
59
|
+
* @description Title for disclaimer info button in the teaser to generate code.
|
|
60
|
+
*/
|
|
61
|
+
learnMoreAboutHowYourDataIsBeingUsed: 'Learn more about how your data is being used',
|
|
29
62
|
} as const;
|
|
30
63
|
|
|
31
64
|
const lockedString = i18n.i18n.lockedString;
|
|
@@ -37,15 +70,92 @@ export enum AiCodeGenerationTeaserDisplayState {
|
|
|
37
70
|
LOADING = 'loading',
|
|
38
71
|
}
|
|
39
72
|
|
|
73
|
+
function getTooltipDisclaimerText(noLogging: boolean, panel: AiCodeCompletion.AiCodeCompletion.ContextFlavor): string {
|
|
74
|
+
switch (panel) {
|
|
75
|
+
case AiCodeCompletion.AiCodeCompletion.ContextFlavor.CONSOLE:
|
|
76
|
+
return noLogging ?
|
|
77
|
+
lockedString(UIStringsNotTranslate.tooltipDisclaimerTextForAiCodeGenerationNoLoggingInConsole) :
|
|
78
|
+
lockedString(UIStringsNotTranslate.tooltipDisclaimerTextForAiCodeGenerationInConsole);
|
|
79
|
+
case AiCodeCompletion.AiCodeCompletion.ContextFlavor.SOURCES:
|
|
80
|
+
return noLogging ?
|
|
81
|
+
lockedString(UIStringsNotTranslate.tooltipDisclaimerTextForAiCodeGenerationNoLoggingInSources) :
|
|
82
|
+
lockedString(UIStringsNotTranslate.tooltipDisclaimerTextForAiCodeGenerationInSources);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
40
86
|
export interface ViewInput {
|
|
41
87
|
displayState: AiCodeGenerationTeaserDisplayState;
|
|
88
|
+
disclaimerTooltipId?: string;
|
|
89
|
+
noLogging: boolean;
|
|
90
|
+
onManageInSettingsTooltipClick: (event: Event) => void;
|
|
91
|
+
// TODO(b/472268298): Remove ContextFlavor explicitly and pass required values
|
|
92
|
+
panel?: AiCodeCompletion.AiCodeCompletion.ContextFlavor;
|
|
42
93
|
}
|
|
43
94
|
|
|
44
|
-
export
|
|
95
|
+
export interface ViewOutput {
|
|
96
|
+
hideTooltip?: () => void;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export type View = (input: ViewInput, output: ViewOutput, target: HTMLElement) => void;
|
|
100
|
+
|
|
101
|
+
export const DEFAULT_VIEW: View = (input, output, target) => {
|
|
102
|
+
if (!input.panel) {
|
|
103
|
+
render(nothing, target);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
45
106
|
|
|
46
|
-
export const DEFAULT_VIEW: View = (input, _output, target) => {
|
|
47
107
|
let teaserLabel;
|
|
48
108
|
switch (input.displayState) {
|
|
109
|
+
case AiCodeGenerationTeaserDisplayState.TRIGGER: {
|
|
110
|
+
if (!input.disclaimerTooltipId) {
|
|
111
|
+
render(nothing, target);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const toGenerateCode = Host.Platform.isMac() ? lockedString(UIStringsNotTranslate.cmdItoGenerateCode) :
|
|
115
|
+
lockedString(UIStringsNotTranslate.ctrlItoGenerateCode);
|
|
116
|
+
const tooltipDisclaimerText = getTooltipDisclaimerText(input.noLogging, input.panel);
|
|
117
|
+
// TODO(b/472291834): Disclaimer icon should match the placeholder's color
|
|
118
|
+
// clang-format off
|
|
119
|
+
teaserLabel = html`<div class="ai-code-generation-teaser-trigger">
|
|
120
|
+
${toGenerateCode} <devtools-button
|
|
121
|
+
.data=${{
|
|
122
|
+
title: lockedString(UIStringsNotTranslate.learnMoreAboutHowYourDataIsBeingUsed),
|
|
123
|
+
size: Buttons.Button.Size.MICRO,
|
|
124
|
+
iconName: 'info',
|
|
125
|
+
variant: Buttons.Button.Variant.ICON,
|
|
126
|
+
jslogContext: 'ai-code-generation-teaser.info-button',
|
|
127
|
+
} as Buttons.Button.ButtonData}
|
|
128
|
+
aria-details=${input.disclaimerTooltipId}
|
|
129
|
+
aria-describedby=${input.disclaimerTooltipId}
|
|
130
|
+
></devtools-button>
|
|
131
|
+
<devtools-tooltip
|
|
132
|
+
id=${input.disclaimerTooltipId}
|
|
133
|
+
variant="rich"
|
|
134
|
+
jslogContext="ai-code-generation-disclaimer"
|
|
135
|
+
${Directives.ref(el => {
|
|
136
|
+
if (el instanceof HTMLElement) {
|
|
137
|
+
output.hideTooltip = () => {
|
|
138
|
+
el.hidePopover();
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
})}>
|
|
142
|
+
<div class="disclaimer-tooltip-container"><div class="tooltip-text">
|
|
143
|
+
${tooltipDisclaimerText}
|
|
144
|
+
</div>
|
|
145
|
+
<span
|
|
146
|
+
tabIndex="0"
|
|
147
|
+
class="link"
|
|
148
|
+
role="link"
|
|
149
|
+
jslog=${VisualLogging.link('open-ai-settings').track({
|
|
150
|
+
click: true,
|
|
151
|
+
})}
|
|
152
|
+
@click=${input.onManageInSettingsTooltipClick}
|
|
153
|
+
>${lockedString(UIStringsNotTranslate.manageInSettings)}</span></div></devtools-tooltip>
|
|
154
|
+
</div>`;
|
|
155
|
+
// clang-format on
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
|
|
49
159
|
case AiCodeGenerationTeaserDisplayState.DISCOVERY: {
|
|
50
160
|
const newBadge = UI.UIUtils.maybeCreateNewBadge(PROMOTION_ID);
|
|
51
161
|
teaserLabel = newBadge ?
|
|
@@ -58,13 +168,6 @@ export const DEFAULT_VIEW: View = (input, _output, target) => {
|
|
|
58
168
|
teaserLabel = html`${lockedString(UIStringsNotTranslate.generating)}`;
|
|
59
169
|
break;
|
|
60
170
|
}
|
|
61
|
-
|
|
62
|
-
case AiCodeGenerationTeaserDisplayState.TRIGGER: {
|
|
63
|
-
const toGenerateCode = Host.Platform.isMac() ? lockedString(UIStringsNotTranslate.cmdItoGenerateCode) :
|
|
64
|
-
lockedString(UIStringsNotTranslate.ctrlItoGenerateCode);
|
|
65
|
-
teaserLabel = html`${toGenerateCode}`;
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
171
|
}
|
|
69
172
|
|
|
70
173
|
// clang-format off
|
|
@@ -73,7 +176,7 @@ export const DEFAULT_VIEW: View = (input, _output, target) => {
|
|
|
73
176
|
<style>${styles}</style>
|
|
74
177
|
<style>@scope to (devtools-widget > *) { ${UI.inspectorCommonStyles} }</style>
|
|
75
178
|
<div class="ai-code-generation-teaser">
|
|
76
|
-
|
|
179
|
+
${teaserLabel}
|
|
77
180
|
</div>
|
|
78
181
|
`, target
|
|
79
182
|
);
|
|
@@ -83,23 +186,32 @@ export const DEFAULT_VIEW: View = (input, _output, target) => {
|
|
|
83
186
|
// TODO(b/448063927): Add "Dont show again" for discovery teaser.
|
|
84
187
|
export class AiCodeGenerationTeaser extends UI.Widget.Widget {
|
|
85
188
|
readonly #view: View;
|
|
189
|
+
#viewOutput: ViewOutput = {};
|
|
86
190
|
|
|
87
191
|
#displayState = AiCodeGenerationTeaserDisplayState.TRIGGER;
|
|
192
|
+
#disclaimerTooltipId?: string;
|
|
193
|
+
#noLogging: boolean; // Whether the enterprise setting is `ALLOW_WITHOUT_LOGGING` or not.
|
|
194
|
+
#panel?: AiCodeCompletion.AiCodeCompletion.ContextFlavor;
|
|
88
195
|
|
|
89
196
|
constructor(view?: View) {
|
|
90
197
|
super();
|
|
91
198
|
this.markAsExternallyManaged();
|
|
199
|
+
this.#noLogging = Root.Runtime.hostConfig.aidaAvailability?.enterprisePolicyValue ===
|
|
200
|
+
Root.Runtime.GenAiEnterprisePolicyValue.ALLOW_WITHOUT_LOGGING;
|
|
92
201
|
this.#view = view ?? DEFAULT_VIEW;
|
|
93
202
|
this.requestUpdate();
|
|
94
203
|
}
|
|
95
204
|
|
|
96
205
|
override performUpdate(): void {
|
|
97
|
-
const output = {};
|
|
98
206
|
this.#view(
|
|
99
207
|
{
|
|
100
208
|
displayState: this.#displayState,
|
|
209
|
+
onManageInSettingsTooltipClick: this.#onManageInSettingsTooltipClick.bind(this),
|
|
210
|
+
disclaimerTooltipId: this.#disclaimerTooltipId,
|
|
211
|
+
noLogging: this.#noLogging,
|
|
212
|
+
panel: this.#panel,
|
|
101
213
|
},
|
|
102
|
-
|
|
214
|
+
this.#viewOutput, this.contentElement);
|
|
103
215
|
}
|
|
104
216
|
|
|
105
217
|
get displayState(): AiCodeGenerationTeaserDisplayState {
|
|
@@ -113,4 +225,21 @@ export class AiCodeGenerationTeaser extends UI.Widget.Widget {
|
|
|
113
225
|
this.#displayState = displayState;
|
|
114
226
|
this.requestUpdate();
|
|
115
227
|
}
|
|
228
|
+
|
|
229
|
+
set disclaimerTooltipId(disclaimerTooltipId: string) {
|
|
230
|
+
this.#disclaimerTooltipId = disclaimerTooltipId;
|
|
231
|
+
this.requestUpdate();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
set panel(panel: AiCodeCompletion.AiCodeCompletion.ContextFlavor) {
|
|
235
|
+
this.#panel = panel;
|
|
236
|
+
this.requestUpdate();
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
#onManageInSettingsTooltipClick(event: Event): void {
|
|
240
|
+
event.stopPropagation();
|
|
241
|
+
this.#viewOutput.hideTooltip?.();
|
|
242
|
+
void UI.ViewManager.ViewManager.instance().showView('chrome-ai');
|
|
243
|
+
event.consume(true);
|
|
244
|
+
}
|
|
116
245
|
}
|
|
@@ -6,9 +6,43 @@
|
|
|
6
6
|
|
|
7
7
|
@scope to (devtools-widget > *) {
|
|
8
8
|
.ai-code-generation-teaser {
|
|
9
|
+
pointer-events: all;
|
|
10
|
+
font-style: italic;
|
|
11
|
+
padding-left: var(--sys-size-3);
|
|
12
|
+
line-height: var(--sys-size-7);
|
|
13
|
+
|
|
14
|
+
.ai-code-generation-teaser-trigger {
|
|
15
|
+
display: inline-flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
}
|
|
18
|
+
|
|
9
19
|
.new-badge {
|
|
10
20
|
font-style: normal;
|
|
11
21
|
display: inline-block;
|
|
12
22
|
}
|
|
23
|
+
|
|
24
|
+
devtools-tooltip:popover-open {
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
align-items: center;
|
|
28
|
+
|
|
29
|
+
.disclaimer-tooltip-container {
|
|
30
|
+
padding: var(--sys-size-4) 0;
|
|
31
|
+
max-width: var(--sys-size-30);
|
|
32
|
+
white-space: normal;
|
|
33
|
+
|
|
34
|
+
.tooltip-text {
|
|
35
|
+
color: var(--sys-color-on-surface-subtle);
|
|
36
|
+
padding: 0 var(--sys-size-5);
|
|
37
|
+
align-items: flex-start;
|
|
38
|
+
gap: 10px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.link {
|
|
42
|
+
margin: var(--sys-size-5) var(--sys-size-8) 0 var(--sys-size-5);
|
|
43
|
+
display: inline-block;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
13
47
|
}
|
|
14
48
|
}
|
|
@@ -347,7 +347,8 @@ export class ObjectEventListenerBar extends UI.TreeOutline.TreeElement {
|
|
|
347
347
|
}
|
|
348
348
|
|
|
349
349
|
const subtitle = title.createChild('span', 'event-listener-tree-subtitle');
|
|
350
|
-
const linkElement = linkifier.linkifyRawLocation(
|
|
350
|
+
const linkElement = linkifier.linkifyRawLocation(
|
|
351
|
+
this.#eventListener.location(), this.#eventListener.sourceURL(), undefined, {tabStop: true});
|
|
351
352
|
subtitle.appendChild(linkElement);
|
|
352
353
|
|
|
353
354
|
this.listItemElement.addEventListener('contextmenu', event => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Name: Dependencies sourced from the upstream `chromium` repository
|
|
2
2
|
URL: https://chromium.googlesource.com/chromium/src
|
|
3
3
|
Version: N/A
|
|
4
|
-
Revision:
|
|
4
|
+
Revision: e3edb4435f06ac3de39688c44cc50378c47e35e8
|
|
5
5
|
Update Mechanism: Manual (https://crbug.com/428069060)
|
|
6
6
|
License: BSD-3-Clause
|
|
7
7
|
License File: LICENSE
|
|
@@ -71,6 +71,10 @@ export class AiCodeCompletionTeaserPlaceholder extends CM.WidgetType {
|
|
|
71
71
|
super.destroy(dom);
|
|
72
72
|
this.teaser?.hideWidget();
|
|
73
73
|
}
|
|
74
|
+
|
|
75
|
+
override eq(other: AiCodeCompletionTeaserPlaceholder): boolean {
|
|
76
|
+
return this.teaser === other.teaser;
|
|
77
|
+
}
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
export function aiCodeCompletionTeaserPlaceholder(teaser: UI.Widget.Widget): CM.Extension {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import * as Common from '../../../core/common/common.js';
|
|
6
6
|
import * as Host from '../../../core/host/host.js';
|
|
7
7
|
import * as i18n from '../../../core/i18n/i18n.js';
|
|
8
|
+
import type * as AiCodeCompletion from '../../../models/ai_code_completion/ai_code_completion.js';
|
|
8
9
|
import * as AiCodeGeneration from '../../../models/ai_code_generation/ai_code_generation.js';
|
|
9
10
|
import * as PanelCommon from '../../../panels/common/common.js';
|
|
10
11
|
import * as CodeMirror from '../../../third_party/codemirror.next/codemirror.next.js';
|
|
@@ -43,6 +44,7 @@ export interface AiCodeGenerationConfig {
|
|
|
43
44
|
onRequestTriggered: () => void;
|
|
44
45
|
// TODO(b/445394511): Move exposing citations to onSuggestionAccepted
|
|
45
46
|
onResponseReceived: (citations: Host.AidaClient.Citation[]) => void;
|
|
47
|
+
panel: AiCodeCompletion.AiCodeCompletion.ContextFlavor;
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
export class AiCodeGenerationProvider {
|
|
@@ -64,6 +66,9 @@ export class AiCodeGenerationProvider {
|
|
|
64
66
|
throw new Error('AI code generation feature is not enabled.');
|
|
65
67
|
}
|
|
66
68
|
this.#generationTeaser = new PanelCommon.AiCodeGenerationTeaser.AiCodeGenerationTeaser();
|
|
69
|
+
this.#generationTeaser.disclaimerTooltipId =
|
|
70
|
+
aiCodeGenerationConfig.panel + '-ai-code-generation-disclaimer-tooltip';
|
|
71
|
+
this.#generationTeaser.panel = aiCodeGenerationConfig.panel;
|
|
67
72
|
this.#aiCodeGenerationConfig = aiCodeGenerationConfig;
|
|
68
73
|
}
|
|
69
74
|
|
|
@@ -265,9 +270,13 @@ export class AiCodeGenerationProvider {
|
|
|
265
270
|
return;
|
|
266
271
|
}
|
|
267
272
|
|
|
273
|
+
const backtickRegex = /^```(?:\w+)?\n([\s\S]*?)\n```$/;
|
|
274
|
+
const matchArray = topSample.generationString.match(backtickRegex);
|
|
275
|
+
const suggestionText = matchArray ? matchArray[1].trim() : topSample.generationString;
|
|
276
|
+
|
|
268
277
|
this.#editor.dispatch({
|
|
269
278
|
effects: setAiAutoCompleteSuggestion.of({
|
|
270
|
-
text: '\n' +
|
|
279
|
+
text: '\n' + suggestionText,
|
|
271
280
|
from: cursor,
|
|
272
281
|
rpcGlobalId: generationResponse.metadata.rpcGlobalId,
|
|
273
282
|
sampleId: topSample.sampleId,
|
|
@@ -276,7 +285,7 @@ export class AiCodeGenerationProvider {
|
|
|
276
285
|
})
|
|
277
286
|
});
|
|
278
287
|
|
|
279
|
-
AiCodeGeneration.debugLog('Suggestion dispatched to the editor',
|
|
288
|
+
AiCodeGeneration.debugLog('Suggestion dispatched to the editor', suggestionText);
|
|
280
289
|
const citations = topSample.attributionMetadata?.citations ?? [];
|
|
281
290
|
this.#aiCodeGenerationConfig?.onResponseReceived(citations);
|
|
282
291
|
} catch (e) {
|
|
@@ -348,5 +357,15 @@ function aiCodeGenerationTeaserExtension(teaser: PanelCommon.AiCodeGenerationTea
|
|
|
348
357
|
}
|
|
349
358
|
}, {
|
|
350
359
|
decorations: v => v.decorations,
|
|
360
|
+
eventHandlers: {
|
|
361
|
+
mousemove(event: MouseEvent): boolean {
|
|
362
|
+
// Required for mouse hover to propagate to the info button in teaser.
|
|
363
|
+
return (event.target instanceof Node && teaser.contentElement.contains(event.target));
|
|
364
|
+
},
|
|
365
|
+
mousedown(event: MouseEvent): boolean {
|
|
366
|
+
// Required for mouse click to propagate to the info tooltip in teaser.
|
|
367
|
+
return (event.target instanceof Node && teaser.contentElement.contains(event.target));
|
|
368
|
+
},
|
|
369
|
+
},
|
|
351
370
|
});
|
|
352
371
|
}
|
|
@@ -320,13 +320,14 @@ export class Linkifier extends Common.ObjectWrapper.ObjectWrapper<EventTypes> im
|
|
|
320
320
|
}
|
|
321
321
|
|
|
322
322
|
linkifyRawLocation(
|
|
323
|
-
rawLocation: SDK.DebuggerModel.Location, fallbackUrl: Platform.DevToolsPath.UrlString,
|
|
324
|
-
|
|
323
|
+
rawLocation: SDK.DebuggerModel.Location, fallbackUrl: Platform.DevToolsPath.UrlString, className?: string,
|
|
324
|
+
options?: LinkifyOptions): HTMLElement {
|
|
325
325
|
return this.linkifyScriptLocation(
|
|
326
326
|
rawLocation.debuggerModel.target(), rawLocation.scriptId, fallbackUrl, rawLocation.lineNumber, {
|
|
327
327
|
columnNumber: rawLocation.columnNumber,
|
|
328
328
|
className,
|
|
329
329
|
inlineFrameIndex: rawLocation.inlineFrameIndex,
|
|
330
|
+
tabStop: options?.tabStop,
|
|
330
331
|
});
|
|
331
332
|
}
|
|
332
333
|
|
|
@@ -352,6 +352,7 @@ export const knownContextValues = new Set([
|
|
|
352
352
|
'ai-code-completion-teaser-dismissed',
|
|
353
353
|
'ai-code-completion-teaser.dismiss',
|
|
354
354
|
'ai-code-completion-teaser.fre',
|
|
355
|
+
'ai-code-generation-teaser.info-button',
|
|
355
356
|
'ai-explorer',
|
|
356
357
|
'ai_assistance',
|
|
357
358
|
'align-content',
|
package/package.json
CHANGED