-
Notifications
You must be signed in to change notification settings - Fork 274
Polling for new notifications #5110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ons' into manodnyb/checkRulesForNotifications
| /** | ||
| * Loads notifications, preferring the latest downloaded version if available, | ||
| * falling back to bundled resource if no downloaded version exists | ||
| */ | ||
| private fun loadLocalNotifications(): NotificationFile? { | ||
| // First try to load from system directory (latest downloaded version) | ||
| getLocalNotificationsPath().let { path -> | ||
| if (path.exists()) { | ||
| try { | ||
| val content = path.readText() | ||
| return deserializeNotifications(content) | ||
| } catch (e: Exception) { | ||
| LOG.error(e) { "Failed to load downloaded notifications, falling back to bundled resource" } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Fall back to bundled resource if no downloaded version exists | ||
| return try { | ||
| val resourceStream = javaClass.getResourceAsStream(NOTIFICATIONS_RESOURCE_PATH) | ||
| ?: return null | ||
|
|
||
| val content = resourceStream.use { stream -> | ||
| stream.bufferedReader().readText() | ||
| } | ||
|
|
||
| deserializeNotifications(content) | ||
| } catch (e: Exception) { | ||
| LOG.error(e) { "Failed to load notifications from bundled resources" } | ||
| null | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isnt this just the RemoteResource system
Qodana Community for JVM18 new problems were found
💡 Qodana analysis was run in the pull request mode: only the changed files were checked Contact Qodana teamContact us at [email protected]
|
...mmunity/src/software/aws/toolkits/jetbrains/core/notifications/NotificationPollingService.kt
Fixed
Show fixed
Hide fixed
| import com.intellij.openapi.project.Project | ||
| import com.intellij.openapi.startup.ProjectActivity | ||
|
|
||
| class NotificationServiceInitializer : ProjectActivity { |
Check warning
Code scanning / QDJVMC
Extension class should be final and non-public Warning
...mmunity/src/software/aws/toolkits/jetbrains/core/notifications/NotificationPollingService.kt
Fixed
Show fixed
Hide fixed
...mmunity/src/software/aws/toolkits/jetbrains/core/notifications/NotificationPollingService.kt
Fixed
Show fixed
Hide fixed
...mmunity/src/software/aws/toolkits/jetbrains/core/notifications/NotificationPollingService.kt
Fixed
Show fixed
Hide fixed
...mmunity/src/software/aws/toolkits/jetbrains/core/notifications/NotificationPollingService.kt
Fixed
Show fixed
Hide fixed
...mmunity/src/software/aws/toolkits/jetbrains/core/notifications/NotificationPollingService.kt
Fixed
Show fixed
Hide fixed
...mmunity/src/software/aws/toolkits/jetbrains/core/notifications/NotificationPollingService.kt
Fixed
Show fixed
Hide fixed
...mmunity/src/software/aws/toolkits/jetbrains/core/notifications/NotificationPollingService.kt
Fixed
Show fixed
Hide fixed
...mmunity/src/software/aws/toolkits/jetbrains/core/notifications/NotificationPollingService.kt
Fixed
Show fixed
Hide fixed
| } | ||
|
|
||
| @Service(Service.Level.APP) | ||
| class NotificationPollingServiceImpl : |
Check warning
Code scanning / QDJVMC
Extension class should be final and non-public Warning
...mmunity/src/software/aws/toolkits/jetbrains/core/notifications/NotificationPollingService.kt
Fixed
Show fixed
Hide fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QDJVMC found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
…/checkRulesForNotifications
...community/src/software/aws/toolkits/jetbrains/core/notifications/CustomizeNotificationsUi.kt
Fixed
Show fixed
Hide fixed
...ommunity/src/software/aws/toolkits/jetbrains/core/notifications/DisplayToastNotifications.kt
Fixed
Show fixed
Hide fixed
...ommunity/src/software/aws/toolkits/jetbrains/core/notifications/DisplayToastNotifications.kt
Fixed
Show fixed
Hide fixed
...ommunity/src/software/aws/toolkits/jetbrains/core/notifications/DisplayToastNotifications.kt
Fixed
Show fixed
Hide fixed
...community/src/software/aws/toolkits/jetbrains/core/notifications/ProcessNotificationsBase.kt
Fixed
Show fixed
Hide fixed
...re/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/RulesEngine.kt
Fixed
Show fixed
Hide fixed
| * Emits telemetry metric for polling failures | ||
| */ | ||
| private fun emitFailureMetric(exception: Exception?) { | ||
| // todo: add metric |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this already exists in common, we can add this metric
| class NotificationServiceInitializer : ProjectActivity { | ||
|
|
||
| override suspend fun execute(project: Project) { | ||
| val service = ApplicationManager.getApplication().getService(NotificationPollingService::class.java) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use the getInstance method here?
|
|
||
| override suspend fun execute(project: Project) { | ||
| val service = ApplicationManager.getApplication().getService(NotificationPollingService::class.java) | ||
| RunOnceUtil.runOnceForApp(this::class.qualifiedName.toString()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this? Wont the startup activity anyway run just once?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this to explicitly only run once per IDE instance and not per-project. It's what I understood to work, don't know about a better way yet
| * Main polling function that checks for updates and downloads if necessary | ||
| * Returns the parsed notifications if successful, null otherwise | ||
| */ | ||
| private fun pollForNotifications(): Boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add tests for this?
...mmunity/src/software/aws/toolkits/jetbrains/core/notifications/NotificationPollingService.kt
Fixed
Show fixed
Hide fixed
1. Auto-trigger now triggers much more frequently and suggestions will consistently show whenever user stops typing. The key shortcuts for Q inline suggestions are now configurable from the keymap settings. Default key shortcut for force accept is option + tab or option + enter and default for navigation keys has now changed from <- (navigating to prev) and -> (navigating to next) arrow keys to option + [ and option + ] , respectively. 2. Amazon Q suggestions can now co-exist with JetBrains code completions (IntelliSense). When both suggestions appear on the screen, tab accepts JetBrains suggestions first. Users will also have other key shortcuts to force accept the other Q suggestion (option + tab or option + enter) 3. The Amazon Q suggestion popup is now hidden by default and only appears above the current editing line when the user hovers over the suggestion preview text. IntelliSense popup (if it's showing) will also appear to be more transparent when user hovers over the suggestion preview.
| startTime = endTime | ||
| val requestId = response.responseMetadata().requestId() | ||
| val sessionId = response.sdkHttpResponse().headers().getOrDefault(KET_SESSION_ID, listOf(requestId))[0] | ||
| if (requestCount == 1) { |
Check warning
Code scanning / QDJVMC
Constant conditions Warning
| LOG.debug { "Skipping sending remaining requests on inactive CodeWhisperer session exit" } | ||
| return | ||
| } | ||
| if (requestCount >= PAGINATION_REQUEST_COUNT_ALLOWED) { |
Check warning
Code scanning / QDJVMC
Constant conditions Warning
| content = message("codewhisperer.notification.custom.not_available"), | ||
| project = requestContext.project, | ||
| notificationActions = listOf( | ||
| NotificationAction.create( |
Check warning
Code scanning / QDJVMC
Usage of redundant or deprecated syntax or deprecated symbols Warning
| message("codewhisperer.notification.custom.simple.button.select_another_customization") | ||
| ) { _, notification -> | ||
| CodeWhispererModelConfigurator.getInstance().showConfigDialog(requestContext.project) | ||
| notification.expire() |
Check warning
Code scanning / QDJVMC
Usage of redundant or deprecated syntax or deprecated symbols Warning
| displayMessage = e.awsErrorDetails().errorMessage() ?: message("codewhisperer.trigger.error.server_side") | ||
| } else if (e is CodeWhispererRuntimeException) { | ||
| requestId = e.requestId().orEmpty() | ||
| sessionId = e.awsErrorDetails().sdkHttpResponse().headers().getOrDefault(KET_SESSION_ID, listOf(requestId))[0] |
Check warning
Code scanning / QDJVMC
Usage of redundant or deprecated syntax or deprecated symbols Warning
| displayMessage = e.awsErrorDetails().errorMessage() ?: message("codewhisperer.trigger.error.server_side") | ||
| } else { | ||
| requestId = "" | ||
| sessionId = "" |
Check warning
Code scanning / QDJVMC
Usage of redundant or deprecated syntax or deprecated symbols Warning
| message("codewhisperer.trigger.error.server_side") | ||
| } else { | ||
| message("codewhisperer.trigger.error.client_side") | ||
| } |
Check warning
Code scanning / QDJVMC
Usage of redundant or deprecated syntax or deprecated symbols Warning
| } | ||
| (newLookup as LookupImpl).component.addMouseHoverListener( | ||
| newLookup, | ||
| object : HoverListener() { |
Check warning
Code scanning / QDJVMC
Unstable API Usage Warning
| } | ||
| (newLookup as LookupImpl).component.addMouseHoverListener( | ||
| newLookup, | ||
| object : HoverListener() { |
Check warning
Code scanning / QDJVMC
Unstable API Usage Warning
| (newLookup as LookupImpl).component.addMouseHoverListener( | ||
| newLookup, | ||
| object : HoverListener() { | ||
| override fun mouseEntered(component: Component, x: Int, y: Int) { |
Check warning
Code scanning / QDJVMC
Unstable API Usage Warning
| ) | ||
| } | ||
|
|
||
| override fun mouseMoved(component: Component, x: Int, y: Int) {} |
Check warning
Code scanning / QDJVMC
Unstable API Usage Warning
| } | ||
|
|
||
| override fun mouseMoved(component: Component, x: Int, y: Int) {} | ||
| override fun mouseExited(component: Component) {} |
Check warning
Code scanning / QDJVMC
Unstable API Usage Warning
| } | ||
|
|
||
| // Helper method to get Path from stored String | ||
| fun getCachedPath(): Path? = |
Check notice
Code scanning / QDJVMC
Class member can have 'private' visibility Note
...community/src/software/aws/toolkits/jetbrains/core/notifications/ProcessNotificationsBase.kt
Fixed
Show fixed
Hide fixed
|
|
||
| package software.aws.toolkits.jetbrains.core.notifications | ||
|
|
||
| import com.fasterxml.jackson.databind.DeserializationFeature |
Check warning
Code scanning / QDJVMC
Unused import directive Warning
| package software.aws.toolkits.jetbrains.core.notifications | ||
|
|
||
| import com.fasterxml.jackson.databind.DeserializationFeature | ||
| import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper |
Check warning
Code scanning / QDJVMC
Unused import directive Warning
| import com.fasterxml.jackson.module.kotlin.readValue | ||
| import com.intellij.openapi.project.Project | ||
| import software.aws.toolkits.core.utils.inputStream | ||
| import java.io.InputStream |
Check warning
Code scanning / QDJVMC
Unused import directive Warning
| import java.nio.file.Path | ||
|
|
||
| object NotificationMapperUtil{ | ||
| val mapper = jacksonObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) |
Check notice
Code scanning / QDJVMC
Function or property has platform type Note
| fun getNotificationsFromFile() { | ||
| // TODO: returns a notification list | ||
| } | ||
| fun getNotificationsFromFile(path: Path): NotificationsList = |
Check notice
Code scanning / QDJVMC
Class member can have 'private' visibility
Types of changes
Implement polling service to check for new notifications from a remote endpoint
Description
Checklist
License
I confirm that my contribution is made under the terms of the Apache 2.0 license.