Skip to content

Commit 83df05e

Browse files
authored
Merge pull request #3622 from github/nickrolfe/eval-log-progress
Report progress for post-evaluation actions
2 parents d7a82cc + b43b1d4 commit 83df05e

File tree

6 files changed

+31
-3
lines changed

6 files changed

+31
-3
lines changed

extensions/ql-vscode/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## [UNRELEASED]
44

55
- Fix a bug when re-importing test databases that erroneously showed old source code. [#3616](https://github.com/github/vscode-codeql/pull/3616)
6+
- Update the progress window with details on potentially long-running post-processing steps after running a query. [#3622](https://github.com/github/vscode-codeql/pull/3622)
67

78
## 1.13.0 - 1 May 2024
89

extensions/ql-vscode/src/common/vscode/progress.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ export interface ProgressUpdate {
3333
message: string;
3434
}
3535

36+
export function progressUpdate(
37+
step: number,
38+
maxStep: number,
39+
message: string,
40+
): ProgressUpdate {
41+
return { step, maxStep, message };
42+
}
43+
3644
export type ProgressCallback = (p: ProgressUpdate) => void;
3745

3846
// Make certain properties within a type optional

extensions/ql-vscode/src/debugger/debugger-ui.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class QLDebugAdapterTracker
135135
): Promise<void> {
136136
if (this.localQueryRun !== undefined) {
137137
const results: CoreQueryResults = body;
138-
await this.localQueryRun.complete(results);
138+
await this.localQueryRun.complete(results, (_) => {});
139139
this.localQueryRun = undefined;
140140
}
141141
}

extensions/ql-vscode/src/local-queries/local-queries.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ export class LocalQueries extends DisposableObject {
485485
localQueryRun.logger,
486486
);
487487

488-
await localQueryRun.complete(results);
488+
await localQueryRun.complete(results, progress);
489489

490490
return results;
491491
} catch (e) {

extensions/ql-vscode/src/local-queries/local-query-run.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import type { LocalQueries } from "./local-queries";
2626
import { tryGetQueryMetadata } from "../codeql-cli/query-metadata";
2727
import { telemetryListener } from "../common/vscode/telemetry";
2828
import type { Disposable } from "../common/disposable-object";
29+
import type { ProgressCallback } from "../common/vscode/progress";
30+
import { progressUpdate } from "../common/vscode/progress";
2931

3032
function formatResultMessage(result: CoreQueryResults): string {
3133
switch (result.resultType) {
@@ -79,23 +81,31 @@ export class LocalQueryRun {
7981
* This function must be called when the evaluation completes, whether the evaluation was
8082
* successful or not.
8183
* */
82-
public async complete(results: CoreQueryResults): Promise<void> {
84+
public async complete(
85+
results: CoreQueryResults,
86+
progress: ProgressCallback,
87+
): Promise<void> {
8388
const evalLogPaths = await this.summarizeEvalLog(
8489
results.resultType,
8590
this.outputDir,
8691
this.logger,
92+
progress,
8793
);
8894
if (evalLogPaths !== undefined) {
8995
this.queryInfo.setEvaluatorLogPaths(evalLogPaths);
9096
}
97+
progress(progressUpdate(1, 4, "Getting completed query info"));
9198
const queryWithResults = await this.getCompletedQueryInfo(results);
99+
progress(progressUpdate(2, 4, "Updating query history"));
92100
this.queryHistoryManager.completeQuery(this.queryInfo, queryWithResults);
101+
progress(progressUpdate(3, 4, "Showing results"));
93102
await this.localQueries.showResultsForCompletedQuery(
94103
this.queryInfo as CompletedLocalQueryInfo,
95104
WebviewReveal.Forced,
96105
);
97106
// Note we must update the query history view after showing results as the
98107
// display and sorting might depend on the number of results
108+
progress(progressUpdate(4, 4, "Updating query history"));
99109
await this.queryHistoryManager.refreshTreeView();
100110

101111
this.logger.dispose();
@@ -109,6 +119,7 @@ export class LocalQueryRun {
109119
QueryResultType.OTHER_ERROR,
110120
this.outputDir,
111121
this.logger,
122+
(_) => {},
112123
);
113124
if (evalLogPaths !== undefined) {
114125
this.queryInfo.setEvaluatorLogPaths(evalLogPaths);
@@ -128,10 +139,12 @@ export class LocalQueryRun {
128139
resultType: QueryResultType,
129140
outputDir: QueryOutputDir,
130141
logger: BaseLogger,
142+
progress: ProgressCallback,
131143
): Promise<EvaluatorLogPaths | undefined> {
132144
const evalLogPaths = await generateEvalLogSummaries(
133145
this.cliServer,
134146
outputDir,
147+
progress,
135148
);
136149
if (evalLogPaths !== undefined) {
137150
if (evalLogPaths.endSummary !== undefined) {

extensions/ql-vscode/src/run-queries-shared.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import { generateSummarySymbolsFile } from "./log-insights/summary-parser";
3131
import { getErrorMessage } from "./common/helpers-pure";
3232
import { createHash } from "crypto";
3333
import { QueryOutputDir } from "./local-queries/query-output-dir";
34+
import { progressUpdate } from "./common/vscode/progress";
35+
import type { ProgressCallback } from "./common/vscode/progress";
3436

3537
/**
3638
* run-queries.ts
@@ -519,6 +521,7 @@ export async function createInitialQueryInfo(
519521
export async function generateEvalLogSummaries(
520522
cliServer: CodeQLCliServer,
521523
outputDir: QueryOutputDir,
524+
progress: ProgressCallback,
522525
): Promise<EvaluatorLogPaths | undefined> {
523526
const log = outputDir.evalLogPath;
524527
if (!(await pathExists(log))) {
@@ -527,6 +530,7 @@ export async function generateEvalLogSummaries(
527530
}
528531
let humanReadableSummary: string | undefined = undefined;
529532
let endSummary: string | undefined = undefined;
533+
progress(progressUpdate(1, 3, "Generating evaluator log summary"));
530534
if (await generateHumanReadableLogSummary(cliServer, outputDir)) {
531535
humanReadableSummary = outputDir.evalLogSummaryPath;
532536
endSummary = outputDir.evalLogEndSummaryPath;
@@ -535,10 +539,12 @@ export async function generateEvalLogSummaries(
535539
let summarySymbols: string | undefined = undefined;
536540
if (isCanary()) {
537541
// Generate JSON summary for viewer.
542+
progress(progressUpdate(2, 3, "Generating JSON log summary"));
538543
jsonSummary = outputDir.jsonEvalLogSummaryPath;
539544
await cliServer.generateJsonLogSummary(log, jsonSummary);
540545

541546
if (humanReadableSummary !== undefined) {
547+
progress(progressUpdate(3, 3, "Generating summary symbols file"));
542548
summarySymbols = outputDir.evalLogSummarySymbolsPath;
543549
await generateSummarySymbolsFile(humanReadableSummary, summarySymbols);
544550
}

0 commit comments

Comments
 (0)