Skip to content

chore: simplify keyboard input simulation support - #1649

Merged
hatayama merged 2 commits into
v3-betafrom
refactor/hatayama/extract-keyboard-simulation-support
Jul 9, 2026
Merged

hatayama merged 2 commits into
v3-betafrom
refactor/hatayama/extract-keyboard-simulation-support

Conversation

@hatayama

@hatayama hatayama commented Jul 9, 2026 •

Copy link
Copy Markdown
Owner

Refs: Refactor round 3 ToDo R3-1

Summary

  • Preserve keyboard simulation behavior while separating wire response construction and main-thread cleanup.
  • Add synchronous characterization coverage for interrupted and timed-out keyboard responses.

User Impact

  • Keyboard press, key-down, and key-up behavior remains unchanged.
  • The internal structure now matches the other input simulation tools, reducing risk in future maintenance.

Changes

  • Extract a stateless response factory with Pause Point evidence projection.
  • Extract stateless keyboard state and overlay cleanup.
  • Track the new async helper with the cancellation-token source guard.

Verification

  • Baseline PlayMode SimulateKeyboard tests: 37 passed.
  • Unity compile: 0 errors, 0 warnings.
  • StaticFacadeStateGuardTests: 20 passed.
  • SimulateKeyboard and response factory PlayMode tests: 41 passed.
  • Normalized move diff: implementation bodies preserved; residuals limited to signatures and direct dispatch qualification.

Review in cubic

hatayama added 2 commits July 9, 2026 11:18
Move interrupted and timed-out response mapping into a stateless factory so the keyboard use case no longer owns wire-visible response details. Characterization tests preserve pause-point evidence and nullable press-edge semantics.
Move keyboard state restoration, timeout cleanup, and press overlay finalization into a stateless helper so the use case focuses on orchestration. Track the helper with the async cancellation-token guard.
@coderabbitai

coderabbitai Bot commented Jul 9, 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: 6053f874-2694-4bd7-8d00-b3a1f7e41598

📥 Commits

Reviewing files that changed from the base of the PR and between 95c4313 and b241fd7.

⛔ Files ignored due to path filters (3)
  • Assets/Tests/PlayMode/KeyboardInputSimulationResponseFactoryTests.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/SimulateKeyboard/KeyboardInputMainThreadCleanup.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/SimulateKeyboard/KeyboardInputSimulationResponseFactory.cs.meta is excluded by none and included by none
📒 Files selected for processing (5)
  • Assets/Tests/Editor/StaticFacadeStateGuardTests.cs
  • Assets/Tests/PlayMode/KeyboardInputSimulationResponseFactoryTests.cs
  • Packages/src/Editor/FirstPartyTools/SimulateKeyboard/KeyboardInputMainThreadCleanup.cs
  • Packages/src/Editor/FirstPartyTools/SimulateKeyboard/KeyboardInputSimulationResponseFactory.cs
  • Packages/src/Editor/FirstPartyTools/SimulateKeyboard/SimulateKeyboardUseCase.cs

📝 Walkthrough

Walkthrough

This PR extracts keyboard-simulation cleanup and response-building logic from SimulateKeyboardUseCase into two new helper classes: KeyboardInputMainThreadCleanup for main-thread state cleanup/rollback, and KeyboardInputSimulationResponseFactory for constructing interrupted/timed-out responses with pause-point metadata. The use case now delegates to these helpers, removing its local helper methods. New PlayMode tests cover the response factory, and an async cancellation guard test's scanned file list is updated.

Changes

Keyboard simulation cleanup/response extraction

Layer / File(s) Summary
Response factory implementation and tests
Packages/src/Editor/FirstPartyTools/SimulateKeyboard/KeyboardInputSimulationResponseFactory.cs, Assets/Tests/PlayMode/KeyboardInputSimulationResponseFactoryTests.cs
New KeyboardInputSimulationResponseFactory builds interrupted/timed-out SimulateKeyboardResponse objects and attaches pause-point hit metadata; new PlayMode tests validate response shaping for interrupted press/key-up and timeout cases using a fake pause controller.
Main-thread cleanup helper implementation
Packages/src/Editor/FirstPartyTools/SimulateKeyboard/KeyboardInputMainThreadCleanup.cs
New KeyboardInputMainThreadCleanup implements FinalizePressOverlay, RollbackHeldKey, ReleaseKeyStateIfPossible, timed-out press/held-key cleanup scheduling, and CanInjectKeyboardState eligibility gating.
SimulateKeyboardUseCase delegation wiring
Packages/src/Editor/FirstPartyTools/SimulateKeyboard/SimulateKeyboardUseCase.cs, Assets/Tests/Editor/StaticFacadeStateGuardTests.cs
ExecutePress, ExecuteKeyDown, and ExecuteKeyUp now delegate cleanup and response construction to the new helper classes; large local helper block removed; async cancellation guard path list updated to include the new cleanup file.

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

Possibly related PRs

  • hatayama/unity-cli-loop#1516: Both PRs modify SimulateKeyboardUseCase.cs's press/hold/up/timeout and pause-point result/cleanup paths.
  • hatayama/unity-cli-loop#1594: Both PRs change SimulateKeyboardUseCase's press/keyup/held-key cleanup paths, overlapping directly in the same cleanup flow.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main refactor of keyboard input simulation support.
Description check ✅ Passed The description matches the refactor and test additions in the changeset.
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-keyboard-simulation-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.

@hatayama
hatayama merged commit d5d7cb5 into v3-beta Jul 9, 2026
10 checks passed
@hatayama
hatayama deleted the refactor/hatayama/extract-keyboard-simulation-support branch July 9, 2026 02:40
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