Skip to content

refactor: extract mouse UI press action execution - #1636

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

hatayama merged 3 commits into
v3-betafrom
refactor/hatayama/extract-mouse-ui-press-actions

Conversation

@hatayama

@hatayama hatayama commented Jul 8, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • extract top-left and Unity screen-space conversion into MouseUiCoordinateConverter
  • extract click and long-press orchestration into MouseUiPressActionExecutor
  • reduce SimulateMouseUiUseCase from 891 lines to 690 lines while leaving all drag execution for the next stages

Behavioral Preservation

  • added synchronous EditMode characterization for the Game view Y flip and coordinate round trip before moving the converter
  • moved the coordinate why-comment with the implementation and switched all 11 press and drag call sites directly to the new owner
  • preserved click and long-press event ordering, messages, response fields, animation timing, frame timeout handling, cancellation, cleanup posting, and every ConfigureAwait(false) call
  • normalized the old press block against the new executor; the only difference was a trailing blank line after normalizing the planned scheduler reference change
  • retargeted the existing timeout-state source guard to MouseUiPressActionExecutor so it continues to reject Unity object re-evaluation after asynchronous timeouts

Planned Adaptation

  • ExecuteClick and ExecuteLongPress are now static executor entries and receive MouseUiMainThreadCleanupScheduler explicitly
  • this replaces six use-case field references without adding a constructor, instance executor, delegate, wrapper, or reverse dependency

Validation

  • Unity compile: 0 errors, 0 warnings
  • SimulateMouseUiTests PlayMode: 32 passed before and after extraction
  • related EditMode suites: 138 passed across 8 fixtures
  • StaticFacadeStateGuardTests: 20 passed after moving the guarded source owner
  • helper-to-use-case reverse references: 0
  • old press and coordinate definitions remaining in the use case: 0

Compatibility

  • no IPC request or response shape changed
  • no protocol version bump is required
  • R2-40 and R2-41 remain intentionally out of scope

Review in cubic

hatayama added 3 commits July 9, 2026 05:35
Expose the final coordinate conversion seam and pin the top-left Y flip and round-trip behavior against the current Game view height before moving the shared implementation.
Move top-left and Unity screen-space conversion into a focused helper so press and drag executors can share the same Game view coordinate contract without depending on the use case.
Move click and long-press event orchestration into a stateless executor, passing the shared cleanup scheduler explicitly so the helper remains independent of the use case. Retarget the timeout-state source guard to the new owner.
@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: 4046a32c-041d-4dd8-94c6-9fe329179c4f

📥 Commits

Reviewing files that changed from the base of the PR and between 29d6caf and 1238636.

⛔ Files ignored due to path filters (3)
  • Assets/Tests/Editor/MouseUiCoordinateConverterTests.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiCoordinateConverter.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiPressActionExecutor.cs.meta is excluded by none and included by none
📒 Files selected for processing (5)
  • Assets/Tests/Editor/MouseUiCoordinateConverterTests.cs
  • Assets/Tests/Editor/StaticFacadeStateGuardTests.cs
  • Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiCoordinateConverter.cs
  • Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiPressActionExecutor.cs
  • Packages/src/Editor/FirstPartyTools/SimulateMouseUi/SimulateMouseUiUseCase.cs

📝 Walkthrough

Walkthrough

Adds MouseUiCoordinateConverter for top-left/bottom-left Y-flip coordinate conversion and MouseUiPressActionExecutor for click/long-press execution flows. Refactors SimulateMouseUiUseCase to delegate click, long-press, and drag coordinate handling to these new components, removing duplicated local implementations. Updates tests accordingly.

Changes

Mouse UI coordinate conversion and press execution refactor

Layer / File(s) Summary
Coordinate conversion utility and tests
Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiCoordinateConverter.cs, Assets/Tests/Editor/MouseUiCoordinateConverterTests.cs
New MouseUiCoordinateConverter internal static class provides InputToScreen/ScreenToInput, flipping Y using Handles.GetMainGameViewSize().y; new test fixture verifies flip and round-trip conversion.
MouseUiPressActionExecutor click/long-press flows
Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiPressActionExecutor.cs
New ExecuteClick and ExecuteLongPress async methods resolve pointer targets, update overlay, run expand/dissipate animations, switch to main thread, and dispatch pointer events via ExecutePointerClickEvents and ExecuteLongPressPointerDown helpers.
SimulateMouseUiUseCase routing and drag flow migration
Packages/src/Editor/FirstPartyTools/SimulateMouseUi/SimulateMouseUiUseCase.cs, Assets/Tests/Editor/StaticFacadeStateGuardTests.cs
Click/LongPress actions now route to MouseUiPressActionExecutor; local coordinate helpers and press implementations removed; drag one-shot/start/move/end and interpolation flows updated to use MouseUiCoordinateConverter; related test updated to reference new source file.

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

Sequence Diagram(s)

sequenceDiagram
  participant UseCase as SimulateMouseUiUseCase
  participant Executor as MouseUiPressActionExecutor
  participant Converter as MouseUiCoordinateConverter
  participant MainThread as Unity Main Thread

  UseCase->>Executor: ExecuteClick / ExecuteLongPress(input)
  Executor->>Converter: InputToScreen(inputPos)
  Executor->>Executor: resolve pointer targets
  Executor->>Executor: update overlay, run expand animation
  Executor->>MainThread: switch context
  MainThread->>MainThread: fire pointerDown/pointerUp/pointerClick
  Executor->>Executor: run dissipate animation
  Executor->>UseCase: return SimulateMouseUiResponse
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main refactor of extracting mouse UI press action execution.
Description check ✅ Passed The description accurately covers the refactor, behavior preservation, validation, and out-of-scope drag work.
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-press-actions

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

You’re at about 97% 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 commented Jul 8, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@hatayama
hatayama merged commit 14415de into v3-beta Jul 8, 2026
10 checks passed
@hatayama
hatayama deleted the refactor/hatayama/extract-mouse-ui-press-actions branch July 8, 2026 21:05
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