Repository navigation
fix(ui): isolate strict HTML previews and save reopened drafts - #146873
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
2a039e1 to
f2ad627
Compare
|
Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 12:00 PM ET / 16:00 UTC (Revision 6). ClawSweeper reviewWhat this changesThe 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 Review scores
Verification
How this fits togetherThe 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]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -16, Tests +339, Docs +3. Total +326 across 12 files. View PR surface stats
Review metricsNone. Technical reviewBest 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. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
Co-authored-by: steipete <[email protected]>
Co-authored-by: steipete <[email protected]>
Co-authored-by: steipete <[email protected]>
Co-authored-by: steipete <[email protected]>
Co-authored-by: steipete <[email protected]>
Co-authored-by: steipete <[email protected]>
3ce03f6 to
d917e89
Compare
|
Merged via squash.
|
…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]>
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-changedand 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.setwith 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
03b36445821test-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-secopsmaintainer 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
a9aea76da8bwith 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.