Skip to content

fix(ui): prevent Control UI hangs on malformed progress content - #147528

Merged
vyctorbrzezowski merged 3 commits into
openclaw:mainfrom
jjjhenriksen:fix/control-ui-regex-hang
Sep 14, 2026
Merged

vyctorbrzezowski merged 3 commits into
openclaw:mainfrom
jjjhenriksen:fix/control-ui-regex-hang

Conversation

@jjjhenriksen

@jjjhenriksen jjjhenriksen commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Closes #143713

What Problem This Solves

Fixes: the macOS Control UI can spend seconds in JavaScriptCore RegExp processing when a progress-card message contains many unmatched raw-content opening tags.

User Impact

User impact: malformed or adversarial progress-card content no longer stalls the Control UI main thread, while normal progress rendering and sanitization remain unchanged.

Why This Change Was Made

The existing raw-content block regex restarts its closing-tag search for every unmatched opener. At the existing 140,000-character markdown limit, 17,500 unmatched <script> tags reproduce the reported String.replace / JavaScriptCore Yarr hot path deterministically.

This replaces that regex with a bounded scanner that tokenizes candidate tags once, indexes compatible closing tags, and pairs each opener with the first valid closer after its end without repeatedly rescanning the message. It retains the old /giu regex's Unicode case-folding and word-boundary behavior, its complete \s closing-tag whitespace set, and its overlapping-tag pairing semantics.

Evidence

Maintainer before/after screenshots and independent reproduction.

  • System JavaScriptCore behavior proof: the exact current-main regex took 9,462 ms for a 140,000-character payload; the scanner took 5 ms on the same payload and engine (/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Helpers/jsc).
  • Full Control UI WebKit before/candidate proof: the same 140,000-character mocked-Gateway progress payload took 2,541 ms to open the hovercard on the pre-fix source and 908 ms on the candidate in Playwright WebKit 26.6, including the same built-in hover delay. The candidate then processed progressCard.changed and visibly refreshed the card in 25 ms. Browser version, Safari UA, payload size, and timings are burned into the screenshots below.
  • ClawSweeper shared-suffix case: the scanner processes the supplied 133,001-character malformed-closer payload in 1 ms on system JavaScriptCore.
  • Focused regression tests: node scripts/run-vitest.mjs ui/src/components/markdown.progress.node.test.ts --maxWorkers=1 --reporter=verbose — 4/4 passed, including Unicode folding/boundary, full closing whitespace, opener-end pairing, and both adversarial timing cases through the public progress-card renderer.
  • Behavior compatibility: 20,000/20,000 seeded mixed raw-content cases produced identical output from the old regex and the scanner after the compatibility repairs.
  • Production-bundled Chromium flow: the mocked-Gateway E2E sends the full payload through progressCard.get, verifies the actual hovercard renders, emits progressCard.changed, and verifies the same hovercard updates. The focused test passed in 1.844 s.
  • Repository gate: pnpm check:changed passed through formatting, lint, UI typecheck, dead-export scans, and changed-code checks with the isolated worktree root.

Before: pre-fix WebKit hovercard

Pre-fix Control UI WebKit hovercard with 140,000-character adversarial payload and timing diagnostics

Candidate: repaired WebKit hovercard

Candidate Control UI WebKit hovercard with the same adversarial payload and timing diagnostics

Candidate: responsive after Gateway refresh

Candidate WebKit hovercard updated after progressCard.changed with timing diagnostics

The reporter's original WebSocket payload is not available. The regression case instead exercises the exact affected progress-card preprocessing path with the same String.replace → JavaScriptCore Yarr signature described in the issue.

@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-13T23:18:34.753482Z f4830ec PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 13, 2026, 8:03 PM ET / September 14, 2026, 00:03 UTC (Revision 3).

ClawSweeper review

What this changes

Replaces slow progress-card Markdown preprocessing with a bounded tag scanner and adds compatibility and browser responsiveness regressions.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open: this remains a useful fix absent from current main and v2026.9.4. The revised scanner resolves the prior compatibility findings, and the inspected WebKit evidence supports the targeted performance improvement. No blocking code defect remains.

Priority: P1
Reviewed head: fe5e45a9659b89426df86a20098fcca4e8f0042a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, well-supported performance repair with prior correctness findings resolved.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): The inspected WebKit screenshots include engine, payload, and timing diagnostics for the real progress-card renderer over a mocked Gateway: 2,541 ms before, 908 ms after, and a visible refresh in 25 ms. Together with the supplied JavaScriptCore observations, this resolves the previous affected-engine proof gap; screenshot destination confirmation remains a separate landing requirement.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): The inspected WebKit screenshots include engine, payload, and timing diagnostics for the real progress-card renderer over a mocked Gateway: 2,541 ms before, 908 ms after, and a visible refresh in 25 ms. Together with the supplied JavaScriptCore observations, this resolves the previous affected-engine proof gap; screenshot destination confirmation remains a separate landing requirement.
Evidence reviewed 9 items Current main still contains the slow path: The fetched main revision retains the raw-content replacement regex, executed before the large-input plain-text fallback. The existing size guard therefore does not eliminate repeated closing-tag searches.
Latest supplied release also retains the regex: Inspection of v2026.9.4 found the same raw-content regex and progressBars replacement call; this PR's scanner is not already supplied by that release.
Prior findings resolved: The current scanner uses Unicode-aware case folding and word boundaries, accepts the complete whitespace class, and binary-searches for a closing tag starting after the opener ends. Public-renderer regressions cover these differences. The earlier revision was retrieved through GitHub after the local historical blob read failed.
Findings None None.
Security None None.

How this fits together

The Control UI receives progress-card text and refresh events from the Gateway. Its Markdown renderer removes raw-content blocks and sanitizes the resulting HTML before displaying progress cards.

flowchart LR
  A[Gateway progress text] --> B[Markdown size guard]
  B --> C[Raw-content scanner]
  C --> D[Markdown or plain-text rendering]
  D --> E[HTML sanitization]
  E --> F[Visible progress card]
  G[Gateway refresh event] --> A
Loading

Before merge

  • Resolve merge risk (P1) - The original reported WebSocket payload remains unavailable, so the broader hang report is not conclusively resolved by this specific repair.
  • Resolve merge risk (P1) - Originating-chat delivery of the before/after screenshots remains unverified.
  • Complete next step (P2) - Confirm the inspected before/after screenshots are also delivered in the originating chat, satisfying the remaining AGENTS.md screenshot landing requirement.
Agent review details

Security

None.

PR surface

Source +134, Tests +166. Total +300 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 137 3 +134
Tests 2 166 0 +166
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 303 3 +300

Review metrics

Metric Value Why it matters
Observed WebKit responsiveness Hovercard 2,541 → 908 ms; candidate refresh 25 ms The supplied diagnostic screenshots demonstrate improvement through the affected browser rendering path.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep progress preprocessing bounded within the existing renderer while preserving raw-tag matching semantics and final HTML sanitization.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep progress preprocessing bounded within the existing renderer while preserving raw-tag matching semantics and final HTML sanitization.

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

Yes for the targeted defect: 17,500 unclosed script tags reach the current-main replacement regex before its parse-size fallback, with supplied JavaScriptCore and WebKit timing evidence. This review did not execute the reproducer, and the original reporter's payload remains unknown.

Is this the best way to solve the issue?

Yes: replacing the repeated-search preprocessing operation preserves the existing rendering owner and sanitization boundary; the revised matching rules address the prior behavioral differences.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 0176c61961da.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The inspected WebKit screenshots include engine, payload, and timing diagnostics for the real progress-card renderer over a mocked Gateway: 2,541 ms before, 908 ms after, and a visible refresh in 25 ms. Together with the supplied JavaScriptCore observations, this resolves the previous affected-engine proof gap; screenshot destination confirmation remains a separate landing requirement.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The inspected WebKit screenshots include engine, payload, and timing diagnostics for the real progress-card renderer over a mocked Gateway: 2,541 ms before, 908 ms after, and a visible refresh in 25 ms. Together with the supplied JavaScriptCore observations, this resolves the previous affected-engine proof gap; screenshot destination confirmation remains a separate landing requirement.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): The inspected WebKit screenshots include engine, payload, and timing diagnostics for the real progress-card renderer over a mocked Gateway: 2,541 ms before, 908 ms after, and a visible refresh in 25 ms. Together with the supplied JavaScriptCore observations, this resolves the previous affected-engine proof gap; screenshot destination confirmation remains a separate landing requirement.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: This repairs a demonstrated multi-second Control UI main-thread stall in progress-card rendering.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): The inspected WebKit screenshots include engine, payload, and timing diagnostics for the real progress-card renderer over a mocked Gateway: 2,541 ms before, 908 ms after, and a visible refresh in 25 ms. Together with the supplied JavaScriptCore observations, this resolves the previous affected-engine proof gap; screenshot destination confirmation remains a separate landing requirement.
  • proof: sufficient: Contributor real behavior proof is sufficient. The inspected WebKit screenshots include engine, payload, and timing diagnostics for the real progress-card renderer over a mocked Gateway: 2,541 ms before, 908 ms after, and a visible refresh in 25 ms. Together with the supplied JavaScriptCore observations, this resolves the previous affected-engine proof gap; screenshot destination confirmation remains a separate landing requirement.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The inspected WebKit screenshots include engine, payload, and timing diagnostics for the real progress-card renderer over a mocked Gateway: 2,541 ms before, 908 ms after, and a visible refresh in 25 ms. Together with the supplied JavaScriptCore observations, this resolves the previous affected-engine proof gap; screenshot destination confirmation remains a separate landing requirement.

Evidence

What I checked:

  • Current main still contains the slow path: The fetched main revision retains the raw-content replacement regex, executed before the large-input plain-text fallback. The existing size guard therefore does not eliminate repeated closing-tag searches. (ui/src/components/markdown.ts:555, 0176c61961da)
  • Latest supplied release also retains the regex: Inspection of v2026.9.4 found the same raw-content regex and progressBars replacement call; this PR's scanner is not already supplied by that release. (ui/src/components/markdown.ts:556, 3a9d69db306c)
  • Prior findings resolved: The current scanner uses Unicode-aware case folding and word boundaries, accepts the complete whitespace class, and binary-searches for a closing tag starting after the opener ends. Public-renderer regressions cover these differences. The earlier revision was retrieved through GitHub after the local historical blob read failed. (ui/src/components/markdown-raw-content.ts:27, fe5e45a9659b)
  • Production entry point and final sanitization: Progress-card rendering calls toSanitizedMarkdownHtml with progressBars enabled. The scanner replaces preprocessing only; Markdown rendering, escaped large-text fallback, DOMPurify, and the existing allowlists remain in place. No authority, dependency, configuration, or persistent-state contract changes. (ui/src/components/markdown.ts:554, fe5e45a9659b)
  • Inspected WebKit before/after evidence: All three downloaded PR-body images were inspected. They display Playwright WebKit 26.6, a 140,000-character payload, pre-fix hovercard rendering at 2,541 ms, candidate rendering at 908 ms, and candidate Gateway refresh at 25 ms. The final image visibly shows the updated text and progress bar. These are diagnostic-bearing screenshots of the affected renderer, beyond an ordinary app screenshot. Source: fix(ui): prevent Control UI hangs on malformed progress content #147528.
  • Targeted browser regression: The introduced E2E exercises progressCard.get through the existing mocked Gateway, opens the actual sidebar hovercard with repeated unclosed tags, then emits progressCard.changed and checks visible replacement content. The PR reports focused Chromium and unit-test passes; this read-only review did not execute contributor code. (ui/src/e2e/markdown-progress-adversarial.e2e.test.ts:77, fe5e45a9659b)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vyctorbrzezowski: 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.

  • Confirm the before/after screenshots were also delivered in the originating implementation chat.

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 (2 earlier review cycles)
  • reviewed 2026-09-13T23:17:22.760Z sha f4830ec :: needs real behavior proof before merge. :: [P2] [P2] Validate closing-tag whitespace without rescanning the suffix | [P2] [P2] Preserve raw-block closers inside apparent nested tags
  • reviewed 2026-09-13T23:39:53.386Z sha e9e4e0a :: needs real behavior proof before merge. :: [P2] [P2] Preserve Unicode-aware raw-tag matching | [P2] [P2] Retain the full closing-tag whitespace set | [P2] [P2] Pair closers only after the opening tag ends

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f4830ecb7a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jjjhenriksen

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 13, 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 added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Sep 13, 2026
@jjjhenriksen

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 13, 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 added proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 14, 2026
@vyctorbrzezowski vyctorbrzezowski self-assigned this Sep 14, 2026
@vyctorbrzezowski

Copy link
Copy Markdown
Member

Before / after: progress-card rendering

Same mocked-Gateway progress card with 140,000 characters of repeated unclosed <script> tags. The screenshots below were supplied by @jjjhenriksen and inspected during maintainer review of fe5e45a9659b89426df86a20098fcca4e8f0042a.

Before After
Before: the progress hovercard opens in 2,541 ms in Playwright WebKit 26.6 After: the same progress hovercard opens in 908 ms in Playwright WebKit 26.6

The corrected card also visibly updates after progressCard.changed; the supplied capture records a 25 ms refresh:

After refresh: updated text and a completed progress bar

Independent reproduction

On system JavaScriptCore on macOS 26.3.1, the original preprocessing operation took 6,171 / 6,183 / 6,382 ms across three runs of the 140,000-character case. The corrected scanner took 2 / 1 / 2 ms, with identical output. These measure preprocessing only, separately from the WebKit hovercard timings above.

The published renderer tests failed on the original implementation at approximately 198 ms against the 100 ms limit. With the corrected renderer, all 4 tests passed, including that case at 22 ms.

node scripts/run-vitest.mjs ui/src/components/markdown.progress.node.test.ts --maxWorkers=1 --reporter=verbose --configLoader runner

Risk and coverage

This confirms the specific repeated-tag performance defect and the tested content-removal behavior. The original reporter's message remains unavailable, so this does not establish the cause of every hang reported in #143713. The screenshots are contributor-supplied WebKit evidence; the independent reproduction above covers system JavaScriptCore and the Node/jsdom renderer.

@vyctorbrzezowski
vyctorbrzezowski merged commit ad157ba into openclaw:main Sep 14, 2026
179 of 181 checks passed
@vyctorbrzezowski

Copy link
Copy Markdown
Member

Merged via squash.

@jjjhenriksen
jjjhenriksen deleted the fix/control-ui-regex-hang branch September 14, 2026 21:10
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 15, 2026
…claw#147528)

* fix(ui): prevent progress card regex stalls

* test(ui): prove adversarial progress rendering

* fix(ui): preserve progress raw tag semantics
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 P1 High-priority user-facing bug, regression, or broken workflow. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

[Bug]: macOS Control UI hangs in JavaScriptCore RegExp while handling WebSocket messages

2 participants