Skip to content

Conversation

@dsarno
Copy link
Owner

@dsarno dsarno commented Dec 22, 2025

Summary

  • add a manage_editor action that requests script compilation without needing playmode changes
  • expose the compilation action through the Python manage_editor tool definition
  • return compilation status details (pre/post state and note) when requesting compilation

Testing

  • not run (not requested)

Codex Task

Summary by CodeRabbit

  • New Features
    • Extended editor management tools with script compilation control. Users can now request script compilation and receive status feedback on whether compilation was already in progress and its current state.

✏️ Tip: You can customize this high-level summary in your review settings.

@cursor
Copy link

cursor bot commented Dec 22, 2025

You have run out of free Bugbot PR reviews for this billing cycle. This will reset on January 7.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@coderabbitai
Copy link

coderabbitai bot commented Dec 22, 2025

Walkthrough

A new "request_script_compilation" action is added to both the C# editor tool and Python service layer. The C# implementation captures compilation state, triggers script compilation via Unity's API, and returns the compilation status. The Python service updates its action parameter type to recognize this new action.

Changes

Cohort / File(s) Summary
Script Compilation Action Handler
MCPForUnity/Editor/Tools/ManageEditor.cs
Adds "request_script_compilation" case in HandleCommand switch statement that invokes CompilationPipeline.RequestScriptCompilation(), tracks prior and current compilation state, and returns response with compilation status. Adds using directive for UnityEditor.Compilation and updates error messaging to list supported actions.
Service Action Definition
Server/src/services/tools/manage_editor.py
Updates manage_editor method's action parameter Literal type to include "request_script_compilation" as an allowed value.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Areas requiring attention:
    • Verify CompilationPipeline.RequestScriptCompilation() is the correct API call and properly handles compilation state tracking
    • Confirm the success response structure (wasCompiling, nowCompiling, note) aligns with client expectations

Poem

🐰 A script compiler's wish comes true,
Whisker-twitching through and through!
New action blooms in Python's garden,
C# catches it with Unity's pardon.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately summarizes the main change: adding a new manage_editor action for script compilation, which is the primary purpose of the PR.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/extend-manage_editor-for-script-compilation-action

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link

greptile-apps bot commented Dec 22, 2025

Greptile Summary

Added request_script_compilation action to the manage_editor tool, enabling script compilation requests without playmode changes. The implementation exposes Unity's CompilationPipeline.RequestScriptCompilation() API and returns detailed compilation status information (pre/post state and explanatory notes).

  • Added UnityEditor.Compilation namespace import in ManageEditor.cs
  • Implemented request_script_compilation case in the action switch statement with proper error handling
  • Exposed compilation status details (wasCompiling, nowCompiling, note) through the response data
  • Updated error message to include new action in supported actions list
  • Added request_script_compilation to Python tool's action literal type for proper type checking

The implementation follows existing patterns in the codebase for adding new actions and properly integrates with the transport layer.

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk
  • The implementation correctly adds a new action following established patterns, with proper error handling and response structure. One minor suggestion about timing when checking compilation state after an async operation, but this doesn't affect functionality. No breaking changes.
  • No files require special attention - both changes are straightforward additions to existing tool functionality

Important Files Changed

Filename Overview
MCPForUnity/Editor/Tools/ManageEditor.cs Added request_script_compilation action with pre/post compilation state tracking; minor timing issue with async compilation check
Server/src/services/tools/manage_editor.py Added request_script_compilation to action literal type; properly integrated with existing parameter handling

Sequence Diagram

sequenceDiagram
    participant Client
    participant Python as manage_editor.py
    participant Unity as ManageEditor.cs
    participant CP as CompilationPipeline

    Client->>Python: manage_editor(action="request_script_compilation")
    Python->>Python: validate parameters & get Unity instance
    Python->>Unity: send_with_unity_instance("manage_editor", params)
    Unity->>Unity: HandleCommand(params)
    Unity->>CP: check isCompiling (wasCompiling)
    CP-->>Unity: current state
    Unity->>CP: RequestScriptCompilation()
    CP-->>Unity: request sent
    Unity->>CP: check isCompiling (nowCompiling)
    CP-->>Unity: updated state
    Unity->>Unity: build SuccessResponse with wasCompiling, nowCompiling, note
    Unity-->>Python: response {success, message, data}
    Python->>Python: unwrap response structure
    Python-->>Client: {success: true, message, data: {wasCompiling, nowCompiling, note}}
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +90 to +92
bool wasCompiling = CompilationPipeline.isCompiling;
CompilationPipeline.RequestScriptCompilation();
bool nowCompiling = CompilationPipeline.isCompiling;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Checking CompilationPipeline.isCompiling immediately after RequestScriptCompilation() may not accurately reflect the compilation state due to async nature. Consider delaying the check or using EditorApplication.update callback.

Prompt To Fix With AI
This is a comment left during a code review.
Path: MCPForUnity/Editor/Tools/ManageEditor.cs
Line: 90:92

Comment:
**style:** Checking `CompilationPipeline.isCompiling` immediately after `RequestScriptCompilation()` may not accurately reflect the compilation state due to async nature. Consider delaying the check or using EditorApplication.update callback.

How can I resolve this? If you propose a fix, please make it concise.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ce09d6 and 7307ef2.

📒 Files selected for processing (2)
  • MCPForUnity/Editor/Tools/ManageEditor.cs
  • Server/src/services/tools/manage_editor.py
🧰 Additional context used
🧬 Code graph analysis (1)
MCPForUnity/Editor/Tools/ManageEditor.cs (1)
MCPForUnity/Editor/Helpers/Response.cs (4)
  • SuccessResponse (11-33)
  • SuccessResponse (28-32)
  • ErrorResponse (35-67)
  • ErrorResponse (61-66)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Greptile Review
🔇 Additional comments (3)
Server/src/services/tools/manage_editor.py (1)

17-17: LGTM!

The addition of "request_script_compilation" to the action Literal type is straightforward and correctly exposes the new Unity backend capability to the Python service layer.

MCPForUnity/Editor/Tools/ManageEditor.cs (2)

5-5: LGTM!

The UnityEditor.Compilation namespace import is necessary for accessing the CompilationPipeline API used in the new action handler.


148-148: LGTM!

The error message correctly includes the new "request_script_compilation" action in the list of supported actions, maintaining consistency with the codebase.

Comment on lines +87 to +109
case "request_script_compilation":
try
{
bool wasCompiling = CompilationPipeline.isCompiling;
CompilationPipeline.RequestScriptCompilation();
bool nowCompiling = CompilationPipeline.isCompiling;
string detail = nowCompiling
? "Unity reports compilation in progress."
: "Unity is not currently compiling; if no pending script changes exist, the request may be a no-op.";
return new SuccessResponse(
"Script compilation request sent.",
new
{
wasCompiling,
nowCompiling,
note = detail
}
);
}
catch (Exception e)
{
return new ErrorResponse($"Error requesting script compilation: {e.Message}");
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

RequestScriptCompilation timing may not reflect actual compilation state.

The nowCompiling check on line 92 occurs immediately after calling RequestScriptCompilation(). Since this operation runs asynchronously, the state may not immediately reflect whether compilation will begin. The current note acknowledges the no-op case but doesn't document this async behavior.

For more reliable state tracking, consider using the CompilationPipeline.compilationStarted event instead of polling isCompiling immediately after the request.

🤖 Prompt for AI Agents
In MCPForUnity/Editor/Tools/ManageEditor.cs around lines 87 to 109, the code
reads CompilationPipeline.isCompiling immediately after
RequestScriptCompilation(), which can be misleading because compilation starts
asynchronously; replace the immediate check with a reliable approach by
subscribing to CompilationPipeline.compilationStarted (and optionally
compilationFinished) to detect when compilation actually begins, update the
success response to either return immediately with a clear note that compilation
is asynchronous or defer returning until compilationStarted fires (or provide a
follow-up callback/notification), and remove the immediate nowCompiling polling
logic so the response accurately reflects true compilation state.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants