From fa384e9f8fd523b4b6be8edeedc0c30d00f026e6 Mon Sep 17 00:00:00 2001 From: venator Date: Sun, 18 Oct 2026 19:37:45 +0200 Subject: [PATCH] Open Settings once the shell's update is over, so the rail's cog no longer crashes the window. Co-Authored-By: Claude Opus 5.5 --- crates/tinyclient/src/gui/settings/mod.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/tinyclient/src/gui/settings/mod.rs b/crates/tinyclient/src/gui/settings/mod.rs index 352db90..6def3d8 100644 --- a/crates/tinyclient/src/gui/settings/mod.rs +++ b/crates/tinyclient/src/gui/settings/mod.rs @@ -212,7 +212,13 @@ pub fn meter(level: Option, cx: &mut App) { } /// Opens Settings on `section`, or brings the open window forward and shows `section` there. +/// Safe to call while the shell is already being updated: the shell's own buttons call it from +/// inside its update, and a new window reads the shell as it first draws. pub fn open(section: Section, cx: &mut App) { + cx.defer(move |cx| open_now(section, cx)); +} + +fn open_now(section: Section, cx: &mut App) { let host = cx.default_global::(); let Some(shell) = host.shell.clone() else { return; @@ -965,7 +971,12 @@ pub fn shot(cx: &mut App) { cx.spawn(async move |cx| { cx.background_executor().timer(std::time::Duration::from_millis(900)).await; let open_on = Section::ALL.into_iter().find(|s| s.name().to_lowercase().starts_with(§ion.to_lowercase())).unwrap_or(Section::Accounts); - cx.update(|cx| open(open_on, cx)); + // From inside the shell's update, as the shell's own buttons open it. + cx.update(|cx| { + if let Some(shell) = cx.default_global::().shell.clone() { + let _ = shell.update(cx, |_, cx| open(open_on, cx)); + } + }); let Some(window) = cx.update(|cx| cx.default_global::().window) else { return; };