Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
- macOS 27 (direct build): a plain notification no longer holds auto-hide for up to 10 minutes. macOS keeps a screen-tall Notification Center window up under a notification, and auto-hide took it for the open panel. It now checks that the panel itself is open (it has Edit Widgets) before waiting ([#524](https://github.com/dwarvesf/hidden/issues/524)).

### Changed
- When auto-hide holds back because of the Settings window, the new-apps prompt, Notification Center, the palette or the pointer sitting in the menu bar, the log now says which, once per expansion. Look for "AutoCollapse: holding for" in Console.
- When auto-hide holds back because of the Settings window, the new-apps prompt, Notification Center, the palette or the pointer sitting in the menu bar, the log now says which, once per expansion. The reason line ("AutoCollapse: holding for ...") is readable in Console; the app behind a popup hold and other details are in the stderr log, which the manual's "Capture a log" shows how to save. The lines for a collapse macOS never answered and for "hiding unavailable" are readable in Console too.

## v1.13.1 (2026-11-18)

Expand Down
4 changes: 4 additions & 0 deletions Hidden Bar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
988E6BB58BB0E21724D3421E /* StackView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55F3F11C2608925A0054B881 /* StackView+Extension.swift */; };
99EA334772E1715B21C424BB /* MenuBarLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 092D9DE26A006349D87B304D /* MenuBarLayout.swift */; };
9B1765C0B5634CFABD06A916 /* AutoStartTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F013C3E5499B4EA7B816F7A8 /* AutoStartTests.swift */; };
A9D0DE00000000000000E002 /* AppLogTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D0DE00000000000000E001 /* AppLogTests.swift */; };
9C79B5D97BC90E0174BC52BE /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6F2F828CAAE82A4D34BDDCBB /* Cocoa.framework */; };
9CD9B70D63B58C9A7A31481A /* NotchOverflowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE73DB4E0664488997EEB6DE /* NotchOverflowController.swift */; };
9F3C757469DFAA7965B8380E /* CaptureActivityMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C1A7E52B9D04F6A8E21C0D7 /* CaptureActivityMonitor.swift */; };
Expand Down Expand Up @@ -369,6 +370,7 @@
DEFBDF50E5A67397D95D1946 /* UpdateController.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = UpdateController.swift; sourceTree = "<group>"; };
E3BF69BE15B7DE0272612470 /* NotchOverflowMenuBuilderTests.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = NotchOverflowMenuBuilderTests.swift; sourceTree = "<group>"; };
F013C3E5499B4EA7B816F7A8 /* AutoStartTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoStartTests.swift; sourceTree = "<group>"; };
A9D0DE00000000000000E001 /* AppLogTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLogTests.swift; sourceTree = "<group>"; };
F248811CF183BD0A4D71C4C6 /* NativeVisibilityEngine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeVisibilityEngine.swift; sourceTree = "<group>"; };
F51314A736131BE28182E378 /* AccessibilityPermission.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = AccessibilityPermission.swift; sourceTree = "<group>"; };
FB0B14538BC3AE95D43DE899 /* AccessibilityMenuBarInventory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessibilityMenuBarInventory.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -560,6 +562,7 @@
764544B7EDBB41A18087ED6F /* ExpandCollapseActionTests.swift */,
A0C0F1E5D3B2470A9C1E2002 /* AutoCollapsePopupGuardTests.swift */,
F013C3E5499B4EA7B816F7A8 /* AutoStartTests.swift */,
A9D0DE00000000000000E001 /* AppLogTests.swift */,
A27C0DE00000000000000004 /* MacOS27NoticeTests.swift */,
CC5FC25336EC320548CF4C87 /* AccessibilityPermissionTests.swift */,
60AFBE8D4C25548192E7D135 /* SettingsModelTests.swift */,
Expand Down Expand Up @@ -1210,6 +1213,7 @@
B12AD86D3E924502860225CC /* ExpandCollapseActionTests.swift in Sources */,
A0C0F1E5D3B2470A9C1E2014 /* AutoCollapsePopupGuardTests.swift in Sources */,
9B1765C0B5634CFABD06A916 /* AutoStartTests.swift in Sources */,
A9D0DE00000000000000E002 /* AppLogTests.swift in Sources */,
A27C0DE00000000000000003 /* MacOS27Notice.swift in Sources */,
A27C0DE00000000000000005 /* MacOS27NoticeTests.swift in Sources */,
A27C0DE00000000000000006 /* String+Extension.swift in Sources */,
Expand Down
36 changes: 36 additions & 0 deletions HiddenBarTests/AppLogTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// AppLogTests.swift
// HiddenBarTests
//
// Copyright © 2026 Console Labs. All rights reserved.
//

import XCTest

final class AppLogTests: XCTestCase {

func testStderrLineKeepsTheNSLogShape() {
XCTAssertEqual(AppLog.stderrLine("AutoCollapse: holding for the palette", timestamp: "2026-11-18 09:00:00.123",
process: "Hidden Bar", pid: 321, thread: 4567),
"2026-11-18 09:00:00.123 Hidden Bar[321:4567] AutoCollapse: holding for the palette\n")
}

func testPublicLineWritesTheTextOnceToStderr() throws {
let file = FileManager.default.temporaryDirectory.appendingPathComponent("applog-\(UUID().uuidString).txt")
FileManager.default.createFile(atPath: file.path, contents: nil)
defer { try? FileManager.default.removeItem(at: file) }
let saved = dup(STDERR_FILENO)
let handle = try FileHandle(forWritingTo: file)
dup2(handle.fileDescriptor, STDERR_FILENO)
AppLog.publicLine("AutoCollapse: holding for the palette 100%")
fflush(stderr)
dup2(saved, STDERR_FILENO)
close(saved)
try handle.close()
let written = try String(contentsOf: file, encoding: .utf8)
// Under Xcode and xcodebuild os_log also mirrors the line to stderr in its own
// shape ("[events] ..."); ours is the one with "[pid:thread]" before the text.
let ours = try NSRegularExpression(pattern: #"\[\d+:\d+\] AutoCollapse: holding for the palette 100%$"#, options: .anchorsMatchLines)
XCTAssertEqual(ours.numberOfMatches(in: written, range: NSRange(written.startIndex..., in: written)), 1, written)
}
}
18 changes: 17 additions & 1 deletion HiddenBarTests/AutoCollapsePopupGuardTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ final class AutoCollapsePopupGuardTests: XCTestCase {
private var panelOpen = true
private var panelReads = 0
private var logged: [String] = []
private var loggedPublic: [String] = []

// A 1600 x 900 display with a 24 pt menu bar, and a 900 x 1600 one to its
// right, raised so its menu bar sits higher.
Expand All @@ -48,6 +49,7 @@ final class AutoCollapsePopupGuardTests: XCTestCase {
panelOpen = true
panelReads = 0
logged = []
loggedPublic = []
}

private func makeGuard() -> AutoCollapsePopupGuard {
Expand All @@ -64,7 +66,8 @@ final class AutoCollapsePopupGuardTests: XCTestCase {
notificationCenterPanelIsOpen: { [unowned self] in panelReads += 1; return panelOpen },
now: { [unowned self] in time },
ownPID: ownPID,
log: { [unowned self] in logged.append($0) })
log: { [unowned self] in logged.append($0) },
logPublic: { [unowned self] in loggedPublic.append("\($0)") })
}

private func window(_ pid: pid_t, layer: Int, _ frame: CGRect) -> OnScreenWindow {
Expand Down Expand Up @@ -109,6 +112,18 @@ final class AutoCollapsePopupGuardTests: XCTestCase {
XCTAssertEqual(logged.count, 2)
}

// The public log gets a line that names no app, window or layer; the detail
// stays in the private line above.
func testPublicLineIsStaticAndLoggedOncePerHold() {
let popupGuard = makeGuard()
list.windows = [window(netMonitor, layer: popUpMenu, CGRect(x: 1200, y: 24, width: 300, height: 400))]
XCTAssertTrue(popupGuard.defersCollapse())
time = 10
XCTAssertTrue(popupGuard.defersCollapse())
XCTAssertEqual(loggedPublic, ["AutoCollapse: holding for a menu bar popup"])
XCTAssertFalse(loggedPublic.joined().contains("netmon"))
}

// #319: a network monitor's graph is a status-level panel under its item.
func testStatusLevelPopoverDefers() {
let popupGuard = makeGuard()
Expand Down Expand Up @@ -140,6 +155,7 @@ final class AutoCollapsePopupGuardTests: XCTestCase {
XCTAssertTrue(popupGuard.defersCollapse())
time = 5 + 600
XCTAssertFalse(popupGuard.defersCollapse(), "the cap wins")
XCTAssertEqual(loggedPublic.last, "AutoCollapse: a menu bar popup held auto-hide for the full limit; collapsing anyway")
time = 5 + 610
XCTAssertFalse(popupGuard.defersCollapse(), "until the bar is expanded again")

Expand Down
17 changes: 17 additions & 0 deletions docs/MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,23 @@ restarts. A ⌘-drag across the arrow still moves it. An app that recreates its
icon without relaunching (BitBar, SwiftBar) can look like a drag; tick "Ignore
drags" on its row to keep it where you put it.

### Capture a log

Hidden Bar writes its log lines to stderr, so a log for a bug report is one command:

```sh
# quit Hidden Bar first, then
open --stderr ~/Desktop/hiddenbar.log "/Applications/Hidden Bar.app"
```

Reproduce the problem, then attach `hiddenbar.log`. The file lists the bundle
identifiers of your menu bar apps (and a Mac's own error texts), so read it
before you share it. In Console and `log show`, macOS shows those lines as
`<private>`; only a few fixed lines are readable there, such as the auto-collapse
hold reasons (`AutoCollapse: holding for ...`) and the "hiding unavailable"
reasons (`NativeVisibility: hiding unavailable: ...`). Filter with
`log show --predicate 'process == "Hidden Bar" AND eventMessage BEGINSWITH "AutoCollapse"'`.

## Requirements

macOS 13 Ventura or later. Pre-Ventura (10.13 - 12.x): use
Expand Down
6 changes: 4 additions & 2 deletions docs/RUNBOOK.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ Standard checks before any release:
- `hoverToExpand` off: no monitor log line, hover does nothing; on (the
Preferences checkbox, no relaunch): dwell expands (synthesize a `mouseMoved` stream: cursor warping alone fires no
events);
- autostart pref on -> `AutoStart: SMAppService.mainApp.status = 1` on stderr;
off -> `= 0` (run the binary directly to capture stderr);
- autostart pref on -> `AutoStart: status = 1` on stderr;
off -> `= 0` (`open --stderr FILE "/Applications/Hidden Bar.app"`, or run the binary
directly, to capture stderr; the unified log shows these lines as `<private>`, only
the static lines logged with `AppLog.publicLine` are readable there);
- localization tables stay parseable: `plutil -lint hidden/*.lproj/*.strings`.

### Debug hooks harness (`scripts/hb-cmd`)
Expand Down
33 changes: 33 additions & 0 deletions hidden/Common/Constant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,42 @@
//

import Foundation
import os

enum Constant {
static let appName = "Hidden Bar"

static var isUsingLTRLanguage = false
}

// Foundation's NSLog marks every value <private> in the unified log, which keeps
// bundle ids and error texts out of Console and sysdiagnoses. That stays the
// default. A line that needs to be readable there goes through publicLine: it
// takes a StaticString, so the compiler rejects anything built at run time and
// no user data can reach the public log. The same line also goes to stderr, as
// NSLog does, because os_log alone does not reach it.
enum AppLog {
private static let log = OSLog(subsystem: Bundle.main.bundleIdentifier ?? "com.dwarvesv.minimalbar", category: "events")
private static let timestamps: DateFormatter = {
let formatter = DateFormatter()
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"
return formatter
}()

static func publicLine(_ text: StaticString) {
let message = "\(text)"
os_log("%{public}@", log: log, type: .default, message)
fputs(stderrLine(message,
timestamp: timestamps.string(from: Date()),
process: ProcessInfo.processInfo.processName,
pid: ProcessInfo.processInfo.processIdentifier,
thread: pthread_mach_thread_np(pthread_self())),
stderr)
}

// The shape NSLog writes to stderr, so a captured file reads the same.
static func stderrLine(_ message: String, timestamp: String, process: String, pid: Int32, thread: UInt32) -> String {
"\(timestamp) \(process)[\(pid):\(thread)] \(message)\n"
}
}
10 changes: 8 additions & 2 deletions hidden/Features/StatusBar/AutoCollapsePopupGuard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ final class AutoCollapsePopupGuard {
private let ownPID: pid_t
private let cap: TimeInterval
private let log: (String) -> Void
private let logPublic: (StaticString) -> Void
private var deferringSince: TimeInterval?

// menuBarItemOwners: bundles the engine read in the menu bar. On macOS 27 the
Expand All @@ -79,7 +80,8 @@ final class AutoCollapsePopupGuard {
now: @escaping () -> TimeInterval = { ProcessInfo.processInfo.systemUptime },
ownPID: pid_t = ProcessInfo.processInfo.processIdentifier,
cap: TimeInterval = AutoCollapsePopupGuard.defaultCap,
log: @escaping (String) -> Void = { NSLog("%@", $0) }) {
log: @escaping (String) -> Void = { NSLog("%@", $0) },
logPublic: @escaping (StaticString) -> Void = { AppLog.publicLine($0) }) {
self.windows = windows
self.displays = displays
self.bundleIdentifier = bundleIdentifier
Expand All @@ -89,6 +91,7 @@ final class AutoCollapsePopupGuard {
self.ownPID = ownPID
self.cap = cap
self.log = log
self.logPublic = logPublic
}

// Before macOS 27 a notification keeps no screen-tall window up, so the window
Expand All @@ -106,12 +109,15 @@ final class AutoCollapsePopupGuard {
}
let time = now()
if deferringSince == nil {
// Owner and layer only: never a window title or other content.
// The public line is static so Console shows the hold; the owner and
// layer stay in the private line, never a window title or content.
logPublic("AutoCollapse: holding for a menu bar popup")
log("AutoCollapse: holding for a popup from \(bundleIdentifier(holder.ownerPID) ?? "pid \(holder.ownerPID)") at layer \(holder.layer)")
}
let since = deferringSince ?? time
deferringSince = since
if time - since >= cap {
logPublic("AutoCollapse: a menu bar popup held auto-hide for the full limit; collapsing anyway")
NSLog("AutoCollapse: a menu-bar popup has been open for %.0f s; collapsing anyway", time - since)
return false
}
Expand Down
22 changes: 15 additions & 7 deletions hidden/Features/StatusBar/Engine/NativeVisibilityEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,13 @@ final class NativeVisibilityEngine: MenuBarEngine {
}

guard visibility.isAvailable else {
logUnavailableOnce("the native menu-bar visibility API is not available in this build or on this macOS")
logUnavailableOnce("NativeVisibility: hiding unavailable: the native menu-bar visibility API is not available in this build or on this macOS")
state = .unavailable
return completion(.unavailable)
}
guard runsFromApplicationsFolder() else {
logUnavailableOnce("macOS 27 would also hide Hidden Bar's own arrow: it hides only apps it knows by bundle id, and Hidden Bar runs from outside an Applications folder (\(Bundle.main.bundlePath))")
logUnavailableOnce("NativeVisibility: hiding unavailable: Hidden Bar runs from outside an Applications folder, so macOS 27 would also hide its arrow",
detail: "macOS 27 would also hide Hidden Bar's own arrow: it hides only apps it knows by bundle id, and Hidden Bar runs from outside an Applications folder (\((Bundle.main.bundlePath as NSString).abbreviatingWithTildeInPath))")
state = .unavailable
return completion(.unavailable)
}
Expand All @@ -276,7 +277,7 @@ final class NativeVisibilityEngine: MenuBarEngine {
// hide icons the user kept visible. Not latched: it works as soon as
// the permission is granted.
inventory.requestAuthorization()
logUnavailableOnce("Accessibility permission is needed to read the menu-bar sections")
logUnavailableOnce("NativeVisibility: hiding unavailable: Accessibility permission is needed to read the menu-bar sections")
return completion(.unavailable)
}
state = .calibrating
Expand All @@ -288,13 +289,13 @@ final class NativeVisibilityEngine: MenuBarEngine {
if self.holdsPresentationList {
return self.holdPresentationListUnread(completion)
}
self.logUnavailableOnce("the arrow's position cannot be read yet")
self.logUnavailableOnce("NativeVisibility: hiding unavailable: the arrow's position cannot be read yet")
self.state = .expanded
return completion(.unavailable)
}
if !self.holdsPresentationList, self.pausesHidingForUnkeepableItems(),
let reason = layout.reasonToKeepBarWhole(unkeepableSystemItems: self.unkeepableSystemItems) {
self.logUnavailableOnce(reason)
self.logUnavailableOnce("NativeVisibility: hiding unavailable: an icon right of the arrow cannot be kept visible, so the bar stays whole", detail: reason)
self.state = .expanded
return completion(.unavailable)
}
Expand Down Expand Up @@ -623,6 +624,7 @@ final class NativeVisibilityEngine: MenuBarEngine {
let attempt = collapseAttempt
scheduleCollapseTimeout(Self.collapseTimeout) { [weak self] in
guard let self = self, attempt == self.collapseAttempt, self.state == .calibrating else { return }
AppLog.publicLine("NativeVisibility: macOS did not answer the hide request; showing the whole menu bar")
NSLog("NativeVisibility: macOS did not answer the hide request within \(Int(Self.collapseTimeout)) s; showing the whole menu bar")
self.revealAll()
self.state = .expanded
Expand Down Expand Up @@ -1098,10 +1100,16 @@ final class NativeVisibilityEngine: MenuBarEngine {
}

// Logged when the reason changes, so a retried collapse does not spam.
private func logUnavailableOnce(_ reason: String) {
// `line` is the public line (static, so no user data); `detail`, when the
// reason carries data such as a path or app names, stays in the private line.
private func logUnavailableOnce(_ line: StaticString, detail: String? = nil) {
let reason = detail ?? "\(line)"
guard reason != lastUnavailableReason else { return }
lastUnavailableReason = reason
NSLog("NativeVisibility: hiding unavailable: \(reason)")
AppLog.publicLine(line)
if let detail {
NSLog("NativeVisibility: hiding unavailable: \(detail)")
}
}

// Checks whether macOS hid a system extra the allow-list could only try to
Expand Down
Loading