From a740b53627e650185ec5b2bcbb9048283e324f19 Mon Sep 17 00:00:00 2001 From: bdeshi Date: Fri, 13 Nov 2026 14:13:32 +0600 Subject: [PATCH] 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 --- Sources/AppDelegate.swift | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) 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