fix(shortcuts): restore page reload shortcuts
Page reload shortcuts (Ctrl+R, Ctrl+Shift+R, F5, Ctrl+F5) were registered in shortcuts.go using a stub method that did nothing. Moved them to the window-level shortcut handler where they actually work. - Ctrl+R / F5: Normal reload - Ctrl+Shift+R / Ctrl+F5: Hard reload (bypass cache) Both handlers target the active pane with proper locking and error handling.
- commit
- 9cc0239007bcc7a17162ef4c1cc6f36528e3bb27
- author
- bnema · · 2025-11-16 18:24 UTC
- committer
- bnema · · 2025-11-16 19:14 UTC
- parent
- 347686c
- signature
- unsigned
1 file · +37 -0
M internal/app/browser/window_shortcuts.go +37 -0
| @@ -63,6 +63,11 @@ func (h *WindowShortcutHandler) registerGlobalShortcuts() error { | |||
| 63 | 63 | {"ctrl+t", h.handleNewTab, "New tab (no-op)"}, | |
| 64 | 64 | {"ctrl+w", h.handleClosePane, "Close current pane"}, | |
| 65 | 65 | {"F12", h.handleDevTools, "Developer tools"}, | |
| 66 | + | // Page reload shortcuts | |
| 67 | + | {"ctrl+r", h.handleReload, "Reload page"}, | |
| 68 | + | {"ctrl+shift+r", h.handleHardReload, "Hard reload (bypass cache)"}, | |
| 69 | + | {"F5", h.handleReload, "Reload page"}, | |
| 70 | + | {"ctrl+F5", h.handleHardReload, "Hard reload (bypass cache)"}, | |
| 66 | 71 | // Zoom shortcuts - global level for proper active pane targeting | |
| 67 | 72 | {"ctrl+plus", h.handleZoomIn, "Zoom in"}, | |
| 68 | 73 | {"ctrl+equal", h.handleZoomIn, "Zoom in (=)"}, | |
| @@ -181,6 +186,38 @@ func (h *WindowShortcutHandler) handlePrint() { | |||
| 181 | 186 | } | |
| 182 | 187 | } | |
| 183 | 188 | ||
| 189 | + | func (h *WindowShortcutHandler) handleReload() { | |
| 190 | + | h.mu.Lock() | |
| 191 | + | defer h.mu.Unlock() | |
| 192 | + | ||
| 193 | + | if h.app.activePane == nil || h.app.activePane.webView == nil { | |
| 194 | + | log.Printf("[window-shortcuts] No active pane for reload") | |
| 195 | + | return | |
| 196 | + | } | |
| 197 | + | ||
| 198 | + | log.Printf("[window-shortcuts] Reload page -> pane %p", h.app.activePane.webView) | |
| 199 | + | ||
| 200 | + | if err := h.app.activePane.webView.Reload(); err != nil { | |
| 201 | + | log.Printf("[window-shortcuts] Failed to reload page: %v", err) | |
| 202 | + | } | |
| 203 | + | } | |
| 204 | + | ||
| 205 | + | func (h *WindowShortcutHandler) handleHardReload() { | |
| 206 | + | h.mu.Lock() | |
| 207 | + | defer h.mu.Unlock() | |
| 208 | + | ||
| 209 | + | if h.app.activePane == nil || h.app.activePane.webView == nil { | |
| 210 | + | log.Printf("[window-shortcuts] No active pane for hard reload") | |
| 211 | + | return | |
| 212 | + | } | |
| 213 | + | ||
| 214 | + | log.Printf("[window-shortcuts] Hard reload (bypass cache) -> pane %p", h.app.activePane.webView) | |
| 215 | + | ||
| 216 | + | if err := h.app.activePane.webView.ReloadBypassCache(); err != nil { | |
| 217 | + | log.Printf("[window-shortcuts] Failed to hard reload page: %v", err) | |
| 218 | + | } | |
| 219 | + | } | |
| 220 | + | ||
| 184 | 221 | // handleZoomIn increases zoom level by 10% | |
| 185 | 222 | func (h *WindowShortcutHandler) handleZoomIn() { | |
| 186 | 223 | h.handleZoom("in", 1.1) | |
| @@ -63,6 +63,11 @@ func (h *WindowShortcutHandler) registerGlobalShortcuts() error { | |||||
| 63 | {"ctrl+t", h.handleNewTab, "New tab (no-op)"}, | 63 | {"ctrl+t", h.handleNewTab, "New tab (no-op)"}, | ||
| 64 | {"ctrl+w", h.handleClosePane, "Close current pane"}, | 64 | {"ctrl+w", h.handleClosePane, "Close current pane"}, | ||
| 65 | {"F12", h.handleDevTools, "Developer tools"}, | 65 | {"F12", h.handleDevTools, "Developer tools"}, | ||
| 66 | + | // Page reload shortcuts | |||
| 67 | + | {"ctrl+r", h.handleReload, "Reload page"}, | |||
| 68 | + | {"ctrl+shift+r", h.handleHardReload, "Hard reload (bypass cache)"}, | |||
| 69 | + | {"F5", h.handleReload, "Reload page"}, | |||
| 70 | + | {"ctrl+F5", h.handleHardReload, "Hard reload (bypass cache)"}, | |||
| 66 | // Zoom shortcuts - global level for proper active pane targeting | 71 | // Zoom shortcuts - global level for proper active pane targeting | ||
| 67 | {"ctrl+plus", h.handleZoomIn, "Zoom in"}, | 72 | {"ctrl+plus", h.handleZoomIn, "Zoom in"}, | ||
| 68 | {"ctrl+equal", h.handleZoomIn, "Zoom in (=)"}, | 73 | {"ctrl+equal", h.handleZoomIn, "Zoom in (=)"}, | ||
| @@ -181,6 +186,38 @@ func (h *WindowShortcutHandler) handlePrint() { | |||||
| 181 | } | 186 | } | ||
| 182 | } | 187 | } | ||
| 183 | 188 | ||||
| 189 | + | func (h *WindowShortcutHandler) handleReload() { | |||
| 190 | + | h.mu.Lock() | |||
| 191 | + | defer h.mu.Unlock() | |||
| 192 | + | ||||
| 193 | + | if h.app.activePane == nil || h.app.activePane.webView == nil { | |||
| 194 | + | log.Printf("[window-shortcuts] No active pane for reload") | |||
| 195 | + | return | |||
| 196 | + | } | |||
| 197 | + | ||||
| 198 | + | log.Printf("[window-shortcuts] Reload page -> pane %p", h.app.activePane.webView) | |||
| 199 | + | ||||
| 200 | + | if err := h.app.activePane.webView.Reload(); err != nil { | |||
| 201 | + | log.Printf("[window-shortcuts] Failed to reload page: %v", err) | |||
| 202 | + | } | |||
| 203 | + | } | |||
| 204 | + | ||||
| 205 | + | func (h *WindowShortcutHandler) handleHardReload() { | |||
| 206 | + | h.mu.Lock() | |||
| 207 | + | defer h.mu.Unlock() | |||
| 208 | + | ||||
| 209 | + | if h.app.activePane == nil || h.app.activePane.webView == nil { | |||
| 210 | + | log.Printf("[window-shortcuts] No active pane for hard reload") | |||
| 211 | + | return | |||
| 212 | + | } | |||
| 213 | + | ||||
| 214 | + | log.Printf("[window-shortcuts] Hard reload (bypass cache) -> pane %p", h.app.activePane.webView) | |||
| 215 | + | ||||
| 216 | + | if err := h.app.activePane.webView.ReloadBypassCache(); err != nil { | |||
| 217 | + | log.Printf("[window-shortcuts] Failed to hard reload page: %v", err) | |||
| 218 | + | } | |||
| 219 | + | } | |||
| 220 | + | ||||
| 184 | // handleZoomIn increases zoom level by 10% | 221 | // handleZoomIn increases zoom level by 10% | ||
| 185 | func (h *WindowShortcutHandler) handleZoomIn() { | 222 | func (h *WindowShortcutHandler) handleZoomIn() { | ||
| 186 | h.handleZoom("in", 1.1) | 223 | h.handleZoom("in", 1.1) | ||