Skip to content

Conversation

andrewyuq
Copy link
Contributor

@andrewyuq andrewyuq commented Sep 25, 2024

  1. Accept (Tab)
  2. Force Accept (Opt + Tab/Opt + Enter)
  3. Navigate to Previous (Opt + [)
  4. Navigate to Next (Opt + ])

Notes:

  1. sessionContext (a new data class in CodeWhispererModel.kt) and isDisplaySessionActive() (checks if we are showing codewhisperer) will be introduced in the following PRs.

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 a review from rli September 25, 2024 19:37
@andrewyuq andrewyuq marked this pull request as ready for review September 25, 2024 19:37
@andrewyuq andrewyuq requested review from a team as code owners September 25, 2024 19:37
<action id="codewhisperer.inline.accept"
class="software.aws.toolkits.jetbrains.services.codewhisperer.actions.CodeWhispererAcceptAction"
text="Accept the Current Inline Suggestion" description="Accept the current inline suggestions">
<keyboard-shortcut keymap="$default" first-keystroke="TAB"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

i'm a bit worried about the interaction between this and the IDE

Copy link
Contributor Author

@andrewyuq andrewyuq Sep 26, 2024

Choose a reason for hiding this comment

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

The logic will be what the promoter does -- when the CW is showing:
CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive()
it will be promoted to CW accept.
Otherwise it will be IDE tab action.

import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererInvocationStatus
import software.aws.toolkits.resources.message

open class CodeWhispererAcceptAction(title: String = message("codewhisperer.inline.accept")) : AnAction(title), DumbAware {
Copy link
Contributor

Choose a reason for hiding this comment

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

make sealed and move the force action here since there is no difference except the key binding?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems like I can't make CodeWhispererAcceptAction as sealed class because I will be getting this error:

Caused by: java.lang.NullPointerException: null cannot be cast to non-null type software.aws.toolkits.jetbrains.services.codewhisperer.actions.CodeWhispererAcceptAction

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.

failing lint
needs will or someone else to ack
probably should target a feature branch instead of main

run {
// TODO: Doesn't reflect dynamically if users change but didn't restart IDE
val shortcut = ActionManager.getInstance().getAction("codewhisperer.inline.navigate.next")
.shortcutSet.shortcuts.first()
Copy link
Contributor

Choose a reason for hiding this comment

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

will throw if user somehow removed shortcut

Copy link
Contributor

@rli rli Oct 3, 2024

Choose a reason for hiding this comment

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

why not

KeymapUtil.getFirstKeyboardShortcutText

or getPrimaryShortcut

Copy link
Contributor Author

Choose a reason for hiding this comment

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

testing

Comment on lines 76 to 80
if (SystemInfo.isMac) {
MacKeymapUtil.getKeyStrokeText(keyStroke, " ", true)
} else {
KeymapUtil.getKeystrokeText(keyStroke)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

do we actually need a space delim?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I tried without space delim it looks a bit weird

Comment on lines +103 to +107
// workaround for certain cases for sometimes the string is not input there
EdtExecutorService.getScheduledExecutorInstance().schedule({
settings.select(configurable, Q_INLINE_KEYBINDING_SEARCH_TEXT)
}, 500, TimeUnit.MILLISECONDS)
Copy link
Contributor

Choose a reason for hiding this comment

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

feels like this should not be required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

last time I checked if I don't have this, it won't input the text in the keymap setting bar, I will try again later

Comment on lines +98 to +100
val settings = DataManager.getInstance().getDataContext(e.source as ActionLink).getData(Settings.KEY) ?: return@link
val configurable: Configurable = settings.find("preferences.keymap") ?: return@link
Copy link
Contributor

Choose a reason for hiding this comment

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

user needs feedback if these are null

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will add a TODO for now, can't think of a best way to inform users failures in this case

)
enabled(invoke)
}.comment(message("aws.settings.codewhisperer.project_context_index_thread.tooltip"))
}.comment(message("aws.settings.codewhisperer.project_context_index_thread.tooltip"), maxLineLength = 47)
Copy link
Contributor

Choose a reason for hiding this comment

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

where does magic number come from

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will just remove it for now.

@andrewyuq andrewyuq changed the base branch from main to auto-trigger-revamp October 3, 2024 20:44
Comment on lines 21 to 24
override fun update(e: AnActionEvent) {
e.presentation.isEnabled = e.project != null && e.getData(CommonDataKeys.EDITOR) != null &&
CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
override fun update(e: AnActionEvent) {
e.presentation.isEnabled = e.project != null && e.getData(CommonDataKeys.EDITOR) != null &&
CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive()
}
override fun update(e: AnActionEvent) {
e.presentation.isEnabled = e.project != null &&
e.getData(CommonDataKeys.EDITOR) != null &&
CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive()
}

Comment on lines 21 to 24
override fun update(e: AnActionEvent) {
e.presentation.isEnabled = e.project != null && e.getData(CommonDataKeys.EDITOR) != null &&
CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

e.project != null && 
    e.getData(CommonDataKeys.EDITOR) != null &&
    CodeWhispererInvocationStatus.getInstance().isDisplaySessionActive()

Comment on lines +29 to +31
ApplicationManager.getApplication().messageBus.syncPublisher(
CodeWhispererPopupManager.CODEWHISPERER_USER_ACTION_PERFORMED
).navigateNext(sessionContext)
Copy link
Contributor

Choose a reason for hiding this comment

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

not related to this PR tho, i feel we could make this messagebus a project level

Copy link
Contributor Author

Choose a reason for hiding this comment

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

prob doesn't matter since we aren't going to have multple display sessions across different projects

@andrewyuq andrewyuq merged commit 34b3435 into aws:auto-trigger-revamp Oct 4, 2024
0 of 8 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