Give the menu-bar hint popover an explicit size so it actually shows

NSPopover measures its content when show() is called, and a container sized
only by Auto Layout constraints has no frame to report yet, so show() failed
silently and the hint never appeared. The label and container now carry
explicit frames, and the view controller states its preferredContentSize.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bdeshiandClaude Sonnet 5.5 committed 2026-11-13 14:13:32 +06:00
1 parent 79395ef9d6
commit a740b53627
1 file changed
+12 -8
+12 -8
View File
@@ -442,25 +442,29 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate, LiveSt
guard !MenuBarHintShown.value, let button = statusItem.button else { return }
MenuBarHintShown.value = true
// Sized with an explicit frame rather than Auto Layout constraints
// alone: NSPopover computes its window size synchronously from
// contentViewController.view at the moment show() is called, and a
// container with no frame of its own — only constraints pinning a
// child to its edges — has nothing to report yet, so show() silently
// fails (isShown comes back false, nothing appears).
let label = NSTextField(wrappingLabelWithString: "Claude isn't running — click here to start a profile.")
label.font = .systemFont(ofSize: 13)
label.isEditable = false
label.isBordered = false
label.drawsBackground = false
label.preferredMaxLayoutWidth = 200
label.frame = NSRect(x: 14, y: 12, width: 200, height: 40)
label.sizeToFit()
label.frame.origin = NSPoint(x: 14, y: 12)
let container = NSView()
let containerSize = NSSize(width: label.frame.width + 28, height: label.frame.height + 24)
let container = NSView(frame: NSRect(origin: .zero, size: containerSize))
container.addSubview(label)
label.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
label.topAnchor.constraint(equalTo: container.topAnchor, constant: 12),
label.bottomAnchor.constraint(equalTo: container.bottomAnchor, constant: -12),
label.leadingAnchor.constraint(equalTo: container.leadingAnchor, constant: 14),
label.trailingAnchor.constraint(equalTo: container.trailingAnchor, constant: -14),
])
let viewController = NSViewController()
viewController.view = container
viewController.preferredContentSize = containerSize
let popover = NSPopover()
popover.contentViewController = viewController