feat #14740: play back calls

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
hauke
2026-11-10 13:37:47 +01:00
co-authored by Claude Opus 5.5
parent 8d757fd639
commit a74cfa5864
16 changed files with 1335 additions and 12 deletions
+123 -1
View File
@@ -5,6 +5,7 @@
errorText,
getCall,
getRecordingState,
getSettings,
listCalls,
mergeSpeakers,
onBackendLoginError,
@@ -27,6 +28,8 @@
} from '../lib/api'
import CallList from '../lib/CallList.svelte'
import { formatDateTime, formatDetailTime, formatMinutes } from '../lib/format'
import Player from '../lib/Player.svelte'
import { segmentAt } from '../lib/playback'
import StatusPill from '../lib/StatusPill.svelte'
import TranscriptView from '../lib/TranscriptView.svelte'
import UpdateBanner from '../lib/UpdateBanner.svelte'
@@ -56,6 +59,16 @@
let uploading = $state<CallId[]>([])
let uploadErrors = $state<Record<CallId, string>>({})
// Playback of the shown call (the player itself lives in `Player`).
let player = $state<ReturnType<typeof Player>>()
/** The playback position once the mix is loaded, else `null`. */
let playerTime = $state<number | null>(null)
let playing = $state(false)
/** Whether the transcript scrolls along; scrolling by hand ends it. */
let follow = $state(true)
/** For "… werden N Tage nach der Transkription gelöscht". */
let retentionDays = $state<number | null>(null)
let editingTitle = $state(false)
let titleDraft = $state('')
let savingTitle = $state(false)
@@ -103,9 +116,16 @@
}
}
function resetPlayback() {
playerTime = null
playing = false
follow = true
}
function select(id: CallId) {
if (id === selectedId) return
selectedId = id
resetPlayback()
detail = null
detailError = ''
actionError = ''
@@ -118,6 +138,7 @@
function clearSelection() {
selectedId = null
resetPlayback()
detail = null
detailError = ''
actionError = ''
@@ -145,6 +166,9 @@
}),
]
refreshList()
getSettings()
.then((settings) => (retentionDays = settings.retention_days))
.catch(() => {})
getRecordingState()
.then((state) => (recordingState = state))
.catch((err) => (recordError = errorText(err)))
@@ -310,6 +334,28 @@
node.select()
}
/** A click on a transcript line: plays from there and follows again. */
function playFrom(secs: number) {
follow = true
player?.playFrom(secs)
}
const SCROLL_KEYS = ['ArrowUp', 'ArrowDown', 'PageUp', 'PageDown', 'Home', 'End', ' ']
/** Scrolling the detail by hand while playing stops following the
* playback (until "folgen" or a click on a line). Only user input counts:
* the transcript's own scrolling raises none of these events. */
function manualScroll(event: Event) {
if (!playing) return
if (event instanceof KeyboardEvent) {
const target = event.target as HTMLElement
if (!SCROLL_KEYS.includes(event.key) || target.closest('input, textarea, button')) return
}
// A press on the scroll bar (not on the content).
if (event instanceof PointerEvent && event.target !== event.currentTarget) return
follow = false
}
/** "Microsoft Teams · heute 10:14 · 32 min" (no duration while recording). */
function defaultTitle(call: CallListItem): string {
const parts = [call.app, formatDetailTime(call.started_at)]
@@ -330,6 +376,11 @@
// Calls that still need the user's attention (not transcribed, or
// transcribed but not uploaded here) — shown as "Gespräche · N offen".
let openCount = $derived(calls.filter((c) => c.needs_action).length)
/** The transcript line being heard, highlighted while the mix is loaded. */
let activeIndex = $derived(
detail && playerTime !== null ? segmentAt(detail.segments, playerTime) : null,
)
</script>
<main class="main">
@@ -364,7 +415,15 @@
</div>
</aside>
<section class="detail">
<!-- The handlers only watch for scrolling by hand (see manualScroll). -->
<!-- svelte-ignore a11y_no_static_element_interactions -->
<section
class="detail"
onwheel={manualScroll}
ontouchmove={manualScroll}
onkeydown={manualScroll}
onpointerdown={manualScroll}
>
{#if detail}
{@const call = detail.call}
<header class="detail-header">
@@ -433,6 +492,36 @@
{/if}
</header>
{#if call.status !== 'recording' && call.status !== 'processing'}
{#if detail.audio_available}
<div class="playback-bar">
{#key call.id}
<Player
bind:this={player}
callId={call.id}
estimate={call.duration_secs}
ontime={(secs) => (playerTime = secs)}
onplaying={(value) => (playing = value)}
/>
{/key}
{#if call.status === 'done' && detail.segments.length > 0}
<button
class="btn small follow"
class:on={follow}
aria-pressed={follow}
title="Das Transkript scrollt mit der Wiedergabe mit"
onclick={() => (follow = !follow)}>folgen</button
>
{/if}
</div>
{:else}
<p class="muted no-audio">
Audio nicht mehr vorhanden – Aufnahmen werden {retentionDays ?? '…'} Tage nach der
Transkription gelöscht (<a href="#/settings">Einstellungen</a>).
</p>
{/if}
{/if}
<div class="body">
{#if call.status === 'recording'}
<p class="state rec">● Aufnahme läuft</p>
@@ -456,6 +545,9 @@
onrename={rename}
onmerge={merge}
onunmerge={unmerge}
{activeIndex}
follow={follow && playing}
onseek={detail.audio_available ? playFrom : undefined}
/>
{/if}
</div>
@@ -681,6 +773,36 @@
margin: 10px 0 0;
}
/* Stays at the top while the transcript scrolls under it. */
.playback-bar {
position: sticky;
top: -18px; /* the detail's top padding: flush with its edge */
z-index: 2;
display: flex;
align-items: center;
gap: 10px;
margin: 0 -24px 14px;
padding: 8px 24px;
background: var(--bg);
border-bottom: 1px solid var(--border);
}
.follow {
flex-shrink: 0;
color: var(--muted);
font-weight: 600;
}
.follow.on {
border-color: var(--primary);
background: var(--primary-soft);
color: var(--primary);
}
.no-audio {
margin: 0 0 14px;
}
.state {
color: var(--muted);
}