Skip to content

Comments

feat(manage_editor): add wait_for_compilation action#815

Open
smuhlaci wants to merge 5 commits intoCoplayDev:betafrom
smuhlaci:beta
Open

feat(manage_editor): add wait_for_compilation action#815
smuhlaci wants to merge 5 commits intoCoplayDev:betafrom
smuhlaci:beta

Conversation

@smuhlaci
Copy link

@smuhlaci smuhlaci commented Feb 23, 2026

Poll editor_state until compilation and domain reload finish so the AI can wait for script changes to compile instead of using fixed sleep.

  • manage_editor(action="wait_for_compilation", timeout=30) on server
  • CLI: unity-mcp editor wait-compile [--timeout N]
  • Reuses wait_for_editor_ready from refresh_unity; no C# changes

Description

Issue #814 describes the problem. Agents using long sleeps after script changes) and proposes wait_for_compilation.

Type of Change

  • New feature (non-breaking change that adds functionality)

Changes Made

Adds a wait_for_compilation action to manage_editor so AI agents can wait for Unity compilation (and domain reload) to finish instead of using fixed sleep durations or custom polling of editor_state. This makes script-edit → play → verify workflows faster and more reliable.

Fixes the workflow issue where agents had to use ~5–12 seconds of sleep after script changes before playing or running other editor operations.

1. Server/src/services/tools/manage_editor.py

  • New wait_for_compilation action:
    • Handled entirely on the Python server (no Unity C# changes).
    • Uses existing wait_for_editor_ready (or equivalent) to poll editor_state until compilation and domain reload are done.
    • Optional timeout parameter (default 30s, max 120s).
    • If compilation is already done, returns immediately; otherwise blocks until ready or timeout.
    • Response can include e.g. waited_seconds for observability.

2. Server/src/cli/commands/editor.py

  • New CLI command: unity-mcp editor wait-compile
    • Supports --timeout for the same timeout behavior.

3. Server/tests/integration/test_manage_editor_wait.py (new file)

  • Integration tests for wait_for_compilation:
    • Returns immediately when editor is already idle (no compilation).
    • Blocks and returns when compilation finishes (polling scenario).
    • Respects timeout when compilation takes too long.
    • Default and max timeout behavior.
    • Routing through manage_editor and behavior after domain reload.

4. C# / Unity side

  • No changes. The new action is handled only in the Python server; Unity already exposes compilation state via editor_state and the existing “wait for ready” infrastructure uses it.
  1. manage_script(action="update", ...) → Script updated
  2. manage_editor(action="wait_for_compilation") → Wait until compile + domain reload done
  3. manage_editor(action="play") → Enter play mode
  4. read_console(types=["error"]) → Check for errors

Testing/Screenshots/Recordings

  • New integration tests in test_manage_editor_wait.py (e.g. 6 cases covering ready, poll, timeout, CLI).
  • Existing test suite run; no regressions (aside from known unrelated failures, e.g. telemetry/sandbox).
Screenshot 2026-02-23 at 14 19 58

Documentation Updates

  • I have added/removed/modified tools or resources
  • If yes, I have updated all documentation files using:
    • The LLM prompt at tools/UPDATE_DOCS_PROMPT.md (recommended)
    • Manual updates following the guide at tools/UPDATE_DOCS.md

Checklist

  • wait_for_compilation implemented in manage_editor.py
  • CLI unity-mcp editor wait-compile added
  • Integration tests added and passing
  • No C#/Unity code changes required
  • MCP tool descriptor will reflect new action when server is regenerated/restarted

Related Issues

Fixes #814

Additional Notes

Summary by Sourcery

Add a server-side manage_editor action and CLI command to wait for Unity script compilation to complete before proceeding with editor operations.

New Features:

  • Introduce manage_editor(action="wait_for_compilation", timeout=...) to block until Unity compilation and domain reload finish or a timeout is reached.
  • Add CLI command unity-mcp editor wait-compile with optional timeout to wait for scripts to compile from the command line.

Documentation:

  • Document the new wait_for_compilation manage_editor action in tools references.
  • Update CLI usage guides and examples to include the unity-mcp editor wait-compile command.

Tests:

  • Add integration test suite covering wait_for_compilation behavior, including immediate success, polling until ready, timeout handling, default timeout, routing via manage_editor, and domain reload scenarios.

Summary by CodeRabbit

  • New Features

    • Added an editor command "wait-compile" to wait for script compilation to finish, with a configurable timeout (default 30s).
  • Documentation

    • CLI guides and public tool reference updated to document the wait-compile command and usage.
  • Tests

    • Added integration tests validating immediate success, polling until ready, timeout behavior, default timeout handling, and related readiness scenarios.

smuhlaci and others added 2 commits February 23, 2026 12:53
Poll editor_state until compilation and domain reload finish so the AI
can wait for script changes to compile instead of using fixed sleep.

- manage_editor(action="wait_for_compilation", timeout=30) on server
- CLI: unity-mcp editor wait-compile [--timeout N]
- Reuses wait_for_editor_ready from refresh_unity; no C# changes

Co-authored-by: Cursor <cursoragent@cursor.com>
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 23, 2026

Reviewer's Guide

Adds a new wait_for_compilation manage_editor action implemented entirely on the Python server, exposes it via a new CLI subcommand, wires it into existing editor readiness polling, and documents the new workflow along with integration tests covering readiness, polling, and timeout behavior.

Sequence diagram for the new wait_for_compilation manage_editor action

sequenceDiagram
    actor Agent
    participant CLI as CLI_unity_mcp
    participant Server as Python_Server
    participant ManageEditor as manage_editor_tool
    participant WaitReady as wait_for_editor_ready
    participant Unity as Unity_Editor

    Agent->>CLI: unity-mcp editor wait-compile --timeout N
    CLI->>Server: run_command manage_editor action=wait_for_compilation timeout=N
    Server->>ManageEditor: manage_editor(ctx, action, timeout)
    ManageEditor->>ManageEditor: coerce_bool(wait_for_completion)
    ManageEditor->>ManageEditor: detect action == wait_for_compilation
    ManageEditor->>ManageEditor: _wait_for_compilation(ctx, timeout)
    ManageEditor->>WaitReady: wait_for_editor_ready(ctx, timeout_s)
    loop Poll editor_state until ready or timeout
        WaitReady->>Unity: query editor_state (compilation, domain_reload)
        Unity-->>WaitReady: editor_state snapshot
    end
    WaitReady-->>ManageEditor: ready_flag, elapsed_seconds
    alt Compilation finished before timeout
        ManageEditor-->>Server: {success: True, data: {waited_seconds, ready: True}}
        Server-->>CLI: formatted success result
        CLI->>CLI: print_success("Compilation complete (waited Xs)")
        CLI-->>Agent: result
    else Timed out waiting for compilation
        ManageEditor-->>Server: {success: False, data: {waited_seconds, ready: False, timeout_seconds}}
        Server-->>CLI: formatted failure result
        CLI->>CLI: print_error("Compilation wait timed out")
        CLI-->>Agent: timeout result
    end
Loading

Updated class diagram for manage_editor tool and editor wait_compile CLI command

classDiagram
    class ManageEditorTool {
        +manage_editor(ctx, action, wait_for_completion, timeout, tool_name, tag_name, layer_name) dict
        +_wait_for_compilation(ctx, timeout) dict
    }

    class RefreshUnityTool {
        +wait_for_editor_ready(ctx, timeout_s) tuple
    }

    class EditorCLI {
        +wait_compile(timeout)
        +play()
        +pause()
        +stop()
    }

    class UnityConnection {
        +async_send_command_with_retry(instance, command, params)
    }

    class TransportHelpers {
        +send_with_unity_instance(sender, unity_instance, command, params)
        +get_unity_instance_from_context(ctx)
    }

    class TelemetryService {
        +is_telemetry_enabled() bool
        +record_tool_usage(event_name, success, duration, metadata)
    }

    ManageEditorTool --> RefreshUnityTool : uses wait_for_editor_ready
    ManageEditorTool --> TransportHelpers : uses
    ManageEditorTool --> UnityConnection : sends manage_editor commands
    ManageEditorTool --> TelemetryService : telemetry_status, telemetry_ping
    EditorCLI --> ManageEditorTool : calls via run_command manage_editor
    EditorCLI --> TransportHelpers : uses config and formatting helpers
Loading

File-Level Changes

Change Details Files
Add wait_for_compilation action to manage_editor that polls Unity editor_state until compilation and domain reload complete, with a configurable timeout.
  • Extend manage_editor tool description and action Literal to include wait_for_compilation as a read-only action.
  • Add an optional timeout parameter to manage_editor for controlling wait_for_compilation behavior.
  • Route wait_for_compilation requests in manage_editor to a new internal _wait_for_compilation coroutine instead of sending a Unity command.
  • Implement _wait_for_compilation using refresh_unity.wait_for_editor_ready, with timeout clamping, elapsed time tracking, and a structured success/failure response payload.
Server/src/services/tools/manage_editor.py
Expose wait_for_compilation via a new CLI subcommand that calls manage_editor and surfaces the result to the user.
  • Add editor wait-compile subcommand with a --timeout/-t option defaulting to 30 seconds.
  • Invoke run_command against manage_editor with action=wait_for_compilation and pass through the timeout value from the CLI.
  • Format and print the tool result using existing helpers, emitting a success message including waited_seconds or an error on timeout.
Server/src/cli/commands/editor.py
Document the new wait-compile CLI command and manage_editor wait_for_compilation action in user- and LLM-facing docs.
  • Update CLI usage guide to show unity-mcp editor wait-compile with optional --timeout.
  • Add wait-compile to the CLI examples under Editor Control.
  • Extend tools-reference docs to include manage_editor(action="wait_for_compilation", timeout=30) usage for scripts compilation waits.
Server/src/cli/CLI_USAGE_GUIDE.md
docs/guides/CLI_USAGE.md
docs/guides/CLI_EXAMPLE.md
.claude/skills/unity-mcp-skill/references/tools-reference.md
unity-mcp-skill/references/tools-reference.md
Add integration tests that validate wait_for_compilation behavior, including readiness, polling, timeout handling, and routing through manage_editor.
  • Create tests that monkeypatch editor_state.get_editor_state to simulate ready, compiling, and domain_reload states and verify _wait_for_compilation behavior.
  • Verify immediate return when already ready, polling across multiple calls until ready, and timeout failure when never ready.
  • Test default timeout handling when timeout is None and ensure the action can be invoked through the public manage_editor entrypoint.
Server/tests/integration/test_manage_editor_wait.py

Assessment against linked issues

Issue Objective Addressed Explanation
#814 Add a manage_editor(action="wait_for_compilation") capability on the server that blocks until Unity compilation and domain reload are finished, using existing editor_state / wait_for_editor_ready logic and returning immediately if already ready.
#814 Support an optional timeout parameter for wait_for_compilation (default ~30 seconds, with an upper bound around 120 seconds) and report the outcome (including how long was waited and whether a timeout occurred).
#814 Expose the new wait_for_compilation capability to users and agents via the CLI and documentation (e.g., CLI command and tool reference examples).

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • _WAIT_FOR_COMPILATION_ACTIONS is declared but never used in manage_editor.py; either remove it or wire it into any action classification/validation logic you intended it for.
  • In the CLI wait-compile command, the error message is hard-coded to 'Compilation wait timed out' regardless of the actual failure cause; consider surfacing result['message'] (and/or checking a timeout flag) so non-timeout errors are reported accurately.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- _WAIT_FOR_COMPILATION_ACTIONS is declared but never used in manage_editor.py; either remove it or wire it into any action classification/validation logic you intended it for.
- In the CLI wait-compile command, the error message is hard-coded to 'Compilation wait timed out' regardless of the actual failure cause; consider surfacing result['message'] (and/or checking a timeout flag) so non-timeout errors are reported accurately.

## Individual Comments

### Comment 1
<location> `Server/src/cli/commands/editor.py:47` </location>
<code_context>
+        waited = result.get("data", {}).get("waited_seconds", 0)
+        print_success(f"Compilation complete (waited {waited}s)")
+    else:
+        print_error("Compilation wait timed out")
+
+
</code_context>

<issue_to_address>
**issue (bug_risk):** CLI error message assumes timeout even if the failure is due to another server-side error.

Any non-success from `manage_editor` currently maps to `print_error("Compilation wait timed out")`, but `_wait_for_compilation`/`manage_editor` can fail for other reasons (e.g., Python error, connectivity). Consider either checking a specific `ready`/`timeout` indicator in `result['data']`, or using `result.get("message")` (or similar) for non-timeout failures so users see the real cause.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 23, 2026

📝 Walkthrough

Walkthrough

Added a new "wait_for_compilation" editor action plus a CLI command to block until Unity script compilation (and domain reload) finishes with an optional timeout; service logic, tests, CLI help, and docs/reference entries were added or updated accordingly.

Changes

Cohort / File(s) Summary
Editor service
Server/src/services/tools/manage_editor.py
Add wait_for_compilation action, new timeout parameter on manage_editor, implement _wait_for_compilation that clamps timeout (1–120s), calls wait_for_editor_ready, and returns structured success/timeout payload.
CLI
Server/src/cli/commands/editor.py, Server/src/cli/CLI_USAGE_GUIDE.md
Add unity-mcp editor wait-compile subcommand with --timeout/-t (float, default 30), call manage_editor(action="wait_for_compilation", timeout=...), and print formatted result.
Integration tests
Server/tests/integration/test_manage_editor_wait.py
New async pytest module validating immediate success, polling-until-ready, timeout path, default timeout behavior, domain_reload blocking scenarios, and call-count expectations via monkeypatched editor_state.
Documentation & references
docs/guides/CLI_EXAMPLE.md, docs/guides/CLI_USAGE.md, unity-mcp-skill/references/tools-reference.md, .claude/skills/.../references/tools-reference.md
Document new CLI command and update tool reference to include manage_editor(action="wait_for_compilation", timeout=30) examples and command listing.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant CLI as CLI
participant Server as Server\n(manage_editor)
participant Refresh as RefreshUnity\n(editor_state)
participant Unity as Unity\n(Editor)
CLI->>Server: unity-mcp editor wait-compile --timeout N
Server->>Server: _wait_for_compilation(timeout=N)
loop polling
Server->>Refresh: wait_for_editor_ready(timeout_s)
Refresh->>Unity: query editor_state
Unity-->>Refresh: respond (compiling / domain_reload / ready)
Refresh-->>Server: state (is_ready / blocking_reason)
end
Server-->>CLI: result { success: true|false, waited_seconds, ready, timeout_seconds? }

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

"I hopped through code with a twitchy tail,
waiting for compiles that once made me wail.
Now a button to wait, no more blind sleeps,
I guard builds while the whole tree sleeps.
🍃 — Rabbit, proud of tiny wins."

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 58.82% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main change: adding a wait_for_compilation action to manage_editor.
Description check ✅ Passed The PR description comprehensively addresses the template requirements, including clear description, type of change, detailed changes made, testing approach, documentation updates, and related issues.
Linked Issues check ✅ Passed All requirements from issue #814 are met: manage_editor wait_for_compilation action implemented with timeout support, CLI command added, existing infrastructure reused, and no Unity C# changes needed.
Out of Scope Changes check ✅ Passed All changes directly support the PR objective of adding wait_for_compilation capability; documentation updates and tests are appropriately scoped to this feature.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link
Contributor

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/guides/CLI_USAGE.md (1)

344-344: ⚠️ Potential issue | 🟡 Minor

wait-compile is missing from the Complete Command Reference table.

The new wait-compile subcommand was added to the Editor Controls section above (line 154) but not listed in the summary table on this line. Add it to keep the documentation consistent.

📝 Proposed fix
-| `editor` | `play`, `pause`, `stop`, `refresh`, `console`, `menu`, `tool`, `add-tag`, `remove-tag`, `add-layer`, `remove-layer`, `tests`, `poll-test`, `custom-tool` |
+| `editor` | `play`, `pause`, `stop`, `wait-compile`, `refresh`, `console`, `menu`, `tool`, `add-tag`, `remove-tag`, `add-layer`, `remove-layer`, `tests`, `poll-test`, `custom-tool` |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/guides/CLI_USAGE.md` at line 344, Add the missing `wait-compile`
subcommand to the Editor Controls list in the Complete Command Reference table
by inserting `wait-compile` into the backtick-enclosed list for `editor` (the
same list that currently contains `play`, `pause`, `stop`, `refresh`, `console`,
`menu`, `tool`, `add-tag`, `remove-tag`, `add-layer`, `remove-layer`, `tests`,
`poll-test`, `custom-tool`) so the summary matches the detailed Editor Controls
section.
🧹 Nitpick comments (3)
Server/src/cli/commands/editor.py (1)

21-23: Minor: -t short option shadows the global -t (--timeout).

The global CLI option -t / --timeout controls the HTTP request timeout (line 38 in CLI_USAGE.md), while this subcommand's -t / --timeout controls the compilation wait duration. Click scopes them correctly so there's no runtime conflict, but it could confuse users. Consider using a different short flag (e.g., -w for "wait") or dropping the short option entirely.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Server/src/cli/commands/editor.py` around lines 21 - 23, The subcommand in
Server/src/cli/commands/editor.py defines a Click option
click.option("--timeout", "-t", type=float) that reuses the global short flag
-t; change the short flag to avoid user confusion (e.g., use "-w" for wait or
remove the short option entirely). Update the option declaration for the editor
command (the click.option for "--timeout") and adjust any code/comments that
reference the short flag so the new short name (or no short name) is used
consistently.
Server/src/services/tools/manage_editor.py (2)

78-78: Unused variable start.

start = time.monotonic() is assigned but never read — elapsed comes from the return value of wait_for_editor_ready. This also makes import time at line 1 unnecessary.

♻️ Proposed fix
-    start = time.monotonic()
     ready, elapsed = await wait_for_editor_ready(ctx, timeout_s=timeout_s)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Server/src/services/tools/manage_editor.py` at line 78, Remove the unused
timing variable and redundant import: delete the line assigning start =
time.monotonic() and remove the top-level import time if no other code in
manage_editor.py uses it; confirm that wait_for_editor_ready’s return value
(elapsed) is used instead and that no other references to start or
time.monotonic remain (look for start and wait_for_editor_ready in this module).

14-14: Unused constant _WAIT_FOR_COMPILATION_ACTIONS.

This frozenset is defined but never referenced. The routing on line 49 uses a direct string comparison instead. Remove it or use it in the routing logic.

♻️ Option A: Remove unused constant
-_WAIT_FOR_COMPILATION_ACTIONS = frozenset({"wait_for_compilation"})
-
♻️ Option B: Use the constant in routing
-        if action == "wait_for_compilation":
+        if action in _WAIT_FOR_COMPILATION_ACTIONS:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Server/src/services/tools/manage_editor.py` at line 14, The constant
_WAIT_FOR_COMPILATION_ACTIONS is defined but never used; either remove that
unused frozenset or change the routing logic that currently does a direct string
comparison (the action routing in this module) to use a membership check against
_WAIT_FOR_COMPILATION_ACTIONS (e.g., replace the direct "wait_for_compilation"
equality check with "if action in _WAIT_FOR_COMPILATION_ACTIONS"). Update or
delete the _WAIT_FOR_COMPILATION_ACTIONS symbol accordingly so there are no
unused definitions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@docs/guides/CLI_USAGE.md`:
- Line 344: Add the missing `wait-compile` subcommand to the Editor Controls
list in the Complete Command Reference table by inserting `wait-compile` into
the backtick-enclosed list for `editor` (the same list that currently contains
`play`, `pause`, `stop`, `refresh`, `console`, `menu`, `tool`, `add-tag`,
`remove-tag`, `add-layer`, `remove-layer`, `tests`, `poll-test`, `custom-tool`)
so the summary matches the detailed Editor Controls section.

---

Nitpick comments:
In `@Server/src/cli/commands/editor.py`:
- Around line 21-23: The subcommand in Server/src/cli/commands/editor.py defines
a Click option click.option("--timeout", "-t", type=float) that reuses the
global short flag -t; change the short flag to avoid user confusion (e.g., use
"-w" for wait or remove the short option entirely). Update the option
declaration for the editor command (the click.option for "--timeout") and adjust
any code/comments that reference the short flag so the new short name (or no
short name) is used consistently.

In `@Server/src/services/tools/manage_editor.py`:
- Line 78: Remove the unused timing variable and redundant import: delete the
line assigning start = time.monotonic() and remove the top-level import time if
no other code in manage_editor.py uses it; confirm that wait_for_editor_ready’s
return value (elapsed) is used instead and that no other references to start or
time.monotonic remain (look for start and wait_for_editor_ready in this module).
- Line 14: The constant _WAIT_FOR_COMPILATION_ACTIONS is defined but never used;
either remove that unused frozenset or change the routing logic that currently
does a direct string comparison (the action routing in this module) to use a
membership check against _WAIT_FOR_COMPILATION_ACTIONS (e.g., replace the direct
"wait_for_compilation" equality check with "if action in
_WAIT_FOR_COMPILATION_ACTIONS"). Update or delete the
_WAIT_FOR_COMPILATION_ACTIONS symbol accordingly so there are no unused
definitions.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 95b6ddb and a0dec49.

⛔ Files ignored due to path filters (1)
  • Server/uv.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • .claude/skills/unity-mcp-skill/references/tools-reference.md
  • Server/src/cli/CLI_USAGE_GUIDE.md
  • Server/src/cli/commands/editor.py
  • Server/src/services/tools/manage_editor.py
  • Server/tests/integration/test_manage_editor_wait.py
  • docs/guides/CLI_EXAMPLE.md
  • docs/guides/CLI_USAGE.md
  • unity-mcp-skill/references/tools-reference.md

smuhlaci and others added 2 commits February 23, 2026 14:36
…wait-compile

- Remove unused _WAIT_FOR_COMPILATION_ACTIONS from manage_editor.py
- Use result.get('message', ...) in editor wait-compile so non-timeout
  errors (e.g. Python/connectivity) are reported accurately

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Copy link
Contributor

@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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Server/src/cli/commands/editor.py`:
- Line 41: The call to run_command("manage_editor", {"action":
"wait_for_compilation", "timeout": timeout}, config) doesn’t pass a transport
timeout so long waits can be cut off; update the invocation of run_command (from
editor CLI) to include a transport timeout parameter equal to or greater than
the requested timeout (e.g., pass transport_timeout=timeout or set it on the
config) so the RPC/transport uses the same timeout when invoking manage_editor
with action "wait_for_compilation".

In `@Server/src/services/tools/manage_editor.py`:
- Line 1: Remove the dead start = time.monotonic() assignment and the now-unused
import time in manage_editor.py: delete the start variable (the one set
immediately before calling wait_for_editor_ready) since elapsed is returned
directly by wait_for_editor_ready, and remove the top-level import time because
it becomes unused after dropping that assignment.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a0dec49 and ed7418a.

📒 Files selected for processing (3)
  • Server/src/cli/commands/editor.py
  • Server/src/services/tools/manage_editor.py
  • docs/guides/CLI_USAGE.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/guides/CLI_USAGE.md

@@ -1,3 +1,4 @@
import time
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove unused start variable and the now-dead import time.

start = time.monotonic() (Line 76) is flagged by Ruff (F841) and has no effect — elapsed is already returned directly by wait_for_editor_ready. Once Line 76 is removed, the import time at Line 1 becomes unused as well.

🧹 Proposed fix
-import time
 from typing import Annotated, Any, Literal
     timeout_s = max(1.0, min(timeout_s, 120.0))
 
-    start = time.monotonic()
     ready, elapsed = await wait_for_editor_ready(ctx, timeout_s=timeout_s)

Also applies to: 76-76

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Server/src/services/tools/manage_editor.py` at line 1, Remove the dead start
= time.monotonic() assignment and the now-unused import time in
manage_editor.py: delete the start variable (the one set immediately before
calling wait_for_editor_ready) since elapsed is returned directly by
wait_for_editor_ready, and remove the top-level import time because it becomes
unused after dropping that assignment.

… not cut off

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy link
Contributor

@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

♻️ Duplicate comments (1)
Server/src/cli/commands/editor.py (1)

41-43: Transport timeout buffer correctly implemented.

The 10-second buffer ensures the transport layer outlasts the server-side compilation wait regardless of float truncation by int(). Consistent with the addressed past review.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Server/src/cli/commands/editor.py` around lines 41 - 43, The current buffer
implementation is correct — keep the transport_timeout calculation and usage
as-is: compute transport_timeout = int(timeout) + 10 and pass it into
run_command(...) while leaving the command payload timeout as the original
timeout; the relevant symbols are transport_timeout, timeout, and the
run_command("manage_editor", {"action": "wait_for_compilation", "timeout":
timeout}, ..., timeout=transport_timeout) call.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Server/src/cli/commands/editor.py`:
- Around line 45-49: The success message breaks when "waited_seconds" is present
but null (producing None) and shows verbose raw floats; change how waited is
obtained and formatted in Server/src/cli/commands/editor.py: replace
result.get("data", {}).get("waited_seconds", 0) with a retrieval that coerces
null to 0 (e.g., waited = result.get("data", {}).get("waited_seconds") or 0) and
then format the value before passing to print_success (e.g., round or format to
2 decimal places with f-string) so print_success(f"Compilation complete (waited
{formatted}s)") always receives a sane string; keep references to result,
waited, and print_success.

---

Duplicate comments:
In `@Server/src/cli/commands/editor.py`:
- Around line 41-43: The current buffer implementation is correct — keep the
transport_timeout calculation and usage as-is: compute transport_timeout =
int(timeout) + 10 and pass it into run_command(...) while leaving the command
payload timeout as the original timeout; the relevant symbols are
transport_timeout, timeout, and the run_command("manage_editor", {"action":
"wait_for_compilation", "timeout": timeout}, ..., timeout=transport_timeout)
call.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ed7418a and 651e806.

📒 Files selected for processing (1)
  • Server/src/cli/commands/editor.py

Comment on lines +45 to +49
if result.get("success"):
waited = result.get("data", {}).get("waited_seconds", 0)
print_success(f"Compilation complete (waited {waited}s)")
else:
print_error(result.get("message", "Compilation wait timed out"))
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

waited_seconds: null from the server bypasses the default and produces a malformed message.

dict.get(key, default) only applies the default when the key is absent. If the server ever returns "waited_seconds": null, the expression result.get("data", {}).get("waited_seconds", 0) evaluates to None, and the success message becomes "Compilation complete (waited Nones)".

Additionally, a raw float like 2.3456 would render verbosely in the output string.

🛡️ Proposed fix
-        waited = result.get("data", {}).get("waited_seconds", 0)
-        print_success(f"Compilation complete (waited {waited}s)")
+        waited = result.get("data", {}).get("waited_seconds") or 0
+        print_success(f"Compilation complete (waited {waited:.1f}s)")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Server/src/cli/commands/editor.py` around lines 45 - 49, The success message
breaks when "waited_seconds" is present but null (producing None) and shows
verbose raw floats; change how waited is obtained and formatted in
Server/src/cli/commands/editor.py: replace result.get("data",
{}).get("waited_seconds", 0) with a retrieval that coerces null to 0 (e.g.,
waited = result.get("data", {}).get("waited_seconds") or 0) and then format the
value before passing to print_success (e.g., round or format to 2 decimal places
with f-string) so print_success(f"Compilation complete (waited {formatted}s)")
always receives a sane string; keep references to result, waited, and
print_success.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agents sleep after script changes

1 participant