feat #14740: start recording from the main window
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
discardCall,
|
||||
errorText,
|
||||
getCall,
|
||||
getRecordingState,
|
||||
listAccounts,
|
||||
listCalls,
|
||||
mergeSpeakers,
|
||||
@@ -15,12 +16,15 @@
|
||||
renameSpeaker,
|
||||
retryCall,
|
||||
setAccount,
|
||||
showRecorder,
|
||||
startManualRecording,
|
||||
transcribeCall,
|
||||
unmergeSpeaker,
|
||||
type Account,
|
||||
type CallDetail,
|
||||
type CallId,
|
||||
type CallListItem,
|
||||
type RecordingState,
|
||||
} from '../lib/api'
|
||||
import CallList from '../lib/CallList.svelte'
|
||||
import { formatDetailTime, formatMinutes } from '../lib/format'
|
||||
@@ -33,6 +37,10 @@
|
||||
let listError = $state('')
|
||||
let accounts = $state<Account[]>([])
|
||||
|
||||
let recordingState = $state<RecordingState>({ state: 'idle' })
|
||||
let recordBusy = $state(false)
|
||||
let recordError = $state('')
|
||||
|
||||
let selectedId = $state<CallId | null>(null)
|
||||
let detail = $state<CallDetail | null>(null)
|
||||
let detailError = $state('')
|
||||
@@ -115,15 +123,45 @@
|
||||
}),
|
||||
onCallEnded(refreshList),
|
||||
onPromptChanged(refreshList),
|
||||
onRecordingState(refreshList),
|
||||
onRecordingState((state) => {
|
||||
recordingState = state
|
||||
refreshList()
|
||||
}),
|
||||
]
|
||||
refreshList()
|
||||
getRecordingState()
|
||||
.then((state) => (recordingState = state))
|
||||
.catch((err) => (recordError = errorText(err)))
|
||||
listAccounts()
|
||||
.then((list) => (accounts = list))
|
||||
.catch((err) => (listError = errorText(err)))
|
||||
return () => unlisten.forEach((u) => u.then((off) => off()))
|
||||
})
|
||||
|
||||
/** The record button: starts a manual recording, or shows the floating
|
||||
* recorder window if one already runs (same as the tray entry). Errors
|
||||
* (e.g. "Es läuft bereits eine Aufnahme", device errors) show inline in
|
||||
* the sidebar header. */
|
||||
async function recordClick() {
|
||||
recordError = ''
|
||||
if (recordingState.state === 'recording') {
|
||||
try {
|
||||
await showRecorder()
|
||||
} catch (err) {
|
||||
recordError = errorText(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
recordBusy = true
|
||||
try {
|
||||
await startManualRecording()
|
||||
} catch (err) {
|
||||
recordError = errorText(err)
|
||||
} finally {
|
||||
recordBusy = false
|
||||
}
|
||||
}
|
||||
|
||||
/** Runs a command on the shown call; its error is shown inline. */
|
||||
async function run(action: (id: CallId) => Promise<void>, done?: () => void) {
|
||||
if (!detail) return
|
||||
@@ -235,8 +273,23 @@
|
||||
<aside class="sidebar">
|
||||
<header class="sidebar-header">
|
||||
<h1>Gespräche</h1>
|
||||
<a class="gear" href="#/settings" title="Einstellungen" aria-label="Einstellungen">⚙</a>
|
||||
<div class="header-actions">
|
||||
<button
|
||||
class="btn small record-btn"
|
||||
class:primary={recordingState.state !== 'recording'}
|
||||
class:recording={recordingState.state === 'recording'}
|
||||
disabled={recordBusy}
|
||||
title="Aufnahme manuell starten"
|
||||
onclick={recordClick}
|
||||
>
|
||||
{recordingState.state === 'recording' ? 'Aufnahme läuft' : '● Aufnahme'}
|
||||
</button>
|
||||
<a class="gear" href="#/settings" title="Einstellungen" aria-label="Einstellungen">⚙</a>
|
||||
</div>
|
||||
</header>
|
||||
{#if recordError}
|
||||
<p class="error record-error">{recordError}</p>
|
||||
{/if}
|
||||
<div class="list">
|
||||
{#if listError}
|
||||
<p class="error pad">{listError}</p>
|
||||
@@ -399,6 +452,27 @@
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.record-btn {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.record-btn.recording {
|
||||
background: var(--rec-soft);
|
||||
border-color: var(--rec);
|
||||
color: var(--rec);
|
||||
}
|
||||
|
||||
.record-error {
|
||||
margin: 0;
|
||||
padding: 8px 16px 0;
|
||||
}
|
||||
|
||||
.gear {
|
||||
color: var(--muted);
|
||||
font-size: 18px;
|
||||
|
||||
Reference in New Issue
Block a user