Skip to content

chore: Keep Compile editor sources under 500 lines - #1784

Merged
hatayama merged 6 commits into
feature/god-class-split-integrationfrom
feat/split-compile-controllers
Jul 14, 2026
Merged

hatayama merged 6 commits into
feature/god-class-split-integrationfrom
feat/split-compile-controllers

Conversation

@hatayama

@hatayama hatayama commented Jul 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Split ExternalSceneChangeTracker, CompileController, and AssemblyDefinitionConsoleErrorValidationService so each implementation file stays under 500 lines without changing compile lifecycle behavior.
  • Characterization tests were committed before each Extract Class move, including delegate-injected recovery decisions for CompileController.

User Impact

  • No user-facing behavior change for compile, external scene/prefab tracking, or asmdef console-error validation.
  • Compile lifecycle watchdog recovery, TaskCompletionSource handling, and SwitchToMainThread positioning are preserved.

Changes

  • AssemblyDefinitionConsoleErrorValidationService → service + message formatter / error DTOs
  • ExternalSceneChangeTracker → tracker + ExternalPrefabStageChangeTracker
  • CompileController → controller + CompileLifecycleRecoveryCoordinator (Watchdog-style delegate injection)

Verification

  • uloop compile ×2 → 0/0 both times
  • All target + extracted files < 500 lines
  • EditMode Compile|ExternalScene|AssemblyDefinition → 215 passed
  • dotnet test tests/UnityCliLoop.CodeComplexity.Tests → 12 passed

Made with Cursor

Review in cubic

hatayama and others added 6 commits July 14, 2026 18:35
…ssage formatting

Pin CreateFailureMessage and AssemblyDefinitionConsoleErrorResult.Message
behavior (file-prefixed listing, no-file fallback, ten-issue display cap)
before extracting this pure logic into its own class.

Co-authored-by: Cursor <cursoragent@cursor.com>
…500-line-clean files

Extract Class: move the AssemblyDefinitionConsoleError/Result DTOs into
their own files and move the pure CreateFailureMessage formatting into
AssemblyDefinitionConsoleErrorMessageFormatter, separating message
formatting from Console error detection. No behavior change; the
characterization tests added in the previous commit stay green.

Co-authored-by: Cursor <cursoragent@cursor.com>
Parameterize BuildFingerprintDiffContexts over an injected snapshot
dictionary and fingerprint reader instead of closing over static
tracker state, then pin its unchanged/changed/no-snapshot behavior
with tests. This prepares the pure logic for extraction into its own
class without altering ResolveForFocusReturn's observed behavior.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ChangeTracker

Extract Class: move all Prefab Stage snapshot tracking (event
registration, save/reload, focus-return resolution, reopen-context
decision) into its own tracker, mirroring the existing Scene tracking
responsibility split. ExternalSceneChangeTracker keeps Scene tracking
and delegates Prefab Stage concerns to the new class; shared
fingerprint/path/logging helpers are now internal so both classes can
share them without behavior change.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ions

Introduce CompileLifecycleRecoveryCoordinator (delegate-injected, mirroring
the CompileLifecycleWatchdog pattern) so start-timeout and missed-callback
recovery decisions are pure-C# testable without running real Unity
compilation. Pin the existing IsCurrentCompileRequest/CreateStoppedWithoutFinishResult
behavior plus new characterization tests for HandleCompileStartTimeout and
HandleCompileStoppedWithoutFinishEvent branching (assembly definition errors,
duplicate asmdef names, generic fallback) before extracting this class into
its own file.

Co-authored-by: Cursor <cursoragent@cursor.com>
…troller

Move the delegate-injected recovery coordinator (start-timeout handling,
missed-callback handling, watchdog fault recovery) into its own file so
CompileController.cs drops from 619 to 482 lines. No behavior change; the
watchdog lifecycle, TaskCompletionSource semantics, and MainThreadSwitcher/
ConfigureAwait(false) call sites in TryCompileAsync are untouched, and the
characterization tests added in the previous commit stay green.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fc0c674b-5783-42f6-880f-e0dac7f1577a

📥 Commits

Reviewing files that changed from the base of the PR and between 55a2640 and f1a87ef.

⛔ Files ignored due to path filters (6)
  • Assets/Tests/Editor/CompileLifecycleRecoveryCoordinatorTests.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/Compile/AssemblyDefinitionConsoleError.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/Compile/AssemblyDefinitionConsoleErrorMessageFormatter.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/Compile/AssemblyDefinitionConsoleErrorResult.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/Compile/CompileLifecycleRecoveryCoordinator.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/Compile/ExternalPrefabStageChangeTracker.cs.meta is excluded by none and included by none
📒 Files selected for processing (12)
  • Assets/Tests/Editor/AssemblyDefinitionConsoleErrorValidationServiceTests.cs
  • Assets/Tests/Editor/CompileLifecycleRecoveryCoordinatorTests.cs
  • Assets/Tests/Editor/CompileLifecycleWatchdogTests.cs
  • Assets/Tests/Editor/ExternalSceneChangeResolverTests.cs
  • Packages/src/Editor/FirstPartyTools/Compile/AssemblyDefinitionConsoleError.cs
  • Packages/src/Editor/FirstPartyTools/Compile/AssemblyDefinitionConsoleErrorMessageFormatter.cs
  • Packages/src/Editor/FirstPartyTools/Compile/AssemblyDefinitionConsoleErrorResult.cs
  • Packages/src/Editor/FirstPartyTools/Compile/AssemblyDefinitionConsoleErrorValidationService.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompileController.cs
  • Packages/src/Editor/FirstPartyTools/Compile/CompileLifecycleRecoveryCoordinator.cs
  • Packages/src/Editor/FirstPartyTools/Compile/ExternalPrefabStageChangeTracker.cs
  • Packages/src/Editor/FirstPartyTools/Compile/ExternalSceneChangeTracker.cs
💤 Files with no reviewable changes (1)
  • Packages/src/Editor/FirstPartyTools/Compile/AssemblyDefinitionConsoleErrorValidationService.cs

📝 Walkthrough

Walkthrough

The PR extracts Prefab Stage change tracking into a dedicated utility, adds compile lifecycle recovery coordination, and separates assembly-definition console error contracts and formatting. Tests cover recovery outcomes, error messages, request identity checks, Prefab Stage reopen contexts, and fingerprint differences.

Changes

Compile recovery and assembly-definition errors

Layer / File(s) Summary
Assembly-definition error contract and formatting
Packages/src/Editor/FirstPartyTools/Compile/AssemblyDefinitionConsoleError.cs, Packages/src/Editor/FirstPartyTools/Compile/AssemblyDefinitionConsoleErrorMessageFormatter.cs, Packages/src/Editor/FirstPartyTools/Compile/AssemblyDefinitionConsoleErrorResult.cs, Packages/src/Editor/FirstPartyTools/Compile/AssemblyDefinitionConsoleErrorValidationService.cs, Assets/Tests/Editor/AssemblyDefinitionConsoleErrorValidationServiceTests.cs
Assembly-definition errors, results, and failure-message formatting are separated into dedicated types and covered by formatting and empty-result tests.
Compile watchdog recovery orchestration
Packages/src/Editor/FirstPartyTools/Compile/CompileLifecycleRecoveryCoordinator.cs, Packages/src/Editor/FirstPartyTools/Compile/CompileController.cs
CompileController delegates watchdog handling to CompileLifecycleRecoveryCoordinator, which handles stale requests, start timeouts, watchdog faults, and missing finish events.
Recovery behavior validation
Assets/Tests/Editor/CompileLifecycleRecoveryCoordinatorTests.cs, Assets/Tests/Editor/CompileLifecycleWatchdogTests.cs
Tests cover assembly-definition, duplicate-name, generic timeout, stopped-without-finish, and current-request recovery behavior.

Prefab Stage external change tracking

Layer / File(s) Summary
Prefab Stage snapshot and recovery flow
Packages/src/Editor/FirstPartyTools/Compile/ExternalPrefabStageChangeTracker.cs
The new tracker manages Prefab Stage fingerprints, session persistence, save handling, external-change detection, and stage reopening.
Scene tracker delegation and fingerprint diffs
Packages/src/Editor/FirstPartyTools/Compile/ExternalSceneChangeTracker.cs
Scene tracking delegates Prefab Stage operations to the new tracker while using explicit snapshot and fingerprint inputs for scene diff reporting.
Prefab Stage and fingerprint-diff tests
Assets/Tests/Editor/ExternalSceneChangeResolverTests.cs
Tests update reopen-context calls and verify missing, matching, and changed fingerprint scenarios.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% 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 summarizes the main change: keeping compile editor sources under 500 lines by splitting them up.
Description check ✅ Passed The description is clearly related to the changeset and matches the extraction-focused refactor described in the diffs.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/split-compile-controllers

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.

@hatayama
hatayama merged commit 03b532d into feature/god-class-split-integration Jul 14, 2026
2 checks passed
@hatayama
hatayama deleted the feat/split-compile-controllers branch July 14, 2026 10:18
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