chrome-devtools-frontend 1.0.1510848 → 1.0.1512147
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/host/AidaClient.ts +2 -0
- package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.ts +1 -1
- package/front_end/models/ai_code_completion/AiCodeCompletion.ts +3 -0
- package/front_end/models/trace/insights/Common.ts +19 -0
- package/front_end/panels/common/AiCodeCompletionDisclaimer.ts +36 -9
- package/front_end/panels/common/AiCodeCompletionSummaryToolbar.ts +32 -0
- package/front_end/panels/common/AiCodeCompletionTeaser.ts +14 -2
- package/front_end/panels/console/ConsolePrompt.ts +26 -0
- package/front_end/panels/sources/AiCodeCompletionPlugin.ts +35 -6
- package/front_end/panels/timeline/TimelinePanel.ts +1 -1
- package/front_end/panels/timeline/utils/InsightAIContext.ts +0 -19
- package/package.json +1 -1
@@ -717,6 +717,8 @@ export class HostConfigTracker extends Common.ObjectWrapper.ObjectWrapper<EventT
|
|
717
717
|
const config =
|
718
718
|
await new Promise<Root.Runtime.HostConfig>(resolve => InspectorFrontendHostInstance.getHostConfig(resolve));
|
719
719
|
Object.assign(Root.Runtime.hostConfig, config);
|
720
|
+
// TODO(crbug.com/442545623): Send `currentAidaAvailability` to the listeners as part of the event so that
|
721
|
+
// `await AidaClient.checkAccessPreconditions()` does not need to be called again in the event handlers.
|
720
722
|
this.dispatchEventToListeners(Events.AIDA_AVAILABILITY_CHANGED);
|
721
723
|
}
|
722
724
|
}
|
@@ -95,7 +95,7 @@ export class PerformanceTraceFormatter {
|
|
95
95
|
continue;
|
96
96
|
}
|
97
97
|
|
98
|
-
const insightBounds =
|
98
|
+
const insightBounds = Trace.Insights.Common.insightBounds(model, insightSet.bounds);
|
99
99
|
const insightParts = [
|
100
100
|
`insight name: ${insightName}`,
|
101
101
|
`description: ${model.description}`,
|
@@ -377,6 +377,9 @@ export class AiCodeCompletion extends Common.ObjectWrapper.ObjectWrapper<EventTy
|
|
377
377
|
clearTimeout(this.#renderingTimeout);
|
378
378
|
this.#renderingTimeout = undefined;
|
379
379
|
}
|
380
|
+
this.#editor.dispatch({
|
381
|
+
effects: TextEditor.Config.setAiAutoCompleteSuggestion.of(null),
|
382
|
+
});
|
380
383
|
}
|
381
384
|
}
|
382
385
|
|
@@ -12,6 +12,7 @@ import * as Types from '../types/types.js';
|
|
12
12
|
import {getLogNormalScore} from './Statistics.js';
|
13
13
|
import {
|
14
14
|
InsightKeys,
|
15
|
+
type InsightModel,
|
15
16
|
type InsightModels,
|
16
17
|
type InsightSet,
|
17
18
|
type InsightSetContext,
|
@@ -432,3 +433,21 @@ export function calculateDocFirstByteTs(docRequest: Types.Events.SyntheticNetwor
|
|
432
433
|
Helpers.Timing.secondsToMicro(timing.requestTime) +
|
433
434
|
Helpers.Timing.milliToMicro(timing.receiveHeadersStart ?? timing.receiveHeadersEnd));
|
434
435
|
}
|
436
|
+
|
437
|
+
/**
|
438
|
+
* Calculates the trace bounds for the given insight that are relevant.
|
439
|
+
*
|
440
|
+
* Uses the insight's overlays to determine the relevant trace bounds. If there are
|
441
|
+
* no overlays, falls back to the insight set's navigation bounds.
|
442
|
+
*/
|
443
|
+
export function insightBounds(
|
444
|
+
insight: InsightModel, insightSetBounds: Types.Timing.TraceWindowMicro): Types.Timing.TraceWindowMicro {
|
445
|
+
const overlays = insight.createOverlays?.() ?? [];
|
446
|
+
const windows = overlays.map(Helpers.Timing.traceWindowFromOverlay).filter(bounds => !!bounds);
|
447
|
+
const overlaysBounds = Helpers.Timing.combineTraceWindowsMicro(windows);
|
448
|
+
if (overlaysBounds) {
|
449
|
+
return overlaysBounds;
|
450
|
+
}
|
451
|
+
|
452
|
+
return insightSetBounds;
|
453
|
+
}
|
@@ -5,6 +5,7 @@
|
|
5
5
|
import '../../ui/components/spinners/spinners.js';
|
6
6
|
import '../../ui/components/tooltips/tooltips.js';
|
7
7
|
|
8
|
+
import * as Host from '../../core/host/host.js';
|
8
9
|
import * as i18n from '../../core/i18n/i18n.js';
|
9
10
|
import * as Root from '../../core/root/root.js';
|
10
11
|
import * as UI from '../../ui/legacy/legacy.js';
|
@@ -47,6 +48,7 @@ const lockedString = i18n.i18n.lockedString;
|
|
47
48
|
export interface ViewInput {
|
48
49
|
disclaimerTooltipId?: string;
|
49
50
|
noLogging: boolean;
|
51
|
+
aidaAvailability?: Host.AidaClient.AidaAccessPreconditions;
|
50
52
|
onManageInSettingsTooltipClick: () => void;
|
51
53
|
}
|
52
54
|
|
@@ -57,13 +59,12 @@ export interface ViewOutput {
|
|
57
59
|
|
58
60
|
export type View = (input: ViewInput, output: ViewOutput, target: HTMLElement) => void;
|
59
61
|
|
60
|
-
export const DEFAULT_SUMMARY_TOOLBAR_VIEW: View =
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
// clang-format off
|
62
|
+
export const DEFAULT_SUMMARY_TOOLBAR_VIEW: View = (input, output, target) => {
|
63
|
+
if (input.aidaAvailability !== Host.AidaClient.AidaAccessPreconditions.AVAILABLE || !input.disclaimerTooltipId) {
|
64
|
+
render(nothing, target);
|
65
|
+
return;
|
66
|
+
}
|
67
|
+
// clang-format off
|
67
68
|
render(
|
68
69
|
html`
|
69
70
|
<style>${styles}</style>
|
@@ -114,8 +115,8 @@ export const DEFAULT_SUMMARY_TOOLBAR_VIEW: View =
|
|
114
115
|
>${lockedString(UIStringsNotTranslate.manageInSettings)}</span></div></devtools-tooltip>
|
115
116
|
</div>
|
116
117
|
`, target);
|
117
|
-
|
118
|
-
|
118
|
+
// clang-format on
|
119
|
+
};
|
119
120
|
|
120
121
|
const MINIMUM_LOADING_STATE_TIMEOUT = 1000;
|
121
122
|
|
@@ -129,11 +130,15 @@ export class AiCodeCompletionDisclaimer extends UI.Widget.Widget {
|
|
129
130
|
#loadingStartTime = 0;
|
130
131
|
#spinnerLoadingTimeout: number|undefined;
|
131
132
|
|
133
|
+
#aidaAvailability?: Host.AidaClient.AidaAccessPreconditions;
|
134
|
+
#boundOnAidaAvailabilityChange: () => Promise<void>;
|
135
|
+
|
132
136
|
constructor(element?: HTMLElement, view: View = DEFAULT_SUMMARY_TOOLBAR_VIEW) {
|
133
137
|
super(element);
|
134
138
|
this.markAsExternallyManaged();
|
135
139
|
this.#noLogging = Root.Runtime.hostConfig.aidaAvailability?.enterprisePolicyValue ===
|
136
140
|
Root.Runtime.GenAiEnterprisePolicyValue.ALLOW_WITHOUT_LOGGING;
|
141
|
+
this.#boundOnAidaAvailabilityChange = this.#onAidaAvailabilityChange.bind(this);
|
137
142
|
this.#view = view;
|
138
143
|
}
|
139
144
|
|
@@ -169,6 +174,14 @@ export class AiCodeCompletionDisclaimer extends UI.Widget.Widget {
|
|
169
174
|
}
|
170
175
|
}
|
171
176
|
|
177
|
+
async #onAidaAvailabilityChange(): Promise<void> {
|
178
|
+
const currentAidaAvailability = await Host.AidaClient.AidaClient.checkAccessPreconditions();
|
179
|
+
if (currentAidaAvailability !== this.#aidaAvailability) {
|
180
|
+
this.#aidaAvailability = currentAidaAvailability;
|
181
|
+
this.requestUpdate();
|
182
|
+
}
|
183
|
+
}
|
184
|
+
|
172
185
|
#onManageInSettingsTooltipClick(): void {
|
173
186
|
this.#viewOutput.hideTooltip?.();
|
174
187
|
void UI.ViewManager.ViewManager.instance().showView('chrome-ai');
|
@@ -179,8 +192,22 @@ export class AiCodeCompletionDisclaimer extends UI.Widget.Widget {
|
|
179
192
|
{
|
180
193
|
disclaimerTooltipId: this.#disclaimerTooltipId,
|
181
194
|
noLogging: this.#noLogging,
|
195
|
+
aidaAvailability: this.#aidaAvailability,
|
182
196
|
onManageInSettingsTooltipClick: this.#onManageInSettingsTooltipClick.bind(this),
|
183
197
|
},
|
184
198
|
this.#viewOutput, this.contentElement);
|
185
199
|
}
|
200
|
+
|
201
|
+
override wasShown(): void {
|
202
|
+
super.wasShown();
|
203
|
+
Host.AidaClient.HostConfigTracker.instance().addEventListener(
|
204
|
+
Host.AidaClient.Events.AIDA_AVAILABILITY_CHANGED, this.#boundOnAidaAvailabilityChange);
|
205
|
+
void this.#onAidaAvailabilityChange();
|
206
|
+
}
|
207
|
+
|
208
|
+
override willHide(): void {
|
209
|
+
super.willHide();
|
210
|
+
Host.AidaClient.HostConfigTracker.instance().removeEventListener(
|
211
|
+
Host.AidaClient.Events.AIDA_AVAILABILITY_CHANGED, this.#boundOnAidaAvailabilityChange);
|
212
|
+
}
|
186
213
|
}
|
@@ -5,6 +5,7 @@
|
|
5
5
|
import '../../ui/components/spinners/spinners.js';
|
6
6
|
import '../../ui/components/tooltips/tooltips.js';
|
7
7
|
|
8
|
+
import * as Host from '../../core/host/host.js';
|
8
9
|
import * as i18n from '../../core/i18n/i18n.js';
|
9
10
|
import * as UI from '../../ui/legacy/legacy.js';
|
10
11
|
import {Directives, html, nothing, render} from '../../ui/lit/lit.js';
|
@@ -38,11 +39,16 @@ export interface ViewInput {
|
|
38
39
|
citationsTooltipId: string;
|
39
40
|
loading: boolean;
|
40
41
|
hasTopBorder: boolean;
|
42
|
+
aidaAvailability?: Host.AidaClient.AidaAccessPreconditions;
|
41
43
|
}
|
42
44
|
|
43
45
|
export type View = (input: ViewInput, output: undefined, target: HTMLElement) => void;
|
44
46
|
|
45
47
|
export const DEFAULT_SUMMARY_TOOLBAR_VIEW: View = (input, _output, target) => {
|
48
|
+
if (input.aidaAvailability !== Host.AidaClient.AidaAccessPreconditions.AVAILABLE) {
|
49
|
+
render(nothing, target);
|
50
|
+
return;
|
51
|
+
}
|
46
52
|
const toolbarClasses = Directives.classMap({
|
47
53
|
'ai-code-completion-summary-toolbar': true,
|
48
54
|
'has-disclaimer': Boolean(input.disclaimerTooltipId),
|
@@ -101,15 +107,27 @@ export class AiCodeCompletionSummaryToolbar extends UI.Widget.Widget {
|
|
101
107
|
#loading = false;
|
102
108
|
#hasTopBorder = false;
|
103
109
|
|
110
|
+
#aidaAvailability?: Host.AidaClient.AidaAccessPreconditions;
|
111
|
+
#boundOnAidaAvailabilityChange: () => Promise<void>;
|
112
|
+
|
104
113
|
constructor(props: AiCodeCompletionSummaryToolbarProps, view?: View) {
|
105
114
|
super();
|
106
115
|
this.#disclaimerTooltipId = props.disclaimerTooltipId;
|
107
116
|
this.#citationsTooltipId = props.citationsTooltipId;
|
108
117
|
this.#hasTopBorder = props.hasTopBorder ?? false;
|
118
|
+
this.#boundOnAidaAvailabilityChange = this.#onAidaAvailabilityChange.bind(this);
|
109
119
|
this.#view = view ?? DEFAULT_SUMMARY_TOOLBAR_VIEW;
|
110
120
|
this.requestUpdate();
|
111
121
|
}
|
112
122
|
|
123
|
+
async #onAidaAvailabilityChange(): Promise<void> {
|
124
|
+
const currentAidaAvailability = await Host.AidaClient.AidaClient.checkAccessPreconditions();
|
125
|
+
if (currentAidaAvailability !== this.#aidaAvailability) {
|
126
|
+
this.#aidaAvailability = currentAidaAvailability;
|
127
|
+
this.requestUpdate();
|
128
|
+
}
|
129
|
+
}
|
130
|
+
|
113
131
|
setLoading(loading: boolean): void {
|
114
132
|
this.#loading = loading;
|
115
133
|
this.requestUpdate();
|
@@ -133,7 +151,21 @@ export class AiCodeCompletionSummaryToolbar extends UI.Widget.Widget {
|
|
133
151
|
citationsTooltipId: this.#citationsTooltipId,
|
134
152
|
loading: this.#loading,
|
135
153
|
hasTopBorder: this.#hasTopBorder,
|
154
|
+
aidaAvailability: this.#aidaAvailability,
|
136
155
|
},
|
137
156
|
undefined, this.contentElement);
|
138
157
|
}
|
158
|
+
|
159
|
+
override wasShown(): void {
|
160
|
+
super.wasShown();
|
161
|
+
Host.AidaClient.HostConfigTracker.instance().addEventListener(
|
162
|
+
Host.AidaClient.Events.AIDA_AVAILABILITY_CHANGED, this.#boundOnAidaAvailabilityChange);
|
163
|
+
void this.#onAidaAvailabilityChange();
|
164
|
+
}
|
165
|
+
|
166
|
+
override willHide(): void {
|
167
|
+
super.willHide();
|
168
|
+
Host.AidaClient.HostConfigTracker.instance().removeEventListener(
|
169
|
+
Host.AidaClient.Events.AIDA_AVAILABILITY_CHANGED, this.#boundOnAidaAvailabilityChange);
|
170
|
+
}
|
139
171
|
}
|
@@ -88,7 +88,7 @@ const lockedString = i18n.i18n.lockedString;
|
|
88
88
|
const CODE_SNIPPET_WARNING_URL = 'https://support.google.com/legal/answer/13505487';
|
89
89
|
|
90
90
|
export interface ViewInput {
|
91
|
-
aidaAvailability
|
91
|
+
aidaAvailability?: Host.AidaClient.AidaAccessPreconditions;
|
92
92
|
onAction: (event: Event) => void;
|
93
93
|
onDismiss: (event: Event) => void;
|
94
94
|
}
|
@@ -134,8 +134,9 @@ interface AiCodeCompletionTeaserConfig {
|
|
134
134
|
export class AiCodeCompletionTeaser extends UI.Widget.Widget {
|
135
135
|
readonly #view: View;
|
136
136
|
|
137
|
-
#aidaAvailability
|
137
|
+
#aidaAvailability?: Host.AidaClient.AidaAccessPreconditions;
|
138
138
|
#boundOnAidaAvailabilityChange: () => Promise<void>;
|
139
|
+
#boundOnAiCodeCompletionSettingChanged: () => void;
|
139
140
|
#onDetach: () => void;
|
140
141
|
|
141
142
|
// Whether the user completed first run experience dialog or not.
|
@@ -153,6 +154,7 @@ export class AiCodeCompletionTeaser extends UI.Widget.Widget {
|
|
153
154
|
this.#onDetach = config.onDetach;
|
154
155
|
this.#view = view ?? DEFAULT_VIEW;
|
155
156
|
this.#boundOnAidaAvailabilityChange = this.#onAidaAvailabilityChange.bind(this);
|
157
|
+
this.#boundOnAiCodeCompletionSettingChanged = this.#onAiCodeCompletionSettingChanged.bind(this);
|
156
158
|
this.#noLogging = Root.Runtime.hostConfig.aidaAvailability?.enterprisePolicyValue ===
|
157
159
|
Root.Runtime.GenAiEnterprisePolicyValue.ALLOW_WITHOUT_LOGGING;
|
158
160
|
this.requestUpdate();
|
@@ -179,6 +181,12 @@ export class AiCodeCompletionTeaser extends UI.Widget.Widget {
|
|
179
181
|
}
|
180
182
|
}
|
181
183
|
|
184
|
+
#onAiCodeCompletionSettingChanged(): void {
|
185
|
+
if (this.#aiCodeCompletionFreCompletedSetting.get() || this.#aiCodeCompletionTeaserDismissedSetting.get()) {
|
186
|
+
this.detach();
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
182
190
|
onAction = async(event: Event): Promise<void> => {
|
183
191
|
event.preventDefault();
|
184
192
|
const result = await FreDialog.show({
|
@@ -243,6 +251,8 @@ export class AiCodeCompletionTeaser extends UI.Widget.Widget {
|
|
243
251
|
super.wasShown();
|
244
252
|
Host.AidaClient.HostConfigTracker.instance().addEventListener(
|
245
253
|
Host.AidaClient.Events.AIDA_AVAILABILITY_CHANGED, this.#boundOnAidaAvailabilityChange);
|
254
|
+
this.#aiCodeCompletionFreCompletedSetting.addChangeListener(this.#boundOnAiCodeCompletionSettingChanged);
|
255
|
+
this.#aiCodeCompletionTeaserDismissedSetting.addChangeListener(this.#boundOnAiCodeCompletionSettingChanged);
|
246
256
|
void this.#onAidaAvailabilityChange();
|
247
257
|
}
|
248
258
|
|
@@ -250,6 +260,8 @@ export class AiCodeCompletionTeaser extends UI.Widget.Widget {
|
|
250
260
|
super.willHide();
|
251
261
|
Host.AidaClient.HostConfigTracker.instance().removeEventListener(
|
252
262
|
Host.AidaClient.Events.AIDA_AVAILABILITY_CHANGED, this.#boundOnAidaAvailabilityChange);
|
263
|
+
this.#aiCodeCompletionFreCompletedSetting.removeChangeListener(this.#boundOnAiCodeCompletionSettingChanged);
|
264
|
+
this.#aiCodeCompletionTeaserDismissedSetting.removeChangeListener(this.#boundOnAiCodeCompletionSettingChanged);
|
253
265
|
}
|
254
266
|
|
255
267
|
override onDetach(): void {
|
@@ -71,6 +71,8 @@ export class ConsolePrompt extends Common.ObjectWrapper.eventMixin<EventTypes, t
|
|
71
71
|
#javaScriptCompletionCompartment: CodeMirror.Compartment = new CodeMirror.Compartment();
|
72
72
|
|
73
73
|
private aidaClient?: Host.AidaClient.AidaClient;
|
74
|
+
private aidaAvailability?: Host.AidaClient.AidaAccessPreconditions;
|
75
|
+
private boundOnAidaAvailabilityChange?: () => Promise<void>;
|
74
76
|
private aiCodeCompletion?: AiCodeCompletion.AiCodeCompletion.AiCodeCompletion;
|
75
77
|
private teaser?: PanelCommon.AiCodeCompletionTeaser;
|
76
78
|
private placeholderCompartment: CodeMirror.Compartment = new CodeMirror.Compartment();
|
@@ -199,6 +201,10 @@ export class ConsolePrompt extends Common.ObjectWrapper.eventMixin<EventTypes, t
|
|
199
201
|
if (this.isAiCodeCompletionEnabled()) {
|
200
202
|
this.aiCodeCompletionSetting.addChangeListener(this.onAiCodeCompletionSettingChanged.bind(this));
|
201
203
|
this.onAiCodeCompletionSettingChanged();
|
204
|
+
this.boundOnAidaAvailabilityChange = this.onAidaAvailabilityChange.bind(this);
|
205
|
+
Host.AidaClient.HostConfigTracker.instance().addEventListener(
|
206
|
+
Host.AidaClient.Events.AIDA_AVAILABILITY_CHANGED, this.boundOnAidaAvailabilityChange);
|
207
|
+
void this.onAidaAvailabilityChange();
|
202
208
|
}
|
203
209
|
}
|
204
210
|
|
@@ -294,6 +300,10 @@ export class ConsolePrompt extends Common.ObjectWrapper.eventMixin<EventTypes, t
|
|
294
300
|
this.highlightingNode = false;
|
295
301
|
SDK.OverlayModel.OverlayModel.hideDOMNodeHighlight();
|
296
302
|
}
|
303
|
+
if (this.boundOnAidaAvailabilityChange) {
|
304
|
+
Host.AidaClient.HostConfigTracker.instance().removeEventListener(
|
305
|
+
Host.AidaClient.Events.AIDA_AVAILABILITY_CHANGED, this.boundOnAidaAvailabilityChange);
|
306
|
+
}
|
297
307
|
}
|
298
308
|
|
299
309
|
history(): TextEditor.AutocompleteHistory.AutocompleteHistory {
|
@@ -505,6 +515,9 @@ export class ConsolePrompt extends Common.ObjectWrapper.eventMixin<EventTypes, t
|
|
505
515
|
// TODO(b/435654172): Refactor and move aiCodeCompletion model one level up to avoid
|
506
516
|
// defining additional listeners and events.
|
507
517
|
private setAiCodeCompletion(): void {
|
518
|
+
if (this.aiCodeCompletion) {
|
519
|
+
return;
|
520
|
+
}
|
508
521
|
if (!this.aidaClient) {
|
509
522
|
this.aidaClient = new Host.AidaClient.AidaClient();
|
510
523
|
}
|
@@ -532,6 +545,19 @@ export class ConsolePrompt extends Common.ObjectWrapper.eventMixin<EventTypes, t
|
|
532
545
|
}
|
533
546
|
}
|
534
547
|
|
548
|
+
private async onAidaAvailabilityChange(): Promise<void> {
|
549
|
+
const currentAidaAvailability = await Host.AidaClient.AidaClient.checkAccessPreconditions();
|
550
|
+
if (currentAidaAvailability !== this.aidaAvailability) {
|
551
|
+
this.aidaAvailability = currentAidaAvailability;
|
552
|
+
if (this.aidaAvailability === Host.AidaClient.AidaAccessPreconditions.AVAILABLE) {
|
553
|
+
this.onAiCodeCompletionSettingChanged();
|
554
|
+
} else if (this.aiCodeCompletion) {
|
555
|
+
this.aiCodeCompletion.remove();
|
556
|
+
this.aiCodeCompletion = undefined;
|
557
|
+
}
|
558
|
+
}
|
559
|
+
}
|
560
|
+
|
535
561
|
async onAiCodeCompletionTeaserActionKeyDown(event: Event): Promise<void> {
|
536
562
|
if (this.teaser?.isShowing()) {
|
537
563
|
await this.teaser?.onAction(event);
|
@@ -22,6 +22,8 @@ const CITATIONS_TOOLTIP_ID = 'sources-ai-code-completion-citations-tooltip';
|
|
22
22
|
|
23
23
|
export class AiCodeCompletionPlugin extends Plugin {
|
24
24
|
#aidaClient?: Host.AidaClient.AidaClient;
|
25
|
+
#aidaAvailability?: Host.AidaClient.AidaAccessPreconditions;
|
26
|
+
#boundOnAidaAvailabilityChange: () => Promise<void>;
|
25
27
|
#aiCodeCompletion?: AiCodeCompletion.AiCodeCompletion.AiCodeCompletion;
|
26
28
|
#aiCodeCompletionSetting = Common.Settings.Settings.instance().createSetting('ai-code-completion-enabled', false);
|
27
29
|
#aiCodeCompletionTeaserDismissedSetting =
|
@@ -48,6 +50,10 @@ export class AiCodeCompletionPlugin extends Plugin {
|
|
48
50
|
}
|
49
51
|
this.#boundEditorKeyDown = this.#editorKeyDown.bind(this);
|
50
52
|
this.#boundOnAiCodeCompletionSettingChanged = this.#onAiCodeCompletionSettingChanged.bind(this);
|
53
|
+
this.#boundOnAidaAvailabilityChange = this.#onAidaAvailabilityChange.bind(this);
|
54
|
+
Host.AidaClient.HostConfigTracker.instance().addEventListener(
|
55
|
+
Host.AidaClient.Events.AIDA_AVAILABILITY_CHANGED, this.#boundOnAidaAvailabilityChange);
|
56
|
+
void this.#onAidaAvailabilityChange();
|
51
57
|
const showTeaser = !this.#aiCodeCompletionSetting.get() && !this.#aiCodeCompletionTeaserDismissedSetting.get();
|
52
58
|
if (showTeaser) {
|
53
59
|
this.#teaser = new PanelCommon.AiCodeCompletionTeaser({onDetach: this.#detachAiCodeCompletionTeaser.bind(this)});
|
@@ -61,6 +67,8 @@ export class AiCodeCompletionPlugin extends Plugin {
|
|
61
67
|
override dispose(): void {
|
62
68
|
this.#teaser = undefined;
|
63
69
|
this.#aiCodeCompletionSetting.removeChangeListener(this.#boundOnAiCodeCompletionSettingChanged);
|
70
|
+
Host.AidaClient.HostConfigTracker.instance().removeEventListener(
|
71
|
+
Host.AidaClient.Events.AIDA_AVAILABILITY_CHANGED, this.#boundOnAidaAvailabilityChange);
|
64
72
|
this.#editor?.removeEventListener('keydown', this.#boundEditorKeyDown);
|
65
73
|
this.#cleanupAiCodeCompletion();
|
66
74
|
super.dispose();
|
@@ -203,23 +211,31 @@ export class AiCodeCompletionPlugin extends Plugin {
|
|
203
211
|
this.#detachAiCodeCompletionTeaser();
|
204
212
|
this.#teaser = undefined;
|
205
213
|
}
|
206
|
-
this.#aiCodeCompletion
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
214
|
+
if (!this.#aiCodeCompletion) {
|
215
|
+
this.#aiCodeCompletion = new AiCodeCompletion.AiCodeCompletion.AiCodeCompletion(
|
216
|
+
{aidaClient: this.#aidaClient}, this.#editor, AiCodeCompletion.AiCodeCompletion.Panel.SOURCES);
|
217
|
+
this.#aiCodeCompletion.addEventListener(
|
218
|
+
AiCodeCompletion.AiCodeCompletion.Events.REQUEST_TRIGGERED, this.#onAiRequestTriggered, this);
|
219
|
+
this.#aiCodeCompletion.addEventListener(
|
220
|
+
AiCodeCompletion.AiCodeCompletion.Events.RESPONSE_RECEIVED, this.#onAiResponseReceived, this);
|
221
|
+
}
|
212
222
|
this.#createAiCodeCompletionDisclaimer();
|
213
223
|
this.#createAiCodeCompletionCitationsToolbar();
|
214
224
|
}
|
215
225
|
|
216
226
|
#createAiCodeCompletionDisclaimer(): void {
|
227
|
+
if (this.#aiCodeCompletionDisclaimer) {
|
228
|
+
return;
|
229
|
+
}
|
217
230
|
this.#aiCodeCompletionDisclaimer = new PanelCommon.AiCodeCompletionDisclaimer();
|
218
231
|
this.#aiCodeCompletionDisclaimer.disclaimerTooltipId = DISCLAIMER_TOOLTIP_ID;
|
219
232
|
this.#aiCodeCompletionDisclaimer.show(this.#aiCodeCompletionDisclaimerContainer, undefined, true);
|
220
233
|
}
|
221
234
|
|
222
235
|
#createAiCodeCompletionCitationsToolbar(): void {
|
236
|
+
if (this.#aiCodeCompletionCitationsToolbar) {
|
237
|
+
return;
|
238
|
+
}
|
223
239
|
this.#aiCodeCompletionCitationsToolbar =
|
224
240
|
new PanelCommon.AiCodeCompletionSummaryToolbar({citationsTooltipId: CITATIONS_TOOLTIP_ID, hasTopBorder: true});
|
225
241
|
this.#aiCodeCompletionCitationsToolbar.show(this.#aiCodeCompletionCitationsToolbarContainer, undefined, true);
|
@@ -253,12 +269,25 @@ export class AiCodeCompletionPlugin extends Plugin {
|
|
253
269
|
}
|
254
270
|
}
|
255
271
|
|
272
|
+
async #onAidaAvailabilityChange(): Promise<void> {
|
273
|
+
const currentAidaAvailability = await Host.AidaClient.AidaClient.checkAccessPreconditions();
|
274
|
+
if (currentAidaAvailability !== this.#aidaAvailability) {
|
275
|
+
this.#aidaAvailability = currentAidaAvailability;
|
276
|
+
if (this.#aidaAvailability === Host.AidaClient.AidaAccessPreconditions.AVAILABLE) {
|
277
|
+
this.#onAiCodeCompletionSettingChanged();
|
278
|
+
} else if (this.#aiCodeCompletion) {
|
279
|
+
this.#cleanupAiCodeCompletion();
|
280
|
+
}
|
281
|
+
}
|
282
|
+
}
|
283
|
+
|
256
284
|
#cleanupAiCodeCompletion(): void {
|
257
285
|
this.#aiCodeCompletion?.removeEventListener(
|
258
286
|
AiCodeCompletion.AiCodeCompletion.Events.REQUEST_TRIGGERED, this.#onAiRequestTriggered, this);
|
259
287
|
this.#aiCodeCompletion?.removeEventListener(
|
260
288
|
AiCodeCompletion.AiCodeCompletion.Events.RESPONSE_RECEIVED, this.#onAiResponseReceived, this);
|
261
289
|
this.#aiCodeCompletion?.remove();
|
290
|
+
this.#aiCodeCompletion = undefined;
|
262
291
|
this.#aiCodeCompletionCitations = [];
|
263
292
|
this.#aiCodeCompletionDisclaimerContainer.removeChildren();
|
264
293
|
this.#aiCodeCompletionDisclaimer = undefined;
|
@@ -1534,7 +1534,7 @@ export class TimelinePanel extends Common.ObjectWrapper.eventMixin<EventTypes, t
|
|
1534
1534
|
// extensions sourcemaps provide little to no-value for the exported trace
|
1535
1535
|
// debugging, so they are filtered out.
|
1536
1536
|
return metadata.sourceMaps.filter(value => {
|
1537
|
-
return
|
1537
|
+
return !Trace.Helpers.Trace.isExtensionUrl(value.url);
|
1538
1538
|
});
|
1539
1539
|
}
|
1540
1540
|
|
@@ -126,22 +126,3 @@ export class AIQueries {
|
|
126
126
|
.filter(tree => !!tree);
|
127
127
|
}
|
128
128
|
}
|
129
|
-
|
130
|
-
/**
|
131
|
-
* Calculates the trace bounds for the given insight that are relevant.
|
132
|
-
*
|
133
|
-
* Uses the insight's overlays to determine the relevant trace bounds. If there are
|
134
|
-
* no overlays, falls back to the insight set's navigation bounds.
|
135
|
-
*/
|
136
|
-
export function insightBounds(
|
137
|
-
insight: Trace.Insights.Types.InsightModel,
|
138
|
-
insightSetBounds: Trace.Types.Timing.TraceWindowMicro): Trace.Types.Timing.TraceWindowMicro {
|
139
|
-
const overlays = insight.createOverlays?.() ?? [];
|
140
|
-
const windows = overlays.map(Trace.Helpers.Timing.traceWindowFromOverlay).filter(bounds => !!bounds);
|
141
|
-
const overlaysBounds = Trace.Helpers.Timing.combineTraceWindowsMicro(windows);
|
142
|
-
if (overlaysBounds) {
|
143
|
-
return overlaysBounds;
|
144
|
-
}
|
145
|
-
|
146
|
-
return insightSetBounds;
|
147
|
-
}
|
package/package.json
CHANGED