mirror of
https://github.com/Shik3i/KoalaSync.git
synced 2026-09-04 15:05:20 +00:00
fix(host-control-mode): reconcile desync state on content reinjection
Fixes a split-brain where a guest who chose "watch on my own" and then reloaded the video page would appear stuck as "Solo" to the host while actually being back in sync. Root cause: background persists hcmDesynced (survives SW restart) and attaches it to content-driven heartbeats, but a freshly injected content script started with hcmDesynced=false and GET_CONTROL_MODE never returned the desync state — so content re-applied host commands (synced) while background kept relaying desynced=true to the host. Fix: GET_CONTROL_MODE now also returns desynced; content adopts it on init (re-shows the badge) and also adopts hostPeerId so later host-change resets work. Desync now survives a page reload consistently on both sides, as intended. Verified the full path: background.js heartbeat (1555 omits / 2018 attaches), reset paths, CONTENT_BOOT and keepAlive-disconnect (neither reset it), content sendHeartbeat on inject. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1435,6 +1435,13 @@
|
||||
if (chrome.runtime.lastError || !res) return;
|
||||
hcmControlMode = res.controlMode || 'everyone';
|
||||
hcmAmHost = !!res.amHost;
|
||||
hcmHostPeerId = res.hostPeerId || null;
|
||||
// Re-adopt persisted desync after a page reload so we don't start synced
|
||||
// while background still relays us as "Solo" to the host (split-brain).
|
||||
if (res.desynced && !hcmDesynced) {
|
||||
hcmDesynced = true;
|
||||
hcmShowBadge();
|
||||
}
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user