Skip to content

feat: Add press-edge diagnostics to simulate-keyboard - #1912

Merged
hatayama merged 2 commits into
feature/round6-pause-point-improvementsfrom
fix/round6-keyboard-press-edge-observation-window
Jul 21, 2026
Merged

feat: Add press-edge diagnostics to simulate-keyboard#1912
hatayama merged 2 commits into
feature/round6-pause-point-improvementsfrom
fix/round6-keyboard-press-edge-observation-window

Conversation

@hatayama

@hatayama hatayama commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • simulate-keyboard's Press/KeyDown response now carries extra diagnostic detail whenever it reports "press edge was not observed", so a real occurrence can be diagnosed directly from the response instead of needing a fresh investigation.

User Impact

  • Before: when simulate-keyboard occasionally reported a Press/KeyDown "press edge was not observed" warning, there was no way to tell from the response alone whether the key-down event was consumed at the wrong moment, never consumed at all, whether gameplay updates even ran during the wait, or whether the key was already down before the action started.
  • After: the same warning message now includes a short, concrete reason, and the response carries matching fields (PressEdgeConsumedByUpdateType, PressEdgeAnyDynamicUpdateObserved, PressEdgeKeyAlreadyPressedBeforeQueue) set only in that case. Timing, grace period, and retry behavior for Press/KeyDown are unchanged.

Investigation

  • The original plan for this change was to extend the existing edge-observation grace window. Before doing that, we tried to reproduce the reported miss to confirm the window was actually the cause.
  • Roughly 200 reproduction attempts across this repo's development project and a separate verification project (concurrent command launches, a main-thread busy-loop, an unfocused Editor with runInBackground=false, and pause-point races) never reproduced a missed edge — the injected key-down event was consumed by a Dynamic update in every single case.
  • Given that negative result, changing the observation window (or adding a speculative re-press) would be a guess rather than a fix. This PR instead adds the diagnostics needed to pin down the actual cause the next time it happens in the field.

Changes

  • Extended the existing onAfterUpdate press-edge monitor in KeyboardInputActionExecutor (both ExecutePress and ExecuteKeyDown) to also record which Input System update type (if any) saw wasPressedThisFrame, whether any Dynamic update ran during the wait, and whether the key was already down right before the event was queued.
  • Added a pure PressEdgeDiagnosticsMessageFormatter that turns those three signals into a short message suffix, covered by unit tests.
  • Added the three nullable fields to SimulateKeyboardResponse, populated only when the press edge was not observed.

Verification

  • dist/darwin-arm64/uloop compile --project-path <repo>: 0 errors, 0 warnings.
  • Verified the new formatter tests actually fail without the implementation: temporarily forced BuildSuffix to return "", recompiled, confirmed 5/5 new tests failed, then reverted and recompiled to confirm 0 errors/warnings again.
  • dist/darwin-arm64/uloop run-tests filtered to PausePoint|SimulateKeyboard|PressEdge|PressHoldUntilEdge: 240/240 passed.
  • dist/darwin-arm64/uloop run-tests (full EditMode suite): 2262/2272 passed; the 3 failures are pre-existing in CliSetupApplicationServiceTests (dispatcher release tag string-length assertions) and unrelated to this change — not modified by this PR.

Review in cubic

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@hatayama, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 43 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 131391b1-1c36-433c-96ac-e9425c76557c

📥 Commits

Reviewing files that changed from the base of the PR and between 6fe08fb and 99bf266.

📒 Files selected for processing (2)
  • Packages/src/Editor/FirstPartyTools/SimulateKeyboard/KeyboardInputActionExecutor.cs
  • Packages/src/Editor/FirstPartyTools/SimulateKeyboard/SimulateKeyboardResponse.cs
📝 Walkthrough

Walkthrough

Press and key-down execution now records why gameplay did not observe a press edge, formats scenario-specific diagnostics, and exposes update-type information in responses. New NUnit tests cover the formatter’s diagnostic branches.

Changes

Press-edge diagnostics

Layer / File(s) Summary
Diagnostic contracts and formatter
Packages/src/Editor/FirstPartyTools/Common/InputSystem/PressEdgeDiagnosticsMessageFormatter.cs, Packages/src/Editor/FirstPartyTools/SimulateKeyboard/SimulateKeyboardResponse.cs, Assets/Tests/Editor/PressEdgeDiagnosticsMessageFormatterTests.cs
The formatter builds suffixes for pre-pressed keys, missing dynamic updates, dropped events, editor consumption, and other update types. Responses expose the consuming update type, and NUnit tests cover these cases.
Executor tracking and response integration
Packages/src/Editor/FirstPartyTools/SimulateKeyboard/KeyboardInputActionExecutor.cs
Press and key-down execution monitor updates, record press-edge diagnostics, compose failure messages, and populate diagnostic response fields when the edge is not observed.

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

Sequence Diagram(s)

sequenceDiagram
  participant KeyboardInputActionExecutor
  participant InputSystem
  participant PressEdgeDiagnosticsMessageFormatter
  participant SimulateKeyboardResponse
  KeyboardInputActionExecutor->>InputSystem: Monitor onAfterUpdate
  InputSystem-->>KeyboardInputActionExecutor: Report update type and press-edge state
  KeyboardInputActionExecutor->>PressEdgeDiagnosticsMessageFormatter: Build diagnostic suffix
  PressEdgeDiagnosticsMessageFormatter-->>KeyboardInputActionExecutor: Return scenario-specific suffix
  KeyboardInputActionExecutor->>SimulateKeyboardResponse: Populate diagnostic fields
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: adding press-edge diagnostics to simulate-keyboard.
Description check ✅ Passed The description clearly matches the changeset and explains the new diagnostics, response fields, and unchanged behavior.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/round6-keyboard-press-edge-observation-window

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.

Round-6 feedback reported intermittent "press edge was not observed"
warnings from simulate-keyboard Press/KeyDown. An extensive
reproduction attempt (roughly 200 attempts across this repo's dev
project and cli-loop-block-kuzushi, covering concurrent load, main-
thread contention, unfocused/runInBackground=false, and pause-point
races) could not reproduce the miss even once, and every observed
KeyDown event was consumed by a Dynamic update. Changing the
observation window or adding a speculative re-press would be a guess,
not a fix.

Instead, extend the existing onAfterUpdate press-edge monitor to also
record which update type (if any) actually saw wasPressedThisFrame,
whether any Dynamic update ran during the wait, and whether the key
was already down before the event was queued. These are additive,
nullable fields set only when the edge is not observed, so a future
field occurrence can be diagnosed directly from the response instead
of needing another investigation like this one. Press/KeyDown timing,
grace, and retry behavior are unchanged.
@hatayama
hatayama force-pushed the fix/round6-keyboard-press-edge-observation-window branch from d8c5750 to 6fe08fb Compare July 21, 2026 07:10
Remove the ref out-parameters from RecordPressEdgeMissDiagnostics per
project convention (no out/ref) by bundling the three diagnostic
locals into a PressEdgeMissDiagnostics class captured by the
onAfterUpdate monitor lambda instead. Also group the XML doc comments
on SimulateKeyboardResponse's three PressEdge* diagnostic fields so
they read as one cohesive set.
@hatayama
hatayama merged commit b9548f1 into feature/round6-pause-point-improvements Jul 21, 2026
1 of 2 checks passed
@hatayama
hatayama deleted the fix/round6-keyboard-press-edge-observation-window branch July 21, 2026 07:21
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