Skip to content

fix(amazonq): fix Q toolwindow potentially shows the wrong content #5598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type" : "bugfix",
"description" : "Fix issue where user can become stuck because Amazon Q Chat does not show authentication prompt"
}
Original file line number Diff line number Diff line change
@@ -99,7 +99,7 @@ class AmazonQToolWindowFactory : ToolWindowFactory, DumbAware {
override fun onProfileSelected(myProject: Project, profile: QRegionProfile?) {
if (project.isDisposed) return
AmazonQToolWindow.getInstance(project).disposeAndRecreate()
qPanel.setContent(AmazonQToolWindow.getInstance(project).component)
prepareChatContent(project, qPanel)
}
}
)
Original file line number Diff line number Diff line change
@@ -82,8 +82,9 @@ class QRegionProfileManager : PersistentStateComponent<QProfileState>, Disposabl
// succeeded in listing profiles, but none match selected
// profiles should be null if access denied or connection is not IdC
if (profiles == null || profiles.none { it.arn == selected.arn }) {
invalidateProfile(selected.arn)
// Note that order matters, should switch to null first then invalidateProfile
switchProfile(project, null, intent = QProfileSwitchIntent.Reload)
invalidateProfile(selected.arn)
Comment on lines +85 to +87
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not ideal, will revisit later

Telemetry.amazonq.profileState.use { span ->
span.source(QProfileSwitchIntent.Reload.value)
.amazonQProfileRegion(selected.region)
@@ -164,7 +165,7 @@ class QRegionProfileManager : PersistentStateComponent<QProfileState>, Disposabl
}

private fun invalidateProfile(arn: String) {
val updated = connectionIdToActiveProfile.filterValues { it.arn != arn }
val updated = connectionIdToActiveProfile.filterValues { it != null && it.arn != arn }
connectionIdToActiveProfile.clear()
connectionIdToActiveProfile.putAll(updated)
}