Skip to content

firmware: on the Relay's unlinked, end only the computer's link - #146

Merged
longzhi merged 1 commit into
mainfrom
claude/relay-unlinked-keeps-socket
Oct 13, 2026
Merged

longzhi merged 1 commit into
mainfrom
claude/relay-unlinked-keeps-socket

Conversation

@longzhi

@longzhi longzhi commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Problem

RelayBox::message handled {"t":"unlinked"} by calling gone(), which is meant for the socket closing. Per docs/relay-protocol.md, unlinked to the box only ends the link of the computer linked through the Relay (gone, released, unpaired, takeover); the socket stays open. After such an unlink:

  1. welcomed was cleared, so report() sent nothing until the next welcome: the Relay stopped hearing about pairing changes and USB/LAN links (e.g. a computer plugging in, which the Relay needs to know to refuse other links).
  2. relay_up went false, so the NETWORK view showed the Relay as DOWN while the socket was up.

(The link mark is unaffected: it doesn't read relay_up, and the Relay link has ended anyway.)

Fix

On unlinked, call firmware.relay_linked(now, None) and drop peer; keep welcomed, the reported state and relay_up. gone() stays for the socket closing.

If #144 (Noise sessions) lands first, this arm should also drop the Noise session and call board.relay_peer(None); whichever merges second picks that up.

Tests

New relay::unlinked_ends_only_the_computers_link: after unlinked, the NETWORK view still shows PROD (plain), and pairing a second computer over the cable is reported (paired + linked via usb). It failed before the fix (PROD DOWN). cargo test in firmware-rs/core passes; the device crate builds (cargo check --release). Not tried on the box.

🤖 Generated with Claude Code

`unlinked` from the Relay means the computer linked through it is gone
(takeover, the computer dropped, unpaired); the box's socket stays open.
RelayBox handled it like a closed socket: it marked the Relay down and
reset itself, so the NETWORK view read "DOWN" and the box stopped
reporting pairing and USB/LAN changes until its next welcome.

Now it ends the computer's link and keeps welcomed, the reported state
and relay_up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 13, 2026 09:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@longzhi
longzhi merged commit cbb73fd into main Oct 13, 2026
2 checks passed
@longzhi
longzhi deleted the claude/relay-unlinked-keeps-socket branch October 13, 2026 09:28
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.

2 participants