File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import {
1010} from "react" ;
1111
1212import { router } from "@/app/router" ;
13+ import { useReloadShortcut } from "@/app/useReloadShortcut" ;
1314import { useAppOnboardingState } from "@/features/onboarding/hooks" ;
1415import { OnboardingFlow } from "@/features/onboarding/ui/OnboardingFlow" ;
1516import { useWorkspaceInit } from "@/features/workspaces/useWorkspaceInit" ;
@@ -66,6 +67,10 @@ function AppReady({ isSharedIdentity }: { isSharedIdentity: boolean }) {
6667}
6768
6869export function App ( ) {
70+ // Mounted at the root so Cmd/Ctrl+R reloads in every app state,
71+ // including the loading and first-run setup screens below.
72+ useReloadShortcut ( ) ;
73+
6974 useLayoutEffect ( ( ) => {
7075 void getCurrentWindow ( ) . show ( ) ;
7176 } , [ ] ) ;
Original file line number Diff line number Diff line change 1+ import * as React from "react" ;
2+
3+ import { hasPrimaryShortcutModifier } from "@/shared/lib/platform" ;
4+
5+ /**
6+ * Reloads the webview on the platform's reload shortcut (Cmd+R on macOS,
7+ * Ctrl+R elsewhere), matching browser behavior.
8+ *
9+ * `window.location.reload()` is the app's existing reload primitive (see
10+ * App.tsx, useWorkspaceInit.ts): it triggers a full reinit that re-reads
11+ * localStorage and reconnects relays.
12+ */
13+ export function useReloadShortcut ( ) {
14+ React . useEffect ( ( ) => {
15+ function handleKeyDown ( event : KeyboardEvent ) {
16+ if (
17+ ! hasPrimaryShortcutModifier ( event ) ||
18+ event . altKey ||
19+ event . shiftKey
20+ ) {
21+ return ;
22+ }
23+ if ( event . key . toLowerCase ( ) !== "r" ) {
24+ return ;
25+ }
26+
27+ event . preventDefault ( ) ;
28+ window . location . reload ( ) ;
29+ }
30+
31+ window . addEventListener ( "keydown" , handleKeyDown ) ;
32+ return ( ) => {
33+ window . removeEventListener ( "keydown" , handleKeyDown ) ;
34+ } ;
35+ } , [ ] ) ;
36+ }
You can’t perform that action at this time.
0 commit comments