Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ import software.aws.toolkits.jetbrains.services.codewhisperer.codescan.CodeWhisp
import software.aws.toolkits.jetbrains.services.codewhisperer.codescan.CodeWhispererCodeScanManager
import software.aws.toolkits.jetbrains.services.codewhisperer.settings.CodeWhispererConfigurable
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererConstants
import software.aws.toolkits.jetbrains.services.cwc.ChatConstants.FOOTER_INFO_LINK_CLICK
import software.aws.toolkits.jetbrains.services.cwc.ChatConstants.RESPONSE_BODY_LINK_CLICK
import software.aws.toolkits.jetbrains.services.cwc.ChatConstants.SOURCE_LINK_CLICK
import software.aws.toolkits.jetbrains.settings.MeetQSettings
import software.aws.toolkits.telemetry.MetricResult
import software.aws.toolkits.telemetry.Telemetry
Expand Down Expand Up @@ -387,16 +390,16 @@ class BrowserConnector(
handleChat(AmazonQChatServer.insertToCursorPosition, enrichedNode)
}

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.

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) }
Comment on lines +393 to +402
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)).

}

CHAT_FILE_CLICK -> {
Expand Down
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.

Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class EditorThemeAdapter {

defaultText = text,
inactiveText = themeColor("TextField.inactiveForeground", default = 0x8C8C8C, darkDefault = 0x808080),
linkText = themeColor("link.foreground", "link", "Link.activeForeground", default = 0x589DF6),
linkText = themeColor("link", "Link.activeForeground", default = 0x589DF6),

background = chatBackground,
border = getBorderColor(currentScheme),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ object ChatConstants {
const val CUSTOMER_MESSAGE_SIZE_LIMIT = 4_000 // Maximum size of the prompt message in characters (actual API limit: 4096)
const val FQN_SIZE_MIN = 1 // Minimum length of fully qualified name in characters (inclusive)
const val FQN_SIZE_LIMIT = 256 // Maximum length of fully qualified name in characters (exclusive, actual API limit: 256)

// UI Message Types (correspond to TypeScript MessageCommand types)
const val FOOTER_INFO_LINK_CLICK = "footer-info-link-click"
const val RESPONSE_BODY_LINK_CLICK = "response-body-link-click"
const val SOURCE_LINK_CLICK = "source-link-click"
}
Loading