Skip to content

fix(ui): teardown MCP Apps before unmount - #111124

Merged
fuller-stack-dev merged 4 commits into
mainfrom
codex/mcp-app-parent-teardown
Jul 19, 2026
Merged

fuller-stack-dev merged 4 commits into
mainfrom
codex/mcp-app-parent-teardown

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Jul 19, 2026 •

Copy link
Copy Markdown
Member

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

@fuller-stack-dev
fuller-stack-dev marked this pull request as ready for review July 19, 2026 02:09
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: L maintainer Maintainer-authored PR labels Jul 19, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Jul 19, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Jul 19, 2026
@clawsweeper

clawsweeper Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 18, 2026, 10:13 PM ET / July 19, 2026, 02:13 UTC.

Summary
The PR adds a bounded Control UI unmount gate so MCP App views can finish ui/resource-teardown before their iframe subtree is removed.

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
Persistent data-model change detected: serialized state: ui/src/pages/chat/components/chat-thread.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦐 gold shrimp
Patch quality: 🦐 gold shrimp
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Obtain focused Control UI lifecycle-owner confirmation for rapid replacement, timeout, and retained-target cases.

Risk before merge

  • [P1] The gate can intentionally defer route, split-pane, or virtualized-row commits for up to 250 ms while teardown is pending; a Control UI owner should confirm that coalescing and retained-view restart behavior preserve responsiveness across all three render owners.

Maintainer options:

  1. Confirm lifecycle timing before merge (recommended)
    Require Control UI owner review of teardown timeout, coalesced renders, and retained-target restart behavior before accepting the intentional render delay.
  2. Accept the bounded delay
    Merge with the documented 250 ms maximum delay if maintainers explicitly judge guaranteed connected teardown more important than immediate replacement commits.

Next step before merge

  • [P2] The protected maintainer label and deliberate UI responsiveness-versus-cleanup trade-off require a lifecycle-owner decision, not an automated repair.

Maintainer decision needed

  • Question: Should the Control UI accept a bounded up-to-250-ms render-commit delay to guarantee connected MCP App teardown across route, pane, and virtualized-view replacement?
  • Rationale: The patch intentionally trades immediate UI commit timing for lifecycle cleanup, and the protected maintainer label requires explicit human judgment on that product/runtime trade-off.
  • Likely owner: fuller-stack-dev — They have prior merged MCP Apps implementation history and authored the proposed lifecycle integration.
  • Options:
    • Approve after lifecycle-owner confirmation (recommended): Confirm the gate preserves router, split-pane, and virtualizer invariants under teardown timeout and rapid replacement, then merge the focused lifecycle fix.
    • Narrow the owner coverage: Limit the gate to the render owners proven to detach live MCP App frames if broad chat rendering delays are not acceptable.

Security
Cleared: The provided diff adds no dependency, workflow, permission, credential, or cross-origin policy change; the remaining concern is lifecycle availability rather than a concrete security or supply-chain regression.

Review details

Best 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 changes

Label changes:

  • add P2: This is a bounded Control UI lifecycle improvement with limited, user-visible rendering impact.
  • add merge-risk: 🚨 availability: The branch intentionally delays owner render commits during bounded teardown, so a lifecycle regression could make route, pane, or transcript updates appear stalled.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored PR is outside the external-contributor proof gate; its body nevertheless supplies claimed real Chromium conformance evidence for teardown-before-detach behavior.

Label justifications:

  • P2: This is a bounded Control UI lifecycle improvement with limited, user-visible rendering impact.
  • merge-risk: 🚨 availability: The branch intentionally delays owner render commits during bounded teardown, so a lifecycle regression could make route, pane, or transcript updates appear stalled.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored PR is outside the external-contributor proof gate; its body nevertheless supplies claimed real Chromium conformance evidence for teardown-before-detach behavior.
Evidence reviewed

PR surface:

Source +223, Tests +348. Total +571 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 5 279 56 +223
Tests 5 355 7 +348
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 634 63 +571

What I checked:

Likely related people:

What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@fuller-stack-dev
fuller-stack-dev merged commit 7d62a27 into main Jul 19, 2026
94 of 97 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the codex/mcp-app-parent-teardown branch July 19, 2026 02:25
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant