Skip to content

Conversation

@evanliu048
Copy link
Contributor

@evanliu048 evanliu048 commented Apr 10, 2025

Problem

On IDE startup, QRegionProfileManager loads the active profile from aws.xml.
However, validateProfile() is called before SSO reauth completes, causing listRegionProfiles() to return empty. This results in the active profile being reset to null.

Fix

Update getIdcConnectionOrNull() to return the connection only if it's a valid Q connection and the token is authorized.
Also, after successful reauth, immediately show the Q panel to avoid triggering the profile selection flow.

Summary

  • Skip profile validation when token isn't ready
  • Ensure Q panel appears after reauth

Changes

  • Refined getIdcConnectionOrNull() to check for BearerTokenAuthState.AUTHORIZED

This should improve the IDE startup flow for users who rely on SSO, reducing friction and avoiding false-positive "profile selection required" states.

Checklist

  • My code follows the code style of this project
  • I have added tests to cover my changes
  • A short description of the change has been added to the CHANGELOG if the change is customer-facing in the IDE.
  • I have added metrics for my changes (if required)

License

I confirm that my contribution is made under the terms of the Apache 2.0 license.

@evanliu048 evanliu048 requested review from a team as code owners April 10, 2025 03:31
Copy link
Contributor

@rli rli left a comment

Choose a reason for hiding this comment

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

this is probably worth a test case

if (connection is AwsBearerTokenConnection && !connection.isSono()) {
return connection
val manager = ToolkitConnectionManager.getInstance(project)
val connection = manager.activeConnectionForFeature(QConnection.getInstance()) as? AwsBearerTokenConnection
Copy link
Contributor

Choose a reason for hiding this comment

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

i think at this point we need to completely remove CodeWhispererConnection if we are assuming everything is now QConnection

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I may be missing part of the context, but I believe I'm using QConnection here—let me know if I'm misunderstanding anything

Copy link
Contributor

Choose a reason for hiding this comment

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

because there was a old CodeWhispererConnection.kt before QConnection came in, so ideally we will check both connection for backward compatiblity. You can check isQConnected. I am in favor of removing codewhispererConnection as it would be a burden to check 2 connection type everywhere and considering we've been using Q_Scope for roughly 1 year, it shouldn't harm to remove CwsprConnection. I can follow up on the cwspr connectin deprecation if @rli you don't have concern about the deprecation

Copy link
Contributor Author

@evanliu048 evanliu048 Apr 10, 2025

Choose a reason for hiding this comment

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

Thanks for the clarification Will. We would need a separate pr to handle the codewhisperer connection deprecation right

Copy link
Contributor

Choose a reason for hiding this comment

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

yes

@rli rli merged commit 1a57043 into aws:main Apr 10, 2025
11 of 14 checks passed
rli pushed a commit that referenced this pull request Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants