Repository navigation
Deepen the Cycle module and tidy the seams around it - #2
Merged
Merged
Conversation
Presses, focus hooks and the Alt-release watcher are separate processes
that agree through a state file. That protocol was spread over Cycler,
Tracker, ReleaseWaiter, Session and SessionStore, and had to be called in
the right order. It now lives in one module, src/cycle/, whose interface
is Cycle::{press, observe_focus, release}, Direction and CycleId.
- Rename Session to Cycle; the state file is now cycle-<hash>.json. An
old session file is simply ignored, and a cycle lasts at most 30s.
- observe_focus holds the cycle lock through its History write, as
press already did.
- Saved state is only reachable through a lock-scoped Turn.
- History owns the live-pane recency rule and hands out an opaque
Snapshot; Visit is private.
- Lock is split from StateFile (Connection::lock).
- LiveConfig moves into the herdr module and HerdrBinary::run is private.
- Environment reads every variable once; herdr_env and config_path go.
- Clock gains pause so the release wait loop and its 30s cap are testable.
- Add GLOSSARY.md defining Cycle.
Overlapping tests are consolidated (117 -> 103) and new ones cover the
hold cap, release grace, idle window and config check/reload.
…ook lock - Socket reads time out after 2s, so a stalled Herdr cannot hold the cycle lock forever and queue up every press and hook behind it. - The release watcher no longer ends the cycle when it gives up at the hold cap with Alt still down; the cycle expires on its own after its last press. - Test that the focus hook holds the cycle lock while it asks Herdr. - Cycle keeps Collaborators whole instead of copying its five fields.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Presses, focus hooks and the Alt-release watcher are separate processes that agree through a state file. The rule for "is this focus event the cycle's or the user's?" was spread over
Cycler,Tracker,ReleaseWaiter,SessionandSessionStore, and callers had to use them in the right order (save before focus, take the lock, honour the grace window). This came out of an architecture review; the design decisions are in the commit message andGLOSSARY.md.What changed
src/cycle/): interface isCycle::{press, observe_focus, release},Direction,CycleId. State machine and store are private. Saved state is only reachable through a lock-scopedTurn.cycle-<hash>.json. No migration: an old file is ignored and a cycle lives at most 30s.Snapshot.Visitis private.StateFile(Connection::lock).LiveConfigmoves into theherdrmodule andHerdrBinary::runis private.Paneshas a constructor.herdr_env.rsandkeys/config_path.rsare gone.pause, so the release wait loop and its 30s cap are testable.GLOSSARY.mdadded, defining Cycle.Behaviour changes
observe_focusnow holds the cycle lock through its History write (it used to drop it first), matchingpress.Clockinstead ofInstant/sleep; real behaviour is unchanged.Panes::contains, which had no production caller left.Tests
117 to 103: overlapping tests were consolidated (one test per behaviour). New tests cover the 30s hold cap, release grace window, idle window, recency order, and the config check/reload adapter. I replaced
focus_a_cycle_caused_is_left_out_of_historywith a stronger version that passes through a pane, because the old assertion became vacuous onceVisitwas private. I also injected six deliberate bugs into the focus-ownership logic and each was caught by a test.cargo fmt --check,cargo clippy --all-targets -- -D warningsandcargo testpass locally on macOS. I also ran the debug binary against a stubherdr(older, older, track, bad args). Not tested: Linux, a real Herdr, a real Alt hold.