Skip to content

Commit c02466e

Browse files
authored
fix(amazonq): fix Q toolwindow potentially shows the wrong content (#5598)
* fix Q toolwindow possibly shows the wrong content * cl * patch * changelog str * test
1 parent 0b592d4 commit c02466e

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "Fix issue where user can become stuck because Amazon Q Chat does not show authentication prompt"
4+
}

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/toolwindow/AmazonQToolWindowFactory.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class AmazonQToolWindowFactory : ToolWindowFactory, DumbAware {
9999
override fun onProfileSelected(myProject: Project, profile: QRegionProfile?) {
100100
if (project.isDisposed) return
101101
AmazonQToolWindow.getInstance(project).disposeAndRecreate()
102-
qPanel.setContent(AmazonQToolWindow.getInstance(project).component)
102+
prepareChatContent(project, qPanel)
103103
}
104104
}
105105
)

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/profile/QRegionProfileManager.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ class QRegionProfileManager : PersistentStateComponent<QProfileState>, Disposabl
8282
// succeeded in listing profiles, but none match selected
8383
// profiles should be null if access denied or connection is not IdC
8484
if (profiles == null || profiles.none { it.arn == selected.arn }) {
85-
invalidateProfile(selected.arn)
85+
// Note that order matters, should switch to null first then invalidateProfile
8686
switchProfile(project, null, intent = QProfileSwitchIntent.Reload)
87+
invalidateProfile(selected.arn)
8788
Telemetry.amazonq.profileState.use { span ->
8889
span.source(QProfileSwitchIntent.Reload.value)
8990
.amazonQProfileRegion(selected.region)
@@ -164,7 +165,7 @@ class QRegionProfileManager : PersistentStateComponent<QProfileState>, Disposabl
164165
}
165166

166167
private fun invalidateProfile(arn: String) {
167-
val updated = connectionIdToActiveProfile.filterValues { it.arn != arn }
168+
val updated = connectionIdToActiveProfile.filterValues { it != null && it.arn != arn }
168169
connectionIdToActiveProfile.clear()
169170
connectionIdToActiveProfile.putAll(updated)
170171
}

0 commit comments

Comments
 (0)