Skip to content

Commit 2eb9ac1

Browse files
Jami CogswellJami Cogswell
authored andcommitted
Add canary for 'View Autofixes' button using 'postMessage' (copilot)
1 parent 15d4b72 commit 2eb9ac1

File tree

5 files changed

+34
-13
lines changed

5 files changed

+34
-13
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ export interface ParsedResultSets {
493493
interface SetVariantAnalysisMessage {
494494
t: "setVariantAnalysis";
495495
variantAnalysis: VariantAnalysis;
496+
isCanary?: boolean;
496497
}
497498

498499
interface SetFilterSortStateMessage {

extensions/ql-vscode/src/variant-analysis/variant-analysis-view.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,13 @@ export class VariantAnalysisView
202202
sortKey: getVariantAnalysisDefaultResultsSort(),
203203
};
204204

205+
// Import isCanary here to ensure we're getting the latest value
206+
const { isCanary } = await import("../config");
207+
205208
await this.postMessage({
206209
t: "setVariantAnalysis",
207210
variantAnalysis,
211+
isCanary: isCanary(),
208212
});
209213

210214
await this.postMessage({

extensions/ql-vscode/src/view/variant-analysis/VariantAnalysis.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,16 @@ export function VariantAnalysis({
7878
debounceTimeoutMillis: 1000,
7979
});
8080

81+
// Track if this is a canary build
82+
const [isCanary, setIsCanary] = useState(false);
83+
8184
useMessageFromExtension<ToVariantAnalysisMessage>((msg) => {
8285
if (msg.t === "setVariantAnalysis") {
8386
setVariantAnalysis(msg.variantAnalysis);
87+
// Set isCanary flag if provided
88+
if (msg.isCanary !== undefined) {
89+
setIsCanary(msg.isCanary);
90+
}
8491
vscode.setState({
8592
variantAnalysisId: msg.variantAnalysis.id,
8693
});
@@ -161,6 +168,7 @@ export function VariantAnalysis({
161168
onStopQueryClick={stopQuery}
162169
onViewAutofixesClick={viewAutofixes}
163170
onCopyRepositoryListClick={copyRepositoryList}
171+
isCanary={isCanary}
164172
onExportResultsClick={exportResults}
165173
onViewLogsClick={onViewLogsClick}
166174
/>

extensions/ql-vscode/src/view/variant-analysis/VariantAnalysisActions.tsx

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export type VariantAnalysisActionsProps = {
1818

1919
hasSelectedRepositories?: boolean;
2020
hasFilteredRepositories?: boolean;
21+
isCanary?: boolean;
2122
};
2223

2324
const Container = styled.div`
@@ -65,24 +66,28 @@ export const VariantAnalysisActions = ({
6566
exportResultsDisabled,
6667
hasSelectedRepositories,
6768
hasFilteredRepositories,
69+
isCanary,
6870
}: VariantAnalysisActionsProps) => {
6971
return (
7072
<Container>
7173
{showResultActions && (
7274
<>
73-
<Button
74-
secondary
75-
onClick={onViewAutofixesClick}
76-
disabled={viewAutofixesDisabled}
77-
>
78-
{chooseText({
79-
hasSelectedRepositories,
80-
hasFilteredRepositories,
81-
normalText: "View Autofixes",
82-
selectedText: "View Autofixes for selected results",
83-
filteredText: "View Autofixes for filtered results",
84-
})}
85-
</Button>
75+
{/* Only show the View Autofixes button in canary builds */}
76+
{isCanary && (
77+
<Button
78+
secondary
79+
onClick={onViewAutofixesClick}
80+
disabled={viewAutofixesDisabled}
81+
>
82+
{chooseText({
83+
hasSelectedRepositories,
84+
hasFilteredRepositories,
85+
normalText: "View Autofixes",
86+
selectedText: "View Autofixes for selected results",
87+
filteredText: "View Autofixes for filtered results",
88+
})}
89+
</Button>
90+
)}
8691
<Button
8792
secondary
8893
onClick={onCopyRepositoryListClick}

extensions/ql-vscode/src/view/variant-analysis/VariantAnalysisHeader.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type VariantAnalysisHeaderProps = {
3939
onExportResultsClick: () => void;
4040

4141
onViewLogsClick?: () => void;
42+
isCanary?: boolean;
4243
};
4344

4445
const Container = styled.div`
@@ -87,6 +88,7 @@ export const VariantAnalysisHeader = ({
8788
onCopyRepositoryListClick,
8889
onExportResultsClick,
8990
onViewLogsClick,
91+
isCanary,
9092
}: VariantAnalysisHeaderProps) => {
9193
const totalScannedRepositoryCount = useMemo(() => {
9294
return variantAnalysis.scannedRepos?.length ?? 0;
@@ -166,6 +168,7 @@ export const VariantAnalysisHeader = ({
166168
hasSelectedRepositories={
167169
selectedRepositoryIds && selectedRepositoryIds.length > 0
168170
}
171+
isCanary={isCanary}
169172
/>
170173
</Row>
171174
<VariantAnalysisStats

0 commit comments

Comments
 (0)