feat(FN-3333): fix spurious version reloads with deterministic build

Fixes spurious new-version reloads by making the build version deterministic using the git hash and adding a 60-second cooldown to the version check. Includes unit tests for the version check logic.

Fusion-Task-Id: FN-3333
This commit is contained in:
Fusion
2026-05-03 15:39:31 -07:00
committed by gsxdsm
parent d812427be7
commit 85d02c8291
4 changed files with 228 additions and 4 deletions

View File

@@ -59,10 +59,20 @@ async function fetchRemoteVersion(): Promise<string | null> {
}
}
export const MIN_CHECK_INTERVAL_MS = 60_000; // 1 minute
let lastCheckTime = 0;
let checkInFlight = false;
async function checkVersion(): Promise<void> {
/** Exported for testing — resets internal cooldown state */
export function _resetCheckState(): void {
lastCheckTime = 0;
checkInFlight = false;
}
export async function checkVersion(): Promise<void> {
if (checkInFlight || document.visibilityState !== "visible") return;
if (Date.now() - lastCheckTime < MIN_CHECK_INTERVAL_MS) return;
lastCheckTime = Date.now();
checkInFlight = true;
try {
const remote = await fetchRemoteVersion();