Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
Fix blank detail pane after deleting the selected recording by hydrating the neighbour through selectRecording, with a watcher safety net for any light-object assignment
Murtaza Nasir8f135f340c3c
diff --git a/static/js/app.modular.js b/static/js/app.modular.jsindex 4cc3799a..88236b92 100644--- a/static/js/app.modular.js+++ b/static/js/app.modular.js@@ -2276,6 +2276,35 @@ document.addEventListener('DOMContentLoaded', async () => {// Create reprocess composable first so it can be passed to recordingsconst reprocessComposable = useReprocess(state, utils);const recordingsComposable = useRecordings(state, utils, reprocessComposable);+ // Expose selectRecording so other composables can navigate to a+ // recording the same way a sidebar click does (which fetches its+ // full detail). Used by delete-neighbour selection in modals.+ utils.selectRecording = recordingsComposable.selectRecording;++ // Hydration safety net: if selectedRecording is ever set to a light+ // sidebar/list object (to_list_dict omits transcription/summary),+ // fetch the full recording so the detail pane never shows a stale+ // "No transcription available". The normal selectRecording() path+ // sets utils._hydratingSelectedRecording while it does its own fetch,+ // so this only acts on assignments that bypass it. Keyed on the id so+ // it fires once per navigation, not on in-place field updates.+ watch(() => (selectedRecording.value && selectedRecording.value.id) || null, async (id) => {+ const rec = selectedRecording.value;+ if (!id || id === 'incognito' || !rec) return;+ if ('transcription' in rec) return; // already a full detail object+ if (utils._hydratingSelectedRecording) return; // selectRecording is fetching it+ try {+ const resp = await fetch(`/api/recordings/${id}`);+ if (!resp.ok) return;+ const full = await resp.json();+ if (selectedRecording.value && selectedRecording.value.id === id) {+ selectedRecording.value = full;+ const idx = recordings.value.findIndex(r => r.id === id);+ if (idx !== -1) recordings.value[idx] = full;+ }+ } catch (_) { /* non-fatal; a manual re-click still hydrates */ }+ });+const uploadComposable = useUpload(state, utils);// Upload disclaimer handlersdiff --git a/static/js/modules/composables/modals.js b/static/js/modules/composables/modals.jsindex f787e1b4..ee350822 100644--- a/static/js/modules/composables/modals.js+++ b/static/js/modules/composables/modals.js@@ -131,8 +131,16 @@ export function useModals(state, utils) {const remaining = recordings.value;if (remaining.length > 0) {const nextIndex = Math.min(deletedIndex, remaining.length - 1);- selectedRecording.value = remaining[nextIndex];- currentView.value = 'detail';+ // Navigate through selectRecording so the neighbour's FULL+ // detail (transcription/summary) is fetched. Assigning the+ // light list object directly left the detail pane showing+ // "No transcription available" until the row was clicked again.+ if (utils.selectRecording) {+ utils.selectRecording(remaining[nextIndex]);+ } else {+ selectedRecording.value = remaining[nextIndex];+ currentView.value = 'detail';+ }} else {selectedRecording.value = null;currentView.value = null;diff --git a/static/js/modules/composables/recordings.js b/static/js/modules/composables/recordings.jsindex 60e6a11f..57658b3f 100644--- a/static/js/modules/composables/recordings.js+++ b/static/js/modules/composables/recordings.js@@ -230,6 +230,11 @@ export function useRecordings(state, utils, reprocessComposable) {speakerColorMap.value = {};}+ // Tell the hydration safety-net watcher that this path already fetches+ // the full detail below, so it doesn't also fetch (avoids a double+ // request on every normal selection). Set BEFORE the assignment so the+ // watcher, which fires on the next tick, sees the flag.+ if (recording && recording.id && utils) utils._hydratingSelectedRecording = true;selectedRecording.value = recording;if (recording && recording.id) {@@ -258,6 +263,8 @@ export function useRecordings(state, utils, reprocessComposable) {}} catch (error) {console.error('Error loading full recording:', error);+ } finally {+ if (utils) utils._hydratingSelectedRecording = false;}}