fix(web): preserve ?server= in URL so F5 reconnects to correct server+repo

Previously, auto-connect immediately stripped ?server= from the URL. This
made the ?project= param useless — F5 would show onboarding instead of
reconnecting. Now ?server= stays in the URL, and the DropZone connect flow
also sets ?server= so both paths support F5 recovery.

The autoConnectRan ref prevents re-trigger within the same session.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Abhigyan Patwari 2026-04-04 08:11:40 +05:30
parent f9f074b67d
commit 10388e43f1

View file

@ -111,9 +111,9 @@ const AppContent = () => {
const serverUrl = params.get('server') || window.location.origin;
const projectParam = params.get('project') || undefined;
// Clean the URL so a refresh won't re-trigger auto-connect
const cleanUrl = window.location.pathname + window.location.hash;
window.history.replaceState(null, '', cleanUrl);
// Keep ?server= in the URL so F5 reconnects to the same server.
// autoConnectRan.current prevents re-trigger within the same session.
// handleServerConnect() will add/update ?project= after connecting.
setProgress({
phase: 'extracting',
@ -219,7 +219,12 @@ const AppContent = () => {
await handleServerConnect(result);
setProgress(null);
if (serverUrl) {
setServerBaseUrl(normalizeServerUrl(serverUrl));
const base = normalizeServerUrl(serverUrl);
setServerBaseUrl(base);
// Add ?server= so F5 reconnects to this server
const url = new URL(window.location.href);
url.searchParams.set('server', base);
window.history.replaceState(null, '', url.toString());
}
}}
/>