Skip to content

Intercept ctrl/command R for refresh #759

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 2 commits into from
Jul 31, 2025
Merged

Intercept ctrl/command R for refresh #759

merged 2 commits into from
Jul 31, 2025

Conversation

wwwillchen
Copy link
Contributor

Fixes #209

cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

cubic analysis

1 issue found across 1 file • Review in cubic

React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.

if (event.key === "r" && (event.ctrlKey || event.metaKey)) {
event.preventDefault(); // Prevent default browser refresh
if (previewMode === "preview") {
console.log("REFRESHING APP IFRAME");
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace console.log with the logging framework.

(This reflects your team's feedback about avoiding console statements in production code.)

Prompt for AI agents
Address the following comment on src/app/layout.tsx at line 26:

<comment>Replace console.log with the logging framework.

(This reflects your team&#39;s feedback about avoiding console statements in production code.)</comment>

<file context>
@@ -4,12 +4,40 @@ import { ThemeProvider } from &quot;../contexts/ThemeContext&quot;;
 import { DeepLinkProvider } from &quot;../contexts/DeepLinkContext&quot;;
 import { Toaster } from &quot;sonner&quot;;
 import { TitleBar } from &quot;./TitleBar&quot;;
+import { useEffect } from &quot;react&quot;;
+import { useRunApp } from &quot;@/hooks/useRunApp&quot;;
+import { useAtomValue } from &quot;jotai&quot;;
+import { previewModeAtom } from &quot;@/atoms/appAtoms&quot;;
 
 export default function RootLayout({
</file context>

if (previewMode === "preview") {
refreshAppIframe(); // Use our custom refresh function instead
}
}
Copy link

Choose a reason for hiding this comment

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

Bug: Refresh Key Listener Fails Outside Preview

The global keyboard listener for refresh events unconditionally prevents the default browser refresh (Ctrl/Cmd+R), but only provides a custom refresh when in preview mode. This causes Ctrl/Cmd+R to do nothing outside of preview mode. Additionally, the listener only checks for the lowercase "r" key, failing to intercept Ctrl/Cmd+Shift+R.

Locations (1)
Fix in Cursor Fix in Web

@wwwillchen wwwillchen merged commit 3ce81e5 into main Jul 31, 2025
4 of 5 checks passed
@wwwillchen wwwillchen deleted the natural-refresh branch July 31, 2025 23:34
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.

Cmd+R to refresh breaks app
1 participant