Skip to content

Commit 2d59af9

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 92b8387 + 219eccc commit 2d59af9

19 files changed

+871
-133
lines changed

Editor/Services/ITestRunnerService.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ public interface ITestRunnerService
2222
/// </summary>
2323
/// <param name="testMode">The test mode to run (EditMode or PlayMode).</param>
2424
/// <param name="returnOnlyFailures">If true, only failed test results are included in the output.</param>
25+
/// <param name="returnWithLogs">If true, all logs are included in the output.</param>
2526
/// <param name="testFilter">A filter string to select specific tests to run.</param>
2627
/// <returns>Task that resolves with test results when tests are complete</returns>
27-
Task<JObject> ExecuteTestsAsync(TestMode testMode, bool returnOnlyFailures, string testFilter);
28+
Task<JObject> ExecuteTestsAsync(TestMode testMode, bool returnOnlyFailures, bool returnWithLogs, string testFilter);
2829
}
29-
}
30+
}

Editor/Services/TestRunnerService.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class TestRunnerService : ITestRunnerService, ICallbacks
2121
private readonly TestRunnerApi _testRunnerApi;
2222
private TaskCompletionSource<JObject> _tcs;
2323
private bool _returnOnlyFailures;
24+
private bool _returnWithLogs;
2425
private List<ITestResultAdaptor> _results;
2526

2627
/// <summary>
@@ -77,13 +78,15 @@ public async Task<List<ITestAdaptor>> GetAllTestsAsync(string testModeFilter = "
7778
/// </summary>
7879
/// <param name="testMode">The test mode to run (EditMode or PlayMode).</param>
7980
/// <param name="returnOnlyFailures">If true, only failed test results are included in the output.</param>
81+
/// <param name="returnWithLogs">If true, all logs are included in the output.</param>
8082
/// <param name="testFilter">A filter string to select specific tests to run.</param>
8183
/// <returns>Task that resolves with test results when tests are complete</returns>
82-
public async Task<JObject> ExecuteTestsAsync(TestMode testMode, bool returnOnlyFailures, string testFilter = "")
84+
public async Task<JObject> ExecuteTestsAsync(TestMode testMode, bool returnOnlyFailures, bool returnWithLogs, string testFilter = "")
8385
{
8486
_tcs = new TaskCompletionSource<JObject>();
8587
_results = new List<ITestResultAdaptor>();
8688
_returnOnlyFailures = returnOnlyFailures;
89+
_returnWithLogs = returnWithLogs;
8790
var filter = new Filter { testMode = testMode };
8891

8992
if (!string.IsNullOrEmpty(testFilter))
@@ -191,30 +194,30 @@ private async Task<JObject> WaitForCompletionAsync(int timeoutSeconds)
191194

192195
private JObject BuildResultJson(List<ITestResultAdaptor> results, ITestResultAdaptor result)
193196
{
194-
int pass = results.Count(r => r.ResultState == "Passed");
195-
int fail = results.Count(r => r.ResultState == "Failed");
196-
int skip = results.Count(r => r.ResultState == "Skipped");
197-
198197
var arr = new JArray(results
198+
.Where(r => !r.HasChildren)
199199
.Where(r => !_returnOnlyFailures || r.ResultState == "Failed")
200200
.Select(r => new JObject {
201201
["name"] = r.Name,
202202
["fullName"] = r.FullName,
203203
["state"] = r.ResultState,
204204
["message"] = r.Message,
205-
["duration"] = r.Duration
205+
["duration"] = r.Duration,
206+
["logs"] = _returnWithLogs ? r.Output : null,
207+
["stackTrace"] = r.StackTrace
206208
}));
207209

210+
int testCount = result.PassCount + result.SkipCount + result.FailCount;
208211
return new JObject {
209212
["success"] = true,
210213
["type"] = "text",
211-
["message"] = $"{result.Test.Name} test run completed: {pass}/{results.Count} passed - {fail}/{results.Count} failed - {skip}/{results.Count} skipped",
214+
["message"] = $"{result.Test.Name} test run completed: {result.PassCount}/{testCount} passed - {result.FailCount}/{testCount} failed - {result.SkipCount}/{testCount} skipped",
212215
["resultState"] = result.ResultState,
213216
["durationSeconds"] = result.Duration,
214-
["testCount"] = results.Count,
215-
["passCount"] = pass,
216-
["failCount"] = fail,
217-
["skipCount"] = skip,
217+
["testCount"] = testCount,
218+
["passCount"] = result.PassCount,
219+
["failCount"] = result.FailCount,
220+
["skipCount"] = result.SkipCount,
218221
["results"] = arr
219222
};
220223
}

Editor/Tools/RunTestsTool.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public override async void ExecuteAsync(JObject parameters, TaskCompletionSource
3737
string testModeStr = parameters?["testMode"]?.ToObject<string>() ?? "EditMode";
3838
string testFilter = parameters?["testFilter"]?.ToObject<string>(); // Optional
3939
bool returnOnlyFailures = parameters?["returnOnlyFailures"]?.ToObject<bool>() ?? false; // Optional
40+
bool returnWithLogs = parameters?["returnWithLogs"]?.ToObject<bool>() ?? false; // Optional
4041

4142
TestMode testMode = TestMode.EditMode;
4243

@@ -48,7 +49,7 @@ public override async void ExecuteAsync(JObject parameters, TaskCompletionSource
4849
McpLogger.LogInfo($"Executing RunTestsTool: Mode={testMode}, Filter={testFilter ?? "(none)"}");
4950

5051
// Call the service to run tests
51-
JObject result = await _testRunnerService.ExecuteTestsAsync(testMode, returnOnlyFailures, testFilter);
52+
JObject result = await _testRunnerService.ExecuteTestsAsync(testMode, returnOnlyFailures, returnWithLogs, testFilter);
5253
tcs.SetResult(result);
5354
}
5455
}

Editor/UnityBridge/McpUnityEditorWindow.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class McpUnityEditorWindow : EditorWindow
2222
private string _mcpConfigJson = "";
2323
private bool _tabsIndentationJson = false;
2424
private Vector2 _helpTabScrollPosition = Vector2.zero;
25+
private Vector2 _serverTabScrollPosition = Vector2.zero;
2526

2627
[MenuItem("Tools/MCP Unity/Server Window", false, 1)]
2728
public static void ShowWindow()
@@ -66,6 +67,7 @@ private void OnGUI()
6667

6768
private void DrawServerTab()
6869
{
70+
_serverTabScrollPosition = EditorGUILayout.BeginScrollView(_serverTabScrollPosition);
6971
EditorGUILayout.BeginVertical("box");
7072

7173
// Server status
@@ -299,15 +301,20 @@ private void DrawServerTab()
299301
}
300302
}
301303

302-
EditorGUILayout.EndVertical();
303-
304+
EditorGUILayout.Separator();
305+
EditorGUILayout.Separator();
306+
304307
EditorGUILayout.Space();
305308

306309
// Force Install Server button
307310
if (GUILayout.Button("Force Install Server", GUILayout.Height(30)))
308311
{
309312
McpUnityServer.Instance.InstallServer();
313+
McpLogger.LogInfo("MCP Unity Server installed successfully.");
310314
}
315+
316+
EditorGUILayout.EndVertical();
317+
EditorGUILayout.EndScrollView();
311318
}
312319

313320
private void DrawHelpTab()

Editor/UnityBridge/McpUnitySettings.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public enum ConsoleLogServiceType
2525
public class McpUnitySettings
2626
{
2727
// Constants
28-
public const string ServerVersion = "1.0.0";
28+
public const string ServerVersion = "1.1.1";
2929
public const string PackageName = "com.gamelovers.mcp-unity";
3030
public const int RequestTimeoutMinimum = 10;
3131

@@ -73,7 +73,6 @@ public static McpUnitySettings Instance
7373
private McpUnitySettings()
7474
{
7575
LoadSettings();
76-
VsCodeWorkspaceUtils.AddPackageCacheToWorkspace();
7776
}
7877

7978
/// <summary>

Editor/Utils/McpUtils.cs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ public static string GetServerPath()
7373

7474
if (packageInfo != null && !string.IsNullOrEmpty(packageInfo.resolvedPath))
7575
{
76-
return Path.Combine(packageInfo.resolvedPath, "Server~");
76+
string serverPath = Path.Combine(packageInfo.resolvedPath, "Server~");
77+
78+
return CleanPathPrefix(serverPath);
7779
}
7880

7981
var assets = AssetDatabase.FindAssets("tsconfig");
@@ -82,18 +84,20 @@ public static string GetServerPath()
8284
{
8385
// Convert relative path to absolute path
8486
var relativePath = AssetDatabase.GUIDToAssetPath(assets[0]);
85-
return Path.GetFullPath(Path.Combine(Application.dataPath, "..", relativePath));
87+
string fullPath = Path.GetFullPath(Path.Combine(Application.dataPath, "..", relativePath));
88+
89+
return CleanPathPrefix(fullPath);
8690
}
8791
if (assets.Length > 0)
8892
{
8993
foreach (var assetJson in assets)
9094
{
9195
string relativePath = AssetDatabase.GUIDToAssetPath(assetJson);
9296
string fullPath = Path.GetFullPath(Path.Combine(Application.dataPath, "..", relativePath));
93-
97+
9498
if(Path.GetFileName(Path.GetDirectoryName(fullPath)) == "Server~")
9599
{
96-
return Path.GetDirectoryName(fullPath);
100+
return CleanPathPrefix(Path.GetDirectoryName(fullPath));
97101
}
98102
}
99103
}
@@ -106,6 +110,20 @@ public static string GetServerPath()
106110
return errorString;
107111
}
108112

113+
/// <summary>
114+
/// Cleans the path prefix by removing a leading "~" character if present on macOS.
115+
/// </summary>
116+
/// <param name="path">The path to clean.</param>
117+
/// <returns>The cleaned path.</returns>
118+
private static string CleanPathPrefix(string path)
119+
{
120+
if (path.StartsWith("~"))
121+
{
122+
return path.Substring(1);
123+
}
124+
return path;
125+
}
126+
109127
/// <summary>
110128
/// Adds the MCP configuration to the Windsurf MCP config file
111129
/// </summary>

0 commit comments

Comments
 (0)