Skip to content

fix(browser): auto-discover Desktop bridge on ephemeral ports - #98

Open
zzalancelot wants to merge 4 commits into
omdsh-dev:mainfrom
zzalancelot:fix/bridge-port-discovery
Open

zzalancelot wants to merge 4 commits into
omdsh-dev:mainfrom
zzalancelot:fix/bridge-port-discovery

Conversation

@zzalancelot

Copy link
Copy Markdown
Contributor

Summary

Fixes #93 — users on DSH Desktop stay stuck on “Reconnecting…” because Desktop binds a random ephemeral port (--port 0), while the extension only probed a fixed port list and never rediscovered after the first resolve.

  • Layered discovery when settings.bridgeUrl is empty: auto-cache → known CLI/Desktop ports → open loopback tabs → bounded ephemeral-port scan (49152–65535).
  • BridgeClient rediscovers after 3 consecutive probe failures so Desktop restarts are followed without user action; a manual bridgeUrl always wins and is never overwritten.
  • Persist successes in dshBridgeAuto (separate from settings); debounce rediscovery on loopback navigations. close(4000)stopped is unchanged.

Test plan

  • Start DSH Desktop (random port), open the side panel with empty bridge URL → reaches connected; SW log shows resolved ws://127.0.0.1:<port>/ext/bridge.
  • Restart DSH (port changes) → extension follows and reconnects within ~60s without changing settings.
  • Set a wrong manual bridge URL → stays on that address (no auto-correct).
  • CLI dsh web on 3080 → still connects immediately (no ephemeral scan).
  • pnpm --filter dsh-browser-extension run test|typecheck|build
  • Another client taking the bridge (close(4000)) still leaves this client stopped.

Follow DSH Desktop random ports when settings.bridgeUrl is empty via
cached auto URL, known CLI ports, loopback tabs, and a bounded ephemeral
scan, and rediscover after repeated probe failures without overriding
manual addresses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

增加对新DSH版本的支持

1 participant