chore: Application layer no longer reads Unity editor state directly#1528
Conversation
Application code read EditorApplication directly in three places: the editor state snapshot subscription, the execution state guard, and busy-exception construction. Introduce IEditorRuntimeStatePort in Application with an Infrastructure implementation, move the EditorApplication.update/playModeStateChanged subscription behind the boundary, and add a source-scan guard test that keeps the Application layer free of UnityEditor references.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (5)
📒 Files selected for processing (17)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughIntroduces ChangesIEditorRuntimeStatePort introduction
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant EditorApplication
participant EditorRuntimeStateSnapshotSubscriber
participant UnityCliLoopEditorStateSnapshot
participant UnityCliLoopToolExecutionService
participant UnityCliLoopEditorStateGuard
participant EditorRuntimeStateService
EditorApplication->>EditorRuntimeStateSnapshotSubscriber: update / playModeStateChanged
EditorRuntimeStateSnapshotSubscriber->>UnityCliLoopEditorStateSnapshot: SetPlayState(isPlaying, isPaused)
UnityCliLoopToolExecutionService->>UnityCliLoopEditorStateGuard: Validate(toolName, editorRuntimeStatePort)
UnityCliLoopEditorStateGuard->>EditorRuntimeStateService: IsCompiling / IsUpdating / IsPlaying / IsPaused
EditorRuntimeStateService->>EditorApplication: read live state
UnityCliLoopEditorStateGuard-->>UnityCliLoopToolExecutionService: throw UnityCliLoopToolBusyException or allow
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Summary
UnityEditorAPIs. Editor runtime state (compiling / updating / playing / paused) now flows through anIEditorRuntimeStatePortowned by Application and implemented in Infrastructure, following the same pattern as the CLI pin reader port (chore: CLI pin reading now goes through an injectable boundary instead of static file IO #1527).User Impact
Changes
IEditorRuntimeStatePort(Application) +EditorRuntimeStateService(Infrastructure) readingEditorApplicationstate.EditorApplication.update/playModeStateChangedsubscription moved from the Application-side snapshot into an Infrastructure subscriber, initialized at the same bootstrap position.UnityCliLoopEditorStateGuard.ValidateForStatenow receives all four state booleans explicitly (named arguments at every call site) instead of reading two of them fromEditorApplicationinside its throw branches.UnityCliLoopToolExecutionServicetakes the port via constructor injection from the composition root.ApplicationSources_WhenLoaded_DoNotReferenceUnityEditorpins the Application layer as UnityEditor-free (no compiler-level gate exists for UnityEditor usage).Verification
dist/darwin-arm64/uloop compile: 0 errors, 0 warningsuloop run-tests(state guard, tool execution service, onion dependency, JSON-RPC version gate, tool registry, tool settings suites): 135/135 passedgrep -rn "UnityEditor" Packages/src/Editor/Application/: zero matches