Skip to content

chore: Session flags use a dedicated repository#1534

Merged
hatayama merged 3 commits into
v3-betafrom
codex/c4-5d-session-flags-session-repository
Jul 6, 2026
Merged

chore: Session flags use a dedicated repository#1534
hatayama merged 3 commits into
v3-betafrom
codex/c4-5d-session-flags-session-repository

Conversation

@hatayama

@hatayama hatayama commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add a Domain-owned ISessionFlagsRepository and move runtime SessionState flags behind UnityCliLoopSessionFlagsRepository.
  • Move flags-only session transitions and consumers to the flags repository while keeping the compile lifecycle coordinator for PR3b.
  • Remove the raw editor-session-state port and broad flags repository name from production code.

Validation

  • dist/darwin-arm64/uloop compile --project-path <PROJECT_ROOT>
  • dist/darwin-arm64/uloop run-tests --project-path <PROJECT_ROOT> --test-mode EditMode --filter-type regex --filter-value "(UnityCliLoopEditorSessionStateRepositoryTests|CompileStatusBridgeCommandTests|CompileSessionResultServiceTests|OnionAssemblyDependencyTests|StaticFacadeStateGuardTests|DomainReloadDetectionServiceTests|DomainReloadRecoveryUseCaseTests|UnityCliLoopServerControllerStartupLockTests|UnityCliLoopServerStartupProtectionTests|SetupWizardWindowTests|UnityCliLoopEditorSettingsRecoveryTests)"

Notes

  • This is C4-5d PR3a. PR3b will extract/rename the remaining compile lifecycle coordinator, move compile/pending consumers to direct repository injection, move test-only ClearAll composition fully into test helpers, and delete UnityCliLoopEditorSessionStateService.

Review in cubic

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@hatayama, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 34 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 675502fe-352b-4940-bb5f-590e739c40c7

📥 Commits

Reviewing files that changed from the base of the PR and between 44ff9b6 and 7414273.

📒 Files selected for processing (1)
  • Packages/src/Editor/Domain/UnityCliLoopEditorSessionStateService.cs
📝 Walkthrough

Walkthrough

This PR extracts editor session flags into ISessionFlagsRepository, implements it with UnityCliLoopSessionFlagsRepository, and exposes it through UnityCliLoopSessionFlagsFacade. Runtime wiring, presentation startup, and tests now use the repository for server, reload, reconnecting, and auto-scan flags.

Changes

Session flags repository extraction

Layer / File(s) Summary
Repository contract, implementation, and facade
Packages/src/Editor/Domain/ISessionFlagsRepository.cs, Packages/src/Editor/Infrastructure/Settings/UnityCliLoopSessionFlagsRepository.cs, Packages/src/Editor/Domain/UnityCliLoopSessionFlagsFacade.cs
Adds the new session-flags interface, its repository implementation, and a static facade for registering and retrieving the repository.
Domain and application services switched to session flags
Packages/src/Editor/Domain/UnityCliLoopEditorSessionStateService.cs, Packages/src/Editor/Application/SessionRecoveryService.cs, Packages/src/Editor/Application/UnityCliLoopServerStartupService.cs, Packages/src/Editor/Application/UseCases/DomainReloadRecoveryUseCase.cs
Removes flag APIs from the session-state service and rewires recovery/startup use cases to read and write flags through ISessionFlagsRepository.
Infrastructure, composition root, and bridge updated
Packages/src/Editor/Infrastructure/Server/DomainReloadDetectionFileService.cs, Packages/src/Editor/Infrastructure/Server/UnityCliLoopServerController.cs, Packages/src/Editor/Infrastructure/Api/CompileStatusBridgeCommand.cs, Packages/src/Editor/CompositionRoot/UnityCliLoopApplicationRegistration.cs, Packages/src/Editor/CompositionRoot/UnityCliLoopEditorBootstrapper.cs, Packages/src/Editor/Presentation/PresentationEditorStartup.cs
Threads the repository through server, reload, compile-status, and startup wiring, and registers it in the application composition root.
Presentation startup and windows use session flags
Packages/src/Editor/Presentation/Setup/SetupWizardWindow.cs, Packages/src/Editor/Presentation/Setup/ThirdPartyToolMigrationWizardWindow.cs, Packages/src/Editor/Presentation/UnityCliLoopSettingsWindow.cs
Switches startup and window-level flag accessors from the session-state service to the repository.
Tests and test helpers migrated
Assets/Tests/Editor/*.cs
Updates helpers and editor tests to build, clear, snapshot, restore, and assert against the repository-backed session flags, including dependency and facade coverage checks.

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

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: moving session flags into a dedicated repository.
Description check ✅ Passed The description matches the changeset and objectives, describing the new session flags repository and related refactors.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/c4-5d-session-flags-session-repository

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.

@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.

1 issue found across 31 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="Packages/src/Editor/Domain/UnityCliLoopSessionFlagsFacade.cs">

<violation number="1" location="Packages/src/Editor/Domain/UnityCliLoopSessionFlagsFacade.cs:13">
P3: Remove the redundant `?? throw ArgumentNullException` after `Debug.Assert` in `RegisterRepository`. Per project convention, internal API boundaries should use `Debug.Assert` for precondition enforcement without widening to runtime exceptions. The `Debug.Assert` already covers the null check in Unity Editor; the `?? throw` is dead code and inconsistent with the fail-fast contract-checking pattern.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

{
private static ISessionFlagsRepository RepositoryValue;

internal static void RegisterRepository(ISessionFlagsRepository repository)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: Remove the redundant ?? throw ArgumentNullException after Debug.Assert in RegisterRepository. Per project convention, internal API boundaries should use Debug.Assert for precondition enforcement without widening to runtime exceptions. The Debug.Assert already covers the null check in Unity Editor; the ?? throw is dead code and inconsistent with the fail-fast contract-checking pattern.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At Packages/src/Editor/Domain/UnityCliLoopSessionFlagsFacade.cs, line 13:

<comment>Remove the redundant `?? throw ArgumentNullException` after `Debug.Assert` in `RegisterRepository`. Per project convention, internal API boundaries should use `Debug.Assert` for precondition enforcement without widening to runtime exceptions. The `Debug.Assert` already covers the null check in Unity Editor; the `?? throw` is dead code and inconsistent with the fail-fast contract-checking pattern.</comment>

<file context>
@@ -0,0 +1,33 @@
+    {
+        private static ISessionFlagsRepository RepositoryValue;
+
+        internal static void RegisterRepository(ISessionFlagsRepository repository)
+        {
+            Debug.Assert(repository != null, "repository must not be null");
</file context>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
Packages/src/Editor/Infrastructure/Settings/UnityCliLoopSessionFlagsRepository.cs (1)

151-158: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Compose ClearDomainReloadRecoveryFlags from the existing clear methods instead of duplicating the sets.

The five SetXxx(false) calls here re-implement ClearDomainReloadFlag, ClearAfterCompileFlag, and ClearReconnectingFlags + ClearPostCompileReconnectingUI. If one of those individual clear methods changes, this combined method can silently drift out of sync.

♻️ Proposed refactor
         public void ClearDomainReloadRecoveryFlags()
         {
-            SetIsDomainReloadInProgress(false);
-            SetIsAfterCompile(false);
-            SetIsReconnecting(false);
-            SetShowReconnectingUI(false);
-            SetShowPostCompileReconnectingUI(false);
+            ClearDomainReloadFlag();
+            ClearAfterCompileFlag();
+            ClearReconnectingFlags();
+            ClearPostCompileReconnectingUI();
         }
🤖 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
`@Packages/src/Editor/Infrastructure/Settings/UnityCliLoopSessionFlagsRepository.cs`
around lines 151 - 158, ClearDomainReloadRecoveryFlags currently duplicates the
individual flag-reset calls instead of reusing the existing clear helpers.
Update UnityCliLoopSessionFlagsRepository’s ClearDomainReloadRecoveryFlags to
compose the already-defined methods like ClearDomainReloadFlag,
ClearAfterCompileFlag, ClearReconnectingFlags, and
ClearPostCompileReconnectingUI so the combined path stays aligned if any single
clear method changes.
🤖 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
`@Packages/src/Editor/Infrastructure/Settings/UnityCliLoopSessionFlagsRepository.cs`:
- Around line 151-158: ClearDomainReloadRecoveryFlags currently duplicates the
individual flag-reset calls instead of reusing the existing clear helpers.
Update UnityCliLoopSessionFlagsRepository’s ClearDomainReloadRecoveryFlags to
compose the already-defined methods like ClearDomainReloadFlag,
ClearAfterCompileFlag, ClearReconnectingFlags, and
ClearPostCompileReconnectingUI so the combined path stays aligned if any single
clear method changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1ec44289-0098-427b-baa8-945af6a67a00

📥 Commits

Reviewing files that changed from the base of the PR and between 4f55cdc and 40f324c.

⛔ Files ignored due to path filters (3)
  • Packages/src/Editor/Domain/ISessionFlagsRepository.cs.meta is excluded by none and included by none
  • Packages/src/Editor/Domain/UnityCliLoopSessionFlagsFacade.cs.meta is excluded by none and included by none
  • Packages/src/Editor/Infrastructure/Settings/UnityCliLoopSessionFlagsRepository.cs.meta is excluded by none and included by none
📒 Files selected for processing (28)
  • Assets/Tests/Editor/CompileSessionResultServiceTests.cs
  • Assets/Tests/Editor/CompileStatusBridgeCommandTests.cs
  • Assets/Tests/Editor/DomainReloadDetectionServiceTests.cs
  • Assets/Tests/Editor/DomainReloadRecoveryUseCaseTests.cs
  • Assets/Tests/Editor/OnionAssemblyDependencyTests.cs
  • Assets/Tests/Editor/SetupWizardWindowTests.cs
  • Assets/Tests/Editor/StaticFacadeStateGuardTests.cs
  • Assets/Tests/Editor/UnityCliLoopEditorSessionStateRepositoryTests.cs
  • Assets/Tests/Editor/UnityCliLoopEditorSessionStateTestFactory.cs
  • Assets/Tests/Editor/UnityCliLoopEditorSettingsRecoveryTests.cs
  • Assets/Tests/Editor/UnityCliLoopServerControllerStartupLockTests.cs
  • Assets/Tests/Editor/UnityCliLoopServerStartupProtectionTests.cs
  • Packages/src/Editor/Application/SessionRecoveryService.cs
  • Packages/src/Editor/Application/UnityCliLoopServerStartupService.cs
  • Packages/src/Editor/Application/UseCases/DomainReloadRecoveryUseCase.cs
  • Packages/src/Editor/CompositionRoot/UnityCliLoopApplicationRegistration.cs
  • Packages/src/Editor/CompositionRoot/UnityCliLoopEditorBootstrapper.cs
  • Packages/src/Editor/Domain/ISessionFlagsRepository.cs
  • Packages/src/Editor/Domain/UnityCliLoopEditorSessionStateService.cs
  • Packages/src/Editor/Domain/UnityCliLoopSessionFlagsFacade.cs
  • Packages/src/Editor/Infrastructure/Api/CompileStatusBridgeCommand.cs
  • Packages/src/Editor/Infrastructure/Server/DomainReloadDetectionFileService.cs
  • Packages/src/Editor/Infrastructure/Server/UnityCliLoopServerController.cs
  • Packages/src/Editor/Infrastructure/Settings/UnityCliLoopSessionFlagsRepository.cs
  • Packages/src/Editor/Presentation/PresentationEditorStartup.cs
  • Packages/src/Editor/Presentation/Setup/SetupWizardWindow.cs
  • Packages/src/Editor/Presentation/Setup/ThirdPartyToolMigrationWizardWindow.cs
  • Packages/src/Editor/Presentation/UnityCliLoopSettingsWindow.cs

@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.

1 issue found across 6 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="Packages/src/Editor/Domain/UnityCliLoopSessionFlagsFacade.cs">

<violation number="1" location="Packages/src/Editor/Domain/UnityCliLoopSessionFlagsFacade.cs:13">
P3: Remove the redundant `?? throw ArgumentNullException` after `Debug.Assert` in `RegisterRepository`. Per project convention, internal API boundaries should use `Debug.Assert` for precondition enforcement without widening to runtime exceptions. The `Debug.Assert` already covers the null check in Unity Editor; the `?? throw` is dead code and inconsistent with the fail-fast contract-checking pattern.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread Packages/src/Editor/Domain/UnityCliLoopEditorSessionStateService.cs Outdated
@hatayama
hatayama merged commit 54dd22c into v3-beta Jul 6, 2026
10 checks passed
@hatayama
hatayama deleted the codex/c4-5d-session-flags-session-repository branch July 6, 2026 02:50
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