From 46c4a3cdbaf3815a4df24f663ebbe421edf7e66d Mon Sep 17 00:00:00 2001 From: Sam Stewart Date: Sat, 30 Nov 2024 09:36:16 -0800 Subject: [PATCH] Fix notification polling race condition (#5142) * Add framework for processing notifications (#5112) * Add deserialization for notification messages retrieved from the notification file and criteria on whether it should be displayed (#5093) * Display toast notifications with actions * Condition matcher for displaying notifications * Modified deserialization cases and added tests * not required file change * feedback 1 * modified the base class * modified test instance lifecycle * Show toasts for notifications and notification banner on critical notifications(#5097) * Display toast notifications with actions * Condition matcher for displaying notifications * Show notification banner * feedback 1 * Modified deserialization cases and added tests * not required file change * feedback 1 * feedback 1 * modified the base class * merge conflicts resolved * rearranged call site * show notifications when panel is opened * fixed tests * detekt * feedback * convert panels into wrappers * fixed test * Adding update/restart action to notifications (#5136) * Poll for new notifications (#5119) * initial commit * run on startup * detekt * move vals * remote resource implementation * comments * detekt * Validate file before saving * cache path * observer implementation * deserialize notifs from file * detekt * remove unused interface * internal class * Fix observer * etag singleton state component * add telemetry * atomicBoolean * initialize once per IDE startup * code scan * Omit (Unit) * specify etag storage location * detekt * fix detekt issues * basic tests * no star imports * coroutine scope delay instead of thread.sleep * feedback fixes * test fix * Application Exists for tests * endpoint object * detekt * detekt fixes * boolean flag * boolean flag * update tests * move startup flag handling to processBase * fix delay * fix delay * Notification dismissal state tracking (#5129) * split notifications into separated lists. * add persistent notification dismissal state logic * boolean changes * group persistant states * comments * Service initialized automatically * isStartup global * Deserialized notification schedule type * tests * persistent state syntax * convert to light services * Remove state from companion object * detekt * endpoint as registryKey * detekt * fix startup issues * Expiry issues * Add logging info to IDE notification polling and processing (#5138) * add logs for polling and processing notifs * redundant * finish log * show message instead of yesNoDialogue * initialize ProcessNotificationsBase listener before Polling service * fix isFirstPoll not setting to false on first pass --------- Co-authored-by: aws-toolkit-automation <43144436+aws-toolkit-automation@users.noreply.github.com> Co-authored-by: manodnyab <66754471+manodnyab@users.noreply.github.com> Co-authored-by: Bryce Ito --- .../jetbrains/core/notifications/CustomizeNotificationsUi.kt | 4 +--- .../core/notifications/NotificationServiceInitializer.kt | 1 + .../jetbrains/core/notifications/ProcessNotificationsBase.kt | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/CustomizeNotificationsUi.kt b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/CustomizeNotificationsUi.kt index 920ba519ea..ba18c46d60 100644 --- a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/CustomizeNotificationsUi.kt +++ b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/CustomizeNotificationsUi.kt @@ -59,12 +59,10 @@ object NotificationManager { add( NotificationActionList(AwsCoreBundle.message("general.more_dialog")) { if (url == null) { - Messages.showYesNoDialog( + Messages.showMessageDialog( project, message, title, - AwsCoreBundle.message("general.acknowledge"), - AwsCoreBundle.message("general.cancel"), AllIcons.General.Error ) } else { diff --git a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/NotificationServiceInitializer.kt b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/NotificationServiceInitializer.kt index c8b84909ce..150e256379 100644 --- a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/NotificationServiceInitializer.kt +++ b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/NotificationServiceInitializer.kt @@ -13,6 +13,7 @@ internal class NotificationServiceInitializer : ProjectActivity { private val initialized = AtomicBoolean(false) override suspend fun execute(project: Project) { + ProcessNotificationsBase.getInstance(project) if (ApplicationManager.getApplication().isUnitTestMode) return if (initialized.compareAndSet(false, true)) { val service = NotificationPollingService.getInstance() diff --git a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/ProcessNotificationsBase.kt b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/ProcessNotificationsBase.kt index e759d9d079..324a70e3a0 100644 --- a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/ProcessNotificationsBase.kt +++ b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/ProcessNotificationsBase.kt @@ -31,6 +31,7 @@ class ProcessNotificationsBase( ) { private val notifListener = mutableListOf() init { + LOG.info { "Initializing ProcessNotificationsBase" } NotificationPollingService.getInstance().addObserver { retrieveStartupAndEmergencyNotifications() }