Skip to content

feature: Add keyboard shortcuts for goto def & find all refs #329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 4, 2025

Conversation

brendan-kellam
Copy link
Contributor

@brendan-kellam brendan-kellam commented Jun 4, 2025

This PR adds keyboard shortcuts for code nav:

  • ⌥+f12 -> go to definition
  • ⌥+shift+f12 -> find all references

Unfortunately seems like f12 can't be used since the dev tools panel is binded to f12.

Summary by CodeRabbit

  • New Features

    • Added keyboard shortcuts for "find all references" (Alt+Shift+F12) and "go to definition" (Alt+F12) within the symbol hover popup, including notifications when no definition is found.
  • Documentation

    • Updated changelog to reflect the addition of new keyboard shortcuts.

@brendan-kellam brendan-kellam requested a review from msukkari June 4, 2025 02:00
Copy link

coderabbitai bot commented Jun 4, 2025

Warning

Rate limit exceeded

@brendan-kellam has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 1 minutes and 9 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 7bcd762 and dde0bcd.

📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • packages/web/src/ee/features/codeNav/components/symbolHoverPopup/index.tsx (4 hunks)

Walkthrough

Keyboard shortcut support was added to the SymbolHoverPopup component, enabling users to trigger "find all references" and "go to definition" actions using alt+shift+f12 and alt+f12 respectively. The changelog was updated to document these new features. No changes were made to exported interfaces.

Changes

File(s) Change Summary
CHANGELOG.md Updated to document new keyboard shortcuts for code navigation actions.
packages/web/src/ee/features/codeNav/components/symbolHoverPopup/index.tsx Added useHotkeys for alt+shift+f12 (find references) and alt+f12 (go to definition) shortcuts.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SymbolHoverPopup
    participant Toast

    User->>SymbolHoverPopup: Press alt+shift+f12
    SymbolHoverPopup->>SymbolHoverPopup: Check if symbol name exists
    alt Symbol name exists
        SymbolHoverPopup->>SymbolHoverPopup: Call onFindReferences(symbolName)
    end

    User->>SymbolHoverPopup: Press alt+f12
    SymbolHoverPopup->>SymbolHoverPopup: Check if symbol info and definitions exist
    alt No definitions found
        SymbolHoverPopup->>Toast: Show "No definition found for this symbol."
    else Definitions found
        SymbolHoverPopup->>SymbolHoverPopup: Call onGotoDefinition()
    end
Loading

Possibly related PRs

Poem

In the popup where symbols gleam,
New shortcuts now fulfill a dream—
With alt and F12, you swiftly go,
To references or definitions, in a flow!
A toast will cheer (or gently warn),
As code navigation is reborn.
🐇⌨️✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@brendan-kellam brendan-kellam force-pushed the bkellam/nav_shortcuts branch from a581359 to cae52dc Compare June 4, 2025 02:01
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/web/src/ee/features/codeNav/components/symbolHoverPopup/index.tsx (1)

100-109: Remove debug console.log statement.

The hotkey implementation is correct, but there's a debug console.log statement that should be removed before production.

 useHotkeys('alt+shift+f12', () => {
     if (symbolInfo?.symbolName) {
-        console.log('here!');
         onFindReferences(symbolInfo.symbolName);
     }
 }, {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d5c4486 and 7bcd762.

📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • packages/web/src/ee/features/codeNav/components/symbolHoverPopup/index.tsx (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/web/src/ee/features/codeNav/components/symbolHoverPopup/index.tsx (1)
packages/web/src/components/hooks/use-toast.ts (2)
  • useToast (194-194)
  • toast (194-194)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (5)
packages/web/src/ee/features/codeNav/components/symbolHoverPopup/index.tsx (4)

11-12: LGTM! Clean import additions.

The new imports for useHotkeys and useToast are correctly added and align with the implementation below.


31-31: LGTM! Proper hook initialization.

The toast hook is correctly initialized for use in the hotkey handlers.


111-128: LGTM! Well-implemented hotkey with proper error handling.

The alt+f12 hotkey implementation is excellent:

  • Properly checks for symbol existence
  • Validates symbol definitions availability
  • Shows user-friendly toast notification when no definition is found
  • Reuses existing onGotoDefinition callback for consistency
  • Includes appropriate accessibility options

The implementation follows good practices and handles edge cases well.


100-128:

❓ Verification inconclusive

Verify hotkey accessibility and keyboard combinations.

The hotkey implementations look functionally correct. However, please verify:

  1. These key combinations don't conflict with browser/OS shortcuts on different platforms
  2. The enableOnFormTags and enableOnContentEditable options are appropriate for the use case
  3. Consider documenting these shortcuts in tooltips as mentioned in the PR objectives

🏁 Script executed:

#!/bin/bash
# Description: Check if there are any existing hotkey conflicts or documentation about keyboard shortcuts

# Search for other hotkey usages in the codebase to check for conflicts
rg "useHotkeys.*alt.*f12" -A 3

# Search for any keyboard shortcut documentation or tooltips
rg -i "keyboard|shortcut|hotkey|tooltip" --type tsx --type ts -A 2

Length of output: 988


Confirm Hotkey Functionality and Documentation

I ran a search across the repo and found only the two bindings in symbolHoverPopup/index.tsx. There are no other alt+f12 or alt+shift+f12 handlers, nor any existing tooltip or shortcut‐documentation references.

• Please verify these combinations don’t collide with built-in browser/OS shortcuts on Windows, macOS, and Linux.
• Ensure the enableOnFormTags and enableOnContentEditable flags match the intended UX (e.g. do you want these keys active inside inputs?).
• Add in-app tooltips or update your docs/README to surface these new shortcuts to users.

CHANGELOG.md (1)

13-13: LGTM! Accurate changelog entry.

The changelog entry correctly documents the new keyboard shortcuts feature and references the appropriate PR number. The entry follows the established format and is placed in the correct section.

msukkari
msukkari previously approved these changes Jun 4, 2025
@brendan-kellam brendan-kellam merged commit 46d7ca9 into main Jun 4, 2025
5 checks passed
@brendan-kellam brendan-kellam deleted the bkellam/nav_shortcuts branch June 4, 2025 02:30
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.

2 participants