fix(oauth): detect WebView window close to unblock login wait

When the user closes the OAuth WebView window manually, the
Destroyed event now triggers notify to unblock the 5-minute
timeout immediately, returning oauth_cancelled instead of
hanging until timeout.

cc
This commit is contained in:
vicrodh committed 2026-04-08 08:37:02 -06:00
1 parent dbc97d6bd1
commit 814bf8b968
1 file changed
+12 -1
+12 -1
View File
@@ -1846,7 +1846,18 @@ pub async fn v2_start_oauth_login(
.build()
.map_err(|e| format!("Failed to open OAuth window: {}", e))?;
// Wait up to 5 minutes for the user to complete login
// Detect when user closes the OAuth window manually
_oauth_window.on_window_event({
let notify_close = Arc::clone(&notify);
move |event| {
if let tauri::WindowEvent::Destroyed = event {
log::info!("[OAuth] WebView window destroyed, unblocking wait");
notify_close.notify_one();
}
}
});
// Wait up to 5 minutes for the user to complete login (or window close)
let timed_out = tokio::time::timeout(std::time::Duration::from_secs(300), notify.notified())
.await
.is_err();