diff --git a/src/main/java/com/sourcegraph/cody/SubscriptionTabUtils.kt b/src/main/java/com/sourcegraph/cody/SubscriptionTabUtils.kt index 3793693586..f93396d568 100644 --- a/src/main/java/com/sourcegraph/cody/SubscriptionTabUtils.kt +++ b/src/main/java/com/sourcegraph/cody/SubscriptionTabUtils.kt @@ -7,6 +7,7 @@ import com.sourcegraph.cody.agent.CodyAgentServer import com.sourcegraph.cody.agent.protocol.GetFeatureFlag import com.sourcegraph.cody.config.CodyAuthenticationManager import java.util.concurrent.CompletableFuture +import java.util.concurrent.TimeUnit data class SubscriptionTabPanelData( val isDotcomAccount: Boolean, @@ -28,7 +29,10 @@ fun fetchSubscriptionPanelData( if (activeAccountType.isDotcomAccount()) { ApplicationManager.getApplication().executeOnPooledThread { val codyProFeatureFlag = - server.evaluateFeatureFlag(GetFeatureFlag.CodyProJetBrains).get() == true + server + .evaluateFeatureFlag(GetFeatureFlag.CodyProJetBrains) + .completeOnTimeout(false, 4, TimeUnit.SECONDS) + .get() == true if (codyProFeatureFlag) { val isCurrentUserPro = getIsCurrentUserPro(server) ?: false result.complete( diff --git a/src/main/java/com/sourcegraph/vcs/RepoUtil.java b/src/main/java/com/sourcegraph/vcs/RepoUtil.java index 543de7a6be..b1f71ac6d3 100644 --- a/src/main/java/com/sourcegraph/vcs/RepoUtil.java +++ b/src/main/java/com/sourcegraph/vcs/RepoUtil.java @@ -159,7 +159,7 @@ private static String doReplacements( .thenCompose( agent -> agent.getServer().convertGitCloneURLToCodebaseName(new CloneURL(cloneURL))) - .completeOnTimeout(/* value= */ null, /* timeout= */ 4, TimeUnit.SECONDS) + .completeOnTimeout(null, 4, TimeUnit.SECONDS) .get(); if (codebaseName == null) { diff --git a/src/main/kotlin/com/sourcegraph/cody/agent/CodyAgentService.kt b/src/main/kotlin/com/sourcegraph/cody/agent/CodyAgentService.kt index 6f6b30f9f6..4cc5d43d90 100644 --- a/src/main/kotlin/com/sourcegraph/cody/agent/CodyAgentService.kt +++ b/src/main/kotlin/com/sourcegraph/cody/agent/CodyAgentService.kt @@ -23,12 +23,16 @@ class CodyAgentService(project: Project) : Disposable { init { onStartup { agent -> agent.client.onNewMessage = Consumer { params -> - AgentChatSessionService.getInstance(project) - .getSession(params.id) - ?.receiveMessage(params.message) + if (!project.isDisposed) { + AgentChatSessionService.getInstance(project) + .getSession(params.id) + ?.receiveMessage(params.message) + } } - AgentChatSessionService.getInstance(project).restoreAllSessions(agent) + if (!project.isDisposed) { + AgentChatSessionService.getInstance(project).restoreAllSessions(agent) + } } } diff --git a/src/main/kotlin/com/sourcegraph/cody/initialization/EndOfTrialNotificationScheduler.kt b/src/main/kotlin/com/sourcegraph/cody/initialization/EndOfTrialNotificationScheduler.kt index c6eff1f262..8e3212527b 100644 --- a/src/main/kotlin/com/sourcegraph/cody/initialization/EndOfTrialNotificationScheduler.kt +++ b/src/main/kotlin/com/sourcegraph/cody/initialization/EndOfTrialNotificationScheduler.kt @@ -38,7 +38,10 @@ class EndOfTrialNotificationScheduler private constructor(val project: Project) CodyAgentService.applyAgentOnBackgroundThread(project) { agent -> val currentUserCodySubscription = - agent.server.getCurrentUserCodySubscription().get(4, TimeUnit.SECONDS) + agent.server + .getCurrentUserCodySubscription() + .completeOnTimeout(null, 4, TimeUnit.SECONDS) + .get() if (currentUserCodySubscription == null) { logger.debug("currentUserCodySubscription is null") @@ -48,12 +51,15 @@ class EndOfTrialNotificationScheduler private constructor(val project: Project) val codyProTrialEnded = agent.server .evaluateFeatureFlag(GetFeatureFlag.CodyProTrialEnded) - .get(4, TimeUnit.SECONDS) == true + .completeOnTimeout(false, 4, TimeUnit.SECONDS) + .get() == true val useSscForCodySubscription = agent.server .evaluateFeatureFlag(GetFeatureFlag.UseSscForCodySubscription) - .get(4, TimeUnit.SECONDS) == true + .orTimeout(4, TimeUnit.SECONDS) + .completeOnTimeout(false, 4, TimeUnit.SECONDS) + .get() == true showProperNotificationIfApplicable( currentUserCodySubscription, codyProTrialEnded, useSscForCodySubscription) diff --git a/src/main/kotlin/com/sourcegraph/cody/statusbar/CodyAutocompleteStatusService.kt b/src/main/kotlin/com/sourcegraph/cody/statusbar/CodyAutocompleteStatusService.kt index 0a5d0a0395..fef6c201ad 100644 --- a/src/main/kotlin/com/sourcegraph/cody/statusbar/CodyAutocompleteStatusService.kt +++ b/src/main/kotlin/com/sourcegraph/cody/statusbar/CodyAutocompleteStatusService.kt @@ -38,9 +38,11 @@ class CodyAutocompleteStatusService : CodyAutocompleteStatusListener, Disposable override fun onCodyAutocompleteStatusReset(project: Project) { ApplicationManager.getApplication().executeOnPooledThread { - val notify = didStatusChanged(project) - if (notify) { - updateCodyStatusBarIcons() + if (!project.isDisposed) { + val notify = didStatusChanged(project) + if (notify) { + updateCodyStatusBarIcons() + } } } } diff --git a/src/main/kotlin/com/sourcegraph/common/UpgradeToCodyProNotification.kt b/src/main/kotlin/com/sourcegraph/common/UpgradeToCodyProNotification.kt index e4e4e08f39..9e595a775a 100644 --- a/src/main/kotlin/com/sourcegraph/common/UpgradeToCodyProNotification.kt +++ b/src/main/kotlin/com/sourcegraph/common/UpgradeToCodyProNotification.kt @@ -5,7 +5,6 @@ import com.intellij.notification.NotificationType import com.intellij.notification.impl.NotificationFullContent import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent -import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.project.DumbAwareAction import com.intellij.openapi.project.Project import com.sourcegraph.Icons @@ -77,9 +76,7 @@ private constructor(title: String, content: String, shouldShowUpgradeOption: Boo else -> CodyBundle.getString("UpgradeToCodyProNotification.title.explain") } - ApplicationManager.getApplication().invokeLater { - UpgradeToCodyProNotification(title, content, shouldShowUpgradeOption).notify(project) - } + UpgradeToCodyProNotification(title, content, shouldShowUpgradeOption).notify(project) } } diff --git a/src/main/resources/icons/chat/newChat.svg b/src/main/resources/icons/chat/newChat.svg index e93a3bd3a7..10a0256e54 100644 --- a/src/main/resources/icons/chat/newChat.svg +++ b/src/main/resources/icons/chat/newChat.svg @@ -1,3 +1,3 @@ - + diff --git a/src/main/resources/icons/chat/newChat_dark.svg b/src/main/resources/icons/chat/newChat_dark.svg new file mode 100644 index 0000000000..628ae6f43d --- /dev/null +++ b/src/main/resources/icons/chat/newChat_dark.svg @@ -0,0 +1,3 @@ + + +