Repository navigation
fix(runtime): scope layout.unsubscribe to the caller's connection - #27423
Conversation
A layout stream's cleanup is now registered under a key that includes the subscriber's connection, and layout.unsubscribe builds that key from the caller's own connection, matching session.tabs.unsubscribe. Another connection can no longer end a stream by passing its id.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The change appears ready to merge after normal checks; no concrete regression is established in the supplied evidence. Pre-merge checks |
|
ELI5
The app's layout feed can be cancelled with a "stop" request that names the feed. Before this change, any connected client could stop any other client's feed just by naming it. Now only the client that started a feed can stop it — the same rule the session-tabs feed already follows.
What Changed
layout.unsubscribelooked up the subscription by its id alone, so a request from connection B carrying connection A's id ended A's layout stream.layout:<connection>:<id>), andlayout.unsubscribebuilds that key from the caller's connection. A request from another connection finds nothing and does nothing; the owner's own unsubscribe, connection-close cleanup and abort all work as before.Nobody calls
layout.unsubscribetoday (the layout stream is not advertised and not on the phone allowlist), so there is no user-visible change now; this closes the gap before anything starts using it.Why
session.tabs.unsubscribealready scopes cancellation this way (it buildssession.tabs:<connection>:...from the caller's connection), so this reuses the same rule rather than adding an ownership table or an id check. Changing the public id format instead would rely on ids staying unguessable, which is weaker than not being able to reach another connection's key at all.Compatibility: no wire shape change. Params (
subscriptionId), the result ({ unsubscribed: true }), the frames and the publicsubscriptionIdstring are all unchanged. The only behaviour change is that a cross-connection unsubscribe is now a no-op.Linked Issue
N/A (internal pre-step for the terminal layout work).
Visual Proof
N/A — server-side RPC ownership check with no UI.
Testing
New test in
workspace-layout.test.ts: an unsubscribe from another connection leaves the stream running; the owner's unsubscribe ends it. The new test fails against the old handler and passes with the fix.pnpm tc, oxlint,pnpm run check:code-quality:changedpass.AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)