Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -26,34 +26,24 @@ class AuthController {
*/
fun getAuthNeededStates(project: Project): AuthNeededStates {
val connectionState = checkBearerConnectionValidity(project, BearerTokenFeatureSet.Q)
val codeWhispererState = checkBearerConnectionValidity(project, BearerTokenFeatureSet.CODEWHISPERER)

// CW chat is enabled for Builder and IDC users, same for Amazon Q
return AuthNeededStates(
chat = getAuthNeededState(connectionState, codeWhispererState),
amazonQ = getAuthNeededState(connectionState, codeWhispererState)
chat = getAuthNeededState(connectionState),
amazonQ = getAuthNeededState(connectionState)
)
}

private fun getAuthNeededState(
amazonqConnectionState: ActiveConnection,
codeWhispererConnectionState: ActiveConnection,
onlyIamIdcConnection: Boolean = false,
): AuthNeededState? =
when (amazonqConnectionState) {
ActiveConnection.NotConnected -> {
if (codeWhispererConnectionState == ActiveConnection.NotConnected) {
AuthNeededState(
message = message("q.connection.disconnected"),
authType = AuthFollowUpType.FullAuth,
)
} else {
// There is a connection for codewhisperer, but it's not valid for Q
AuthNeededState(
message = message("q.connection.need_scopes"),
authType = AuthFollowUpType.MissingScopes,
)
}
AuthNeededState(
message = message("q.connection.disconnected"),
authType = AuthFollowUpType.FullAuth,
)
}

is ActiveConnection.ValidBearer -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@
<typedHandler implementation="software.aws.toolkits.jetbrains.services.codewhisperer.editor.CodeWhispererTypedHandler"/>
<editorActionHandler action="EditorEnter" implementationClass="software.aws.toolkits.jetbrains.services.codewhisperer.editor.CodeWhispererEnterHandler"
order="first, before editorEnter"/>
<actionPromoter order="last" implementation="software.aws.toolkits.jetbrains.services.codewhisperer.actions.CodeWhispererActionPromoter"/>
<fileEditorProvider implementation="software.aws.toolkits.jetbrains.services.codewhisperer.learn.LearnCodeWhispererEditorProvider"/>

<!-- Inline Completion Provider -->
<inline.completion.provider id="amazon.q" implementation="software.aws.toolkits.jetbrains.services.codewhisperer.popup.QInlineCompletionProvider"/>
</extensions>

<extensions defaultExtensionNs="aws.toolkit.core">
Expand Down Expand Up @@ -90,29 +92,6 @@
text="Invoke Amazon Q Inline Suggestions">
<keyboard-shortcut keymap="$default" first-keystroke="alt C"/>
</action>
<action id="codewhisperer.inline.navigate.previous"
class="software.aws.toolkits.jetbrains.services.codewhisperer.actions.CodeWhispererNavigatePrevAction"
text="Navigate to Previous Inline Suggestion" description="Navigate to previous inline suggestion">
<keyboard-shortcut keymap="$default" first-keystroke="alt OPEN_BRACKET"/>
</action>
<action id="codewhisperer.inline.navigate.next"
class="software.aws.toolkits.jetbrains.services.codewhisperer.actions.CodeWhispererNavigateNextAction"
text="Navigate to Next Inline Suggestion" description="Navigate to next inline suggestion">
<keyboard-shortcut keymap="$default" first-keystroke="alt CLOSE_BRACKET"/>
</action>
<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"/>
</action>
<action id="codewhisperer.inline.force.accept"
class="software.aws.toolkits.jetbrains.services.codewhisperer.actions.CodeWhispererForceAcceptAction"
text="Force Accept the Current Amazon Q Suggestion" description="Force accept the current Amazon Q suggestion">
<keyboard-shortcut keymap="Mac OS X" first-keystroke="alt TAB"/>
<keyboard-shortcut keymap="Mac OS X 10.5+" first-keystroke="alt TAB"/>
<keyboard-shortcut keymap="$default" first-keystroke="alt ENTER"/>
</action>


<group id="aws.toolkit.codewhisperer.toolbar.security">
<group id="codewhisperer.toolbar.security.group" icon="AllIcons.Actions.GroupBy" text="Group" popup="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project
import org.jetbrains.annotations.ApiStatus
import software.aws.toolkits.core.utils.getLogger
import software.aws.toolkits.core.utils.warn
import software.aws.toolkits.jetbrains.core.credentials.AwsBearerTokenConnection
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManager
import software.aws.toolkits.jetbrains.core.credentials.pinning.CodeWhispererConnection
import software.aws.toolkits.jetbrains.core.credentials.pinning.QConnection
import software.aws.toolkits.jetbrains.core.credentials.sono.isSono
import software.aws.toolkits.jetbrains.core.credentials.sso.bearer.BearerTokenAuthState
import software.aws.toolkits.jetbrains.core.credentials.sso.bearer.BearerTokenProvider
Expand All @@ -38,7 +35,7 @@ class CodeWhispererExplorerActionManager : PersistentStateComponent<CodeWhispere
}

private fun getCodeWhispererConnectionStartUrl(project: Project): String {
val connection = ToolkitConnectionManager.getInstance(project).activeConnectionForFeature(CodeWhispererConnection.getInstance())
val connection = ToolkitConnectionManager.getInstance(project).activeConnectionForFeature(QConnection.getInstance())
return getConnectionStartUrl(connection) ?: CodeWhispererConstants.ACCOUNTLESS_START_URL
}

Expand Down Expand Up @@ -95,22 +92,8 @@ class CodeWhispererExplorerActionManager : PersistentStateComponent<CodeWhispere
actionState.value[CodeWhispererExploreStateType.IsFirstRestartAfterQInstall] = isFirstRestartAfterQInstall
}

@Deprecated("Accountless credential will be removed soon")
@ApiStatus.ScheduledForRemoval
// Will keep it for existing accountless users
/**
* Will be called from CodeWhispererService.showRecommendationInPopup()
* Caller (e.x. CodeWhispererService) should take care if null value returned, popup a notification/hint window or dialog etc.
*/
fun resolveAccessToken(): String? {
if (actionState.token == null) {
LOG.warn { "Logical Error: Try to get access token before token initialization" }
}
return actionState.token
}

fun checkActiveCodeWhispererConnectionType(project: Project): CodeWhispererLoginType {
val conn = ToolkitConnectionManager.getInstance(project).activeConnectionForFeature(CodeWhispererConnection.getInstance()) as? AwsBearerTokenConnection
val conn = ToolkitConnectionManager.getInstance(project).activeConnectionForFeature(QConnection.getInstance()) as? AwsBearerTokenConnection
return conn?.let {
val provider = (it.getConnectionSettings().tokenProvider.delegate as? BearerTokenProvider) ?: return@let CodeWhispererLoginType.Logout

Expand Down Expand Up @@ -148,7 +131,5 @@ class CodeWhispererExplorerActionManager : PersistentStateComponent<CodeWhispere
companion object {
@JvmStatic
fun getInstance(): CodeWhispererExplorerActionManager = service()

private val LOG = getLogger<CodeWhispererExplorerActionManager>()
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import com.intellij.openapi.util.Key
import kotlinx.coroutines.Job
import software.aws.toolkits.jetbrains.services.amazonq.CodeWhispererFeatureConfigService
import software.aws.toolkits.jetbrains.services.amazonq.profile.QRegionProfileManager
import software.aws.toolkits.jetbrains.services.codewhisperer.model.LatencyContext
import software.aws.toolkits.jetbrains.services.codewhisperer.model.TriggerTypeInfo
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererAutomatedTriggerType
import software.aws.toolkits.jetbrains.services.codewhisperer.popup.QInlineCompletionProvider
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererService
import software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererServiceNew
import software.aws.toolkits.resources.message
Expand All @@ -33,8 +31,6 @@ class CodeWhispererRecommendationAction : AnAction(message("codewhisperer.trigge
if (QRegionProfileManager.getInstance().hasValidConnectionButNoActiveProfile(project)) {
return
}
val latencyContext = LatencyContext()
latencyContext.codewhispererEndToEndStart = System.nanoTime()
val editor = e.getRequiredData(CommonDataKeys.EDITOR)
if (!(
if (CodeWhispererFeatureConfigService.getInstance().getNewAutoTriggerUX()) {
Expand All @@ -47,14 +43,7 @@ class CodeWhispererRecommendationAction : AnAction(message("codewhisperer.trigge
return
}

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

e.getData(CommonDataKeys.EDITOR)?.getUserData(ACTION_JOB_KEY)?.set(job)
QInlineCompletionProvider.invokeCompletion(editor)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import software.aws.toolkits.jetbrains.core.coroutines.EDT
import software.aws.toolkits.jetbrains.core.coroutines.getCoroutineUiContext
import software.aws.toolkits.jetbrains.core.coroutines.projectCoroutineScope
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManager
import software.aws.toolkits.jetbrains.core.credentials.pinning.CodeWhispererConnection
import software.aws.toolkits.jetbrains.core.credentials.pinning.QConnection
import software.aws.toolkits.jetbrains.services.codewhisperer.codescan.listeners.CodeWhispererCodeScanDocumentListener
import software.aws.toolkits.jetbrains.services.codewhisperer.codescan.listeners.CodeWhispererCodeScanEditorMouseMotionListener
import software.aws.toolkits.jetbrains.services.codewhisperer.codescan.listeners.CodeWhispererCodeScanFileListener
Expand Down Expand Up @@ -397,7 +397,7 @@ class CodeWhispererCodeScanManager(val project: Project) {
var codeScanStatus: Result = Result.Failed
val startTime = Instant.now().toEpochMilli()
var codeScanResponseContext = defaultCodeScanResponseContext()
val connection = ToolkitConnectionManager.getInstance(project).activeConnectionForFeature(CodeWhispererConnection.getInstance())
val connection = ToolkitConnectionManager.getInstance(project).activeConnectionForFeature(QConnection.getInstance())
var language: CodeWhispererProgrammingLanguage = CodeWhispererUnknownLanguage.INSTANCE
var skipTelemetry = false
try {
Expand Down
Loading
Loading