Skip to content

Commit

Permalink
Popup delay addition for code scan issues. (#4436)
Browse files Browse the repository at this point in the history
* Delay for popup for code scan issue by 1.5 seconds to reduce noisy popups during mouse hovers.

* detekt error correction.
  • Loading branch information
ashishrp-aws committed May 8, 2024
1 parent 5763706 commit df6bfa7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.intellij.psi.PsiDocumentManager
import com.intellij.ui.JBColor
import com.intellij.ui.awt.RelativePoint
import com.intellij.ui.components.JBScrollPane
import com.intellij.util.TimeoutUtil.sleep
import icons.AwsIcons
import software.amazon.awssdk.services.codewhispererruntime.model.CodeWhispererRuntimeException
import software.aws.toolkits.core.utils.convertMarkdownToHTML
Expand All @@ -38,6 +39,7 @@ import software.aws.toolkits.jetbrains.services.codewhisperer.language.CodeWhisp
import software.aws.toolkits.jetbrains.services.codewhisperer.language.programmingLanguage
import software.aws.toolkits.jetbrains.services.codewhisperer.telemetry.CodeWhispererTelemetryService
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererColorUtil.getHexString
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererConstants.CODE_SCAN_ISSUE_POPUP_DELAY_IN_SECONDS
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererConstants.CODE_SCAN_ISSUE_TITLE_MAX_LENGTH
import software.aws.toolkits.jetbrains.services.codewhisperer.util.runIfIdcConnectionOrTelemetryEnabled
import software.aws.toolkits.jetbrains.utils.applyPatch
Expand Down Expand Up @@ -378,7 +380,10 @@ class CodeWhispererCodeScanEditorMouseMotionListener(private val project: Projec
// Show popup for only the first issue found.
// Only add popup if the issue is still valid. If the issue has gone stale or invalid because
// the user has made some edits, we don't need to show the popup for the stale or invalid issues.
if (!issuesInRange.first().isInvalid) showPopup(issuesInRange, e)
if (!issuesInRange.first().isInvalid) {
sleep(CODE_SCAN_ISSUE_POPUP_DELAY_IN_SECONDS)
showPopup(issuesInRange, e)
}
}

private data class ScanIssuePopupContext(val issue: CodeWhispererCodeScanIssue, val popup: JBPopup)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ object CodeWhispererConstants {
const val TOTAL_SECONDS_IN_MINUTE: Long = 60L
const val ACCOUNTLESS_START_URL = "accountless"
const val FEATURE_CONFIG_POLL_INTERVAL_IN_MS: Long = 30 * 60 * 1000L // 30 mins
const val CODE_SCAN_ISSUE_POPUP_DELAY_IN_SECONDS: Long = 1500 // 1.5 seconds
const val USING: String = "using"
const val GLOBAL_USING: String = "global using"
const val STATIC: String = "static"
Expand Down

0 comments on commit df6bfa7

Please sign in to comment.