diff --git a/Sources/AppDelegate.swift b/Sources/AppDelegate.swift index 337bf04..c7668a9 100644 --- a/Sources/AppDelegate.swift +++ b/Sources/AppDelegate.swift @@ -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