fix(update): never restart into an update during a call
- Idle check for the automatic update restart also requires no native call - Test covers the call case Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -41,10 +41,11 @@ pub struct IdleInputs {
41
41
pub window_active: bool,
42
42
pub composer_empty: bool,
43
43
pub send_in_flight: bool,
44
pub in_call: bool,
44
45
}
45
46
46
47
pub fn is_idle(inputs: IdleInputs) -> bool {
47
!inputs.window_active && inputs.composer_empty && !inputs.send_in_flight
48
!inputs.window_active && inputs.composer_empty && !inputs.send_in_flight && !inputs.in_call
48
49
}
49
50
50
51
pub fn update_is_ready(running: &str, published: Option<&str>, update_exe_exists: bool) -> bool {
@@ -307,11 +308,12 @@ mod tests {
307
308
window_active: false,
308
309
composer_empty: true,
309
310
send_in_flight: false,
311
in_call: false,
310
312
}
311
313
}
312
314
313
315
#[test]
314
fn idle_needs_all_three_conditions() {
316
fn idle_needs_all_conditions_and_no_call() {
315
317
assert!(is_idle(idle()));
316
318
assert!(!is_idle(IdleInputs {
317
319
window_active: true,
@@ -325,6 +327,10 @@ mod tests {
325
327
send_in_flight: true,
326
328
..idle()
327
329
}));
330
assert!(!is_idle(IdleInputs {
331
in_call: true,
332
..idle()
333
}));
328
334
}
329
335
330
336
#[test]
@@ -41,10 +41,11 @@ pub struct IdleInputs {41
pub window_active: bool,41
pub window_active: bool,42
pub composer_empty: bool,42
pub composer_empty: bool,43
pub send_in_flight: bool,43
pub send_in_flight: bool,44
pub in_call: bool,44
}45
}45
46
46
pub fn is_idle(inputs: IdleInputs) -> bool {47
pub fn is_idle(inputs: IdleInputs) -> bool {47
!inputs.window_active && inputs.composer_empty && !inputs.send_in_flight48
!inputs.window_active && inputs.composer_empty && !inputs.send_in_flight && !inputs.in_call48
}49
}49
50
50
pub fn update_is_ready(running: &str, published: Option<&str>, update_exe_exists: bool) -> bool {51
pub fn update_is_ready(running: &str, published: Option<&str>, update_exe_exists: bool) -> bool {@@ -307,11 +308,12 @@ mod tests {307
window_active: false,308
window_active: false,308
composer_empty: true,309
composer_empty: true,309
send_in_flight: false,310
send_in_flight: false,311
in_call: false,310
}312
}311
}313
}312
314
313
#[test]315
#[test]314
fn idle_needs_all_three_conditions() {316
fn idle_needs_all_conditions_and_no_call() {315
assert!(is_idle(idle()));317
assert!(is_idle(idle()));316
assert!(!is_idle(IdleInputs {318
assert!(!is_idle(IdleInputs {317
window_active: true,319
window_active: true,@@ -325,6 +327,10 @@ mod tests {325
send_in_flight: true,327
send_in_flight: true,326
..idle()328
..idle()327
}));329
}));330
assert!(!is_idle(IdleInputs {331
in_call: true,332
..idle()333
}));328
}334
}329
335
330
#[test]336
#[test]@@ -557,6 +557,7 @@ impl AppShell {
557
557
window_active: window.is_window_active(),
558
558
composer_empty: conversation.composer_is_empty(cx),
559
559
send_in_flight: conversation.send_in_flight(),
560
in_call: self.state.read(cx).call.is_some(),
560
561
});
561
562
// On Linux only the user restarts: the update dialog or the title bar button.
562
563
if idle && cfg!(not(target_os = "linux")) {
@@ -557,6 +557,7 @@ impl AppShell {557
window_active: window.is_window_active(),557
window_active: window.is_window_active(),558
composer_empty: conversation.composer_is_empty(cx),558
composer_empty: conversation.composer_is_empty(cx),559
send_in_flight: conversation.send_in_flight(),559
send_in_flight: conversation.send_in_flight(),560
in_call: self.state.read(cx).call.is_some(),560
});561
});561
// On Linux only the user restarts: the update dialog or the title bar button.562
// On Linux only the user restarts: the update dialog or the title bar button.562
if idle && cfg!(not(target_os = "linux")) {563
if idle && cfg!(not(target_os = "linux")) {