Skip to content

fix: prevent Ctrl+R page reload and show platform-aware shortcuts (#58)#66

Merged
matt1398 merged 1 commit intomatt1398:mainfrom
Psypeal:fix/ctrl-r-shortcut
Feb 23, 2026
Merged

fix: prevent Ctrl+R page reload and show platform-aware shortcuts (#58)#66
matt1398 merged 1 commit intomatt1398:mainfrom
Psypeal:fix/ctrl-r-shortcut

Conversation

@Psypeal
Copy link
Contributor

@Psypeal Psypeal commented Feb 22, 2026

Summary

  • Intercept Ctrl+R/Cmd+R in before-input-event to prevent Electron default page reload
  • Replace hardcoded macOS shortcut symbols with platform-aware formatShortcut() helper showing Ctrl+ on Windows/Linux

Fixes #58

Changes

  • src/main/index.ts - Add Ctrl+R/Cmd+R intercept in existing before-input-event handler
  • src/renderer/utils/stringUtils.ts - Add formatShortcut(), modKey, shiftKey utilities
  • 5 UI files - Replace hardcoded command symbols with formatShortcut() calls

Test plan

  • On Linux/Windows: Ctrl+R no longer reloads the Electron page
  • Shortcut hints show Ctrl+ instead of command symbol on non-Mac
  • On macOS: Cmd+R and symbols unchanged
  • Zoom shortcuts still work correctly

Summary by CodeRabbit

  • New Features

    • Keyboard shortcuts now dynamically display with platform-appropriate formatting (⌘ on macOS, Ctrl+ on Windows/Linux).
  • Bug Fixes

    • Fixed Cmd/Ctrl+R keyboard behavior to enable custom session refresh functionality.

…tt1398#58)

Intercept Ctrl+R/Cmd+R in before-input-event to prevent Electron's default page reload. Replace hardcoded macOS shortcut symbols with platform-aware helpers that show Ctrl+ on Windows/Linux.
@gemini-code-assist
Copy link

Summary of Changes

Hello @Psypeal, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses two key areas to improve the application's responsiveness and user interface consistency. It prevents the default browser-like page reload when Ctrl+R or Cmd+R is pressed, enabling custom application behavior for this shortcut. Concurrently, it standardizes the display of keyboard shortcuts across platforms, ensuring that users see the correct modifier keys for their operating system.

Highlights

  • Prevented Electron Page Reload: Intercepted Ctrl+R/Cmd+R key presses in the main process to prevent Electron's default page reload behavior, allowing the renderer process to handle it for application-specific actions like 'Refresh Session'.
  • Platform-Aware Shortcut Display: Introduced new utility functions to dynamically format and display keyboard shortcuts, showing 'Ctrl+' on Windows/Linux and '⌘' on macOS, improving user experience across different operating systems.
Changelog
  • src/main/index.ts
    • Added logic to the before-input-event handler to prevent the default Electron page reload when Ctrl+R or Cmd+R is pressed.
  • src/renderer/components/dashboard/DashboardView.tsx
    • Updated the 'Search' shortcut hint to use the new formatShortcut utility for platform-aware display.
  • src/renderer/components/layout/SidebarHeader.tsx
    • Updated the 'Collapse sidebar' shortcut hint to use the new formatShortcut utility.
  • src/renderer/components/layout/TabBar.tsx
    • Updated 'Refresh Session' and 'Search' shortcut hints to use the new formatShortcut utility.
  • src/renderer/components/layout/TabContextMenu.tsx
    • Updated 'Close Tab', 'Split Right', and 'Close All Tabs' shortcut hints to use the new formatShortcut utility, including support for the Shift modifier.
  • src/renderer/components/sidebar/SessionContextMenu.tsx
    • Updated the 'Open in New Tab' shortcut hint to use the new formatShortcut utility.
  • src/renderer/utils/stringUtils.ts
    • Added isMacPlatform constant to detect the operating system.
    • Exported modKey and shiftKey constants to provide platform-specific modifier symbols.
    • Implemented the formatShortcut function to generate platform-aware keyboard shortcut strings.
Activity
  • No specific human activity (comments, reviews, or progress updates) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai coderabbitai bot added the bug Something isn't working label Feb 22, 2026
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request effectively addresses the stated goals of preventing Ctrl+R page reload in Electron and introducing platform-aware shortcut displays. The formatShortcut utility is a good addition for improving UX across different operating systems. The changes are well-implemented and follow good practices.

@coderabbitai
Copy link

coderabbitai bot commented Feb 22, 2026

No actionable comments were generated in the recent review. 🎉


📝 Walkthrough

Walkthrough

Implements cross-platform keyboard shortcut formatting by introducing platform-aware utilities that dynamically format shortcuts based on the operating system (macOS vs. Windows/Linux), then applies these utilities across UI components and main process event handling to replace hard-coded keyboard symbols.

Changes

Cohort / File(s) Summary
Platform-Aware Shortcut Utilities
src/renderer/utils/stringUtils.ts
Introduces isMacPlatform detection, exports modKey and shiftKey constants adapted per platform, and adds formatShortcut(key, opts) function to dynamically format keyboard shortcuts with proper modifier key ordering.
Main Process Event Handling
src/main/index.ts
Adds preventDefault logic for Cmd/Ctrl+R key event to intercept and disable default page reload, allowing the renderer to implement custom "Refresh Session" action.
UI Components Using Shortcuts
src/renderer/components/dashboard/DashboardView.tsx, src/renderer/components/layout/SidebarHeader.tsx, src/renderer/components/layout/TabBar.tsx, src/renderer/components/layout/TabContextMenu.tsx, src/renderer/components/sidebar/SessionContextMenu.tsx
Imports formatShortcut utility and replaces hard-coded keyboard symbols in button titles and menu labels with dynamic formatting calls for Refresh Session, Search, Collapse Sidebar, Close Tab, Split Right, and Open in New Tab actions.

Suggested labels

bug

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Pull request successfully addresses issue #58 by intercepting Ctrl+R in the main process and adding platform-aware shortcut formatting utilities to display correct shortcuts on all platforms.
Out of Scope Changes check ✅ Passed All changes directly support the core objectives: preventing Ctrl+R reload, implementing platform-aware shortcuts, and updating UI components to display platform-appropriate shortcut hints.

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

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

@matt1398 matt1398 merged commit c4975f1 into matt1398:main Feb 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refresh Session keyboard shortcut does not work on Windows

2 participants