Skip to content

Fix: the end control never receives clicks on macOS 27 (click lands at the item's centre) - #134

Draft
Pongchayanneung wants to merge 2 commits into
krishhgg:mainfrom
Pongchayanneung:fix/end-control-click-on-status-item
Draft

Pongchayanneung wants to merge 2 commits into
krishhgg:mainfrom
Pongchayanneung:fix/end-control-click-on-status-item

Conversation

@Pongchayanneung

Copy link
Copy Markdown

What changes

On a MacBook Pro with a notch running macOS 27, the end control (the circled x next to the countdown) never ends a session, however it is pressed. A click on a status item reports its location at the centre of the item's window, whatever was clicked. SwiftUI therefore sees every click land on the countdown, which opens the Days / Hours / Minutes pills to extend, and the end control at the right edge is never hit. The same flaw sends a click on a pill to the middle pill.

Evidence from a debug build (button 118 pt wide, real click at the end control, pointer 18 pt from the right edge):

event.locationInWindow converted to the button: x = 59.0   (bw = 118.0, the centre)

With the session idle the same click on the 32 pt item gave 16.0, the centre again.

The fix reads the pointer from NSEvent.mouseLocation in a local leftMouseDown monitor. While a session runs, a click in the right 30 pt of the item ends it and the click is taken. HoldToEndButton also ends on release, so on a machine where the location is right a plain click works too.

Scope note: this changes the end control from press-and-hold to click. If you want to keep the hold, the zone handler could start the ring instead. I did not do that.

Not fixed here: clicks on the pills still land on the middle pill on this Mac.

How it was tested

  • Added testEndZoneIsTheRightEdgeOfTheItem in UIStatusTests. I could not run it: this Mac has Command Line Tools only, so swift test fails with no such module 'XCTest'. swift build passes.
  • By hand, on the installed build (ad hoc signed from this branch): started a 1 hour session, then a real mouse click (CGEvent) at the end control. Log:
2026-10-20T02:38:56Z [info] insomnia: session started until 2026-10-20T03:38:51Z (3600s requested)
2026-10-20T02:39:02Z [info] insomnia: session end (user)
2026-10-20T02:39:02Z [info] insomnia: sleep restored

pmset -g then shows SleepDisabled 0 and there is no session.json.

  • Before the change the same click opened the pills and the session kept running.

Real-Mac evidence

Draft. MacBook Pro (Apple Silicon, built-in Liquid Retina XDR display), macOS 27 (26A428). Only the check above was run. The other items in docs/releasing.md were not run and I will not claim them. I have not opened an issue first, which CONTRIBUTING.md asks for before changing a default.

🤖 Generated with Claude Code

https://claude.ai/code/session_0186aQ2a3QihzStd6T8WrfZv

Pongchayanneung and others added 2 commits October 20, 2026 09:39
On macOS 27 a click on a status item reports its location at the centre
of the item's window, so SwiftUI saw every click land on the countdown and
the end control at the right edge was never reached. A local mouse monitor
now reads the pointer position on screen and ends the session when the
click falls in the right-hand 30pt while a session runs. The control also
ends on release instead of requiring a completed hold. README and spec
updated.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0186aQ2a3QihzStd6T8WrfZv
@Pongchayanneung

Copy link
Copy Markdown
Author

Real-Mac report for 8e76572

Build. Clean checkout of the head commit, installed with ./scripts/install.sh at 10:05:08 (+07, 2026-10-20). Release build, ad hoc signed, codesign --verify --strict passes.

$ git rev-parse HEAD
8e765722ca6ac20044fc95bf3ac4d328d3cd72e0
$ git status --short
(nothing)

Mac.

ProductName:		macOS
ProductVersion:		27.0
BuildVersion:		26A428
hw.model: Mac17,2
machdep.cpu.brand_string: Apple M5

Built-in display with a notch. On battery, Low Power Mode was already on before the run (lowpowermode 1 in every sample), so it is unchanged by it.

Checks. Only one item in "Real-Mac checks before a release" is affected by this change: "Normal end ... restore live power state", here ended by the user with the end control.

Steps: 10:05:33 launch the app (no session to restore). 10:05:46 start a 1 hour session. 10:05:59 one real left click (CGEvent mouse down/up) on the end control at the right edge of the status item. Result: pass, the session ended on that single click and sleep was restored.

insomnia.log for the run:

2026-10-20T03:05:33Z [info] insomnia: launched
2026-10-20T03:05:33Z [info] insomnia: reconcile: no session, nothing to restore
2026-10-20T03:05:46Z [info] insomnia: session started until 2026-10-20T04:05:41Z (3600s requested)
2026-10-20T03:05:46Z [info] insomnia: lid observer started (lid open)
2026-10-20T03:05:59Z [info] insomnia: session end (user)
2026-10-20T03:05:59Z [info] insomnia: sleep restored
2026-10-20T03:05:59Z [info] insomnia: notify: Session ended - Ended by you. Sleep is back to normal.

(Times in the log are UTC, the samples below are +07. The notification authorization lines are left out; notifications are not allowed for the app on this Mac.)

pmset samples, started before the check and left running (time, SleepDisabled, lowpowermode under Battery Power):

10:05:32  SleepDisabled    0  lowpowermode         1
10:05:37  SleepDisabled    0  lowpowermode         1
10:05:42  SleepDisabled    1  lowpowermode         1
10:05:47  SleepDisabled    1  lowpowermode         1
10:05:52  SleepDisabled    1  lowpowermode         1
10:05:57  SleepDisabled    1  lowpowermode         1
10:06:02  SleepDisabled    0  lowpowermode         1
10:06:07  SleepDisabled    0  lowpowermode         1
10:06:12  SleepDisabled    0  lowpowermode         1
10:06:17  SleepDisabled    0  lowpowermode         1

SleepDisabled goes 0 to 1 after the start and back to 0 after the click. After the end, state.json reads "sleepDisabledByUs" : false and there is no session.json.

pmset -g log | grep -E ' (Sleep|Wake|DarkWake) ' has no entry in the 10:05 to 10:06 window. The last entry before it is 2026-10-20 07:42:14 +0700 Wake.

The recovery agent after the run: launchctl print gui/$(id -u)/com.insomnia.backstop shows runs = 2, last exit code = 0.

Before this change, on the same Mac, the same click on the end control opened the Days / Hours / Minutes pills and the session kept running (the cause is in the PR description).

Not run. The rest of "Real-Mac checks before a release" does not touch the status item's click handling, so I did not run it: force-quit and deadline recovery, reboot and login, lid close and the lid simulation build, Low Power Mode on macOS 27, thermal, hotspot, freezing and audio checks, and the release channel checks. I also did not click the countdown to check that it still opens the extend pills (it sits about 36 pt from the right edge, outside the 30 pt zone). I did not test an Intel Mac or macOS 26 by hand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant