Skip to content

fix(runtime): scope layout.unsubscribe to the caller's connection - #27423

Merged
Jinwoo-H merged 1 commit into
mainfrom
layout-p14-unsubscribe-scope
Oct 11, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
layout-p14-unsubscribe-scope

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​45 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​39
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​9 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​5

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

  • Before: layout.unsubscribe looked up the subscription by its id alone, so a request from connection B carrying connection A's id ended A's layout stream.
  • After: the stream's cleanup is registered under a key that also contains the subscriber's connection (layout:<connection>:<id>), and layout.unsubscribe builds 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.unsubscribe today (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.unsubscribe already scopes cancellation this way (it builds session.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 public subscriptionId string 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

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

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:changed pass.

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-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

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)
  • 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 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.
@coderabbitai

coderabbitai Bot commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6ca7a989-4ef2-4669-9b8f-6a95f64f9ece

📥 Commits

Reviewing files that changed from the base of the PR and between e8b3981 and 27a9a58.


📒 Files selected for processing (2)
  • src/main/runtime/rpc/methods/workspace-layout.test.ts
  • src/main/runtime/rpc/methods/workspace-layout.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.



📝 Walkthrough

Walkthrough

layout.subscribe now registers cleanup under a key that combines the connection ID and subscription ID. layout.unsubscribe uses the same key. Tests verify that an unsubscribe request from a different connection leaves the subscription active, while a request from the opening connection ends it and calls runtime unsubscribe once.


Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 27a9a

The change appears ready to merge after normal checks; no concrete regression is established in the supplied evidence.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: scoping layout.unsubscribe to the caller's connection.
Description check Passed The description is complete and focused. It explains the behavior before and after the change, the rationale, compatibility impact, testing, and why visual proof is not applicable. The linked issue is…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

  • 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Jinwoo-H
Jinwoo-H merged commit e3d747b into main Oct 11, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant