Skip to content

Commit d9d9bd5

Browse files
committed
feat: allow terminal selection or pasted error for /upgradesFindCL
1 parent 17b2b79 commit d9d9bd5

File tree

1 file changed

+84
-76
lines changed

1 file changed

+84
-76
lines changed

src/chat/commands/upgradesFindCL.ts

Lines changed: 84 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -345,17 +345,23 @@ export async function upgradesFindCL(
345345
stream: vscode.ChatResponseStream,
346346
token: vscode.CancellationToken,
347347
) {
348-
if (request.prompt) {
349-
stream.markdown("Cannot process prompt after the command.");
350-
} else if (
351-
!request.toolReferences.find(
352-
(reference) => reference.name === lmToolNames.getTerminalSelection,
353-
)
348+
const terminalSelectionAttached = !!request.toolReferences.find(
349+
(reference) => reference.name === lmToolNames.getTerminalSelection,
350+
);
351+
352+
if (
353+
(!request.prompt && !terminalSelectionAttached) ||
354+
(request.prompt && terminalSelectionAttached)
354355
) {
355356
stream.markdown(
356-
"This command requires you attach the 'Terminal Selection' context.",
357+
"This command requires you attach the 'Terminal Selection' context or provide the error in the prompt (but not both).",
357358
);
358-
} else {
359+
return {};
360+
}
361+
362+
let errorText: string;
363+
364+
if (terminalSelectionAttached) {
359365
const terminalSelection = await vscode.lm.invokeTool(
360366
lmToolNames.getTerminalSelection,
361367
{ input: {}, toolInvocationToken: request.toolInvocationToken },
@@ -369,77 +375,79 @@ export async function upgradesFindCL(
369375
return {};
370376
}
371377

372-
stream.progress("Checking current git branch...");
373-
const branchName = await exec("git rev-parse --abbrev-ref HEAD", {
374-
cwd: electronRoot.fsPath,
375-
encoding: "utf8",
376-
}).then(({ stdout }) => stdout.trim());
377-
if (branchName !== "roller/chromium/main") {
378-
stream.markdown(
379-
"Confirm you have a Chromium roll branch checked out - only `roller/chromium/main is supported for now.",
380-
);
381-
return {};
382-
}
383-
stream.progress("Determining Chromium versions...");
384-
const versions = await getChromiumVersions(electronRoot, branchName);
385-
if (!versions.previousVersion || !versions.newVersion) {
386-
stream.markdown(
387-
"Couldn't determine Chromium versions from local checkout.",
388-
);
389-
return {};
390-
}
391-
if (
392-
compareChromiumVersions(versions.newVersion, versions.previousVersion) <=
393-
0
394-
) {
395-
stream.markdown(
396-
"Chromium version in this branch is the same or older than `origin/main`.",
397-
);
398-
return {};
399-
}
400-
const previousChromiumVersionDate = await getChromiumVersionCommitDate(
378+
errorText = terminalSelectionText;
379+
} else {
380+
errorText = request.prompt;
381+
}
382+
383+
stream.progress("Checking current git branch...");
384+
const branchName = await exec("git rev-parse --abbrev-ref HEAD", {
385+
cwd: electronRoot.fsPath,
386+
encoding: "utf8",
387+
}).then(({ stdout }) => stdout.trim());
388+
if (branchName !== "roller/chromium/main") {
389+
stream.markdown(
390+
"Confirm you have a Chromium roll branch checked out - only `roller/chromium/main is supported for now.",
391+
);
392+
return {};
393+
}
394+
395+
stream.progress("Determining Chromium versions...");
396+
const versions = await getChromiumVersions(electronRoot, branchName);
397+
if (!versions.previousVersion || !versions.newVersion) {
398+
stream.markdown(
399+
"Couldn't determine Chromium versions from local checkout.",
400+
);
401+
return {};
402+
}
403+
if (
404+
compareChromiumVersions(versions.newVersion, versions.previousVersion) <= 0
405+
) {
406+
stream.markdown(
407+
"Chromium version in this branch is the same or older than `origin/main`.",
408+
);
409+
return {};
410+
}
411+
const previousChromiumVersionDate = await getChromiumVersionCommitDate(
412+
chromiumRoot,
413+
versions.previousVersion,
414+
);
415+
if (!previousChromiumVersionDate) {
416+
stream.markdown(
417+
"Couldn't determine the commit date for the previous Chromium version. Ensure you've synced recently.",
418+
);
419+
return {};
420+
}
421+
422+
stream.progress("Analyzing terminal selection...");
423+
const errorType = await determineErrorType(request.model, errorText, token);
424+
425+
if (errorType === ErrorType.SYNC) {
426+
await analyzeSyncError(
401427
chromiumRoot,
402-
versions.previousVersion,
428+
request,
429+
stream,
430+
tools,
431+
previousChromiumVersionDate,
432+
errorText,
433+
token,
403434
);
404-
if (!previousChromiumVersionDate) {
405-
stream.markdown(
406-
"Couldn't determine the commit date for the previous Chromium version. Ensure you've synced recently.",
407-
);
408-
return {};
409-
}
410-
stream.progress("Analyzing terminal selection...");
411-
const errorType = await determineErrorType(
412-
request.model,
413-
terminalSelectionText,
435+
} else if (errorType === ErrorType.BUILD) {
436+
await analyzeBuildError(
437+
chromiumRoot,
438+
request,
439+
stream,
440+
tools,
441+
versions.previousVersion,
442+
versions.newVersion,
443+
errorText,
414444
token,
415445
);
416-
if (errorType === ErrorType.SYNC) {
417-
await analyzeSyncError(
418-
chromiumRoot,
419-
request,
420-
stream,
421-
tools,
422-
previousChromiumVersionDate,
423-
terminalSelectionText,
424-
token,
425-
);
426-
} else if (errorType === ErrorType.BUILD) {
427-
await analyzeBuildError(
428-
chromiumRoot,
429-
request,
430-
stream,
431-
tools,
432-
versions.previousVersion,
433-
versions.newVersion,
434-
terminalSelectionText,
435-
token,
436-
);
437-
} else if (errorType === ErrorType.UNKNOWN) {
438-
stream.markdown(
439-
"Could not determine the error type from the terminal selection.",
440-
);
441-
return {};
442-
}
443-
return {};
446+
} else if (errorType === ErrorType.UNKNOWN) {
447+
stream.markdown(
448+
"Could not determine the error type from the terminal selection.",
449+
);
444450
}
451+
452+
return {};
445453
}

0 commit comments

Comments
 (0)