Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
Keep chat textarea enabled and focused during AI response streaming
Murtaza Nasir2fa266464cc8
diff --git a/static/js/app.modular.js b/static/js/app.modular.jsindex b71e32e9..57e04eb2 100644--- a/static/js/app.modular.js+++ b/static/js/app.modular.js@@ -521,6 +521,7 @@ document.addEventListener('DOMContentLoaded', async () => {const chatInput = ref('');const isChatLoading = ref(false);const chatMessagesRef = ref(null);+ const chatInputRef = ref(null);// --- Audio Player State (Main Player) ---const playerVolume = ref(1.0);@@ -710,7 +711,7 @@ document.addEventListener('DOMContentLoaded', async () => {currentPlayingSegmentIndex, followPlayerMode, processingIndicatorMinimized,// Chat- showChat, isChatMaximized, chatMessages, chatInput, isChatLoading, chatMessagesRef,+ showChat, isChatMaximized, chatMessages, chatInput, isChatLoading, chatMessagesRef, chatInputRef,// Audio PlayerplayerVolume, audioIsPlaying, audioCurrentTime, audioDuration, audioIsMuted, audioIsLoading, asrEditorAudio,diff --git a/static/js/modules/composables/chat.js b/static/js/modules/composables/chat.jsindex f00efa02..ffb6deeb 100644--- a/static/js/modules/composables/chat.js+++ b/static/js/modules/composables/chat.js@@ -6,7 +6,7 @@export function useChat(state, utils) {const {showChat, isChatMaximized, chatMessages, chatInput,- isChatLoading, chatMessagesRef, selectedRecording, csrfToken+ isChatLoading, chatMessagesRef, chatInputRef, selectedRecording, csrfToken} = state;const { showToast, setGlobalError, onChatComplete, t } = utils;@@ -32,6 +32,14 @@ export function useChat(state, utils) {}};+ const focusChatInput = () => {+ Vue.nextTick(() => {+ if (chatInputRef.value) {+ chatInputRef.value.focus();+ }+ });+ };+const toggleChatMaximize = () => {if (isChatMaximized.value) {isChatMaximized.value = false;@@ -57,6 +65,7 @@ export function useChat(state, utils) {chatMessages.value.push({ role: 'user', content: message });chatInput.value = '';isChatLoading.value = true;+ focusChatInput();await Vue.nextTick();scrollChatToBottom();@@ -218,6 +227,7 @@ export function useChat(state, utils) {if (isChatScrolledToBottom()) {scrollChatToBottom();}+ focusChatInput();// Refresh token budget after chat completionif (onChatComplete) {onChatComplete();diff --git a/static/js/modules/state/chat.js b/static/js/modules/state/chat.jsindex dc58cbda..e8cb4117 100644--- a/static/js/modules/state/chat.js+++ b/static/js/modules/state/chat.js@@ -9,6 +9,7 @@ export function createChatState(ref) {const chatInput = ref('');const isChatLoading = ref(false);const chatMessagesRef = ref(null);+ const chatInputRef = ref(null);return {showChat,@@ -16,6 +17,7 @@ export function createChatState(ref) {chatMessages,chatInput,isChatLoading,- chatMessagesRef+ chatMessagesRef,+ chatInputRef};}diff --git a/templates/components/detail/desktop-chat-section.html b/templates/components/detail/desktop-chat-section.htmlindex fa4608ab..0a356aab 100644--- a/templates/components/detail/desktop-chat-section.html+++ b/templates/components/detail/desktop-chat-section.html@@ -88,8 +88,9 @@<div class="border-t border-[var(--border-primary)] p-4 bg-[var(--bg-tertiary)]"><div class="flex gap-2"><textarea v-model="chatInput"+ ref="chatInputRef"@keydown="handleChatKeydown"- :disabled="isChatLoading || selectedRecording.status !== 'COMPLETED' || processedTranscription.isError"+ :disabled="selectedRecording.status !== 'COMPLETED' || processedTranscription.isError":placeholder="t('chat.placeholderWithHint')"class="flex-1 px-3 py-2 bg-[var(--bg-input)] border border-[var(--border-secondary)] rounded-lg resize-none focus:outline-none focus:ring-2 focus:ring-[var(--ring-focus)] text-sm"rows="2">diff --git a/templates/components/detail/mobile-chat-panel.html b/templates/components/detail/mobile-chat-panel.htmlindex c2c58ca6..ad9fabc5 100644--- a/templates/components/detail/mobile-chat-panel.html+++ b/templates/components/detail/mobile-chat-panel.html@@ -46,7 +46,7 @@</div><div class="border-t border-[var(--border-primary)] p-4 bg-[var(--bg-tertiary)]"><div class="flex gap-2">- <textarea v-model="chatInput" @keydown="handleChatKeydown" :disabled="isChatLoading || selectedRecording.status !== 'COMPLETED' || processedTranscription.isError" :placeholder="t('chat.placeholder')" class="flex-1 px-3 py-2 bg-[var(--bg-input)] border border-[var(--border-secondary)] rounded-lg resize-none focus:outline-none focus:ring-2 focus:ring-[var(--ring-focus)] text-sm" rows="2"></textarea>+ <textarea v-model="chatInput" ref="chatInputRef" @keydown="handleChatKeydown" :disabled="selectedRecording.status !== 'COMPLETED' || processedTranscription.isError" :placeholder="t('chat.placeholder')" class="flex-1 px-3 py-2 bg-[var(--bg-input)] border border-[var(--border-secondary)] rounded-lg resize-none focus:outline-none focus:ring-2 focus:ring-[var(--ring-focus)] text-sm" rows="2"></textarea><button @click="sendChatMessage" :disabled="!chatInput.trim() || isChatLoading || selectedRecording.status !== 'COMPLETED' || processedTranscription.isError" class="px-4 py-2 bg-[var(--bg-button)] text-[var(--text-button)] rounded-lg hover:bg-[var(--bg-button-hover)] transition-colors disabled:opacity-50 disabled:cursor-not-allowed"><i class="fas fa-paper-plane"></i></button>