Skip to content

Remove the test-job focus nudge that steals OS focus - #59

Closed
vbucc wants to merge 1 commit into
mainfrom
fix/remove-focus-nudge
Closed

vbucc wants to merge 1 commit into
mainfrom
fix/remove-focus-nudge

Conversation

@vbucc

@vbucc vbucc commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

get_test_job pulled Unity to the front whenever a running job had reported no progress for 3 s and Unity wasn't the frontmost app. On macOS it does that with an AppleScript activate, which also switches Spaces. Any test longer than 3 s meets the condition, so polling a PlayMode run stole focus from whatever app you were typing in, over and over: 3–12 s in front each time, repeating on a 1/2/4/8/10 s backoff.

This removes it: utils/focus_nudge.py, tests/test_focus_nudge.py, and both call sites in get_test_job, along with the helpers only they used.

Why it isn't needed: TestRunnerNoThrottle puts the editor in No Throttling for every test run, so a backgrounded editor keeps running at full speed. The App Nap case the nudge was written for comes with a sleeping display, which a focus nudge can't fix. Measured in p005unity on macOS: a full PlayMode run of 1,251 tests finished in 827 s, 0 failures, with the editor in the background throughout and get_test_job called once mid-run.

Tests: cd Server && uv run --extra dev pytest tests/: 1519 passed, 3 skipped.

Takes effect after merge and an MCP server restart with uvx --refresh (the Server code changed).

🤖 Generated with Claude Code

get_test_job focused Unity whenever a running job had reported no progress
for 3 s and Unity was not the frontmost app. Any test longer than 3 s meets
that condition, so polling a PlayMode run pulled Unity to the front over and
over: AppleScript activate on macOS (which also switches Spaces), held for
3-12 s, then back to the previous app. Typing in another app lost focus
repeatedly.

The nudge isn't needed: TestRunnerNoThrottle puts the editor in No Throttling
for every test run, so a backgrounded editor keeps running. The App Nap case
it was written for comes with a sleeping display, which a focus nudge can't
fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vbucc

vbucc commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by #61: upstream v10.3.0 skips the focus nudge when the editor reports run_in_background.

@vbucc vbucc closed this Oct 7, 2026
@vbucc
vbucc deleted the fix/remove-focus-nudge branch October 7, 2026 07:47
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