Skip to content

refactor: extract mouse UI request preparation - #1632

Merged
hatayama merged 4 commits into
v3-betafrom
refactor/hatayama/extract-mouse-ui-command-validation
Jul 8, 2026
Merged

refactor: extract mouse UI request preparation#1632
hatayama merged 4 commits into
v3-betafrom
refactor/hatayama/extract-mouse-ui-command-validation

Conversation

@hatayama

@hatayama hatayama commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • extract schema-to-command conversion into MouseUiSimulationCommand
  • extract request and drag-state validation into MouseUiSimulationValidator
  • add characterization coverage for the existing validation response contract
  • reduce SimulateMouseUiUseCase from 1,591 to 1,403 lines without changing runtime behavior

Scope Notes

  • The only non-move production adaptation is passing PausedActionDescription into the validator, which keeps dependency direction from the use case to the validator.
  • CreateFailure is temporarily owned by the validator, and the use case's defensive unknown-action branch calls it directly. Response-factory extraction remains a later R2-33 stage.
  • Target resolution and DTOs, response construction, activity logging, overlay animation, and action/drag execution remain out of scope.
  • No unsupported-bypass characterization was added because every currently representable MouseAction supports bypass; that branch cannot be reached through the public schema today.
  • IPC request and response shapes are unchanged, so no protocol version bump is required.

Verification

  • dist/darwin-arm64/uloop compile (0 errors, 0 warnings)
  • PlayMode SimulateMouseUiTests (32 passed)
  • EditMode SimulateMouseUiActionValidationTests (1 passed)
  • EditMode PlayModeToolPreflightServiceTests (8 passed)
  • EditMode StaticFacadeStateGuardTests (20 passed)
  • EditMode OnionAssemblyDependencyTests (83 passed)
  • all four new validation characterization tests were confirmed Green before the production move
  • git diff --check origin/v3-beta...HEAD

Review in cubic

hatayama added 3 commits July 9, 2026 03:39
Pin the public tool responses for negative drag speed, unsupported drag buttons,
missing bypass targets, and invalid drop-target usage before moving command and
validation responsibilities out of the use case.
Move schema normalization and enum conversion into a dedicated internal command
type so subsequent validator extraction no longer depends on a nested private
type. Preserve every copied value, default, and validation message.
Move play-mode, request-option, and active-drag checks into a dedicated
validator while keeping public pause text on the use-case facade. Pass that
text explicitly to preserve dependency direction and every wire-visible
failure response.
@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: 94e3af3a-dcea-48a4-bdd0-1376b7cce5d1

📥 Commits

Reviewing files that changed from the base of the PR and between dfb43b5 and 9307aa3.

📒 Files selected for processing (1)
  • Assets/Tests/PlayMode/SimulateMouseUiTests.cs
🚧 Files skipped from review as they are similar to previous changes (1)
  • Assets/Tests/PlayMode/SimulateMouseUiTests.cs

📝 Walkthrough

Walkthrough

This PR extracts mouse UI simulation command construction and request validation from SimulateMouseUiUseCase into two new types, updates the use case to delegate to them, removes now-unused local helpers, and adds PlayMode tests for validation failure scenarios.

Changes

SimulateMouseUi validation refactor

Layer / File(s) Summary
Command extraction
Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiSimulationCommand.cs
New internal MouseUiSimulationCommand type built via TryFromSchema, mapping SimulateMouseUiSchema action and button enums to runtime equivalents and exposing coordinates, drag, and target-path properties.
Validator implementation
Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiSimulationValidator.cs
New internal static MouseUiSimulationValidator with ValidateSimulationStart, ValidateActiveDragState, ValidateSimulationRequestOptions, and CreateFailure, enforcing preflight, idle-pointer, drag speed/button, bypass raycast, and drop-target-path rules.
Use case delegation and cleanup
Packages/src/Editor/FirstPartyTools/SimulateMouseUi/SimulateMouseUiUseCase.cs
ExecuteAsync and ExecuteMouseAction now call the new validator/command types; removes the nested MouseUiSimulationCommand, local validation helpers, and IsDragAction.
Request validation tests
Assets/Tests/PlayMode/SimulateMouseUiTests.cs
Adds four [UnityTest] methods verifying validation failures for negative drag speed, disallowed drag button, missing target path with bypass raycast, and unsupported drop target path.

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

Possibly related PRs

  • hatayama/unity-cli-loop#1517: Both PRs wire SimulateMouseUiUseCase/MouseUiSimulationValidator simulation-start checks through PlayModeToolPreflightService.
  • hatayama/unity-cli-loop#1519: Both PRs implement the paused-PlayMode preflight check now used inside MouseUiSimulationValidator.ValidateSimulationStart.
  • hatayama/unity-cli-loop#1522: Both PRs change command/schema validation so invalid mouse UI inputs return Success=false with tests covering the failure paths.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main refactor: extracting mouse UI request preparation.
Description check ✅ Passed The description accurately covers the extracted command/validation logic and the validation coverage added.
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-command-validation

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.

All reported issues were addressed across 6 files

You’re at about 94% 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.

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

Re-trigger cubic

Comment thread Assets/Tests/PlayMode/SimulateMouseUiTests.cs Outdated
Use the existing SimulateMouseUiTests classic assertion style in the four new response-contract characterizations. This keeps the fixture internally consistent without changing the behavior under test.
@hatayama
hatayama merged commit ee17f00 into v3-beta Jul 8, 2026
10 checks passed
@hatayama
hatayama deleted the refactor/hatayama/extract-mouse-ui-command-validation branch July 8, 2026 19:12
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