Skip to content

Commit d78338e

Browse files
committed
feat: add description to performance view
Adds a generic InfoBox similar to the existing WarningBox. Currently threads through a string as the description, but it should be trivial to change that to a ReactNode if needed...
1 parent ef3e125 commit d78338e

File tree

6 files changed

+44
-4
lines changed

6 files changed

+44
-4
lines changed

extensions/ql-vscode/src/common/interface-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ export type ToComparePerformanceViewMessage = SetPerformanceComparisonQueries;
401401

402402
export interface SetPerformanceComparisonQueries {
403403
readonly t: "setPerformanceComparison";
404+
readonly description: string;
404405
readonly from: PerformanceComparisonDataFromLog;
405406
readonly to: PerformanceComparisonDataFromLog;
406407
}

extensions/ql-vscode/src/compare-performance/compare-performance-view.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ export class ComparePerformanceView extends AbstractWebview<
4343
);
4444
}
4545

46-
async showResults(fromJsonLog: string, toJsonLog: string) {
46+
async showResults(
47+
fromJsonLog: string,
48+
toJsonLog: string,
49+
description: string,
50+
) {
4751
const panel = await this.getPanel();
4852
panel.reveal(undefined, false);
4953

@@ -65,6 +69,7 @@ export class ComparePerformanceView extends AbstractWebview<
6569

6670
await this.postMessage({
6771
t: "setPerformanceComparison",
72+
description,
6873
from: fromPerf.getData(),
6974
to: toPerf.getData(),
7075
});
@@ -125,6 +130,6 @@ export class ComparePerformanceView extends AbstractWebview<
125130
);
126131
return;
127132
}
128-
await this.showResults(result.before, result.after);
133+
await this.showResults(result.before, result.after, result.description);
129134
}
130135
}

extensions/ql-vscode/src/compare-performance/remote-logs.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ export class RemoteLogs {
254254
| {
255255
before: string;
256256
after: string;
257+
description: string;
257258
}
258259
| undefined
259260
> {
@@ -270,7 +271,11 @@ export class RemoteLogs {
270271
if (processed.some((d) => typeof d === "undefined")) {
271272
throw new Error("Silently failed to download or process some logs!?");
272273
}
273-
return { before: processed[0]!, after: processed[1]! };
274+
return {
275+
before: processed[0]!,
276+
after: processed[1]!,
277+
description: picked.description,
278+
};
274279
}
275280

276281
/**
@@ -640,6 +645,7 @@ export class RemoteLogs {
640645
| {
641646
before: ArtifactDownload;
642647
after: ArtifactDownload;
648+
description: string;
643649
}
644650
| undefined
645651
> {
@@ -723,6 +729,7 @@ export class RemoteLogs {
723729
before: targetInfoChoice1.downloads["evaluator-logs"],
724730
after: targetInfos.find((t) => t.info.target_id === targetChoice2)!
725731
.downloads["evaluator-logs"],
732+
description: `Comparison of logs from DCA experiment '${experimentChoice}' between targets '${targetChoice1}' and '${targetChoice2}'`,
726733
};
727734
}
728735
}

extensions/ql-vscode/src/extension.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,11 @@ async function showPerformanceComparison(
12231223
`Comparing performance of ${from.getQueryName()} and ${to.getQueryName()}`,
12241224
);
12251225

1226-
await view.showResults(fromLog, toLog);
1226+
await view.showResults(
1227+
fromLog,
1228+
toLog,
1229+
`Comparison of logs from local runs of ${from.getQueryName()} and ${to.getQueryName()}`,
1230+
);
12271231
}
12281232

12291233
function addUnhandledRejectionListener() {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { styled } from "styled-components";
2+
3+
const InfoBoxDiv = styled.div`
4+
max-width: 100em;
5+
padding: 0.5em 1em;
6+
border: 1px solid var(--vscode-widget-border);
7+
box-shadow: var(--vscode-widget-shadow) 0px 3px 8px;
8+
display: flex;
9+
`;
10+
11+
export interface WarningBoxProps {
12+
children: React.ReactNode;
13+
}
14+
15+
export function InfoBox(props: WarningBoxProps) {
16+
return (
17+
<InfoBoxDiv>
18+
<p>{props.children}</p>
19+
</InfoBoxDiv>
20+
);
21+
}

extensions/ql-vscode/src/view/compare-performance/ComparePerformance.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type {
1111
PipelineSummary,
1212
} from "../../log-insights/performance-comparison";
1313
import { Codicon, ViewTitle, WarningBox } from "../common";
14+
import { InfoBox } from "../common/InfoBox";
1415
import { useMessageFromExtension } from "../common/useMessageFromExtension";
1516
import { abbreviateRASteps } from "./RAPrettyPrinter";
1617

@@ -363,6 +364,7 @@ export function ComparePerformance(_: Record<string, never>) {
363364
return (
364365
<>
365366
<ViewTitle>Performance comparison</ViewTitle>
367+
{data?.description && <InfoBox>{data.description}</InfoBox>}
366368
{hasCacheHitMismatch && (
367369
<WarningBox>
368370
<strong>Inconsistent cache hits</strong>

0 commit comments

Comments
 (0)