The board window says its name once — the scene declares the title SwiftUI keeps hiding

`HostedWindowController.hideTitle()` was the same shape of bug a429a7e fixed for
`titlebarAppearsTransparent`: an out-of-band `NSWindow.titleVisibility` write, correct the
instant it ran, undone by SwiftUI's own next pass over the window's configuration — a tree
that declares nothing resolves `.visible`, and SwiftUI writes that back over the out-of-band
`.hidden` on the very next `@State`-driven re-render this board window's own liveness causes.
The system title reappeared beside the board-popover widget, "occasionally" — whenever that
next re-render happened to land.

Confirmed with an A/B harness (no interactive display in this session, so not reproduced on
screen; mechanism established in code, per the card's own fallback): a bare out-of-band write
held indefinitely against resize and key-status changes alone, but reverted on the very next
`@State`-driven render and stayed reverted — reasserting from `body`'s own construction or
from `.onChange` both lost the same race, since SwiftUI's resync runs later than either. The
only thing that held was declaring the posture in the tree itself, mirroring
`.toolbarBackgroundVisibility`'s role in a429a7e.

`KanbanApp`'s board `WindowGroup` now declares `.windowToolbarStyle(.unified(showsTitle:
false))`. It is a scene modifier, not a per-window one, so — unlike `.toolbarBackgroundVisibility`
— it cannot wait for a board's load to finish before taking effect; every board window it
creates keeps the system title hidden from its very first frame. `boardLoadingTitlebarAccessory`
covers the gap that opens before the loading window has a store to build the real widget from: a
small, non-interactive, plain-text stand-in carrying the registry record's cached name, installed
the moment the window attaches and swapped by identity for the real widget the moment the store
loads — so the loading window's chrome still carries a name throughout, per 02-architecture.md.
`hideTitle()`'s own write stays; it is no longer what keeps the title hidden, but it is still
correct for the one render turn before the scene's own re-assertion catches up.

Confined to `BoardWindowHost.swift`, `BoardInfoPopover.swift` and `KanbanApp.swift` —
`WindowAccessor.swift`'s shared `hideTitle()`/`titleVisibility` machinery is untouched, since a
concurrent fix is addressing the card window's version of this same bug through that file.

New regression tests (`BoardLoadingTitlebarStandInTests`, `KanbanTests/BoardLoadingTests.swift`)
pin the stand-in's layout and the identity-based swap. Full suite green (3219 tests) except the
pre-existing, documented environment-sensitive `PointerLatencyTests`, confirmed unaffected by
rerunning them in isolation.

Claude-Session: https://claude.ai/code/session_014PtZdPwqZuqEDLc6wZMtEy
This commit is contained in:
2026-08-09 12:06:01 -04:00
parent 50e26efdb9
commit f4b2de55fb
4 changed files with 183 additions and 10 deletions
+68
View File
@@ -1,3 +1,4 @@
import AppKit
import Foundation
import Testing
@testable import Kanban
@@ -175,3 +176,70 @@ struct BoardLoadingTests {
)
}
}
// MARK: - The loading window's titlebar stand-in
/// **The duplicate-name bug's fix** (Pipeline card a73bad86): a board window's system title is kept
/// permanently hidden by `KanbanApp`'s `.windowToolbarStyle(.unified(showsTitle: false))` a scene
/// modifier that cannot wait for the store, so it hides the system title on the loading window too,
/// before there is a `BoardStore` to build the real widget from. `boardLoadingTitlebarAccessory`
/// is what fills that gap, and `BoardWindowHost.configureWindow` swaps it for the real widget by
/// removing it from the window by identity the same pattern
/// `HostedWindowController.removeTitlebarAccessory` uses for its own slot, pinned again here because
/// the swap itself runs inline in a private method with no seam of its own to call directly.
@MainActor
@Suite("Board loading state ▸ the titlebar stand-in")
struct BoardLoadingTitlebarStandInTests {
private static func window() -> NSWindow {
NSWindow(
contentRect: NSRect(x: 0, y: 0, width: 600, height: 400),
styleMask: [.titled, .closable, .miniaturizable, .resizable],
backing: .buffered,
defer: true
)
}
@Test("It lays out leading, exactly like the real widget it stands in for")
func laysOutLeading() {
let accessory = boardLoadingTitlebarAccessory(title: "Roadmap")
#expect(accessory.layoutAttribute == .leading)
// Wide and tall enough that it is never a zero-size, invisible widget the intrinsic
// measurement `.intrinsicContentSize` runs settles the exact figure, which is not the part
// worth pinning; not being clipped to nothing is.
#expect(accessory.view.frame.width > 0)
#expect(accessory.view.frame.height > 0)
}
@Test("Removing it by identity leaves any other accessory the window carries untouched")
func removalByIdentityIsTargeted() {
let window = Self.window()
let standIn = boardLoadingTitlebarAccessory(title: "Roadmap")
let other = boardLoadingTitlebarAccessory(title: "Some Other Board")
window.addTitlebarAccessoryViewController(standIn)
window.addTitlebarAccessoryViewController(other)
#expect(window.titlebarAccessoryViewControllers.count == 2)
// `BoardWindowHost.configureWindow`'s own removal: find by identity, remove by index.
if let index = window.titlebarAccessoryViewControllers.firstIndex(where: { $0 === standIn }) {
window.removeTitlebarAccessoryViewController(at: index)
}
#expect(window.titlebarAccessoryViewControllers.count == 1)
#expect(window.titlebarAccessoryViewControllers.first === other, "the untargeted one survives")
}
@Test("A window with no stand-in installed is left alone by the same removal")
func removalIsANoOpWithoutOne() {
let window = Self.window()
let other = boardLoadingTitlebarAccessory(title: "Some Other Board")
window.addTitlebarAccessoryViewController(other)
let standIn: NSTitlebarAccessoryViewController? = nil
if let standIn, let index = window.titlebarAccessoryViewControllers.firstIndex(where: { $0 === standIn }) {
window.removeTitlebarAccessoryViewController(at: index)
}
#expect(window.titlebarAccessoryViewControllers.count == 1, "nothing to remove, nothing removed")
}
}