From e2189ee335e0d71fc39a397ace708a1a00fdeb58 Mon Sep 17 00:00:00 2001 From: "blu@blu.cx" <38222767+thebrandonlucas@users.noreply.github.com> Date: Wed, 28 Oct 2026 04:59:49 -0500 Subject: [PATCH] fix(gpui): load older thread replies after the list releases its state GPUI calls a list's scroll handler while it holds the list's state borrowed. The thread panel's handler called load_older, which reads and changes that state, so scrolling up in a thread with older replies panicked with "RefCell already borrowed" and aborted the app. Run load_older with cx.defer instead. Fixes #89 --- apps/buzz-gpui/crates/app/src/ui/thread.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/buzz-gpui/crates/app/src/ui/thread.rs b/apps/buzz-gpui/crates/app/src/ui/thread.rs index e4e77841161..31689be3bf0 100644 --- a/apps/buzz-gpui/crates/app/src/ui/thread.rs +++ b/apps/buzz-gpui/crates/app/src/ui/thread.rs @@ -301,7 +301,12 @@ impl ThreadPanel { let weak = cx.entity().downgrade(); list.set_scroll_handler(move |event, _, cx| { if event.visible_range.start < LOAD_OLDER_WITHIN && event.is_scrolled { - let _ = weak.update(cx, |this, _| this.load_older()); + // GPUI runs this while it holds the list's state, and + // load_older reads and changes that state; run it after. + let weak = weak.clone(); + cx.defer(move |cx| { + let _ = weak.update(cx, |this, _| this.load_older()); + }); } }); let tasks = vec![