-
Notifications
You must be signed in to change notification settings - Fork 273
feat(amazonq): enable @sage, pass feature config to mynahUI #5683
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ import software.aws.toolkits.jetbrains.core.credentials.pinning.QConnection | |
| import software.aws.toolkits.jetbrains.services.amazonq.profile.QRegionProfileManager | ||
| import software.aws.toolkits.jetbrains.services.codewhisperer.customization.CodeWhispererCustomization | ||
| import software.aws.toolkits.jetbrains.utils.isQExpired | ||
|
|
||
| import com.google.gson.Gson | ||
| @Service | ||
| class CodeWhispererFeatureConfigService { | ||
| private val featureConfigs = mutableMapOf<String, FeatureContext>() | ||
|
|
@@ -82,6 +82,17 @@ class CodeWhispererFeatureConfigService { | |
|
|
||
| fun getChatWSContext(): Boolean = getFeatureValueForKey(CHAT_WS_CONTEXT).stringValue() == "TREATMENT" | ||
|
|
||
| // convert into mynahUI parsable string | ||
| // format: '[["key1", {"name":"Feature1","variation":"A","value":true}]]' | ||
| fun getFeatureConfigJsonString(): String { | ||
| val jsonString = featureConfigs.entries.map { (key, value) -> | ||
| "[\"$key\",${Gson().toJson(value)}]" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I use objectMapper here then this function would be blocked on IO forever and webview will never load. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and Gson formatted string happens to match what MynahUI requires. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This data in VSC is a JSON.stringfied(JSON.stringfield(Object)). See https://github.com/aws/aws-toolkit-vscode/blob/bb11bd9a4b498b2129085f43217b6b712dbf8c44/packages/amazonq/src/lsp/chat/webviewProvider.ts#L85. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I implement it in this way then it would stuck at It can also hang at handleMessage function of StreamMessageProducer.java There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder why the key value pairs are not modelled as json in mynah-ui |
||
| } | ||
| return """ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we return jsonstring directly? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No it will fail. I spent 6 hours making it correct. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is trying to deserialize as a typescript MAP on MynahUI end |
||
| '$jsonString' | ||
| """.trimIndent() | ||
| } | ||
|
|
||
| // Get the feature value for the given key. | ||
| // In case of a misconfiguration, it will return a default feature value of Boolean false. | ||
| private fun getFeatureValueForKey(name: String): FeatureValue = | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.