Skip to content

[Bug] Get Test Job launching Electron #699

Closed

Description

@materwelonDhruv

macOS version: 26.2 (25C56)
VSCode Version: 1.109.0 (Universal)

Version: 1.109.0 (Universal)
Commit: bdd88df003631aaa0bcbe057cb0a940b80a476fa
Date: 2026-02-04T02:01:38.288Z (4 days ago)
Electron: 39.3.0
ElectronBuildId: 13168319
Chromium: 142.0.7444.265
Node.js: 22.21.1
V8: 14.2.231.22-electron.0
OS: Darwin arm64 25.2.0

Agent: Github CoPilot
Unity Version: 6000.3.4f1

So whenever copilot runs tests and then checks for test results, Electron gets launched on my mac.

I'm not exactly sure what other information I can provide, or look for. Please let me know.

And thank you so much for this MCP!!!

Activity

  1. changed the title [-]Get Test Job launching Electron[/-] [+][Bug] Get Test Job launching Electron[/+] on Feb 8, 2026
  2. whatevertogo commented on Feb 11, 2026

    @whatevertogo
    Contributor

    Hi @materwelonDhruv, thanks for the report!

    This is actually expected behavior caused by the "Focus Nudge" feature, not a bug.

    What's happening

    When Unity runs in the background on macOS, the OS aggressively throttles it (App Nap), which can cause PlayMode tests to stall completely. To work around this, unity-mcp temporarily switches focus to Unity when it detects a test job is stalled, allowing Unity to make progress, then returns focus to your previous app.

    The "Electron launching" you're seeing is VSCode (which is built with Electron) being refocused when Unity returns focus to it after the nudge.

    Why this is needed

    Without this nudge mechanism, PlayMode tests can hang indefinitely on macOS when Unity is in the background because the OS puts it to sleep. This is a well-known macOS behavior affecting background applications.

    Options if this is disruptive

    1. Keep Unity focused - No nudges will occur if Unity is already the frontmost app
    2. Adjust nudge behavior via environment variables:
      • UNITY_MCP_NUDGE_DURATION_S=3 - How long Unity stays focused (default 3s)
      • UNITY_MCP_NUDGE_BASE_INTERVAL_S=5 - Minimum time between nudges (default 1s)
      • UNITY_MCP_NUDGE_MAX_INTERVAL_S=30 - Max interval between nudges (default 10s)
    3. Disable focus nudging - If you set UNITY_MCP_NUDGE_BASE_INTERVAL_S to a very large value (like 999999), nudges will effectively never happen

    Note: If tests are completing successfully despite the window switching, everything is working as designed—the window switching is the trade-off for allowing background Unity tests to run on macOS.

    Let me know if you'd like a dedicated environment variable like UNITY_MCP_ENABLE_FOCUS_NUDGE=false to completely disable this feature!

    Written By Agent.

  3. materwelonDhruv commented on Feb 18, 2026

    @materwelonDhruv
    Author

    Interesting. No, it's all good. I don't need an env for it.

    But I don't understand why it launches a new window of Electron itself. Not VSCode or something. Literally Electron. Quite confusing. Because focusing back on VSCode shouldn't be launching Electron, right?

  4. whatevertogo commented on Feb 18, 2026

    @whatevertogo
    Contributor

    Confirmed from current code: this is a real macOS focus-restore bug in focus_nudge.py.

    Current flow stores only the frontmost process name (via System Events), then restores focus with:
    tell application "<process_name>" to activate.

    For some Electron-based IDE setups, the process name can be generic (for example "Electron"), which can cause macOS to activate/launch a different app target (e.g. Electron.app) instead of restoring the original IDE window.

    Suggested direction:

    • capture (bundle_id, pid, process_name) for the original foreground app
    • restore in order:
      1. tell application id "<bundle_id>" to activate
      2. fallback by pid via System Events
      3. fallback by process name via System Events
    • avoid direct tell application "<generic_process_name>" for names like Electron

    @dsarno would you mind taking a look when you have a chance? . I don't have a macOS device right now.

  5. dsarno commented on Feb 18, 2026

    @dsarno
    Collaborator

    Yes I'll look thank you @whatevertogo

  6. added a commit that references this issue on Feb 19, 2026
    e66f923
  7. dsarno commented on Feb 19, 2026

    @dsarno
    Collaborator

    Fix implemented in PR #783. The macOS focus-restore now captures the bundle identifier alongside the process name and uses tell application id "<bundle_id>" to activate when restoring focus.

    Root cause: VS Code's process name is "Electron", so tell application "Electron" to activate launched a standalone Electron instance instead of returning to VS Code.

    What changed in focus_nudge.py:

    • _get_frontmost_app_macos() now retrieves both process name and bundle ID via a single AppleScript call (with a guard for processes that have no bundle ID)
    • _focus_app_macos() prefers tell application id "com.microsoft.VSCode" to activate (or whatever the actual bundle ID is), falling back to name-based activation if bundle ID fails
    • Windows/Linux unaffected -- they use window titles and window IDs respectively

    This will ship in the next beta release.

  8. added a commit that references this issue on Feb 19, 2026
    9493c5f
  9. dsarno commented on Feb 19, 2026

    @dsarno
    Collaborator

    @materwelonDhruv Would you mind testing to see if this works for you? It's on the beta branch, which you can install into unity with this link:

    https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#beta

  10. added 2 commits that reference this issue on Feb 25, 2026
    edd2c6d
    103eb73
  11. materwelonDhruv commented on Feb 26, 2026

    @materwelonDhruv
    Author

    Hey @dsarno I haven't had a chance to test this out yet. Apologies for the late reply. I'll confirm this is fixed the next time I work on my game! Thanks a ton :)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions