From 498cc6e4bc25faa07de115f43e1b17025df13d37 Mon Sep 17 00:00:00 2001 From: Lawrence Chen <54008264+lawrencecchen@users.noreply.github.com> Date: Sun, 8 Feb 2026 19:03:25 -0800 Subject: [PATCH] Fix update pill never appearing in toolbar @Published fires on willSet, so the Combine sink measured fittingSize while SwiftUI still saw the old state (idle/EmptyView), getting 0x0. Defer measurement to next run loop cycle so SwiftUI processes the new state before we read fittingSize. --- Sources/WindowToolbarController.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sources/WindowToolbarController.swift b/Sources/WindowToolbarController.swift index fedadd35..c340ce88 100644 --- a/Sources/WindowToolbarController.swift +++ b/Sources/WindowToolbarController.swift @@ -133,8 +133,12 @@ final class WindowToolbarController: NSObject, NSToolbarDelegate { updateSizeCancellables[key] = updateViewModel.$state .receive(on: DispatchQueue.main) .sink { [weak self, weak view] _ in - guard let self, let view else { return } - self.sizeToolbarItem(for: key, hostingView: view) + // @Published fires on willSet, so SwiftUI hasn't processed the + // new state yet. Defer measurement to the next run loop cycle. + DispatchQueue.main.async { [weak self, weak view] in + guard let self, let view else { return } + self.sizeToolbarItem(for: key, hostingView: view) + } } return item }