Fix RIDER-115461: ask the startup activity of the What's New status

GitOrigin-RevId: 3789261a9308a1ebc0d006ce1b8371e55e4a0bad
This commit is contained in:
Ivan Migalev
2025-04-23 18:05:08 +00:00
committed by intellij-monorepo-bot
parent a02b58969d
commit 3daf3282c5
2 changed files with 15 additions and 23 deletions
@@ -9,15 +9,12 @@ import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.application.ApplicationNamesInfo
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.service
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.diagnostic.runAndLogException
import com.intellij.openapi.progress.currentThreadCoroutineScope
import com.intellij.openapi.project.Project
import com.intellij.platform.whatsNew.reaction.FUSReactionChecker
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
import org.jetbrains.concurrency.await
@@ -29,12 +26,6 @@ internal class WhatsNewAction : AnAction(), com.intellij.openapi.project.DumbAwa
private val REACTIONS_STATE = "whatsnew.reactions.state"
private val reactionChecker = FUSReactionChecker(REACTIONS_STATE)
private val hasWhatsNewContent by lazy {
appScope.async {
WhatsNewContent.hasWhatsNewContent()
}
}
suspend fun openWhatsNew(project: Project) {
LOG.info("Open What's New page requested.")
val dataContext = LOG.runAndLogException { DataManager.getInstance().dataContextFromFocusAsync.await() }
@@ -55,9 +46,8 @@ internal class WhatsNewAction : AnAction(), com.intellij.openapi.project.DumbAwa
return ActionUpdateThread.BGT
}
@OptIn(ExperimentalCoroutinesApi::class)
override fun update(e: AnActionEvent) {
e.presentation.isEnabledAndVisible = if (hasWhatsNewContent.isCompleted) hasWhatsNewContent.getCompleted() else false
e.presentation.isEnabledAndVisible = service<WhatsNewStatus>().isContentAvailable
e.presentation.setText(IdeBundle.messagePointer("whats.new.action.custom.text", ApplicationNamesInfo.getInstance().fullProductName))
e.presentation.setDescription(IdeBundle.messagePointer("whats.new.action.custom.description", ApplicationNamesInfo.getInstance().fullProductName))
}
@@ -65,7 +55,7 @@ internal class WhatsNewAction : AnAction(), com.intellij.openapi.project.DumbAwa
override fun actionPerformed(e: AnActionEvent) {
val project = e.project
if (project != null) {
project.getScope().launch {
currentThreadCoroutineScope().launch {
openWhatsNewPage(project, e.dataContext, true)
}
} else {
@@ -74,13 +64,4 @@ internal class WhatsNewAction : AnAction(), com.intellij.openapi.project.DumbAwa
}
}
@Service(Service.Level.PROJECT)
private class ScopeProvider(val scope: CoroutineScope)
private fun Project.getScope() = this.service<ScopeProvider>().scope
@Service(Service.Level.APP)
private class AppScopeProvider(val scope: CoroutineScope)
private val appScope: CoroutineScope
get() = service<AppScopeProvider>().scope
private val LOG = logger<WhatsNewAction>()
@@ -1,4 +1,4 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.platform.whatsNew
import com.intellij.codeWithMe.ClientId
@@ -10,6 +10,8 @@ import com.intellij.openapi.actionSystem.ActionManager
import com.intellij.openapi.application.ex.ApplicationInfoEx
import com.intellij.openapi.client.ClientKind
import com.intellij.openapi.client.ClientSessionsManager
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.serviceAsync
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.project.Project
import com.intellij.openapi.startup.ProjectActivity
@@ -70,6 +72,14 @@ private class WhatsNewEnvironmentAccessorImpl : WhatsNewEnvironmentAccessor {
}
}
@Service
internal class WhatsNewStatus {
private val isContentAvailableFlag = AtomicBoolean()
var isContentAvailable: Boolean
get() = isContentAvailableFlag.get()
set(value) = isContentAvailableFlag.set(value)
}
internal class WhatsNewShowOnStartCheckService(private val environment: WhatsNewEnvironmentAccessor) : ProjectActivity {
@Suppress("unused") // used by the component container
constructor() : this(WhatsNewEnvironmentAccessorImpl())
@@ -87,6 +97,7 @@ internal class WhatsNewShowOnStartCheckService(private val environment: WhatsNew
val content = environment.getWhatsNewContent()
logger.info("Got What's New content: $content")
if (content != null) {
serviceAsync<WhatsNewStatus>().isContentAvailable = content.isAvailable()
if (WhatsNewContentVersionChecker.isNeedToShowContent(content).also { logger.info("Should show What's New: $it") }) {
val whatsNewAction = environment.findAction()
if (whatsNewAction != null) {