Fix intermittently reappearing main-window title - #56
Merged
Merged
Conversation
SwiftUI's hosting bar-appearance bridge mirrors ContentView's .navigationTitle onto the AppKit-owned main window and re-asserts titleVisibility = .visible on asynchronous preference updates (first layout, content loads, window tiling). That races configureMainWindowChrome's .hidden and wins whenever it fires last, so the title showed up intermittently — reliably on cold-start window creation. Disable scene bridging on the manual window's NSHostingController so AppKit stays the sole owner of the window chrome. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The main window is supposed to show no titlebar title (the glass toolbar is the first content row under a transparent titlebar), but "Oh My Worktree" intermittently appeared next to the traffic lights — sometimes right after opening the window, and it persisted until app restart.
Root cause
A last-writer-wins race between AppKit and SwiftUI on
NSWindow.titleVisibility. An lldb breakpoint on-[NSWindow setTitleVisibility:]captured the sequence on the main window:NSHostingView.viewDidMoveToWindow→ SwiftUIBarAppearanceBridge.updateWindowTitlesets.visible(bridging ContentView's.navigationTitle("Oh My Worktree"))AppDelegate.configureMainWindowChromesets.hidden✓MainWindowChromeConfiguratorprobe re-applies.hidden✓NSHostingView.preferencesDidChange(ViewGraph render) →BarAppearanceBridgesets.visibleagain — final writer, title showsNSHostingControllerbridges title/toolbar scene preferences to its host window by default, and the bridge re-runs on async preference updates (first layout, content loads, window tiling), so whether the title showed depended on whichever side wrote last. Cold-start window creation (launch → open window ~2s later) reproduced it 3/3.Fix
Set
sceneBridgingOptions = []on theNSHostingControllerused for AppDelegate-managed windows, so AppKit stays the sole owner of the window chrome..navigationTitlestays in ContentView for the WindowGroup path; the manual window's title string is already set viawindow.titlefor the title-based window lookup.Verification
swiftlint lintcleanAppDelegate+*.swiftis on the coverage exclusion list, so the 100% gate is unaffected🤖 Generated with Claude Code