@sourcegraph/cody-web 0.5.1 → 0.6.1
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/dist/{agent.worker-CHrb4rcq.js → agent.worker-DVKzbHSN.mjs} +3330 -8643
- package/dist/agent.worker.js +2 -3
- package/dist/{cl100k_base-BgU9RXdk.js → cl100k_base-B4kyDDRQ.mjs} +3 -3
- package/dist/demo/App.d.ts.map +1 -1
- package/dist/{git-log-Bn_F1p4S.js → git-log-D98vF6zD.mjs} +10 -10
- package/dist/{index-ZysJUhSy.js → index-AVrhN4Ic.mjs} +74 -74
- package/dist/index.js +3169 -3087
- package/dist/lib/components/CodyWebPanel.d.ts.map +1 -1
- package/dist/lib/components/CodyWebPanelProvider.d.ts.map +1 -1
- package/dist/lib/types.d.ts +5 -4
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/shell-C6EMKtG-.mjs +47 -0
- package/dist/style.css +11 -4
- package/dist/{time-date-C7nUVQ0Y.js → time-date-5mt-Pcg3.mjs} +10612 -3909
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/shell-DFgpuMKe.js +0 -47
package/dist/demo/App.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../demo/App.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAW/B,OAAO,2CAA2C,CAAA;
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../demo/App.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAW/B,OAAO,2CAA2C,CAAA;AA+BlD,eAAO,MAAM,GAAG,EAAE,EAcjB,CAAA"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const agent_worker = require("./agent.worker-CHrb4rcq.js");
|
|
4
|
-
const timeDate = require("./time-date-C7nUVQ0Y.js");
|
|
1
|
+
import { p as path, U as Uri, s as spawn } from "./agent.worker-DVKzbHSN.mjs";
|
|
2
|
+
import { w as wrapInActiveSpan, C as ContextItemSource } from "./time-date-5mt-Pcg3.mjs";
|
|
5
3
|
async function getContextFileFromGitLog(file, options) {
|
|
6
|
-
return
|
|
7
|
-
const cwd =
|
|
4
|
+
return wrapInActiveSpan("commands.context.git-log", async (span) => {
|
|
5
|
+
const cwd = path.dirname(file.fsPath);
|
|
8
6
|
const args = ["log", `-L:${options.funcname}:${file.fsPath}`, `--max-count=${options.maxCount}`];
|
|
9
7
|
const result = await spawnAsync("git", args, { cwd });
|
|
10
8
|
if (result.code !== 0) {
|
|
@@ -18,14 +16,14 @@ async function getContextFileFromGitLog(file, options) {
|
|
|
18
16
|
type: "file",
|
|
19
17
|
content: result.stdout,
|
|
20
18
|
title: "Terminal Output",
|
|
21
|
-
uri:
|
|
22
|
-
source:
|
|
19
|
+
uri: Uri.file("terminal-output"),
|
|
20
|
+
source: ContextItemSource.History
|
|
23
21
|
}
|
|
24
22
|
];
|
|
25
23
|
});
|
|
26
24
|
}
|
|
27
25
|
async function spawnAsync(command, args, opts) {
|
|
28
|
-
const childProcess =
|
|
26
|
+
const childProcess = spawn();
|
|
29
27
|
let stdout = "";
|
|
30
28
|
let stderr = "";
|
|
31
29
|
childProcess.stdout.on("data", (data) => {
|
|
@@ -51,4 +49,6 @@ async function spawnAsync(command, args, opts) {
|
|
|
51
49
|
code
|
|
52
50
|
};
|
|
53
51
|
}
|
|
54
|
-
|
|
52
|
+
export {
|
|
53
|
+
getContextFileFromGitLog
|
|
54
|
+
};
|
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const timeDate = require("./time-date-C7nUVQ0Y.js");
|
|
4
|
+
import { U as Uri, P as Position, R as Range, w as window, D as DiagnosticSeverity, b as workspace, c as updateRangeMultipleChanges, d as commands, f as executeEdit, T as TERMINAL_EDIT_STATES, g as ThemeColor, h as languages, C as CodeLens, i as setTutorialUri, j as logSidebarClick, k as Disposable } from "./agent.worker-DVKzbHSN.mjs";
|
|
5
|
+
import { t as telemetryRecorder, p as ps, d as dedent } from "./time-date-5mt-Pcg3.mjs";
|
|
8
6
|
const EMOJI_SVG_TEMPLATE = `<svg width="32" height="32" xmlns="http://www.w3.org/2000/svg">
|
|
9
7
|
<text x="50%" y="50%" dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="24px">{emoji}</text>
|
|
10
8
|
</svg>`;
|
|
11
9
|
const transformEmojiToSvg = (emoji) => {
|
|
12
10
|
const svg = EMOJI_SVG_TEMPLATE.replace("{emoji}", emoji);
|
|
13
11
|
const uri = "data:image/svg+xml;base64," + Buffer.from(svg).toString("base64");
|
|
14
|
-
return
|
|
12
|
+
return Uri.parse(uri);
|
|
15
13
|
};
|
|
16
14
|
function findRangeOfText(document, searchText) {
|
|
17
15
|
for (let line = 0; line < document.lineCount; line++) {
|
|
18
16
|
const lineText = document.lineAt(line);
|
|
19
17
|
const indexOfText = lineText.text.indexOf(searchText);
|
|
20
18
|
if (indexOfText >= 0) {
|
|
21
|
-
const start = new
|
|
22
|
-
const end = new
|
|
23
|
-
return new
|
|
19
|
+
const start = new Position(line, indexOfText);
|
|
20
|
+
const end = new Position(line, indexOfText + searchText.length);
|
|
21
|
+
return new Range(start, end);
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
24
|
return null;
|
|
@@ -29,7 +27,7 @@ const TUTORIAL_EMOJIS = {
|
|
|
29
27
|
Todo: "👉"
|
|
30
28
|
// 👉
|
|
31
29
|
};
|
|
32
|
-
const TODO_DECORATION =
|
|
30
|
+
const TODO_DECORATION = window.createTextEditorDecorationType({
|
|
33
31
|
gutterIconPath: transformEmojiToSvg(TUTORIAL_EMOJIS.Todo),
|
|
34
32
|
gutterIconSize: "contain"
|
|
35
33
|
});
|
|
@@ -41,41 +39,41 @@ const setFixDiagnostic = (collection, uri, range) => {
|
|
|
41
39
|
{
|
|
42
40
|
range,
|
|
43
41
|
message: "Python: Implicit string concatenation not allowed",
|
|
44
|
-
severity:
|
|
42
|
+
severity: DiagnosticSeverity.Error
|
|
45
43
|
}
|
|
46
44
|
]);
|
|
47
45
|
};
|
|
48
46
|
const registerEditTutorialCommand = (editor, onComplete, range) => {
|
|
49
47
|
let trackedRange = range;
|
|
50
|
-
const rangeTracker =
|
|
48
|
+
const rangeTracker = workspace.onDidChangeTextDocument((event) => {
|
|
51
49
|
if (event.document !== editor.document) {
|
|
52
50
|
return;
|
|
53
51
|
}
|
|
54
52
|
const changes = new Array(...event.contentChanges);
|
|
55
|
-
const updatedRange =
|
|
53
|
+
const updatedRange = updateRangeMultipleChanges(trackedRange, changes);
|
|
56
54
|
if (!updatedRange.isEqual(trackedRange)) {
|
|
57
55
|
trackedRange = updatedRange;
|
|
58
56
|
}
|
|
59
57
|
});
|
|
60
|
-
const editCommand =
|
|
58
|
+
const editCommand = commands.registerCommand(
|
|
61
59
|
"cody.tutorial.edit",
|
|
62
60
|
async (_document, source = "editor") => {
|
|
63
|
-
|
|
61
|
+
telemetryRecorder.recordEvent("cody.interactiveTutorial", "edit", {
|
|
64
62
|
privateMetadata: { source }
|
|
65
63
|
});
|
|
66
64
|
editor.setDecorations(TODO_DECORATION, []);
|
|
67
|
-
const task = await
|
|
65
|
+
const task = await executeEdit({
|
|
68
66
|
configuration: {
|
|
69
67
|
document: editor.document,
|
|
70
68
|
range: trackedRange,
|
|
71
|
-
preInstruction:
|
|
69
|
+
preInstruction: ps`Function that finds logs in a dir`
|
|
72
70
|
}
|
|
73
71
|
});
|
|
74
72
|
if (!task) {
|
|
75
73
|
return;
|
|
76
74
|
}
|
|
77
75
|
const interval = setInterval(async () => {
|
|
78
|
-
if (
|
|
76
|
+
if (TERMINAL_EDIT_STATES.includes(task.state)) {
|
|
79
77
|
clearInterval(interval);
|
|
80
78
|
onComplete();
|
|
81
79
|
}
|
|
@@ -85,20 +83,20 @@ const registerEditTutorialCommand = (editor, onComplete, range) => {
|
|
|
85
83
|
return [rangeTracker, editCommand];
|
|
86
84
|
};
|
|
87
85
|
const registerChatTutorialCommand = (onComplete) => {
|
|
88
|
-
const disposable =
|
|
86
|
+
const disposable = commands.registerCommand(
|
|
89
87
|
"cody.tutorial.chat",
|
|
90
88
|
async (_document, source = "editor") => {
|
|
91
|
-
|
|
89
|
+
telemetryRecorder.recordEvent("cody.interactiveTutorial", "chat", {
|
|
92
90
|
privateMetadata: { source }
|
|
93
91
|
});
|
|
94
|
-
await
|
|
92
|
+
await commands.executeCommand("cody.chat.newEditorPanel");
|
|
95
93
|
onComplete();
|
|
96
94
|
}
|
|
97
95
|
);
|
|
98
96
|
return disposable;
|
|
99
97
|
};
|
|
100
98
|
const registerAutocompleteListener = (editor, activeStep) => {
|
|
101
|
-
const disposable =
|
|
99
|
+
const disposable = window.onDidChangeTextEditorSelection(async ({ textEditor }) => {
|
|
102
100
|
const document = textEditor.document;
|
|
103
101
|
if (document.uri !== editor.document.uri) {
|
|
104
102
|
return;
|
|
@@ -110,7 +108,7 @@ const registerAutocompleteListener = (editor, activeStep) => {
|
|
|
110
108
|
return;
|
|
111
109
|
}
|
|
112
110
|
if (activeStep.range.contains(textEditor.selection.active) && document.getText(activeStep.range).trim() === activeStep.originalText) {
|
|
113
|
-
await
|
|
111
|
+
await commands.executeCommand("cody.autocomplete.manual-trigger");
|
|
114
112
|
}
|
|
115
113
|
});
|
|
116
114
|
return disposable;
|
|
@@ -120,7 +118,7 @@ const getStepContent = (step) => {
|
|
|
120
118
|
let stepContent = "";
|
|
121
119
|
switch (step) {
|
|
122
120
|
case "autocomplete":
|
|
123
|
-
stepContent =
|
|
121
|
+
stepContent = dedent`
|
|
124
122
|
### Welcome to Cody!
|
|
125
123
|
"""
|
|
126
124
|
Learn how to use Cody to write, edit and fix code by completing the 4 tasks below.
|
|
@@ -138,7 +136,7 @@ const getStepContent = (step) => {
|
|
|
138
136
|
`;
|
|
139
137
|
break;
|
|
140
138
|
case "edit":
|
|
141
|
-
stepContent =
|
|
139
|
+
stepContent = dedent`
|
|
142
140
|
\n\n
|
|
143
141
|
### Task 2 of 4: Edit Code with instructions
|
|
144
142
|
"""
|
|
@@ -150,7 +148,7 @@ const getStepContent = (step) => {
|
|
|
150
148
|
`;
|
|
151
149
|
break;
|
|
152
150
|
case "fix":
|
|
153
|
-
stepContent =
|
|
151
|
+
stepContent = dedent`
|
|
154
152
|
\n\n
|
|
155
153
|
### Task 3 of 4: Ask Cody to Fix
|
|
156
154
|
"""
|
|
@@ -163,7 +161,7 @@ const getStepContent = (step) => {
|
|
|
163
161
|
`;
|
|
164
162
|
break;
|
|
165
163
|
case "chat":
|
|
166
|
-
stepContent =
|
|
164
|
+
stepContent = dedent`
|
|
167
165
|
\n\n
|
|
168
166
|
### Task 4 of 4: Start a chat
|
|
169
167
|
#
|
|
@@ -179,9 +177,9 @@ const getStepData = (document, step) => {
|
|
|
179
177
|
if (!triggerText) {
|
|
180
178
|
return null;
|
|
181
179
|
}
|
|
182
|
-
const autocompleteRange = new
|
|
183
|
-
new
|
|
184
|
-
new
|
|
180
|
+
const autocompleteRange = new Range(
|
|
181
|
+
new Position(triggerText.start.line - 1, 0),
|
|
182
|
+
new Position(triggerText.start.line - 1, Number.MAX_SAFE_INTEGER)
|
|
185
183
|
);
|
|
186
184
|
return {
|
|
187
185
|
key: "autocomplete",
|
|
@@ -198,9 +196,9 @@ const getStepData = (document, step) => {
|
|
|
198
196
|
const editLine = triggerText.start.line - 1;
|
|
199
197
|
return {
|
|
200
198
|
key: "edit",
|
|
201
|
-
range: new
|
|
202
|
-
new
|
|
203
|
-
new
|
|
199
|
+
range: new Range(
|
|
200
|
+
new Position(editLine, 0),
|
|
201
|
+
new Position(editLine, Number.MAX_SAFE_INTEGER)
|
|
204
202
|
),
|
|
205
203
|
type: "manual"
|
|
206
204
|
};
|
|
@@ -211,9 +209,9 @@ const getStepData = (document, step) => {
|
|
|
211
209
|
return null;
|
|
212
210
|
}
|
|
213
211
|
const fixLine = triggerText.start.line - 1;
|
|
214
|
-
const fixRange = new
|
|
215
|
-
new
|
|
216
|
-
new
|
|
212
|
+
const fixRange = new Range(
|
|
213
|
+
new Position(fixLine, document.lineAt(fixLine).firstNonWhitespaceCharacterIndex),
|
|
214
|
+
new Position(fixLine, Number.MAX_SAFE_INTEGER)
|
|
217
215
|
);
|
|
218
216
|
return {
|
|
219
217
|
key: "fix",
|
|
@@ -230,9 +228,9 @@ const getStepData = (document, step) => {
|
|
|
230
228
|
const chatLine = triggerText.start.line;
|
|
231
229
|
return {
|
|
232
230
|
key: "chat",
|
|
233
|
-
range: new
|
|
234
|
-
new
|
|
235
|
-
new
|
|
231
|
+
range: new Range(
|
|
232
|
+
new Position(chatLine, 0),
|
|
233
|
+
new Position(chatLine, Number.MAX_SAFE_INTEGER)
|
|
236
234
|
),
|
|
237
235
|
type: "manual"
|
|
238
236
|
};
|
|
@@ -253,12 +251,12 @@ const getNextStep = (step) => {
|
|
|
253
251
|
};
|
|
254
252
|
const initTutorialDocument = async (uri) => {
|
|
255
253
|
const firstStep = getStepContent("autocomplete");
|
|
256
|
-
await
|
|
257
|
-
return
|
|
254
|
+
await workspace.fs.writeFile(uri, Buffer.from(firstStep));
|
|
255
|
+
return workspace.openTextDocument(uri);
|
|
258
256
|
};
|
|
259
257
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
260
258
|
const resetDocument = async (uri) => {
|
|
261
|
-
await
|
|
259
|
+
await commands.executeCommand("workbench.action.closeActiveEditor", uri);
|
|
262
260
|
await sleep(250);
|
|
263
261
|
return initTutorialDocument(uri);
|
|
264
262
|
};
|
|
@@ -277,7 +275,7 @@ class TutorialLinkProvider {
|
|
|
277
275
|
links.push(
|
|
278
276
|
new (void 0)(
|
|
279
277
|
editRange,
|
|
280
|
-
|
|
278
|
+
Uri.parse(
|
|
281
279
|
`command:cody.tutorial.edit?${encodeURIComponent(JSON.stringify(params))}`
|
|
282
280
|
)
|
|
283
281
|
)
|
|
@@ -289,14 +287,14 @@ class TutorialLinkProvider {
|
|
|
289
287
|
links.push(
|
|
290
288
|
new (void 0)(
|
|
291
289
|
chatRange,
|
|
292
|
-
|
|
290
|
+
Uri.parse(
|
|
293
291
|
`command:cody.tutorial.chat?${encodeURIComponent(JSON.stringify(params))}`
|
|
294
292
|
)
|
|
295
293
|
)
|
|
296
294
|
);
|
|
297
295
|
}
|
|
298
|
-
const linkDecoration =
|
|
299
|
-
color: new
|
|
296
|
+
const linkDecoration = window.createTextEditorDecorationType({
|
|
297
|
+
color: new ThemeColor("textLink.activeForeground")
|
|
300
298
|
});
|
|
301
299
|
this.editor.setDecorations(linkDecoration, links);
|
|
302
300
|
return links;
|
|
@@ -306,11 +304,11 @@ class ResetLensProvider {
|
|
|
306
304
|
constructor(editor) {
|
|
307
305
|
__publicField(this, "disposables", []);
|
|
308
306
|
this.editor = editor;
|
|
309
|
-
this.disposables.push(
|
|
307
|
+
this.disposables.push(languages.registerCodeLensProvider(editor.document.uri, this));
|
|
310
308
|
}
|
|
311
309
|
provideCodeLenses(document) {
|
|
312
310
|
return [
|
|
313
|
-
new
|
|
311
|
+
new CodeLens(new Range(0, 0, 0, 0), {
|
|
314
312
|
title: "Reset Tutorial",
|
|
315
313
|
command: "cody.tutorial.reset"
|
|
316
314
|
})
|
|
@@ -325,16 +323,16 @@ class ResetLensProvider {
|
|
|
325
323
|
}
|
|
326
324
|
const startTutorial = async (document) => {
|
|
327
325
|
const disposables = [];
|
|
328
|
-
const editor = await
|
|
329
|
-
const diagnosticCollection =
|
|
326
|
+
const editor = await window.showTextDocument(document);
|
|
327
|
+
const diagnosticCollection = languages.createDiagnosticCollection("codyTutorial");
|
|
330
328
|
disposables.push(diagnosticCollection);
|
|
331
|
-
|
|
329
|
+
telemetryRecorder.recordEvent("cody.interactiveTutorial", "started");
|
|
332
330
|
let activeStep = null;
|
|
333
331
|
let activeRangeListener;
|
|
334
332
|
let successListener;
|
|
335
333
|
const setActiveRangeListener = (range) => {
|
|
336
334
|
activeRangeListener == null ? void 0 : activeRangeListener.dispose();
|
|
337
|
-
activeRangeListener =
|
|
335
|
+
activeRangeListener = workspace.onDidChangeTextDocument((event) => {
|
|
338
336
|
if (event.document.uri !== editor.document.uri) {
|
|
339
337
|
return;
|
|
340
338
|
}
|
|
@@ -342,7 +340,7 @@ const startTutorial = async (document) => {
|
|
|
342
340
|
return;
|
|
343
341
|
}
|
|
344
342
|
const changes = new Array(...event.contentChanges);
|
|
345
|
-
const newInteractiveRange =
|
|
343
|
+
const newInteractiveRange = updateRangeMultipleChanges(range, changes);
|
|
346
344
|
if (!newInteractiveRange.isEqual(range)) {
|
|
347
345
|
activeStep.range = newInteractiveRange;
|
|
348
346
|
}
|
|
@@ -352,11 +350,11 @@ const startTutorial = async (document) => {
|
|
|
352
350
|
const progressToNextStep = async () => {
|
|
353
351
|
const nextStep = (activeStep == null ? void 0 : activeStep.key) ? getNextStep(activeStep.key) : "autocomplete";
|
|
354
352
|
if (activeStep == null ? void 0 : activeStep.key) {
|
|
355
|
-
|
|
353
|
+
telemetryRecorder.recordEvent("cody.interactiveTutorial.stepComplete", activeStep.key);
|
|
356
354
|
}
|
|
357
355
|
if (nextStep === null) {
|
|
358
356
|
editor.setDecorations(TODO_DECORATION, []);
|
|
359
|
-
|
|
357
|
+
telemetryRecorder.recordEvent("cody.interactiveTutorial", "finished");
|
|
360
358
|
return;
|
|
361
359
|
}
|
|
362
360
|
switch (activeStep == null ? void 0 : activeStep.key) {
|
|
@@ -372,7 +370,7 @@ const startTutorial = async (document) => {
|
|
|
372
370
|
if (needsInsertion) {
|
|
373
371
|
const content = getStepContent(nextStep);
|
|
374
372
|
await editor.edit((editBuilder) => {
|
|
375
|
-
editBuilder.insert(new
|
|
373
|
+
editBuilder.insert(new Position(editor.document.lineCount, 0), content);
|
|
376
374
|
});
|
|
377
375
|
}
|
|
378
376
|
editor.document.save();
|
|
@@ -401,7 +399,7 @@ const startTutorial = async (document) => {
|
|
|
401
399
|
};
|
|
402
400
|
const startListeningForSuccess = (key) => {
|
|
403
401
|
successListener == null ? void 0 : successListener.dispose();
|
|
404
|
-
successListener =
|
|
402
|
+
successListener = workspace.onDidChangeTextDocument(async ({ document: document2 }) => {
|
|
405
403
|
if (document2.uri !== editor.document.uri) {
|
|
406
404
|
return;
|
|
407
405
|
}
|
|
@@ -423,11 +421,11 @@ const startTutorial = async (document) => {
|
|
|
423
421
|
disposables.push(
|
|
424
422
|
startListeningForSuccess("autocomplete"),
|
|
425
423
|
new ResetLensProvider(editor),
|
|
426
|
-
|
|
424
|
+
languages.registerDocumentLinkProvider(
|
|
427
425
|
editor.document.uri,
|
|
428
426
|
new TutorialLinkProvider(editor)
|
|
429
427
|
),
|
|
430
|
-
|
|
428
|
+
window.onDidChangeVisibleTextEditors((editors) => {
|
|
431
429
|
const tutorialIsActive = editors.find(
|
|
432
430
|
(editor2) => editor2.document.uri.toString() === document.uri.toString()
|
|
433
431
|
);
|
|
@@ -437,7 +435,7 @@ const startTutorial = async (document) => {
|
|
|
437
435
|
editor.setDecorations(TODO_DECORATION, [activeStep.range]);
|
|
438
436
|
})
|
|
439
437
|
);
|
|
440
|
-
return new
|
|
438
|
+
return new Disposable(() => {
|
|
441
439
|
for (const disposable of disposables) {
|
|
442
440
|
disposable.dispose();
|
|
443
441
|
}
|
|
@@ -446,7 +444,7 @@ const startTutorial = async (document) => {
|
|
|
446
444
|
};
|
|
447
445
|
const registerInteractiveTutorial = async (context) => {
|
|
448
446
|
const disposables = [];
|
|
449
|
-
const documentUri =
|
|
447
|
+
const documentUri = setTutorialUri(context);
|
|
450
448
|
let document = await initTutorialDocument(documentUri);
|
|
451
449
|
let status = "stopped";
|
|
452
450
|
let cleanup;
|
|
@@ -461,7 +459,7 @@ const registerInteractiveTutorial = async (context) => {
|
|
|
461
459
|
status = "stopped";
|
|
462
460
|
};
|
|
463
461
|
disposables.push(
|
|
464
|
-
|
|
462
|
+
window.onDidChangeVisibleTextEditors((editors) => {
|
|
465
463
|
const tutorialIsVisible = editors.find(
|
|
466
464
|
(editor) => editor.document.uri.toString() === documentUri.toString()
|
|
467
465
|
);
|
|
@@ -476,34 +474,34 @@ const registerInteractiveTutorial = async (context) => {
|
|
|
476
474
|
}
|
|
477
475
|
return;
|
|
478
476
|
}),
|
|
479
|
-
|
|
477
|
+
window.onDidChangeActiveTextEditor(async (editor) => {
|
|
480
478
|
const tutorialIsActive = editor && editor.document.uri.toString() === documentUri.toString();
|
|
481
|
-
return
|
|
479
|
+
return commands.executeCommand("setContext", "cody.tutorialActive", tutorialIsActive);
|
|
482
480
|
}),
|
|
483
|
-
|
|
481
|
+
workspace.onDidCloseTextDocument((document2) => {
|
|
484
482
|
if (document2.uri !== documentUri) {
|
|
485
483
|
return;
|
|
486
484
|
}
|
|
487
|
-
|
|
485
|
+
telemetryRecorder.recordEvent("cody.interactiveTutorial", "closed");
|
|
488
486
|
}),
|
|
489
|
-
|
|
487
|
+
commands.registerCommand("cody.tutorial.start", async () => {
|
|
490
488
|
if (status === "started") {
|
|
491
|
-
return
|
|
489
|
+
return window.showTextDocument(documentUri);
|
|
492
490
|
}
|
|
493
491
|
return start();
|
|
494
492
|
}),
|
|
495
|
-
|
|
496
|
-
|
|
493
|
+
commands.registerCommand("cody.tutorial.reset", async () => {
|
|
494
|
+
telemetryRecorder.recordEvent("cody.interactiveTutorial", "reset");
|
|
497
495
|
stop();
|
|
498
496
|
document = await resetDocument(documentUri);
|
|
499
497
|
return start();
|
|
500
498
|
}),
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
void
|
|
499
|
+
commands.registerCommand("cody.sidebar.tutorial", () => {
|
|
500
|
+
logSidebarClick("tutorial");
|
|
501
|
+
void commands.executeCommand("cody.tutorial.start");
|
|
504
502
|
})
|
|
505
503
|
);
|
|
506
|
-
const tutorialVisible =
|
|
504
|
+
const tutorialVisible = window.visibleTextEditors.some(
|
|
507
505
|
(editor) => editor.document.uri.toString() === documentUri.toString()
|
|
508
506
|
);
|
|
509
507
|
if (tutorialVisible) {
|
|
@@ -511,4 +509,6 @@ const registerInteractiveTutorial = async (context) => {
|
|
|
511
509
|
}
|
|
512
510
|
return disposables;
|
|
513
511
|
};
|
|
514
|
-
|
|
512
|
+
export {
|
|
513
|
+
registerInteractiveTutorial
|
|
514
|
+
};
|