Skip to content

Commit 513099b

Browse files
committed
Fix showing of raw evaluator log for cancelled items
This will ensure that when "Show Evaluator Log (Raw JSON)" is used on a cancelled query history item, we will still show it if it exists. This changes the error messages on other cases to be more specific.
1 parent 3cf2be9 commit 513099b

File tree

1 file changed

+23
-41
lines changed

1 file changed

+23
-41
lines changed

extensions/ql-vscode/src/query-history/query-history-manager.ts

+23-41
Original file line numberDiff line numberDiff line change
@@ -702,24 +702,6 @@ export class QueryHistoryManager extends DisposableObject {
702702
}
703703
}
704704

705-
async getQueryHistoryItemDirectory(
706-
queryHistoryItem: QueryHistoryInfo,
707-
): Promise<string> {
708-
if (queryHistoryItem.t === "local") {
709-
if (queryHistoryItem.completedQuery) {
710-
return queryHistoryItem.completedQuery.query.querySaveDir;
711-
}
712-
} else if (queryHistoryItem.t === "variant-analysis") {
713-
return this.variantAnalysisManager.getVariantAnalysisStorageLocation(
714-
queryHistoryItem.variantAnalysis.id,
715-
);
716-
} else {
717-
assertNever(queryHistoryItem);
718-
}
719-
720-
throw new Error("Unable to get query directory");
721-
}
722-
723705
async handleOpenQueryDirectory(item: QueryHistoryInfo) {
724706
let externalFilePath: string | undefined;
725707
if (item.t === "local") {
@@ -781,27 +763,32 @@ export class QueryHistoryManager extends DisposableObject {
781763
);
782764
}
783765

784-
private warnInProgressEvalLogSummary() {
785-
void showAndLogWarningMessage(
786-
this.app.logger,
787-
'The evaluator log summary is still being generated for this run. Please try again later. The summary generation process is tracked in the "CodeQL Extension Log" view.',
788-
);
789-
}
766+
private async warnNoEvalLogSummary(item: LocalQueryInfo) {
767+
const evalLogLocation =
768+
item.evalLogLocation ?? item.initialInfo.outputDir?.evalLogPath;
790769

791-
private warnInProgressEvalLogViewer() {
792-
void showAndLogWarningMessage(
793-
this.app.logger,
794-
"The viewer's data is still being generated for this run. Please try again or re-run the query.",
795-
);
770+
// Summary log file doesn't exist.
771+
if (evalLogLocation && (await pathExists(evalLogLocation))) {
772+
// If raw log does exist, then the summary log is still being generated.
773+
void showAndLogWarningMessage(
774+
this.app.logger,
775+
'The evaluator log summary is still being generated for this run. Please try again later. The summary generation process is tracked in the "CodeQL Extension Log" view.',
776+
);
777+
} else {
778+
this.warnNoEvalLogs();
779+
}
796780
}
797781

798782
async handleShowEvalLog(item: QueryHistoryInfo) {
799783
if (item.t !== "local") {
800784
return;
801785
}
802786

803-
if (item.evalLogLocation) {
804-
await tryOpenExternalFile(this.app.commands, item.evalLogLocation);
787+
const evalLogLocation =
788+
item.evalLogLocation ?? item.initialInfo.outputDir?.evalLogPath;
789+
790+
if (evalLogLocation && (await pathExists(evalLogLocation))) {
791+
await tryOpenExternalFile(this.app.commands, evalLogLocation);
805792
} else {
806793
this.warnNoEvalLogs();
807794
}
@@ -812,18 +799,13 @@ export class QueryHistoryManager extends DisposableObject {
812799
return;
813800
}
814801

815-
if (item.evalLogSummaryLocation) {
816-
await tryOpenExternalFile(this.app.commands, item.evalLogSummaryLocation);
802+
// If the summary file location wasn't saved, display error
803+
if (!item.evalLogSummaryLocation) {
804+
await this.warnNoEvalLogSummary(item);
817805
return;
818806
}
819807

820-
// Summary log file doesn't exist.
821-
if (item.evalLogLocation && (await pathExists(item.evalLogLocation))) {
822-
// If raw log does exist, then the summary log is still being generated.
823-
this.warnInProgressEvalLogSummary();
824-
} else {
825-
this.warnNoEvalLogs();
826-
}
808+
await tryOpenExternalFile(this.app.commands, item.evalLogSummaryLocation);
827809
}
828810

829811
async handleShowEvalLogViewer(item: QueryHistoryInfo) {
@@ -833,7 +815,7 @@ export class QueryHistoryManager extends DisposableObject {
833815

834816
// If the JSON summary file location wasn't saved, display error
835817
if (item.jsonEvalLogSummaryLocation === undefined) {
836-
this.warnInProgressEvalLogViewer();
818+
await this.warnNoEvalLogSummary(item);
837819
return;
838820
}
839821

0 commit comments

Comments
 (0)