Skip to content

chore: isolate project IPC client sessions - #1641

Merged
hatayama merged 2 commits into
v3-betafrom
refactor/hatayama/extract-bridge-client-sessions
Jul 8, 2026
Merged

hatayama merged 2 commits into
v3-betafrom
refactor/hatayama/extract-bridge-client-sessions

Conversation

@hatayama

@hatayama hatayama commented Jul 8, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Give project IPC client streams, handler tasks, and request sessions one explicit lifecycle owner.
  • Reduce the bridge server to listener acceptance, server cancellation, shutdown coordination, and lifecycle events.

User Impact

  • There is no intended user-visible behavior change.
  • CLI connections, dispatch acceptance, heartbeats, final responses, disconnect cancellation, shutdown, and recovery remain unchanged.

Changes

  • Move UnityCliLoopBridgeServerInstanceFactory unchanged into its matching production file.
  • Add UnityCliLoopBridgeClientSessionManager as the sole owner of the client stream registry, handler task registry, task IDs, request processor, heartbeat service, disconnect monitor, and normal-disconnection classification.
  • Move client disconnect-all, handler startup, active-task snapshots, read/reassembly loop, accepted-request coordination, and session cleanup into the manager.
  • Keep the server constructor signature and runtime argument validation order unchanged; the manager receives already validated dependencies and uses assertions for its internal preconditions.
  • Replace exactly four server call sites: disconnect during normal stop, active task capture, disconnect during unexpected cleanup, and accepted-client handoff.
  • Reduce UnityCliLoopBridgeServer from 713 lines to 348 lines.

Verification

  • Passed the related EditMode baseline before editing (167/167).
  • Confirmed the moved factory class body is byte-identical to the base revision.
  • Compared all seven moved session method bodies after normalizing the three required private to internal entry changes; every body matched.
  • Verified the server has no client stream/task/request dependency fields and the manager has no server reverse reference.
  • Verified the manager is called from exactly four server sites and all session implementation methods remain private.
  • Passed the final transport, response writer, bridge shutdown, reassembler, heartbeat, cancellation policy, response serializer, client connection, CLI version gate, architecture, and static facade guard fixtures (167/167).
  • Compiled the Unity package with 0 errors and 0 warnings.
  • Removed moved trailing whitespace only; no logic changed.

Compatibility

  • Request/response JSON shapes, Content-Length bytes, readiness/dispatch behavior, accepted/heartbeat/final ordering, cancellation tokens, exception filters, task continuations, and cleanup order are unchanged.
  • No IPC contract changed, so the protocol declarations remain untouched.

R2-35 Completion

  • The server now owns listener/server lifecycle state, while the manager uniquely owns client session state and cleanup. This PR is the R2-35 completion candidate; no speculative third stage is planned.

Review in cubic

hatayama added 2 commits July 9, 2026 07:42
Move the existing public factory unchanged into its matching infrastructure file so the remaining server source can focus on listener and session lifecycle responsibilities.
Give one instance manager ownership of connected streams, handler tasks, request framing coordination, and session cleanup. Keep the server responsible for listener acceptance, server cancellation, shutdown orchestration, and lifecycle events while preserving every handshake and task transition.
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

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

Next review available in: 29 seconds

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: 36e994d4-67bf-4492-89aa-40faa7da6755

📥 Commits

Reviewing files that changed from the base of the PR and between 5758724 and d5ab493.

⛔ Files ignored due to path filters (2)
  • Packages/src/Editor/Infrastructure/UnityCliLoopBridgeClientSessionManager.cs.meta is excluded by none and included by none
  • Packages/src/Editor/Infrastructure/UnityCliLoopBridgeServerInstanceFactory.cs.meta is excluded by none and included by none
📒 Files selected for processing (3)
  • Packages/src/Editor/Infrastructure/UnityCliLoopBridgeClientSessionManager.cs
  • Packages/src/Editor/Infrastructure/UnityCliLoopBridgeServer.cs
  • Packages/src/Editor/Infrastructure/UnityCliLoopBridgeServerInstanceFactory.cs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/hatayama/extract-bridge-client-sessions

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.

@hatayama
hatayama merged commit dde189d into v3-beta Jul 8, 2026
10 checks passed
@hatayama
hatayama deleted the refactor/hatayama/extract-bridge-client-sessions branch July 8, 2026 22:56
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