-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathCopilotStartupNotificationActivity.java
More file actions
47 lines (39 loc) · 2.1 KB
/
Copy pathCopilotStartupNotificationActivity.java
File metadata and controls
47 lines (39 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package appland.copilotChat;
import appland.ProjectActivityAdapter;
import appland.copilotChat.copilot.GitHubCopilotService;
import appland.settings.AppMapApplicationSettingsService;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import java.util.concurrent.atomic.AtomicBoolean;
import static appland.notifications.AppMapNotifications.showCopilotAuthenticationRequired;
import static appland.notifications.AppMapNotifications.showFirstCopilotIntegrationEnabled;
public class CopilotStartupNotificationActivity extends ProjectActivityAdapter implements DumbAware {
private static final AtomicBoolean isNotificationShown = new AtomicBoolean(false);
@Override
public void runActivity(@NotNull Project project) {
// don't show if the user is not yet logged in to an AppMap account
if (!AppMapApplicationSettingsService.getInstance().hasAppMapKey()) {
return;
}
// don't show if the GitHub Copilot plugin is unavailable
if (CopilotModelInfoProvider.isDisabled()) {
return;
}
// if the Copilot integration is enabled, but not authenticated, show a notification
var copilotService = GitHubCopilotService.getInstance();
if (copilotService.isCopilotAuthenticated()) {// if the Copilot integration is enabled for the first time, show a notification
var wasDetectedBefore = AppMapApplicationSettingsService.getInstance().isCopilotIntegrationDetected();
if (!wasDetectedBefore && isNotificationShown.compareAndSet(false, true)) {
AppMapApplicationSettingsService.getInstance().setCopilotIntegrationDetected(true);
ApplicationManager.getApplication().invokeLater(() -> showFirstCopilotIntegrationEnabled(project));
}
try {
copilotService.ensureContentExclusionsDownloaded();
} catch (Exception e) {
// this is ok for now, it will be retried later
}
}
}
}