Skip to content

Conversation

dsarno
Copy link
Collaborator

@dsarno dsarno commented Sep 2, 2025

Stabilizes script auto-reload on Windows by forcing import/compile after edits, debouncing reliably, and hardening path handling and writes. Behavior on macOS remains unchanged.

Key changes:

  • Force synchronous AssetDatabase.ImportAsset + CompilationPipeline.RequestScriptCompilation after edits
  • Debounced refresh uses ImportAsset (not Refresh) and nudges the editor tick
  • Sanitize Assets/ paths and slashes for consistent imports
  • Atomic writes with File.Replace/Copy fallbacks to ensure file watchers fire on Windows

Verification:

  • Edit any script and confirm domain reload via [DomainReloadLogger] before/after messages
  • Confirm no regressions on macOS; reload timing on Windows is now consistent

Summary by CodeRabbit

  • New Features

    • Added a public helper to normalize asset paths, improving consistency across import workflows.
  • Bug Fixes

    • Ensures editor updates continue even when the Unity window is unfocused.
    • Improves reliability of asset import and compile by using sanitized asset paths, preventing duplicated or malformed paths.
  • Chores

    • Updated embedded server version to 3.2.0.

…ous ImportAsset and RequestScriptCompilation\n- Debounced refresh calls ImportAsset instead of Refresh\n- Path sanitation for Assets/ and slashes\n- Atomic writes with Windows-safe fallbacks\n- Nudge Editor tick for debounce reliability
Copy link
Contributor

coderabbitai bot commented Sep 2, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds asset path sanitization via ManageScriptRefreshHelpers.SanitizeAssetsPath and routes schedule/import flows through it. Updates AssetDatabase.ImportAsset flags to ForceUpdate | ForceSynchronousImport. Invokes EditorApplication.QueuePlayerLoopUpdate in Schedule to trigger ticks when unfocused. Public helper added. Server version bumped from 3.1.1 to 3.2.0.

Changes

Cohort / File(s) Summary
Editor tooling: script management and refresh
UnityMcpBridge/Editor/Tools/ManageScript.cs
Added ManageScriptRefreshHelpers.SanitizeAssetsPath; updated ScheduleScriptRefresh and ImportAndRequestCompile to sanitize paths; switched ImportAsset to ForceUpdate
Server version bump
UnityMcpBridge/UnityMcpServer~/src/server_version.txt
Updated version string from 3.1.1 to 3.2.0.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller
  participant MS as ManageScript
  participant H as ManageScriptRefreshHelpers
  participant ED as EditorApplication
  participant AD as AssetDatabase

  rect rgba(230,245,255,0.5)
    note over Caller,MS: ScheduleScriptRefresh flow (updated)
    Caller->>MS: ScheduleScriptRefresh(path)
    MS->>H: SanitizeAssetsPath(path)
    H-->>MS: sanitizedPath
    MS->>ED: QueuePlayerLoopUpdate()  %% new nudge
    MS-->>Caller: Scheduled (debounced)
  end

  rect rgba(240,255,230,0.5)
    note over Caller,AD: Import and compile flow (updated)
    Caller->>MS: ImportAndRequestCompile(path)
    MS->>H: SanitizeAssetsPath(path)
    H-->>MS: sanitizedPath
    MS->>AD: ImportAsset(sanitizedPath, ForceUpdate|ForceSynchronousImport)
    AD-->>MS: Import complete
    MS-->>Caller: Compile requested
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I thump my paws—refresh in flight,
Paths made neat, from slash to light.
A nudge to loops when screens go dim,
Imports march in synchronous trim.
Version hops to three-dot-two—
Carrot raised: “Clean builds anew!” 🥕


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 35e7d89 and 8c2b4a2.

📒 Files selected for processing (2)
  • UnityMcpBridge/Editor/Tools/ManageScript.cs (3 hunks)
  • UnityMcpBridge/UnityMcpServer~/src/server_version.txt (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@dsarno dsarno merged commit b22f3e3 into CoplayDev:main Sep 2, 2025
1 check was pending
@dsarno dsarno deleted the fix/windows-auto-reload-managescript branch September 5, 2025 22:44
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.

1 participant