Add stop button

This commit is contained in:
2024-03-09 15:22:44 -05:00
parent d2470b2dd6
commit bdf5715868
6 changed files with 54 additions and 11 deletions

View File

@@ -19,6 +19,7 @@ document.addEventListener('DOMContentLoaded', () => {
const promptInput = document.getElementById('promptInput');
const modelSelect = document.getElementById('modelSelect');
const sendButton = document.getElementById('sendButton');
const stopButton = document.getElementById('stopButton');
const modelSelectionContainer = document.getElementById('modelSelectionContainer');
if (chatForm && promptInput && modelSelect) {
@@ -32,6 +33,7 @@ document.addEventListener('DOMContentLoaded', () => {
sendButton.disabled = true;
promptInput.disabled = true;
stopButton.disabled = false;
displayMessage(userInput, 'user');
@@ -49,10 +51,10 @@ document.addEventListener('DOMContentLoaded', () => {
displayMessage(`Error: ${error.message}`, 'assistant');
} finally {
typingIndicator.remove();
sendButton.disabled = false;
promptInput.disabled = false;
promptInput.focus();
stopButton.disabled = true;
}
});
} else {
@@ -60,6 +62,11 @@ document.addEventListener('DOMContentLoaded', () => {
}
});
document.getElementById('stopButton').addEventListener('click', () => {
window.electronAPI.abortPrompt();
document.getElementById('stopButton').disabled = true;
});
function displayTypingIndicator() {
const chatHistory = document.getElementById('chatHistory');
const typingIndicator = document.createElement('div');