[eric] browser: Cmd+R reloads focused browser, else the app (MRU fallback was blocking app reload)

This commit is contained in:
ciregenz
2026-06-26 03:15:30 -07:00
parent 22649ba377
commit 80a8b6a94f
@@ -1,7 +1,7 @@
import React, { useState, useEffect, useRef, useCallback, startTransition, useMemo } from 'react';
import { NavLink, Outlet, useNavigate, useLocation } from 'react-router-dom';
import { openSettingsModal } from '@/shared/state/settingsSlice';
import { getLastInteractedBrowser, getKeepAliveBrowserIds, setLastInteractedBrowser, clearLastInteractedBrowser } from '@/shared/browserFocus';
import { getLastInteractedBrowser, setLastInteractedBrowser, clearLastInteractedBrowser } from '@/shared/browserFocus';
import { getWebview } from '@/shared/browserRegistry';
import Box from '@mui/material/Box';
import ListItemButton from '@mui/material/ListItemButton';
@@ -336,15 +336,14 @@ const AppShell: React.FC = () => {
return () => document.removeEventListener('pointerdown', onPointerDown, true);
}, []);
// Cmd/Ctrl+R: main neutralizes the default-menu reload and hands us the decision. Reload the browser you're in or last used IN PLACE (keeps its login); only when no browser is open at all do we fall back to a full app reload, since reloading the renderer destroys every webview and wipes its session.
// Cmd/Ctrl+R: main neutralizes the default-menu reload and hands us the decision. If you're focused IN a browser, reload just that one in place (keeps its login); the moment you click off into the dashboard it reloads OpenSwarm itself, same as a normal browser tab vs the app window.
useEffect(() => {
const w = window as any;
if (!w.openswarm?.onReloadShortcut) return;
return w.openswarm.onReloadShortcut(() => {
for (const id of [getLastInteractedBrowser(), ...getKeepAliveBrowserIds()]) {
const wv = id ? getWebview(id) : undefined;
if (wv) { try { wv.reload(); return; } catch (_e) { /* torn-down webview; try the next */ } }
}
const id = getLastInteractedBrowser();
const wv = id ? getWebview(id) : undefined;
if (wv) { try { wv.reload(); return; } catch (_e) { /* torn-down webview; fall through to app reload */ } }
window.location.reload();
});
}, []);