Skip to content

Commit

Permalink
Show notification if the download of an AppMap CLI binary failed
Browse files Browse the repository at this point in the history
  • Loading branch information
jansorg committed Dec 9, 2024
1 parent 83912b4 commit e261a1c
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,36 @@ public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification noti
notification.notify(project);
});
}

/**
* 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);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public class AppMapApplicationSettings {
*/
private volatile int maxPinnedFileSizeKB = 20;

private volatile boolean showFailedCliDownloadError = true;

public AppMapApplicationSettings() {
}

Expand Down
3 changes: 3 additions & 0 deletions plugin-core/src/main/resources/META-INF/appmap-core.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<listener topic="appland.cli.AppLandDownloadListener"
class="appland.cli.StartServicesAfterDownloadListener"/>

<listener topic="appland.cli.AppLandDownloadListener"
class="appland.cli.FailedDownloadNotificationListener"/>

<listener topic="appland.files.AppMapFileChangeListener"
class="appland.notifications.FirstAppMapListener"/>
</projectListeners>
Expand Down
6 changes: 5 additions & 1 deletion plugin-core/src/main/resources/messages/appland.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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=AppMap Binary Download Failed
notification.cliDownloadFailed.content=Failed to download a required AppMap binary. Please refer to the instructions to manually install it.
notification.cliDownloadFailed.browseAction=Show instructions

statusBar.recording.displayName=AppMap Recording
statusBar.recording.recordingStatus=Recording...

Expand Down Expand Up @@ -268,4 +273,3 @@ findingsOverview.openFindingsByHashError.message=Unable to locate AppMap with ha
toolwindow.appmap.navie.intro=<html>Ask Navie a question about your application to get started.</html>
toolwindow.appmap.navie.newNavieChat=New Navie Chat
toolwindow.appmap.navie.details=<html>Navie uses AppMap data to improve the accuracy of Generative AI models. Navie searches through your locally stored AppMap data to identify the application behavior related to your question.</html>
notification.dontShowAgainOption=Don't show again

0 comments on commit e261a1c

Please sign in to comment.