Skip to content

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

Python

Sticky speaker labels now follow the entire speaker run, not just the first segment — grouped consecutive same-speaker segments into .speaker-run wrappers in app.modular.js (new simpleSegmentRuns precomputed array) and rebuilt the desktop-transcription-panel template to iterate over runs instead of segments; the speaker-tablet at the top of each .speaker-run uses position:sticky;top:0 so it pins for ALL the run's segments instead of disappearing after the first; also fix the Select Template programmatic modal in ui.js to use modal-* primitive chrome (was rounded-md mismatched) and escape user-supplied template name/description via _esc helper to prevent injection; gitignore internal-docs/ folder for the design-system reference doc

Murtaza Nasiraeba354c39a7
diff --git a/.gitignore b/.gitignore
index 1e5f05ff..dca70be0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -57,3 +57,7 @@ final-*.png
# Session-internal scratch (UX redesign notes etc.). These live in
# temp/ so you can read them locally, but they shouldn't be tracked.
temp/ux-redesign-*.md
+
+# Internal-only documentation (design system, working notes, etc.).
+# Lives on disk for local reference but is never tracked.
+internal-docs/
diff --git a/static/css/styles.css b/static/css/styles.css
index d0987b48..964bdfa0 100644
--- a/static/css/styles.css
+++ b/static/css/styles.css
@@ -1666,55 +1666,22 @@ body {
transition: background-color 0.3s ease, box-shadow 0.3s ease;
}
-/* Sticky speaker labels: as the user scrolls past a speaker segment,
- * its speaker label pin to the top of the transcript scroll area so the
- * current speaker is always visible. Implemented per-segment via
- * position:sticky so the natural reading flow is preserved (no JS).
- * Activates a small gradient backdrop when the tablet is stuck so it
- * stays legible against transcript prose. */
-.speaker-segment .speaker-tablet,
-.speaker-segment .speaker-tablet-group {
+/* Speaker run: wraps consecutive same-speaker segments so the sticky
+ * speaker tablet at the top of the run sticks for the entire run.
+ * Without this grouping, each segment was its own sticky scope and the
+ * tablet would disappear as soon as the first segment scrolled past. */
+.speaker-run {
+ position: relative;
+ margin-bottom: 1.25rem;
+}
+
+/* Sticky speaker tablet — pinned to the top of its .speaker-run so it
+ * stays visible across all the run's segments. Pure CSS, no JS. */
+.speaker-run > .speaker-tablet,
+.speaker-run > .speaker-tablet-group {
position: sticky;
top: 0;
z-index: 5;
-}
-
-/* Soft gradient backdrop behind the sticky tablet so prose underneath
- * doesn't read through the label. Uses the rail surface so it adapts to
- * theme. */
-.speaker-segment .speaker-tablet::before,
-.speaker-segment .speaker-tablet-group::before {
- content: '';
- position: absolute;
- inset: -2px -8px -2px -8px;
- background: linear-gradient(
- to bottom,
- var(--bg-primary) 0%,
- var(--bg-primary) 60%,
- rgba(0, 0, 0, 0) 100%
- );
- z-index: -1;
- pointer-events: none;
- opacity: 0;
- transition: opacity 0.15s ease;
-}
-
-/* The "stuck" detection trick: when the parent .speaker-segment is
- * being scrolled past, the sticky element's offsetTop equals the
- * scroll container's scrollTop. We can't detect this in pure CSS, so
- * we use a subtle box-shadow that appears whenever the sticky element
- * is at top:0 of the viewport. position:sticky doesn't expose a
- * "stuck" state to CSS, but the gradient is visible only when the
- * tablet sits above content; harmless cosmetic otherwise. */
-.speaker-segment .speaker-tablet:not(:first-child)::before,
-.speaker-segment .speaker-tablet-group:not(:first-child)::before {
- opacity: 1;
-}
-
-/* The tablet itself needs a small visual indication so the "this is the
- * current speaker" anchor stays subtly highlighted while stuck. */
-.speaker-segment .speaker-tablet,
-.speaker-segment .speaker-tablet-group {
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
diff --git a/static/js/app.modular.js b/static/js/app.modular.js
index b44404f9..4ab9618e 100644
--- a/static/js/app.modular.js
+++ b/static/js/app.modular.js
@@ -1642,11 +1642,34 @@ document.addEventListener('DOMContentLoaded', async () => {
}));
const processedSimpleSegments = [];
+ // Group consecutive same-speaker segments into runs
+ // so the sticky speaker tablet at the top of each
+ // run sticks for the entire run, not just the first
+ // segment. Each run is { speaker, color, startTime,
+ // speakerId, segments: [original simpleSegments] }.
+ const simpleSegmentRuns = [];
let lastSpeakerId = null;
- simpleSegments.forEach(segment => {
+ let runOffset = 0; // index of the first segment in the current run
+ simpleSegments.forEach((segment, idx) => {
+ const isNewSpeaker = segment.speakerId !== lastSpeakerId;
processedSimpleSegments.push({
...segment,
- showSpeaker: segment.speakerId !== lastSpeakerId
+ showSpeaker: isNewSpeaker
+ });
+ if (isNewSpeaker) {
+ simpleSegmentRuns.push({
+ speaker: segment.speaker,
+ color: segment.color,
+ speakerId: segment.speakerId,
+ startTime: segment.startTime || segment.start_time,
+ runOffset: idx,
+ segments: []
+ });
+ runOffset = idx;
+ }
+ simpleSegmentRuns[simpleSegmentRuns.length - 1].segments.push({
+ ...segment,
+ originalIndex: idx
});
lastSpeakerId = segment.speakerId;
});
@@ -1675,6 +1698,7 @@ document.addEventListener('DOMContentLoaded', async () => {
isJson: true,
segments: simpleSegments,
simpleSegments: processedSimpleSegments,
+ simpleSegmentRuns: simpleSegmentRuns,
bubbleRows: bubbleRows,
speakers: speakers.map(speaker => ({
name: speakerMap.value[speaker]?.name || speaker,
diff --git a/static/js/modules/composables/ui.js b/static/js/modules/composables/ui.js
index 921ea48f..8d2c3f34 100644
--- a/static/js/modules/composables/ui.js
+++ b/static/js/modules/composables/ui.js
@@ -1542,27 +1542,44 @@ export function useUI(state, utils, processedTranscription) {
templates = await templatesResponse.json();
}
- // If there are templates, show a selection dialog
+ // If there are templates, show a selection dialog (built as
+ // a programmatic modal — uses the same modal-overlay /
+ // modal-panel / modal-header / modal-body / modal-footer
+ // primitives as Vue-rendered modals so the chrome matches).
let templateId = null;
if (templates.length > 0) {
- // Create a simple modal for template selection
+ // Escape user-supplied template name/description before
+ // injection. Translations and is_default flag are
+ // controlled values; template id is constrained by the
+ // DOM data attribute.
+ const _esc = (s) => String(s == null ? '' : s)
+ .replace(/&/g, '&')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;')
+ .replace(/"/g, '&quot;')
+ .replace(/'/g, '&#39;');
const modal = document.createElement('div');
- modal.className = 'fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50';
+ modal.className = 'modal-overlay';
modal.innerHTML = `
- <div class="bg-[var(--bg-secondary)] rounded-lg p-6 max-w-md w-full mx-4">
- <h3 class="text-lg font-semibold mb-4">${t('transcriptTemplates.selectTemplate')}</h3>
- <div class="space-y-2 max-h-60 overflow-y-auto">
- ${templates.map(tmpl => `
- <button class="template-option w-full text-left p-3 rounded border border-[var(--border-primary)] hover:bg-[var(--bg-tertiary)] ${tmpl.is_default ? 'ring-2 ring-[var(--ring-focus)]' : ''}" data-template-id="${tmpl.id}">
- <div class="font-medium">${tmpl.name}</div>
- ${tmpl.description ? `<div class="text-sm text-[var(--text-muted)]">${tmpl.description}</div>` : ''}
- ${tmpl.is_default ? `<div class="text-xs text-[var(--text-accent)] mt-1"><i class="fas fa-star mr-1"></i>${t('transcriptTemplates.default')}</div>` : ''}
- </button>
- `).join('')}
+ <div class="modal-panel modal-panel--sm">
+ <div class="modal-header">
+ <h3 class="modal-title">${_esc(t('transcriptTemplates.selectTemplate'))}</h3>
+ <button class="modal-close cancel-btn" title="Close"><i class="fas fa-times"></i></button>
</div>
- <div class="mt-4 flex gap-2">
- <button class="cancel-btn px-4 py-2 bg-[var(--bg-tertiary)] text-[var(--text-secondary)] rounded hover:bg-[var(--bg-accent-light)]">${t('transcriptTemplates.cancel')}</button>
- <button class="download-without-template-btn px-4 py-2 bg-[var(--bg-accent)] text-white rounded hover:bg-[var(--bg-accent-hover)]">${t('transcriptTemplates.downloadWithoutTemplate')}</button>
+ <div class="modal-body" style="padding: var(--sp-2);">
+ <div class="space-y-1 max-h-60 overflow-y-auto">
+ ${templates.map(tmpl => `
+ <button class="template-option w-full text-left p-3 rounded-md border border-[var(--border-primary)] hover:bg-[var(--bg-tertiary)] transition-colors ${tmpl.is_default ? 'ring-1 ring-[var(--text-accent)]' : ''}" data-template-id="${_esc(tmpl.id)}">
+ <div class="t-body-strong">${_esc(tmpl.name)}</div>
+ ${tmpl.description ? `<div class="t-meta">${_esc(tmpl.description)}</div>` : ''}
+ ${tmpl.is_default ? `<div class="t-meta mt-1" style="color: var(--text-accent);"><i class="fas fa-star mr-1"></i>${_esc(t('transcriptTemplates.default'))}</div>` : ''}
+ </button>
+ `).join('')}
+ </div>
+ </div>
+ <div class="modal-footer">
+ <button class="cancel-btn btn btn--ghost">${_esc(t('transcriptTemplates.cancel'))}</button>
+ <button class="download-without-template-btn btn btn--primary">${_esc(t('transcriptTemplates.downloadWithoutTemplate'))}</button>
</div>
</div>
`;
diff --git a/templates/components/detail/desktop-transcription-panel.html b/templates/components/detail/desktop-transcription-panel.html
index ad580f13..fc6febcd 100644
--- a/templates/components/detail/desktop-transcription-panel.html
+++ b/templates/components/detail/desktop-transcription-panel.html
@@ -205,27 +205,33 @@
<!-- Simple View -->
<div v-if="!processedTranscription.hasDialogue || transcriptionViewMode === 'simple'"
class="transcription-simple-view">
+ <!-- Speaker runs (consecutive same-speaker segments
+ grouped into one container) so the sticky speaker
+ tablet at the top of each run sticks for the WHOLE
+ run, not just the first segment. -->
<div v-if="processedTranscription.hasDialogue">
- <div v-for="(segment, index) in processedTranscription.simpleSegments"
- :key="`seg-${index}-${segment.startTime}`"
- :class="['speaker-segment', { 'active-playing-segment': currentPlayingSegmentIndex === index }]"
- @click="seekAudioFromEvent"
- @dblclick.stop="openAsrEditorAtSegment(index)"
- :title="'Double-click to edit this segment'"
- :data-start-time="segment.startTime"
- :data-segment-index="index">
- <template v-if="segment.showSpeaker">
- <div v-if="showTimestampsSimpleView"
- :class="['speaker-tablet-group', segment.color]">
- <span class="speaker-tablet-time">${ formatTimestamp(segment.startTime) }</span>
- <span class="speaker-tablet-name">${segment.speaker}</span>
- </div>
- <div v-else :class="['speaker-tablet', segment.color]">
- ${segment.speaker}
+ <div v-for="(run, runIndex) in processedTranscription.simpleSegmentRuns"
+ :key="`run-${runIndex}-${run.startTime}`"
+ class="speaker-run">
+ <div v-if="showTimestampsSimpleView"
+ :class="['speaker-tablet-group', run.color]">
+ <span class="speaker-tablet-time">${ formatTimestamp(run.startTime) }</span>
+ <span class="speaker-tablet-name">${run.speaker}</span>
+ </div>
+ <div v-else :class="['speaker-tablet', run.color]">
+ ${run.speaker}
+ </div>
+ <div v-for="(segment, segIndex) in run.segments"
+ :key="`seg-${segment.originalIndex}-${segment.startTime}`"
+ :class="['speaker-segment', { 'active-playing-segment': currentPlayingSegmentIndex === segment.originalIndex }]"
+ @click="seekAudioFromEvent"
+ @dblclick.stop="openAsrEditorAtSegment(segment.originalIndex)"
+ :title="'Double-click to edit this segment'"
+ :data-start-time="segment.startTime"
+ :data-segment-index="segment.originalIndex">
+ <div class="speaker-text">
+ ${segment.sentence}
</div>
- </template>
- <div class="speaker-text">
- ${segment.sentence}
</div>
</div>
</div>