-
Notifications
You must be signed in to change notification settings - Fork 272
feat(amazonq): expose 'Manage Subscriptions' action for builder id paid tier #5777
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 all commits
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.jetbrains.services.codewhisperer.actions | ||
|
||
import com.intellij.openapi.actionSystem.ActionUpdateThread | ||
import com.intellij.openapi.actionSystem.AnAction | ||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.intellij.openapi.progress.currentThreadCoroutineScope | ||
import com.intellij.openapi.project.DumbAware | ||
import kotlinx.coroutines.future.await | ||
import kotlinx.coroutines.launch | ||
import org.eclipse.lsp4j.ExecuteCommandParams | ||
import software.aws.toolkits.core.utils.error | ||
import software.aws.toolkits.core.utils.getLogger | ||
import software.aws.toolkits.jetbrains.core.credentials.AwsBearerTokenConnection | ||
import software.aws.toolkits.jetbrains.core.credentials.ToolkitConnectionManager | ||
import software.aws.toolkits.jetbrains.core.credentials.pinning.QConnection | ||
import software.aws.toolkits.jetbrains.core.credentials.sono.isSono | ||
import software.aws.toolkits.jetbrains.services.amazonq.lsp.AmazonQLspService | ||
|
||
class ManageSubscription : AnAction(), DumbAware { | ||
override fun getActionUpdateThread() = ActionUpdateThread.BGT | ||
Check warning on line 23 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/actions/ManageSubscription.kt
|
||
|
||
override fun update(e: AnActionEvent) { | ||
val project = e.project | ||
Check warning on line 26 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/actions/ManageSubscription.kt
|
||
// disable if user is IdC | ||
if (project == null) { | ||
e.presentation.isEnabledAndVisible = false | ||
Check warning on line 29 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/actions/ManageSubscription.kt
|
||
} else { | ||
val connection = ToolkitConnectionManager.getInstance(project) | ||
.activeConnectionForFeature(QConnection.getInstance()) as? AwsBearerTokenConnection | ||
Check warning on line 32 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/actions/ManageSubscription.kt
|
||
|
||
e.presentation.isEnabledAndVisible = connection.isSono() | ||
Check warning on line 34 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/actions/ManageSubscription.kt
|
||
} | ||
} | ||
Check warning on line 36 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/actions/ManageSubscription.kt
|
||
|
||
override fun actionPerformed(e: AnActionEvent) { | ||
val project = e.project ?: return | ||
currentThreadCoroutineScope().launch { | ||
Check warning on line 40 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/actions/ManageSubscription.kt
|
||
Check warningCode scanning / QDJVMC Unstable API Usage Warning
'currentThreadCoroutineScope()' is declared in unstable 'com.intellij.openapi.progress.CoroutinesKt' marked with @ApiStatus.Experimental
|
||
AmazonQLspService.getInstance(project).execute { lsp -> | ||
lsp.workspaceService.executeCommand( | ||
ExecuteCommandParams().apply { | ||
this.command = "aws/chat/manageSubscription" | ||
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. confirming if this works even if auth is not migrated to Flare? Is there any step that would require regular builder id auth? 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. auth is not involved at all extension to Flare: |
||
} | ||
) | ||
}.handleAsync { _, ex -> | ||
Check warning on line 47 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/actions/ManageSubscription.kt
|
||
if (ex != null) { | ||
LOG.error(ex) { "Failed aws/chat/manageSubscription" } | ||
Check warning on line 49 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/actions/ManageSubscription.kt
|
||
} | ||
}.await() | ||
} | ||
} | ||
Check warning on line 53 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/actions/ManageSubscription.kt
|
||
|
||
companion object { | ||
private val LOG = getLogger<ManageSubscription>() | ||
Check warning on line 56 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/actions/ManageSubscription.kt
|
||
} | ||
} |
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.
Why not keep using
add(QSwitchProfilesAction())
?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.
marginally saves some GC cycles because we dont need to construct/gc