Skip to content

fix: reply with r on a commit page without focusing the card - #1691

Open
JPetsis wants to merge 1 commit into
dev-null-sh:productionfrom
JPetsis:fix/984-reply-shortcut
Open

JPetsis wants to merge 1 commit into
dev-null-sh:productionfrom
JPetsis:fix/984-reply-shortcut

Conversation

@JPetsis

@JPetsis JPetsis commented Dec 1, 2026 •

Copy link
Copy Markdown

Summary

Fixes #984.

On a commit's own page, pressing r did nothing. The global shortcut hook only
resolved a commit action inside the focused reply or commit card, and a freshly
loaded commit page has no card focus, so the Reply button's
aria-keyshortcuts="r" was never clicked. Focusing the card first made the
shortcut work, which is what the report described. The same scope bug also
disabled q, y, s and o on that page.

Changes

  • commit-card.tsx marks the page's main commit with data-focused.
  • commitActionScope() in lib/commit-shortcuts.ts prefers a focused reply or
    commit and falls back to the page's data-focused commit.
  • use-keyboard-shortcuts.ts uses that scope when resolving commit actions.
  • CommitShortcutScope.test.ts covers focused reply, focused commit, page
    fallback and no scope.

No visual change; this is keyboard behavior only.

Validation

Local:

  • Reproduced on the live site in Chromium on macOS: r with body focused does
    nothing; focusing the commit card clicks Reply. As a guest, that click
    redirects to GitHub sign-in.
  • node --experimental-strip-types --test tests/Unit/CommitShortcutScope.test.ts:
    3 passed.
  • bun run test:unit: 336 passed.
  • React suite (vp test run --exclude '**/*.test.ts' --exclude 'vendor/**'):
    111 files, 1,164 passed.
  • bun run test:types: passed.
  • vp fmt --check and vp lint on the four changed files: passed.
  • vendor/bin/pest (full sequential suite): 6,726 passed, 0 failed,
    37,175 assertions.

Local Docker run with synthetic data: the commit page carried
data-focused="true", r with body focused opened the reply composer, and
Escape closed it without a reply.

Independent review

Reviewer: @JPetsis. Base baa02bbf990bbfc108072db9459e32718f151fb5,
head 8f5e289d102c7b28406345ef20792d6fa95794d4.
Verdict: PASS (code review). The implementer also ran the local Docker build
with synthetic data: r with body focused opened the reply composer, and no
reply was submitted.
Limits: production does not carry the change; the keyboard check used local
synthetic data.

Limitations

The live-site check used a guest session, so it confirms the Reply button is
activated but not the authenticated composer opening. The new unit test covers
the scope logic.

A 4-worker parallel Pest run produced two order-dependent
CommitSearchControllerTest failures. That file passes 11/11 alone and in the
full sequential run, and the failures are unrelated to this change.

The keyboard hook resolved actions only inside the focused reply or commit, so a commit page, where nothing has focus on load, ignored r along with q, y, s and o. Mark the page's own commit with data-focused and fall back to it when no card has focus.
@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The commit card exposes its focused state through data-focused. Keyboard shortcut lookup uses the active element’s reply or commit when available, or falls back to the focused page commit.

Changes: Commit shortcut scope

Layer / File(s) Summary
Resolve and use the shortcut scope
resources/js/components/commit-card.tsx, resources/js/lib/commit-shortcuts.ts, resources/js/hooks/use-keyboard-shortcuts.ts, tests/Unit/CommitShortcutScope.test.ts
The commit card sets data-focused when focused. commitActionScope prefers the active element’s reply or commit ancestor, then falls back to the focused page commit. The keyboard shortcut hook uses this scope, and tests cover precedence and fallback behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

Suggested reviewers: xheaven, nunomaduro

Merge Risk: Minimal · up to 8f5e2

Pressing r, q, y, s or o on a commit page with no card focused now targets that page's commit. No concrete merge-blocking risk was found, and the change is easy to revert.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the change: pressing r on a commit page opens the reply box without focusing the card. The changeset adds a commitActionScope fallback to the page's own commit (marked with data-focuse…
Linked Issues check Passed [#984] Requires that pressing r on a /commit/{id} page reaches that commit's reply box. The PR adds a data-focused marker to the page's main commit in commit-card.tsx. The new `commitActionSco…
Out of Scope Changes check Passed All changed files relate to the #984 fix: the page-commit marker in commit-card.tsx, the scope helper in commit-shortcuts.ts, the hook update in use-keyboard-shortcuts.ts, and the scope unit tes…
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names the change: pressing r on a commit page opens the reply box without focusing the card. The changeset adds a commitActionScope fallback to the page's own commit (marked with data-focused) when no reply or commit card is focused, and the linked issue asks for the same behavior. The title is specific and matches the main change. It uses the fix: prefix, which is a common convention.

Full details: Linked Issues check

Explanation

[#984] Requires that pressing r on a /commit/{id} page reaches that commit's reply box. The PR adds a data-focused marker to the page's main commit in commit-card.tsx. The new commitActionScope() in resources/js/lib/commit-shortcuts.ts prefers a focused reply or commit. When no card has focus, it falls back to [data-commit][data-focused] inside the root. use-keyboard-shortcuts.ts uses this scope when it resolves commit actions, so the Reply button on the page's own commit becomes the shortcut target. The head file confirms the helper logic. tests/Unit/CommitShortcutScope.test.ts covers the focused reply, focused commit, page fallback, and no-scope cases. The author also reports a local Docker check where r opened the reply composer. The live check used a guest session, so authenticated composer opening is confirmed only by the local run and the unit test. The code-level evidence supports the fix.

Full details: Out of Scope Changes check

Explanation

All changed files relate to the #984 fix: the page-commit marker in commit-card.tsx, the scope helper in commit-shortcuts.ts, the hook update in use-keyboard-shortcuts.ts, and the scope unit tests. The same scope bug also affected q, y, s, and o, so the shared fallback applies to those keys by design. The PR description reports a 4-worker Pest flake in CommitSearchControllerTest. That test is not in the changed file list, and the PR reports it passes in sequential runs, so it does not indicate an out-of-scope change.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9c997957-2139-4506-b29f-13cf869337c1
Commits

Reviewing files that changed from the base of the PR and between baa02bb and 8f5e289.

Files selected for processing: 4

  • resources/js/components/commit-card.tsx
  • resources/js/hooks/use-keyboard-shortcuts.ts
  • resources/js/lib/commit-shortcuts.ts
  • tests/Unit/CommitShortcutScope.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

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.

Shortcut "r" doesn't work from specific commit

1 participant