Skip to content

Move editor-only runtime state to Unity SessionState #1163

@qua-hatayama

Description

@qua-hatayama

Summary

Move editor-only runtime and reload flags out of the persistent UserSettings JSON and into Unity SessionState.

server-state.json must stay unchanged because the native Go CLI reads it as the external readiness contract.

Motivation

Several current flags are only meaningful inside the current Unity Editor session or across a Domain Reload. Persisting those flags in UserSettings can leave stale runtime state after Editor quit or abnormal termination.

The goal is to keep persistent settings for user preferences only, while storing transient Editor-session state in the API designed for that lifetime.

Target transient state

Move these values out of UnityCliLoopEditorSettingsData and into SessionState:

  • isServerRunning
  • isAfterCompile
  • isDomainReloadInProgress
  • isReconnecting
  • showReconnectingUI
  • showPostCompileReconnectingUI

Implementation notes

  • Add IUnityCliLoopEditorSessionStatePort.
  • Add UnityCliLoopEditorSessionStateService.
  • Add UnityCliLoopEditorSessionStateRepository to wrap Unity SessionState access.
  • Update Domain Reload, recovery, server controller, bridge server, and post-compile UI code to read transient state from the new service.
  • Keep UnityCliLoopEditorSettingsRepository focused on persistent user settings.
  • Remove the transient fields from UnityCliLoopEditorSettingsData.
  • Clean up legacy transient keys from old UserSettings JSON during recovery/cleanup.
  • Define SessionState keys through constants instead of inline string literals.
  • Use false as the default value for all transient bools.

Do not change

  • Temp/UnityCliLoop/server-state.json
  • ServerReadinessStateStore
  • Go CLI readiness polling
  • setup wizard settings
  • tool settings
  • other preferences that should survive an Editor restart

Test plan

  • Add tests proving the session state repository can read values after service/repository recreation within the same Editor session.
  • Add tests proving server start/stop, Domain Reload, and recovery update SessionState.
  • Add tests proving UserSettings JSON no longer persists runtime flags.
  • Add tests proving old JSON with transient keys still loads and is cleaned up.
  • Update DomainReloadDetectionServiceTests and DomainReloadRecoveryUseCaseTests for the new session state service.
  • Run uloop compile.
  • Run the related EditMode test filter.
  • Run scripts/check-go-cli.sh && git diff --check if Go CLI-facing behavior may have been touched.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions