Skip to content
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

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

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

Conversation

rli
Copy link
Contributor

@rli rli commented Aug 21, 2024

image

This enables webviews to work over thin client instances by working around registerSchemeHandlerFactory being a no-op as described in IJPL-170861.

Open issues:

  • This should only be enabled on remote if 242+
  • registerSchemeHandlerFactory not working correctly -- need further evaluation
  • FQN WASM code doesn't seem to be invoked properly
  • double check that FileEditorManager.getInstance(project).selectedFiles.first().name and editor.virtualFile.name are equivalent
  • Should we just do FileEditorManager#selectedTextEditorWithRemotes? that is what inline suggestions is using
    • consolidate on decision. ChatController/FeatureDevController processInsertCodeAtCursorPosition need to be migrated too
  • Figure out why error in FocusAreaContextExtractor is not surfaced anywhere

License

I confirm that my contribution is made under the terms of the Apache 2.0 license.

rli and others added 7 commits August 21, 2024 13:35
 Conflicts:
	plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/toolwindow/AmazonQToolWindowFactory.kt
	plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/Browser.kt
	plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/webview/BrowserConnector.kt
Copy link

github-actions bot commented Jan 22, 2025

Qodana Community for JVM

12 new problems were found

Inspection name Severity Problems
Unstable API Usage 🔶 Warning 6
ActionUpdateThread is missing 🔶 Warning 1
Unused symbol 🔶 Warning 1
Private property naming convention ◽️ Notice 2
Leaking 'this' in constructor ◽️ Notice 1
Boolean expression can be simplified ◽️ Notice 1

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at [email protected]

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

QDJVMC found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

) : CefRequestHandlerAdapter() {
private val myResources: MutableMap<String, () -> CefResourceHandler?> = HashMap()

private val REJECTING_RESOURCE_HANDLER: CefResourceHandler = object : CefResourceHandlerAdapter() {

Check notice

Code scanning / QDJVMC

Private property naming convention Note

Private property name REJECTING_RESOURCE_HANDLER should not contain underscores in the middle or the end
}
}

private val RESOURCE_REQUEST_HANDLER = resourceHandlerWrapper { path ->

Check notice

Code scanning / QDJVMC

Private property naming convention Note

Private property name RESOURCE_REQUEST_HANDLER should not contain underscores in the middle or the end
private val headers: Map<String, String> = mapOf(),
) : CefResourceHandler, Disposable {
init {
Disposer.register(parent, this)

Check notice

Code scanning / QDJVMC

Leaking 'this' in constructor Note

Leaking 'this' in constructor of non-final class JBCefStreamResourceHandler
private fun streamHandler(path: String, stream: InputStream) =
JBCefStreamResourceHandler(
stream,
if (path.endsWith(".wasm") == true) "application/wasm" else URLConnection.getFileNameMap().getContentTypeFor(path),

Check notice

Code scanning / QDJVMC

Boolean expression can be simplified Note

Boolean expression can be simplified
}
}

fun addResource(path: String, stream: InputStream?) =

Check warning

Code scanning / QDJVMC

Unused symbol Warning

Function "addResource" is never used
@rli rli marked this pull request as ready for review January 24, 2025 20:26
@rli rli requested review from a team as code owners January 24, 2025 20:26
@@ -122,7 +122,7 @@

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

Check warning

Code scanning / QDJVMC

Unstable API Usage Warning

'getSelectedTextEditorWithRemotes()' is marked unstable with @ApiStatus.Experimental
@@ -194,7 +194,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

Code scanning / QDJVMC

Unstable API Usage Warning

'getSelectedTextEditorWithRemotes()' is marked unstable with @ApiStatus.Experimental
@@ -219,7 +219,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

Code scanning / QDJVMC

Unstable API Usage Warning

'getSelectedTextEditorWithRemotes()' is marked unstable with @ApiStatus.Experimental
@@ -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

Code scanning / QDJVMC

Unstable API Usage Warning

'getSelectedTextEditorWithRemotes()' is marked unstable with @ApiStatus.Experimental
@@ -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

Code scanning / QDJVMC

Unstable API Usage Warning

'getSelectedTextEditorWithRemotes()' is marked unstable with @ApiStatus.Experimental
@@ -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

Code scanning / QDJVMC

Unstable API Usage Warning

'getSelectedTextEditorWithRemotes()' is marked unstable with @ApiStatus.Experimental
rli and others added 3 commits January 27, 2025 10:29
 Conflicts:
	plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/popup/CodeWhispererPopupManager.kt
@rli rli requested a review from a team as a code owner January 31, 2025 22:01
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.

1 participant