Skip to content

test(ui): observe MCP cancellation at the HTTP boundary - #131680

Merged
steipete merged 1 commit into
mainfrom
codex/release-qa-mcp-cancel-observation
Aug 28, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/release-qa-mcp-cancel-observation

Conversation

@steipete

@steipete steipete commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves a problem where full release QA reports failed MCP App cancellation when leaving the standalone page, even though the real Gateway has disconnected and the MCP request has been cancelled. Reproduced from the frozen release-QA candidate in the real-Gateway CI job, then locally with unchanged source.

This is a maintainer-requested full release QA repair, assisted by Codex.

Why This Change Was Made

Chromium can omit requestfailed during document navigation. A separate real-browser HTTP probe confirmed that neither Playwright page/context events nor CDP Network.loadingFailed necessarily report that disconnect, so awaiting the missing event would not fix the evidence.

Observe the actual Gateway HTTP response through Node's documented diagnostics channel instead. The observer is restricted to the test Gateway's local port, POST method and standalone view path. Each scenario captures its exact response before performing cancellation, then requires it to close without finishing; the later successful control request must finish normally. The listener is removed in the existing cleanup block. No request headers, bodies or tickets are added to artifacts.

The exact upstream cancellation ID, cooperative/noncooperative behavior, no-late-response checks, successful control call, and fresh-document/history checks remain intact. No product behavior or timeout changes; production LOC delta is zero, with 42 added/8 removed test and test-support lines after the mechanical refresh. The Node diagnostics contract was checked against installed Node 24 source and the supported Node 22.22.3 source/docs.

User Impact

No user-visible behavior changes. Release QA now checks the actual HTTP disconnect without depending on an event Chromium may omit during navigation.

Evidence

  • Unchanged candidate 871b18dff5039484e86c76d282699a8defcb1654: the full real Chromium/Gateway test failed naturally at the old pagehide POST failure-event assertion. Upstream cancellation still matched the exact call.
  • Fixed full scenario passed twice: 2/2 tests in 105.54s, then 2/2 in 77.05s after restoring the fault injection. Node 24.19.0, Chromium 151.0.7922.34, actual Gateway HTTP/WebSocket, official MCP App and stdio MCP SDK. This mounts the real Control UI component; it is not a full-dashboard smoke test.
  • All five modes (caller timeout, abort, cooperative cancellation, frame teardown, pagehide) recorded a closed response with writableFinished=false, matched upstream cancellation, no late reply, and a successful subsequent control call. Ordinary history back/forward passed; cleanup reported no failures.
  • Negative control: temporarily removing the real fetch abort signal made the test fail specifically because the HTTP response finished normally (writableFinished=true, HTTP 403). The independent SDK timeout still emitted cancellation, demonstrating why correlated cancellation alone cannot substitute for transport proof. Mutation restored; no dependency edits retained or made.
  • Required changed-file gate passed on Blacksmith Testbox tbx_01m13rj72df125cwh4a4kssar6: exitCode0 in13m05.99s, including all core-test and UI typechecks, Knip, i18n, lint, formatting and ratchets. Backing run; the one-shot lease stopped after success, so the backing lease workflow may show cancellation during cleanup.
  • Codex autoreview: clean, no accepted/actionable findings. Targeted formatting and diff checks passed.

Reproduction command:

node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/mcp-app-conformance.e2e.test.ts --reporter=verbose

Named follow-up: sanitized MCP conformance failure-artifact upload. This test writes .artifacts/control-ui-e2e/mcp-app-request-lifetime, while the existing optional CI proof upload collects only the sibling real-gateway directory. Keep that CI artifact-routing improvement separate from this cancellation-evidence repair.

Refreshed-head verification

Mechanically rebased to resolve the conflict with #131690's partial polling repair. Reviewed/pushed head: dafd9df3b6e5f07751a7a8813524282f558d6acc. Both resulting files are byte-for-byte identical to the original reviewed head dbbae686193487b967218df005c03fffbfb86c18; the old polling assertion is removed, not retained alongside HTTP observation. Production +0/-0; E2E +19/-8; test support +23/-0.

Fresh isolated Codex autoreview on the resolved diff passed with no accepted/actionable findings (default P0 scope). Diff whitespace and patch-equality checks passed. No source edits followed review.

Fresh Linux proof on Blacksmith Testbox tbx_01m13y6y69pmv7j9anb85rh31b (backing run 33163043879):

  • Node 24.19.0, Chromium 151.0.7922.34: complete conformance file 2/2 passed in 92.77s.
  • Caller timeout, caller abort, cooperative cancellation, frame teardown, and pagehide each recorded closed=true, writableFinished=false. Each subsequent control completed normally; request-ID correlation, late-reply suppression and connection reuse assertions passed.
  • Ordinary back/forward history completed; cleanup recorded failures: []. BFCache restoration remains unproven and is not claimed. This is the real source-mounted component/Gateway/stdio/official App flow, not a full-dashboard smoke test.
  • Sibling Gateway HTTP cancellation suite 7/7 passed in 7.88s.
  • Changed-file gate passed; the complete Testbox proof command exited 0 in 16m1.383s. The owned lease is stopped and confirmed completed.
  • Exact-head CI 33163017681 completed successfully. Workflow Sanity 33163017659 passed. Native review artifacts validated as READY FOR /prepare-pr, and OPENCLAW_TESTBOX=1 scripts/pr prepare-run 131680 passed with selection.mode=exact-head, without moving the reviewed SHA.

Commands:

node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/mcp-app-conformance.e2e.test.ts --reporter=verbose
node scripts/run-vitest.mjs src/gateway/mcp-app-standalone-cancellation.test.ts --reporter=verbose
node scripts/check-changed.mjs -- ui/src/e2e/mcp-app-conformance.e2e.test.ts ui/src/test-helpers/mcp-app-conformance-fixture.ts
git diff origin/main...HEAD --check
git diff --exit-code dbbae686193487b967218df005c03fffbfb86c18 HEAD -- ui/src/e2e/mcp-app-conformance.e2e.test.ts ui/src/test-helpers/mcp-app-conformance-fixture.ts

The old failed UI shard (33157532185/job/98803949528) actually timed out waiting for Recovered paragraph 1 in the transcript pointer case. The refreshed base contains #131539's repair (90b7950ccdcffbd9a87cec29d44951a9c9a5efce), and the refreshed shard passed. No unrelated repair was added here.

ClawSweeper's 09:09 UTC review had no actionable code findings; its expect_output deadline expired at Vitest RUN before the scenario executed. The fresh real-browser results above address its after-fix proof request and Rank-up move. Its automatic re-review may finish independently; no review placeholder substitutes for the actual CI gate.

The refreshed 10:29 UTC ClawSweeper review also found no actionable code/security defect. Its only Rank-up move was green exact-head required CI; that is now satisfied. Native prepare passed; land-ready on the unchanged reviewed head. Live matching rules require GitHub Actions openclaw/ci-gate and no independent approval rule; no bypass is used.

@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: XS maintainer Maintainer-authored PR labels Aug 28, 2026
@steipete
steipete marked this pull request as ready for review August 28, 2026 08:59
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision. labels Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 6:29 AM ET / 10:29 UTC.

ClawSweeper review

What this changes

The PR changes MCP App browser conformance tests to observe the Gateway’s actual HTTP response lifecycle rather than rely on a Playwright failure event during cancellation.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. This is a distinct, correctly scoped repair for a current-main cancellation assertion that remains brittle after the earlier polling fix; no blocking code or security finding was found, but exact-head CI is still running.

Priority: P2
Reviewed head: dafd9df3b6e5f07751a7a8813524282f558d6acc

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, owner-boundary test repair with no blocking source finding; exact-head CI remains the remaining merge gate.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored test-only PR is exempt from the external-contributor proof gate; its body nevertheless records focused after-fix real Gateway and Chromium runs.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored test-only PR is exempt from the external-contributor proof gate; its body nevertheless records focused after-fix real Gateway and Chromium runs.
Evidence reviewed 6 items Introduced observer scope: The new test-support observer retains only Gateway-local POST requests to the standalone view endpoint and returns an unsubscribe closure.
Cancellation correlation: Each serial scenario snapshots responses before its call, waits for the matching tool start, binds exactly one response, and then requires destruction without a finished write; the following control call must finish normally.
Gateway owner boundary: The real standalone handler installs client-disconnect watching for POST requests, propagates its abort signal through the MCP operation, and does not write a result after that signal aborts.
Findings None None.
Security None None.

How this fits together

A standalone MCP App sends tool calls from its browser host to the Gateway’s view endpoint. The Gateway owns the HTTP disconnect signal that cancels the MCP operation, and this test verifies that boundary while confirming a later control call still completes.

flowchart LR
  Browser[Standalone MCP App browser]
  Call[Tool-call request]
  Gateway[Gateway view endpoint]
  Observer[HTTP response observer]
  Cancel[Abort or page exit]
  MCP[MCP tool runtime]
  Control[Later control call]
  Browser --> Call --> Gateway --> MCP
  Observer --> Gateway
  Cancel --> Browser
  Gateway --> Observer
  Control --> Gateway
Loading

Before merge

  • Resolve merge risk (P1) - Exact-head required checks are still in progress, so merge readiness remains unproven despite the focused source review.
  • Complete next step (P2) - No mechanical repair is indicated; this PR needs ordinary exact-head CI completion and maintainer merge handling.
Agent review details

Security

None.

PR surface

Source +23, Tests +11. Total +34 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 23 0 +23
Tests 1 19 8 +11
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 42 8 +34

Review metrics

Metric Value Why it matters
Production versus test delta production +0/-0; E2E test +19/-8; test support +23/-0 The entire 42-added/8-removed patch is confined to cancellation conformance evidence and adds no runtime behavior.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the boundary-level assertion once the exact reviewed head has green required CI; retain the browser-event diagnostics only as supplemental evidence, not as the cancellation oracle.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the boundary-level assertion once the exact reviewed head has green required CI; retain the browser-event diagnostics only as supplemental evidence, not as the cancellation oracle.

Do we have a high-confidence way to reproduce the issue?

Yes, at high confidence: current main retains the exact brittle assertion and the PR supplies a focused real Gateway/Chromium command and before/after result. This restricted review host could not independently open a loopback listener, so it did not rerun the scenario.

Is this the best way to solve the issue?

Yes. The Gateway response is the owner of the disconnect fact; polling a browser event is only a partial mitigation because navigation can omit that event entirely.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 811e32c1ca67.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored test-only PR is exempt from the external-contributor proof gate; its body nevertheless records focused after-fix real Gateway and Chromium runs.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: needs maintainer proof decision: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This improves release-QA reliability for an existing MCP App cancellation path without changing user-facing runtime behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored test-only PR is exempt from the external-contributor proof gate; its body nevertheless records focused after-fix real Gateway and Chromium runs.

Evidence

What I checked:

  • Introduced observer scope: The new test-support observer retains only Gateway-local POST requests to the standalone view endpoint and returns an unsubscribe closure. (ui/src/test-helpers/mcp-app-conformance-fixture.ts:12, dafd9df3b6e5)
  • Cancellation correlation: Each serial scenario snapshots responses before its call, waits for the matching tool start, binds exactly one response, and then requires destruction without a finished write; the following control call must finish normally. (ui/src/e2e/mcp-app-conformance.e2e.test.ts:721, dafd9df3b6e5)
  • Gateway owner boundary: The real standalone handler installs client-disconnect watching for POST requests, propagates its abort signal through the MCP operation, and does not write a result after that signal aborts. (src/gateway/mcp-app-standalone.ts:350, 811e32c1ca67)
  • Node diagnostics contract: Direct inspection of embedded Node 22.23.2 and 24.19.0 source shows http.server.request.start publishing the exact request and response before server.emit('request', req, res).
  • Current-main necessity: Current main still contains the prior requestfailed polling assertion and lacks the introduced HTTP observer; the reviewed head is not contained by fetched main. (ui/src/e2e/mcp-app-conformance.e2e.test.ts:791, 811e32c1ca67)
  • Related merged partial fix: The earlier merged polling repair is an ancestor of this PR, but it only waits for browser requestfailed; current source confirms that event remains the assertion replaced here. (ui/src/e2e/mcp-app-conformance.e2e.test.ts:791, 4ef3b14275f4)

Likely related people:

  • steipete: Authored the current branch and the earlier merged cancellation-evidence repair in the same conformance test. (role: recent test-area contributor; confidence: high; commits: dafd9df3b6e5, 4ef3b14275f4; files: ui/src/e2e/mcp-app-conformance.e2e.test.ts, ui/src/test-helpers/mcp-app-conformance-fixture.ts)
  • tzy-17: Authored the existing Gateway request-lifetime repair underpinning the cancellation invariant. (role: cancellation-lifetime feature owner; confidence: high; commits: a29e5c9a312f; files: src/gateway/mcp-app-standalone.ts, src/gateway/mcp-app-standalone-cancellation.test.ts)
  • Jason (Json): Authored the ticketed standalone MCP App host feature from which this E2E surface originates. (role: original standalone-host contributor; confidence: medium; commits: 2a2e97b96057; files: src/gateway/mcp-app-standalone-host.ts, ui/src/e2e/mcp-app-conformance.e2e.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Wait for the exact reviewed head’s required checks to finish successfully before merge.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

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

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-28T09:09:24.487Z sha dbbae68 :: needs real behavior proof before merge. :: none

@steipete

steipete commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor Author

I independently confirmed the missing-event case with pinned Chromium 151.0.7922.34 and an isolated local HTTP server. A normal explicit fetch abort closed the captured HTTP response unfinished and produced Page, BrowserContext, and CDP failure events. Navigating the same page to about:blank also closed the exact response with destroyed=true and writableFinished=false, but produced none of those browser failure events during a 16-second observation window.

That distinguishes this from the delayed-callback interleaving covered by #131690, which I landed earlier. Its polling change is only a partial repair and does not supersede this PR. The exact-response observation here is the correct owner-boundary proof; it also retains the negative control that prevents an independent upstream deadline from masquerading as browser cancellation.

I also checked Node 22.22.3's source: the diagnostics payload is published before the real request handler, including its exact request and response objects. The installed Node 24 source has the same ordering.

I am taking this existing PR through the mechanical conflict refresh and normal native landing gates, preserving the HTTP-boundary repair rather than creating another replacement. No production change, timeout increase, or approval bypass is needed. Fresh exact-head CI remains required before merge.

Land-ready update: the mechanical refresh is pushed as dafd9df3b6e5f07751a7a8813524282f558d6acc, and both changed files remain byte-for-byte identical to the reviewed original. Production LOC +0/-0; tests/support +42/-8. No source edits followed fresh isolated Codex autoreview, which passed with no accepted/actionable findings (default P0 scope).

Exact-head CI 33163017681 completed successfully, including every UI E2E shard and the real-Gateway lane. Fresh Blacksmith Testbox proof (owned lease tbx_01m13y6y69pmv7j9anb85rh31b, backing run 33163043879) passed conformance 2/2 in 92.77s on Chromium 151.0.7922.34/Node 24.19.0, sibling HTTP cancellation 7/7, and the changed-file gate. Complete command exit 0 in 16m1.383s; lease stopped and confirmed completed. All five exact responses closed unfinished, subsequent controls finished, history completed, and cleanup had no failures. The PR body records exact commands and preserves the negative control and proof limits.

Native review artifacts validated READY FOR /prepare-pr; OPENCLAW_TESTBOX=1 scripts/pr prepare-run 131680 passed using exact-head hosted evidence and did not change the SHA. The 10:29 UTC ClawSweeper review found no actionable defect; its remaining exact-head CI Rank-up move is satisfied. Live rules require GitHub Actions openclaw/ci-gate, with no independent approval rule. Proceeding only through native scripts/pr merge-run 131680, without bypass.

@steipete steipete self-assigned this Aug 28, 2026
@steipete
steipete force-pushed the codex/release-qa-mcp-cancel-observation branch from dbbae68 to dafd9df Compare August 28, 2026 10:20
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision. labels Aug 28, 2026
@steipete
steipete merged commit 4d9187a into main Aug 28, 2026
179 checks passed
@steipete
steipete deleted the codex/release-qa-mcp-cancel-observation branch August 28, 2026 10:44
@steipete

Copy link
Copy Markdown
Contributor 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 P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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