Skip to content

Conversation

samgst-amazon
Copy link
Contributor

@samgst-amazon samgst-amazon commented Jun 10, 2025

This fixes the chat input not accepting prompts under certain circumstances.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Description

QuickActionGenerator class creates three command groups:

  1. "Q Developer Agent for Software Development" - contains commands like /dev, /doc, /review, /test
  2. "Q Developer Agent for Code Transformation" - contains commands like /transform
  3. "Quick Actions" - contains commands like /help and /clear

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 the initialQuickActions 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

  • 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.

Copy link

github-actions bot commented Jun 10, 2025

Qodana Community for JVM

It 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
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at [email protected]

@samgst-amazon samgst-amazon marked this pull request as ready for review June 10, 2025 19:21
@samgst-amazon samgst-amazon requested review from a team as code owners June 10, 2025 19:21
@andrewyuq andrewyuq requested a review from Copilot June 11, 2025 22:10
Copy link

@Copilot Copilot AI left a 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 after updateQuickActionsInBrowser 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 like credentialsFuture or updateFuture 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) {

@samgst-amazon samgst-amazon merged commit 3a24655 into main Jun 13, 2025
14 of 16 checks passed
@samgst-amazon samgst-amazon deleted the samgst/q-chat-reauth-profile-select-bug branch June 13, 2025 21:20
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.

1 participant