Skip to content

Commit df6bfa7

Browse files
authored
Popup delay addition for code scan issues. (#4436)
* Delay for popup for code scan issue by 1.5 seconds to reduce noisy popups during mouse hovers. * detekt error correction.
1 parent 5763706 commit df6bfa7

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/codescan/listeners/CodeWhispererCodeScanEditorMouseMotionListener.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import com.intellij.psi.PsiDocumentManager
2424
import com.intellij.ui.JBColor
2525
import com.intellij.ui.awt.RelativePoint
2626
import com.intellij.ui.components.JBScrollPane
27+
import com.intellij.util.TimeoutUtil.sleep
2728
import icons.AwsIcons
2829
import software.amazon.awssdk.services.codewhispererruntime.model.CodeWhispererRuntimeException
2930
import software.aws.toolkits.core.utils.convertMarkdownToHTML
@@ -38,6 +39,7 @@ import software.aws.toolkits.jetbrains.services.codewhisperer.language.CodeWhisp
3839
import software.aws.toolkits.jetbrains.services.codewhisperer.language.programmingLanguage
3940
import software.aws.toolkits.jetbrains.services.codewhisperer.telemetry.CodeWhispererTelemetryService
4041
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererColorUtil.getHexString
42+
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererConstants.CODE_SCAN_ISSUE_POPUP_DELAY_IN_SECONDS
4143
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererConstants.CODE_SCAN_ISSUE_TITLE_MAX_LENGTH
4244
import software.aws.toolkits.jetbrains.services.codewhisperer.util.runIfIdcConnectionOrTelemetryEnabled
4345
import software.aws.toolkits.jetbrains.utils.applyPatch
@@ -378,7 +380,10 @@ class CodeWhispererCodeScanEditorMouseMotionListener(private val project: Projec
378380
// Show popup for only the first issue found.
379381
// Only add popup if the issue is still valid. If the issue has gone stale or invalid because
380382
// the user has made some edits, we don't need to show the popup for the stale or invalid issues.
381-
if (!issuesInRange.first().isInvalid) showPopup(issuesInRange, e)
383+
if (!issuesInRange.first().isInvalid) {
384+
sleep(CODE_SCAN_ISSUE_POPUP_DELAY_IN_SECONDS)
385+
showPopup(issuesInRange, e)
386+
}
382387
}
383388

384389
private data class ScanIssuePopupContext(val issue: CodeWhispererCodeScanIssue, val popup: JBPopup)

plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererConstants.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ object CodeWhispererConstants {
6868
const val TOTAL_SECONDS_IN_MINUTE: Long = 60L
6969
const val ACCOUNTLESS_START_URL = "accountless"
7070
const val FEATURE_CONFIG_POLL_INTERVAL_IN_MS: Long = 30 * 60 * 1000L // 30 mins
71+
const val CODE_SCAN_ISSUE_POPUP_DELAY_IN_SECONDS: Long = 1500 // 1.5 seconds
7172
const val USING: String = "using"
7273
const val GLOBAL_USING: String = "global using"
7374
const val STATIC: String = "static"

0 commit comments

Comments
 (0)