Skip to content

chore: Move compile disconnect policy into Domain - #1537

Merged
hatayama merged 1 commit into
v3-betafrom
codex/c4-10-jsonrpc-cancel-policy-domain
Jul 6, 2026
Merged

hatayama merged 1 commit into
v3-betafrom
codex/c4-10-jsonrpc-cancel-policy-domain

Conversation

@hatayama

@hatayama hatayama commented Jul 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Moves the accepted-request disconnect decision for compile requests into a pure Domain policy.
  • Keeps JSON-RPC parameter extraction in the infrastructure layer.

User Impact

  • No intended behavior change: compile requests that wait for domain reload still stay alive after client disconnect, while fire-and-forget compile requests still cancel.

Changes

  • Added JsonRpcAcceptedRequestCancellationPolicy in Domain with signature ShouldCancelOnClientDisconnect(string methodName, bool? compileWaitsForDomainReload).
  • Updated JsonRpcProcessor to read WaitForDomainReload from JToken as a nullable bool and delegate the decision to Domain.
  • Added unit coverage for non-compile, compile wait=true, compile wait=false, and unknown wait preference defaults.
  • Added JSON-RPC coverage for non-boolean WaitForDomainReload preserving the default wait=true behavior.

Verification

  • dist/darwin-arm64/uloop compile --project-path "/Users/a12115/ghq/hatayama/unity-cli-loop2" (0 errors, 0 warnings)
  • dist/darwin-arm64/uloop run-tests --project-path "/Users/a12115/ghq/hatayama/unity-cli-loop2" --test-mode EditMode --filter-type regex --filter-value "io.github.hatayama.UnityCliLoop.Tests.Editor.(JsonRpcAcceptedRequestCancellationPolicyTests|JsonRpcProcessorCliVersionGateTests).*" (21/21 passed)

Review in cubic

Keep transport parsing in infrastructure while centralizing the compile-specific cancellation decision in a pure domain policy.
@coderabbitai

coderabbitai Bot commented Jul 6, 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: d039828d-1fca-4b9f-ab96-fa806556e747

📥 Commits

Reviewing files that changed from the base of the PR and between 2e72dc7 and 10b7c5e.

⛔ Files ignored due to path filters (2)
  • Assets/Tests/Editor/JsonRpcAcceptedRequestCancellationPolicyTests.cs.meta is excluded by none and included by none
  • Packages/src/Editor/Domain/JsonRpcAcceptedRequestCancellationPolicy.cs.meta is excluded by none and included by none
📒 Files selected for processing (4)
  • Assets/Tests/Editor/JsonRpcAcceptedRequestCancellationPolicyTests.cs
  • Assets/Tests/Editor/JsonRpcProcessorCliVersionGateTests.cs
  • Packages/src/Editor/Domain/JsonRpcAcceptedRequestCancellationPolicy.cs
  • Packages/src/Editor/Infrastructure/Api/JsonRpcProcessor.cs

📝 Walkthrough

Walkthrough

Introduces a new JsonRpcAcceptedRequestCancellationPolicy class that centralizes logic for deciding whether accepted JSON-RPC requests should be canceled on client disconnect, based on method type and a nullable compile-wait-for-domain-reload flag. JsonRpcProcessor is updated to read this flag as nullable and delegate the decision. New unit tests cover both the policy and the processor's handling of malformed input.

Changes

Compile Cancellation Policy Extraction

Layer / File(s) Summary
New cancellation policy class
Packages/src/Editor/Domain/JsonRpcAcceptedRequestCancellationPolicy.cs, Assets/Tests/Editor/JsonRpcAcceptedRequestCancellationPolicyTests.cs
Adds a static policy class with ShouldCancelOnClientDisconnect and a helper defaulting null to true; tests cover non-compile, compile-waiting, compile-not-waiting, and unknown-preference scenarios.
JsonRpcProcessor integration with nullable wait flag
Packages/src/Editor/Infrastructure/Api/JsonRpcProcessor.cs, Assets/Tests/Editor/JsonRpcProcessorCliVersionGateTests.cs
Replaces the old default-cancel logic with a bool?-returning helper and delegates the final decision to the new policy; adds a test asserting non-boolean WaitForDomainReload values do not cancel the accepted request.

Estimated code review effort: 2 (Simple) | ~12 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant JsonRpcProcessor
  participant JsonRpcAcceptedRequestCancellationPolicy

  Client->>JsonRpcProcessor: ProcessRequestWithEarlyResponseAsync(compile request)
  JsonRpcProcessor->>JsonRpcProcessor: ReadCompileRequestWaitsForDomainReload(params)
  JsonRpcProcessor->>JsonRpcAcceptedRequestCancellationPolicy: ShouldCancelOnClientDisconnect(method, compileWaitsForDomainReload)
  alt method not compile
    JsonRpcAcceptedRequestCancellationPolicy-->>JsonRpcProcessor: true
  else compileWaitsForDomainReload is null or true
    JsonRpcAcceptedRequestCancellationPolicy-->>JsonRpcProcessor: false
  else compileWaitsForDomainReload is false
    JsonRpcAcceptedRequestCancellationPolicy-->>JsonRpcProcessor: true
  end
  JsonRpcProcessor-->>Client: accepted result with cancelOnClientDisconnect
Loading

Possibly related PRs

  • hatayama/unity-cli-loop#1240: Overlaps with the same JSON-RPC early-response cancellation behavior and cancelOnClientDisconnect/WaitForDomainReload tests.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: moving compile disconnect policy logic into the Domain layer.
Description check ✅ Passed The description matches the implemented changes and verification, covering the domain policy move and related tests.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/c4-10-jsonrpc-cancel-policy-domain

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.

No issues found across 6 files

Re-trigger cubic

@hatayama
hatayama merged commit 74a3d57 into v3-beta Jul 6, 2026
10 checks passed
@hatayama
hatayama deleted the codex/c4-10-jsonrpc-cancel-policy-domain branch July 6, 2026 04:45
RyanXie123 pushed a commit to RyanXie123/unity-cli-loop that referenced this pull request Sep 22, 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