feat #14740: start recording from the main window
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -355,12 +355,21 @@ pub fn show_main(app: &AppHandle) {
|
||||
show_and_focus(app, "main");
|
||||
}
|
||||
|
||||
/// Brings the floating window to the front (tray "Aufnahme manuell
|
||||
/// starten" while a recording runs).
|
||||
pub fn show_recorder(app: &AppHandle) {
|
||||
/// Brings the floating window to the front: the tray's "Aufnahme manuell
|
||||
/// starten" and the main window's record button both call this instead of
|
||||
/// starting a second recording when one is already running.
|
||||
pub fn focus_recorder(app: &AppHandle) {
|
||||
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) {
|
||||
if let Some(window) = app.get_webview_window(label) {
|
||||
let _ = window.unminimize();
|
||||
|
||||
@@ -123,6 +123,7 @@ pub fn run() {
|
||||
commands::test_devices,
|
||||
commands::get_recording_state,
|
||||
commands::start_manual_recording,
|
||||
commands::show_recorder,
|
||||
commands::stop_recording,
|
||||
commands::discard_current_recording,
|
||||
commands::get_pending_prompt,
|
||||
|
||||
@@ -38,7 +38,7 @@ pub fn create(app: &AppHandle) -> tauri::Result<()> {
|
||||
app.state::<AppState>().recording_state(),
|
||||
RecordingState::Recording { .. }
|
||||
) {
|
||||
commands::show_recorder(app);
|
||||
commands::focus_recorder(app);
|
||||
return;
|
||||
}
|
||||
// Opening the audio devices can take a moment; keep the
|
||||
|
||||
@@ -128,6 +128,8 @@ export const listDevices = () => invoke<Devices>('list_devices')
|
||||
export const testDevices = () => invoke<DeviceLevels>('test_devices')
|
||||
export const getRecordingState = () => invoke<RecordingState>('get_recording_state')
|
||||
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 discardCurrentRecording = () => invoke<void>('discard_current_recording')
|
||||
export const getPendingPrompt = () => invoke<PendingPrompt | null>('get_pending_prompt')
|
||||
|
||||
@@ -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>
|
||||
<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