Skip to content

Add support for Amazon Q chat on remote 242+ #4825

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

Merged
merged 23 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from 21 commits
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 @@ -3,6 +3,7 @@

import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
import org.jetbrains.intellij.platform.gradle.tasks.PatchPluginXmlTask
import org.jetbrains.intellij.platform.gradle.tasks.aware.SplitModeAware
import software.aws.toolkits.gradle.intellij.IdeFlavor
import software.aws.toolkits.gradle.intellij.toolkitIntelliJ

Expand Down Expand Up @@ -75,3 +76,8 @@ tasks.runIde {
systemProperty("user.home", home)
environment("HOME", home)
}

val runSplitIde by intellijPlatformTesting.runIde.registering {
splitMode = true
splitModeTarget = SplitModeAware.SplitModeTarget.BACKEND
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0

# Toolkit Version
toolkitVersion=3.58-SNAPSHOT
toolkitVersion=3.58-SNAPSHOT-ASBX_TEST_0228
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we revert this?

Copy link
Contributor

Choose a reason for hiding this comment

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

We can probably revert this for now--this is for differentiating the build, and we may need to re-add it (or something equivalent) whenever we ship a new test build.


# Publish Settings
publishToken=
Expand Down
4 changes: 0 additions & 4 deletions plugins/amazonq/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
import software.aws.toolkits.gradle.changelog.tasks.GeneratePluginChangeLog
import software.aws.toolkits.gradle.intellij.IdeFlavor
import software.aws.toolkits.gradle.intellij.IdeVersions
import software.aws.toolkits.gradle.intellij.toolkitIntelliJ

plugins {
id("toolkit-publishing-conventions")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.intellij.ui.dsl.builder.Align
import com.intellij.ui.dsl.builder.panel
import com.intellij.ui.jcef.JBCefJSQuery
import org.cef.CefApp
import software.aws.toolkits.core.utils.error
import software.aws.toolkits.core.utils.getLogger
import software.aws.toolkits.core.utils.warn
Expand All @@ -30,8 +29,8 @@
import software.aws.toolkits.jetbrains.core.region.AwsRegionProvider
import software.aws.toolkits.jetbrains.core.webview.BrowserMessage
import software.aws.toolkits.jetbrains.core.webview.BrowserState
import software.aws.toolkits.jetbrains.core.webview.LocalAssetJBCefRequestHandler
import software.aws.toolkits.jetbrains.core.webview.LoginBrowser
import software.aws.toolkits.jetbrains.core.webview.WebviewResourceHandlerFactory
import software.aws.toolkits.jetbrains.isDeveloperMode
import software.aws.toolkits.jetbrains.services.amazonq.util.createBrowser
import software.aws.toolkits.jetbrains.utils.isQConnected
Expand Down Expand Up @@ -108,25 +107,14 @@
class QWebviewBrowser(val project: Project, private val parentDisposable: Disposable) :
LoginBrowser(
project,
QWebviewBrowser.DOMAIN,
QWebviewBrowser.WEB_SCRIPT_URI
),
Disposable {
// TODO: confirm if we need such configuration or the default is fine
override val jcefBrowser = createBrowser(parentDisposable)
private val query = JBCefJSQuery.create(jcefBrowser)
private val assetHandler = LocalAssetJBCefRequestHandler(jcefBrowser)

Check warning on line 115 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/QLoginWebview.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/QLoginWebview.kt#L115

Added line #L115 was not covered by tests

init {
CefApp.getInstance()
.registerSchemeHandlerFactory(
"http",
domain,
WebviewResourceHandlerFactory(
domain = "http://$domain/",
assetUri = "/webview/assets/"
),
)

loadWebView(query)

query.addHandler(jcefHandler)
Expand Down Expand Up @@ -273,12 +261,15 @@
}

override fun loadWebView(query: JBCefJSQuery) {
jcefBrowser.loadHTML(getWebviewHTML(webScriptUri, query))
val webScriptUri = assetHandler.createResource(
"js/getStart.js",
QWebviewBrowser::class.java.getResourceAsStream("/webview/assets/js/getStart.js")

Check warning on line 266 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/QLoginWebview.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/QLoginWebview.kt#L264-L266

Added lines #L264 - L266 were not covered by tests
)

jcefBrowser.loadURL(assetHandler.createResource("content.html", getWebviewHTML(webScriptUri, query)))

Check warning on line 269 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/QLoginWebview.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/QLoginWebview.kt#L269

Added line #L269 was not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can we assign the file names to consts

}

companion object {
private val LOG = getLogger<QWebviewBrowser>()
private const val WEB_SCRIPT_URI = "http://webview/js/getStart.js"
private const val DOMAIN = "webview"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@
import software.aws.toolkits.jetbrains.services.amazonq.toolwindow.AMAZON_Q_WINDOW_ID
import software.aws.toolkits.jetbrains.services.amazonq.toolwindow.AmazonQToolWindow
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererConstants.runScanKey
import software.aws.toolkits.jetbrains.utils.isRunningOnRemoteBackend
import software.aws.toolkits.resources.message
import software.aws.toolkits.telemetry.UiTelemetry

class QOpenPanelAction : AnAction(message("action.q.openchat.text"), null, AwsIcons.Logos.AWS_Q) {

Check warning on line 17 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/QOpenPanelAction.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

ActionUpdateThread is missing

Override 'getActionUpdateThread' and choose 'EDT' or 'BGT'
override fun actionPerformed(e: AnActionEvent) {
if (isRunningOnRemoteBackend()) return
val project = e.getRequiredData(CommonDataKeys.PROJECT)
UiTelemetry.click(project, "q_openChat")
ToolWindowManager.getInstance(project).getToolWindow(AMAZON_Q_WINDOW_ID)?.activate(null, true)
if (e.getData(runScanKey) == true) {
AmazonQToolWindow.openScanTab(project)
}
}

override fun update(e: AnActionEvent) {
e.presentation.isEnabled = e.getData(CommonDataKeys.PROJECT) != null
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the situation when this option is shown and project is 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.

the action is not available if the project is null

}

Check warning on line 29 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/QOpenPanelAction.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/QOpenPanelAction.kt#L29

Added line #L29 was not covered by tests
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.cef.browser.CefFrame
import org.cef.handler.CefLoadHandlerAdapter
import software.aws.toolkits.jetbrains.core.coroutines.disposableCoroutineScope
import software.aws.toolkits.jetbrains.core.webview.LocalAssetJBCefRequestHandler
import software.aws.toolkits.jetbrains.services.amazonq.toolwindow.AmazonQToolWindow
import software.aws.toolkits.jetbrains.services.amazonq.webview.theme.EditorThemeAdapter
import software.aws.toolkits.resources.message
Expand Down Expand Up @@ -72,7 +73,7 @@

private fun loadWebView() {
// load the web app
jcefBrowser.loadHTML(getWebviewHTML())
jcefBrowser.loadURL(LocalAssetJBCefRequestHandler(jcefBrowser).createResource("content.html", getWebviewHTML()))

Check warning on line 76 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/gettingstarted/QGettingStartedContent.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/gettingstarted/QGettingStartedContent.kt#L76

Added line #L76 was not covered by tests
}

private fun getWebviewHTML(): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package software.aws.toolkits.jetbrains.services.amazonq.toolwindow

import com.intellij.idea.AppMode
import com.intellij.openapi.Disposable
import com.intellij.openapi.util.Disposer
import com.intellij.ui.components.JBTextArea
Expand All @@ -15,6 +14,7 @@
import com.intellij.ui.jcef.JBCefApp
import software.aws.toolkits.jetbrains.isDeveloperMode
import software.aws.toolkits.jetbrains.services.amazonq.webview.Browser
import software.aws.toolkits.jetbrains.utils.isRunningOnRemoteBackend
import java.awt.event.ActionListener
import javax.swing.JButton

Expand Down Expand Up @@ -66,8 +66,8 @@
private fun init() {
if (!JBCefApp.isSupported()) {
// Fallback to an alternative browser-less solution
if (AppMode.isRemoteDevHost()) {
webviewContainer.add(JBTextArea("Amazon Q chat is not supported in remote dev environment."))
if (isRunningOnRemoteBackend()) {
webviewContainer.add(JBTextArea("Amazon Q chat is not supported in this remote dev environment because it lacks JCEF webview support."))

Check warning on line 70 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/toolwindow/AmazonQPanel.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/toolwindow/AmazonQPanel.kt#L70

Added line #L70 was not covered by tests
} else {
webviewContainer.add(JBTextArea("JCEF not supported"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
import com.intellij.openapi.Disposable
import com.intellij.openapi.util.Disposer
import com.intellij.ui.jcef.JBCefJSQuery
import org.cef.CefApp
import software.aws.toolkits.jetbrains.core.webview.LocalAssetJBCefRequestHandler
import software.aws.toolkits.jetbrains.services.amazonq.util.HighlightCommand
import software.aws.toolkits.jetbrains.services.amazonq.util.createBrowser
import software.aws.toolkits.jetbrains.settings.MeetQSettings
import java.nio.file.Paths

/*
Displays the web view for the Amazon Q tool window
Expand All @@ -21,6 +22,17 @@

val receiveMessageQuery = JBCefJSQuery.create(jcefBrowser)

private val assetRequestHandler = LocalAssetJBCefRequestHandler(jcefBrowser)

Check warning on line 25 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/Browser.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/Browser.kt#L25

Added line #L25 was not covered by tests

init {
assetRequestHandler.addWildcardHandler("mynah") { path ->
val asset = path.replaceFirst("mynah/", "/mynah-ui/assets/")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we test this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

follow up later

Paths.get(asset).normalize().toString().replace("\\", "/").let {
this::class.java.getResourceAsStream(it)
}

Check warning on line 32 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/Browser.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/Browser.kt#L27-L32

Added lines #L27 - L32 were not covered by tests
}
}

Check warning on line 34 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/Browser.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/Browser.kt#L34

Added line #L34 was not covered by tests

fun init(
isCodeTransformAvailable: Boolean,
isFeatureDevAvailable: Boolean,
Expand All @@ -29,14 +41,6 @@
isCodeTestAvailable: Boolean,
highlightCommand: HighlightCommand?,
) {
// register the scheme handler to route http://mynah/ URIs to the resources/assets directory on classpath
CefApp.getInstance()
.registerSchemeHandlerFactory(
"http",
"mynah",
AssetResourceHandler.AssetResourceHandlerFactory(),
)

loadWebView(isCodeTransformAvailable, isFeatureDevAvailable, isDocAvailable, isCodeScanAvailable, isCodeTestAvailable, highlightCommand)
}

Expand All @@ -63,9 +67,13 @@
// setup empty state. The message request handlers use this for storing state
// that's persistent between page loads.
jcefBrowser.setProperty("state", "")

// load the web app
jcefBrowser.loadHTML(
getWebviewHTML(isCodeTransformAvailable, isFeatureDevAvailable, isDocAvailable, isCodeScanAvailable, isCodeTestAvailable, highlightCommand)
jcefBrowser.loadURL(
assetRequestHandler.createResource(
"webview/chat.html",
getWebviewHTML(isCodeTransformAvailable, isFeatureDevAvailable, isDocAvailable, isCodeScanAvailable, isCodeTestAvailable, highlightCommand)

Check warning on line 75 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/Browser.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/Browser.kt#L72-L75

Added lines #L72 - L75 were not covered by tests
)
)
}

Expand All @@ -84,7 +92,7 @@
val postMessageToJavaJsCode = receiveMessageQuery.inject("JSON.stringify(message)")

val jsScripts = """
<script type="text/javascript" src="$WEB_SCRIPT_URI" defer onload="init()"></script>
<script type="text/javascript" src="http://toolkitasset/mynah/js/mynah-ui.js" defer onload="init()"></script>
<script type="text/javascript">
const init = () => {
mynahUI.createMynahUI(
Expand Down Expand Up @@ -120,7 +128,6 @@
}

companion object {
private const val WEB_SCRIPT_URI = "http://mynah/js/mynah-ui.js"
private const val MAX_ONBOARDING_PAGE_COUNT = 3
private val OBJECT_MAPPER = jacksonObjectMapper()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@

ApplicationManager.getApplication().invokeAndWait {
selectionRange = ApplicationManager.getApplication().runReadAction<Range?> {
val editor = FileEditorManager.getInstance(project).selectedTextEditor
val editor = FileEditorManager.getInstance(project).selectedTextEditorWithRemotes.firstOrNull()

Check warning on line 133 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/controller/CodeTestChatController.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/controller/CodeTestChatController.kt#L133

Added line #L133 was not covered by tests

Check warning on line 133 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/controller/CodeTestChatController.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'getSelectedTextEditorWithRemotes()' is marked unstable with @ApiStatus.Experimental

Check warning

Code scanning / QDJVMC

Unstable API Usage Warning

'getSelectedTextEditorWithRemotes()' is marked unstable with @ApiStatus.Experimental
Copy link
Contributor

Choose a reason for hiding this comment

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

does this api also work in local ?

editor?.let {
val selectionModel = it.selectionModel
val startOffset = selectionModel.selectionStart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@

withContext(EDT) {
broadcastQEvent(QFeatureEvent.STARTS_EDITING)
val editor: Editor = FileEditorManager.getInstance(context.project).selectedTextEditor ?: return@withContext
val editor: Editor = FileEditorManager.getInstance(context.project).selectedTextEditorWithRemotes.firstOrNull() ?: return@withContext

Check warning on line 210 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/controller/FeatureDevController.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'getSelectedTextEditorWithRemotes()' is marked unstable with @ApiStatus.Experimental

Check warning

Code scanning / QDJVMC

Unstable API Usage Warning

'getSelectedTextEditorWithRemotes()' is marked unstable with @ApiStatus.Experimental

val caret: Caret = editor.caretModel.primaryCaret
val offset: Int = caret.offset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
override suspend fun processInsertCodeAtCursorPosition(message: IncomingCwcMessage.InsertCodeAtCursorPosition) {
broadcastQEvent(QFeatureEvent.STARTS_EDITING)
withContext(EDT) {
val editor: Editor = FileEditorManager.getInstance(context.project).selectedTextEditor ?: return@withContext
val editor: Editor = FileEditorManager.getInstance(context.project).selectedTextEditorWithRemotes.firstOrNull() ?: return@withContext

Check warning on line 212 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/controller/ChatController.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'getSelectedTextEditorWithRemotes()' is marked unstable with @ApiStatus.Experimental

Check warning

Code scanning / QDJVMC

Unstable API Usage Warning

'getSelectedTextEditorWithRemotes()' is marked unstable with @ApiStatus.Experimental

val caret: Caret = editor.caretModel.primaryCaret
val offset: Int = caret.offset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
private val languageExtractor: LanguageExtractor = LanguageExtractor()
suspend fun extract(): FileContext? {
val editor = computeOnEdt {
FileEditorManager.getInstance(project).selectedTextEditor
FileEditorManager.getInstance(project).selectedTextEditorWithRemotes.firstOrNull()

Check warning on line 21 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/editor/context/file/FileContextExtractor.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/editor/context/file/FileContextExtractor.kt#L21

Added line #L21 was not covered by tests

Check warning on line 21 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/editor/context/file/FileContextExtractor.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'getSelectedTextEditorWithRemotes()' is marked unstable with @ApiStatus.Experimental

Check warning

Code scanning / QDJVMC

Unstable API Usage Warning

'getSelectedTextEditorWithRemotes()' is marked unstable with @ApiStatus.Experimental
} ?: return null

val fileLanguage = computeOnEdt {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
private val languageExtractor: LanguageExtractor = LanguageExtractor()
suspend fun extract(): FocusAreaContext? {
val editor = computeOnEdt {
FileEditorManager.getInstance(project).selectedTextEditor
FileEditorManager.getInstance(project).selectedTextEditorWithRemotes.firstOrNull()

Check warning on line 29 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/editor/context/focusArea/FocusAreaContextExtractor.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/editor/context/focusArea/FocusAreaContextExtractor.kt#L29

Added line #L29 was not covered by tests

Check warning on line 29 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/editor/context/focusArea/FocusAreaContextExtractor.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'getSelectedTextEditorWithRemotes()' is marked unstable with @ApiStatus.Experimental

Check warning

Code scanning / QDJVMC

Unstable API Usage Warning

'getSelectedTextEditorWithRemotes()' is marked unstable with @ApiStatus.Experimental
} ?: return null

if (editor.document.text.isBlank()) return null
Expand Down Expand Up @@ -109,7 +109,7 @@
languageExtractor.extractLanguageNameFromCurrentFile(editor)
}
val fileText = editor.document.text
val fileName = FileEditorManager.getInstance(project).selectedFiles.first().name
val fileName = editor.virtualFile.name

Check warning on line 112 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/editor/context/focusArea/FocusAreaContextExtractor.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/editor/context/focusArea/FocusAreaContextExtractor.kt#L112

Added line #L112 was not covered by tests

// Offset the selection range to the start of the trimmedFileText
val selectionInsideTrimmedFileTextRange = codeSelectionRange.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
private var selectionListener: InlineChatSelectionListener? = null

init {
val editor = project.let { FileEditorManager.getInstance(it).selectedTextEditor }
val editor = project.let { FileEditorManager.getInstance(it).selectedTextEditorWithRemotes.firstOrNull() }

Check warning on line 21 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/inline/listeners/InlineChatFileListener.kt

View check run for this annotation

Codecov / codecov/patch

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/inline/listeners/InlineChatFileListener.kt#L21

Added line #L21 was not covered by tests

Check warning on line 21 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/inline/listeners/InlineChatFileListener.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unstable API Usage

'getSelectedTextEditorWithRemotes()' is marked unstable with @ApiStatus.Experimental

Check warning

Code scanning / QDJVMC

Unstable API Usage Warning

'getSelectedTextEditorWithRemotes()' is marked unstable with @ApiStatus.Experimental
if (editor != null) {
setupListenersForEditor(editor)
currentEditor = editor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

package software.aws.toolkits.jetbrains.services.cwc.inline.listeners

import com.intellij.idea.AppMode
import com.intellij.openapi.Disposable
import com.intellij.openapi.editor.event.SelectionEvent
import com.intellij.openapi.editor.event.SelectionListener
import software.aws.toolkits.jetbrains.services.cwc.inline.InlineChatEditorHint
import software.aws.toolkits.jetbrains.utils.isRunningOnRemoteBackend

class InlineChatSelectionListener : SelectionListener, Disposable {
private val inlineChatEditorHint = InlineChatEditorHint()
override fun selectionChanged(e: SelectionEvent) {
if (AppMode.isRemoteDevHost()) return
if (isRunningOnRemoteBackend()) return
val editor = e.editor
val selectionModel = editor.selectionModel

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
factoryClass="software.aws.toolkits.jetbrains.services.codemodernizer.toolwindow.CodeModernizerBottomToolWindowFactory"
icon="AllIcons.Actions.Preview"/>
<fileEditorProvider implementation="software.aws.toolkits.jetbrains.services.codemodernizer.plan.CodeModernizerPlanEditorProvider"/>
<fileEditorProvider implementation="software.aws.toolkits.jetbrains.services.codemodernizer.summary.CodeModernizerSummaryEditorProvider"/>
</extensions>

<extensions defaultExtensionNs="amazon.q">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ import software.aws.toolkits.jetbrains.services.codemodernizer.utils.parseXmlDep
import software.aws.toolkits.jetbrains.services.codemodernizer.utils.setDependencyVersionInPom
import software.aws.toolkits.jetbrains.services.codemodernizer.utils.tryGetJdk
import software.aws.toolkits.jetbrains.ui.feedback.CodeTransformFeedbackDialog
import software.aws.toolkits.jetbrains.utils.isRunningOnRemoteBackend
import software.aws.toolkits.jetbrains.utils.notifyStickyError
import software.aws.toolkits.jetbrains.utils.notifyStickyInfo
import software.aws.toolkits.resources.message
Expand Down Expand Up @@ -134,14 +133,6 @@ class CodeModernizerManager(private val project: Project) : PersistentStateCompo

fun validate(project: Project, transformationType: CodeTransformType): ValidationResult {
fun validateCore(project: Project): ValidationResult {
if (isRunningOnRemoteBackend()) {
return ValidationResult(
false,
InvalidTelemetryReason(
CodeTransformPreValidationError.RemoteRunProject,
)
)
}
if (!isCodeTransformAvailable(project)) {
return ValidationResult(
false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import com.intellij.openapi.vfs.VirtualFile
import software.amazon.awssdk.services.codewhispererruntime.model.TransformationPlan
import software.aws.toolkits.core.utils.debug
import software.aws.toolkits.core.utils.getLogger
import software.aws.toolkits.jetbrains.utils.isRunningOnRemoteBackend

class CodeModernizerPlanEditorProvider : FileEditorProvider, DumbAware {
override fun accept(project: Project, file: VirtualFile) = file is CodeModernizerPlanVirtualFile
Expand All @@ -31,8 +30,8 @@ class CodeModernizerPlanEditorProvider : FileEditorProvider, DumbAware {
val MIGRATION_PLAN_KEY = Key.create<TransformationPlan>("TRANSFORMATION_PLAN")
val MODULE_NAME_KEY = Key.create<String>("MODULE_NAME")
val JAVA_VERSION = Key.create<String>("JAVA_VERSION")

fun openEditor(project: Project, plan: TransformationPlan, module: String?, javaVersionNumber: String) {
if (isRunningOnRemoteBackend()) return
val virtualFile = CodeModernizerPlanVirtualFile()
virtualFile.putUserData(MIGRATION_PLAN_KEY, plan)
virtualFile.putUserData(MODULE_NAME_KEY, module)
Expand Down
Loading
Loading