Repository navigation
fix: Unity no longer pauses on external change dialogs after focus return - #1447
Conversation
Hold Unity Auto Refresh while the editor is unfocused, then save dirty editor state and resolve clean external Scene or Prefab Stage changes before refresh resumes. This keeps common Git restore and checkout workflows from blocking on Unity confirmation dialogs.
Keep active Auto Refresh holds in place during normal command initialization, and avoid reopening a Prefab Stage when dirty prefab state could not be saved.
Domain reload can reinitialize the focus-return guard while the editor is still in the background. Release a persisted Auto Refresh hold only when the editor is focused so later filesystem changes still wait for the focus-return preflight.
Focus-return handling intentionally persists Unity's in-memory editor state before refresh so source-control file replacement cannot trigger external reload dialogs.
Reopen externally changed Prefab Stages with the original opened instance and mode so focus-return refresh keeps in-context editing state intact.
|
Warning Review limit reached
Next review available in: 3 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR extends ChangesFocus-return resolution and Auto Refresh coordination
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Editor
participant ExternalAssetFocusReturnService
participant ExternalSceneChangeTracker
participant PrefabStage
participant AssetDatabase
Editor->>ExternalAssetFocusReturnService: focus lost
ExternalAssetFocusReturnService->>ExternalAssetFocusReturnService: disallow Auto Refresh, store hold
Editor->>ExternalAssetFocusReturnService: focus regained
ExternalAssetFocusReturnService->>ExternalSceneChangeTracker: ResolveForFocusReturn (try)
ExternalSceneChangeTracker->>ExternalSceneChangeTracker: save dirty/restore missing Scenes and Prefab Stage
ExternalSceneChangeTracker->>PrefabStage: compare current vs stored fingerprints
ExternalSceneChangeTracker->>AssetDatabase: reimport mismatched prefab asset
ExternalSceneChangeTracker->>PrefabStage: reopen Prefab Stage
ExternalSceneChangeTracker->>ExternalSceneChangeTracker: record updated snapshot
ExternalAssetFocusReturnService->>ExternalAssetFocusReturnService: release hold, allow Auto Refresh (finally)
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 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 |
Persist tracked asset fingerprints across editor domain reloads so focus-return preflight can still detect external Scene and Prefab changes. Also validate Prefab Stage reopen inputs before calling Unity APIs that throw for invalid or missing Prefab assets.
Remove the README additions for the focus-return behavior so the PR keeps the documentation unchanged.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
Assets/Tests/Editor/ExternalSceneChangeResolverTests.cs (1)
299-320: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider asserting full fingerprint fields for the missing-scene entry too.
The round-trip test only checks
ExistsforMissingScenePath; assertingLastWriteTimeUtc/Lengthas well would give stronger regression coverage for the serialization format.Suggested addition
Assert.That(restored[MissingScenePath].Exists, Is.False); + Assert.That(restored[MissingScenePath].LastWriteTimeUtc, Is.EqualTo(DateTime.MinValue)); + Assert.That(restored[MissingScenePath].Length, Is.EqualTo(0));🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Assets/Tests/Editor/ExternalSceneChangeResolverTests.cs` around lines 299 - 320, The round-trip test in ExternalSceneChangeResolverTests only verifies the Exists flag for the missing-scene snapshot, so extend SnapshotSessionStore_WhenSnapshotsRoundTrip_PreservesFingerprints to also assert the restored LastWriteTimeUtc and Length for MissingScenePath. Use ExternalAssetSnapshotSessionStore.SerializeSnapshots/RestoreSnapshots and the MissingScenePath entry to confirm the full fingerprint survives JSON storage.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@Assets/Tests/Editor/ExternalSceneChangeResolverTests.cs`:
- Around line 299-320: The round-trip test in ExternalSceneChangeResolverTests
only verifies the Exists flag for the missing-scene snapshot, so extend
SnapshotSessionStore_WhenSnapshotsRoundTrip_PreservesFingerprints to also assert
the restored LastWriteTimeUtc and Length for MissingScenePath. Use
ExternalAssetSnapshotSessionStore.SerializeSnapshots/RestoreSnapshots and the
MissingScenePath entry to confirm the full fingerprint survives JSON storage.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 0da70e09-e96e-464f-ae5b-be4d2f597a2d
📒 Files selected for processing (2)
Assets/Tests/Editor/ExternalSceneChangeResolverTests.csPackages/src/Editor/FirstPartyTools/Compile/ExternalSceneChangeResolver.cs
🚧 Files skipped from review as they are similar to previous changes (1)
- Packages/src/Editor/FirstPartyTools/Compile/ExternalSceneChangeResolver.cs
There was a problem hiding this comment.
1 issue found across 4 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Do not advance Prefab Stage baselines when reopening fails, because the editor can still be showing the previous Prefab contents. Also skip initial snapshot recording after held Auto Refresh recovery has already run preflight, and batch Scene snapshot persistence inside focus-return save loops.
Summary
User Impact
Changes
Verification
cli/dist/darwin-arm64/uloop compile --project-path "$(git rev-parse --show-toplevel)"-> success, 0 errors, 0 warningscli/dist/darwin-arm64/uloop run-tests --project-path "$(git rev-parse --show-toplevel)" --test-mode EditMode --filter-type regex --filter-value "ExternalSceneChangeResolverTests"-> 16 passedcli/dist/darwin-arm64/uloop run-tests --project-path "$(git rev-parse --show-toplevel)" --test-mode EditMode --filter-type regex --filter-value "TestExecutionStateValidationServiceTests"-> 8 passedautoreview --mode branch --base origin/v3-beta --prompt "<autosave requirement>"-> clean, no accepted/actionable findings/review 1447via cmux -> accepted findings addressed