Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions apps/desktop/src-tauri/src/recording.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1057,29 +1057,39 @@ pub async fn start_recording(
let _ = RecordingEvent::Stopped.emit(&app);
}
Err(e) => {
let mut state = state_mtx.write().await;

let error = e.to_string();
let _ = RecordingEvent::Failed {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor cleanup: e.to_string() is computed 3x here; consider computing it once and reusing it (also keeps the error message consistent across event/state cleanup/dialog).

Suggested change
let _ = RecordingEvent::Failed {
Err(e) => {
let error = e.to_string();
let _ = RecordingEvent::Failed {
error: error.clone(),
}
.emit(&app);
{
let mut state = state_mtx.write().await;
let _ = handle_recording_end(
app.clone(),
Err(error.clone()),
&mut state,
project_file_path,
)
.await;
}
let mut dialog = MessageDialogBuilder::new(
app.dialog().clone(),
"An error occurred".to_string(),
error,
)
.kind(tauri_plugin_dialog::MessageDialogKind::Error);

Copy link
Author

@chindris-mihai-alexandru chindris-mihai-alexandru Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied in 7beab87. I now compute the error string once and reuse it for the failed event payload, cleanup path, and dialog message.

error: e.to_string(),
error: error.clone(),
}
.emit(&app);

{
let mut state = state_mtx.write().await;
handle_recording_end(
app.clone(),
Err(error.clone()),
&mut state,
project_file_path,
)
.await
.ok();
}

let mut dialog = MessageDialogBuilder::new(
app.dialog().clone(),
"An error occurred".to_string(),
e.to_string(),
error,
)
.kind(tauri_plugin_dialog::MessageDialogKind::Error);

if let Some(window) = CapWindowId::RecordingControls.get(&app) {
if let Some(window) = CapWindowId::Main
.get(&app)
.or_else(|| CapWindowId::RecordingControls.get(&app))
{
dialog = dialog.parent(&window);
}

dialog.blocking_show();

handle_recording_end(app, Err(e.to_string()), &mut state, project_file_path)
.await
.ok();
}
}
}
Expand Down