Skip to content

Conversation

@nkomonen-amazon
Copy link
Contributor

@nkomonen-amazon nkomonen-amazon commented Apr 20, 2025

When certain settings/configs are changed in the IDE, they need to be propagated to the language server.
The settings were the customizationArn, the users opt in preference for telemetry, and some other things.

This PR:

  • Pushes the new customization arn when it is changed. This arn only exists when the user is using the non-default customization, otherwise it is undefined.
    • A small hack needed to be made to explicitly push this change, since by default we utilized the automatic push to the LS when the users settings file changed (eg opt in telemetry). But because customization is not stored in the users settings, we didn't get that for free. See the command aws.amazonq.updateCustomizations which was made to handle this edge case. Which eventually explicitly uses the language server message DidChangeConfigurationNotification
  • Pushes the opt out telemetry setting to the language server
    • Since this setting is stored in the vscode settings json, the push to language server mechanism comes for free under the DidChangeConfigurationNotification message.
  • The Q Auth Profile ARN is a separate config that needed to be handled by a different handler (different from customization), so the function pushConfigUpdate() was created to route the correct config to the correct handler in the LS
    • This uses the message updateConfigurationRequestType which is different from DidChangeConfigurationNotification that the other configs use. This results in a different code path being hit, which is expected.

Some helpful notes:

  • getAmazonQRelatedWorkspaceConfigs() (triggered through DidChangeConfigurationNotification) is the language server side code that parses the config sent by the client/ide. So the client/ide must match the shape expected by the LS. This is an example why optOutTelemetry did not work out of the box, and needed some changes to be consumable by the LS.

  • Treat all work as PUBLIC. Private feature/x branches will not be squash-merged at release time.
  • Your code changes must meet the guidelines in CONTRIBUTING.md.
  • License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@nkomonen-amazon nkomonen-amazon requested review from a team as code owners April 20, 2025 17:41
@github-actions
Copy link

  • This pull request modifies code in src/* but no tests were added/updated.
    • Confirm whether tests should be added or ensure the PR description explains why tests are not required.
  • This pull request implements a feat or fix, so it must include a changelog entry (unless the fix is for an unreleased feature). Review the changelog guidelines.
    • Note: beta or "experiment" features that have active users should announce fixes in the changelog.
    • If this is not a feature or fix, use an appropriate type from the title guidelines. For example, telemetry-only changes should use the telemetry type.

return [
{
customization,
optOutTelemetry: getOptOutPreference() === 'OPTOUT',
Copy link
Contributor

Choose a reason for hiding this comment

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

oh wait this is a boolean? the type they have in the interface vs what is expected to be passed in is so confusing 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

jpinkney-aws and others added 4 commits April 20, 2025 14:28
Just needed to fix the value to match that of the one in configurationUtils.ts

Signed-off-by: nkomonen-amazon <nkomonen@amazon.com>
Problem:

A message was already set up in a previous commit to send the lsp a
message when the Q customization model was changed, but it didn't work
as expected.

Solution:

There are different lsp messages sent to indicate a change in user settings.
For auth Q profile it is one type of Request, and for the customization selection,
it uses a different lsp notification.

Each type of message has its own handler in the language server, so if we send the
message using the wrong message type, it will not be handled correctly since the correct
handler is somewhere else.

The notable handling functions were:
- getAmazonQRelatedWorkspaceConfigs(), where it is part of the handler for `didChangeConfiguration()`
- setupConfigurationListeners(), where it is part of the handler for `onUpdateConfiguration()`

Signed-off-by: nkomonen-amazon <nkomonen@amazon.com>
- Remove some unrelated development related code
- Enable local indexing

Signed-off-by: nkomonen-amazon <nkomonen@amazon.com>
@jpinkney-aws jpinkney-aws merged commit c89997e into aws:feature/hybridChat Apr 20, 2025
18 of 22 checks passed
@nkomonen-amazon nkomonen-amazon deleted the flare-local-context-2 branch April 21, 2025 03:03
await Commands.tryExecute('aws.amazonq.refreshStatusBar')

// hack: triggers amazon q to send the customizations back to flare
await Commands.tryExecute('aws.amazonq.updateCustomizations')
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not call a function instead of a command?

Commands should be avoided, because they are less reliable and less visible if they fail (partly because they tend to be async).

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