public void onSendToChatUi()

in plugin/src/software/aws/toolkits/eclipse/amazonq/inlineChat/InlineChatSession.java [167:213]


    public void onSendToChatUi(final String message) {
        if (!isSessionActive()) {
            return;
        }

        try {
            // Deserialize object
            ObjectMapper mapper = ObjectMapperFactory.getInstance();
            var rootNode = mapper.readTree(message);
            if (rootNode.has("command") && "errorMessage".equals(rootNode.get("command").asText())) {
                uiManager.showErrorNotification();
                restoreAndEndSession();
                return;
            }

            var paramsNode = rootNode.get("params");
            var isPartialResult = rootNode.get("isPartialResult").asBoolean();
            var chatResult = mapper.treeToValue(paramsNode, InlineChatResult.class);

            if (chatResult != null && chatResult.messageId() != null) {
                task.setRequestId(chatResult.messageId());
            }

            if (!verifyChatResultParams(chatResult)) {
                restoreAndEndSession();
                return;
            }

            // Render diffs and move to deciding once we receive final result
            diffManager.processDiff(chatResult, isPartialResult).thenRun(() -> {
                if (!isPartialResult) {
                    setState(SessionState.DECIDING);
                    uiManager.transitionToDecidingPrompt();
                    blockUserInput(false);
                }
            }).exceptionally(throwable -> {
                Activator.getLogger().error("Failed to process diff", throwable);
                uiManager.showErrorNotification();
                restoreAndEndSession();
                return null;
            });

        } catch (Exception e) {
            uiManager.showErrorNotification();
            restoreAndEndSession();
        }
    }