Repository navigation
fix(computer): close helper session review gaps - #11428
Conversation
📝 WalkthroughWalkthroughAgent session registration now returns explicit 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
Greptile SummaryThis PR closes three security and correctness gaps in the computer-use helper's session management, all identified in post-merge review of #11425.
Confidence Score: 5/5Safe to merge — all three changed paths (auth gate, session state machine, hot-path lock avoidance) are internally consistent, covered by the updated test suite, and close real gaps without regressing existing behavior. The auth fixes in isAuthenticated and handleRequest are straightforward and complementary: both now require an authorized peer regardless of whether a token is configured. The session state machine change (adding wasReleased) correctly prevents late connections from re-entering the ownership set or triggering a second close callback, and the new test case directly exercises this path. Files Needing Attention: No files require special attention. The three changed files form a tight, self-contained unit and the test file directly validates the new terminal-state behavior.
|
| Filename | Overview |
|---|---|
| native/computer-use-macos/Sources/OrcaComputerUseMacOS/main.swift | Fixes two auth gaps: isAuthenticated now requires authorizedPeer even when no token is configured, and handleRequest now rejects unauthorized peers unconditionally (was gated on expectedToken != nil). A per-connection registrationComplete flag removes lock contention from the steady-state request hot path. |
| native/computer-use-macos/Sources/OrcaComputerUseMacOSCore/AgentSessionOwnership.swift | Adds wasReleased terminal state and richer AgentSessionRegistration enum; session can no longer be re-claimed after the final owner disconnects, and the new return values let callers distinguish claimed/joined/released/rejected without inspecting internal state. |
| native/computer-use-macos/Tests/OrcaComputerUseMacOSTests/AgentSessionOwnershipTests.swift | Adds testReleasedSessionCannotBeReclaimed and updates all existing assertions to the new enum type; coverage now exercises the full state machine including the new terminal-released path. |
Reviews (2): Last reviewed commit: "perf(computer): stop released session re..." | Re-trigger Greptile
* fix(computer): close helper session review gaps * perf(computer): stop released session registration retries
Summary
Follow-up to #11425 that closes all post-merge review findings before the computer-use supervisor work continues.
--agentlaunches, but the lower-level request and lifecycle checks now fail closed independently.sessionLockor mutate the connection set.rejected/sessionReleased/joined/claimedregistration results so the listener distinguishes retryable authentication failures, terminal release, first ownership, and valid joins without repeating work.Behavior and failure contract
The first trusted, token-valid request claims the session and cancels the unclaimed-startup deadline. Additional authenticated connections may join only while that session remains live. The final registered disconnect marks the session released and triggers exactly one close callback. Malformed, untrusted, token-invalid, duplicate, and post-release connections cannot add lifetime.
Normal provider request handling, explicit
terminate, socket permissions, token generation, peer lookup, TCC identity, and caller-owned path cleanup remain unchanged.Testing
swift test --package-path native/computer-use-macos— 43 tests passedpnpm verify:computer-nativepnpm lintgit diff --checkAdded coverage proves a released session cannot be reclaimed. Existing cases continue to cover unclaimed and unauthenticated disconnects, duplicate registration, multiple connections, and last-owner release.
AI Review Report
Reviewed the authentication gate, per-request hot path, session state transitions, concurrent connection ordering, descriptor cleanup, and late-arrival termination window. The new terminal release state closes the redundant callback race, while the connection-local registration flag removes the lock/set operation from authenticated steady-state requests.
No unresolved findings remain in this follow-up.
Security Audit
Screenshots
No UI change.