Repository navigation
fix(ui): teardown MCP Apps before unmount - #111124
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 18, 2026, 10:13 PM ET / July 19, 2026, 02:13 UTC. Summary PR surface: Source +223, Tests +348. Total +571 across 10 files. Reproducibility: unclear. The PR describes concrete route, split-pane, and virtualizer triggers and supplies Chromium proof claims, but this review did not independently reproduce the current-main ordering failure. Review metrics: none identified. Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Merge only after a Control UI lifecycle owner confirms that the bounded connected-frame teardown and replacement-safe restart behavior are correct for routing, split panes, and virtualized transcript eviction. Do we have a high-confidence way to reproduce the issue? Unclear. The PR describes concrete route, split-pane, and virtualizer triggers and supplies Chromium proof claims, but this review did not independently reproduce the current-main ordering failure. Is this the best way to solve the issue? Unclear. An owner-level bounded gate is a plausible way to preserve a connected frame through teardown, but the full current implementation and ext-apps teardown contract require lifecycle-owner confirmation before calling it the best fix. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ead8f691eacf. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +223, Tests +348. Total +571 across 10 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
Merged via squash.
|
* fix(ui): teardown MCP Apps before unmount * fix(ui): keep MCP teardown helpers internal
* fix(ui): teardown MCP Apps before unmount * fix(ui): keep MCP teardown helpers internal
Related: #110515
What Problem This Solves
Fixes an issue where users leaving, replacing, or rerendering a Control UI MCP App view could have its iframe detached before the app acknowledged
ui/resource-teardown. That could skip app cleanup during route changes, split-pane changes, virtualized transcript eviction, or explicit app teardown.Why This Change Was Made
The render owners now hold the outgoing subtree while each nested MCP App performs one bounded teardown, then commit the latest coalesced render. The component owns one resource generation, clears listeners/subscriptions exactly once, removes the iframe only after the teardown response or the named 250 ms timeout, and cannot let a stale teardown remove a replacement. Retained panes and rows stay mounted; only a torn-down view that survives the parent commit is restarted.
The change intentionally does not add a second host, detached-frame cache, compatibility shim, or unbounded render queue.
AI-assisted: yes. I reviewed the complete owner/caller/callee surface and the exact
@modelcontextprotocol/[email protected]teardown contract, and addressed all accepted autoreview findings.User Impact
Control UI MCP Apps now receive their required teardown notification while still connected, including during rerender, view replacement, page changes, and explicit app teardown. Cleanup is bounded, replacement-safe, and does not reset the per-view prompt budget on remount. There is no visual change.
Evidence
pnpm test ui/src/components/mcp-app-view.test.ts ui/src/components/mcp-app-unmount.test.ts ui/src/components/mcp-app-security.test.ts ui/src/app/router-outlet.test.ts ui/src/pages/chat/chat-page.test.ts ui/src/pages/chat/chat-thread.test.ts: 159/159 passed on exact-head Testbox.pnpm check:changed: passed thecoreTests, uilanes, including formatting, core-test/UI typechecks, and full lint.pnpm build: passed, including the Control UI production build, sidecar verification, and performance budgets.pnpm test:ui:e2e ui/src/e2e/mcp-app-conformance.e2e.test.ts: real system Chromium passed. The conformance host observed the Control UI teardown response before iframe detachment; standalone teardown, reload, tool, and resource flows stayed green.