Skip to content

fix: PlayMode start reports compiler errors instead of timing out#1354

Merged
hatayama merged 2 commits into
v3-betafrom
fix/play-mode
Jun 16, 2026
Merged

fix: PlayMode start reports compiler errors instead of timing out#1354
hatayama merged 2 commits into
v3-betafrom
fix/play-mode

Conversation

@hatayama

@hatayama hatayama commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • PlayMode start now fails fast with saved compiler diagnostics when Unity reports script compilation errors.
  • The CLI returns a structured compiler-error envelope instead of waiting until the PlayMode transition times out.

User Impact

  • Before this change, running uloop control-play-mode --action Play with compiler errors could hang until the wait timeout and hide the actual cause.
  • After this change, users immediately see the compiler error count and diagnostics, including errors that appear while the CLI is polling for PlayMode to finish starting.

Changes

  • Record Unity compiler errors from the editor compilation callbacks for the current editor domain.
  • Gate PlayMode start on Unity script-compilation failure state and include saved diagnostics in the tool response.
  • Teach the CLI to turn those responses into CONTROL_PLAY_MODE_COMPILE_ERRORS during both the initial request and polling.

Verification

  • cli/dist/darwin-arm64/uloop compile --project-path "$(git rev-parse --show-toplevel)"
  • cli/dist/darwin-arm64/uloop run-tests --project-path "$(git rev-parse --show-toplevel)" --test-mode EditMode --filter-type regex --filter-value "ControlPlayModeUseCaseTests"
  • go test ./internal/cli -run TestRunControlPlayModeWithStateWait
  • scripts/check-go-cli.sh
  • /Users/a12115/dotfiles/.claude/skills/codex-review/scripts/codex-review v3-beta

Review in cubic

hatayama added 2 commits June 16, 2026 10:09
Use Unity's script compilation failure flag to stop PlayMode entry immediately, and surface the saved compiler diagnostics instead of waiting for the state poll timeout.
Return saved compiler diagnostics from status polling so Play requests that become blocked after the initial command do not fall back to the generic wait timeout.
@coderabbitai

coderabbitai Bot commented Jun 16, 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: ae8c79fb-9af6-485f-aa80-42b1d28eb01c

📥 Commits

Reviewing files that changed from the base of the PR and between 2ee34eb and 3d8933e.

⛔ Files ignored due to path filters (5)
  • Packages/src/Editor/FirstPartyTools/ControlPlayMode/AssemblyInfo.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/ControlPlayMode/ControlPlayModeCompilationFailureService.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/ControlPlayMode/ControlPlayModeCompileError.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/ControlPlayMode/ControlPlayModeEditorStartup.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/ControlPlayMode/ControlPlayModeServices.cs.meta is excluded by none and included by none
📒 Files selected for processing (12)
  • Assets/Tests/Editor/ControlPlayModeUseCaseTests.cs
  • Packages/src/Editor/FirstPartyTools/ControlPlayMode/AssemblyInfo.cs
  • Packages/src/Editor/FirstPartyTools/ControlPlayMode/ControlPlayModeCompilationFailureService.cs
  • Packages/src/Editor/FirstPartyTools/ControlPlayMode/ControlPlayModeCompileError.cs
  • Packages/src/Editor/FirstPartyTools/ControlPlayMode/ControlPlayModeEditorStartup.cs
  • Packages/src/Editor/FirstPartyTools/ControlPlayMode/ControlPlayModeResponse.cs
  • Packages/src/Editor/FirstPartyTools/ControlPlayMode/ControlPlayModeServices.cs
  • Packages/src/Editor/FirstPartyTools/ControlPlayMode/ControlPlayModeUseCase.cs
  • Packages/src/Editor/FirstPartyTools/FirstPartyToolsEditorStartup.cs
  • cli/internal/cli/control_play_mode_wait.go
  • cli/internal/cli/control_play_mode_wait_test.go
  • cli/internal/cli/error_envelope.go

📝 Walkthrough

Walkthrough

Adds compile-error blocking to the play-mode control feature. A new Unity service tracks script compilation failures via pipeline events and snapshots diagnostics. The use case checks compilation state before entering play mode and returns a blocked response with error details. The Go CLI decodes these blocked responses and exits early with a structured error envelope. Tests cover all new paths on both sides.

Changes

Compile-Error Blocking for Control-Play-Mode

Layer / File(s) Summary
Data contracts: compile error DTO, response fields, Go structs, error code
Packages/src/Editor/FirstPartyTools/ControlPlayMode/ControlPlayModeCompileError.cs, Packages/src/Editor/FirstPartyTools/ControlPlayMode/ControlPlayModeResponse.cs, cli/internal/cli/control_play_mode_wait.go, cli/internal/cli/error_envelope.go
ControlPlayModeCompileError sealed class with Message/File/Line and internal factory from CompilerMessage; ControlPlayModeResponse extended with BlockedByCompileErrors, CompileErrorCount, CompileErrors; Go response struct and sub-type mirroring these fields; new errorCodeControlPlayModeCompileErrors constant.
Unity compilation-failure service, registry, and startup wiring
Packages/src/Editor/FirstPartyTools/ControlPlayMode/ControlPlayModeCompilationFailureService.cs, Packages/src/Editor/FirstPartyTools/ControlPlayMode/ControlPlayModeServices.cs, Packages/src/Editor/FirstPartyTools/ControlPlayMode/ControlPlayModeEditorStartup.cs, Packages/src/Editor/FirstPartyTools/ControlPlayMode/AssemblyInfo.cs, Packages/src/Editor/FirstPartyTools/FirstPartyToolsEditorStartup.cs
IControlPlayModeCompilationFailureProvider and IControlPlayModeCompilationFailureGate interfaces; ControlPlayModeCompilationFailureService subscribes to Unity compilation events, records errors, snapshots on failure, and clears on next start/success; ControlPlayModeCompilationFailureGate wraps EditorUtility.scriptCompilationFailed; registry and static facade expose them; ControlPlayModeEditorStartup called from FirstPartyToolsEditorStartup.Initialize(); InternalsVisibleTo added for friend assemblies.
ControlPlayModeUseCase compile-error gating
Packages/src/Editor/FirstPartyTools/ControlPlayMode/ControlPlayModeUseCase.cs
New constructor with optional IControlPlayModeCompilationFailureProvider and IControlPlayModeCompilationFailureGate parameters; compilation-failure guard inserted in StatusOnly=Play and Play action paths; CreateCompileErrorBlockedResponse helper added; CreateResponse initializes CompileErrors to empty array.
Go CLI compile-error detection and early-exit handling
cli/internal/cli/control_play_mode_wait.go
requestControlPlayModeStatus now passes action in payload; initial-response and polling-loop paths check BlockedByCompileErrors and return immediately via controlPlayModeCompileErrorsError; new helper builds cliError with computed count and compile error details.
C# and Go tests
Assets/Tests/Editor/ControlPlayModeUseCaseTests.cs, cli/internal/cli/control_play_mode_wait_test.go
Seven new C# tests covering ControlPlayModeCompilationFailureService event-driven state transitions and ControlPlayModeUseCase blocking scenarios (StatusOnly-Play, StatusOnly-Stop, Play with/without saved snapshot), with stub provider/gate helpers; two new Go tests simulate immediate block and mid-poll block, validating exit code, error code, and diagnostics content.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • hatayama/unity-cli-loop#1312: Modifies runControlPlayModeWithStateWait in the same control_play_mode_wait.go file, adjusting spinner progress callback wiring in the function this PR also extends.
  • hatayama/unity-cli-loop#1300: Extends ControlPlayModeResponse and ControlPlayModeUseCase/control_play_mode_wait.go response construction, the same files this PR modifies to add compile-error blocking fields.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.52% 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 'fix: PlayMode start reports compiler errors instead of timing out' directly and clearly describes the main change: fixing PlayMode startup to immediately report compiler errors rather than timing out.
Description check ✅ Passed The description provides a comprehensive summary of changes related to the changeset, covering the problem (PlayMode start hanging on compiler errors), the solution (fast failure with diagnostics), and the verification approach.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 fix/play-mode

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 and usage tips.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 17 files

Re-trigger cubic

@hatayama
hatayama merged commit 69804cd into v3-beta Jun 16, 2026
9 checks passed
@hatayama
hatayama deleted the fix/play-mode branch June 16, 2026 02:54
@github-actions github-actions Bot mentioned this pull request Jun 16, 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