fix(webviews): relay local daemon peer state events

Closed
TE
7d ago
+450-3

Local daemon peer transitions currently do not reach the web session's peer state. This narrow source PR intentionally extracts and replaces the stale peer-state carrier in our existing remote-location strip draft #26796 (b749e778f5bb2203333556be9a53ff1437095dc1), which also carries unlanded picker prerequisites. #26796 remains draft and must rebase onto this foundation and remove its superseded carrier hunks before review. This PR supplies the carrier foundation; remote-strip UI completion and real-machine proof remain outstanding.

The owning overlap index covered 482 open PRs. The feature overlap is our own #26796; other overlaps are shared transport or native allowlist files, with no other peer-state adapter identified. This change leaves picker presentation, optional-project behavior, recent folders, defaults, colors, and glass untouched.

The adapter follows the merged daemon contracts from #26756 (honest initialize handshake), #26823 (peer-state events), and #26860 (origin privacy). It enables only when initialize advertises peerStateEvents and reports the local origin used by LOCAL/APP connections. Peer, remote, missing, and unknown origins cannot request or consume peer topology.

  • Read _acpmux/peers {} once after initialization and on each reconnect, then apply _acpmux/peer_state_changed from that same connection. No polling.
  • Fence snapshots by connection/read generation and per-peer revision so an older read cannot overwrite a newer event. Repeated identical observations remain idempotent while still fencing stale reads. Explicitly clear old lastSeen and error values, and reset capability before a reconnect initializes.
  • Add only the missing native _acpmux/peers relay, accepting no parameters and filtering replies to name, state, lastSeen, and error. Existing incoming notification forwarding carries the events. No daemon or session/auth fallback changes.
  • Preserve existing snapshot behavior when the feature is absent.

Validation on Linux at 085467e71042c174e90a7b7a2d748e04e502be08 over 1f723c64fe2a70709ac21b88f10f4bc8bfdf0823: meaningful tests-first red was 3 failures / 4 passes; the repaired integration and reducer suites pass 15 tests / 66 assertions. Full bun --bun run check passes. The supported scoped web prepush helper passes under Bun, and the permitted source-scanner prepush layers report no new violations across all eight changed files. Native policy tests are included but unrun.

The #26809 hold is lifted. No real remote-machine transition, spinner/green/red, no-project Send, light/dark, or gallery capture has been verified. Root owns fresh independent exact-head review, required-check reconciliation, and the final landing loop. Our existing #26796 remains unchanged.

Agent session: agent session


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Relays local daemon peer state events to the web session's peer state, so peer transitions on the local machine show live instead of only at the last _acpmux/status read.

  • Adds a zero-parameter _acpmux/peers native relay that filters replies to name, state, lastSeen, and error.
  • The web client reads one snapshot after initialize and on each reconnect, then applies _acpmux/peer_state_changed notifications; it never polls.
  • Enables the feature only when initialize advertises peerStateEvents and the origin is local/app; other origins and older daemons keep the existing snapshot behavior.
  • Fences snapshot reads per connection/read generation and per-peer revision so stale reads cannot overwrite newer events, and clears nullable lastSeen and error on repeated observations.
  • On an _acpmux/lagged notice, re-reads the snapshot so a peer that went down while the client lagged no longer shows as connected.
  • This is the carrier foundation for draft #26796; remote-strip UI and real-machine validation remain outstanding, and native tests are included but unrun.