unity-mcp/TestProjects/UnityMCPTests/Assets/Tests/EditMode/Tools
dsarno 4d969419d4
Fix WebSocket connection reliability and domain reload recovery (#656)
* Add server-side ping/pong heartbeat to detect dead WebSocket connections

On Windows, WebSocket connections can die silently (OSError 64) without
either side being notified. This causes commands to fail with "Unity
session not available" until Unity eventually detects the dead connection.

Changes:
- Add PingMessage model for server->client pings
- Add ping loop in PluginHub that sends pings every 10 seconds
- Track last pong time per session; close connection if no pong within 20s
- Include session_id in pong messages from Unity for server-side tracking
- Clean up debug/timing logs from Issue #654 investigation

The server will now proactively detect dead connections within 20 seconds
instead of waiting indefinitely for the next command to fail.

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

* Fix connection recovery after Unity domain reloads (#654)

When Unity performs a domain reload (after script changes, test runs,
or large payload transfers), the MCP connection drops and needs to
reconnect. The previous reconnection timeout (2s) was too short for
domain reloads which can take 10-30s.

Changes:
- Increase UNITY_MCP_RELOAD_MAX_WAIT_S default from 2s to 30s
- Increase backoff cap when reloading from 0.8s to 5.0s
- Skip PluginHub session resolution for stdio transport (was causing
  unnecessary waits on every command)

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

* Fix ping/pong heartbeat, reduce timeout to 20s, fix test flakiness

- Add server-side ping loop to detect dead WebSocket connections
- Include session_id in pong messages for tracking
- Reduce domain reload timeout from 30s to 20s
- Add ClassVar annotations for mutable class attributes
- Add lock protection for _last_pong access
- Change debug stack trace log from Warn to Debug level
- Remove unused TIMING-STDIO variable
- Fix flaky async duration test (allow 20% timer variance)
- Fix Python test that cleared HOME env var on Windows
- Skip Unix-path test on Windows (path separator difference)
- Add LogAssert.Expect to PropertyConversion tests

Fixes #654, #643

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

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 16:42:39 -08:00
..
Characterization Large Cleanup and Refactor + Many new Tests added (#642) 2026-01-29 02:47:36 -08:00
Fixtures Harden `manage_scriptable_object` Tool (#522) 2026-01-07 10:46:35 -04:00
AIPropertyMatchingTests.cs 🔧 Clean up & Consolidate Shared Services Across MCP Tools (#519) 2026-01-06 12:58:17 -08:00
AIPropertyMatchingTests.cs.meta Allow the LLMs to read menu items, not just execute them (#263) 2025-09-12 11:19:58 -04:00
Characterization.meta Large Cleanup and Refactor + Many new Tests added (#642) 2026-01-29 02:47:36 -08:00
CommandRegistryTests.cs Clean up Unity and Python tests (#548) 2026-01-11 20:26:20 -08:00
CommandRegistryTests.cs.meta Improve Windsurf MCP Config (#231) 2025-08-24 06:57:11 -04:00
ComponentResolverTests.cs Move Get commands to editor resources + Run Python tests every update (#368) 2025-11-05 16:06:48 -04:00
ComponentResolverTests.cs.meta Allow the LLMs to read menu items, not just execute them (#263) 2025-09-12 11:19:58 -04:00
DomainReloadResilienceTests.cs Large Cleanup and Refactor + Many new Tests added (#642) 2026-01-29 02:47:36 -08:00
DomainReloadResilienceTests.cs.meta HTTP Server, uvx, C# only custom tools (#375) 2025-11-24 23:21:06 -04:00
ExecuteMenuItemTests.cs Add testing and move menu items to resources (#316) 2025-10-13 11:16:43 -04:00
ExecuteMenuItemTests.cs.meta Add testing and move menu items to resources (#316) 2025-10-13 11:16:43 -04:00
Fixtures.meta feature/Add new manage_scriptable_object tool (#489) 2025-12-28 20:15:50 -08:00
GameObjectAPIStressTests.cs v9 pre-release pruning (#528) 2026-01-07 18:51:51 -04:00
GameObjectAPIStressTests.cs.meta 🎮 GameObject Toolset Redesign and Streamlining (#518) 2026-01-06 10:13:45 -08:00
MCPToolParameterTests.cs Clean up Unity and Python tests (#548) 2026-01-11 20:26:20 -08:00
MCPToolParameterTests.cs.meta Feature/run tests summary clean (#501) 2026-01-01 20:36:45 -08:00
ManageGameObjectCreateTests.cs v9 pre-release pruning (#528) 2026-01-07 18:51:51 -04:00
ManageGameObjectCreateTests.cs.meta 🎮 GameObject Toolset Redesign and Streamlining (#518) 2026-01-06 10:13:45 -08:00
ManageGameObjectDeleteTests.cs v9 pre-release pruning (#528) 2026-01-07 18:51:51 -04:00
ManageGameObjectDeleteTests.cs.meta 🎮 GameObject Toolset Redesign and Streamlining (#518) 2026-01-06 10:13:45 -08:00
ManageGameObjectModifyTests.cs v9 pre-release pruning (#528) 2026-01-07 18:51:51 -04:00
ManageGameObjectModifyTests.cs.meta 🎮 GameObject Toolset Redesign and Streamlining (#518) 2026-01-06 10:13:45 -08:00
ManageGameObjectTests.cs Clean up Unity and Python tests (#548) 2026-01-11 20:26:20 -08:00
ManageGameObjectTests.cs.meta Allow the LLMs to read menu items, not just execute them (#263) 2025-09-12 11:19:58 -04:00
ManageMaterialPropertiesTests.cs Harden `manage_scriptable_object` Tool (#522) 2026-01-07 10:46:35 -04:00
ManageMaterialPropertiesTests.cs.meta feat: Add `manage_material` tool for dedicated material manipulation (#440) 2025-12-07 19:39:52 -08:00
ManageMaterialReproTests.cs Harden `manage_scriptable_object` Tool (#522) 2026-01-07 10:46:35 -04:00
ManageMaterialReproTests.cs.meta feat: Add `manage_material` tool for dedicated material manipulation (#440) 2025-12-07 19:39:52 -08:00
ManageMaterialStressTests.cs Harden `manage_scriptable_object` Tool (#522) 2026-01-07 10:46:35 -04:00
ManageMaterialStressTests.cs.meta feat: Add `manage_material` tool for dedicated material manipulation (#440) 2025-12-07 19:39:52 -08:00
ManageMaterialTests.cs Harden `manage_scriptable_object` Tool (#522) 2026-01-07 10:46:35 -04:00
ManageMaterialTests.cs.meta feat: Add `manage_material` tool for dedicated material manipulation (#440) 2025-12-07 19:39:52 -08:00
ManagePrefabsCrudTests.cs Add create_child parameter to manage_prefabs modify_contents (#646) 2026-01-29 04:14:52 -08:00
ManagePrefabsCrudTests.cs.meta feat: Prefab Feature Updates (#611) 2026-01-25 16:36:29 -08:00
ManageSceneHierarchyPagingTests.cs Payload-safe paging for hierarchy/components + safer asset search + docs (#490) 2025-12-28 20:57:57 -08:00
ManageSceneHierarchyPagingTests.cs.meta Payload-safe paging for hierarchy/components + safer asset search + docs (#490) 2025-12-28 20:57:57 -08:00
ManageScriptValidationTests.cs Autoformat (#297) 2025-09-30 16:25:33 -04:00
ManageScriptValidationTests.cs.meta fix: address CodeRabbit and Greptile feedback 2025-09-03 16:37:45 -07:00
ManageScriptableObjectStressTests.cs Clean up Unity and Python tests (#548) 2026-01-11 20:26:20 -08:00
ManageScriptableObjectStressTests.cs.meta Harden `manage_scriptable_object` Tool (#522) 2026-01-07 10:46:35 -04:00
ManageScriptableObjectTests.cs Harden `manage_scriptable_object` Tool (#522) 2026-01-07 10:46:35 -04:00
ManageScriptableObjectTests.cs.meta feature/Add new manage_scriptable_object tool (#489) 2025-12-28 20:15:50 -08:00
MaterialDirectPropertiesTests.cs Harden `manage_scriptable_object` Tool (#522) 2026-01-07 10:46:35 -04:00
MaterialDirectPropertiesTests.cs.meta Material tools: support direct shader property keys + add EditMode coverage (#344) 2025-10-23 18:25:29 -07:00
MaterialMeshInstantiationTests.cs Move Get commands to editor resources + Run Python tests every update (#368) 2025-11-05 16:06:48 -04:00
MaterialMeshInstantiationTests.cs.meta test: Consolidate pytest suite to MCPForUnity and improve test infrastructure (#332) 2025-10-21 10:42:55 -07:00
MaterialParameterToolTests.cs v9 pre-release pruning (#528) 2026-01-07 18:51:51 -04:00
MaterialParameterToolTests.cs.meta Harden MCP tool parameter handling + add material workflow tests (TDD) (#343) 2025-10-23 17:57:27 -07:00
PropertyConversionErrorHandlingTests.cs Fix WebSocket connection reliability and domain reload recovery (#656) 2026-01-30 16:42:39 -08:00
PropertyConversionErrorHandlingTests.cs.meta Fix WebSocket connection reliability and domain reload recovery (#656) 2026-01-30 16:42:39 -08:00
PropertyConversion_ArrayForFloat_Test.cs Fix WebSocket connection reliability and domain reload recovery (#656) 2026-01-30 16:42:39 -08:00
PropertyConversion_ArrayForFloat_Test.cs.meta Fix WebSocket connection reliability and domain reload recovery (#656) 2026-01-30 16:42:39 -08:00
ReadConsoleTests.cs Harden `manage_scriptable_object` Tool (#522) 2026-01-07 10:46:35 -04:00
ReadConsoleTests.cs.meta feat: Add `manage_material` tool for dedicated material manipulation (#440) 2025-12-07 19:39:52 -08:00
RunTestsTests.cs v9 pre-release pruning (#528) 2026-01-07 18:51:51 -04:00
RunTestsTests.cs.meta Feature/run tests summary clean (#501) 2026-01-01 20:36:45 -08:00
UIDocumentSerializationTests.cs fix: Add special handling for UIDocument serialization to prevent infinite loops (#586) 2026-01-19 08:21:36 -08:00
UIDocumentSerializationTests.cs.meta Project scoped tools (#596) 2026-01-21 13:07:52 -04:00