Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 65 additions & 5 deletions Assets/Editor/CompileCheckWindow/CompileEditorWindow.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using UnityEngine;
using UnityEditor;
using UnityEditor.Compilation;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;

using io.github.hatayama.UnityCliLoop.Application;
using io.github.hatayama.UnityCliLoop.FirstPartyTools;
Expand All @@ -18,6 +20,7 @@ public class CompileEditorWindow : EditorWindow
private CompileLogDisplay _logDisplay;
private Vector2 _scrollPosition;
private bool _forceRecompile = false;
private bool _isPostCompileReadinessRunning = false;

// Note: Compile window data is now managed via McpSessionManager

Expand Down Expand Up @@ -94,9 +97,8 @@ private void OnGUI()
_forceRecompile = EditorGUILayout.Toggle("Force Recompile", _forceRecompile);
GUILayout.Space(5);

EditorGUI.BeginDisabledGroup(_compileController.IsCompiling);
string buttonText = _compileController.IsCompiling ? "Compiling..." :
(_forceRecompile ? "Run Force Compile" : "Run Compile");
EditorGUI.BeginDisabledGroup(IsCompileActionBusy());
string buttonText = CreateCompileButtonText();
if (GUILayout.Button(buttonText, GUILayout.Height(30)))
{
// Execute compilation using async/await
Expand Down Expand Up @@ -125,7 +127,21 @@ private void OnGUI()

private async Task ExecuteCompileAsync()
{
CompileResult result = await _compileController.TryCompileAsync(_forceRecompile);
CompileResult result = await _compileController.TryCompileAsync(_forceRecompile, CancellationToken.None);
if (ShouldRunExecuteDynamicCodeReadinessAfterCompile(result))
{
_isPostCompileReadinessRunning = true;
Repaint();
try
{
await RunExecuteDynamicCodeReadinessProbesAfterCompileAsync(CancellationToken.None);
}
finally
{
_isPostCompileReadinessRunning = false;
Repaint();
}
}

// Output result to log (for debugging)
string message = string.IsNullOrEmpty(result.Message) ? "(none)" : result.Message;
Expand All @@ -143,6 +159,50 @@ private async Task ExecuteCompileAsync()
UnityEngine.Debug.Log(logMessage);
}

private static bool ShouldRunExecuteDynamicCodeReadinessAfterCompile(CompileResult result)
{
return result.Success == true;
}

private static async Task RunExecuteDynamicCodeReadinessProbesAfterCompileAsync(CancellationToken ct)
{
// Why: the editor Compile Tool bypasses the native CLI's post-compile readiness wait,
// so it must run the same hidden probe path before handing control back to the user.
foreach (string code in ExecuteDynamicCodeReadinessProbe.CreateReturnStringProbeCodes())
{
ct.ThrowIfCancellationRequested();
JObject parameters = new()
{
["Code"] = code,
["CompileOnly"] = false,
["YieldToForegroundRequests"] = false
};
await UnityCliLoopToolRegistrar.GetRegistry().ExecuteToolAsync(
"execute-dynamic-code",
parameters);
}
}

private bool IsCompileActionBusy()
{
return _compileController.IsCompiling || _isPostCompileReadinessRunning;
}

private string CreateCompileButtonText()
{
if (_compileController.IsCompiling)
{
return "Compiling...";
}

if (_isPostCompileReadinessRunning)
{
return "Preparing...";
}

return _forceRecompile ? "Run Force Compile" : "Run Compile";
}

private void OnCompileCompleted(CompileResult result)
{
_logDisplay.AppendCompletionMessage(result);
Expand Down Expand Up @@ -180,4 +240,4 @@ private void ClearLog()
Repaint();
}
}
}
}
1 change: 1 addition & 0 deletions Assets/Editor/uLoopMCP.Dev.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"UnityCLILoop.FirstPartyTools.Common.MouseUi.Editor",
"UnityCLILoop.FirstPartyTools.Common.Overlay.Editor",
"UnityCLILoop.FirstPartyTools.Compile.Editor",
"UnityCLILoop.FirstPartyTools.ExecuteDynamicCode.Editor",
"UnityCLILoop.FirstPartyTools.FindGameObjects.Editor",
"UnityCLILoop.FirstPartyTools.GetLogs.Editor",
"UnityCLILoop.FirstPartyTools.RunTests.Editor",
Expand Down

This file was deleted.

Loading