Skip to content

Commit 6c73a33

Browse files
committed
start lsp node process regardless chat project context is enabled or not
1 parent 8577d78 commit 6c73a33

File tree

3 files changed

+25
-29
lines changed

3 files changed

+25
-29
lines changed

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/startup/AmazonQStartupActivity.kt

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import software.aws.toolkits.jetbrains.core.gettingstarted.emitUserState
1818
import software.aws.toolkits.jetbrains.services.amazonq.toolwindow.AmazonQToolWindow
1919
import software.aws.toolkits.jetbrains.services.amazonq.toolwindow.AmazonQToolWindowFactory
2020
import software.aws.toolkits.jetbrains.services.codewhisperer.explorer.CodeWhispererExplorerActionManager
21-
import software.aws.toolkits.jetbrains.services.codewhisperer.settings.CodeWhispererSettings
2221
import software.aws.toolkits.jetbrains.services.cwc.editor.context.project.ProjectContextController
2322
import java.lang.management.ManagementFactory
2423
import java.time.Duration
@@ -50,26 +49,24 @@ class AmazonQStartupActivity : ProjectActivity {
5049
// Automatically start the project context LSP after some delay when average CPU load is below 30%.
5150
// The CPU load requirement is to avoid competing with native JetBrains indexing and other CPU expensive OS processes
5251
// In the future we will decouple LSP start and indexing start to let LSP perform other tasks.
53-
if (CodeWhispererSettings.getInstance().isProjectContextEnabled()) {
54-
val startLspIndexingDuration = Duration.ofMinutes(30)
55-
project.waitForSmartMode()
56-
try {
57-
withTimeout(startLspIndexingDuration) {
58-
while (true) {
59-
val cpuUsage = ManagementFactory.getOperatingSystemMXBean().systemLoadAverage
60-
if (cpuUsage > 0 && cpuUsage < 30) {
61-
ProjectContextController.getInstance(project = project)
62-
break
63-
} else {
64-
delay(60_000) // Wait for 60 seconds
65-
}
52+
val startLspIndexingDuration = Duration.ofMinutes(30)
53+
project.waitForSmartMode()
54+
try {
55+
withTimeout(startLspIndexingDuration) {
56+
while (true) {
57+
val cpuUsage = ManagementFactory.getOperatingSystemMXBean().systemLoadAverage
58+
if (cpuUsage > 0 && cpuUsage < 30) {
59+
ProjectContextController.getInstance(project = project)
60+
break
61+
} else {
62+
delay(60_000) // Wait for 60 seconds
6663
}
6764
}
68-
} catch (e: TimeoutCancellationException) {
69-
LOG.warn { "Failed to start LSP server due to time out" }
70-
} catch (e: Exception) {
71-
LOG.warn { "Failed to start LSP server" }
7265
}
66+
} catch (e: TimeoutCancellationException) {
67+
LOG.warn { "Failed to start LSP server due to time out" }
68+
} catch (e: Exception) {
69+
LOG.warn { "Failed to start LSP server" }
7370
}
7471
}
7572

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/editor/context/project/ProjectContextProvider.kt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,14 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
4040
private val mapper = jacksonObjectMapper()
4141
init {
4242
cs.launch {
43-
if (CodeWhispererSettings.getInstance().isProjectContextEnabled()) {
44-
while (true) {
45-
if (encoderServer.isNodeProcessRunning()) {
46-
// TODO: need better solution for this
47-
delay(10000)
48-
initAndIndex()
49-
break
50-
} else {
51-
yield()
52-
}
43+
while (true) {
44+
if (encoderServer.isNodeProcessRunning()) {
45+
// TODO: need better solution for this
46+
delay(10000)
47+
initAndIndex()
48+
break
49+
} else {
50+
yield()
5351
}
5452
}
5553
}
@@ -130,6 +128,7 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
130128
}
131129

132130
fun index(): Boolean {
131+
if (!CodeWhispererSettings.getInstance().isProjectContextEnabled()) return false
133132
val projectRoot = project.guessProjectDir()?.path ?: return false
134133

135134
val indexStartTime = System.currentTimeMillis()

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/SupplementalContextStrategy.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ enum class UtgStrategy : SupplementalContextStrategy {
2121
enum class CrossFileStrategy : SupplementalContextStrategy {
2222
OpenTabsBM25,
2323
Empty,
24-
ProjectContext
24+
ProjectContext,
2525
;
2626

2727
override fun toString() = when (this) {

0 commit comments

Comments
 (0)