Skip to content

refactor: fold duplicated rules onto one definition each - #33

Merged
rbstp merged 1 commit into
masterfrom
chore/cleanup-pass
Sep 7, 2026
Merged

rbstp merged 1 commit into
masterfrom
chore/cleanup-pass

Conversation

@rbstp

@rbstp rbstp commented Sep 7, 2026

Copy link
Copy Markdown
Owner

A cleanup pass over master: reuse, simplification, efficiency and altitude. No behaviour change is
intended anywhere, and the 265 unit tests, the release build and make check-package all pass.

The recurring finding was one rule written out several times.

Geometry. isVisible and visibleCentre shared 26 byte-identical lines of grid decomposition,
which is the hardest geometry in the repo kept in two copies in the module that exists so it is
written once. That block is now coverGrid; the two sweeps that follow it genuinely differ and stay
apart. WarpPlan.visiblePart was a second copy of FocusRing's largest-overlap-screen search and
now calls it.

Window identity. The CFEqual-then-frame-then-title rule that tells Electron's windows apart
lived inline in focusMatches and in liveFocusIndex as well as in Target ==, and the copies had
already drifted. Both now go through sameWindow/windowTarget, so Target == is the only
definition. The CFEqual short-circuit stays in front of the two Accessibility reads.

Modifiers and shortcuts. The four-modifier table was hand-written three times, in Agent,
MenuBar and Hotkey; one extension now carries the AppKit and Carbon translations. Shortcut
moves to file scope so Config.load reads the eight hotkey settings through the same
defaultsKey/keyPath table changeModifiers already writes through, instead of restating the key
strings.

Efficiency. The global mouse monitor was installed for the life of the process and handed every
mouse event on the system, and its whole body was a bool test that is false precisely while the
mouse is moving. It is now installed only while the loop is idling, which also drops it while Heed
is switched off. badgeCentres ran the grid sweep for every ring window and then kept nine, which
is the latency before the badges appear. holdingApplies asked LaunchServices before asking the
free question.

Leftovers. WindowCandidate.canActivate was only ever true (eligibility is decided in
eligibleApp before the candidate is built), so the field and its unreachable reject arm are gone.
--probe was missing the click-grace guard currentCondition has, so it reported nothing
suppressing during a click grace window. Five doc comments were left mid-sentence or duplicated by
762c6e8, including the one recording why Outlook's reminder cannot be classified structurally.

Deliberately not done, all worth their own change: replacing verifyFocus's spin-wait with the
didActivateApplication notification it already observes (it would delete the verifyTimeoutMs
setting), skipping the pre-apply confirmation hit test at dwellMs = 0, moving the entry-motion
rule into DwellMachine so it can be tested, sampling frontmostApplication once per tick, and
unifying the guard chain that currentCondition and --probe both spell out.

Codex reviewed the diff for accidental behaviour changes and found one: memoising the Raycast
application scan let the Focus Window action run against a stale inventory if Heed were uninstalled
while the list was open. The memo is gone; the shared findHeed lookup it was bundled with stays.

Geometry: isVisible and visibleCentre shared 26 byte-identical lines of
grid decomposition, now coverGrid, and WarpPlan's visiblePart was a
second copy of FocusRing's largest-overlap-screen search.

Window identity: the CFEqual-then-frame-then-title rule that tells
Electron's windows apart was written inline in focusMatches and
liveFocusIndex as well as in Target ==. Both now go through sameWindow
and windowTarget, so the rule has one definition.

Modifiers: the four-modifier table was hand-written three times, in
Agent, MenuBar and Hotkey. One extension carries the AppKit and Carbon
translations instead.

Shortcuts: Shortcut moves to file scope so Config.load reads the eight
hotkey settings through the same defaultsKey and keyPath table that
changeModifiers already writes through.

Efficiency: the global mouse monitor was installed for the life of the
process and handed every mouse event on the system, doing nothing
whenever the loop was already at full poll; it is now installed only
while idling, which also drops it while Heed is off. badgeCentres ran
the grid sweep for every ring window and then kept nine. holdingApplies
queried LaunchServices before asking the free question first.

Also: WindowCandidate.canActivate was only ever true, --probe was
missing the click-grace guard currentCondition has, and five doc
comments were left mid-sentence or duplicated by 762c6e8.
@rbstp
rbstp merged commit 5aaee42 into master Sep 7, 2026
1 check passed
@rbstp
rbstp deleted the chore/cleanup-pass branch September 7, 2026 17:06
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