mirror of
https://github.com/Shik3i/KoalaSync.git
synced 2026-08-28 03:27:10 +00:00
fix(extension): trust HOST_BLOCKED as authoritative (join race, EC-5)
hcmHandleBlocked no longer re-checks local control mode before acting. Background only sends HOST_BLOCKED to a gated guest, so the message itself is authoritative — adopt host-only/guest role from it. Fixes the join race where a HOST_BLOCKED arriving before the CONTROL_MODE broadcast was silently ignored. Also corrects the EC-4 note: "let catch-up re-sync" is invalid (sync is event-driven, no continuous catch-up); the right fix is a buffer-aware deferred snap-back. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -175,7 +175,12 @@
|
||||
|
||||
// Entry point: background told us our local action was blocked in host-only.
|
||||
function hcmHandleBlocked(action, target) {
|
||||
if (!hcmIsGuestGated()) return;
|
||||
// HOST_BLOCKED is only ever sent to a gated guest (background verifies
|
||||
// host-only + !host before sending), so it's authoritative. Adopt the
|
||||
// role/mode from it in case our CONTROL_MODE broadcast hasn't landed yet
|
||||
// (join race, EC-5) — otherwise we'd miss the dialog/snap-back.
|
||||
hcmControlMode = 'host-only';
|
||||
hcmAmHost = false;
|
||||
if (Date.now() < hcmSnapBackCooldownUntil) return; // EC-4 loop guard
|
||||
if (hcmDesynced) return; // already solo, nothing to do
|
||||
|
||||
|
||||
Reference in New Issue
Block a user