Skip to content

Conversation

@samgst-amazon
Copy link
Contributor

The user will be provided with an option to Dismiss the message. Once a user has clicked on Dismiss in any of the UI components, they will not be shown the same notification again.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Description

To keep a track of which notifications are not shown again, notification ids of these messages will be stored to the aws.xml file(persistent storage). This set is retrieved while processing notifications and used to filter out previously dismissed notifications from being further processed and shown.

Checklist

  • My code follows the code style of this project
  • I have added tests to cover my changes
  • A short description of the change has been added to the CHANGELOG if the change is customer-facing in the IDE.
  • I have added metrics for my changes (if required)

License

I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions
Copy link

github-actions bot commented Nov 26, 2024

Qodana Community for JVM

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at [email protected]

?: Pair(emptyList(), emptyList())

val dismissalState = NotificationDismissalState.getInstance()
(if (isStartup) startupNotifications else emptyList())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this part handle the fact that startup notifications should be shown only once per session?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can we move the handling into separate list handling for readability

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes and yes, I was passing the boolean in from the polling service but I think the flag can live here instead.

@samgst-amazon samgst-amazon changed the base branch from feature/ideNotifs to samgst/ideNotifs-polling November 26, 2024 02:19
@samgst-amazon samgst-amazon changed the base branch from samgst/ideNotifs-polling to samgst/notificationPolling November 26, 2024 02:20
@samgst-amazon samgst-amazon marked this pull request as ready for review November 26, 2024 02:25
@samgst-amazon samgst-amazon requested a review from a team as a code owner November 26, 2024 02:25
createNotificationExpiringAction(
object : AnAction("Dismiss") {
override fun actionPerformed(e: AnActionEvent) {
ProcessNotificationsBase.showBannerNotification.remove(id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

state should not be stored in companion objects

private val project: Project,
) {
private val notifListener = mutableListOf<NotifListener>()
private var isStartup: AtomicBoolean = AtomicBoolean(true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't you want startup notifications to propagate consistently across all projects on startup?

Comment on lines 55 to 56
fun getInstance(): NotificationEtagState =
ApplicationManager.getApplication().getService(NotificationEtagState::class.java)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fun getInstance(): NotificationEtagState =
ApplicationManager.getApplication().getService(NotificationEtagState::class.java)
fun getInstance(): NotificationEtagState =
ApplicationManager.getApplication().getService<NotificationEtagState>()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting a syntax error when I do this. I think this is for newer versions of Intellij SDK. I don't see any other usages of the bottom code in our repository, but I do see the ::class.java version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you try using getInstance(): NotificationETagState = service()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that works!

notifications?.let { notificationsList ->
val (startupNotifications, emergencyNotifications) = notificationsList.notifications
?.partition { notification ->
notification.schedule.type.equals("StartUp", ignoreCase = true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be modeled in the deserializer

Comment on lines 23 to 24
<applicationService serviceImplementation="software.aws.toolkits.jetbrains.core.notifications.NotificationEtagState"/>
<applicationService serviceImplementation="software.aws.toolkits.jetbrains.core.notifications.NotificationDismissalState"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these can be light services


@State(name = "notificationDismissals", storages = [Storage("aws.xml")])
class NotificationDismissalState : PersistentStateComponent<NotificationDismissalConfiguration> {
private var state = NotificationDismissalConfiguration()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

val


@State(name = "notificationEtag", storages = [Storage("aws.xml")])
class NotificationEtagState : PersistentStateComponent<NotificationEtagConfiguration> {
private var state = NotificationEtagConfiguration()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

val

import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage

@State(name = "notificationDismissals", storages = [Storage("aws.xml")])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider using BaseState

Comment on lines +117 to +122
// Create a custom deserializer if needed
class NotificationTypeDeserializer : JsonDeserializer<NotificationScheduleType>() {
override fun deserialize(p: JsonParser, ctxt: DeserializationContext): NotificationScheduleType =
NotificationScheduleType.fromString(p.valueAsString)
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not convinced we actually need a custom deserializer but ok

@samgst-amazon samgst-amazon merged commit 26caf31 into samgst/notificationPolling Nov 27, 2024
1 of 7 checks passed
@samgst-amazon samgst-amazon deleted the samgst/notificationStates branch November 27, 2024 00:28
samgst-amazon added a commit that referenced this pull request Nov 27, 2024
* 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
samgst-amazon added a commit that referenced this pull request Nov 29, 2024
* 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

* fix isFirstPoll not setting to false on first pass

---------

Co-authored-by: aws-toolkit-automation <[email protected]>
Co-authored-by: manodnyab <[email protected]>
Co-authored-by: Bryce Ito <[email protected]>
bryceitoc9 added a commit that referenced this pull request Nov 30, 2024
* 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 <[email protected]>
Co-authored-by: manodnyab <[email protected]>
Co-authored-by: Bryce Ito <[email protected]>
karanA-aws pushed a commit to karanA-aws/aws-toolkit-jetbrains that referenced this pull request Jan 17, 2025
* Add framework for processing notifications (aws#5112)

* Add deserialization for notification messages retrieved from the notification file and criteria on whether it should be displayed (aws#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(aws#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 (aws#5136)

* Poll for new notifications (aws#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  (aws#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 (aws#5138)

* add logs for polling and processing notifs

* redundant

* finish log

* fix isFirstPoll not setting to false on first pass

---------

Co-authored-by: aws-toolkit-automation <[email protected]>
Co-authored-by: manodnyab <[email protected]>
Co-authored-by: Bryce Ito <[email protected]>
karanA-aws pushed a commit to karanA-aws/aws-toolkit-jetbrains that referenced this pull request Jan 17, 2025
* Add framework for processing notifications (aws#5112)

* Add deserialization for notification messages retrieved from the notification file and criteria on whether it should be displayed (aws#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(aws#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 (aws#5136)

* Poll for new notifications (aws#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  (aws#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 (aws#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 <[email protected]>
Co-authored-by: manodnyab <[email protected]>
Co-authored-by: Bryce Ito <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants