-
Notifications
You must be signed in to change notification settings - Fork 272
fix(amazonq): fix chat input not responding correctly after reauth #5805
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
Conversation
Qodana Community for JVMIt seems all right 👌 No new problems were found according to the checks applied 💡 Qodana analysis was run in the pull request mode: only the changed files were checked Contact Qodana teamContact us at [email protected]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR ensures chat input commands are correctly initialized after reauthentication by sending up-to-date feature flags once the chat UI is ready, and it also refreshes local configuration after credentials are updated.
- Chain
updateConfiguration()
after token credentials update in the LSP auth service - Defer sending quick-action commands to browser until UI is ready, using a new helper method
- Remove hardcoded quick-action array from chat creation to rely on dynamic initialization
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/auth/DefaultAuthCredentialsService.kt | Chain configuration refresh to the credentials update future |
plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jenkins/services/amazonq/webview/BrowserConnector.kt | Add updateQuickActionsInBrowser and call it once the UI is ready |
plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jenkins/services/amazonq/webview/Browser.kt | Remove static quickActionCommands array in favor of dynamic injection |
Comments suppressed due to low confidence (5)
plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/amazonq/webview/BrowserConnector.kt:97
- [nitpick] The newly added imports are not grouped or sorted according to the existing style. Consider organizing and alphabetizing imports to match the project's conventions.
import software.aws.toolkits.jetbrains.services.amazonqCodeScan.auth.isCodeScanAvailable
plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/amazonq/webview/BrowserConnector.kt:558
- [nitpick] Using
slice(0, 2)
introduces a magic number. Consider extracting the slice length into a named constant or adding a comment to clarify why only the first two commands are needed.
const commands = tempConnector.initialQuickActions?.slice(0, 2) || [];
plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/amazonq/webview/Browser.kt:150
- Passing an empty array here may result in no quick actions displayed until the browser receives the updated commands. Consider deferring
createChat
invocation until afterupdateQuickActionsInBrowser
or passing the initial commands to avoid a UI flash with no actions.
quickActionCommands: [],
plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/auth/DefaultAuthCredentialsService.kt:114
- [nitpick] The variable name
future
is generic. Consider renaming to something more descriptive likecredentialsFuture
orupdateFuture
to clarify its purpose.
val future = AmazonQLspService.executeIfRunning(project) { server ->
plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/amazonq/webview/BrowserConnector.kt:538
- The new
updateQuickActionsInBrowser
method contains substantial logic and side effects but has no corresponding unit tests. Adding tests will help prevent regressions.
private fun updateQuickActionsInBrowser(browser: Browser) {
This fixes the chat input not accepting prompts under certain circumstances.
Types of changes
Description
QuickActionGenerator class creates three command groups:
These three groups are returned as an array from hybridChatConnector.initialQuickActions.
When not authenticated, the feature flags are all false. This causes empty command groups in
QuickActionGenerator.ts
. The empty command groups are filtered out from theinitialQuickActions
array. Hardcoding the indexes used results in the errors for the prompt input box which prevents users from submitting anything to Q.By sending these commands after the chat tab is ready instead of at browser initialization, we send the correct feature flags for a user's authenticated connection.
This also synchronizes previously selected Q dev profiles to flare after a reauth.
Checklist
License
I confirm that my contribution is made under the terms of the Apache 2.0 license.