Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
Upload modal items 4 + 5: inline file preview (duration + file-type icon) and sticky modal-footer Upload action — (item 4) per-file row in the queue display now shows the file's audio/video duration alongside its size, populated asynchronously by a new computeFileDuration helper in upload.js that uses a hidden <audio> or <video> element with preload='metadata' so the browser only reads the container headers without downloading the whole payload; resolves to null gracefully for corrupt / unsupported codecs / timeout (8 s safety); video files get a sky-blue fa-file-video glyph instead of the audio one so the queue at a glance shows the mix of types relevant to the keep-audio-only toggle; (item 5) the Upload + Incognito-upload buttons used to live inside the queued-files div, only visible after scrolling past it; now they live in a real sticky <div class='modal-footer modal-footer--between'> at the bottom of the modal-panel where they stay reachable while the user scrolls through the queue + Options group; footer has Cancel on the left (calls closeUploadView) and Upload (or Incognito Upload when active) on the right; primary button is properly disabled with a clear 'Upload' label when no files are queued so the next required step is signposted; incognito multi-file hint preserved as a paragraph just above the footer border
Murtaza Nasir6ad2f7f28de4
diff --git a/static/js/modules/composables/upload.js b/static/js/modules/composables/upload.jsindex 84a36d46..97f5411a 100644--- a/static/js/modules/composables/upload.js+++ b/static/js/modules/composables/upload.js@@ -59,6 +59,34 @@ export function useUpload(state, utils) {const { setGlobalError, showToast, formatFileSize, onChatComplete, t } = utils;+ // Probe a File for its audio/video duration without uploading it.+ // Uses a hidden <audio> or <video> element with preload="metadata"+ // so the browser only reads the container headers, not the whole+ // payload. Resolves to seconds (number) or null if the file can't+ // be parsed (corrupt, unsupported codec, etc.). Used by the upload+ // queue to populate item.duration on each queued file so the user+ // sees length + size next to the filename before uploading.+ const computeFileDuration = (file) => new Promise((resolve) => {+ try {+ const isVideo = /^video\//i.test(file.type)+ || /\.(mp4|mov|mkv|avi|webm|m4v|wmv|flv|ts|mts|mpeg|mpg|ogv|vob|asf)$/i.test(file.name);+ const url = URL.createObjectURL(file);+ const el = document.createElement(isVideo ? 'video' : 'audio');+ el.preload = 'metadata';+ const done = (val) => {+ try { URL.revokeObjectURL(url); } catch (_) {}+ resolve(val);+ };+ el.onloadedmetadata = () => done(isFinite(el.duration) ? el.duration : null);+ el.onerror = () => done(null);+ // Safety timeout — some browsers stall on unsupported codecs+ setTimeout(() => done(null), 8000);+ el.src = url;+ } catch (_) {+ resolve(null);+ }+ });+// Compute selected tags from IDsconst selectedTags = computed(() => {return selectedTagIds.value.map(id =>@@ -228,7 +256,7 @@ export function useUpload(state, utils) {// which is extremely expensive for binary File/Blob payloads// and was a likely cause of the UI freeze seen when 10+ files// were queued at once (issue #280).- uploadQueue.value.push({+ const queueItem = {file: markRaw ? markRaw(fileObject) : fileObject,notes: notes,tags: tags,@@ -237,8 +265,22 @@ export function useUpload(state, utils) {recordingId: null,clientId: clientId,error: null,+ // Populated asynchronously by computeFileDuration+ // below — the queue display reads item.duration to+ // show e.g. "12:34" next to the filename. Leaving+ // it null shows just size until probing finishes+ // (usually well under a second).+ duration: null,willAutoSummarize: false // Server will tell us via SUMMARIZING status- });+ };+ uploadQueue.value.push(queueItem);+ // Fire-and-forget duration probe. Mutating the queue+ // item's `duration` field after the push is reactive+ // because the item itself is a plain object Vue+ // tracks; only the inner File is markRaw.+ computeFileDuration(fileObject).then(d => {+ queueItem.duration = d;+ }).catch(() => {});filesAdded++;} else if (fileObject) {setGlobalError(t('upload.invalidFileType', { name: fileObject.name }));diff --git a/templates/components/upload-view.html b/templates/components/upload-view.htmlindex 637b7de7..d3fefbb1 100644--- a/templates/components/upload-view.html+++ b/templates/components/upload-view.html@@ -40,9 +40,26 @@class="flex flex-col gap-0.5 px-2 py-1.5 bg-[var(--bg-tertiary)] rounded border border-[var(--border-secondary)]"><div class="flex items-center justify-between"><div class="flex items-center gap-1.5 min-w-0 flex-1">- <i class="fas fa-file-audio text-[var(--text-muted)] text-xs"></i>- <span class="text-xs text-[var(--text-primary)] truncate">${item.file.name}</span>- <span class="text-[10px] text-[var(--text-muted)] flex-shrink-0">(${formatFileSize(item.file.size)})</span>+ <!-- File-type icon: video files get a+ video glyph so users instantly see+ which queue items are video at a+ glance (relevant for the audio-+ only / video-retention toggles). -->+ <i :class="[+ 'text-xs flex-shrink-0',+ /\.(mp4|mov|mkv|avi|webm|m4v|wmv|flv|ts|mts|mpeg|mpg|ogv|vob|asf)$/i.test(item.file.name)+ ? 'fas fa-file-video text-sky-500'+ : 'fas fa-file-audio text-[var(--text-muted)]'+ ]"></i>+ <span class="text-xs text-[var(--text-primary)] truncate" v-text="item.file.name"></span>+ <!-- Size + duration. Duration is+ populated asynchronously by the+ computeFileDuration probe in+ upload.js; while null we just show+ size. -->+ <span class="text-[10px] text-[var(--text-muted)] flex-shrink-0">+ (${ formatFileSize(item.file.size) }<span v-if="item.duration">, ${ formatDuration(item.duration) }</span>)+ </span></div><button @click="removeFromQueue(item.clientId)"class="ml-1.5 p-0.5 text-[var(--text-muted)] hover:text-red-500 transition-colors flex-shrink-0"@@ -170,32 +187,9 @@</button></div>- <!-- Upload Buttons -->- <div class="mt-2 space-y-2">- <!-- Normal Upload Button (when not in incognito mode or feature disabled) -->- <button v-if="!incognitoMode || !enableIncognitoMode"- @click="startUpload"- class="btn btn--lg btn--primary w-full">- <i class="fas fa-cloud-upload-alt"></i>- <span v-text="t('upload.uploadNFiles', { count: pendingQueueFiles.length })"></span>- </button>-- <!-- Incognito Upload Button (only when feature enabled and mode selected) -->- <button v-else-if="enableIncognitoMode && incognitoMode"- @click="startIncognitoUpload"- :disabled="incognitoProcessing || pendingQueueFiles.length !== 1"- class="w-full px-4 py-2.5 bg-gradient-to-r from-violet-500 to-purple-600 text-white rounded-lg hover:from-violet-600 hover:to-purple-700 disabled:opacity-50 disabled:cursor-not-allowed transition-all flex items-center justify-center gap-2 font-medium text-sm shadow-sm">- <i :class="incognitoProcessing ? 'fas fa-spinner fa-spin' : 'fas fa-user-secret'"></i>- <span v-if="incognitoProcessing">${ t('incognito.processing') }</span>- <span v-else-if="pendingQueueFiles.length !== 1">${ t('incognito.selectExactlyOneFile') }</span>- <span v-else>${ t('incognito.processInIncognito') }</span>- </button>-- <p v-if="enableIncognitoMode && incognitoMode && pendingQueueFiles.length > 1" class="text-xs text-violet-600 dark:text-violet-400 text-center">- <i class="fas fa-info-circle mr-1"></i>- ${ t('incognito.oneFileAtATime') }- </p>- </div>+ <!-- Note: Upload + Incognito-upload buttons moved to+ the sticky modal-footer below so the primary+ action is always reachable without scrolling. --></div><!-- Divider (hidden when files are selected) -->@@ -728,5 +722,44 @@</div><!-- end .mt-2 wrapper inside details --></details><!-- end Options progressive-disclosure group --></div>++ <!-- Sticky modal-footer: primary Upload action always visible+ without scrolling. The button is enabled only when the+ queue has files; otherwise it's a clear, disabled+ affordance pointing at the next required step. The+ Incognito variant swaps in when incognito mode is active. -->+ <p v-if="enableIncognitoMode && incognitoMode && pendingQueueFiles.length > 1"+ class="text-xs text-violet-600 dark:text-violet-400 text-center px-5 py-2 border-t"+ style="border-top-color: var(--border-primary);">+ <i class="fas fa-info-circle mr-1"></i>+ ${ t('incognito.oneFileAtATime') }+ </p>+ <div class="modal-footer modal-footer--between">+ <button @click="closeUploadView" class="btn btn--ghost">+ <span v-text="t('common.cancel')"></span>+ </button>++ <!-- Normal Upload Button (when not in incognito mode or feature disabled) -->+ <button v-if="!incognitoMode || !enableIncognitoMode"+ @click="startUpload"+ :disabled="pendingQueueFiles.length === 0"+ class="btn btn--primary">+ <i class="fas fa-cloud-upload-alt"></i>+ <span v-if="pendingQueueFiles.length === 0">${ t('upload.title') || 'Upload' }</span>+ <span v-else v-text="t('upload.uploadNFiles', { count: pendingQueueFiles.length })"></span>+ </button>++ <!-- Incognito Upload Button (only when feature enabled and mode selected) -->+ <button v-else+ @click="startIncognitoUpload"+ :disabled="incognitoProcessing || pendingQueueFiles.length !== 1"+ class="btn btn--primary"+ style="background: linear-gradient(to right, #8b5cf6, #9333ea); border-color: transparent; color: white;">+ <i :class="incognitoProcessing ? 'fas fa-spinner fa-spin' : 'fas fa-user-secret'"></i>+ <span v-if="incognitoProcessing">${ t('incognito.processing') }</span>+ <span v-else-if="pendingQueueFiles.length !== 1">${ t('incognito.selectExactlyOneFile') }</span>+ <span v-else>${ t('incognito.processInIncognito') }</span>+ </button>+ </div></div></div>