Repository navigation
fix: tray connects to the Gateway as an interactive client - #1909
Conversation
…on identity The tray opts in to gateway-client/ui through GatewayClientFactory so the Gateway treats its long-lived connection as interactive. CLI, setup, and validator clients keep cli/cli. The signed device payload and serialized client use one identity. Disconnect presence beacons no longer count as active or claim a live node. Co-authored-by: Copilot App <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThe PR gives the tray an interactive Gateway identity and prevents stale disconnect beacons from claiming a live node. Example: Companion reconnects while the Gateway retains earlier disconnect beacons.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it addresses behavior still present on main, has relevant real-Gateway evidence, and introduces no actionable defect found in this review. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherApp selects the operator identity through GatewayClientFactory, ConnectEnvelopeBuilder signs and serializes the handshake, and InstanceMerger combines Gateway presence and node data for the Instances page. flowchart LR
A[Tray composition root] --> B[GatewayClientFactory]
B --> C[OpenClawGatewayClient]
C --> D[ConnectEnvelopeBuilder]
D --> E[Gateway]
E --> F[InstanceMerger]
F --> G[Instances page]
Technical reviewBest possible solution: Land the focused identity and presence corrections through the existing factory, envelope builder, and merger. Do we have a high-confidence way to reproduce the issue? Current-main source retains cli/cli identity and timestamp-only presence classification, and the supplied real-Gateway baseline demonstrates both failures. Is this the best way to solve the issue? The patch is the smallest complete correction using existing owners: select one identity for signing and serialization, prioritize live strong matches, and classify disconnected unmatched presence offline. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 65c7ddba163e. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed October 28, 2026, 1:22 PM ET / 17:22 UTC (Revision 3). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Co-authored-by: Copilot App <[email protected]>
|
Hi, I'm a Copilot triage agent, not Scott. I added a small maintainer fix so a |
…1909) * feat(connection): tray operator connects with the interactive Companion identity The tray opts in to gateway-client/ui through GatewayClientFactory so the Gateway treats its long-lived connection as interactive. CLI, setup, and validator clients keep cli/cli. The signed device payload and serialized client use one identity. Disconnect presence beacons no longer count as active or claim a live node. Co-authored-by: Copilot App <[email protected]> * fix(instances): prefer node presence for shared device ids Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: Copilot App <[email protected]>
Ported from upstream 7f6706f (openclaw#1909). OperatorClientIdentity picks the id and mode a connection signs and sends: Cli (cli/cli, the default, as before) or Interactive (gateway-client/ui). The gateway takes a cli connection for a one-off command and gives it no owner profile, so the owner's account methods (users.authConnect.*, the ChatGPT sign-in) were refused. GatewayClientFactory and OpenClawGatewayClient carry the option. Co-Authored-By: Claude Opus 5.5 <[email protected]>
What Problem This Solves
Fixes: the tray's long-lived operator connection identifies itself as
cli/cli, so the Gateway treats it as ephemeral and attaches no owner profile to it. Disconnect presence beacons from a previous connection can also appear active or take a live node from the current connection.User Impact
User impact: the tray connects to the Gateway as an interactive Companion client, and stale disconnect beacons no longer show a node as active. No visible UI change. CLI, setup, validator and node connections are unchanged.
Why This Change Was Made
GatewayClientFactory.ClientIdentity(defaultCli) is set toInteractiveonly by the tray composition root inApp.xaml.cs.ConnectEnvelopeBuilderthen usesgateway-client/uifor both the signed device payload and the serialized client, so they cannot disagree.InstanceMergerlets live beacons claim nodes before disconnect beacons, and a disconnect beacon is offline unless its node is still online. Existing device key, token, role and scopes are unchanged and there is no auth bypass. Two ledger rows are added todocs/ARCHITECTURE.md.This is layer 2 of a local feature split; layer 1 (#1906) is merged.
Evidence
Run on this head with task-owned isolated profile roots, legacy
OPENCLAW_TRAY_LOCAL_DATA_DIRunset and E2E/integration opt-ins unset:./build.ps1: exit 0dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj: 4693 passed, 25 skipped, 0 faileddotnet test ./tests/OpenClaw.Connection.Tests/OpenClaw.Connection.Tests.csproj: 1696 passed, 1 skipped, 0 faileddotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj: 4686 passed, 0 failedConnectEnvelopeBuilderTests+InstanceMergerTests: 83 passedNew tests:
Create_OperatorIdentityIsCliUnlessInteractiveRequested,OperatorIdentity_SignedAndSerializedIdentityMatch_WithoutChangingOtherFields,OperatorIdentity_RealDevicePayloadCoversChosenIdentity,DisconnectReason_IsNotActive_DespiteFreshTimestamp,Reconnect_OldDisconnectRowAndNewRow_OnlyNewIsActive_AndOwnsNode,ConnectedNode_IsNotOverridden_ByStaleDisconnectPresence, plus theAppRefactorContractTestscomposition guard.Change Type
Scope
winnodeRequired proof pools
none: no WinUI visual, WSL/MXC, installer or GPU behavior changed. The change is a connect-envelope identity and presence-merge policy covered by unit and composition tests.Validation
See Evidence for exact commands and counts.
Real Behavior Proof
[email protected](npm, dc2523e) as a task-owned node process on loopback 127.0.0.1 with token auth and isolated state/HOME. The harness drives the productionOpenClawGatewayClientandInstanceMergerbuilt from this head, with real Ed25519 device identities. No Companion UI, WSL or native MSIX Gateway was launched, and all profile roots were task-owned.npm install [email protected] --ignore-scriptsin a temp dir, thennode openclaw.mjs gateway --port <free> --bind loopback --auth token --allow-unconfigured, then the harness scenarios below (token and IP values redacted).N/A(terminal evidence only; no UI claim).role=operator, clientId=gateway-client, mode=uithenDeviceTokenReceived ... HandshakeSucceededafter the pairing request was approved through the Gateway CLI (loopback does not auto-approve).RPC users.self => OK {"profile":{"id":"gateway-owner",...}};sessions.createandchat.historyon that session OK; presence lists the connection asmode=ui reason=connect.gateway-ownerprofile. A second paired interactive device also resolves togateway-ownerand can read the first device's session. Upstreamdocs/concepts/multi-user.mdstates session ownership and visibility are usability features, not security boundaries, so there is no cross-profile rejection to exercise. The PR changes no auth, scopes or session access; the same Gateway session visibility applies toclianduiconnections.chat.sendmarker appears in admin history. Afterdevices revoke, the live socket closes4001 - device removed; reconnect and fresh device-token-only connections fail at handshake withAUTH_DEVICE_TOKEN_MISMATCH, so nochat.historyorchat.sendcan run. Admin history:containsBefore=True containsAfter=False.cli/clireconnects asgateway-client/uiusing only its stored device token:HandshakeSucceeded,PairingRequiredSeen=False, 0 pending pairing requests,users.selfreturnsgateway-owner.mode=ui reason=disconnectbeside the new live one. HEADInstanceMerger:ACTIVE rows: 1, old rows Offline.Baseline (main 326884e) versus head on identical real data:
cli/cliconnection reacheshello-okbutusers.selffails withusers.self requires an authenticated userand the connection is not in presence (the Gateway treatsclias ephemeral). Thegateway-client/uiconnection gets the owner profile and appears in presence.InstanceMergeron the same real presence payload: main reportsACTIVE rows: 5(disconnect beacons shown Active or Idle); head reportsACTIVE rows: 1.Isolation and cleanup: owned Gateway and worker PIDs were stopped by PID and none remain, and the port has no listener. Real
%APPDATA%\OpenClawTrayand~\.openclawwere unchanged. Five files in real%LOCALAPPDATA%\OpenClawTraychanged before this lab's Gateway started, with[test]log lines; no OpenClaw process of this lab was running then, so a concurrent unrelated test run is the likely writer (not proven).extended-stableGateway (2026.9.35) was not run; the stable-Companion check used the same production client with acli/clipairing, not the installed Companion app; no UI/visual proof.Security Impact
NoNoNoNoNoYes, explain the risk and mitigation: N/A. Only the operator client id and mode strings change, and they are covered by the existing device signature.Compatibility and Migration
YesNoNoReview Conversations