Skip to content

chore: Collapse the input-simulation tools' redundant intermediate DTO layer#1516

Merged
hatayama merged 2 commits into
v3-betafrom
refactor/c2-collapse-simulate-dto-layers
Jul 5, 2026
Merged

chore: Collapse the input-simulation tools' redundant intermediate DTO layer#1516
hatayama merged 2 commits into
v3-betafrom
refactor/c2-collapse-simulate-dto-layers

Conversation

@hatayama

@hatayama hatayama commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Summary

User Impact

  • No user-visible change. All three tool responses stay identical.

Changes

  • Each use case now takes its wire Schema and returns its wire Response directly; the tools' ToRequest/ToResponse mapping helpers are deleted.
  • The shared types file keeps the real domain vocabulary (the four action/button enums, UnityCliLoopInputSimulationDefaults, UnityCliLoopPausePointHit) — those are consumed by the wire DTOs themselves.
  • Explicit ArgumentNullException guards sit at each use-case entry, matching the precedent set in the earlier collapses.
  • No SessionState or persistence path exists for these results, so there is no stored-shape compatibility constraint. Repo-wide grep confirms zero remaining references to the nine deleted types.
  • The assembly-boundary guard test that referenced the deleted types is removed; sibling guards remain.

Verification

  • dist/darwin-arm64/uloop compile → 0 errors, 0 warnings.
  • dist/darwin-arm64/uloop run-tests --filter-type regex --filter-value "(Simulate|StaticFacadeStateGuard|OnionAssemblyDependency).*Tests" → 93 passed, 0 failed, 0 skipped.

Review in cubic

The three input-simulation tools (simulate-keyboard, simulate-mouse-input,
simulate-mouse-ui) each carried a pure field-copy layer between the wire
schema/response and the use case: a per-tool service interface plus a
Request and Result DTO that only forwarded fields with matching names.
The tool executor did the copy on the way in and out, adding weight
without adding a boundary — the use cases already reach into Unity
Editor APIs directly, so the interface offers no substitutable seam.

Fold the use cases so each one accepts its own Schema and returns its
own Response directly; keep the shared enums, mouse-UI defaults, and the
PausePointHit value object because the wire responses still use them.
This is the third PR in the collapse series after Compile (#1514) and
RunTests (#1515) and follows the same reviewer feedback: explicit null
guards at the use case entry, no comments referencing pre-collapse
shape, and domain value objects preserved.
@coderabbitai

coderabbitai Bot commented Jul 5, 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: 90932c50-1e3e-4adb-86df-9e40a99d7170

📥 Commits

Reviewing files that changed from the base of the PR and between 76c957e and d41c488.

📒 Files selected for processing (8)
  • Assets/Tests/Editor/OnionAssemblyDependencyTests.cs
  • Packages/src/Editor/FirstPartyTools/Common/InputSimulation/UnityCliLoopInputSimulationTypes.cs
  • Packages/src/Editor/FirstPartyTools/SimulateKeyboard/SimulateKeyboardTool.cs
  • Packages/src/Editor/FirstPartyTools/SimulateKeyboard/SimulateKeyboardUseCase.cs
  • Packages/src/Editor/FirstPartyTools/SimulateMouseInput/SimulateMouseInputTool.cs
  • Packages/src/Editor/FirstPartyTools/SimulateMouseInput/SimulateMouseInputUseCase.cs
  • Packages/src/Editor/FirstPartyTools/SimulateMouseUi/SimulateMouseUiTool.cs
  • Packages/src/Editor/FirstPartyTools/SimulateMouseUi/SimulateMouseUiUseCase.cs
💤 Files with no reviewable changes (1)
  • Assets/Tests/Editor/OnionAssemblyDependencyTests.cs

📝 Walkthrough

Walkthrough

Legacy input simulation service interfaces and request/result DTO types are removed and replaced with a unified schema/response contract. SimulateKeyboard, SimulateMouseInput, and SimulateMouseUi tools now delegate directly to use-case ExecuteAsync(Schema, CancellationToken) methods returning typed Response objects, eliminating intermediate request/response conversion helpers. An associated assembly-boundary test for the removed types is deleted.

Changes

Input simulation ExecuteAsync migration

Layer / File(s) Summary
Remove legacy service interfaces and DTOs; drop obsolete assembly test
Packages/src/Editor/FirstPartyTools/Common/InputSimulation/UnityCliLoopInputSimulationTypes.cs, Assets/Tests/Editor/OnionAssemblyDependencyTests.cs
Removes IUnityCliLoopKeyboardSimulationService, IUnityCliLoopMouseInputSimulationService, IUnityCliLoopMouseUiSimulationService and their request/result DTO classes; keeps UnityCliLoopInputSimulationDefaults; deletes the corresponding architecture test.
SimulateKeyboard ExecuteAsync refactor
Packages/src/Editor/FirstPartyTools/SimulateKeyboard/SimulateKeyboardTool.cs, Packages/src/Editor/FirstPartyTools/SimulateKeyboard/SimulateKeyboardUseCase.cs
Tool delegates to useCase.ExecuteAsync(parameters, ct); use-case exposes ExecuteAsync(SimulateKeyboardSchema, CancellationToken) returning SimulateKeyboardResponse, updating validation, dispatch, press/keydown/keyup handlers, and interruption/timeout/pause-point helpers.
SimulateMouseInput ExecuteAsync refactor
Packages/src/Editor/FirstPartyTools/SimulateMouseInput/SimulateMouseInputTool.cs, Packages/src/Editor/FirstPartyTools/SimulateMouseInput/SimulateMouseInputUseCase.cs
Tool delegates to useCase.ExecuteAsync(parameters, ct); use-case exposes ExecuteAsync(SimulateMouseInputSchema, CancellationToken) returning SimulateMouseInputResponse, updating click/long-press/move-delta/scroll/smooth-delta handlers and interruption/timeout/pause-point helpers.
SimulateMouseUi ExecuteAsync refactor
Packages/src/Editor/FirstPartyTools/SimulateMouseUi/SimulateMouseUiTool.cs, Packages/src/Editor/FirstPartyTools/SimulateMouseUi/SimulateMouseUiUseCase.cs
Tool delegates to useCase.ExecuteAsync(parameters, ct); use-case exposes ExecuteAsync(SimulateMouseUiSchema, CancellationToken) returning SimulateMouseUiResponse, updating validation helpers, click/long-press/drag start/move/end flows, pointer-target resolution, result-construction helpers, and FromSchema command mapping.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Tool as SimulateXTool
  participant UseCase as SimulateXUseCase
  participant Device as Keyboard/Mouse

  Tool->>UseCase: ExecuteAsync(schema, ct)
  UseCase->>UseCase: validate schema, PlayMode/pause state
  UseCase->>Device: dispatch action-specific handler
  Device-->>UseCase: interaction result
  UseCase-->>Tool: typed Response object
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: collapsing the redundant intermediate DTO layer in the input-simulation tools.
Description check ✅ Passed The description matches the changeset and explains the DTO-layer removal, use-case refactor, and test cleanup.
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/c2-collapse-simulate-dto-layers

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

Re-trigger cubic

…wait

Self-review follow-up: SimulateMouseInputUseCase now names its schema
parameter "parameters" like SimulateKeyboardUseCase, and
SimulateMouseUiTool no longer calls ConfigureAwait(false) on a body
that has no code after the await, matching its sibling tools.
SimulateMouseUiUseCase keeps "request" because "parameters" is already
taken by the MouseUiSimulationCommand used throughout that file.
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