feat #14740: automatic call detection on windows

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
hauke
2026-11-05 15:38:55 +01:00
co-authored by Claude Opus 5.5
parent 61bf18e47f
commit d631252600
15 changed files with 1255 additions and 71 deletions
+102
View File
@@ -0,0 +1,102 @@
<script lang="ts">
import { onMount } from 'svelte'
import {
discardCall,
errorText,
getCallBrief,
getPendingPrompt,
onCallEnded,
transcribeCall,
type CallBrief,
type CallId,
} from '../lib/api'
import { formatMinutes, formatTimeRange } from '../lib/format'
let brief = $state<CallBrief | null>(null)
let busy = $state(false)
let error = $state('')
function show(next: CallBrief | null) {
if (next?.id !== brief?.id) error = ''
brief = next
}
// The window stays loaded while hidden, so it may have missed the event:
// ask the backend whenever it is shown again.
const refresh = () =>
getPendingPrompt()
.then(show)
.catch((err) => (error = errorText(err)))
const load = (id: CallId) =>
getCallBrief(id)
.then(show)
.catch((err) => (error = errorText(err)))
onMount(() => {
const unlisten = onCallEnded(load)
refresh()
window.addEventListener('focus', refresh)
return () => {
window.removeEventListener('focus', refresh)
unlisten.then((off) => off())
}
})
async function run(action: (id: CallId) => Promise<void>) {
if (!brief) return
busy = true
error = ''
try {
await action(brief.id)
} catch (err) {
error = errorText(err)
} finally {
busy = false
}
}
</script>
<main class="prompt">
{#if brief}
<div class="title">{brief.app} · {formatMinutes(brief.duration_secs)}</div>
<div class="muted">{formatTimeRange(brief.started_at, brief.ended_at)}</div>
<div class="actions">
<button class="btn primary" disabled={busy} onclick={() => run(transcribeCall)}>
Transkribieren
</button>
<button class="btn danger" disabled={busy} onclick={() => run(discardCall)}>Verwerfen</button>
</div>
{:else}
<p class="muted">Kein Gespräch wartet auf eine Entscheidung.</p>
{/if}
{#if error}
<div class="error">{error}</div>
{/if}
</main>
<style>
:global(body:has(.prompt)) {
overflow: hidden;
}
.prompt {
min-height: 100vh;
background: var(--surface);
padding: 14px;
}
.title {
font-weight: 600;
}
.actions {
display: flex;
gap: 8px;
margin-top: 14px;
}
.error {
margin-top: 8px;
}
</style>