feat #14740: start recording from the main window

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
hauke
2026-11-06 12:03:46 +01:00
co-authored by Claude Sonnet 5
parent c7811b75ae
commit 57a99417d0
5 changed files with 92 additions and 6 deletions
+12 -3
View File
@@ -355,12 +355,21 @@ pub fn show_main(app: &AppHandle) {
show_and_focus(app, "main"); show_and_focus(app, "main");
} }
/// Brings the floating window to the front (tray "Aufnahme manuell /// Brings the floating window to the front: the tray's "Aufnahme manuell
/// starten" while a recording runs). /// starten" and the main window's record button both call this instead of
pub fn show_recorder(app: &AppHandle) { /// starting a second recording when one is already running.
pub fn focus_recorder(app: &AppHandle) {
show_and_focus(app, "recorder"); show_and_focus(app, "recorder");
} }
/// Main window record button while a recording already runs: shows/focuses
/// the floating recorder window instead of starting another recording.
/// Shares [`focus_recorder`] with the tray handler.
#[tauri::command]
pub fn show_recorder(app: AppHandle) {
focus_recorder(&app);
}
fn show_and_focus(app: &AppHandle, label: &str) { fn show_and_focus(app: &AppHandle, label: &str) {
if let Some(window) = app.get_webview_window(label) { if let Some(window) = app.get_webview_window(label) {
let _ = window.unminimize(); let _ = window.unminimize();
+1
View File
@@ -123,6 +123,7 @@ pub fn run() {
commands::test_devices, commands::test_devices,
commands::get_recording_state, commands::get_recording_state,
commands::start_manual_recording, commands::start_manual_recording,
commands::show_recorder,
commands::stop_recording, commands::stop_recording,
commands::discard_current_recording, commands::discard_current_recording,
commands::get_pending_prompt, commands::get_pending_prompt,
+1 -1
View File
@@ -38,7 +38,7 @@ pub fn create(app: &AppHandle) -> tauri::Result<()> {
app.state::<AppState>().recording_state(), app.state::<AppState>().recording_state(),
RecordingState::Recording { .. } RecordingState::Recording { .. }
) { ) {
commands::show_recorder(app); commands::focus_recorder(app);
return; return;
} }
// Opening the audio devices can take a moment; keep the // Opening the audio devices can take a moment; keep the
+2
View File
@@ -128,6 +128,8 @@ export const listDevices = () => invoke<Devices>('list_devices')
export const testDevices = () => invoke<DeviceLevels>('test_devices') export const testDevices = () => invoke<DeviceLevels>('test_devices')
export const getRecordingState = () => invoke<RecordingState>('get_recording_state') export const getRecordingState = () => invoke<RecordingState>('get_recording_state')
export const startManualRecording = () => invoke<CallId>('start_manual_recording') export const startManualRecording = () => invoke<CallId>('start_manual_recording')
/** Shows/focuses the floating recorder window instead of starting another recording. */
export const showRecorder = () => invoke<void>('show_recorder')
export const stopRecording = () => invoke<void>('stop_recording') export const stopRecording = () => invoke<void>('stop_recording')
export const discardCurrentRecording = () => invoke<void>('discard_current_recording') export const discardCurrentRecording = () => invoke<void>('discard_current_recording')
export const getPendingPrompt = () => invoke<PendingPrompt | null>('get_pending_prompt') export const getPendingPrompt = () => invoke<PendingPrompt | null>('get_pending_prompt')
+76 -2
View File
@@ -4,6 +4,7 @@
discardCall, discardCall,
errorText, errorText,
getCall, getCall,
getRecordingState,
listAccounts, listAccounts,
listCalls, listCalls,
mergeSpeakers, mergeSpeakers,
@@ -15,12 +16,15 @@
renameSpeaker, renameSpeaker,
retryCall, retryCall,
setAccount, setAccount,
showRecorder,
startManualRecording,
transcribeCall, transcribeCall,
unmergeSpeaker, unmergeSpeaker,
type Account, type Account,
type CallDetail, type CallDetail,
type CallId, type CallId,
type CallListItem, type CallListItem,
type RecordingState,
} from '../lib/api' } from '../lib/api'
import CallList from '../lib/CallList.svelte' import CallList from '../lib/CallList.svelte'
import { formatDetailTime, formatMinutes } from '../lib/format' import { formatDetailTime, formatMinutes } from '../lib/format'
@@ -33,6 +37,10 @@
let listError = $state('') let listError = $state('')
let accounts = $state<Account[]>([]) let accounts = $state<Account[]>([])
let recordingState = $state<RecordingState>({ state: 'idle' })
let recordBusy = $state(false)
let recordError = $state('')
let selectedId = $state<CallId | null>(null) let selectedId = $state<CallId | null>(null)
let detail = $state<CallDetail | null>(null) let detail = $state<CallDetail | null>(null)
let detailError = $state('') let detailError = $state('')
@@ -115,15 +123,45 @@
}), }),
onCallEnded(refreshList), onCallEnded(refreshList),
onPromptChanged(refreshList), onPromptChanged(refreshList),
onRecordingState(refreshList), onRecordingState((state) => {
recordingState = state
refreshList()
}),
] ]
refreshList() refreshList()
getRecordingState()
.then((state) => (recordingState = state))
.catch((err) => (recordError = errorText(err)))
listAccounts() listAccounts()
.then((list) => (accounts = list)) .then((list) => (accounts = list))
.catch((err) => (listError = errorText(err))) .catch((err) => (listError = errorText(err)))
return () => unlisten.forEach((u) => u.then((off) => off())) 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. */ /** Runs a command on the shown call; its error is shown inline. */
async function run(action: (id: CallId) => Promise<void>, done?: () => void) { async function run(action: (id: CallId) => Promise<void>, done?: () => void) {
if (!detail) return if (!detail) return
@@ -235,8 +273,23 @@
<aside class="sidebar"> <aside class="sidebar">
<header class="sidebar-header"> <header class="sidebar-header">
<h1>Gespräche</h1> <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> </header>
{#if recordError}
<p class="error record-error">{recordError}</p>
{/if}
<div class="list"> <div class="list">
{#if listError} {#if listError}
<p class="error pad">{listError}</p> <p class="error pad">{listError}</p>
@@ -399,6 +452,27 @@
font-size: 16px; 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 { .gear {
color: var(--muted); color: var(--muted);
font-size: 18px; font-size: 18px;