@codingame/monaco-vscode-telemetry-service-override 32.0.2 → 33.0.9
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/index.js +2 -0
- package/package.json +3 -3
- package/vscode/src/vs/platform/telemetry/common/telemetryLogAppender.js +1 -1
- package/vscode/src/vs/platform/telemetry/common/telemetryService.js +21 -21
- package/vscode/src/vs/workbench/contrib/bracketPairColorizer2Telemetry/browser/bracketPairColorizer2Telemetry.contribution.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/bracketPairColorizer2Telemetry/browser/bracketPairColorizer2Telemetry.contribution.js +34 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/aiContributionFeature.d.ts +15 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/aiContributionFeature.js +97 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/editStats/aiStatsChart.d.ts +24 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/editStats/aiStatsChart.js +236 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/editStats/aiStatsFeature.d.ts +24 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/editStats/aiStatsFeature.js +213 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/editStats/aiStatsStatusBar.d.ts +27 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/editStats/aiStatsStatusBar.js +250 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/editStats/media.css +127 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/editTelemetry.contribution.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/editTelemetry.contribution.js +75 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/editTelemetryContribution.d.ts +8 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/editTelemetryContribution.js +82 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/helpers/annotatedDocuments.d.ts +30 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/helpers/annotatedDocuments.js +79 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/helpers/documentWithAnnotatedEdits.d.ts +128 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/helpers/documentWithAnnotatedEdits.js +297 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/helpers/observableWorkspace.d.ts +31 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/helpers/observableWorkspace.js +66 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/helpers/utils.d.ts +9 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/helpers/utils.js +47 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/helpers/vscodeObservableWorkspace.d.ts +26 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/helpers/vscodeObservableWorkspace.js +84 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/settingIds.d.ts +2 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/settingIds.js +6 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/settings.d.ts +3 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/settings.js +7 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/arcTelemetryReporter.d.ts +37 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/arcTelemetryReporter.js +80 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/arcTelemetrySender.d.ts +20 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/arcTelemetrySender.js +173 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/editSourceTrackingFeature.d.ts +23 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/editSourceTrackingFeature.js +232 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/editSourceTrackingImpl.d.ts +48 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/editSourceTrackingImpl.js +292 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/editTracker.d.ts +41 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/editTracker.js +99 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/scmAdapter.d.ts +18 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/scmAdapter.js +44 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/common/arcTracker.d.ts +29 -0
- package/vscode/src/vs/workbench/contrib/editTelemetry/common/arcTracker.js +64 -0
- package/vscode/src/vs/workbench/contrib/telemetry/browser/telemetry.contribution.js +1 -1
package/vscode/src/vs/workbench/contrib/editTelemetry/browser/telemetry/editSourceTrackingImpl.js
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { reverseOrder, compareBy, numberComparator, sumBy } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
|
|
4
|
+
import { IntervalTimer } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
|
|
5
|
+
import { Disposable, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
6
|
+
import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
|
|
7
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
8
|
+
import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
9
|
+
import { IUserAttentionService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/userAttention/common/userAttentionService.service';
|
|
10
|
+
import { EditTelemetryReportInlineEditArcSender, EditTelemetryReportEditArcForChatOrInlineChatSender, CreateSuggestionIdForChatOrInlineChatCaller } from './arcTelemetrySender.js';
|
|
11
|
+
import { createDocWithJustReason } from '../helpers/documentWithAnnotatedEdits.js';
|
|
12
|
+
import { DocumentEditSourceTracker } from './editTracker.js';
|
|
13
|
+
import { sumByCategory } from '../helpers/utils.js';
|
|
14
|
+
import { ScmAdapter } from './scmAdapter.js';
|
|
15
|
+
import { IRandomService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/editTelemetry/browser/randomService.service';
|
|
16
|
+
import { mapObservableArrayCached } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/utils/utils';
|
|
17
|
+
import { derived } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/derived';
|
|
18
|
+
import { observableSignal } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableSignal';
|
|
19
|
+
import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/reactions/autorun';
|
|
20
|
+
import { runOnChange } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/utils/runOnChange';
|
|
21
|
+
|
|
22
|
+
let EditSourceTrackingImpl = class EditSourceTrackingImpl extends Disposable {
|
|
23
|
+
constructor(_statsEnabled, _annotatedDocuments, _instantiationService) {
|
|
24
|
+
super();
|
|
25
|
+
this._statsEnabled = _statsEnabled;
|
|
26
|
+
this._annotatedDocuments = _annotatedDocuments;
|
|
27
|
+
this._instantiationService = _instantiationService;
|
|
28
|
+
const scmBridge = this._instantiationService.createInstance(ScmAdapter);
|
|
29
|
+
this._states = mapObservableArrayCached(this, this._annotatedDocuments.documents, (doc, store) => {
|
|
30
|
+
return [doc.document, store.add(
|
|
31
|
+
this._instantiationService.createInstance(TrackedDocumentInfo, doc, scmBridge, this._statsEnabled)
|
|
32
|
+
)];
|
|
33
|
+
});
|
|
34
|
+
this.docsState = ( this._states.map(entries => ( new Map(entries))));
|
|
35
|
+
this.docsState.recomputeInitiallyAndOnChange(this._store);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
EditSourceTrackingImpl = ( __decorate([( __param(2, IInstantiationService))], EditSourceTrackingImpl));
|
|
39
|
+
let TrackedDocumentInfo = class TrackedDocumentInfo extends Disposable {
|
|
40
|
+
constructor(
|
|
41
|
+
_doc,
|
|
42
|
+
_scm,
|
|
43
|
+
_statsEnabled,
|
|
44
|
+
_instantiationService,
|
|
45
|
+
_telemetryService,
|
|
46
|
+
_randomService,
|
|
47
|
+
_userAttentionService
|
|
48
|
+
) {
|
|
49
|
+
super();
|
|
50
|
+
this._doc = _doc;
|
|
51
|
+
this._scm = _scm;
|
|
52
|
+
this._statsEnabled = _statsEnabled;
|
|
53
|
+
this._instantiationService = _instantiationService;
|
|
54
|
+
this._telemetryService = _telemetryService;
|
|
55
|
+
this._randomService = _randomService;
|
|
56
|
+
this._userAttentionService = _userAttentionService;
|
|
57
|
+
this._repo = derived(this, reader => this._scm.getRepo(_doc.document.uri, reader));
|
|
58
|
+
const docWithJustReason = createDocWithJustReason(_doc.documentWithAnnotations, this._store);
|
|
59
|
+
const longtermResetSignal = observableSignal("resetSignal");
|
|
60
|
+
let longtermReason = "closed";
|
|
61
|
+
this.longtermTracker = derived(reader => {
|
|
62
|
+
if (!this._statsEnabled.read(reader)) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
longtermResetSignal.read(reader);
|
|
66
|
+
const t = reader.store.add(( new DocumentEditSourceTracker(docWithJustReason, undefined)));
|
|
67
|
+
const startFocusTime = this._userAttentionService.totalFocusTimeMs;
|
|
68
|
+
const startTime = Date.now();
|
|
69
|
+
reader.store.add(toDisposable(() => {
|
|
70
|
+
if (!t.isEmpty()) {
|
|
71
|
+
this.sendTelemetry(
|
|
72
|
+
"longterm",
|
|
73
|
+
longtermReason,
|
|
74
|
+
t,
|
|
75
|
+
this._userAttentionService.totalFocusTimeMs - startFocusTime,
|
|
76
|
+
Date.now() - startTime
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
t.dispose();
|
|
80
|
+
}));
|
|
81
|
+
return t;
|
|
82
|
+
}).recomputeInitiallyAndOnChange(this._store);
|
|
83
|
+
this._store.add(( new IntervalTimer())).cancelAndSet(() => {
|
|
84
|
+
longtermReason = "10hours";
|
|
85
|
+
longtermResetSignal.trigger(undefined);
|
|
86
|
+
longtermReason = "closed";
|
|
87
|
+
}, 10 * 60 * 60 * 1000);
|
|
88
|
+
this._store.add(autorun(reader => {
|
|
89
|
+
const repo = this._repo.read(reader);
|
|
90
|
+
if (repo) {
|
|
91
|
+
reader.store.add(runOnChange(repo.headCommitHashObs, () => {
|
|
92
|
+
longtermReason = "hashChange";
|
|
93
|
+
longtermResetSignal.trigger(undefined);
|
|
94
|
+
longtermReason = "closed";
|
|
95
|
+
}));
|
|
96
|
+
reader.store.add(runOnChange(repo.headBranchNameObs, () => {
|
|
97
|
+
longtermReason = "branchChange";
|
|
98
|
+
longtermResetSignal.trigger(undefined);
|
|
99
|
+
longtermReason = "closed";
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
}));
|
|
103
|
+
this._store.add(this._instantiationService.createInstance(
|
|
104
|
+
EditTelemetryReportInlineEditArcSender,
|
|
105
|
+
_doc.documentWithAnnotations,
|
|
106
|
+
this._repo
|
|
107
|
+
));
|
|
108
|
+
this._store.add(this._instantiationService.createInstance(
|
|
109
|
+
EditTelemetryReportEditArcForChatOrInlineChatSender,
|
|
110
|
+
_doc.documentWithAnnotations,
|
|
111
|
+
this._repo
|
|
112
|
+
));
|
|
113
|
+
this._store.add(
|
|
114
|
+
this._instantiationService.createInstance(CreateSuggestionIdForChatOrInlineChatCaller, _doc.documentWithAnnotations)
|
|
115
|
+
);
|
|
116
|
+
const resetSignal = observableSignal("resetSignal");
|
|
117
|
+
this.windowedTracker = derived(reader => {
|
|
118
|
+
if (!this._statsEnabled.read(reader)) {
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
if (!this._doc.isVisible.read(reader)) {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
resetSignal.read(reader);
|
|
125
|
+
reader.store.add(
|
|
126
|
+
this._userAttentionService.fireAfterGivenFocusTimePassed(10 * 60 * 1000, () => {
|
|
127
|
+
resetSignal.trigger(undefined);
|
|
128
|
+
})
|
|
129
|
+
);
|
|
130
|
+
const t = reader.store.add(( new DocumentEditSourceTracker(docWithJustReason, undefined)));
|
|
131
|
+
const startFocusTime = this._userAttentionService.totalFocusTimeMs;
|
|
132
|
+
const startTime = Date.now();
|
|
133
|
+
reader.store.add(toDisposable(async () => {
|
|
134
|
+
this.sendTelemetry(
|
|
135
|
+
"10minFocusWindow",
|
|
136
|
+
"time",
|
|
137
|
+
t,
|
|
138
|
+
this._userAttentionService.totalFocusTimeMs - startFocusTime,
|
|
139
|
+
Date.now() - startTime
|
|
140
|
+
);
|
|
141
|
+
t.dispose();
|
|
142
|
+
}));
|
|
143
|
+
return t;
|
|
144
|
+
}).recomputeInitiallyAndOnChange(this._store);
|
|
145
|
+
const focusResetSignal = observableSignal("focusResetSignal");
|
|
146
|
+
this.windowedFocusTracker = derived(reader => {
|
|
147
|
+
if (!this._statsEnabled.read(reader)) {
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
if (!this._doc.isVisible.read(reader)) {
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
focusResetSignal.read(reader);
|
|
154
|
+
reader.store.add(
|
|
155
|
+
this._userAttentionService.fireAfterGivenFocusTimePassed(20 * 60 * 1000, () => {
|
|
156
|
+
focusResetSignal.trigger(undefined);
|
|
157
|
+
})
|
|
158
|
+
);
|
|
159
|
+
const t = reader.store.add(( new DocumentEditSourceTracker(docWithJustReason, undefined)));
|
|
160
|
+
const startFocusTime = this._userAttentionService.totalFocusTimeMs;
|
|
161
|
+
const startTime = Date.now();
|
|
162
|
+
reader.store.add(toDisposable(async () => {
|
|
163
|
+
this.sendTelemetry(
|
|
164
|
+
"20minFocusWindow",
|
|
165
|
+
"time",
|
|
166
|
+
t,
|
|
167
|
+
this._userAttentionService.totalFocusTimeMs - startFocusTime,
|
|
168
|
+
Date.now() - startTime
|
|
169
|
+
);
|
|
170
|
+
t.dispose();
|
|
171
|
+
}));
|
|
172
|
+
return t;
|
|
173
|
+
}).recomputeInitiallyAndOnChange(this._store);
|
|
174
|
+
}
|
|
175
|
+
async sendTelemetry(mode, trigger, t, focusTime, actualTime) {
|
|
176
|
+
const ranges = t.getTrackedRanges();
|
|
177
|
+
const keys = t.getAllKeys();
|
|
178
|
+
if (keys.length === 0) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const data = this.getTelemetryData(ranges);
|
|
182
|
+
const statsUuid = this._randomService.generateUuid();
|
|
183
|
+
const sums = sumByCategory(ranges, r => r.range.length, r => r.sourceKey);
|
|
184
|
+
const entries = Object.entries(sums).filter(([key, value]) => value !== undefined);
|
|
185
|
+
entries.sort(reverseOrder(compareBy(([key, value]) => value, numberComparator)));
|
|
186
|
+
entries.length = mode === "longterm" ? 30 : 10;
|
|
187
|
+
for (const key of keys) {
|
|
188
|
+
if (!sums[key]) {
|
|
189
|
+
sums[key] = 0;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
for (const [key, value] of Object.entries(sums)) {
|
|
193
|
+
if (value === undefined) {
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
const repr = t.getRepresentative(key);
|
|
197
|
+
const deltaModifiedCount = t.getTotalInsertedCharactersCount(key);
|
|
198
|
+
this._telemetryService.publicLog2("editTelemetry.editSources.details", {
|
|
199
|
+
mode,
|
|
200
|
+
sourceKey: key,
|
|
201
|
+
sourceKeyCleaned: repr.toKey(1, {
|
|
202
|
+
$extensionId: false,
|
|
203
|
+
$extensionVersion: false,
|
|
204
|
+
$modelId: false
|
|
205
|
+
}),
|
|
206
|
+
extensionId: repr.props.$extensionId,
|
|
207
|
+
extensionVersion: repr.props.$extensionVersion,
|
|
208
|
+
modelId: repr.props.$modelId,
|
|
209
|
+
trigger,
|
|
210
|
+
languageId: this._doc.document.languageId.get(),
|
|
211
|
+
statsUuid: statsUuid,
|
|
212
|
+
conversationId: repr.props.$$sessionId,
|
|
213
|
+
requestId: repr.props.$$requestId,
|
|
214
|
+
modifiedCount: value,
|
|
215
|
+
deltaModifiedCount: deltaModifiedCount,
|
|
216
|
+
totalModifiedCount: data.totalModifiedCharactersInFinalState
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
const isTrackedByGit = await data.isTrackedByGit;
|
|
220
|
+
this._telemetryService.publicLog2("editTelemetry.editSources.stats", {
|
|
221
|
+
mode,
|
|
222
|
+
languageId: this._doc.document.languageId.get(),
|
|
223
|
+
statsUuid: statsUuid,
|
|
224
|
+
nesModifiedCount: data.nesModifiedCount,
|
|
225
|
+
inlineCompletionsCopilotModifiedCount: data.inlineCompletionsCopilotModifiedCount,
|
|
226
|
+
inlineCompletionsNESModifiedCount: data.inlineCompletionsNESModifiedCount,
|
|
227
|
+
otherAIModifiedCount: data.otherAIModifiedCount,
|
|
228
|
+
unknownModifiedCount: data.unknownModifiedCount,
|
|
229
|
+
userModifiedCount: data.userModifiedCount,
|
|
230
|
+
ideModifiedCount: data.ideModifiedCount,
|
|
231
|
+
totalModifiedCharacters: data.totalModifiedCharactersInFinalState,
|
|
232
|
+
externalModifiedCount: data.externalModifiedCount,
|
|
233
|
+
isTrackedByGit: isTrackedByGit ? 1 : 0,
|
|
234
|
+
focusTime,
|
|
235
|
+
actualTime,
|
|
236
|
+
trigger
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
getTelemetryData(ranges) {
|
|
240
|
+
const getEditCategory = source => {
|
|
241
|
+
if (source.category === "ai" && source.kind === "nes") {
|
|
242
|
+
return "nes";
|
|
243
|
+
}
|
|
244
|
+
if (source.category === "ai" && source.kind === "completion" && source.extensionId === "github.copilot") {
|
|
245
|
+
return "inlineCompletionsCopilot";
|
|
246
|
+
}
|
|
247
|
+
if (source.category === "ai" && source.kind === "completion" && source.extensionId === "github.copilot-chat" && source.providerId === "completions") {
|
|
248
|
+
return "inlineCompletionsCopilot";
|
|
249
|
+
}
|
|
250
|
+
if (source.category === "ai" && source.kind === "completion" && source.extensionId === "github.copilot-chat" && source.providerId === "nes") {
|
|
251
|
+
return "inlineCompletionsNES";
|
|
252
|
+
}
|
|
253
|
+
if (source.category === "ai" && source.kind === "completion") {
|
|
254
|
+
return "inlineCompletionsOther";
|
|
255
|
+
}
|
|
256
|
+
if (source.category === "ai") {
|
|
257
|
+
return "otherAI";
|
|
258
|
+
}
|
|
259
|
+
if (source.category === "user") {
|
|
260
|
+
return "user";
|
|
261
|
+
}
|
|
262
|
+
if (source.category === "ide") {
|
|
263
|
+
return "ide";
|
|
264
|
+
}
|
|
265
|
+
if (source.category === "external") {
|
|
266
|
+
return "external";
|
|
267
|
+
}
|
|
268
|
+
if (source.category === "unknown") {
|
|
269
|
+
return "unknown";
|
|
270
|
+
}
|
|
271
|
+
return "unknown";
|
|
272
|
+
};
|
|
273
|
+
const sums = sumByCategory(ranges, r => r.range.length, r => getEditCategory(r.source));
|
|
274
|
+
const totalModifiedCharactersInFinalState = sumBy(ranges, r => r.range.length);
|
|
275
|
+
return {
|
|
276
|
+
nesModifiedCount: sums.nes ?? 0,
|
|
277
|
+
inlineCompletionsCopilotModifiedCount: sums.inlineCompletionsCopilot ?? 0,
|
|
278
|
+
inlineCompletionsNESModifiedCount: sums.inlineCompletionsNES ?? 0,
|
|
279
|
+
otherAIModifiedCount: sums.otherAI ?? 0,
|
|
280
|
+
userModifiedCount: sums.user ?? 0,
|
|
281
|
+
ideModifiedCount: sums.ide ?? 0,
|
|
282
|
+
unknownModifiedCount: sums.unknown ?? 0,
|
|
283
|
+
externalModifiedCount: sums.external ?? 0,
|
|
284
|
+
totalModifiedCharactersInFinalState,
|
|
285
|
+
languageId: this._doc.document.languageId.get(),
|
|
286
|
+
isTrackedByGit: this._repo.get()?.isIgnored(this._doc.document.uri)
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
TrackedDocumentInfo = ( __decorate([( __param(3, IInstantiationService)), ( __param(4, ITelemetryService)), ( __param(5, IRandomService)), ( __param(6, IUserAttentionService))], TrackedDocumentInfo));
|
|
291
|
+
|
|
292
|
+
export { EditSourceTrackingImpl };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
2
|
+
import { IReader } from "@codingame/monaco-vscode-api/vscode/vs/base/common/observable";
|
|
3
|
+
import { OffsetRange } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/core/ranges/offsetRange";
|
|
4
|
+
import { TextModelEditSource } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/textModelEditSource";
|
|
5
|
+
import { IDocumentWithAnnotatedEdits, EditSource } from "../helpers/documentWithAnnotatedEdits.js";
|
|
6
|
+
/**
|
|
7
|
+
* Tracks a single document.
|
|
8
|
+
*/
|
|
9
|
+
export declare class DocumentEditSourceTracker<T = void> extends Disposable {
|
|
10
|
+
private readonly _doc;
|
|
11
|
+
readonly data: T;
|
|
12
|
+
private _edits;
|
|
13
|
+
private _pendingExternalEdits;
|
|
14
|
+
private readonly _update;
|
|
15
|
+
private readonly _representativePerKey;
|
|
16
|
+
private readonly _sumAddedCharactersPerKey;
|
|
17
|
+
constructor(_doc: IDocumentWithAnnotatedEdits, data: T);
|
|
18
|
+
private _applyEdit;
|
|
19
|
+
waitForQueue(): Promise<void>;
|
|
20
|
+
getTotalInsertedCharactersCount(key: string): number;
|
|
21
|
+
getAllKeys(): string[];
|
|
22
|
+
getRepresentative(key: string): TextModelEditSource | undefined;
|
|
23
|
+
getTrackedRanges(reader?: IReader): TrackedEdit[];
|
|
24
|
+
isEmpty(): boolean;
|
|
25
|
+
_getDebugVisualization(): {
|
|
26
|
+
value: string;
|
|
27
|
+
decorations: {
|
|
28
|
+
range: number[];
|
|
29
|
+
color: string;
|
|
30
|
+
}[];
|
|
31
|
+
$fileExtension: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export declare class TrackedEdit {
|
|
35
|
+
readonly originalRange: OffsetRange;
|
|
36
|
+
readonly range: OffsetRange;
|
|
37
|
+
readonly sourceKey: string;
|
|
38
|
+
readonly source: EditSource;
|
|
39
|
+
readonly sourceRepresentative: TextModelEditSource;
|
|
40
|
+
constructor(originalRange: OffsetRange, range: OffsetRange, sourceKey: string, source: EditSource, sourceRepresentative: TextModelEditSource);
|
|
41
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
|
|
2
|
+
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
3
|
+
import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
|
|
4
|
+
import { AnnotatedStringEdit } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/edits/stringEdit';
|
|
5
|
+
import { observableSignal } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableSignal';
|
|
6
|
+
import { runOnChange } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/utils/runOnChange';
|
|
7
|
+
|
|
8
|
+
class DocumentEditSourceTracker extends Disposable {
|
|
9
|
+
constructor(_doc, data) {
|
|
10
|
+
super();
|
|
11
|
+
this._doc = _doc;
|
|
12
|
+
this.data = data;
|
|
13
|
+
this._edits = AnnotatedStringEdit.empty;
|
|
14
|
+
this._pendingExternalEdits = AnnotatedStringEdit.empty;
|
|
15
|
+
this._update = observableSignal(this);
|
|
16
|
+
this._representativePerKey = ( new Map());
|
|
17
|
+
this._sumAddedCharactersPerKey = ( new Map());
|
|
18
|
+
this._register(runOnChange(this._doc.value, (_val, _prevVal, edits) => {
|
|
19
|
+
const eComposed = AnnotatedStringEdit.compose(( edits.map(e => e.edit)));
|
|
20
|
+
if (eComposed.replacements.every(e => e.data.source.category === "external")) {
|
|
21
|
+
if (this._edits.isEmpty())
|
|
22
|
+
; else {
|
|
23
|
+
this._pendingExternalEdits = this._pendingExternalEdits.compose(eComposed);
|
|
24
|
+
}
|
|
25
|
+
} else {
|
|
26
|
+
if (!this._pendingExternalEdits.isEmpty()) {
|
|
27
|
+
this._applyEdit(this._pendingExternalEdits);
|
|
28
|
+
this._pendingExternalEdits = AnnotatedStringEdit.empty;
|
|
29
|
+
}
|
|
30
|
+
this._applyEdit(eComposed);
|
|
31
|
+
}
|
|
32
|
+
this._update.trigger(undefined);
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
_applyEdit(e) {
|
|
36
|
+
for (const r of e.replacements) {
|
|
37
|
+
let existing = this._sumAddedCharactersPerKey.get(r.data.key);
|
|
38
|
+
if (existing === undefined) {
|
|
39
|
+
existing = 0;
|
|
40
|
+
this._representativePerKey.set(r.data.key, r.data.representative);
|
|
41
|
+
}
|
|
42
|
+
const newCount = existing + r.getNewLength();
|
|
43
|
+
this._sumAddedCharactersPerKey.set(r.data.key, newCount);
|
|
44
|
+
}
|
|
45
|
+
this._edits = this._edits.compose(e);
|
|
46
|
+
}
|
|
47
|
+
async waitForQueue() {
|
|
48
|
+
await this._doc.waitForQueue();
|
|
49
|
+
}
|
|
50
|
+
getTotalInsertedCharactersCount(key) {
|
|
51
|
+
const val = this._sumAddedCharactersPerKey.get(key);
|
|
52
|
+
return val ?? 0;
|
|
53
|
+
}
|
|
54
|
+
getAllKeys() {
|
|
55
|
+
return Array.from(( this._sumAddedCharactersPerKey.keys()));
|
|
56
|
+
}
|
|
57
|
+
getRepresentative(key) {
|
|
58
|
+
return this._representativePerKey.get(key);
|
|
59
|
+
}
|
|
60
|
+
getTrackedRanges(reader) {
|
|
61
|
+
this._update.read(reader);
|
|
62
|
+
const ranges = this._edits.getNewRanges();
|
|
63
|
+
return ( ranges.map((r, idx) => {
|
|
64
|
+
const e = this._edits.replacements[idx];
|
|
65
|
+
const te = ( new TrackedEdit(e.replaceRange, r, e.data.key, e.data.source, e.data.representative));
|
|
66
|
+
return te;
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
isEmpty() {
|
|
70
|
+
return this._edits.isEmpty();
|
|
71
|
+
}
|
|
72
|
+
_getDebugVisualization() {
|
|
73
|
+
const ranges = this.getTrackedRanges();
|
|
74
|
+
const txt = this._doc.value.get().value;
|
|
75
|
+
return {
|
|
76
|
+
...{
|
|
77
|
+
$fileExtension: "text.w"
|
|
78
|
+
},
|
|
79
|
+
"value": txt,
|
|
80
|
+
"decorations": ( ranges.map(r => {
|
|
81
|
+
return {
|
|
82
|
+
range: [r.range.start, r.range.endExclusive],
|
|
83
|
+
color: r.source.getColor()
|
|
84
|
+
};
|
|
85
|
+
}))
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
class TrackedEdit {
|
|
90
|
+
constructor(originalRange, range, sourceKey, source, sourceRepresentative) {
|
|
91
|
+
this.originalRange = originalRange;
|
|
92
|
+
this.range = range;
|
|
93
|
+
this.sourceKey = sourceKey;
|
|
94
|
+
this.source = source;
|
|
95
|
+
this.sourceRepresentative = sourceRepresentative;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export { DocumentEditSourceTracker, TrackedEdit };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IReader, IObservable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/observable";
|
|
2
|
+
import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
|
|
3
|
+
import { ISCMRepository } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/scm/common/scm";
|
|
4
|
+
import { ISCMService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/scm/common/scm.service";
|
|
5
|
+
export declare class ScmAdapter {
|
|
6
|
+
private readonly _scmService;
|
|
7
|
+
private readonly _repos;
|
|
8
|
+
private readonly _reposChangedSignal;
|
|
9
|
+
constructor(_scmService: ISCMService);
|
|
10
|
+
getRepo(uri: URI, reader: IReader | undefined): ScmRepoAdapter | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare class ScmRepoAdapter {
|
|
13
|
+
private readonly _repo;
|
|
14
|
+
readonly headBranchNameObs: IObservable<string | undefined>;
|
|
15
|
+
readonly headCommitHashObs: IObservable<string | undefined>;
|
|
16
|
+
constructor(_repo: ISCMRepository);
|
|
17
|
+
isIgnored(uri: URI): Promise<boolean>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { WeakCachedFunction } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cache';
|
|
4
|
+
import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
5
|
+
import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
|
|
6
|
+
import { ISCMService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/scm/common/scm.service';
|
|
7
|
+
import { observableSignalFromEvent } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableSignalFromEvent';
|
|
8
|
+
import { derived } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/derived';
|
|
9
|
+
|
|
10
|
+
let ScmAdapter = class ScmAdapter {
|
|
11
|
+
constructor(_scmService) {
|
|
12
|
+
this._scmService = _scmService;
|
|
13
|
+
this._repos = ( new WeakCachedFunction(repo => ( new ScmRepoAdapter(repo))));
|
|
14
|
+
this._reposChangedSignal = observableSignalFromEvent(this, Event.any(
|
|
15
|
+
this._scmService.onDidAddRepository,
|
|
16
|
+
this._scmService.onDidRemoveRepository
|
|
17
|
+
));
|
|
18
|
+
}
|
|
19
|
+
getRepo(uri, reader) {
|
|
20
|
+
this._reposChangedSignal.read(reader);
|
|
21
|
+
const repo = this._scmService.getRepository(uri);
|
|
22
|
+
if (!repo) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
return this._repos.get(repo);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
ScmAdapter = ( __decorate([( __param(0, ISCMService))], ScmAdapter));
|
|
29
|
+
class ScmRepoAdapter {
|
|
30
|
+
constructor(_repo) {
|
|
31
|
+
this._repo = _repo;
|
|
32
|
+
this.headBranchNameObs = derived(
|
|
33
|
+
reader => this._repo.provider.historyProvider.read(reader)?.historyItemRef.read(reader)?.name
|
|
34
|
+
);
|
|
35
|
+
this.headCommitHashObs = derived(
|
|
36
|
+
reader => this._repo.provider.historyProvider.read(reader)?.historyItemRef.read(reader)?.revision
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
async isIgnored(uri) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { ScmAdapter, ScmRepoAdapter };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BaseStringEdit, IEditData } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/core/edits/stringEdit";
|
|
2
|
+
import { AbstractText } from "@codingame/monaco-vscode-api/vscode/vs/editor/common/core/text/abstractText";
|
|
3
|
+
/**
|
|
4
|
+
* The ARC (accepted and retained characters) counts how many characters inserted by the initial suggestion (trackedEdit)
|
|
5
|
+
* stay unmodified after a certain amount of time after acceptance.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ArcTracker {
|
|
8
|
+
private readonly _valueBeforeTrackedEdit;
|
|
9
|
+
private _updatedTrackedEdit;
|
|
10
|
+
private _trackedEdit;
|
|
11
|
+
constructor(_valueBeforeTrackedEdit: AbstractText, trackedEdit: BaseStringEdit);
|
|
12
|
+
getOriginalCharacterCount(): number;
|
|
13
|
+
/**
|
|
14
|
+
* edit must apply to _updatedTrackedEdit.apply(_valueBeforeTrackedEdit)
|
|
15
|
+
*/
|
|
16
|
+
handleEdits(edit: BaseStringEdit): void;
|
|
17
|
+
getAcceptedRestrainedCharactersCount(): number;
|
|
18
|
+
getDebugState(): unknown;
|
|
19
|
+
getLineCountInfo(): {
|
|
20
|
+
deletedLineCounts: number;
|
|
21
|
+
insertedLineCounts: number;
|
|
22
|
+
};
|
|
23
|
+
getValues(): unknown;
|
|
24
|
+
}
|
|
25
|
+
export declare class IsTrackedEditData implements IEditData<IsTrackedEditData> {
|
|
26
|
+
readonly isTrackedEdit: boolean;
|
|
27
|
+
constructor(isTrackedEdit: boolean);
|
|
28
|
+
join(data: IsTrackedEditData): IsTrackedEditData | undefined;
|
|
29
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
|
|
2
|
+
import { sumBy } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
|
|
3
|
+
import { LineEdit } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/edits/lineEdit';
|
|
4
|
+
|
|
5
|
+
class ArcTracker {
|
|
6
|
+
constructor(_valueBeforeTrackedEdit, trackedEdit) {
|
|
7
|
+
this._valueBeforeTrackedEdit = _valueBeforeTrackedEdit;
|
|
8
|
+
this._trackedEdit = trackedEdit.removeCommonSuffixPrefix(_valueBeforeTrackedEdit.getValue());
|
|
9
|
+
this._updatedTrackedEdit = this._trackedEdit.mapData(() => ( new IsTrackedEditData(true)));
|
|
10
|
+
}
|
|
11
|
+
getOriginalCharacterCount() {
|
|
12
|
+
return sumBy(this._trackedEdit.replacements, e => e.getNewLength());
|
|
13
|
+
}
|
|
14
|
+
handleEdits(edit) {
|
|
15
|
+
const e = edit.mapData(_d => ( new IsTrackedEditData(false)));
|
|
16
|
+
const composedEdit = this._updatedTrackedEdit.compose(e);
|
|
17
|
+
this._updatedTrackedEdit = composedEdit;
|
|
18
|
+
}
|
|
19
|
+
getAcceptedRestrainedCharactersCount() {
|
|
20
|
+
const s = sumBy(
|
|
21
|
+
this._updatedTrackedEdit.replacements,
|
|
22
|
+
e => e.data.isTrackedEdit ? e.getNewLength() : 0
|
|
23
|
+
);
|
|
24
|
+
return s;
|
|
25
|
+
}
|
|
26
|
+
getDebugState() {
|
|
27
|
+
return {
|
|
28
|
+
edits: ( this._updatedTrackedEdit.replacements.map(e => ({
|
|
29
|
+
range: ( e.replaceRange.toString()),
|
|
30
|
+
newText: e.newText,
|
|
31
|
+
isTrackedEdit: e.data.isTrackedEdit
|
|
32
|
+
})))
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
getLineCountInfo() {
|
|
36
|
+
const e = this._updatedTrackedEdit.toStringEdit(r => r.data.isTrackedEdit);
|
|
37
|
+
const le = LineEdit.fromStringEdit(e, this._valueBeforeTrackedEdit);
|
|
38
|
+
const deletedLineCount = sumBy(le.replacements, r => r.lineRange.length);
|
|
39
|
+
const insertedLineCount = sumBy(le.getNewLineRanges(), r => r.length);
|
|
40
|
+
return {
|
|
41
|
+
deletedLineCounts: deletedLineCount,
|
|
42
|
+
insertedLineCounts: insertedLineCount
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
getValues() {
|
|
46
|
+
return {
|
|
47
|
+
arc: this.getAcceptedRestrainedCharactersCount(),
|
|
48
|
+
...this.getLineCountInfo()
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
class IsTrackedEditData {
|
|
53
|
+
constructor(isTrackedEdit) {
|
|
54
|
+
this.isTrackedEdit = isTrackedEdit;
|
|
55
|
+
}
|
|
56
|
+
join(data) {
|
|
57
|
+
if (this.isTrackedEdit !== data.isTrackedEdit) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { ArcTracker, IsTrackedEditData };
|
|
@@ -176,7 +176,7 @@ let TelemetryContribution = class TelemetryContribution extends Disposable {
|
|
|
176
176
|
constructor() {
|
|
177
177
|
super({
|
|
178
178
|
id: "workbench.action.showTelemetry",
|
|
179
|
-
title: ( localize2(
|
|
179
|
+
title: ( localize2(13906, "Show Telemetry")),
|
|
180
180
|
category: Categories.Developer,
|
|
181
181
|
f1: true
|
|
182
182
|
});
|