diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/manager/DefaultLspManager.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/manager/DefaultLspManager.java index 33fd05a5..2821976c 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/manager/DefaultLspManager.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/manager/DefaultLspManager.java @@ -14,6 +14,12 @@ import java.util.HashSet; import java.util.Optional; +import org.eclipse.swt.widgets.Display; +import software.aws.toolkits.eclipse.amazonq.util.Constants; +import software.aws.toolkits.eclipse.amazonq.util.PersistentToolkitNotification; +import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.eclipse.mylyn.commons.ui.dialogs.AbstractNotificationPopup; + import software.aws.toolkits.eclipse.amazonq.exception.AmazonQPluginException; import software.aws.toolkits.eclipse.amazonq.lsp.manager.fetcher.ArtifactUtils; import software.aws.toolkits.eclipse.amazonq.lsp.manager.fetcher.LspFetcher; @@ -83,6 +89,14 @@ private LspInstallResult fetchLspInstallation() { } Manifest manifest = fetchManifest(); + if (manifest.isManifestDeprecated() && manifest.manifestSchemaVersion() != null) { + try { + showDeprecatedManifestNotification(manifest.manifestSchemaVersion()); + } catch (Exception e) { + Activator.getLogger().error("Failed to show deprecated manifest notification", e); + } + } + var platform = platformOverride != null ? platformOverride : PluginUtils.getPlatform(); var architecture = architectureOverride != null ? architectureOverride : PluginUtils.getArchitecture(); @@ -239,6 +253,33 @@ private static void makeExecutable(final Path filePath) throws IOException { Files.setPosixFilePermissions(filePath, permissions); } + private static void showDeprecatedManifestNotification(final String version) { + ArtifactVersion schemaVersion = ArtifactUtils.parseVersion(version); + ArtifactVersion storedValue = Optional.ofNullable(Activator.getPluginStore().get(Constants.MANIFEST_DEPRECATED_NOTIFICATION_KEY)) + .map(ArtifactUtils::parseVersion) + .orElse(null); + + if (storedValue == null || remoteVersionIsGreater(schemaVersion, storedValue)) { + Display.getDefault().asyncExec(() -> { + AbstractNotificationPopup notification = new PersistentToolkitNotification(Display.getCurrent(), + Constants.MANIFEST_DEPRECATED_NOTIFICATION_TITLE, + Constants.MANIFEST_DEPRECATED_NOTIFICATION_BODY, + (selected) -> { + if (selected) { + Activator.getPluginStore().put(Constants.MANIFEST_DEPRECATED_NOTIFICATION_KEY, schemaVersion.toString()); + } else { + Activator.getPluginStore().remove(Constants.MANIFEST_DEPRECATED_NOTIFICATION_KEY); + } + }); + notification.open(); + }); + } + } + + private static boolean remoteVersionIsGreater(final ArtifactVersion remote, final ArtifactVersion storedValue) { + return remote.compareTo(storedValue) > 0; + } + public static class Builder { private String manifestUrl; private Path workingDirectory; diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/util/Constants.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/util/Constants.java index fa290cea..550200a0 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/util/Constants.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/util/Constants.java @@ -18,11 +18,15 @@ private Constants() { public static final String DO_NOT_SHOW_UPDATE_KEY = "doNotShowUpdate"; public static final String PLUGIN_UPDATE_NOTIFICATION_TITLE = "Amazon Q Update Available"; public static final String PLUGIN_UPDATE_NOTIFICATION_BODY = "Amazon Q plugin version %s is available." - + "Please update to receive the latest features and bug fixes."; + + " Please update to receive the latest features and bug fixes."; public static final String LSP_CW_OPT_OUT_KEY = "shareCodeWhispererContentWithAWS"; public static final String LSP_CODE_REFERENCES_OPT_OUT_KEY = "includeSuggestionsWithCodeReferences"; public static final String IDE_CUSTOMIZATION_NOTIFICATION_TITLE = "Amazon Q Customization"; public static final String IDE_CUSTOMIZATION_NOTIFICATION_BODY_TEMPLATE = "Amazon Q inline suggestions are now coming from the %s"; + public static final String MANIFEST_DEPRECATED_NOTIFICATION_KEY = "doNotShowDeprecatedManifest"; + public static final String MANIFEST_DEPRECATED_NOTIFICATION_TITLE = "Update Amazon Q Extension"; + public static final String MANIFEST_DEPRECATED_NOTIFICATION_BODY = "This version of the plugin" + + " will no longer receive updates to Amazon Q Language authoring features"; public static final String DEFAULT_Q_FOUNDATION_DISPLAY_NAME = "Amazon Q foundation (Default)"; public static final String LOGIN_TYPE_KEY = "LOGIN_TYPE"; public static final String LOGIN_IDC_PARAMS_KEY = "IDC_PARAMS"; diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/util/UpdateUtils.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/util/UpdateUtils.java index 1f7b9cee..979afeab 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/util/UpdateUtils.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/util/UpdateUtils.java @@ -12,6 +12,7 @@ import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.time.Duration; +import java.util.Optional; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.eclipse.mylyn.commons.ui.dialogs.AbstractNotificationPopup; @@ -36,7 +37,9 @@ public static UpdateUtils getInstance() { } private UpdateUtils() { - mostRecentNotificationVersion = Activator.getPluginStore().getObject(Constants.DO_NOT_SHOW_UPDATE_KEY, ArtifactVersion.class); + mostRecentNotificationVersion = Optional.ofNullable(Activator.getPluginStore().get(Constants.DO_NOT_SHOW_UPDATE_KEY)) + .map(ArtifactUtils::parseVersion) + .orElse(null); String localString = PluginClientMetadata.getInstance().getPluginVersion(); localVersion = ArtifactUtils.parseVersion(localString.substring(0, localString.lastIndexOf("."))); } @@ -108,7 +111,7 @@ private void showNotification() { String.format(Constants.PLUGIN_UPDATE_NOTIFICATION_BODY, remoteVersion.toString()), (selected) -> { if (selected) { - Activator.getPluginStore().putObject(Constants.DO_NOT_SHOW_UPDATE_KEY, remoteVersion); + Activator.getPluginStore().put(Constants.DO_NOT_SHOW_UPDATE_KEY, remoteVersion.toString()); } else { Activator.getPluginStore().remove(Constants.DO_NOT_SHOW_UPDATE_KEY); }