Repository navigation
v0.3.88 — No more silent Safe Mode waits; scenarios with optional steps
Why this matters
When a script change broke compilation and the editor was opened afterwards, ensure-ready waited out its whole timeout on Unity's "Enter Safe Mode?" dialog and then suggested polling again. In one session that took 900 s, while status_summary already knew the editor was stuck on the dialog. A recovery after a frozen heartbeat could also close a live editor without a save prompt.
Scenarios had their own false failures:
- a best-effort "close the popup if it is there" click failed the whole run when there was nothing to close;
- a click that opened a popup a few frames later read as "no effect";
- a
project_refreshright after a hook that changed scripting defines always timed out.
What changed
Editor startup and compile state
- The startup wait stops on the dialog.
ensure-readyrecognises the "Enter Safe Mode?" dialog while it waits, using the same signs asstatus_summary: a live editor, compile errors written during the wait, no bridge, and an Editor.log that has been quiet for 20 s. It then ends aseditor_startup_modal_blocked, with the compiler error line and a recovery command: quit, batch compile, reopen. A log that is still moving, or a bridge that attaches, keeps the wait going. - A closed editor is not opened on red code. The package now saves a snapshot of the compile inputs and the last compile result. With the editor closed,
ensure-ready --open-editorandrecover-editor-sessioncompare the current files with that snapshot. If the code changed or the last compile failed, they run a batch compile first and refuse to open the editor when it is red (editor_open_refused_compile_red). A touched file whose content did not change opens without the probe. Pass--compile-preflight offto skip it. status_summaryno longer shows a false zero. Without a live bridge, it no longer showscompiler_error_count: 0beside an Editor.log full of errors. It reportscompile_state: unmeasuredand lists the errors seen in the log as an observation, never as a compiler count.- The compile gate notices a fix in another file. It now sees fixes in any compile input, not only in the file named in the error.
- A live editor is never closed by recovery without permission.
recover-editor-sessioncloses a live editor only with--force-terminate. - A dead editor's old state no longer reads as healthy.
unity_ensure_readybrings the same command to the MCP surface.
Scenarios
- Optional steps. Scenario
ui_click,ui_existsandui_get_texttakeoptional: true. Suppose an optional click is refused before delivery because the target is missing, hidden or covered, or a read step's complete search finds nothing. The step then becomesskipped_optional_absentand the run can still pass. Every other failure still fails. - Waiting for a delayed change.
waitForTreeChangeMsonunity_ui_clickand the scenarioui_clickstep keeps checking the UI on later editor frames, so a popup that appears a few frames after the click counts. - Refresh after a define-changing hook settles. The domain reload used to drop the refresh's request id, so the step waited for an id that no longer existed. It now settles once the editor is idle after the reload.
- The decision verdict keeps the right failure label. It no longer relabels a failed run as
playmode_throttledbecause an earlier Play Mode step was throttled. - The compact
unity_scenario_run_and_waitresult is smaller. It lists only failed and skipped-optional steps and counts the rest. A 20-step passing run dropped from about 13 KB to about 2 KB.
What this gives developers
- A broken compile at editor startup surfaces in seconds with the error line and the next command, instead of a long silent wait.
- Opening a closed project on code that does not compile is refused before Unity reaches the Safe Mode dialog.
- Scenarios can dismiss popups "if present" without turning every run red, and asynchronous popups no longer need
expectStateChange: falseas a workaround. - Smaller scenario results on the default path.
Validation
- Host Python suite: 1386 tests passed, 14 platform skips.
- Package self-tests in clean generated projects, package from local source, macOS:
- on Unity 2021.3.58f1, 2022.3.62f3, 6000.0.58f2, 6000.1.13f1, 6000.2.14f1, 6000.3.23f1, 6000.4.4f1, 6000.5.10f1 and 6000.6.0b3: EditMode core 229/229 and PlayMode core 6/6;
- on 2021.3.58f1 also TextMeshPro 6/6, uGUI 69/69, and PlayMode uGUI with 22 passed and 6 skipped.
- The first 2021.3.58f1 run failed one new uGUI test. That was a test-loop issue with Test Framework 1.1; the test was fixed and the rerun passed.
- Safe Mode wait, live on Unity 6000.0.58f2 with a script that did not compile and the editor closed:
- with
--compile-preflight off, the wait ended aseditor_startup_modal_blockedafter 25 s (38 s on a larger project, where the previous version waited 900 s); - with the preflight on, the open was refused after 5 s and no editor started;
- after the error was removed, the editor opened healthy.
- with
- Scenario refresh after a define-changing hook, live on Unity 6000.0.58f2 with the editor unfocused: before the fix, 4 of 4 runs timed out; after it, 3 of 3 settled in about 3.5 s.
Known limitations
Unity Package CIremains waived (no runner Unity license); the local licensed runs above are the package evidence.- Live Unity runs were on macOS only. Windows and Linux are covered by host tests and CI.
- The closed-editor preflight needs the snapshot written by this package version. The first
ensure-readyafter upgrading a project opens without it. - An editor that was already stuck on a dialog before
ensure-readystarted is diagnosed bystatus_summary. In that caseensure-readypoints there rather than raisingeditor_startup_modal_blockeditself. - A delivered optional click that fails
expectStateChangestill ends the run asinconclusive. - Optional steps and the click wait have not yet been run against a real project's scenarios.