5e4191499764
fix: localhost-first host discovery and cancel inFlight on SAS popup close
- time
- 2026-06-20 02:11 UTC · 4 months ago
- machine
- koh2
- agent
- claude-sonnet-4-6
- session
- pairing handshake fix
- parent
- cfa12cd81206
↓ peach-browser-5e419149.tar.gzatlas at this save
files changed2 files
src/background/desktop-pairing-bg.ts+5 −5src/popup/views/ChirpSync.tsx+8 −0src/background/desktop-pairing-bg.ts+5 −5
@@ -104,11 +104,11 @@104104 export function productionDesktopPairingDeps(): DesktopPairingDeps {105105 return {106106 async findHost(port) {107- // mDNS first — instant and reliable when chrome.mdns is available. But108- // chrome.mdns can hand back stale/duplicate cache entries (e.g. a host109- // that's since gone, or one not running `peach-sync pair`), so only commit110- // to a discovered host that actually accepts a pairing connection right111- // now; otherwise fall through to the probe.107+ // Localhost first: peach-sync runs on the same machine as the extension.108+ // This works in every browser without mDNS or WebRTC, and is the fastest109+ // path. The daemon binds 0.0.0.0 so 127.0.0.1 is always reachable.110+ if (await wsPortOpen("127.0.0.1", port, 800)) return "127.0.0.1";111+ // mDNS next — instant when chrome.mdns is available (Chrome/Chromium).112112 const discovered = await discoverPeachSync();113113 if (discovered && (await wsPortOpen(discovered.ip, port, 800))) return discovered.ip;114114 // Fallback: /24 subnet probe (Firefox, Chrome without mDNS, or a stale hit).src/popup/views/ChirpSync.tsx+8 −0
@@ -227,6 +227,14 @@227227 chrome.runtime.onMessage.addListener(handler);228228 onCleanup(() => chrome.runtime.onMessage.removeListener(handler));229229 }230+ // If the popup closes while the user is on the SAS screen, resolve the231+ // pending background confirm as false so the service worker clears232+ // inFlight and future pairing attempts aren't stuck with "pairing_in_progress".233+ onCleanup(() => {234+ if (desktopPhase() === "sas") {235+ void sendMessage({ type: "DESKTOP_PAIR_CONFIRM", payload: { confirmed: false } });236+ }237+ });230238 });231239 232240 async function handleStartPairing(): Promise<void> {