Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
Item 6 (recent tag/folder suggestions + clearable chips) — most users follow a recording routine (same tags, same folder, same language across uploads) and re-picking them every time is friction; now after a successful upload the form choices are memo-ed to localStorage as 'lastUploadDefaults' (tag IDs, folder ID, language, min/max speakers) and a new hydrateUploadDefaults() helper restores them the FIRST time a file lands in the queue, only filling slots the user hasn't already set (idempotent — never clobbers a deliberate choice this session) and only restoring tag IDs / folder IDs that still exist on the user's account (graceful degradation if a tag or folder was deleted between sessions); the hydration is deferred until file-added rather than firing on modal mount so a user who opens then immediately closes the modal doesn't get residual chips lingering; second half: each chip in the Options summary now has an inline × button that clears just that selection via @click.stop.prevent so the click doesn't toggle the <details> open state — folder × wipes selectedFolderId, tags × wipes selectedTagIds, language × wipes uploadLanguage, speakers × wipes both min and max — gives the user one-tap escape from any restored value they don't want this time
Murtaza Nasir5b159de890d9
diff --git a/static/js/modules/composables/upload.js b/static/js/modules/composables/upload.jsindex 97f5411a..17690e46 100644--- a/static/js/modules/composables/upload.js+++ b/static/js/modules/composables/upload.js@@ -190,8 +190,56 @@ export function useUpload(state, utils) {e.target.value = null;};+ // Restore the previous upload's form choices (tags / folder /+ // language / min-max speakers) when (a) we have a memo from a+ // prior successful upload and (b) the user hasn't set anything+ // for this upload yet. Idempotent — only fills empty slots so a+ // user who already picked something doesn't get clobbered. Called+ // automatically when the first file lands in the queue.+ let _hydrateAttempted = false;+ const hydrateUploadDefaults = () => {+ if (_hydrateAttempted) return;+ _hydrateAttempted = true;+ let memo;+ try {+ const raw = localStorage.getItem('lastUploadDefaults');+ if (!raw) return;+ memo = JSON.parse(raw);+ } catch (_) { return; }+ if (!memo) return;+ // Tags: only fill if nothing currently selected. Also drop+ // any tag IDs that no longer exist on the user's account.+ if (selectedTagIds && (!selectedTagIds.value || selectedTagIds.value.length === 0)+ && Array.isArray(memo.tagIds) && memo.tagIds.length > 0+ && Array.isArray(availableTags?.value)) {+ const liveIds = new Set(availableTags.value.map(t => t.id));+ const restored = memo.tagIds.filter(id => liveIds.has(id));+ if (restored.length > 0) selectedTagIds.value = restored;+ }+ if (selectedFolderId && (selectedFolderId.value == null) && memo.folderId != null) {+ // Only restore if the folder still exists.+ if (Array.isArray(availableFolders?.value)+ && availableFolders.value.some(f => f.id === memo.folderId)) {+ selectedFolderId.value = memo.folderId;+ }+ }+ if (uploadLanguage && !uploadLanguage.value && memo.language) {+ uploadLanguage.value = memo.language;+ }+ if (uploadMinSpeakers && !uploadMinSpeakers.value && memo.minSpeakers) {+ uploadMinSpeakers.value = memo.minSpeakers;+ }+ if (uploadMaxSpeakers && !uploadMaxSpeakers.value && memo.maxSpeakers) {+ uploadMaxSpeakers.value = memo.maxSpeakers;+ }+ };+// Add files to the upload queueconst addFilesToQueue = (files) => {+ // Restore last-upload defaults the first time a file lands in+ // the queue (deferred until then so a user who opens then+ // immediately closes the modal doesn't get residual chips).+ hydrateUploadDefaults();let filesAdded = 0;for (const file of files) {const fileObject = file.file ? file.file : file;@@ -575,6 +623,23 @@ export function useUpload(state, utils) {recordings.value.unshift(data);totalRecordings.value++;+ // Remember the upload-form choices so the NEXT modal open+ // can pre-fill them. Most users follow a routine (same+ // tags, same folder, same language) and re-typing them on+ // every upload is friction. Persisted in localStorage;+ // restored by hydrateUploadDefaults() on the first file+ // added to the queue.+ try {+ const memo = {+ tagIds: Array.isArray(selectedTagIds?.value) ? [...selectedTagIds.value] : [],+ folderId: selectedFolderId?.value ?? null,+ language: uploadLanguage?.value ?? '',+ minSpeakers: uploadMinSpeakers?.value ?? '',+ maxSpeakers: uploadMaxSpeakers?.value ?? ''+ };+ localStorage.setItem('lastUploadDefaults', JSON.stringify(memo));+ } catch (_) { /* localStorage disabled / quota — ignore */ }+// For in-app recordings (where the upload modal opened// automatically after the user stopped recording), auto-// navigate to the new recording's detail view — otherwisediff --git a/templates/components/upload-view.html b/templates/components/upload-view.htmlindex 6e6f0eff..4cf09471 100644--- a/templates/components/upload-view.html+++ b/templates/components/upload-view.html@@ -413,7 +413,11 @@<span class="text-sm font-medium" style="color: var(--text-secondary);">Options</span><!-- Chip summary of currently-set values. Each- chip is conditionally rendered. -->+ chip has a small × button so the user can+ clear individual selections without expanding+ the full editor. @click.stop.prevent stops+ the click from toggling the <details> open+ state (we want JUST the clear, not expand). --><div class="flex items-center gap-1 ml-2 flex-wrap min-w-0"><!-- Folder chip --><span v-if="foldersEnabled && selectedFolderId && getFolderById(selectedFolderId)"@@ -421,6 +425,11 @@:style="{ background: getFolderColor(selectedFolderId) + '22', color: getFolderColor(selectedFolderId) }"><i class="fas fa-folder"></i><span class="truncate max-w-[120px]" v-text="getFolderById(selectedFolderId).name"></span>+ <button @click.stop.prevent="selectedFolderId = null"+ class="hover:opacity-100 opacity-70"+ title="Clear folder">+ <i class="fas fa-times text-[9px]"></i>+ </button></span><!-- Tag count chip --><span v-if="selectedTags.length > 0"@@ -428,6 +437,11 @@style="background: var(--bg-accent); color: var(--text-accent);"><i class="fas fa-tag"></i><span>${ selectedTags.length } ${ selectedTags.length === 1 ? 'tag' : 'tags' }</span>+ <button @click.stop.prevent="selectedTagIds = []"+ class="hover:opacity-100 opacity-70"+ title="Clear tags">+ <i class="fas fa-times text-[9px]"></i>+ </button></span><!-- Language chip (only if non-default) --><span v-if="uploadLanguage"@@ -435,6 +449,11 @@style="background: var(--bg-accent); color: var(--text-accent);"><i class="fas fa-language"></i><span v-text="uploadLanguage"></span>+ <button @click.stop.prevent="uploadLanguage = ''"+ class="hover:opacity-100 opacity-70"+ title="Clear language">+ <i class="fas fa-times text-[9px]"></i>+ </button></span><!-- Speakers chip (only if non-default) --><span v-if="uploadMinSpeakers || uploadMaxSpeakers"@@ -442,6 +461,11 @@style="background: var(--bg-accent); color: var(--text-accent);"><i class="fas fa-users"></i><span>${ uploadMinSpeakers || '?' }${ uploadMinSpeakers != uploadMaxSpeakers ? '-' + (uploadMaxSpeakers || '?') : '' }</span>+ <button @click.stop.prevent="uploadMinSpeakers = ''; uploadMaxSpeakers = ''"+ class="hover:opacity-100 opacity-70"+ title="Clear speakers">+ <i class="fas fa-times text-[9px]"></i>+ </button></span></div>