Skip to content

fix(stream/engine): end a pairing the host refuses by code alone - #87

Draft
enricobuehler wants to merge 1 commit into
mainfrom
fix/pair-refused-by-code
Draft

enricobuehler wants to merge 1 commit into
mainfrom
fix/pair-refused-by-code

Conversation

@enricobuehler

@enricobuehler enricobuehler commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

A PIN the host refuses left the pairing sheet on "Pairing…" for good, with no sentence. Found while checking 0.6.1 against a 0.47.0 host; 0.6.0 does the same.

Cause

The host refuses a pairing with its close code and an empty sentence, and leaves the wording to the client. onClosed ended a pairing only when a sentence came with the close, so a code alone changed nothing and the state stayed pairing.

The case that showed it: a browser that reaches the host through the page server typed a PIN armed for any device. The host wants a PIN bound to that browser and closes with 0x60. Its log says so; the page said nothing.

Change

  • PAIR_REFUSED: the pairing gate's close codes (0x60 to 0x67) with the sentences the monorepo already has for them (reject_not_armed, reject_bound_other, reject_rate_limited, …).
  • onClosed reads the host's sentence, else the code's. A pairing then ends as pair-refused with that sentence. A request for access and a dial get the same sentence where the host sent none: a denied request no longer falls back to the wrong-PIN line, and a dial no longer says "the host closed the session (code 96)".
  • Seven message keys join Words; the page installs them.

Checks

  • npm run check, npm test (142 + 19). The new test pairs, refuses with 0x60 and no sentence, and expects pair-refused with the reject_not_armed text.
  • Live, before the fix: the page server and a 0.47.0 host on loopback, headless Chromium. The sheet still read "Pairing…" 35 s after the host's close, on the 0.6.1 build and on the released 0.6.0 build.
  • Live, after the fix, on this PR's CI build and the same rig: within 6 s of the host's close the sheet shows "Pairing isn't started on the host — start it on the Devices page of the host's web console, then try again." under the PIN field, and Pair is active again.

Not in this PR

The sentence for 0x60 says pairing isn't started on the host. For a browser behind the page server the real cause is that the PIN is not bound to this device. Telling the two apart needs the host to say which, or a code of its own.

A host refuses a pairing with its close code and no sentence, and leaves
the wording to the client. The engine ended a pairing only on a sentence,
so a PIN the host would not take left the sheet on "Pairing…" for good.

The pairing gate's codes read as the page's own sentences wherever the
host sends none: in a pairing, a request for access, a dial.
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.

1 participant