Skip to content

Commit 35f41d8

Browse files
authored
Merge branch 'main' into experiment/lsp-tool-contract-tuning
2 parents 467198e + 1996083 commit 35f41d8

2 files changed

Lines changed: 33 additions & 10 deletions

File tree

src/upgrade/display/notificationManager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class NotificationManager implements IUpgradeIssuesRenderer {
9393
sendInfo(operationId, {
9494
operationName: "java.dependency.upgradeNotification.show",
9595
extensionState,
96+
source: hasCVEIssue ? Upgrade.SOURCE_CVE : Upgrade.SOURCE_JAVA_UPGRADE,
9697
});
9798

9899
const buttons = hasCVEIssue

src/upgrade/utility.ts

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ export async function checkOrInstallAppModExtensionForUpgrade(
197197
}
198198

199199
await commands.executeCommand("workbench.extensions.installExtension", ExtensionName.APP_MODERNIZATION_FOR_JAVA);
200+
sendInfo(operationId, {
201+
operationName: "java.dependency.upgradeFlow.result",
202+
upgradeFlowStep: "installSucceeded",
203+
installType: state === "outdated" ? "updated" : "installed",
204+
});
200205

201206
if (state === "outdated") {
202207
// Extension was updated (not freshly installed) — reload required
@@ -219,18 +224,35 @@ export async function checkOrInstallAppModExtensionForUpgrade(
219224
return false;
220225
}
221226

222-
await checkOrPromptToEnableAppModExtension("upgrade");
227+
// Wait until the freshly installed extension is registered, returning as
228+
// soon as it is ready, or after a 5s timeout fallback at the latest.
229+
await waitForExtensionReady(extensionIdToCheck, 5000);
223230

224-
// Wait briefly for the newly installed extension to activate
225-
await new Promise(resolve => setTimeout(resolve, 2000));
226-
227-
// Re-check if the newly installed extension is active and meets version requirement
228-
const newState = getExtensionState(extensionIdToCheck);
229-
const canProceed = newState === "up-to-date";
230231
sendInfo(operationId, {
231232
operationName: "java.dependency.upgradeFlow.result",
232-
upgradeFlowResult: canProceed ? "proceeded" : "activation-timeout",
233+
upgradeFlowResult: "proceeded",
233234
});
234-
return canProceed;
235+
return true;
235236
})();
236-
}
237+
}
238+
239+
function waitForExtensionReady(extensionId: string, timeoutMs: number): Promise<void> {
240+
return new Promise<void>(resolve => {
241+
if (extensions.getExtension(extensionId)) {
242+
resolve();
243+
return;
244+
}
245+
let timer: NodeJS.Timeout;
246+
const disposable = extensions.onDidChange(() => {
247+
if (extensions.getExtension(extensionId)) {
248+
clearTimeout(timer);
249+
disposable.dispose();
250+
resolve();
251+
}
252+
});
253+
timer = setTimeout(() => {
254+
disposable.dispose();
255+
resolve();
256+
}, timeoutMs);
257+
});
258+
}

0 commit comments

Comments
 (0)