Repository navigation
Realistic random cursor roaming - #3
Merged
Merged
Conversation
…deterministic tests - Planner.Plan interpolates from current position to a fresh uniform random target, clamped to screen bounds - randomness injected via a minimal RandomSource seam so tests are deterministic - path is continuous, ends exactly at target, covers corner/1x1/target-equals-current edge cases - cgo/os-free, builds under GOOS=linux
…ing and regenerate mock - replace Nudge(dx, dy int) error with MoveTo(x, y int) error, Position(), and Bounds() - regenerate mockgen mock from the new interface (MoveTo/Position/Bounds) Note: this leaves the tree non-building until the service/adapter/main cutover in the following tasks, as planned.
… tick - roam(ctx): read Position/Bounds, ask domain.Planner for a glide path, then drive() calls MoveTo per path point with a short inter-step pause - ctx checked between every step so cancellation stops promptly mid-glide - Position/Bounds/MoveTo errors are logged and abandon the current roam without crashing the loop - tests rewritten with synctest + regenerated mockgen mock: one roam per tick, ordered MoveTo, mid-glide cancel, per-call error handling, start/stop logging Note: this leaves the tree non-building until the adapter/main cutover in the following tasks, as planned.
…o to CGPointer - getPosition/getBounds/moveTo C helpers replace the relative nudge helper: current cursor location via CGEventGetLocation, main-display bounds via CGDisplayBounds(CGMainDisplayID()), absolute move via a MouseMoved event - every CoreFoundation object created is released; NULL-create failures release nothing and signal failure - ErrNudgeFailed split into ErrPositionFailed and ErrMoveFailed - compile-time assertion that *CGPointer satisfies port.Pointer - tests updated to the new API (position/bounds/move-to-current-position smoke tests, no CI mouse movement)
…move dead Offset domain code - construct a runtime-seeded *math/rand/v2.Rand (rand.NewPCG from the auto-seeded package generator) and a domain.Planner, wired into KeeperService alongside the pointer/logger/interval - remove nudgeOffset constant and the domain.NewOffset validation - update flag help text and package doc comment to describe random roaming instead of the 1px nudge - keep the AccessibilityTrusted preflight warning and SIGINT/SIGTERM clean-exit-0 signal handling unchanged - delete domain.Offset, NewOffset, and ErrNonPositiveOffset (and their tests): roaming uses absolute clamped targets, so a relative offset value object no longer has meaning - fix a stale ErrNudgeFailed reference in a service test comment
Addresses roaming code review #1: - CR-01: clamp the starting cursor position into the display bounds before interpolating, so a cursor on a secondary monitor (global coords) cannot send early glide steps off-screen; covered by a new planner test - WR-01: reuse a single time.Timer across the glide instead of time.After per step - WR-02/IN-01/IN-02: clarify rounding, bounds-per-roam, and adapter Bounds contract
Addresses roaming code review #2 (IN-01, IN-02): restore the OnePixelScreen doc comment to its function and make the clamp test table-driven, adding the exact boundary case (curX == width).
… service seam Addresses custom-prompt review #1 (P2): - start the reused glide timer stopped so the first inter-step gap is exactly stepPause - add a service synctest asserting every MoveTo stays within [0,w)x[0,h) even when Position() reports an out-of-bounds start
- service: invalid-bounds (Plan error) abandon path and move-error-on-first-step abandon -- service coverage now 100% - planner: very large screen, bounded step delta corner-to-corner, and different-seed-different-path cases
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.
Summary
Replace the invisible 1px nudge with realistic random roaming: each
-intervaltick the cursor glides over ~40 small steps to a fresh uniform-random point on
the main display, like a person moving the mouse. Bounded to the screen, no
drift, interruptible mid-glide.
Type of change
What changed
internal/activity/domain/planner.go-- purePlannerproducing a glide pathto a random target via an injected
RandomSourceseam; clamps start + targetto bounds; deterministic +
GOOS=linux-buildable.internal/activity/port/pointer.go--Pointerreshaped:Position(),Bounds(),MoveTo(x,y); mock regenerated.internal/activity/service/keeper_service.go--KeeperServiceroams once pertick, driving the path through
MoveTowith a reused timer, ctx-checkedbetween steps.
internal/activity/adapter/cgpointer.go-- CoreGraphicsPosition/Bounds/MoveTobehind//go:build darwin, every CF object released.cmd/sysmon/main.go-- runtime-seeded*math/rand/v2.Rand+ planner injected;-interval/-quiet/signal-exit-0/accessibility preflight unchanged.Nudge/Offsetdomain code.Why / context
How it was tested
go build ./...go test -race ./...-- domain 100%, service 100%, adapter 83%golangci-lint run ./...-- 0 issuesGOOS=linux go build ./internal/activity/{domain,port,service}/...-- cgo-freeChecklist
Architecture & code
macOS / cgo
//go:build darwin; MoveTo posts a real eventConcurrency & resources
Safety & correctness
Reviewer notes
Four review passes (2x GSD code-review, 2x project review prompt) applied; all
findings fixed down to nit level. CI runs build/lint/test on macOS only.