Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import com.intellij.openapi.project.DumbAwareAction
import com.intellij.util.messages.Topic
import software.aws.toolkits.jetbrains.services.amazonq.toolwindow.AmazonQToolWindow
import software.aws.toolkits.resources.AmazonQBundle
import software.aws.toolkits.resources.message
import java.util.EventListener

class QRefreshPanelAction : DumbAwareAction(AmazonQBundle.message("amazonq.refresh.panel"), null, AllIcons.Actions.Refresh) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class AmazonQToolWindow private constructor(

val component
get() = chatPanel.component

fun disposeAndRecreate() {
Disposer.dispose(chatPanel)
Copy link
Contributor

@Will-ShaoHua Will-ShaoHua May 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what will happen if we keep creating new panel and they are never disposed, will it cause memory leak (but idk how to test it..)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes we would need to dispose if we are creating new panels

chatPanel = AmazonQPanel(project, scope)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@manodnyab will it help if we assign the new panel first then dispose the stale one?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe not, just tested

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#5729 would fix the crash issue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this part, if 5729 fixes the crash

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.ErrorParams
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.GetSerializedChatResult
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.SEND_CHAT_COMMAND_PROMPT
import software.aws.toolkits.jetbrains.services.amazonq.profile.QRegionProfileDialog
import software.aws.toolkits.jetbrains.services.amazonq.profile.QRegionProfileManager
import software.aws.toolkits.jetbrains.services.amazonq.profile.QRegionProfileSelectedListener
import java.util.UUID
Expand Down Expand Up @@ -140,19 +141,28 @@
val incomingType = params.authFollowupType
val connectionManager = ToolkitConnectionManager.getInstance(project)
try {
connectionManager.activeConnectionForFeature(QConnection.getInstance())?.let {
reauthConnectionIfNeeded(project, it, isReAuth = true)
}
when (incomingType) {
AuthFollowupType.USE_SUPPORTED_AUTH -> {
project.messageBus.syncPublisher(QRegionProfileSelectedListener.TOPIC)
.onProfileSelected(project, QRegionProfileManager.getInstance().activeProfile(project))
val activeProfile = QRegionProfileManager.getInstance().activeProfile(project)

Check warning on line 146 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/flareChat/ChatCommunicationManager.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/flareChat/ChatCommunicationManager.kt#L146

Added line #L146 was not covered by tests
if (activeProfile != null) {
project.messageBus.syncPublisher(QRegionProfileSelectedListener.TOPIC)
.onProfileSelected(project, QRegionProfileManager.getInstance().activeProfile(project))

Check warning on line 149 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/flareChat/ChatCommunicationManager.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/flareChat/ChatCommunicationManager.kt#L148-L149

Added lines #L148 - L149 were not covered by tests
} else {
QRegionProfileDialog(
project,
selectedProfile = null
).show()

Check warning on line 154 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/flareChat/ChatCommunicationManager.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/flareChat/ChatCommunicationManager.kt#L151-L154

Added lines #L151 - L154 were not covered by tests
}

return
}
AuthFollowupType.RE_AUTH,
AuthFollowupType.MISSING_SCOPES,
AuthFollowupType.FULL_AUTH,
-> {
connectionManager.activeConnectionForFeature(QConnection.getInstance())?.let {
reauthConnectionIfNeeded(project, it, isReAuth = true)

Check warning on line 164 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/flareChat/ChatCommunicationManager.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/flareChat/ChatCommunicationManager.kt#L164

Added line #L164 was not covered by tests
}
return
}
else -> {
Expand Down
Loading