Skip to content

v1.3.1

Choose a tag to compare

@niqibiao niqibiao released this 16 Apr 06:03
· 74 commits to main since this release

What's New in v1.3.1

Refresh System Overhaul

The cs refresh command has been completely reworked to fix compilation reliability issues and add targeted import support.

Two-Mode Refresh

Mode Usage How it works
Targeted cs refresh --files Assets/Scripts/Foo.cs Packages/com.xxx/Bar.cs ImportAsset each file directly — no scanning, works for any path
Full cs refresh (no --files) Activates Unity window (flushes file watcher) then AssetDatabase.Refresh() handles everything

Targeted mode is ideal for agent workflows where the caller knows exactly which files changed. It is O(N) where N = number of changed files, regardless of project size.

Full mode now uses SetForegroundWindow (Windows P/Invoke) to bring Unity to the foreground before calling Refresh(). This ensures the OS file-watcher queue is flushed, making Refresh() reliable even when Unity runs in the background.

Root Causes Fixed (C# Package Side)

These fixes are in com.zh1zh1.csharpconsole v1.3.1, consumed by this plugin:

Issue Cause Fix
Refresh misses external changes when Unity is in background OS file-watcher queue not flushed ActivateEditorWindow via SetForegroundWindow P/Invoke
ImportAsset(ForceUpdate) does not trigger compilation Import is deferred, RequestScriptCompilation compiles stale code Changed to ForceUpdate + ForceSynchronousImport
EditorApplication.delayCall unreliable from HTTP thread TriggerRefresh callback silently lost Use MainThreadRequestRunner.Post thread-safe dispatcher
Refresh resets ImportAsset cache Calling both in the same frame undoes the import Separated into two modes: targeted (ImportAsset only) vs full (Refresh only)
Grace period race condition OnEditorUpdate used stale timestamp after domain reload Separate Requested/RefreshingAssets phase handling with DateTimeOffset.UtcNow.Ticks

--wait Timeout

  • Cap raised from 300s to 600s (10 minutes) to accommodate large projects with long compilation times
  • Default in /unity-cli-refresh slash command raised from 60s to 120s
  • The C# state machine has no compilation timeout — it waits indefinitely for isCompiling to finish

Setup UX Improvements

  • Local setup always checks for updates: cs setup --method local now runs git pull --ff-only every time instead of silently returning "Already installed"
  • Version alignment check on setup: Both local and git methods now compare plugin vs package version after confirming installation. Prints ⚠ version mismatch when misaligned
  • Slash commands offer immediate action: /unity-cli-setup and /unity-cli-status now directly ask whether to update when a version mismatch is detected, instead of passively reporting it

Port Management

  • Constants extracted: DEFAULT_EDITOR_PORT = 14500, DEFAULT_RUNTIME_PORT = 15500 centralized in cli/init.py
  • Auto-detection: Reads Temp/CSharpConsole/refresh_state.json to discover the actual editor port (supports dynamic port allocation)
  • Runtime mode fix: compile_ip/compile_port now correctly route refresh/compile operations to the editor service when --mode runtime

Connection Reliability

  • Broader error handling: Retry logic now catches OSError (stdlib base class) instead of just ConnectionRefusedError, covering all socket-level failures including those from bundled requests library
  • TOCTOU fix: detect_port() no longer does redundant exists() check before read_text() — eliminated race condition
  • Deferred port detection: detect_port() only reads disk when the result is actually needed

Command Catalog Update

9 new prefab asset commands added to SKILL.md (total: 46 to 59 commands):

Command Description
prefab/asset_hierarchy Get hierarchy tree of a prefab asset
prefab/asset_get Get GameObject info in a prefab asset
prefab/asset_get_component Get serialized properties of a component
prefab/asset_modify_component Modify component fields with auto-save
prefab/asset_add_component Add a component to a prefab GameObject
prefab/asset_remove_component Remove a component by type and index
prefab/asset_add_gameobject Add a child GameObject
prefab/asset_modify_gameobject Modify GO properties (name, tag, layer, active, isStatic)
prefab/asset_remove_gameobject Remove a child GameObject

Housekeeping

  • Removed completed design docs from git history (docs directory purged via git filter-repo)
  • .gitignore now excludes docs directory

Companion Package

Requires com.zh1zh1.csharpconsole v1.3.1 for the refresh reliability fixes.

Full changelog: v1.2.0...v1.3.1