Skip to content

Conversation

@andrewyuq
Copy link
Contributor

@andrewyuq andrewyuq commented Oct 10, 2024

  1. The configurable actions are added to the official release regardless(i.e. seeing them in the keymap), the difference is that for treatment group users they will be able to use the new configurable actions while the control group won't be able to use them.
  2. Create mutliple xxxNew classes that will be used for new auto-trigger UX, old UX will continue to use the classes without the New suffix.

Types of changes

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

Description

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.

@andrewyuq andrewyuq requested review from a team as code owners October 10, 2024 23:18
@andrewyuq andrewyuq force-pushed the auto-trigger-review branch from bd19e86 to db17201 Compare October 10, 2024 23:21
@andrewyuq andrewyuq force-pushed the auto-trigger-review branch from 54710a6 to d994940 Compare October 11, 2024 18:34
if (CodeWhispererFeatureConfigService.getInstance().getNewAutoTriggerUX()) {
CodeWhispererInvocationStatusNew.getInstance().documentChanged()
} else {
CodeWhispererInvocationStatus.getInstance().documentChanged()
Copy link
Contributor

Choose a reason for hiding this comment

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

for all these singleton service, I think we can do

fun getInstance(): CodeWhispererService = if (newUX) CodeWhispererServiceNew.getInstance() else service()

Copy link
Contributor Author

@andrewyuq andrewyuq Oct 14, 2024

Choose a reason for hiding this comment

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

CodeWhispererServiceNew.getInstance() is of type CodeWhispererServiceNew, so the getInstance() will have a type of Any then

val manager = CodeWhispererCodeReferenceManager.getInstance(sessionContext.project)
manager.insertCodeReference(states, previews, sessionContext.selectedIndex)
manager.addListeners(sessionContext.editor)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

https://github.com/aws/aws-toolkit-jetbrains/pull/4961/files#diff-1ab0dd85b16f44cfa6d69aa50fb4e94ae80cb9b76a3e9245b7fc93b1f3b29b82R717-R723

since we have the new implementation in the existing class, shouldnt we just use the existing CodeWhispererCodeReferenceActionListener above and override?

Copy link
Contributor

@rli rli left a comment

Choose a reason for hiding this comment

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

i see lots of code that appears duplicate between old/new so it is difficult to figure out what is new and what is just the same logic but referencing new objects

Comment on lines +35 to +51
if (!(
if (CodeWhispererFeatureConfigService.getInstance().getNewAutoTriggerUX()) {
CodeWhispererServiceNew.getInstance().canDoInvocation(editor, CodewhispererTriggerType.OnDemand)
} else {
CodeWhispererService.getInstance().canDoInvocation(editor, CodewhispererTriggerType.OnDemand)
}
)
) {
return
}

val triggerType = TriggerTypeInfo(CodewhispererTriggerType.OnDemand, CodeWhispererAutomatedTriggerType.Unknown())
val job = CodeWhispererService.getInstance().showRecommendationsInPopup(editor, triggerType, latencyContext)
val job = if (CodeWhispererFeatureConfigService.getInstance().getNewAutoTriggerUX()) {
CodeWhispererServiceNew.getInstance().showRecommendationsInPopup(editor, triggerType, latencyContext)
} else {
CodeWhispererService.getInstance().showRecommendationsInPopup(editor, triggerType, latencyContext)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

can avoid working around typecast issues if you declare a common interface

Copy link
Contributor

Choose a reason for hiding this comment

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

when can we get rid of this file? it should be possible to have all sigv4/bearer coexist. ideally streamining/non-streaming can share clients too

}
}

fun getMatchingSymbolsFromRecommendation(
Copy link
Contributor

Choose a reason for hiding this comment

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

if it's not too hard can you pull out the common code so there's less delta and risk

import java.util.Queue

@Service
class CodeWhispererTelemetryServiceNew {
Copy link
Contributor

Choose a reason for hiding this comment

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

doesn't telemetry will share most of the same logic and only have some new param, if only function parameters are different we can just have overloads

Comment on lines +119 to +120
CodeWhispererPopupManager.CODEWHISPERER_USER_ACTION_PERFORMED,
object : CodeWhispererUserActionListener {
Copy link
Contributor

@Will-ShaoHua Will-ShaoHua Oct 14, 2024

Choose a reason for hiding this comment

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

looks like these 2 lines are shared, so we just need one listener with 2 afterAccept?

Comment on lines +123 to +128
if (CodeWhispererFeatureConfigService.getInstance().getNewAutoTriggerUX()) {
CodeWhispererInvocationStatusNew.getInstance().hasExistingServiceInvocation()
} else {
CodeWhispererInvocationStatus.getInstance().hasExistingServiceInvocation()
}
) {
Copy link
Contributor

@Will-ShaoHua Will-ShaoHua Oct 14, 2024

Choose a reason for hiding this comment

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

same here if we can do

fun getInstqaonce() = if (newUX) CodeWhispererInvocationStatusNew.getInstance() else service()

code here won't need to be changed and can be as it is

CodeWhispererInvocationStatus.getInstance().hasExistingServiceInvocation()

if (CodeWhispererFeatureConfigService.getInstance().getNewAutoTriggerUX()) {
CodeWhispererTelemetryServiceNew.getInstance().previousUserTriggerDecision
} else {
CodeWhispererTelemetryService.getInstance().previousUserTriggerDecision
Copy link
Contributor

Choose a reason for hiding this comment

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

i feel telemetryService can be shared, and have likely maintain 2 previousUserTriggerDecision

class CwsprTelemetryService {
      private val previousUserTriggerDecisionOld: Queue<Decision>
      private val previousUserTrigerDecisionNew: Queue<Decision>
     

     val previousUserTriggerDecision: Decision
               get() {
                      if (newUX) {} else {}
                }
}

Comment on lines +82 to +85
if (CodeWhispererFeatureConfigService.getInstance().getNewAutoTriggerUX()) {
CodeWhispererServiceNew.getInstance().canDoInvocation(editor, CodewhispererTriggerType.AutoTrigger)
} else {
CodeWhispererService.getInstance().canDoInvocation(editor, CodewhispererTriggerType.AutoTrigger)
Copy link
Contributor

Choose a reason for hiding this comment

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

same

fun getInstance() = if (newUX) newService.getInstance() else service()

then we won't need change here

CodeWhispererService.getInstance().canDoInvocation(editor, CodewhispererTriggerType.AutoTrigger)

Comment on lines +22 to +25
if (CodeWhispererFeatureConfigService.getInstance().getNewAutoTriggerUX()) {
CodeWhispererServiceNew.getInstance().showRecommendationsInPopup(editor, triggerTypeInfo, latencyContext)
} else {
CodeWhispererService.getInstance().showRecommendationsInPopup(editor, triggerTypeInfo, latencyContext)
Copy link
Contributor

Choose a reason for hiding this comment

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

same

fun getInstance() = if (newUX) newService.getInstance() else service()

then we won't need change here

CodeWhispererService.getInstance().showRecommendationsInPopup(...)

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

QDJVMC found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@andrewyuq
Copy link
Contributor Author

andrewyuq commented Oct 17, 2024

Most of the comments are around refactoring old/new classses into having a common interface and implementations to implement the diffs, there's some work for the refactor, will be pushing the current version as is since it also does the job and revisit the refactor later

@andrewyuq andrewyuq enabled auto-merge (squash) October 17, 2024 19:29
@andrewyuq andrewyuq merged commit 12e7803 into aws:main Oct 17, 2024
12 of 13 checks passed
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.

3 participants