diff --git a/plugin-core/src/main/java/appland/cli/FailedDownloadNotificationListener.java b/plugin-core/src/main/java/appland/cli/FailedDownloadNotificationListener.java new file mode 100644 index 00000000..0767c9c0 --- /dev/null +++ b/plugin-core/src/main/java/appland/cli/FailedDownloadNotificationListener.java @@ -0,0 +1,20 @@ +package appland.cli; + +import appland.notifications.AppMapNotifications; +import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.NotNull; + +public final class FailedDownloadNotificationListener implements AppLandDownloadListener { + @NotNull private final Project project; + + public FailedDownloadNotificationListener(@NotNull Project project) { + this.project = project; + } + + @Override + public void downloadFinished(@NotNull CliTool type, boolean success) { + if (!success) { + AppMapNotifications.showFailedCliBinaryDownloadNotification(project); + } + } +} diff --git a/plugin-core/src/main/java/appland/notifications/AppMapNotifications.java b/plugin-core/src/main/java/appland/notifications/AppMapNotifications.java index 611e7c56..2044e76f 100644 --- a/plugin-core/src/main/java/appland/notifications/AppMapNotifications.java +++ b/plugin-core/src/main/java/appland/notifications/AppMapNotifications.java @@ -354,4 +354,36 @@ public static void showCopilotAuthenticationRequired() { } }); } + + /** + * See https://github.com/getappmap/appmap-intellij-plugin/issues/814. + */ + public static void showFailedCliBinaryDownloadNotification(@NotNull Project project) { + if (!AppMapApplicationSettingsService.getInstance().isShowFailedCliDownloadError()) { + return; + } + + // the message should only appear once + AppMapApplicationSettingsService.getInstance().setShowFailedCliDownloadError(false); + + ApplicationManager.getApplication().invokeLater(() -> { + Notification notification = new AppMapFullContentNotification( + GENERIC_NOTIFICATIONS_ID, + null, + AppMapBundle.get("notification.cliDownloadFailed.title"), + null, + AppMapBundle.get("notification.cliDownloadFailed.content"), + NotificationType.ERROR, + null + ); + + var showInstructionsAction = NotificationAction.create(lazy("notification.cliDownloadFailed.browseAction"), (e, n) -> { + n.expire(); + BrowserUtil.browse("https://appmap.io/docs/reference/appmap-airgapped-install.html#download-the-appmap-application-binaries"); + }); + + notification = notification.addAction(showInstructionsAction); + notification.notify(project); + }); + } } diff --git a/plugin-core/src/main/java/appland/settings/AppMapApplicationSettings.java b/plugin-core/src/main/java/appland/settings/AppMapApplicationSettings.java index cc045751..d19ca7d8 100644 --- a/plugin-core/src/main/java/appland/settings/AppMapApplicationSettings.java +++ b/plugin-core/src/main/java/appland/settings/AppMapApplicationSettings.java @@ -65,6 +65,8 @@ public class AppMapApplicationSettings { */ private volatile int maxPinnedFileSizeKB = 20; + private volatile boolean showFailedCliDownloadError = true; + public AppMapApplicationSettings() { } diff --git a/plugin-core/src/main/resources/META-INF/appmap-core.xml b/plugin-core/src/main/resources/META-INF/appmap-core.xml index c1057a69..4674c876 100644 --- a/plugin-core/src/main/resources/META-INF/appmap-core.xml +++ b/plugin-core/src/main/resources/META-INF/appmap-core.xml @@ -24,6 +24,9 @@ + + diff --git a/plugin-core/src/main/resources/messages/appland.properties b/plugin-core/src/main/resources/messages/appland.properties index 33846a77..0b49f5ac 100644 --- a/plugin-core/src/main/resources/messages/appland.properties +++ b/plugin-core/src/main/resources/messages/appland.properties @@ -122,6 +122,7 @@ dirPathValidation.notDir=Please enter the location of a directory, not a file. nameValidation.empty=Please enter a valid name. +notification.dontShowAgainOption=Don't show again notification.closeButton=Close notification.stopButton=Stop notification.recordingHelpButton=Show Help @@ -162,6 +163,10 @@ notification.exportAppMapJson.content=An error occurred while exporting AppMap J notification.reloadProject.content=Please reload your project because the AppMap settings changed. +notification.cliDownloadFailed.title=Download Failed: AppMap CLI Tools +notification.cliDownloadFailed.content=Failed to download the AppMap CLI tools. This is a required dependency of the AppMap plugin. Please refer to the instructions to manually install it. +notification.cliDownloadFailed.browseAction=Show instructions + statusBar.recording.displayName=AppMap Recording statusBar.recording.recordingStatus=Recording...