Skip to content

Commit

Permalink
Merge pull request #38 from InAnYan/fix-for-33
Browse files Browse the repository at this point in the history
  • Loading branch information
InAnYan authored Jun 4, 2024
2 parents 1ea6029 + bca31f6 commit dec354e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ private void buildChatUI(BibEntry entry) {
ChatMessage aiMessage = ChatMessage.assistant(aiMessageText);
aiChatComponent.addMessage(aiMessage);
entry.getAiChatMessages().add(aiMessage);

aiChatComponent.requestUserPromptTextFieldFocus();
})
.onFailure(e -> {
// TODO: User-friendly error message.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.function.Consumer;

import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.geometry.NodeOrientation;
import javafx.geometry.Pos;
Expand Down Expand Up @@ -34,6 +35,11 @@ public AiChatComponent(Consumer<String> sendMessageCallback) {
.load();
}

@FXML
public void initialize() {
Platform.runLater(() -> userPromptTextField.requestFocus());
}

@FXML
private void internalSendMessageEvent() {
String userPrompt = userPromptTextField.getText();
Expand Down Expand Up @@ -69,4 +75,8 @@ public void addMessage(ChatMessage chatMessage) {
public void addError(String message) {
chatVBox.getChildren().add(new ChatMessageComponent().withError(message));
}

public void requestUserPromptTextFieldFocus() {
userPromptTextField.requestFocus();
}
}

0 comments on commit dec354e

Please sign in to comment.