feat(mcp): list and close preview tabs - #8724
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Warning Your free Security trial is over. An organization admin can activate Security or dismiss this notice. Comment |
Thread transfer impact
This comment will update automatically after the next completed run. |
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This PR adds two production MCP operations, including destructive tab closure, and changes broker lease and response-ordering behavior used by existing preview automation. Capability gating and focused tests reduce risk, but the cross-component runtime changes and concurrency logic exceed a bounded additive change. No code changes detected at You can add or adjust custom eligibility rules. Learn more. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Bugbot Autofix is ON, but a cloud agent failed to start.
Reviewed by Cursor Bugbot for commit 319a8eb. Configure here.
bb1133e to
e104794
Compare
c01ff20 to
9d2539a
Compare
e104794 to
76b5db2
Compare
b82facd to
2ac9bfe
Compare
76b5db2 to
66853ce
Compare
66853ce to
fe4579d
Compare
|
Superseded as the active MCP proposal by #10559 in the rebuilt MCP stack, following the maintainer request to review thin service wrappers separately from service hardening. This is not a full feature-parity replacement. The existing preview capability and browser-access setting are required. Close uses the existing server/host lifecycle and does not claim renderer cleanup has finished. Broker race hardening is separate. Closing this mixed proposal without merging. The remote branch |

Agents could open and control collaborative browser tabs through MCP, but they could not discover every tab owned by the current thread or close one exact tab without using a client UI.
This adds bounded
preview_listand explicit-tabpreview_closetools. Listing reads only the server preview manager with a thread-bound keyset cursor. Closing uses the manager's existing close event, preserves foreign tabs, and clears the provider session's implicit broker tab behind a sequence barrier so an older automation response cannot restore the closed target.Behavior:
tabId, returns the exact closed ID, and reports missing, foreign, or repeated closes asPreviewSessionLookupError;Focused validation:
tools/list, manager events, broker lease clearing, stable pagination, authority denial, and repeated close;Dependency: standalone sibling based on
agents/mcp-controls/base-490318aat490318afa505d3d033295eca12d7e62b4b922725. It does not depend on the project or queue/input stacks.Implemented by GPT-5.6-Sol via Codex in T3 Code.
Note
Medium Risk
Touches concurrent preview automation broker tab-leasing and close races; incorrect barriers could mis-route automation or leave stale tab targets, though behavior is heavily test-covered.
Overview
Agents can discover and tear down collaborative preview tabs for the current thread via new MCP tools
preview_listandpreview_close, without opening or attaching a browser host for listing.preview_listreads server-tracked sessions only: thread-scoped keyset pagination (cursor/limit), stable cursors (hashed thread binding, size-capped), truncated load-failure diagnostics, and rejection of foreign-thread cursors. Access still requires the credentialpreviewcapability.preview_closerequires an exacttabId, closes throughPreviewManager.closeExact(normal closed events for desktop clients), and callsPreviewAutomationBroker.forgetClosedTabso the provider session’s implicit “current tab” lease is cleared. The broker now commits tab assignments only after successful responses and uses close sequence barriers so in-flight or late host responses cannot resurrect a closed tab or steal routing from another tab; barriers retire on timeout, failure, or interrupt.Wiring includes
PreviewMcpService, contract schemas/errors, toolkit handlers and registration, Claude read-only allowlist updates for annotated read-only preview tools, UI presentation strings, and user/docs notes on agent browser controls.Reviewed by Cursor Bugbot for commit 66853ce. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add Orchestration V2 system with MCP toolkits for preview, orchestrator, and worktree operations
PreviewMcpService(list/close preview tabs with cursor pagination),OrchestratorMcpService(thread/task lifecycle, delegation, scheduling), andWorktreeMcpService(git worktree handoff and status). Each enforces capability-scoped access viaMcpInvocationContext.ComposerBannerprimitives.OrchestrationCommandReceiptschema now requires acommandTypestring field;ProviderInstance.adapterrenamed toorchestrationAdapterwith typeProviderAdapterV2Shape;LatestTurnTiming/SessionActivityStaterenamed toLatestRunTiming/RuntimeActivityStatewithturnId→runIdandactiveTurnId→activeRunId; WebSocket RPC methods switched fromORCHESTRATION_WS_METHODStoORCHESTRATION_V2_WS_METHODS;requireMcpCapabilitysignature narrowed to only accept'preview'; cache schema version bumped to 3 and old V1 entries are auto-discarded on decode failure;ModelSelectionencoding now emits instance-based canonical form instead of legacy provider-based form.Macroscope summarized fe4579d.