Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
Revert ASR editor to virtual scrolling; keep speaker modal on content-visibility + bounded hydration — user's correct observation: the ASR editor is spreadsheet-like (uniform single-line inputs + a textarea capped at max-h-20: 80px), so row heights are bounded and the fixed-itemHeight virtual scroll is the right tool; user explicitly said 'earlier I wasn't having any scrolling issues with this EditASR transcription model'; the issues were always with the speaker modal (variable-height segments); my content-visibility approach was overkill for the editor and was caught producing CLS 0.50–3.02 in the latest metrics; CHANGES; (1) styles.css: removed 'table-layout: fixed' and the 'content-visibility: auto; contain-intrinsic-size' rule from .asr-editor-table; back to the original simple style; (2) asr-editor-modal.html: restored the virtual-scroll structure — asrEditorSpacerBefore / asrEditorVisibleSegments v-for with segment._originalIndex / asrEditorSpacerAfter, plus @scroll='onAsrEditorScroll($event)' on the container; removed the hydrated/placeholder template split; rows are now mounted by virtual scroll's window (~30 rows total in DOM); (3) app.modular.js: utils.scrollAsrEditorToIndex back to asrEditorVirtualScroll.scrollToIndex(index-2, 'auto') so highlight-jump still leaves 2 rows of clearance under the sticky table header; utils.resetAsrEditorScroll back to asrEditorVirtualScroll.reset(); removed the ASR-editor _makeRowHydrator wiring and the showAsrEditorModal watcher; hydrateAsrEditorRow kept as a no-op for any leftover template refs (none now, but defensive); kept the _makeRowHydrator factory + showSpeakerModal wiring — speaker modal continues to use content-visibility + bounded hydration which is correct for its variable-height segments
Murtaza Nasird664c09197b7
diff --git a/static/css/styles.css b/static/css/styles.cssindex 4e289e7e..0784bd12 100644--- a/static/css/styles.css+++ b/static/css/styles.css@@ -3398,28 +3398,6 @@ body {.asr-editor-table {width: 100%;border-collapse: collapse; /* Changed to collapse */- /* table-layout: fixed lets the browser ignore row contents when- computing column widths (instead of measuring every row to find- the widest cell). Required for content-visibility on <tr> to- work, because the auto algorithm forces a full table layout on- every row to determine column widths — which defeats the whole- point of skipping off-screen rows. Columns are explicitly sized- in the template (w-40 / w-20 / etc.), so fixed layout produces- the same visual result. */- table-layout: fixed;-}--/* Skip layout + paint for off-screen ASR-editor rows. Same pattern- used on .speaker-segment: every row stays in the DOM (so the- scrollbar is stable and scrollIntoView lands on real positions),- but only the on-screen ones pay the per-row layout cost.- contain-intrinsic-size gives the browser a 44 px placeholder size- for off-screen rows — the typical row height with one line of- sentence text. Rows whose textarea has grown to multiple lines- simply contribute their real height when scrolled into view. */-.asr-editor-table tbody > tr {- content-visibility: auto;- contain-intrinsic-size: auto 44px;}.asr-editor-table th {diff --git a/static/js/app.modular.js b/static/js/app.modular.jsindex 8b0b3bf8..2a1b8dbf 100644--- a/static/js/app.modular.js+++ b/static/js/app.modular.js@@ -1202,25 +1202,22 @@ document.addEventListener('DOMContentLoaded', async () => {const asrEditorHighlightIndex = ref(null); // Segment index briefly highlighted after double-click open// -------------------------------------------------------------- // Lazy-hydration wiring for the ASR editor + speaker modal- // long lists (declared above as asrEditorHydratedRows /- // speakerModalHydratedRows). The factory creates one- // IntersectionObserver per pane. Rows entering the watch- // region (viewport ± 600 px) get added to the hydrated Set;- // rows leaving get REMOVED — bounded membership so the- // hydrated count stays around one viewport's worth (~50–100- // rows) regardless of transcript length. Without bounded- // dehydration, scrolling top → bottom would gradually- // promote every row and re-introduce the 1400 ms INP /- // 142k DOM nodes regression we saw at 2500 segments. A row- // is never dehydrated while it contains- // document.activeElement, so the user editing an input- // mid-scroll never gets it yanked away.+ // Lazy-hydration wiring for the SPEAKER modal long transcript+ // pane (declared above as speakerModalHydratedRows). The+ // factory creates an IntersectionObserver against the+ // scrollable container. Rows entering the watch region+ // (viewport ± 600 px) get added to the hydrated Set; rows+ // leaving get REMOVED — bounded membership so the hydrated+ // count stays around one viewport's worth regardless of+ // transcript length. A row is never dehydrated while it+ // contains document.activeElement, so editing mid-scroll+ // never yanks an input away.//- // Same factory is shared between modals; each gets its own- // observer + Set so they can run independently. Modal-open /- // close cycles re-set up / tear down via watch on- // showAsrEditorModal / showSpeakerModal.+ // The ASR editor uses a different approach (fixed-height+ // virtual scrolling) because its rows are spreadsheet-like+ // — uniform single-line inputs + a textarea capped at+ // max-h-20. Variable-height tricks aren't worth the CLS+ // cost there.// -------------------------------------------------------------const _makeRowHydrator = (containerRef, hydratedRef, options = {}) => {const observer = { current: null };@@ -1260,18 +1257,15 @@ document.addEventListener('DOMContentLoaded', async () => {};return { setup, teardown, hydrate };};- const _asrEditorHydrator = _makeRowHydrator(asrEditorRef, asrEditorHydratedRows);- const hydrateAsrEditorRow = _asrEditorHydrator.hydrate;- watch(showAsrEditorModal, (open) => {- if (open) nextTick(() => _asrEditorHydrator.setup());- else _asrEditorHydrator.teardown();- });const _speakerModalHydrator = _makeRowHydrator(speakerModalTranscriptRef, speakerModalHydratedRows);const hydrateSpeakerModalRow = _speakerModalHydrator.hydrate;watch(showSpeakerModal, (open) => {if (open) nextTick(() => _speakerModalHydrator.setup());else _speakerModalHydrator.teardown();});+ // ASR editor uses virtual scroll; no hydration wiring needed.+ // Keep hydrateAsrEditorRow as a no-op for any leftover refs.+ const hydrateAsrEditorRow = () => {};// --- Computed properties needed by composables ---const isMobileScreen = computed(() => windowWidth.value < 1024);@@ -2344,22 +2338,11 @@ document.addEventListener('DOMContentLoaded', async () => {// Add scrollToSegmentIndex to utils for composables that need itutils.scrollToSegmentIndex = scrollToSegmentIndex;utils.resetModalAudioState = resetModalAudioState;- utils.resetAsrEditorScroll = () => {- if (asrEditorRef.value) asrEditorRef.value.scrollTop = 0;- };- // Scroll the editor table to a specific row by index. The- // table no longer uses virtual scrolling — all rows are in- // the DOM (with content-visibility skipping off-screen paint),- // so this is just a real-DOM lookup + scrollIntoView using- // measured positions. block: 'center' centres the row in the- // viewport so it lands well clear of the sticky table header- // without us having to know the header's height.- utils.scrollAsrEditorToIndex = (index) => {- const container = asrEditorRef.value;- if (!container) return;- const target = container.querySelector(`[data-segment-index="${index}"]`);- if (target) target.scrollIntoView({ block: 'center', behavior: 'auto' });- };+ utils.resetAsrEditorScroll = () => asrEditorVirtualScroll.reset();+ // Scroll to the target row but offset upward so the row lands+ // comfortably below the sticky table header (~2 rows of clearance)+ // instead of being clipped at the top.+ utils.scrollAsrEditorToIndex = (index) => asrEditorVirtualScroll.scrollToIndex(Math.max(0, index - 2), 'auto');utils.setAsrEditorScrollTop = (scrollTop) => {if (asrEditorRef.value) {asrEditorRef.value.scrollTop = scrollTop;diff --git a/templates/modals/asr-editor-modal.html b/templates/modals/asr-editor-modal.htmlindex 9805fa4e..db0c5cfc 100644--- a/templates/modals/asr-editor-modal.html+++ b/templates/modals/asr-editor-modal.html@@ -73,19 +73,17 @@</div></div>- <!-- Editor table — renders ALL segments natively (no virtual- scroll spacers). content-visibility: auto on each <tr>- (set in styles.css under .asr-editor-table tbody > tr)- lets the browser skip layout + paint for off-screen rows- so we keep the perf win, while scrollHeight stays stable- (placeholder size for off-screen rows = 44 px via- contain-intrinsic-size). v-memo on each row stops Vue- from re-rendering rows whose data didn't change when an- unrelated row's input updates. table-layout: fixed- (see styles.css) is required for content-visibility to- work on table rows — without it the browser must lay out- every row to compute column widths. -->- <div ref="asrEditorRef" class="flex-grow overflow-y-auto custom-scrollbar" @scroll="closeAllSpeakerSuggestions()">+ <!-- Editor table uses VIRTUAL SCROLLING with fixed itemHeight=44+ (set in app.modular.js's asrEditorVirtualScroll). This+ modal is spreadsheet-like — every row carries the same+ single-line inputs and a textarea capped at max-h-20 (80+ px), so row heights are bounded and uniform enough for+ the fixed-height estimate to be accurate. The variable-+ height tricks the speaker modal uses (content-visibility+ + bounded hydration) are overkill here and were caught+ introducing CLS shifts of ~3.0 in the editor — exactly+ the regression we were trying to avoid. -->+ <div ref="asrEditorRef" class="flex-grow overflow-y-auto custom-scrollbar" @scroll="closeAllSpeakerSuggestions(); onAsrEditorScroll($event)"><table class="min-w-full asr-editor-table border border-[var(--border-primary)]"><thead class="sticky top-0 z-10"><tr class="text-xs uppercase text-[var(--text-muted)]">@@ -97,81 +95,60 @@</tr></thead><tbody>- <tr v-for="(segment, idx) in editingSegments"- :key="`asr-${idx}-${segment.start_time}`"- v-memo="[idx, segment.speaker, segment.start_time, segment.end_time, segment.sentence, asrEditorHighlightIndex === idx, asrEditorHydratedRows.has(idx), isDropdownOpen(idx)]"- :data-segment-index="idx"- @focusin="hydrateAsrEditorRow(idx)"- :class="['hover:bg-[var(--bg-tertiary)] transition-colors border-b border-[var(--border-primary)]', { 'asr-editor-row--highlighted': asrEditorHighlightIndex === idx }]">- <!-- Hydrated (interactive) version: only mounted once- the IntersectionObserver in app.modular.js has- promoted this row, or the user has focused into- it via @focusin. Carries all the v-models,- event handlers, and the dropdown teleport. -->- <template v-if="asrEditorHydratedRows.has(idx)">- <td class="border-r border-[var(--border-primary)] align-middle">- <div class="relative h-full">- <div class="flex items-center h-full">- <input type="text" v-model="editingSegments[idx].speaker"- @input="filterSpeakerSuggestions(idx); openSpeakerSuggestions(idx)"- @focus="openSpeakerSuggestions(idx)"- class="w-full h-full px-3 py-2.5 pr-7 bg-transparent border-0 focus:outline-none text-sm text-[var(--text-primary)]" />- <button type="button" @click.stop="openSpeakerSuggestions(idx)"- class="absolute right-2 top-1/2 -translate-y-1/2 p-1 text-[var(--text-muted)] hover:text-[var(--text-primary)] cursor-pointer">- <i class="fas fa-chevron-down text-xs"></i>- </button>- </div>+ <!-- Virtual scroll spacer (top) -->+ <tr v-if="asrEditorSpacerBefore > 0"><td colspan="5" :style="{ height: asrEditorSpacerBefore + 'px', padding: 0 }"></td></tr>++ <tr v-for="segment in asrEditorVisibleSegments" :key="`asr-${segment._originalIndex}-${segment.start_time}`" :data-segment-index="segment._originalIndex" :class="['hover:bg-[var(--bg-tertiary)] transition-colors border-b border-[var(--border-primary)]', { 'asr-editor-row--highlighted': asrEditorHighlightIndex === segment._originalIndex }]">+ <td class="border-r border-[var(--border-primary)] align-middle">+ <div class="relative h-full">+ <div class="flex items-center h-full">+ <input type="text" v-model="editingSegments[segment._originalIndex].speaker"+ @input="filterSpeakerSuggestions(segment._originalIndex); openSpeakerSuggestions(segment._originalIndex)"+ @focus="openSpeakerSuggestions(segment._originalIndex)"+ class="w-full h-full px-3 py-2.5 pr-7 bg-transparent border-0 focus:outline-none text-sm text-[var(--text-primary)]" />+ <button type="button" @click.stop="openSpeakerSuggestions(segment._originalIndex)"+ class="absolute right-2 top-1/2 -translate-y-1/2 p-1 text-[var(--text-muted)] hover:text-[var(--text-primary)] cursor-pointer">+ <i class="fas fa-chevron-down text-xs"></i>+ </button></div>- <teleport to="body">- <div v-if="isDropdownOpen(idx)"- class="fixed z-[100] w-40 bg-[var(--bg-secondary)] border border-[var(--border-primary)] rounded-md shadow-lg max-h-48 overflow-y-auto"- :style="getDropdownPosition(idx)">- <div v-for="speaker in editingSegments[idx].filteredSpeakers" :key="speaker" @mousedown.prevent="selectSpeaker(idx, speaker)" class="px-3 py-2 cursor-pointer hover:bg-[var(--bg-tertiary)] text-sm">${speaker}</div>- <div @mousedown.prevent="openEditSpeakersModal" class="px-3 py-2 cursor-pointer hover:bg-[var(--bg-accent)] text-sm text-[var(--text-accent)] border-t border-[var(--border-primary)] flex items-center">- <i class="fas fa-user-edit mr-2"></i> <span v-text="t('buttons.editSpeakers')"></span>- </div>+ </div>+ <teleport to="body">+ <div v-if="isDropdownOpen(segment._originalIndex)"+ class="fixed z-[100] w-40 bg-[var(--bg-secondary)] border border-[var(--border-primary)] rounded-md shadow-lg max-h-48 overflow-y-auto"+ :style="getDropdownPosition(segment._originalIndex)">+ <div v-for="speaker in editingSegments[segment._originalIndex].filteredSpeakers" :key="speaker" @mousedown.prevent="selectSpeaker(segment._originalIndex, speaker)" class="px-3 py-2 cursor-pointer hover:bg-[var(--bg-tertiary)] text-sm">${speaker}</div>+ <div @mousedown.prevent="openEditSpeakersModal" class="px-3 py-2 cursor-pointer hover:bg-[var(--bg-accent)] text-sm text-[var(--text-accent)] border-t border-[var(--border-primary)] flex items-center">+ <i class="fas fa-user-edit mr-2"></i> <span v-text="t('buttons.editSpeakers')"></span></div>- </teleport>- </td>- <td class="border-r border-[var(--border-primary)] align-middle">- <input type="number" step="0.01" v-model.number="editingSegments[idx].start_time" class="w-full px-3 py-2.5 bg-transparent border-0 focus:outline-none text-sm text-[var(--text-primary)] text-center" />- </td>- <td class="border-r border-[var(--border-primary)] align-middle">- <input type="number" step="0.01" v-model.number="editingSegments[idx].end_time" class="w-full px-3 py-2.5 bg-transparent border-0 focus:outline-none text-sm text-[var(--text-primary)] text-center" />- </td>- <td class="border-r border-[var(--border-primary)] align-top">- <textarea v-model="editingSegments[idx].sentence" rows="1" class="w-full px-3 py-2.5 bg-transparent border-0 focus:outline-none text-sm text-[var(--text-primary)] resize-none max-h-20 overflow-y-auto custom-scrollbar block" @input="autoResizeTextarea($event)"></textarea>- </td>- <td class="px-1 text-center align-middle">- <div class="flex items-center justify-center gap-1">- <button @click="$refs.asrEditorAudioRef && ($refs.asrEditorAudioRef.currentTime = segment.start_time, $refs.asrEditorAudioRef.play())" class="p-1.5 rounded hover:bg-[var(--bg-accent)] text-[var(--text-muted)] hover:text-[var(--text-accent)] transition-colors" :title="t('help.playFromHere')">- <i class="fas fa-play text-xs"></i>- </button>- <button @click="addSegmentBelow(idx)" class="p-1.5 rounded hover:bg-green-600/20 text-[var(--text-muted)] hover:text-green-500 transition-colors" :title="t('help.addSegmentBelow')">- <i class="fas fa-plus text-xs"></i>- </button>- <button @click="removeSegment(idx)" class="p-1.5 rounded hover:bg-red-600/20 text-[var(--text-muted)] hover:text-red-500 transition-colors" :title="t('help.deleteSegment')">- <i class="fas fa-trash text-xs"></i>- </button></div>- </td>- </template>- <!-- Placeholder version for off-screen rows: just- 4 read-only `<td>`s rendering the current- values. No v-model, no event handlers, no- dropdown teleport — cheap to mount. The- padding intentionally matches the hydrated- version's input padding (px-3 py-2.5) so- promotion in place doesn't cause a visible- layout shift. -->- <template v-else>- <td class="border-r border-[var(--border-primary)] align-middle px-3 py-2.5 text-sm text-[var(--text-primary)] truncate">${ segment.speaker }</td>- <td class="border-r border-[var(--border-primary)] align-middle px-3 py-2.5 text-sm text-[var(--text-primary)] text-center">${ segment.start_time }</td>- <td class="border-r border-[var(--border-primary)] align-middle px-3 py-2.5 text-sm text-[var(--text-primary)] text-center">${ segment.end_time }</td>- <td class="border-r border-[var(--border-primary)] align-top px-3 py-2.5 text-sm text-[var(--text-primary)]">${ segment.sentence }</td>- <td></td>- </template>+ </teleport>+ </td>+ <td class="border-r border-[var(--border-primary)] align-middle">+ <input type="number" step="0.01" v-model.number="editingSegments[segment._originalIndex].start_time" class="w-full px-3 py-2.5 bg-transparent border-0 focus:outline-none text-sm text-[var(--text-primary)] text-center" />+ </td>+ <td class="border-r border-[var(--border-primary)] align-middle">+ <input type="number" step="0.01" v-model.number="editingSegments[segment._originalIndex].end_time" class="w-full px-3 py-2.5 bg-transparent border-0 focus:outline-none text-sm text-[var(--text-primary)] text-center" />+ </td>+ <td class="border-r border-[var(--border-primary)] align-top">+ <textarea v-model="editingSegments[segment._originalIndex].sentence" rows="1" class="w-full px-3 py-2.5 bg-transparent border-0 focus:outline-none text-sm text-[var(--text-primary)] resize-none max-h-20 overflow-y-auto custom-scrollbar block" @input="autoResizeTextarea($event)"></textarea>+ </td>+ <td class="px-1 text-center align-middle">+ <div class="flex items-center justify-center gap-1">+ <button @click="$refs.asrEditorAudioRef && ($refs.asrEditorAudioRef.currentTime = segment.start_time, $refs.asrEditorAudioRef.play())" class="p-1.5 rounded hover:bg-[var(--bg-accent)] text-[var(--text-muted)] hover:text-[var(--text-accent)] transition-colors" :title="t('help.playFromHere')">+ <i class="fas fa-play text-xs"></i>+ </button>+ <button @click="addSegmentBelow(segment._originalIndex)" class="p-1.5 rounded hover:bg-green-600/20 text-[var(--text-muted)] hover:text-green-500 transition-colors" :title="t('help.addSegmentBelow')">+ <i class="fas fa-plus text-xs"></i>+ </button>+ <button @click="removeSegment(segment._originalIndex)" class="p-1.5 rounded hover:bg-red-600/20 text-[var(--text-muted)] hover:text-red-500 transition-colors" :title="t('help.deleteSegment')">+ <i class="fas fa-trash text-xs"></i>+ </button>+ </div>+ </td></tr>++ <!-- Virtual scroll spacer (bottom) -->+ <tr v-if="asrEditorSpacerAfter > 0"><td colspan="5" :style="{ height: asrEditorSpacerAfter + 'px', padding: 0 }"></td></tr></tbody></table><div class="py-4 flex justify-center">