-
Notifications
You must be signed in to change notification settings - Fork 275
docs(amazonq): Update autobuild setting strings #5301
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
docs(amazonq): Update autobuild setting strings #5301
Conversation
| val stringValue by map<CodeWhispererStringConfigurationType, String>() | ||
|
|
||
| val projectAutoBuildConfigurationMap by map<String, Boolean>() | ||
| val autoBuildSetting by map<String, Boolean>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs @get:Property like the other properties in here
after release, renaming this will be a breaking change for customers so it is probably worth a test case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the missing @get:Property. Do you have a recommendation on how to test that we aren't renaming a variable? I recognize renaming this would be breaking and is only done now since we are pre-release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh great there are no existing tests on this state component
basic ser/deser tests similar to below should be sufficient coverage:
Lines 297 to 440 in 2e39dc0
| @Test | |
| fun serialize() { | |
| val element = xmlElement( | |
| """ | |
| <component name="codewhispererCustomizationStates"> | |
| </component> | |
| """.trimIndent() | |
| ) | |
| val state = CodeWhispererCustomizationState().apply { | |
| this.previousAvailableCustomizations.putAll( | |
| mapOf( | |
| "fake-sso-url" to mutableListOf("arn_1", "arn_2") | |
| ) | |
| ) | |
| this.connectionIdToActiveCustomizationArn.putAll( | |
| mapOf( | |
| "fake-sso-url" to CodeWhispererCustomization(arn = "arn_2", name = "name_2", description = "description_2") | |
| ) | |
| ) | |
| } | |
| XmlSerializer.serializeInto(state, element) | |
| val actual = XMLOutputter().outputString(element) | |
| val expected = "<component name=\"codewhispererCustomizationStates\">\n" + | |
| "<option name=\"connectionIdToActiveCustomizationArn\">" + | |
| "<map>" + | |
| "<entry key=\"fake-sso-url\">" + | |
| "<value>" + | |
| "<CodeWhispererCustomization>" + | |
| "<option name=\"arn\" value=\"arn_2\" />" + | |
| "<option name=\"name\" value=\"name_2\" />" + | |
| "<option name=\"description\" value=\"description_2\" />" + | |
| "</CodeWhispererCustomization>" + | |
| "</value>" + | |
| "</entry>" + | |
| "</map>" + | |
| "</option>" + | |
| "<option name=\"previousAvailableCustomizations\">" + | |
| "<map>" + | |
| "<entry key=\"fake-sso-url\">" + | |
| "<value>" + | |
| "<list>" + | |
| "<option value=\"arn_1\" />" + | |
| "<option value=\"arn_2\" />" + | |
| "</list>" + | |
| "</value>" + | |
| "</entry>" + | |
| "</map>" + | |
| "</option>" + | |
| "</component>" | |
| assertThat(actual).isEqualTo(expected) | |
| } | |
| @Test | |
| fun `deserialize empty data`() { | |
| val element = xmlElement( | |
| """ | |
| <component name="codewhispererCustomizationStates"> | |
| </component> | |
| """ | |
| ) | |
| val actual = XmlSerializer.deserialize(element, CodeWhispererCustomizationState::class.java) | |
| assertThat(actual.connectionIdToActiveCustomizationArn).hasSize(0) | |
| assertThat(actual.previousAvailableCustomizations).hasSize(0) | |
| } | |
| @Test | |
| fun `deserialize users choosing a customization`() { | |
| val element = xmlElement( | |
| """ | |
| <component name="codewhispererCustomizationStates"> | |
| <option name="connectionIdToActiveCustomizationArn"> | |
| <map> | |
| <entry key="fake-sso-url"> | |
| <value> | |
| <CodeWhispererCustomization> | |
| <option name="arn" value="arn_2" /> | |
| <option name="name" value="name_2" /> | |
| <option name="description" value="description_2" /> | |
| </CodeWhispererCustomization> | |
| </value> | |
| </entry> | |
| </map> | |
| </option> | |
| <option name="previousAvailableCustomizations"> | |
| <map> | |
| <entry key="fake-sso-url"> | |
| <value> | |
| <list> | |
| <option value="arn_1" /> | |
| <option value="arn_2" /> | |
| <option value="arn_3" /> | |
| </list> | |
| </value> | |
| </entry> | |
| </map> | |
| </option> | |
| </component> | |
| """ | |
| ) | |
| val actual = XmlSerializer.deserialize(element, CodeWhispererCustomizationState::class.java) | |
| assertThat(actual.connectionIdToActiveCustomizationArn).hasSize(1) | |
| assertThat(actual.connectionIdToActiveCustomizationArn["fake-sso-url"]).isEqualTo( | |
| CodeWhispererCustomization( | |
| arn = "arn_2", | |
| name = "name_2", | |
| description = "description_2" | |
| ) | |
| ) | |
| assertThat(actual.previousAvailableCustomizations).hasSize(1) | |
| assertThat(actual.previousAvailableCustomizations["fake-sso-url"]).isEqualTo(listOf("arn_1", "arn_2", "arn_3")) | |
| } | |
| @Test | |
| fun `deserialize users choosing default customization`() { | |
| val element = xmlElement( | |
| """ | |
| <component name="codewhispererCustomizationStates"> | |
| <option name="previousAvailableCustomizations"> | |
| <map> | |
| <entry key="fake-sso-url"> | |
| <value> | |
| <list> | |
| <option value="arn_1" /> | |
| <option value="arn_2" /> | |
| <option value="arn_3" /> | |
| </list> | |
| </value> | |
| </entry> | |
| </map> | |
| </option> | |
| </component> | |
| """ | |
| ) | |
| val actual = XmlSerializer.deserialize(element, CodeWhispererCustomizationState::class.java) | |
| assertThat(actual.connectionIdToActiveCustomizationArn).hasSize(0) | |
| assertThat(actual.previousAvailableCustomizations).hasSize(1) | |
| assertThat(actual.previousAvailableCustomizations["fake-sso-url"]).isEqualTo(listOf("arn_1", "arn_2", "arn_3")) | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on another note, doing a map of project -> boolean isnt really the best way to model this.
if you don't want the setting to be application-wide, you should define a new project-level state component so that the setting is saved per-project. right now the implementation looks like it makes a new check box for every project the user opens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The setting is application wide and mirrors the structure that we're able to give in VSCode. I think there is opportunity for improvement in modeling, but I don't think I want to block on that right now. I'd love to learn about where project-level state component and what other features are using it. If we do migrate, we'll implement the logic to import the settings accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pointer on the tests. I've added them here, with an initial focus on our property. I've kept it generic for other teams to be able to contribute more validation there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switching between the two is not exactly trivial so it would be better to get that right now.
the configurable is already set up to support project-level settings so the only difference would be creating a new state service, and you can get rid of the weird map layer
private val codeWhispererProjectSettings
get() = CodeWhispererProjectSettings.getInstance(project) group(message("aws.settings.codewhisperer.feature_development")) {
row {
text(message("aws.settings.codewhisperer.feature_development.allow_running_code_and_test_commands"))
}
row {
checkBox(codeWhispererProjectSettings.getAutoBuildSetting()).apply {
connect.subscribe(
ToolkitConnectionManagerListener.TOPIC,
object : ToolkitConnectionManagerListener {
override fun activeConnectionChanged(newConnection: ToolkitConnection?) {
enabled(isCodeWhispererEnabled(project))
}
}
)
bindSelected(
getter = { codeWhispererProjectSettings.isAutoBuildFeatureEnabled() },
setter = { newValue -> codeWhispererProjectSettings.toggleAutoBuildFeature(newValue) }
)
}
}
} @Service(Level.PROJECT)
@State(name = "codewhispererProejctSettings", storages = [Storage("aws.xml")])
class CodeWhispererProjectSettings(private val project: Project) : PersistentStateComponent<CodeWhispererProjectConfiguration> {
...
}
class CodeWhispererProjectConfiguration : BaseState() {
@get:Property
val autoBuildSetting by property(false)
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can take this as a follow up. Given we're trying to merge the feature branch into main today, I think we'll accept the risk of needing to implement a pathway to import settings from the storage layer from the existing format into a the new format once we migrate to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
Types of changes
Description
Improves the formatting and strings presented to customers when the allow /dev to run code and test commands automatically. Also includes minor variable name changes to improve internal consistency.
Checklist
License
I confirm that my contribution is made under the terms of the Apache 2.0 license.