-
Notifications
You must be signed in to change notification settings - Fork 273
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
Conversation
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
…rains into rli/remote-chat-wip
Qodana Community for JVM12 new problems were found
💡 Qodana analysis was run in the pull request mode: only the changed files were checked Contact Qodana teamContact us at [email protected]
|
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.
QDJVMC found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
...src/software/aws/toolkits/jetbrains/services/cwc/editor/context/file/FileContextExtractor.kt
Fixed
Show fixed
Hide fixed
...src/software/aws/toolkits/jetbrains/services/cwc/editor/context/file/FileContextExtractor.kt
Fixed
Show fixed
Hide fixed
...src/software/aws/toolkits/jetbrains/services/cwc/editor/context/file/FileContextExtractor.kt
Fixed
Show fixed
Hide fixed
...src/software/aws/toolkits/jetbrains/services/cwc/editor/context/file/FileContextExtractor.kt
Fixed
Show fixed
Hide fixed
...src/software/aws/toolkits/jetbrains/services/cwc/editor/context/file/FileContextExtractor.kt
Fixed
Show fixed
Hide fixed
| ) : 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 val RESOURCE_REQUEST_HANDLER = resourceHandlerWrapper { path -> |
Check notice
Code scanning / QDJVMC
Private property naming convention Note
| private val headers: Map<String, String> = mapOf(), | ||
| ) : CefResourceHandler, Disposable { | ||
| init { | ||
| Disposer.register(parent, this) |
Check notice
Code scanning / QDJVMC
Leaking 'this' in constructor Note
| 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
| } | ||
| } | ||
|
|
||
| fun addResource(path: String, stream: InputStream?) = |
Check warning
Code scanning / QDJVMC
Unused symbol Warning
| 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
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.
does this api also work in local ?
| 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
| 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
| 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
| 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
|
|
||
| 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
Conflicts: plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/popup/CodeWhispererPopupManager.kt
|
Confirmed Windows Local works after the latest change (at least, log in + asking a basic chat question) |
gradle.properties
Outdated
|
|
||
| # Toolkit Version | ||
| toolkitVersion=3.58-SNAPSHOT | ||
| toolkitVersion=3.58-SNAPSHOT-ASBX_TEST_0228 |
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.
Should we revert this?
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.
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.
| QWebviewBrowser::class.java.getResourceAsStream("/webview/assets/js/getStart.js") | ||
| ) | ||
|
|
||
| jcefBrowser.loadURL(assetHandler.createResource("content.html", getWebviewHTML(webScriptUri, query))) |
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.
nit: can we assign the file names to consts
| } | ||
|
|
||
| override fun update(e: AnActionEvent) { | ||
| e.presentation.isEnabled = e.getData(CommonDataKeys.PROJECT) != null |
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.
What is the situation when this option is shown and project is null?
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.
the action is not available if the project is null
|
|
||
| init { | ||
| assetRequestHandler.addWildcardHandler("mynah") { path -> | ||
| val asset = path.replaceFirst("mynah/", "/mynah-ui/assets/") |
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.
Should we test this?
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.
follow up later
|
|
||
| override fun loadWebView(query: JBCefJSQuery) { | ||
| jcefBrowser.loadHTML(getWebviewHTML(webScriptUri, query)) | ||
| val webScriptUri = assetHandler.createResource( |
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.
duplicated code, maybe could be converted to a function?
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.
the classloader is important so it might become more complicated
| * @param myProtocol The protocol to handle (e.g., "http", "file"). | ||
| * @param myAuthority The authority of the requests (e.g., "localhost", "mydomain"). | ||
| */ | ||
| open class JBCefLocalRequestHandler( |
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.
can this be used directly?
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.
this is a straight copy from jetbrains so we should keep it slim to make it easy to copy over any changes later
Conflicts: plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/popup/CodeWhispererPopupManager.kt
|
Before merging to main, can we add a changelog? |
|
@manodnyab We're planning on turning this into a feature branch |
* feat(amazonq): Add support for Amazon Q chat on remote 242+ (#4825) * fix(amazonq): Bug Fix for "Q: Send to Prompt" doesn't work in split panes on local or remote (#5463) * fix(amazonq): use https as scheme for local webview resource resolver (#5489) https://developer.mozilla.org/en-US/docs/Web/API/Clipboard `navigator.clipboard` is only accessible from a "secure context", which JCEF does not think we are using, because the URI authority is not localhost or https. Since we are hooking onto the CEF resource request handler, it does not matter what we use for the scheme/authority as long as there is no conflict with real resources. Previous implementation used a different load mechanism which somehow met the secure context criteria. * fix(amazonq): fix agentic asset loading in remote mode (#5734) local uris cannot be loaded if the host is deemed non-remote * fix(amazonq): fix code issues tab not appearing in remote (#5737) on remote, each client gets its own instance of the tool window. logic needs to handle this case, otherwise it will only make changes against the 'main' IDE, and will not be visible to remote clients * fix(amazonq): use progress bar decorator while loading q chat on remote (#5749) animated icons do not show up on remote * fix: provide loading text when chat assets are slow to load (#5973) on remote, it can take 10+ seconds for chat to be visible. additionally, delete some unneeded assets to slightly reduce load time * feat(amazonq): limit remote to amzn-internal compute (#5993) Per internal discussion, feature deemed not ready for external users due to https://youtrack.jetbrains.com/issue/IJPL-203169 * fix: delete changelog for internal feature (#6009) * feat: show message to resize on remote chat (#6007) --------- Co-authored-by: Lokesh <[email protected]>
This enables webviews to work over thin client instances by working around
registerSchemeHandlerFactorybeing a no-op as described in IJPL-170861.Open issues:This should only be enabled on remote if 242+registerSchemeHandlerFactorynot working correctly -- need further evaluationFQN WASM code doesn't seem to be invoked properlydouble check thatFileEditorManager.getInstance(project).selectedFiles.first().nameandeditor.virtualFile.nameare equivalentShould we just doFileEditorManager#selectedTextEditorWithRemotes? that is what inline suggestions is usingconsolidate on decision. ChatController/FeatureDevControllerprocessInsertCodeAtCursorPositionneed to be migrated tooFigure out why error inFocusAreaContextExtractoris not surfaced anywhereLicense
I confirm that my contribution is made under the terms of the Apache 2.0 license.