Skip to content

chore: simplify keyboard input action execution#1650

Merged
hatayama merged 1 commit into
v3-betafrom
refactor/hatayama/extract-keyboard-input-actions
Jul 9, 2026
Merged

chore: simplify keyboard input action execution#1650
hatayama merged 1 commit into
v3-betafrom
refactor/hatayama/extract-keyboard-input-actions

Conversation

@hatayama

@hatayama hatayama commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Refs: Refactor round 3 ToDo R3-2

Summary

  • Preserve keyboard input behavior while isolating press, key-down, and key-up execution.
  • Complete the shared input-tool structure established for mouse and keyboard simulation.

User Impact

  • Keyboard simulation behavior and response fields remain unchanged.
  • The keyboard use case is now a focused orchestrator, reducing risk in future action changes.

Changes

  • Extract a stateless keyboard input action executor.
  • Keep validation, logging, overlay setup, and direct action dispatch in the use case.
  • Track the new async helper with the cancellation-token source guard.

Verification

  • Baseline keyboard PlayMode tests: 41 passed.
  • Unity compile: 0 errors, 0 warnings.
  • StaticFacadeStateGuardTests: 20 passed.
  • Head keyboard PlayMode tests: 41 passed.
  • Normalized move diff: implementation bodies preserved; residuals limited to three signatures and three direct dispatch replacements.

Review in cubic

Move press, key-down, and key-up workflows into a stateless executor so the keyboard use case retains only validation, setup, logging, and dispatch. Preserve input update ordering, timeout escalation, and cleanup behavior.
@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: 6a9935ae-3cec-402a-a90d-52815e0cbadc

📥 Commits

Reviewing files that changed from the base of the PR and between d5d7cb5 and 0243f33.

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

📝 Walkthrough

Walkthrough

Keyboard input simulation logic for Press, KeyDown, and KeyUp actions is extracted from SimulateKeyboardUseCase into a new internal static KeyboardInputActionExecutor class. SimulateKeyboardUseCase now delegates to this executor and removes its former private implementations. A test guard allowlist is updated to include the new file.

Changes

Keyboard Input Action Executor Extraction

Layer / File(s) Summary
New KeyboardInputActionExecutor implementation
Packages/src/Editor/FirstPartyTools/SimulateKeyboard/KeyboardInputActionExecutor.cs
Adds a new internal static class implementing ExecutePress, ExecuteKeyDown, ExecuteKeyUp, and IsGameplayPressEdgeVisible, with validation, main-thread coordination, InputSystem.onAfterUpdate monitoring, and cleanup for timeout/rollback scenarios.
Use case delegation and guard allowlist update
Packages/src/Editor/FirstPartyTools/SimulateKeyboard/SimulateKeyboardUseCase.cs, Assets/Tests/Editor/StaticFacadeStateGuardTests.cs
SimulateKeyboardUseCase.ExecuteAsync now calls the new executor's methods instead of removed private implementations; the async cancellation-token guard test allowlist is extended to scan the new file.

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

Sequence Diagram(s)

sequenceDiagram
  participant UseCase as SimulateKeyboardUseCase
  participant Executor as KeyboardInputActionExecutor
  participant InputSystem
  UseCase->>Executor: ExecutePress/ExecuteKeyDown/ExecuteKeyUp(Keyboard, Key, ct)
  Executor->>Executor: validate key state and duration
  Executor->>InputSystem: register transient key/overlay state
  Executor->>InputSystem: subscribe onAfterUpdate
  InputSystem-->>Executor: wasPressedThisFrame edge observed
  Executor->>Executor: wait for observation/timeout window
  Executor->>Executor: cleanup (unregister, rollback, timeout scheduling)
  Executor-->>UseCase: SimulateKeyboardResponse
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the refactor that simplifies keyboard input action execution.
Description check ✅ Passed The description is clearly related to the refactor and matches the changeset details.
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-input-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.

@hatayama
hatayama merged commit 0e3648b into v3-beta Jul 9, 2026
10 checks passed
@hatayama
hatayama deleted the refactor/hatayama/extract-keyboard-input-actions branch July 9, 2026 03:01
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