@@ -13,20 +13,25 @@ class SecurityFindingsToolWindowFactory : ToolWindowFactory {
1313 toolWindow.contentManager.addContent(content)
1414 SecurityFindingsService .getInstance(project).toolWindowPanel = panel
1515
16- // Load cached scan results if available — but only if files haven't changed
16+ // Load cached results on background thread to avoid freezing the UI
1717 val projectBasePath = project.basePath
1818 if (projectBasePath != null ) {
19- val cached = ScanCache .load(projectBasePath)
20- if (cached != null && cached.findings.isNotEmpty()) {
21- // Recompute file hashes from the cached file paths and compare
22- val cachedFiles = cached.fileHashes.keys.map { java.io.File (it) }
23- val currentHashes = ScanCache .computeFileHashes(cachedFiles)
24- if (ScanCache .hasFilesChanged(currentHashes, cached.fileHashes)) {
25- panel.setStatus(" Code has changed since last scan. Run a new scan for updated results." )
26- } else {
27- panel.showFindings(cached.findings)
28- panel.setStatus(" Showing ${cached.findings.size} cached finding${if (cached.findings.size != 1 ) " s" else " " } from previous scan" )
29- }
19+ com.intellij.openapi.application.ApplicationManager .getApplication().executeOnPooledThread {
20+ try {
21+ val cached = ScanCache .load(projectBasePath)
22+ if (cached != null && cached.findings.isNotEmpty()) {
23+ val cachedFiles = cached.fileHashes.keys.map { java.io.File (it) }
24+ val currentHashes = ScanCache .computeFileHashes(cachedFiles)
25+ com.intellij.openapi.application.ApplicationManager .getApplication().invokeLater {
26+ if (ScanCache .hasFilesChanged(currentHashes, cached.fileHashes)) {
27+ panel.setStatus(" Code has changed since last scan. Run a new scan for updated results." )
28+ } else {
29+ panel.showFindings(cached.findings)
30+ panel.setStatus(" Showing ${cached.findings.size} cached finding${if (cached.findings.size != 1 ) " s" else " " } from previous scan" )
31+ }
32+ }
33+ }
34+ } catch (_: Exception ) { }
3035 }
3136 }
3237 }
0 commit comments