fix(cards): URL task dialogs no longer crash the app on Windows
Opening the dialog read AppState while the card action was still updating it. The panic could not unwind through the window procedure and aborted the app. The caller now hands the engine over instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -315,6 +315,7 @@ impl AppState {
315
315
scope: scope.clone(),
316
316
web_application_resource,
317
317
},
318
self.engine.clone(),
318
319
cx,
319
320
);
320
321
if in_dialog {
@@ -315,6 +315,7 @@ impl AppState {315
scope: scope.clone(),315
scope: scope.clone(),316
web_application_resource,316
web_application_resource,317
},317
},318
self.engine.clone(),318
cx,319
cx,319
);320
);320
if in_dialog {321
if in_dialog {@@ -1,5 +1,8 @@
1
use std::sync::Arc;
2
1
3
use gpui_kit::*;
2
4
5
use crate::backend::Engine;
3
6
use crate::card_state::CardScope;
4
7
5
8
#[cfg(windows)]
@@ -36,11 +39,11 @@ pub enum UrlDialogNext {
36
39
}
37
40
38
41
#[cfg(windows)]
39
pub fn open_url_dialog(dialog: UrlDialog, cx: &mut App) {
40
hosted::open(dialog, cx);
42
pub fn open_url_dialog(dialog: UrlDialog, engine: Option<Arc<Engine>>, cx: &mut App) {
43
hosted::open(dialog, engine, cx);
41
44
}
42
45
43
46
#[cfg(not(windows))]
44
pub fn open_url_dialog(dialog: UrlDialog, cx: &mut App) {
47
pub fn open_url_dialog(dialog: UrlDialog, _engine: Option<Arc<Engine>>, cx: &mut App) {
45
48
cx.open_url(&dialog.fallback_url);
46
49
}
@@ -1,5 +1,8 @@1
use std::sync::Arc;2
1
use gpui_kit::*;3
use gpui_kit::*;2
4
5
use crate::backend::Engine;3
use crate::card_state::CardScope;6
use crate::card_state::CardScope;4
7
5
#[cfg(windows)]8
#[cfg(windows)]@@ -36,11 +39,11 @@ pub enum UrlDialogNext {36
}39
}37
40
38
#[cfg(windows)]41
#[cfg(windows)]39
pub fn open_url_dialog(dialog: UrlDialog, cx: &mut App) {42
pub fn open_url_dialog(dialog: UrlDialog, engine: Option<Arc<Engine>>, cx: &mut App) {40
hosted::open(dialog, cx);43
hosted::open(dialog, engine, cx);41
}44
}42
45
43
#[cfg(not(windows))]46
#[cfg(not(windows))]44
pub fn open_url_dialog(dialog: UrlDialog, cx: &mut App) {47
pub fn open_url_dialog(dialog: UrlDialog, _engine: Option<Arc<Engine>>, cx: &mut App) {45
cx.open_url(&dialog.fallback_url);48
cx.open_url(&dialog.fallback_url);46
}49
}@@ -17,13 +17,12 @@ pub fn install_host(transport: Arc<WebViewTransport>) {
17
17
let _ = HOST.set(transport);
18
18
}
19
19
20
pub fn open(dialog: UrlDialog, cx: &mut App) {
20
pub fn open(dialog: UrlDialog, engine: Option<Arc<Engine>>, cx: &mut App) {
21
21
let Some(host) = HOST.get().cloned() else {
22
22
cx.open_url(&dialog.fallback_url);
23
23
return;
24
24
};
25
25
let state = cx.global::<AppHandle>().0.clone();
26
let engine = state.read(cx).engine.clone();
27
26
let owner = cx
28
27
.active_window()
29
28
.and_then(|window| {
@@ -17,13 +17,12 @@ pub fn install_host(transport: Arc<WebViewTransport>) {17
let _ = HOST.set(transport);17
let _ = HOST.set(transport);18
}18
}19
19
20
pub fn open(dialog: UrlDialog, cx: &mut App) {20
pub fn open(dialog: UrlDialog, engine: Option<Arc<Engine>>, cx: &mut App) {21
let Some(host) = HOST.get().cloned() else {21
let Some(host) = HOST.get().cloned() else {22
cx.open_url(&dialog.fallback_url);22
cx.open_url(&dialog.fallback_url);23
return;23
return;24
};24
};25
let state = cx.global::<AppHandle>().0.clone();25
let state = cx.global::<AppHandle>().0.clone();26
let engine = state.read(cx).engine.clone();27
let owner = cx26
let owner = cx28
.active_window()27
.active_window()29
.and_then(|window| {28
.and_then(|window| {