Skip to content

Conversation

@aseemxs
Copy link
Contributor

@aseemxs aseemxs commented Dec 5, 2025

Types of changes

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

Description

Problem:
External links in Amazon Q chat responses and footer (e.g., in /help command responses) were not opening when clicked in JetBrains IDEs.

Root Cause:
The existing link click handlers (CHAT_LINK_CLICK, CHAT_INFO_LINK_CLICK, CHAT_SOURCE_LINK_CLICK) were broken due to two issues:

  1. Incorrect JSON path: Handlers were delegating to LSP server methods which have empty/no-op implementations
  2. Wrong data extraction: Link URLs needed to be extracted from node.params.link on the client side
  3. Theme color bug: Link color was using link.foreground theme key which resolves to black in some themes

Fix:

  1. BrowserConnector.kt: Modified three link click handlers to:
    • Extract link URL directly from node.params.link
    • Open browser immediately using BrowserUtil.browse() instead of delegating to LSP server
    • Added support for legacy command names (response-body-link-click, footer-info-link-click, source-link-click)
  2. EditorThemeAdapter.kt: Fixed link color to use correct theme key (link instead of link.foreground) so links display in proper blue color
    across all themes
Screen.Recording.2025-12-11.at.1.14.26.PM.mov

Impact:

  • Links in chat responses now open correctly in the system browser
  • Link color now properly respects IntelliJ theme settings (displays as blue instead of black)
  • Cleaner solution using existing code paths rather than adding new infrastructure

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.

Links in chat responses were not opening because:
1. Link URL was being read from wrong JSON path (node.link instead of node.params.link)
2. Was delegating to LSP server which has empty handlers

Now opens browser directly on client side with correct URL extraction.
link.foreground returns black in some themes, use 'link' key instead which has the correct blue color
@aseemxs aseemxs marked this pull request as ready for review December 11, 2025 22:24
Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary diff

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The theme change is intentional - it fixes link styling to make them properly blue/visible. The old lookup was failing to find the right color, so links weren't visually distinguishable. This is part of the overall "fix links" scope since broken styling affects link usability.

}

CHAT_LINK_CLICK -> {
handleChat(AmazonQChatServer.linkClick, node)
Copy link
Contributor

Choose a reason for hiding this comment

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

are there implications to telemetry

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No telemetry impact. Telemetry is sent from the UI side (chat-client) before it reaches BrowserConnector:

// messager.ts

onLinkClick = (params: LinkClickParams): void => {
    this.chatApi.linkClick(params)      // → aws/chat/linkClick (what we handle)
    this.chatApi.telemetry({ ... })     // → telemetry/event (sent separately)
}

The old handleChat(AmazonQChatServer.linkClick, node) forwarded to the LSP server which has empty handlers (onLinkClick() {}). It wasn't contributing to telemetry - just a dead end that never opened the browser.

aseemxs and others added 3 commits December 15, 2025 13:57
- Open browser directly when link click messages are received
- Support both Flare (aws/chat/linkClick) and legacy (response-body-link-click) message formats
- Fix link color by using correct theme key lookup
- Add constants for legacy link click message types
Comment on lines +393 to +402
CHAT_LINK_CLICK, RESPONSE_BODY_LINK_CLICK -> {
node.get("params")?.get("link")?.asText()?.let { BrowserUtil.browse(it) }
}

CHAT_INFO_LINK_CLICK -> {
handleChat(AmazonQChatServer.infoLinkClick, node)
CHAT_INFO_LINK_CLICK, FOOTER_INFO_LINK_CLICK -> {
node.get("params")?.get("link")?.asText()?.let { BrowserUtil.browse(it) }
}

CHAT_SOURCE_LINK_CLICK -> {
handleChat(AmazonQChatServer.sourceLinkClick, node)
CHAT_SOURCE_LINK_CLICK, SOURCE_LINK_CLICK -> {
node.get("params")?.get("link")?.asText()?.let { BrowserUtil.browse(it) }
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 it is ridiculous that we have 6 different messages, all with the same payload format, that ask the client to open a browser link

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rli Agreed on the 6 message types being excessive. Should I create a follow-up issue to consolidate these into a single OPEN_LINK message type?

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 the bigger question is where these new messages came from because i dont see a reference to them outside of vsc/jb

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These UI message types (source-link-click, response-body-link-click, footer-info-link-click) were originally created in VSCode and then ported to JetBrains, creating the same architectural redundancy in both codebases.

Copy link
Contributor

Choose a reason for hiding this comment

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

if these are needed, why don't eclipse and VS have references to this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Eclipse uses a single PluginUtils.handleExternalLinkClick() method that directly calls the platform's browser API. No message types needed - just openURL(new URL(url)).

- Move FOOTER_INFO_LINK_CLICK, RESPONSE_BODY_LINK_CLICK, SOURCE_LINK_CLICK from FlareChatCommands.kt to ChatConstants.kt
- These constants don't follow aws/chat/ prefix pattern and belong with other chat constants
- Update BrowserConnector.kt imports to use ChatConstants
@aseemxs aseemxs requested a review from a team as a code owner December 18, 2025 21:06
aseemxs and others added 8 commits December 18, 2025 13:10
- Move FOOTER_INFO_LINK_CLICK, RESPONSE_BODY_LINK_CLICK, SOURCE_LINK_CLICK from FlareChatCommands.kt to ChatConstants.kt
- These constants don't follow aws/chat/ prefix pattern and belong with other chat constants
- Update BrowserConnector.kt imports to use ChatConstants
- Change Rider sdkVersion from '2025.3-SNAPSHOT' to '2025.3'
- Resolves CI dependency resolution failures
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.

2 participants