Skip to content

chore: simplify external Scene change handling - #1639

Merged
hatayama merged 2 commits into
v3-betafrom
refactor/hatayama/split-external-scene-change-resolver
Jul 8, 2026
Merged

hatayama merged 2 commits into
v3-betafrom
refactor/hatayama/split-external-scene-change-resolver

Conversation

@hatayama

@hatayama hatayama commented Jul 8, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Give each external Scene change responsibility explicit production file ownership.
  • Use one shared file-state comparison contract for compile and Prefab focus-return decisions.

User Impact

  • There is no intended user-visible behavior change.
  • External Scene reload policy, focus-return handling, snapshot persistence, messages, and cleanup ordering remain unchanged.

Changes

  • Keep ExternalSceneChangeResolver in its existing matching file.
  • Move ExternalSceneChangeTracker, ExternalAssetSnapshotSessionStore, and ExternalAssetFocusReturnService unchanged into matching files.
  • Add ExternalAssetFileStateComparer and replace the two byte-identical private comparison methods with direct calls.
  • Preserve the existing (Exists, LastWriteTimeUtc, Length) tuple shape instead of introducing a broader fingerprint data-model migration.

Verification

  • Passed the existing resolver fixture before editing (16/16).
  • Compared all four moved class bodies against the base revision; each class body was byte-identical after the file split.
  • Confirmed the new comparer tests fail before implementation with four CS0103 errors, then pass after implementation (4/4).
  • Passed the combined comparer and resolver tests (20/20).
  • Passed the related comparer, resolver, compile use case, architecture, and static facade guard fixtures (124/124).
  • Compiled the Unity package with 0 errors and 0 warnings.

Compatibility

  • SessionState keys, serialized snapshot JSON fields, event subscriptions, mutable static state ownership, visibility, messages, and comparison short-circuit order are unchanged.
  • No IPC request or response shape changed, so the protocol version remains unchanged.

Review in cubic

hatayama added 2 commits July 9, 2026 07:05
Give the tracker, snapshot session store, focus-return coordinator, and compile resolver explicit file ownership while preserving every class body, visibility, event hook, and mutable state owner.
Use one stateless comparer for Scene and Prefab fingerprint identity so both reload paths share the same existence, timestamp, and length contract. Cover each comparison field independently to prevent future drift.
@coderabbitai

coderabbitai Bot commented Jul 8, 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: bf225af6-490c-4170-91bf-b4621ee84d13

📥 Commits

Reviewing files that changed from the base of the PR and between 37b9f5d and 1f530a6.

⛔ Files ignored due to path filters (5)
  • Assets/Tests/Editor/ExternalAssetFileStateComparerTests.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/Compile/ExternalAssetFileStateComparer.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/Compile/ExternalAssetFocusReturnService.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/Compile/ExternalAssetSnapshotSessionStore.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/Compile/ExternalSceneChangeTracker.cs.meta is excluded by none and included by none
📒 Files selected for processing (6)
  • Assets/Tests/Editor/ExternalAssetFileStateComparerTests.cs
  • Packages/src/Editor/FirstPartyTools/Compile/ExternalAssetFileStateComparer.cs
  • Packages/src/Editor/FirstPartyTools/Compile/ExternalAssetFocusReturnService.cs
  • Packages/src/Editor/FirstPartyTools/Compile/ExternalAssetSnapshotSessionStore.cs
  • Packages/src/Editor/FirstPartyTools/Compile/ExternalSceneChangeResolver.cs
  • Packages/src/Editor/FirstPartyTools/Compile/ExternalSceneChangeTracker.cs

📝 Walkthrough

Walkthrough

Introduces a shared ExternalAssetFileStateComparer for fingerprint equality checks, new ExternalAssetFocusReturnService and ExternalAssetSnapshotSessionStore utilities, and a new ExternalSceneChangeTracker that persists scene/Prefab fingerprints across domain reloads and resolves external changes on compile and editor focus return. Updates ExternalSceneChangeResolver to use the shared comparer.

Changes

External asset change tracking

Layer / File(s) Summary
Shared file-state comparer and tests
Packages/src/Editor/FirstPartyTools/Compile/ExternalAssetFileStateComparer.cs, Assets/Tests/Editor/ExternalAssetFileStateComparerTests.cs, Packages/src/Editor/FirstPartyTools/Compile/ExternalSceneChangeResolver.cs
Adds HasSameFileState comparing Exists/LastWriteTimeUtc/Length, unit tests covering match and mismatch cases, and updates the resolver to delegate to it instead of a removed local helper.
Focus-return service and snapshot session store
Packages/src/Editor/FirstPartyTools/Compile/ExternalAssetFocusReturnService.cs, Packages/src/Editor/FirstPartyTools/Compile/ExternalAssetSnapshotSessionStore.cs
Adds a delegate-driven service that holds/restores auto-refresh state based on editor focus, and a JSON-based session store for serializing/deserializing snapshot dictionaries.
Tracker initialization and compile resolution
Packages/src/Editor/FirstPartyTools/Compile/ExternalSceneChangeTracker.cs
Adds Initialize() to restore snapshots and register scene/Prefab Stage/focus event handlers, and ResolveForCompile() to resolve external Scene changes and persist updated snapshots.
Focus-return resolution and prefab reopen
Packages/src/Editor/FirstPartyTools/Compile/ExternalSceneChangeTracker.cs
Saves dirty/missing scenes and Prefab Stage, resolves external Scene/Prefab changes, reimports and reopens changed prefabs with instance-aware reopen context, and logs failures.
Fingerprinting and persistence helpers
Packages/src/Editor/FirstPartyTools/Compile/ExternalSceneChangeTracker.cs
Adds snapshot recording, trackability checks, fingerprint reading, scene setup reload, resolver construction, SessionState persistence, and path normalization/display/logging utilities.

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

Possibly related PRs

  • hatayama/unity-cli-loop#1447: Introduces ExternalSceneChangeResolverTests covering ExternalAssetFileStateComparer, ExternalAssetFocusReturnService, and ExternalAssetSnapshotSessionStore that are directly used by this PR.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title concisely matches the main change: simplifying external Scene change handling.
Description check ✅ Passed The description is clearly related to the code changes and summarizes the split and shared comparer.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 refactor/hatayama/split-external-scene-change-resolver

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 b47a227 into v3-beta Jul 8, 2026
10 checks passed
@hatayama
hatayama deleted the refactor/hatayama/split-external-scene-change-resolver branch July 8, 2026 22:17
RyanXie123 pushed a commit to RyanXie123/unity-cli-loop that referenced this pull request Sep 22, 2026
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