Skip to content

refactor: extract mouse UI overlay support - #1635

Merged
hatayama merged 3 commits into
v3-betafrom
refactor/hatayama/extract-mouse-ui-overlay-support
Jul 8, 2026
Merged

refactor: extract mouse UI overlay support#1635
hatayama merged 3 commits into
v3-betafrom
refactor/hatayama/extract-mouse-ui-overlay-support

Conversation

@hatayama

@hatayama hatayama commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • extract structured simulation activity logging into MouseUiSimulationActivityLogger
  • extract Editor-frame waiting and overlay animation into MouseUiEditorFrameWaiter and MouseUiOverlayAnimator
  • extract captured-main-thread cleanup into MouseUiMainThreadCleanupScheduler
  • keep event and drag execution in SimulateMouseUiUseCase for the next planned split

Behavioral Preservation

  • added synchronous EditMode characterization for immediate cleanup and queued overlay clearing before moving the implementation
  • preserved frame timeout, cancellation, ConfigureAwait(false), main-thread switching, animation timing, cleanup posting, and state mutation order
  • verified the full SimulateMouseUiTests PlayMode suite passed both before and after the move
  • normalized the old use case against the new use case and three support classes in both directions; the only residual lines were the planned ownership field and the two adaptations below
  • removed the one-line EnsureOverlayExists wrapper and now call OverlayCanvasFactory.EnsureExists() directly
  • removed the three private animation constant aliases and reference SimulateMouseUiAnimationConstants directly from the animator

Validation

  • Unity compile: 0 errors, 0 warnings
  • SimulateMouseUiTests PlayMode: 32 passed
  • MouseUiMainThreadCleanupSchedulerTests: 2 passed
  • MouseUiPointerTargetResolverTests: 10 passed
  • MouseUiSimulationResponseFactoryTests: 12 passed
  • SimulateMouseUiActionValidationTests: 1 passed
  • PlayModeToolPreflightServiceTests: 8 passed
  • StaticFacadeStateGuardTests: 20 passed
  • OnionAssemblyDependencyTests: 83 passed

Compatibility

  • no IPC request or response shape changed
  • no protocol version bump is required

Review in cubic

hatayama added 3 commits July 9, 2026 05:11
Expose the final extraction seams and lock down immediate cleanup behavior with synchronous EditMode tests. Animation and frame-wait behavior remains covered by the existing PlayMode suite to avoid unsafe editor-thread coordination tests.
Move the structured start and completion log construction into a cohesive helper while preserving every event name, message, context field, and correlation identifier.
Move frame waiting, overlay animation, and main-thread cleanup scheduling into cohesive helpers while preserving timing, cancellation, and cleanup behavior. Remove the one-line overlay wrapper and local animation constant aliases so callers use the owning APIs directly.
@coderabbitai

coderabbitai Bot commented Jul 8, 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: 79def0ac-845c-45a6-9462-c8fa9d0256ad

📥 Commits

Reviewing files that changed from the base of the PR and between 56d206b and 52c96a8.

⛔ Files ignored due to path filters (5)
  • Assets/Tests/Editor/MouseUiMainThreadCleanupSchedulerTests.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiEditorFrameWaiter.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiMainThreadCleanupScheduler.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiOverlayAnimator.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiSimulationActivityLogger.cs.meta is excluded by none and included by none
📒 Files selected for processing (6)
  • Assets/Tests/Editor/MouseUiMainThreadCleanupSchedulerTests.cs
  • Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiEditorFrameWaiter.cs
  • Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiMainThreadCleanupScheduler.cs
  • Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiOverlayAnimator.cs
  • Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiSimulationActivityLogger.cs
  • Packages/src/Editor/FirstPartyTools/SimulateMouseUi/SimulateMouseUiUseCase.cs

📝 Walkthrough

Walkthrough

This PR extracts overlay animation, editor-frame waiting, main-thread cleanup scheduling, and activity logging from SimulateMouseUiUseCase into four new dedicated helper classes, updates the use case to delegate to them across click, long-press, and drag flows, removes the old inline implementations, and adds tests for the new cleanup scheduler.

Changes

SimulateMouseUi Helper Extraction

Layer / File(s) Summary
Editor frame waiter
Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiEditorFrameWaiter.cs
New helper waits for an editor frame with timeout and switches execution to the Unity main thread.
Main-thread cleanup scheduler and tests
Packages/.../MouseUiMainThreadCleanupScheduler.cs, Assets/Tests/Editor/MouseUiMainThreadCleanupSchedulerTests.cs
New scheduler captures main-thread context and runs/posts cleanup actions immediately or via SynchronizationContext, with validation and new NUnit tests.
Overlay animator
Packages/.../MouseUiOverlayAnimator.cs
New static class provides PlayExpandAnimation and PlayDissipateAnimation, gated by frame waiting and main-thread switching, clearing overlay state on dissipate completion.
Activity logger
Packages/.../MouseUiSimulationActivityLogger.cs
New static logger emits structured start/complete events for mouse UI simulations.
UseCase wiring and flow integration
Packages/.../SimulateMouseUiUseCase.cs
Adds a scheduler field, wires context capture/logging/overlay setup to new helpers, and routes click, long-press, and drag flows' expand/dissipate/cleanup logic through the new helper classes, removing the old local implementations.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Possibly related PRs

  • hatayama/unity-cli-loop#1333: Both PRs refactor SimulateMouseUi to avoid hangs via timeout-aware editor-frame waiting and explicit main-thread cleanup for overlay state.
  • hatayama/unity-cli-loop#1516: Both PRs modify SimulateMouseUiUseCase.cs, changing the use case's internal flow and overlay animation/cleanup logic.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main refactor: extracting mouse UI overlay support into helper classes.
Description check ✅ Passed The description is directly related to the changes and accurately summarizes the extraction and behavioral checks.
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 refactor/hatayama/extract-mouse-ui-overlay-support

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 11 files

You’re at about 96% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

Re-trigger cubic

@hatayama
hatayama merged commit 29d6caf into v3-beta Jul 8, 2026
10 checks passed
@hatayama
hatayama deleted the refactor/hatayama/extract-mouse-ui-overlay-support branch July 8, 2026 20:28
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