-
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 1 commit
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,57 @@ | ||
// 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.CodeWhispererConnection | ||
|
||
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 | ||
|
||
override fun update(e: AnActionEvent) { | ||
val project = e.project | ||
// disable if user is IdC | ||
|
||
rli marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
if (project == null) { | ||
e.presentation.isEnabledAndVisible = false | ||
} else { | ||
e.presentation.isEnabledAndVisible = (ToolkitConnectionManager.getInstance(project).activeConnectionForFeature(QConnection.getInstance()) as? AwsBearerTokenConnection).isSono() | ||
} | ||
} | ||
|
||
override fun actionPerformed(e: AnActionEvent) { | ||
val project = e.project ?: return | ||
currentThreadCoroutineScope().launch { | ||
Check warning on line 39 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 -> | ||
if (ex != null) { | ||
LOG.error(ex) { "Failed aws/chat/manageSubscription" } | ||
} | ||
}.await() | ||
} | ||
} | ||
|
||
companion object { | ||
private val LOG = getLogger<ManageSubscription>() | ||
} | ||
} |
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