Send chat prompt message to lsp - #26
Conversation
| e.printStackTrace(); | ||
| } | ||
| return null; |
There was a problem hiding this comment.
Instead of swallowing the exception let's wrap the original with an AmazonQPluginException and throw it back to the caller. In that case it should probably be the top level webview command execution logic that catches any error occurring during the processing of one of the commands. That could then log + potentially display an error to the user in the view (this part can come later).
There was a problem hiding this comment.
Good idea! Didn't realize there was an AmazonQPluginException. Added to the other LSP send functions also.
| void tabAdd(GenericTabParams params); | ||
|
|
||
| @JsonNotification("aws/chat/ready") | ||
| void chatReady(); |
There was a problem hiding this comment.
Did it not work when annotated as a JsonRequest with a void response type (CompletableFuture<Void>)? Maybe this makes more sense as an explicit fire & forget non blocking type though.
There was a problem hiding this comment.
Yeah the LSP server did not recognize the request when it was annotated as a JsonRequest. The server is explicitly expecting a Notification. Surprisingly, most of the LSP features are Notifications rather than requests as specified in their doc (https://github.com/aws/language-server-runtimes/tree/main/runtimes#feature-specification-4)
There was a problem hiding this comment.
Cool, thanks for the info. That makes sense.
a5ca0d4 to
4ff9d04
Compare
angjordn
left a comment
There was a problem hiding this comment.
Made the requested updates
| PluginLogger.error("Unhandled chat command: " + command.toString()); | ||
| } | ||
| return null; |
There was a problem hiding this comment.
Avoid the null return by explicitly raising a PluginException here. This is a specific internal failure that should not be squelched.
angjordn
left a comment
There was a problem hiding this comment.
Throw AmazonQPlugiinException for missing commands and fix checkstyle errors
| return null; | ||
| default: | ||
| PluginLogger.error("Unhandled chat command: " + command.toString()); | ||
| throw new AmazonQPluginException("Unhandled command in ChatCommunicationManager: " + command.toString()); |
There was a problem hiding this comment.
@breedloj Throwing the PluginException as you mentioned. You also mentioned throwing the exception to avoid returning null - I moved the return null statements to the associated cases to be more explicit about which cases null is being returned on.
| default: | ||
| PluginLogger.info("Unhandled command: " + parsedCommand.getCommand()); | ||
| break; | ||
| throw new AmazonQPluginException("Unhandled command in AmazonQChatViewActionHandler: " + command.toString()); |
There was a problem hiding this comment.
@breedloj Also updated the ActionHandler to a PluginException to match the unhandled command case in ChatCommunicationManager
Description:
aws/chat/sendChatPromptmessageDemo of UI to Logged response
Log_response.mov