You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(pairing): drop only the syncing desktop's relayed phones - #51226
When your Mac relays your phone to an Orca server, the server keeps one "phone via this Mac" entry per phone. Each time the Mac tells the server "these are my phones", the server removes the ones not on the list. Until now it removed every phone under that Mac's server pairing, even ones that belong to another Mac sharing the same pairing, and it could never remove phones a Mac left behind under an older pairing. Now the Mac says which installation it is, and the server removes only that installation's phones, wherever they were added.
Files
Added
Deleted
Net
Test
2
$\color{#1a7f37}{\Huge{\mathbf{+}}}$44
$\color{#cf222e}{\Huge{\mathbf{−}}}$1
$\color{#1a7f37}{\Huge{\mathbf{+}}}$43
Prod
9
$\color{#1a7f37}{\Huge{\mathbf{+}}}$67
$\color{#cf222e}{\Huge{\mathbf{−}}}$20
$\color{#1a7f37}{\Huge{\mathbf{+}}}$47
What Changed
pairing.delegatedMobileDevice.sync takes an optional clientInstanceId (the desktop installation id that the account declaration already sends). A new runtime capability, pairing.delegated-mobile-devices-origin.v1, says a server accepts it. The params schema is .strict(), so a desktop sends the field only to servers that advertise the capability.
The server works out which rows to drop in one place, droppedDelegatedPhones:
It drops unwanted phones of the syncing installation under any of that installation's rows, so a phone minted under a row from before a re-pair can still be removed.
It drops unwanted phones that no installation has claimed, but only under the calling row, as before.
It never touches phones another installation claimed on a shared row.
When the sync carries no id (an older desktop), the server falls back to the socket's declared installation. If that declaration hasn't arrived yet (it is fire-and-forget), the sync drops only unclaimed phones, not every child under the row.
DeviceRegistry.listDelegatedMobileDevices had one remaining caller and is removed.
Why
Phones are about to get server pairings of their own, chained to these delegated rows (the next PRs in this stack). After that, deleting a delegated row is what revokes a phone's direct access, so the server has to delete exactly the right rows:
Removing too many cuts off another desktop's phones.
Never removing the rows under an old pairing leaves an unpaired phone with access.
The origin used to come only from the socket's async declaration, which usually arrives after the first sync. Sending it in the sync itself takes that race away for new desktops.
The capability gate keeps every version pairing working:
New desktop, old server: the old server never sees the new field.
Old desktop, new server: keeps today's behaviour, except that it no longer drops phones another installation has claimed.
Linked Issue
Part of #40079, #27988, #26291 and #10426. Those issues are fixed once phones can mint their own server pairings later in this stack; this PR makes revocation of those pairings exact.
Visual Proof
N/A: no UI changes. The proof is a real three-process run, described under Testing.
Testing
Real run on macOS with two worktree-built orca serve processes: a server, and a "desktop" paired to the server as a runtime environment. A phone-protocol client was paired to the desktop as a mobile device.
The phone's status.get tagged with the server's execution host was relayed and answered by the server's runtime.
The server's orca-devices.json gained one mobile row: parentDeviceId is the desktop's runtime row, phoneKey is the phone's device id on the desktop, and originClientInstanceId is the desktop's installation id, now sent in the sync params.
delegated-mobile-devices.test.ts pins the drop rule for desktops sharing one row and for a row left behind by a re-pair. It fails against the old filter.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Performance
None, because this changes only how the server picks rows on a sync it already does. It is one pass over the device list instead of a filtered pass, with no new syncs, reads or writes. The desktop's installation id is already cached in memory for the account declaration.
Risk
The riskiest part is the drop rule, because it decides which phones lose access.
Too loose: another desktop's phones on a shared row would be cut off, and they would recover on that desktop's next sync.
Too strict: a phone this desktop unpaired would keep its delegated row until a later sync. Today only the desktop holds that row's token, so the phone can't use it.
A paired desktop could claim another installation's id. It already holds workspace permission on the server, which lets it run terminals there, so the claim gives it no new power. A plain revert restores the old drop rule.
Level: Medium
AI Disclosure
Review
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
The server side is shared by Electron serve and orcad. The desktop side changes only the params of a sync it already sends.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
A server dropped every relayed phone under a desktop's row on each sync, so
desktops sharing one row revoked each other's phones, and phones a desktop
minted under its row from before a re-pair could never be cut. The sync now
names the desktop's installation, and the server drops only that
installation's unwanted phones, on any row.
No actionable comments were generated in the recent review.
Walkthrough
Delegated phone sync can include the desktop client instance ID when the host advertises the origin-runtime capability. The RPC path forwards that ID to the server. The server uses the ID to select unwanted delegated child devices for removal while retaining phones associated with other installations. Tests cover selection across installations and rows.
Merge Risk: Low · up to 19df2
Delegated phone sync now removes only the syncing desktop's phones, including phones left under an older pairing. The server uses the installation ID the client sends without checking it against the caller's declared installation. A paired desktop could therefore remove another installation's relayed phones, and those would be re-created on that desktop's next sync. The author has accepted this tradeoff, and the exposure is limited to already-paired devices that hold broad workspace access. The remaining risk is low, but the owner should know about it before merging.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: the server now drops only the syncing desktop's relayed phones. It is a conventional fix(pairing) title, short, and matches the changeset (droppedDelegatedPhones, clie…
Description check
The description follows the repository template. It includes ELI5, What Changed, Why, Linked Issue, Visual Proof (N/A with reason), Testing with a real three-process macOS run, Performance, Risk with …
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: the server now drops only the syncing desktop's relayed phones. It is a conventional fix(pairing) title, short, and matches the changeset (droppedDelegatedPhones, clientInstanceId in sync, shared-row handling). It is 60 characters, which is within a normal title length.
Full details: Description check
Explanation
The description follows the repository template. It includes ELI5, What Changed, Why, Linked Issue, Visual Proof (N/A with reason), Testing with a real three-process macOS run, Performance, Risk with level and revert path, and the checklist. Gaps: the Risk section's Level is filled in as Medium, which is fine. The AI Disclosure section is empty, but the template says to ignore it for internal contributors, so this is not a defect unless the author is external. The Linked Issue uses 'Part of' references rather than 'Fixes #', which the template says must be an actual issue. The lint/typecheck/test/build checklist item is left unchecked.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: a7a75369-a436-4e16-be13-522cc27780dd
Commits
Reviewing files that changed from the base of the PR and between 9c44c9e and 19df2c2.
Files selected for processing: 1
src/main/runtime/rpc/core.ts
Files skipped from review as they are similar to previous changes: 1
src/main/runtime/rpc/core.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
When your Mac relays your phone to an Orca server, the server keeps one "phone via this Mac" entry per phone. Each time the Mac tells the server "these are my phones", the server removes the ones not on the list. Until now it removed every phone under that Mac's server pairing, even ones that belong to another Mac sharing the same pairing, and it could never remove phones a Mac left behind under an older pairing. Now the Mac says which installation it is, and the server removes only that installation's phones, wherever they were added.
What Changed
pairing.delegatedMobileDevice.synctakes an optionalclientInstanceId(the desktop installation id that the account declaration already sends). A new runtime capability,pairing.delegated-mobile-devices-origin.v1, says a server accepts it. The params schema is.strict(), so a desktop sends the field only to servers that advertise the capability.droppedDelegatedPhones:DeviceRegistry.listDelegatedMobileDeviceshad one remaining caller and is removed.Why
Phones are about to get server pairings of their own, chained to these delegated rows (the next PRs in this stack). After that, deleting a delegated row is what revokes a phone's direct access, so the server has to delete exactly the right rows:
The origin used to come only from the socket's async declaration, which usually arrives after the first sync. Sending it in the sync itself takes that race away for new desktops.
The capability gate keeps every version pairing working:
Linked Issue
Part of #40079, #27988, #26291 and #10426. Those issues are fixed once phones can mint their own server pairings later in this stack; this PR makes revocation of those pairings exact.
Visual Proof
N/A: no UI changes. The proof is a real three-process run, described under Testing.
Testing
Real run on macOS with two worktree-built
orca serveprocesses: a server, and a "desktop" paired to the server as a runtime environment. A phone-protocol client was paired to the desktop as a mobile device.The phone's
status.gettagged with the server's execution host was relayed and answered by the server's runtime.The server's
orca-devices.jsongained one mobile row:parentDeviceIdis the desktop's runtime row,phoneKeyis the phone's device id on the desktop, andoriginClientInstanceIdis the desktop's installation id, now sent in the sync params.delegated-mobile-devices.test.tspins the drop rule for desktops sharing one row and for a row left behind by a re-pair. It fails against the old filter.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Performance
None, because this changes only how the server picks rows on a sync it already does. It is one pass over the device list instead of a filtered pass, with no new syncs, reads or writes. The desktop's installation id is already cached in memory for the account declaration.
Risk
The riskiest part is the drop rule, because it decides which phones lose access.
A paired desktop could claim another installation's id. It already holds
workspacepermission on the server, which lets it run terminals there, so the claim gives it no new power. A plain revert restores the old drop rule.Level: Medium
AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
The server side is shared by Electron serve and orcad. The desktop side changes only the params of a sync it already sends.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)