Skip to content

fix: Simulated key presses now reach gameplay polling#1236

Merged
hatayama merged 3 commits into
v3-betafrom
feature/hatayama/fix-wasPressedThisFrame
May 28, 2026
Merged

fix: Simulated key presses now reach gameplay polling#1236
hatayama merged 3 commits into
v3-betafrom
feature/hatayama/fix-wasPressedThisFrame

Conversation

@hatayama

Copy link
Copy Markdown
Owner

Summary

  • Simulated keyboard taps now stay observable long enough for gameplay code that polls wasPressedThisFrame in Update().
  • Agent-facing guidance now points tap scenarios to Press and reserves KeyDown / KeyUp for intentional holds.

User Impact

  • Before, simulate-keyboard --action Press --key Space could report success while a game that used Keyboard.current.spaceKey.wasPressedThisFrame missed the jump/start action.
  • After this change, simulated taps are held across gameplay observation frames so normal Input System edge checks can see them without rewriting game code to held-state polling.

Changes

  • Keep simulated press inputs alive for a second standard observation frame before release.
  • Add PlayMode coverage for keyboard and mouse wasPressedThisFrame polling from MonoBehaviour.Update().
  • Update README and bundled skill guidance for tap vs held-key scenarios.

Verification

  • Packages/src/Cli~/dist/darwin-arm64/uloop compile --project-path <PROJECT_ROOT>
  • Packages/src/Cli~/dist/darwin-arm64/uloop run-tests --test-mode PlayMode --filter-type regex --filter-value "^io\.github\.hatayama\.UnityCliLoop\.Tests\.PlayMode\.SimulateKeyboardTests\." --project-path <PROJECT_ROOT>
  • Packages/src/Cli~/dist/darwin-arm64/uloop run-tests --test-mode PlayMode --filter-type regex --filter-value "^io\.github\.hatayama\.UnityCliLoop\.Tests\.PlayMode\.SimulateMouseInputTests\." --project-path <PROJECT_ROOT>
  • git diff --check
  • ~/.codex/skills/codex-review/scripts/codex-review v3-beta

Keep simulated Press inputs alive across gameplay observation frames so Update-based input polling can see edge-triggered actions such as wasPressedThisFrame. Add focused PlayMode coverage for keyboard and mouse input, and update skills/docs to guide agents toward Press for tap actions instead of rewriting gameplay code to held-state checks.
@coderabbitai

coderabbitai Bot commented May 28, 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: 1406e765-07b0-45fd-bbee-51bd911eef36

📥 Commits

Reviewing files that changed from the base of the PR and between 687925d and 311dccc.

📒 Files selected for processing (6)
  • .agents/skills/uloop-simulate-keyboard/SKILL.md
  • .claude/skills/uloop-simulate-keyboard/SKILL.md
  • Assets/Tests/PlayMode/SimulateKeyboardTests.cs
  • Packages/src/Editor/FirstPartyTools/SimulateKeyboard/Skill/SKILL.md
  • README.md
  • README_ja.md
✅ Files skipped from review due to trivial changes (3)
  • README.md
  • README_ja.md
  • Packages/src/Editor/FirstPartyTools/SimulateKeyboard/Skill/SKILL.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • .claude/skills/uloop-simulate-keyboard/SKILL.md
  • .agents/skills/uloop-simulate-keyboard/SKILL.md

📝 Walkthrough

Walkthrough

The PR centralizes observation-frame timing, adds play-mode tests verifying keyboard and mouse simulated Press/KeyDown are observable via Update polling (including gameplay jump wiring), and updates SKILL/README docs to advise using Press for edge-triggered checks and KeyDown/KeyUp for held-key scenarios with troubleshooting steps.

Changes

Input Press Observability and Guidance

Layer / File(s) Summary
Observation frame timing constants refactoring
Packages/src/Editor/FirstPartyTools/Common/InputSystem/InputSystemUpdateHelper.cs
Introduce StandardPressObservationFrames and ManualPressObservationFrames and update GetMinimumObservationFrameCount() to use them.
Keyboard press Update-frame observability tests
Assets/Tests/PlayMode/SimulateKeyboardTests.cs
Add field and setup wiring for UpdateFramePressObserver, multiple UnityTests verifying default Press and KeyDown are visible via wasPressedThisFrame in Update, add UpdateFramePressObserver and WasPressedGameplayJumpController helper MonoBehaviours.
Mouse press Update-frame observability tests
Assets/Tests/PlayMode/SimulateMouseInputTests.cs
Instantiate/destroy MouseUpdateFramePressObserver in fixture, reset observer in click test, assert at least one wasPressedThisFrame detection during Update, and add the observer MonoBehaviour.
Press vs KeyDown/KeyUp action documentation
.agents/skills/uloop-simulate-keyboard/SKILL.md, .claude/skills/uloop-simulate-keyboard/SKILL.md, Packages/src/Editor/FirstPartyTools/SimulateKeyboard/Skill/SKILL.md, README.md, README_ja.md
Clarify that Press targets edge-triggered gameplay checks (e.g., wasPressedThisFrame), recommend KeyDown/KeyUp for intentionally held-key behaviour, and add a troubleshooting checklist for cases where simulated input shows isPressed true but the game state does not change.

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly Related PRs

  • hatayama/unity-cli-loop#783: Modifies the same Assets/Tests/PlayMode/SimulateKeyboardTests.cs to validate Press observability via wasPressedThisFrame, with overlapping test logic.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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 clearly and concisely summarizes the main fix: simulated key presses now reach gameplay polling code, which is the core objective of this PR.
Description check ✅ Passed The description is directly related to the changeset, explaining the problem, solution, impact, and verification steps for the simulated key press fix.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 feature/hatayama/fix-wasPressedThisFrame

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 and usage tips.

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Actionable comments posted: 0

@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

hatayama added 2 commits May 28, 2026 23:11
Add gameplay-style coverage that Press and KeyDown drive Update-based wasPressedThisFrame state transitions before the tool returns. Document that KeyDown emits only one initial edge before becoming held state, so agents should verify input timing before rewriting gameplay polling to isPressed.
@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Actionable comments posted: 0

@hatayama
hatayama merged commit ba735f1 into v3-beta May 28, 2026
8 checks passed
@hatayama
hatayama deleted the feature/hatayama/fix-wasPressedThisFrame branch May 28, 2026 15:09
@github-actions github-actions Bot mentioned this pull request May 28, 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