Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python

Fix merge notes picker being empty from the sidebar: expose a has_notes flag in the recordings list dict (notes text is excluded there for lightness) and detect notes via it

Murtaza Nasird3906d36ed4d
diff --git a/src/models/recording.py b/src/models/recording.py
index c0a1562d..c3d7cf1b 100644
--- a/src/models/recording.py
+++ b/src/models/recording.py
@@ -339,6 +339,10 @@ class Recording(db.Model):
'id': self.id,
'title': self.title,
'participants': self.participants,
+ # Cheap boolean (full notes text is excluded from the list for
+ # lightness) — lets the merge modal offer this recording as a notes
+ # source without loading every recording's notes.
+ 'has_notes': bool(self.notes and self.notes.strip()),
'status': self.status,
'created_at': self.created_at.isoformat() if self.created_at else None,
'completed_at': self.completed_at.isoformat() if self.completed_at else None,
diff --git a/static/js/modules/composables/bulk-operations.js b/static/js/modules/composables/bulk-operations.js
index 80b0fce5..4629732e 100644
--- a/static/js/modules/composables/bulk-operations.js
+++ b/static/js/modules/composables/bulk-operations.js
@@ -47,9 +47,10 @@ export function useBulkOperations({
// '__self__' (the recorded clip), or null (keep no notes).
const mergeNotesSourceId = ref(null);
// Sources in the merge that actually have notes — drives the selector.
- const mergeNotesCandidates = computed(() =>
- mergeOrderedList.value.filter(r => r && r.notes && String(r.notes).trim())
- );
+ // List dicts carry a cheap `has_notes` flag; detail dicts and the recorded
+ // clip carry full `notes` text. Accept either.
+ const _entryHasNotes = (r) => !!(r && (r.has_notes || (r.notes && String(r.notes).trim())));
+ const mergeNotesCandidates = computed(() => mergeOrderedList.value.filter(_entryHasNotes));
// Keep the notes selection valid as the list changes: default to the first
// source with notes; respect an explicit "keep none" ('none'); and if the
// chosen source leaves the list, fall back to the first remaining one.
diff --git a/tests/test_cov_recordings_read.py b/tests/test_cov_recordings_read.py
index 96ea203e..b5d466b5 100644
--- a/tests/test_cov_recordings_read.py
+++ b/tests/test_cov_recordings_read.py
@@ -315,6 +315,24 @@ def test_paginated_folder_filter(owner):
assert no_folder not in ids
+def test_paginated_list_includes_has_notes_flag(owner):
+ # The merge notes picker relies on this cheap flag (full notes text is not
+ # shipped in the list).
+ with _db():
+ u = db.session.get(User, owner)
+ wn = make_recording(u, title="wn")
+ wn.notes = "some notes"
+ db.session.commit()
+ with_notes = wn.id
+ without = make_recording(u, title="wo").id
+ c = new_client()
+ login(c, owner)
+ resp = c.get("/api/recordings?per_page=100")
+ by_id = {r["id"]: r for r in resp.get_json()["recordings"]}
+ assert by_id[with_notes]["has_notes"] is True
+ assert by_id[without]["has_notes"] is False
+
+
def test_paginated_status_filter(owner):
# The merge picker uses ?status=COMPLETED to fetch only mergeable recordings.
with _db():