Skip to content

fix(macos): keep Peekaboo nodes connected across unchanged refreshes - #196748

Closed
jalehman wants to merge 1 commit into
mainfrom
fix/macos-peekaboo-provider-generation
Closed

jalehman wants to merge 1 commit into
mainfrom
fix/macos-peekaboo-provider-generation

Conversation

@jalehman

@jalehman jalehman commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes unnecessary Mac node reconnections when an unchanged Peekaboo capability advertisement is read again.

User Impact

Mac nodes advertising Peekaboo retain their admitted connection across unchanged refreshes. Real connect-option changes still reconnect. This affects the existing WebSocket path on main, independently of the OpenClaw ID integration; no particular released version is claimed here.

Existing transport and refresh frequency

Yes: today's non-ID coordinator re-reads the descriptor whenever its connection loop consumes a refresh. This is event-driven, not steady once-per-second polling. Defaults changes, app activation and permission-change notifications call refresh(); unchanged-control refreshes wake the loop without intentionally revoking the route. Its newest-one event buffer can coalesce bursts, so there is no fixed connected-state frequency. Disconnected recovery probes run after 30 seconds; failed connection attempts back off from 1 second to a 10-second cap.

Pinned-main evidence: notification subscriptions, unchanged refresh and connection loop, descriptor preparation, and option equality replacing the channel. The red/green regression exercises this ordinary WebSocket coordinator/session boundary with existing socket fixtures.

Why This Change Was Made

Each descriptor read generated a new provider UUID. GatewayConnectOptions includes that descriptor in equality, so the next coordinator connect replaced its own route. Keep the generation stable for the in-process provider lifetime instead. A new process still gets a new generation. Gateway provider-generation checks and native lifecycle-based stale-observation invalidation are unchanged; pairing and command policy are untouched.

Evidence

  • Baseline: b21829a4c85fb685888538b3bc1369bfb5b36bd4. The new ordinary-WebSocket coordinator/session regression failed on main: consecutive reads produced unequal options, a second socket, and a replacement route.
  • Fixed Studio app/test build passed. The regression and four existing settings/provider siblings passed: 5 tests in 0.017 seconds. The regression also verifies that a genuine option change creates a replacement connection.
  • Targeted SwiftFormat 0.63.1 and SwiftLint 0.65.1 passed for both files; git diff --check passed. Production delta: +4/-1 lines; one boundary regression adds 81 test lines without new production test hooks.
  • Separate integration exercise with the identical production patch: real invocation → cold-process reconnect with the same node identity → successful invocation → signed owner revocation closing one live connection and leaving zero nodes. Identity persisted in a private test file plus SQLite, not production Keychain/preferences. This does not establish staging or GUI/account-sign-in acceptance.
  • Gap: one unchanged bundled-CUA filesystem test was denied access to Foundation's per-user temporary directory by the operator-safe sandbox. It is not counted as passing; the sandbox was not weakened. Full-suite/CI coverage remains unproven.
  • Fresh independent Astra delta review found no verified P0–P2 regression. It confirmed ordinary-WebSocket impact, genuine changed-options reconnection, and separate native lifecycle invalidation. Adopted its test-isolation recommendation to set includeDeviceIdentity: false before publication. The final Studio rebuild and two affected Peekaboo tests passed; the coordinator-requested follow-up of all five runnable focused tests also passed (0.011 seconds) using that same built candidate. No production code changed after review. Review limits: the reviewer did not establish whether process-wide WindowObservationArtifacts cleanup in MacNodeRuntime.shutdown is isolated from parallel tests, and did not review the frame-token lifecycle. CI and the full suite have not been run as part of this proof.

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@jalehman jalehman changed the title fix(macos): preserve Peekaboo provider generation across refreshes fix(macos): keep Peekaboo nodes connected across unchanged refreshes Nov 10, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR retains Peekaboo’s advertised generation across descriptor reads and adds a connection-retention regression.

Example: OpenClaw.app becomes active while a Mac node uses Peekaboo.

  • Before: Rebuilding unchanged connection options generates another UUID and replaces the node connection.
  • After: Unchanged options retain the existing connection; changing the display name from Mac to Renamed Mac still reconnects.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful focused repair with a meaningful boundary regression, but provider-switch generation reuse needs correction.
Proof confidence 🦐 gold shrimp (3/6) The supplied maintainer-authored classification exempts the ordinary contributor proof gate; available evidence is a reported fixture-WebSocket regression, while the separate invocation/reconnect/revocation exercise does not demonstrate unchanged-refresh retention.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Mac nodes reconnect when ordinary refreshes rebuild an unchanged Peekaboo advertisement.
Reason: The reconnect trigger is source-confirmed, and the supplied maintainer-authored direction supports repairing it without new settings.

Merge readiness

⛔ Needs changes before merge - 1 item remains

This PR addresses a current reconnect bug, but its process-wide generation also reuses a retired Peekaboo identity after switching providers.

Priority: P2
Reviewed head: ea82e6fd3f2902e36e7fb8dea4c52d143062c410

Before merge

  • Rotate Peekaboo generation when returning from another provider (P2) - Select Peekaboo, switch to CUA, then select Peekaboo again without restarting the app: this immutable static returns the original Peekaboo generation. The documented provider-switch contract requires generation rotation, and clients such as ComputerToolNode.bindCapabilities use generation changes to discard prior observation state. A client that did not observe the intermediate CUA advertisement therefore sees the retired Peekaboo identity as unchanged. Native lifecycle checks still reject stale references, but the advertised identity no longer signals that retirement. Retain the UUID at the existing coordinator lifecycle owner and replace it on provider changes; add the round-trip case alongside unchanged-refresh retention.

Findings

  • [P2] Rotate Peekaboo generation when returning from another provider — apps/macos/Sources/OpenClaw/ComputerControlProvider.swift:8-9

Tests

  • Missing end-to-end proof: No supplied shipped-entry-point trace demonstrates an unchanged app refresh retaining the connection, and the added regression omits a Peekaboo → CUA → Peekaboo round trip.
Agent review details

How this fits together

The macOS coordinator builds capability descriptors into node connection options, which the shared WebSocket session compares when deciding whether to replace its connection.

flowchart LR
  A[App activation or settings notification] --> B[Mac node coordinator]
  B --> C[Peekaboo descriptor]
  C --> D[Connection options]
  D --> E[Gateway node session]
  E --> F[Retained or replacement WebSocket]
Loading

Technical review

Best possible solution:

Retain generation in the existing coordinator across unchanged refreshes, rotate it on provider replacement, and consolidate the overlapping repair.

Do we have a high-confidence way to reproduce the issue?

Current source deterministically links descriptor reconstruction to unequal options and channel replacement; the author reports a red/green regression, but this review ran no target code.

Is this the best way to solve the issue?

Fixing the descriptor producer is appropriate, but a process-wide constant exceeds the provider lifecycle; the existing coordinator already owns provider transitions.

Full review comments:

  • [P2] Rotate Peekaboo generation when returning from another provider — apps/macos/Sources/OpenClaw/ComputerControlProvider.swift:8-9
    Select Peekaboo, switch to CUA, then select Peekaboo again without restarting the app: this immutable static returns the original Peekaboo generation. The documented provider-switch contract requires generation rotation, and clients such as ComputerToolNode.bindCapabilities use generation changes to discard prior observation state. A client that did not observe the intermediate CUA advertisement therefore sees the retired Peekaboo identity as unchanged. Native lifecycle checks still reject stale references, but the advertised identity no longer signals that retirement. Retain the UUID at the existing coordinator lifecycle owner and replace it on provider changes; add the round-trip case alongside unchanged-refresh retention.
    Confidence: 0.88

Overall correctness: patch is incorrect
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against ecbad2efa1d7.

Provenance checked

  • Peekaboo descriptor generation changes intended behavior with a stated reason (4a6edc0: The original native v2 implementation added capability advertising alongside lifecycle-scoped reference invalidation; its PR gives no reason for identity changing on each descriptor read.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 4a6edc0 adds apps/macos/Sources/OpenClaw/ComputerControlProvider.swift:11 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4a6edc0d27bc; files: apps/macos/Sources/OpenClaw/ComputerControlProvider.swift)

PR surface

Source +3, Tests +81. Total +84 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 4 1 +3
Tests 1 81 0 +81
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 85 1 +84

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +4/-1; tests +81/-0 The test exercises connection and route retention plus genuine option-change reconnection without adding production test hooks.

Root-cause cluster

Relationship: same_root_cause
Canonical: #196085
Summary: Both repair proposals address the same fresh-UUID descriptor and structural-options comparison chain.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Unchanged refreshes cause source-confirmed node connection churn; failed actions, lost work, and broad prevalence are not established.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 10, 2026, 11:55 AM ET / 16:55 UTC.

@jalehman

Copy link
Copy Markdown
Contributor Author

Folded into #196759 by maintainer decision: its exact patch is carried there (stable patch ID matches this PR's head) and is reviewed and CI-tested as part of that PR. Closing in favor of #196759; nothing here is lost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: macos App: macos P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant