Skip to content

fix(ui): release deferred responses on socket close - #120554

Closed
vincentkoc wants to merge 1 commit into
mainfrom
fix/ui-request-scoped-deferrals-20260808
Closed

vincentkoc wants to merge 1 commit into
mainfrom
fix/ui-request-scoped-deferrals-20260808

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 8, 2026 •

Copy link
Copy Markdown
Member

Root cause

The serialized Control UI mock Gateway retained deferred responses after their owning WebSocket closed. Method settlement could then select a stale response, attempt delivery to the closed socket, and leave the replacement socket waiting without a visible result.

Repair

MockWebSocket.close() now removes only deferred responses owned by that socket. The socket lifecycle remains the cleanup owner, while method deferrals, held methods, parameter matching, count cursors, and request logs keep their existing behavior.

This changes test infrastructure only. Production behavior is unchanged.

Files

  • ui/src/test-helpers/control-ui-e2e.ts
  • ui/src/test-helpers/control-ui-e2e.deferral.test.ts

Proof

  • Exact head: 4b8c42ef60f828b08e746981a83013ce1389663b
  • Failing before repair: the regression left the replacement socket without a response after the stale predecessor consumed settlement.
  • Fixture suites: 16/16 passed.
  • Reconnect E2E scenarios: 40/40 passed.
  • P1 autoreview: clean, no actionable findings.
  • LOC: production +0/-0; test support +44/-0.
  • Current-main drift does not touch either changed file; merge-tree is clean.
  • tsgo:ui and check:changed remain blocked by four unrelated current-main assertBeforeRename type errors in src/infra/install-package-dir.ts.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: M maintainer Maintainer-authored PR labels Aug 8, 2026
@vincentkoc vincentkoc self-assigned this Aug 8, 2026
@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. labels Aug 8, 2026
@vincentkoc
vincentkoc force-pushed the fix/ui-request-scoped-deferrals-20260808 branch from efc1d2e to c2e4dc1 Compare August 8, 2026 11:22
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Exact head: 3e30e2e54679b794e7641e9551b2ac50c4494a63.

@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. and removed 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. labels Aug 8, 2026
@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 2, 2026, 4:35 PM ET / 20:35 UTC.

ClawSweeper review

What this changes

This PR makes Control UI mock-Gateway deferred responses request-scoped and updates reconnect, question-recovery, and catalog-history E2E tests to use deterministic controls.

Regression provenance

Possible regression — probable (reviewed change; known regression link). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep open for maintainer handling. The member-authored, maintainer-labeled PR is not mergeable against current main, and its test-harness API and global test setup must be reconciled with newer merged fixture contracts before it can land.

Priority: P2
Reviewed head: 3e30e2e54679b794e7641e9551b2ac50c4494a63

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The proposed test coverage is useful, but the stale branch has two concrete fixture-contract blockers before merge.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored test-only PR is exempt from the external-contributor proof gate; the body’s focused harness and browser-run results are supplemental validation that must be refreshed after rebase.
Patch quality 🦐 gold shrimp (3/6) 2 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored test-only PR is exempt from the external-contributor proof gate; the body’s focused harness and browser-run results are supplemental validation that must be refreshed after rebase.
Evidence reviewed 4 items Introduced control API: The PR adds an atomic close/defer control, exact-ID settlement, and request-ID-based waiting to the serialized mock Gateway.
Current-main deferral contract: Current main instead supports parameter-matched one-shot deferrals and preserves held-method multi-response settlement; current E2Es use these contracts.
Current fixture lifetime boundary: Merged current main runs serialized mock-Gateway tests in a fresh JSDOM VM realm and closes that realm even after assertion failure, preventing global/listener leakage between tests.
Findings 2 actionable findings [P1] Rebase the mock-Gateway API onto current main
[P1] Run the added serialized tests in the isolated fixture
Security None None.

How this fits together

Control UI browser tests install a serialized mock Gateway in the page, then exercise reconnect and session-history behavior through that simulated transport. The helper records browser requests and controls delayed responses so E2E tests can assert the UI’s recovery behavior.

flowchart LR
  A[Browser E2E scenario] --> B[Control UI page]
  B --> C[Mock Gateway harness]
  C --> D[Deferred request controls]
  D --> E[Reconnect or history response]
  E --> F[UI assertions]
Loading

Before merge

  • Rebase the mock-Gateway API onto current main (P1) - Current main’s shared harness preserves parameter-matched deferNext, held multi-response settlement, and count-based cursor waits. The introduced helper API at this location replaces those semantics, and GitHub reports the PR as dirty; resolve the rebase by retaining current contracts and adding only the needed atomic behavior.
  • Run the added serialized tests in the isolated fixture (P1) - The added tests execute the serialized mock directly in the shared global window. Current main’s merged fixture closes a fresh JSDOM realm after every test to prevent queued work, listeners, and globals leaking into routing tests; migrate these cases to that fixture during the rebase.
  • Resolve merge risk (P1) - Resolving the dirty merge by restoring this branch’s helper shape could discard current main’s parameter-matched deferrals, held-response semantics, cursor waits, or isolated test realm and reintroduce UI automation flakiness.
  • Complete next step (P2) - Rebase onto current main, retain its matched-deferral, held-response, cursor-wait, and isolated-realm contracts, migrate the added serialized tests to the fixture, then request one exact-head re-review.

Findings

  • [P1] Rebase the mock-Gateway API onto current main — ui/src/test-helpers/control-ui-e2e.ts:295-321
  • [P1] Run the added serialized tests in the isolated fixture — ui/src/test-helpers/control-ui-e2e.mock-gateway.test.ts:27-224
Agent review details

Security

None.

PR surface

Tests +392. Total +392 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 7 501 109 +392
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 501 109 +392

Review metrics

Metric Value Why it matters
Production versus test-support delta production +0/-0; test/support +501/-109 The branch is entirely test infrastructure, so merge safety depends on preserving current harness contracts rather than production compatibility.

Merge-risk options

Maintainer options:

  1. Rebase onto the current fixture (recommended)
    Port the useful reconnect coverage onto the current mock-Gateway contracts and retain the isolated JSDOM fixture before rerunning focused tests.
  2. Pause the stale branch
    Keep the branch draft if its deterministic scenarios cannot be expressed without replacing the newer shared fixture behavior.

Technical review

Best possible solution:

Rebase onto current main, preserve its parameter-matched deferral, held-response, cursor-wait, and isolated-realm contracts, and add only the deterministic reconnect coverage that remains necessary.

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

Yes, source comparison provides a high-confidence reproduction path: applying the branch’s old helper/test shape over current main would remove current matched-deferral and isolated-realm coverage unless reconciled.

Is this the best way to solve the issue?

No. Request-scoped control is plausible, but the branch is not the best current solution until it is expressed as an additive extension of current main’s deferral and fixture-lifetime contracts.

Full review comments:

  • [P1] Rebase the mock-Gateway API onto current main — ui/src/test-helpers/control-ui-e2e.ts:295-321
    Current main’s shared harness preserves parameter-matched deferNext, held multi-response settlement, and count-based cursor waits. The introduced helper API at this location replaces those semantics, and GitHub reports the PR as dirty; resolve the rebase by retaining current contracts and adding only the needed atomic behavior.
    Confidence: 0.98
  • [P1] Run the added serialized tests in the isolated fixture — ui/src/test-helpers/control-ui-e2e.mock-gateway.test.ts:27-224
    The added tests execute the serialized mock directly in the shared global window. Current main’s merged fixture closes a fresh JSDOM realm after every test to prevent queued work, listeners, and globals leaking into routing tests; migrate these cases to that fixture during the rebase.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is bounded Control UI test-infrastructure work affecting CI determinism, not production behavior.
  • merge-risk: 🚨 automation: The shared mock Gateway controls browser reconnect and deferred-response tests, and an incorrect conflict resolution can destabilize those automation paths.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This MEMBER-authored test-only PR is exempt from the external-contributor proof gate; the body’s focused harness and browser-run results are supplemental validation that must be refreshed after rebase.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Rebase while retaining current main’s parameter-matched deferrals, held-response settlement, cursor waits, and isolated JSDOM fixture.
  • Port the added serialized tests to mockGatewayTest and its gatewayPage realm.
  • Request one exact-head re-review after the reconciled focused harness and browser scenarios pass.

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 (6 earlier review cycles)
  • reviewed 2026-08-08T13:38:47.874Z sha 3e30e2e :: found issues before merge. :: [P1] Update the remaining duplicate config.patch deferral
  • reviewed 2026-08-08T13:46:42.587Z sha 3e30e2e :: needs maintainer review before merge. :: none
  • reviewed 2026-08-14T23:32:25.652Z sha 3e30e2e :: needs maintainer review before merge. :: none
  • reviewed 2026-08-15T22:33:02.882Z sha 3e30e2e :: needs maintainer review before merge. :: none
  • reviewed 2026-08-21T18:39:56.473Z sha 3e30e2e :: found issues before merge. :: [P1] Rebase the mock-Gateway controls onto current main
  • reviewed 2026-08-29T18:56:42.080Z sha 3e30e2e :: needs maintainer review before merge. :: none

@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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 8, 2026
@clawsweeper clawsweeper Bot added clawsweeper-recovery-stuck status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper-recovery-stuck status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 15, 2026
@clawsweeper clawsweeper Bot added clawsweeper-recovery-stuck status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper-recovery-stuck status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 29, 2026
@vincentkoc
vincentkoc force-pushed the fix/ui-request-scoped-deferrals-20260808 branch from 3e30e2e to 4b8c42e Compare September 5, 2026 02:05
@vincentkoc vincentkoc changed the title test(ui): deflake reconnect and catalog history E2E fix(ui): release deferred responses on socket close Sep 5, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review September 5, 2026 02:05
@clawsweeper

clawsweeper Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@vincentkoc

Copy link
Copy Markdown
Member Author

Exact-head publication proof:

  • Head: 4b8c42ef60f828b08e746981a83013ce1389663b (signed).
  • Current main checked: 7d1e6227bd552a24b0af313622e416ca159a27f9.
  • Current-main drift does not touch either changed file; merge-tree is clean.
  • The regression failed before repair because a closed predecessor consumed settlement and the replacement received no response.
  • Fixture suites: 16/16 passed.
  • Reconnect E2E scenarios: 40/40 passed.
  • P1 autoreview: clean, no actionable findings.
  • LOC: production +0/-0; test support +44/-0.
  • tsgo:ui and check:changed remain blocked only by four unrelated current-main assertBeforeRename type errors in src/infra/install-package-dir.ts.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(ui): release deferred responses on socket close This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@vincentkoc

Copy link
Copy Markdown
Member Author

Final close proof (September 5, 2026):

Closing as superseded/unneeded. The merged replacements own the durable behavior, the cleanup attempt violates current contracts, and no current reconstruction remains.

@vincentkoc vincentkoc closed this Sep 5, 2026
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: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant