Merge claude/1
This commit is contained in:
commit
b19e5ac3d4
@ -681,6 +681,11 @@ class ServicesManager {
|
|||||||
for (const [name] of this.openLogStreams) this._closeLogStream(name);
|
for (const [name] of this.openLogStreams) this._closeLogStream(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Public hook for the page lifecycle (pagehide). Closes every live log
|
||||||
|
// tail so the browser can BFCache-snapshot the page instead of being
|
||||||
|
// forced into a full reload on back/forward.
|
||||||
|
pauseStreams() { this._stopAllLogs(); }
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
// Status refresh loop (only updates dots/text, not full re-render)
|
// Status refresh loop (only updates dots/text, not full re-render)
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|||||||
@ -170,6 +170,14 @@ class LibrePortalSPAClean {
|
|||||||
// Update browser history
|
// Update browser history
|
||||||
if (addToHistory) {
|
if (addToHistory) {
|
||||||
history.pushState({ route: path }, '', path);
|
history.pushState({ route: path }, '', path);
|
||||||
|
} else {
|
||||||
|
// Even for "don't add to history" navigations (initial route, back-compat
|
||||||
|
// rewrites) we stamp the current entry's state with the resolved route.
|
||||||
|
// Without this the very first history entry has state: null, so popstate
|
||||||
|
// back to it from a later pushState'd entry hits the null guard and
|
||||||
|
// does nothing — exactly the "back button doesn't work" symptom.
|
||||||
|
const here = window.location.pathname + window.location.search;
|
||||||
|
history.replaceState({ route: path }, '', here);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currentRoute = path;
|
this.currentRoute = path;
|
||||||
@ -373,7 +381,7 @@ class LibrePortalSPAClean {
|
|||||||
const taskId = url.searchParams.get('task');
|
const taskId = url.searchParams.get('task');
|
||||||
const canonical = window.appPath(appName, tab, sub, taskId);
|
const canonical = window.appPath(appName, tab, sub, taskId);
|
||||||
if (canonical !== url.pathname + url.search) {
|
if (canonical !== url.pathname + url.search) {
|
||||||
window.history.replaceState({}, '', canonical);
|
window.history.replaceState({ route: canonical }, '', canonical);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -612,11 +620,36 @@ window.navigateToRoute = function(href) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle browser back/forward
|
// Handle browser back/forward. Prefer the route stamped on the history
|
||||||
|
// entry's state; fall back to the URL bar so entries that somehow lack
|
||||||
|
// state (third-party history manipulation, very-early popstate before
|
||||||
|
// init() finished) still re-render the right page instead of no-op'ing.
|
||||||
window.addEventListener('popstate', (e) => {
|
window.addEventListener('popstate', (e) => {
|
||||||
if (e.state && e.state.route && window.spaClean) {
|
if (!window.spaClean) return;
|
||||||
window.spaClean.navigate(e.state.route, false);
|
const route = (e.state && e.state.route) || (window.location.pathname + window.location.search);
|
||||||
}
|
window.spaClean.navigate(route, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Back-forward cache (BFCache) cooperation. Open SSE/WebSocket connections
|
||||||
|
// block the browser from snapshotting the page, so the back button ends up
|
||||||
|
// doing a full reload instead of restoring instantly. Closing every live
|
||||||
|
// bus we own on pagehide lets the snapshot happen; on pageshow with
|
||||||
|
// event.persisted === true the page just came back from BFCache and we
|
||||||
|
// reopen them. Fresh loads also fire pageshow but with persisted=false —
|
||||||
|
// we ignore those because the normal init paths already started everything.
|
||||||
|
window.addEventListener('pagehide', () => {
|
||||||
|
try { window.taskEventBus && window.taskEventBus.stop(); } catch (_) {}
|
||||||
|
try { window.LiveSystem && window.LiveSystem.pause && window.LiveSystem.pause(); } catch (_) {}
|
||||||
|
try { window.servicesManager && window.servicesManager.pauseStreams && window.servicesManager.pauseStreams(); } catch (_) {}
|
||||||
|
});
|
||||||
|
|
||||||
|
window.addEventListener('pageshow', (e) => {
|
||||||
|
if (!e.persisted) return;
|
||||||
|
try { window.taskEventBus && window.taskEventBus.start(); } catch (_) {}
|
||||||
|
try { window.LiveSystem && window.LiveSystem.resume && window.LiveSystem.resume(); } catch (_) {}
|
||||||
|
// Service log tail streams aren't auto-resumed — the user can click
|
||||||
|
// Resume on the overlay if they were tailing a log. Most BFCache restores
|
||||||
|
// are "back to dashboard", so silently dropping the tail is fine.
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle internal link clicks
|
// Handle internal link clicks
|
||||||
|
|||||||
@ -105,6 +105,18 @@ window.LiveSystem = (() => {
|
|||||||
// Fetch the last sample synchronously (or null if the stream hasn't
|
// Fetch the last sample synchronously (or null if the stream hasn't
|
||||||
// produced one yet). Useful for snapshot-style reads without a sub.
|
// produced one yet). Useful for snapshot-style reads without a sub.
|
||||||
get last() { return last; },
|
get last() { return last; },
|
||||||
|
// Force-close the stream and cancel any pending reopen. Used by the
|
||||||
|
// page lifecycle (pagehide) so the browser can put the page into
|
||||||
|
// BFCache; the visibilitychange handler would normally do this too,
|
||||||
|
// but firing explicitly leaves nothing to race.
|
||||||
|
pause() {
|
||||||
|
close();
|
||||||
|
if (reopenTimer) { clearTimeout(reopenTimer); reopenTimer = null; }
|
||||||
|
},
|
||||||
|
// Reopen if anything is still subscribed and the document is visible.
|
||||||
|
// Called from pageshow(persisted=true) when the page is restored from
|
||||||
|
// BFCache.
|
||||||
|
resume() { open(); },
|
||||||
// Test hook: count of active subscribers.
|
// Test hook: count of active subscribers.
|
||||||
get subCount() { return subs.size; }
|
get subCount() { return subs.size; }
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user