Skip to content

fix(ui): isolate strict HTML previews and save reopened drafts - #146873

Merged
roboclaw-bot merged 6 commits into
mainfrom
openclaw/html-preview-review-fixes
Sep 13, 2026
Merged

roboclaw-bot merged 6 commits into
mainfrom
openclaw/html-preview-review-fixes

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #146672

What Problem This Solves

Fixes strict HTML previews allowing forbidden descendant-frame requests and Save silently doing nothing when a retained HTML draft is reopened before Source.

User Impact

Strict mode keeps the sandbox resource restrictions while disabling the document’s scripts. Reopened HTML drafts can be saved directly from Preview, with the same conflict detection, Reload, and Overwrite controls as Source.

Why This Change Was Made

Both modes now use the existing separate-origin sandbox host. Only the untrusted inner document loses script permission in strict mode; the host’s CSP, descendant-markup guard, origin validation, and frame retirement remain in force. Ordinary files still receive no widget capability bridges.

Save and conflict recovery consume the existing retained text when no editor is mounted, preserve its expected hash, and clear or retain dirty state according to the actual save result.

Evidence

  • The new browser regression fails on the original strict renderer because its forbidden iframe reaches a controlled loopback HTTP receiver. The fixed renderer rejects it before I/O in strict, scripts, and strict → scripts → strict transitions.

  • 46 attachment/transport tests, 19 Chromium file/editor tests, 16 isolated sandbox/HTTP tests, and all 10 affected Chromium E2E cases pass. Coverage includes saving before Source, retained conflict hashes, Reload/Overwrite without an editor, exact HTML transfer in strict mode, and closing root-distinct files through their filename tab.

  • Independent review found no actionable P0–P2 findings.

  • The earlier full check-changed and runtime/UI build passed. Fresh build, live proof and exact-head CI now pass for the Reload/editor-initialization repair. Startup limits remain unchanged.

  • Real isolated Gateway + Chromium, with no mocked network, passed scripts and strict rendering, original downloads, retained state, and forbidden-descendant checks across both transition directions. The reopened draft sent one sessions.files.set with its retained expected hash, updated the disk bytes, and cleared Save without ever mounting Source.

Controlled-receiver diagnostics from the real-Gateway runs:

{"scripts_strict_scripts":{"controlRequests":1,"forbiddenRequests":0,"guardRejections":3},"strict_scripts_strict":{"controlRequests":1,"forbiddenRequests":0,"guardRejections":3},"reopenedDraft":{"saveCalls":1,"expectedHashPreserved":true,"editorMounted":false}}

Upstream #146862 fixed the stale sidebar-test imports; #146803 fixed the independent agent-shard cap. The previous 03b36445821 test-merge passed that shard guard. This PR does not change either prerequisite’s code or raise limits. Both stale UI test expectations found by CI have been migrated, without weakening their content, identity, or detachment assertions.

Owner Involvement

This work was directly requested by @steipete in the originating Team task, including sandboxed HTML rendering. Live GitHub membership checks on September 13, 2026 confirm active openclaw-secops maintainer and organization-admin roles. This records existing owner involvement for the scoped sandbox repair; it does not claim a separate GitHub approval or waive any enforced review/CI gate.

The real-Gateway captures are inspected and retained. GitHub attachment upload returned HTTP 400 (Bad Content-Length), so the transport diagnostics above are supplied inline.

Reload / Source Race Follow-up

The latest review identified a real ordering defect: Reload could finish while first-time Source language loading was pending, after the editor had captured the discarded draft. The editor now reconciles from the panel’s current text after asynchronous creation and before installation or registering draft callbacks. Existing ownership/version checks remain in place.

A deterministic Chromium regression delays the real HTML language loader, finishes Reload first, then resumes editor initialization. It fails on a9aea76da8b with the old draft visible and passes with the repair. Editable and read-only reload outcomes are covered; the editable case then saves a new edit with the reloaded hash. Independent P0–P2 review of this change is scoped-clean.

Startup Budget

The current-main control also exceeded the existing startup limit. To repair CI without changing budgets, the sidebar normalizer now reuses prepared IDs and active-panel selection, using the existing string readers. Legacy layout migration, blank versus missing main-panel IDs, plugin slots and expanded-side behavior are unchanged.

All 35 layout tests pass, as do 10,000 deterministic before/after normalization cases. The canonical source comparison reports 355,702 gzip bytes against the unchanged 355,719-byte startup ceiling. Typecheck, type-aware lint and the coercion-declaration guard pass; independent P0–P2 review is scoped-clean. No baseline, limit or test assertion was weakened.

The branch was refreshed onto main for the failing integration guard; range comparison preserves the production changes and drops only a filename-tab test migration already upstream. Fresh exact-head CI and runtime replay are complete.

Final Validation

For head d917e89713d1f1d96d4f57aa56f7f2007a4db973: full runtime/UI build completed, both real-Gateway scripts/strict replays and all 10 affected bundled browser E2E cases passed. Current-head review has no findings. CI attempt 2 and the required CI gate are green.

Attempt 1 hit the pre-existing rejected-update subprocess timeout documented in #146154. The CLI/test sources are unchanged by this PR; both rejection/state-immutability checks passed locally, and one failed-job retry passed. The original diagnostic log is retained. No retry was added to tests, no timeout was increased, and no claim is made that the underlying baseline hang was fixed.

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

@roboclaw-bot roboclaw-bot self-assigned this Sep 13, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime docker Docker and sandbox tooling agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Sep 13, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review September 13, 2026 08:20
@roboclaw-bot
roboclaw-bot requested a review from a team as a code owner September 13, 2026 08:20
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/html-preview-review-fixes branch from 2a039e1 to f2ad627 Compare September 13, 2026 08:23
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 12:00 PM ET / 16:00 UTC (Revision 6).

ClawSweeper review

What this changes

The PR routes strict HTML previews through the isolated sandbox, enables saving and conflict recovery for reopened drafts before Source loads, and simplifies sidebar layout normalization.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main retains both defects, and the prior Reload/Source finding is repaired. No blocking correctness defect was found in the introduced changes.

Priority: P2
Reviewed head: d917e89713d1f1d96d4f57aa56f7f2007a4db973

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with relevant runtime diagnostics, meaningful regression coverage and no remaining blocking finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The supplied real-Gateway Chromium diagnostics exercise the changed preview host, reject forbidden descendant requests before receiver I/O across both mode-transition directions, and demonstrate a hash-preserving draft save to disk without Source. Browser regressions supplement the Reload race coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The supplied real-Gateway Chromium diagnostics exercise the changed preview host, reject forbidden descendant requests before receiver I/O across both mode-transition directions, and demonstrate a hash-preserving draft save to disk without Source. Browser regressions supplement the Reload race coverage.
Evidence reviewed 9 items Introduced scope: Reviewed the pinned merge-base-to-head changes. The host-verified test merge has the pinned base and PR head as its two parents and retains the same introduced file set; unrelated base-branch changes were excluded.
Current main still needs the fixes: Fetched main still renders strict previews directly through srcdoc and returns from saveFile when no editor exists. The merged feature PR #146672 supplies the original feature, not these repairs; the other supplied merged PRs address separate CI prerequisites.
Sandbox boundary: The trusted shell checks parent source and origin, guards descendant markup before assigning the inner document, and gives strict documents an empty sandbox permission set. The preview consumer closes unsupported bridge ports and retains connection and frame-generation checks. This is OpenClaw’s own Canvas/sandbox implementation, with no affirmative Codex dependency.
Findings None None.
Security None None.

How this fits together

The Control UI displays workspace files and attachments in chat-side panels. HTML passes through the Gateway’s isolated preview host, while editable file drafts use the existing hash-checked save contract.

flowchart TD
  A[Workspace files and attachments] --> B[Chat file panel]
  B --> C[Gateway preview service]
  C --> D[Isolated sandbox host]
  D --> E[Inner document with mode restrictions]
  B --> F[Retained draft or editor text]
  F --> G[Hash-checked save]
  G --> H[Saved file or conflict controls]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -16, Tests +339, Docs +3. Total +326 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 5 44 60 -16
Tests 6 364 25 +339
Docs 1 4 1 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 412 86 +326

Review metrics

None.

Technical review

Best possible solution:

Keep one guarded preview transport for every sandbox mode and one draft-text owner for saving, reloading and editor initialization.

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

Yes: current-main source establishes the editorless Save no-op and strict preview’s bypass of the sandbox host; supplied browser diagnostics corroborate the latter. This reviewer did not execute a reproduction.

Is this the best way to solve the issue?

Yes: the patch reuses the existing guarded host and file-save contract, addresses the previous asynchronous editor race, and preserves sidebar normalization semantics.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: Repairs bounded HTML-preview isolation and draft-saving defects without evidence of widespread runtime disruption.
  • 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 (logs): The supplied real-Gateway Chromium diagnostics exercise the changed preview host, reject forbidden descendant requests before receiver I/O across both mode-transition directions, and demonstrate a hash-preserving draft save to disk without Source. Browser regressions supplement the Reload race coverage.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied real-Gateway Chromium diagnostics exercise the changed preview host, reject forbidden descendant requests before receiver I/O across both mode-transition directions, and demonstrate a hash-preserving draft save to disk without Source. Browser regressions supplement the Reload race coverage.

Evidence

What I checked:

  • Introduced scope: Reviewed the pinned merge-base-to-head changes. The host-verified test merge has the pinned base and PR head as its two parents and retains the same introduced file set; unrelated base-branch changes were excluded. (d917e89713d1)
  • Current main still needs the fixes: Fetched main still renders strict previews directly through srcdoc and returns from saveFile when no editor exists. The merged feature PR feat(ui): keep file previews in tabs and render HTML #146672 supplies the original feature, not these repairs; the other supplied merged PRs address separate CI prerequisites. (ui/src/pages/chat/components/chat-detail-panel.ts:503, c99812a97a0d)
  • Sandbox boundary: The trusted shell checks parent source and origin, guards descendant markup before assigning the inner document, and gives strict documents an empty sandbox permission set. The preview consumer closes unsupported bridge ports and retains connection and frame-generation checks. This is OpenClaw’s own Canvas/sandbox implementation, with no affirmative Codex dependency. (src/agents/sandbox-host.ts:257, d917e89713d1)
  • Prior finding resolved: Editor installation reconciles current panel text after asynchronous language loading and before registering draft callbacks. The added browser regression covers Reload finishing first with both editable and read-only outcomes. The earlier reviewed commit was unavailable locally, so no claim of a complete revision-to-revision comparison is made. (ui/src/pages/chat/components/chat-detail-panel.ts:266, d917e89713d1)
  • Real behavior evidence: The complete supplied PR body, captured under sourceRevision b2aaa717a4124fe21787b86c7347bc66a76f049537b0efacdea4ad223e0e2063, reports isolated real-Gateway Chromium runs with one successful control request, zero forbidden requests and three guard rejections in each transition direction. It also records one reopened-draft save preserving the expected hash, changing disk bytes and clearing Save without mounting Source. Inline diagnostics were inspected; retained captures were not available in the supplied scratch directory.
  • Normalization compatibility: The refactor preserves string trimming, blank-versus-missing main-panel IDs, unique IDs, legacy chat-slot migration and active-side selection. Existing layout tests cover persisted round trips and legacy expanded layouts; the supplied body additionally reports 10,000 equivalent before/after cases. (ui/src/pages/chat/sidebar-layout-normalize.ts:55, d917e89713d1)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

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 (5 earlier review cycles)
  • reviewed 2026-09-13T08:29:33.688Z sha f2ad627 :: blocked before merge. :: none
  • reviewed 2026-09-13T08:45:55.144Z sha 03b3644 :: blocked before merge. :: none
  • reviewed 2026-09-13T09:38:04.420Z sha a9aea76 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-13T11:24:46.632Z sha a9aea76 :: needs changes before merge. :: [P2] [P2] Reconcile pending editor creation after Reload
  • reviewed 2026-09-13T15:09:27.602Z sha 3ce03f650f2a159008260045b6dedd8a75515fd3 :: needs maintainer review before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot reopened this Sep 13, 2026
@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. 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: 🐚 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. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 13, 2026
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/html-preview-review-fixes branch from 3ce03f6 to d917e89 Compare September 13, 2026 15:53
@roboclaw-bot
roboclaw-bot merged commit ab59bcf into main Sep 13, 2026
337 of 340 checks passed
@roboclaw-bot
roboclaw-bot deleted the openclaw/html-preview-review-fixes branch September 13, 2026 16:30
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
…law#146873)

* fix(ui): isolate strict HTML previews and save reopened drafts

Co-authored-by: steipete <[email protected]>

* test(ui): assert strict HTML attachment transport

Co-authored-by: steipete <[email protected]>

* fix(ui): preserve reloaded text during Source initialization

Co-authored-by: steipete <[email protected]>

* test(ui): use shared deferred helper for Reload regression

Co-authored-by: steipete <[email protected]>

* test(ui): use the deferred helper default type

Co-authored-by: steipete <[email protected]>

* refactor(ui): reuse normalized sidebar layout values

Co-authored-by: steipete <[email protected]>

---------

Co-authored-by: steipete <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui docker Docker and sandbox tooling docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. 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.

1 participant