Skip to content

fix(ui): file links outside the session workspace fail to open, HTML previews drop their assets - #163185

Merged
steipete merged 12 commits into
mainfrom
steipete/web-ui-wm-clickability-8a43b7
Oct 3, 2026
Merged

steipete merged 12 commits into
mainfrom
steipete/web-ui-wm-clickability-8a43b7

Conversation

@steipete

@steipete steipete commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: clicking a file link in Control UI chat shows "Failed to load" when the file lives outside the viewing session's workspace. This is common for links in forwarded or inter-session updates, which point into the sending session's workspace, and for scratch files under the agent workspace. HTML files that did open rendered without their relative images, stylesheets, and scripts.

User Impact

User impact: file links in chat open whenever the session's agent could read the file. Links in forwarded messages open in the sending session's workspace. HTML previews such as design concepts now render with their sibling PNGs, CSS, and JS.

Viewers who can only read a session, such as Team guests with view access, still see only files inside that session's workspace. When a link is blocked, the panel now says the file is outside the session's workspace instead of a generic "Failed to load". Session-only readers can now render HTML previews at all.

Why This Change Was Made

The sidebar preview enforced its own rule: it always contained reads to the session root, even when the agent's file tools are unrestricted. It now follows the same boundary the agent uses. Reads stay contained in read-only, guarded, and workspace modes, with tools.fs.workspaceOnly, under a sandbox, and for any session whose tools do not run on the Gateway host. Otherwise any host path is readable, which is the documented default.

Reading outside the root also requires that the caller could start a turn in that session right now. This check runs the Gateway's real chat.send admission for that session (scope, sharing role, agent allowlist, role sandbox requirement, incognito/draft rules). It runs inside the prepared session facts and is rechecked after file I/O, before the response is sent. So viewing a session never grants more filesystem access than asking its agent would. Out-of-root previews are read-only, with no edit hash; writes keep their existing root containment.

Links inside a message that carries a sender session resolve against that sender's session.

HTML previews load assets through a new session read method, sessions.files.assets, which applies the same boundary to every asset. The UI inlines the results into the sandboxed preview by source offset, without reserializing the author's document. It skips documents that set their own <base href>.

Limits: 64 refs per call, 1 MiB per asset, 4 MiB total per call, which stays well under the 25 MiB frame limit. Fonts are not loaded because the shared sandbox CSP stays unchanged (font-src 'self'). Missing or oversized assets show a small "Some assets couldn't be loaded (N)" notice. canvas.document.preview joins the session-reader admission set. It only echoes caller HTML and the sandbox location.

To reuse the router fence for this check, authorizeGatewayRequestPreDispatch moved, unchanged, from server-methods.ts into server-methods/request-authorization.ts, gaining a synchronous consumeSessionTurn hook. Callers and test mocks were updated to the new import path.

Update behavior: no config, state, migration, or plugin-loading change.

Compatibility: packages/gateway-protocol/src/schema/sessions.ts gains only additive wire schema. It adds the sessions.files.assets request/result and an optional reason: "outside_session_boundary" detail on the existing session_file_not_found error. No stored data, migration, or config shape changes. The Control UI ships with its Gateway (ui/AGENTS.md, Gateway Coupling). Native models are generated at build time from this schema (#162251), and prepare-native-protocol.mjs --check passes.

Release-note context: Control UI file links now open files outside the session workspace when the session's agent could read them and you can send turns in that session. Links in forwarded messages open in the sending session, and HTML previews load relative images, stylesheets, and scripts.

Evidence

HTML preview with relative assets, before and after (synthetic fixture; the after capture includes one deliberately missing asset to show the notice):

HTML preview before: no styles, broken image, script did not run
HTML preview after: styles, image, and script load; one missing asset shows the notice

Live, on an isolated dev Gateway started from this branch (real Playwright clicks and real Gateway responses, synthetic fixture under /Users/Shared): an outside-workspace HTML link opens with its sibling PNG and CSS. The file response omits hash, so the preview is read-only. After switching the same session to workspace mode, the same link is refused with the new message.

Live: outside-workspace HTML link opens with its sibling image and stylesheet
Live: same link refused once the session is in workspace mode

Focused tests, run with pnpm test <file> --maxWorkers=1 on a heavily loaded host (load average around 55 on 32 cores; most wall time is cold transform):

Test file Wall
src/gateway/server-methods/sessions-files.host-read.test.ts (new: mode/policy/sandbox/exec-node denial matrix, placement observation, canonicalization, hardlinked host file, post-read recheck, write containment) 192.6s
src/gateway/server-methods.session-turn-authority.test.ts (new: session writer allowed, view-only caller hidden, solo/admin incognito inside prepared authorization, scope/incarnation recheck after I/O) 59.9s
src/gateway/server-methods/sessions-file-assets.test.ts (new) 118.2s
ui/src/pages/chat/components/chat-html-preview-assets.test.ts (new) 11.8s
src/gateway/server-methods/sessions-files.test.ts 141.3s
ui/src/pages/chat/components/chat-html-preview-element.test.ts 16.1s
ui/src/pages/chat/components/chat-session-workspace.test.ts 17.5s
ui/src/pages/chat/components/chat-message.forwarded-attribution.test.ts 29.1s
ui/src/pages/chat/components/chat-sidebar.test.ts 12.2s
Moved-import tests: internal-facade, method-scopes.own-session, server-methods-list, server-methods.canonical-validation, session-row-prepared-read, main-session-restart-dispatch-start, subagent-announce.requester-settle-dispatch, node-workspace-protocol 7–121s each

Two negative controls failed as intended against the original implementation: host preview rejection and missing sender ownership. pnpm run tsgo:core, pnpm run tsgo:ui, oxlint, oxfmt, ui:i18n:verify, protocol generation (TS, Swift, Kotlin), and git diff --check pass. Independent Codex autoreview found no P0 or P1 findings.

Second head (fixes from CI and ClawSweeper on the first head 735a02c82fbf):

  • Moving authorizeGatewayRequestPreDispatch had also refactored its tail. The tail called assertInvocationCurrent, and through it the request's sessionMutationCommitGuard, at the end of pre-dispatch for every request. Mutation commit guards then fired before handlers ran. CI caught it in plugins.lifecycle-contention.test.ts, where a disable succeeded instead of a retryable UNAVAILABLE, and in src/acp/control-plane/spawn.test.ts, two admission/retirement cases. Both pass on main and failed on this branch locally. The ordinary path is now exactly main's code again: apart from import paths, the only differences are the consumeSessionTurn parameter and branches that run only when it is set. Contention passes 2/2 and spawn 13/13.
  • Deferred classic scripts (two ClawSweeper P2s): inlining <script defer src> dropped defer. Each deferred classic script is now replaced in place by an inline module trampoline. Inline modules share the browser's single post-parsing queue with deferred and module scripts, in document order. The trampoline inserts the original code as an inline classic script, which keeps classic global and sloppy-mode semantics under the unchanged sandbox CSP. A real-sandbox e2e case (session file preview, mocked sessions.files.assets, actual sandbox host) covers it: a blocking head script runs before #app exists, a module sets state, and two deferred classic scripts then read that state and see the body in order (ready true in order). The case failed before the fix with undefined true in order.
  • chat-message.forwarded-attribution.test.ts was updated to main's current renderer types (CI check-test-types). pnpm run tsgo:test:ui and pnpm run tsgo:test:src pass.

After rebasing onto d4b98b3a5101, every test file this PR adds or modifies passed again, along with the tests main changed in the overlapping files: 613 tests passed, 1 skipped. Typechecks, lint/format, ui:i18n:verify, and node scripts/prepare-native-protocol.mjs --check (native models are now generated at build time, #162251) pass.

Inherited local failure, not caused by this PR: src/gateway/local-request-context.session-notify.test.ts › "queues an owned-child notification for operator.sessions.write" fails identically on unmodified main d4b98b3a5101 on this heavily loaded Mac (status error instead of queued; the other 5 cases pass). The case passes when replayed alone, and main CI is green. This PR changes that path only by importing the moved authorizer from its new module. It is filed for a separate fix.

Gap: a forwarded message cannot be produced on a model-less dev Gateway, so sender-session resolution is covered by UI tests rather than a live capture.

…preview assets

File links in Control UI chat failed with "Failed to load" when the file lived
outside the viewing session's workspace root, which is common for links in
forwarded/inter-session updates and for agent-workspace scratch files. HTML
previews also rendered without their relative images, stylesheets and scripts.

- sessions.files.get/list follow the session agent's file-tool read boundary:
  contained in read-only/guarded/workspace modes, with tools.fs.workspaceOnly,
  under a sandbox, or when file tools do not run on the Gateway host;
  otherwise host paths are readable. Out-of-root reads additionally require
  the caller to pass the real chat.send admission for that session, run inside
  prepared session facts and rechecked after I/O. Out-of-root previews are
  read-only; write containment is unchanged.
- Links inside messages with a sender session open against that session.
- New session read method sessions.files.assets lets the UI inline relative
  assets into sandboxed HTML previews by source offset (64 refs, 1 MiB per
  asset, 4 MiB per call; fonts stay unloaded under the unchanged CSP).
- canvas.document.preview joins session-reader admission so session-only
  readers can render HTML previews.
- authorizeGatewayRequestPreDispatch moves unchanged into
  server-methods/request-authorization.ts with a synchronous
  consumeSessionTurn hook.
@clawsweeper

clawsweeper Bot commented Oct 2, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling size: XL labels Oct 2, 2026
@steipete
steipete marked this pull request as ready for review October 2, 2026 02:46
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: b8f2e033d8ba62a221c307a24352fe66a4ae9162
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/methods/core-descriptors.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-methods.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-methods/request-authorization.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-methods/session-file-read-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/session-method-policy.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/shared/session-method-scopes-base.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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 Oct 2, 2026
@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 2, 2026, 8:26 PM ET / October 3, 2026, 00:26 UTC (Revision 11).

ClawSweeper review

What this changes

Control UI file previews use the sending session’s file-read permissions and load relative HTML images, stylesheets, and scripts through bounded Gateway reads.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR remains useful: current main still lacks the corrected preview behavior. No blocking correctness finding remains, and the earlier migration request is unsupported by the additive wire-only changes.

Priority: P2
Reviewed head: b8f2e033d8ba62a221c307a24352fe66a4ae9162

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, coherent patch with strong visible proof and focused authorization coverage; no additional blocking repair was identified.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): Inspected before/after images show restored HTML image, stylesheet, and script output; the recorded isolated-Gateway run exercises the changed file/asset owners and shows host-read success followed by workspace-mode denial. Router and revocation tests supplement this evidence. Forwarded-session resolution has test coverage rather than a live capture. No stored-data contract changes, so the earlier migration-proof request does not apply.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): Inspected before/after images show restored HTML image, stylesheet, and script output; the recorded isolated-Gateway run exercises the changed file/asset owners and shows host-read success followed by workspace-mode denial. Router and revocation tests supplement this evidence. Forwarded-session resolution has test coverage rather than a live capture. No stored-data contract changes, so the earlier migration-proof request does not apply.
Evidence reviewed 8 items Pinned introduction and clean checkout: Reviewed the introduced delta from b60f9e2 to b8f2e03. Raw head parent records match the supplied original-head identity. The supplied test merge is stale and was not used to infer removal of main behavior. Final git status remained clean.
Still necessary on current main: Current main rejects file paths outside the workspace in its file-preview owner; its HTML preview element transfers document HTML without fetching sibling assets. Neither provided merged related PR implements these changes.
Authorization through response publication: Host reads borrow real chat.send admission, verify the exact session incarnation, and check current placement and filesystem policy. The handler repeats that admission while synchronously publishing the response; outside-root previews omit editing hashes and writes retain containment.
Findings None None.
Security None None.

How this fits together

Control UI turns file links in chat into Gateway requests scoped to the owning session. The Gateway authorizes filesystem access and returns preview bytes, which the UI renders in its existing isolated HTML sandbox.

flowchart TD
  A[Chat file link] --> B[Resolve owning session]
  B --> C[Gateway session read authorization]
  C --> D{Outside workspace?}
  D -->|Yes| E[Current turn permission and host policy]
  D -->|No| F[Bounded file and asset reads]
  E --> F
  F --> G[Recheck authority and return bytes]
  G --> H[Isolated HTML preview]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +1214, Tests +1503, Docs +34. Total +2751 across 62 files.

View PR surface stats
Area Files Added Removed Net
Source 39 1577 363 +1214
Tests 19 1595 92 +1503
Docs 4 38 4 +34
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 62 3210 459 +2751

Review metrics

Metric Value Why it matters
Production versus test growth production +1214 net lines; tests and support +1503 net lines Production growth serves the stated authorization reuse and bounded HTML asset-loading behavior.
New wire operation 1 additive RPC; 64 references, 1 MiB per asset, 4 MiB per call The new preview transport has explicit request and response-size bounds without changing stored state.

Stored data model

Persistent data-model change detected: unknown-data-model-change: packages/gateway-protocol/src/schema/sessions.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Use the canonical session authorization owner for previews, preserve contained writes and sandbox isolation, and keep asset loading bounded with visible partial failures.

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

Yes, from source: current main contains previews to the workspace and never fetches relative HTML assets. The supplied before/after and isolated-Gateway evidence demonstrates the affected flow; this reviewer did not execute target code.

Is this the best way to solve the issue?

Yes. Reusing turn admission avoids a competing authorization policy, while sender-scoped preview identity and bounded asset reads address the two reported failures without persistent-state changes.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • remove rating: 🦞 diamond lobster: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This repairs a bounded Control UI file-preview workflow without evidence of an urgent core outage.
  • 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): Inspected before/after images show restored HTML image, stylesheet, and script output; the recorded isolated-Gateway run exercises the changed file/asset owners and shows host-read success followed by workspace-mode denial. Router and revocation tests supplement this evidence. Forwarded-session resolution has test coverage rather than a live capture. No stored-data contract changes, so the earlier migration-proof request does not apply.
  • proof: sufficient: Contributor real behavior proof is sufficient. Inspected before/after images show restored HTML image, stylesheet, and script output; the recorded isolated-Gateway run exercises the changed file/asset owners and shows host-read success followed by workspace-mode denial. Router and revocation tests supplement this evidence. Forwarded-session resolution has test coverage rather than a live capture. No stored-data contract changes, so the earlier migration-proof request does not apply.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. Inspected before/after images show restored HTML image, stylesheet, and script output; the recorded isolated-Gateway run exercises the changed file/asset owners and shows host-read success followed by workspace-mode denial. Router and revocation tests supplement this evidence. Forwarded-session resolution has test coverage rather than a live capture. No stored-data contract changes, so the earlier migration-proof request does not apply.

Evidence

What I checked:

  • Pinned introduction and clean checkout: Reviewed the introduced delta from b60f9e2 to b8f2e03. Raw head parent records match the supplied original-head identity. The supplied test merge is stale and was not used to infer removal of main behavior. Final git status remained clean. (b8f2e033d8ba)
  • Still necessary on current main: Current main rejects file paths outside the workspace in its file-preview owner; its HTML preview element transfers document HTML without fetching sibling assets. Neither provided merged related PR implements these changes. (src/gateway/server-methods/workspace-files.ts, 23bc4d7bfe86)
  • Authorization through response publication: Host reads borrow real chat.send admission, verify the exact session incarnation, and check current placement and filesystem policy. The handler repeats that admission while synchronously publishing the response; outside-root previews omit editing hashes and writes retain containment. (src/gateway/server-methods/sessions-files.ts:516, b8f2e033d8ba)
  • Forbidden and changed-authority coverage: Inspected tests exercise the production router and file handler with real temporary files for allowed writers and denied foreign-session readers. Additional cases reject scope loss and session replacement before publication, and the file-handler suite rejects a policy change after reading. These are supplemental source-reviewed tests, not reviewer-executed live proof. (src/gateway/server-methods.session-turn-authority.test.ts, b8f2e033d8ba)
  • Inspected visual and runtime evidence: Inspected all four prepared images. Before/after captures show restored styling, an image, script-produced summary text, and an omitted-asset notice. The recorded isolated-Gateway scenario shows an outside-workspace preview loading PNG/CSS and refusal after switching to workspace mode. This supports those observed results, not a general CSP or authorization-bypass claim. The captured body sourceRevision is a4dad54ab421d94385fcec68e6d4e154d2c9c3d45188a7dd3cc2c9e063e51ebc; captures do not independently identify an exact commit. Forwarded-session resolution is explicitly supported by tests rather than live media.
  • Previous findings and compatibility request: The deferred-classic ordering repair uses in-place module trampolines and has a browser scenario asserting blocking-before-body and module/deferred ordering. The protocol adds one request/result and preserves existing shapes; no persistent schema, configuration, migration, or settings writer changes were found. The protocol and asset owner are unchanged between the previous reviewed head and this head. UI/Gateway version coupling is explicitly defined by ui/AGENTS.md. (packages/gateway-protocol/src/schema/sessions.ts:297, b8f2e033d8ba)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Kimi Yu: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; 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 (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-02T04:13:35.016Z sha 713e923 :: blocked before merge. :: none
  • reviewed 2026-10-02T07:47:22.906Z sha 9a542e3 :: blocked before merge. :: none
  • reviewed 2026-10-02T11:16:06.247Z sha f1eda59 :: blocked before merge. :: none
  • reviewed 2026-10-02T12:22:05.571Z sha c0e6c57 :: blocked before merge. :: none
  • reviewed 2026-10-02T16:10:54.257Z sha 1608dca :: blocked before merge. :: none
  • reviewed 2026-10-02T16:34:05.244Z sha 8d60716 :: blocked before merge. :: none
  • reviewed 2026-10-02T17:29:24.717Z sha 6368d17 :: blocked before merge. :: none
  • reviewed 2026-10-02T21:04:57.255Z sha fda96fe :: blocked before merge. :: none

Restore the ordinary pre-dispatch fence to main so mutation commit guards
retain handler-entry ordering for plugin contention and ACP cleanup.
Session file reads use non-committing request checks, including their
borrowed chat.send authorization, without consuming mutation callbacks.

Append deferred classic preview scripts after authored HTML in source
order. Keep module, async, and blocking scripts in place. Update forwarded
message fixtures for current renderer APIs while retaining file ownership
assertions.

Validation: all 12 requested test files and the HTML preview browser suite;
core, UI, UI-test, and source-test type lanes; copy-out oxlint and oxfmt over
all 63 branch-changed files; git diff --check. The existing Linux-only
non-UTF-8 filename test is skipped on macOS.
The previous commit also special-cased sessions.files.* in the router and
swapped their transport commit guard for a new non-committing check. That
was not needed: in-root file reads on main already revalidate through
retainSessionScopedRead, which runs the request's commit guard, and
production guards are caller-currency assertions. The actual regression was
only the pre-dispatch tail invoking assertInvocationCurrent for every
request, which the previous commit already restored to main.

Restore server-methods.ts, session-mutation-guards.ts and the turn-authority
test to their reviewed state; the host-read path again revalidates through
requestMutationAuthority.assertCurrent(), matching existing reads.

Validation: plugins.lifecycle-contention (2/2) and acp spawn (13/13) pass;
session-turn-authority, host-read and assets suites pass (23 tests);
tsgo:core and tsgo:test:src pass.
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Oct 2, 2026
Replace the end-of-document append path with in-place inline module
trampolines. Each trampoline inserts the original code as an inline classic
script, preserving document order with modules, classic globals, retained
attributes, and sloppy mode under the existing sandbox CSP and document guard.
Escape serialized code and attributes against HTML script termination.

Replace the srcdoc-only regression with the real session-file preview path,
mocked sessions.files.assets, and the actual sandbox host. Before the fix it
produced "undefined true in order"; afterward it produces "ready true in order"
and confirms blocking head scripts run before the body exists. Document the
script ordering behavior.

Validation (wall time): assets 9/9, 3.80s; full HTML preview E2E 3/3, 31.40s;
preview element 34/34, 6.92s; tsgo:ui 9.75s; tsgo:test:ui 85.04s.
Copy-out oxlint checked all 3 TypeScript files, 0.12s; copy-out oxfmt checked
all 4 changed files, 0.34s. git diff --check passed.
@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: 🦐 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: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 2, 2026
@steipete
steipete enabled auto-merge (squash) October 2, 2026 05:14
…pete/web-ui-wm-clickability-8a43b7

# Conflicts:
#	ui/src/pages/chat/components/chat-detail-slot.ts
…pete/web-ui-wm-clickability-8a43b7

# Conflicts:
#	src/gateway/methods/core-descriptors.ts
#	src/gateway/server-methods-list.test.ts
…pete/web-ui-wm-clickability-8a43b7

# Conflicts:
#	ui/src/pages/chat/components/chat-message.forwarded-attribution.test.ts
…pete/web-ui-wm-clickability-8a43b7

# Conflicts:
#	src/gateway/methods/core-descriptors.ts
#	src/gateway/server-methods-list.test.ts
…pete/web-ui-wm-clickability-8a43b7

# Conflicts:
#	src/gateway/server-methods.ts
#	src/gateway/session-row-prepared-read.test.ts
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Oct 3, 2026
@steipete
steipete merged commit c183920 into main Oct 3, 2026
155 checks passed
@steipete
steipete deleted the steipete/web-ui-wm-clickability-8a43b7 branch October 3, 2026 00:35
steipete added a commit that referenced this pull request Oct 3, 2026
File preview identities now include the session key. The mocked files response
still returned main while the pane used agent:main:main, so the active row could
never match after the preview resolved. Match the response to the requested
session, preserving the delayed-directory response and both content/selection
assertions. No production behavior changes.

Remote proof on captured main 06ac4a4 using the native UI E2E owner reproduced
the one original failure across 3 tests in 47s; the reviewed correction passed
all 3 in 22s. Combined fixture proof used Hetzner lease cbx_0ddfa2afe062,
run run_2fdec9b8159f9fdd9a8551bc1b942607. Direct review was clean.

Refs #163185, #162920.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 3, 2026
…previews drop their assets (openclaw#163185)

* fix(ui): open file links outside the session workspace and load HTML preview assets

File links in Control UI chat failed with "Failed to load" when the file lived
outside the viewing session's workspace root, which is common for links in
forwarded/inter-session updates and for agent-workspace scratch files. HTML
previews also rendered without their relative images, stylesheets and scripts.

- sessions.files.get/list follow the session agent's file-tool read boundary:
  contained in read-only/guarded/workspace modes, with tools.fs.workspaceOnly,
  under a sandbox, or when file tools do not run on the Gateway host;
  otherwise host paths are readable. Out-of-root reads additionally require
  the caller to pass the real chat.send admission for that session, run inside
  prepared session facts and rechecked after I/O. Out-of-root previews are
  read-only; write containment is unchanged.
- Links inside messages with a sender session open against that session.
- New session read method sessions.files.assets lets the UI inline relative
  assets into sandboxed HTML previews by source offset (64 refs, 1 MiB per
  asset, 4 MiB per call; fonts stay unloaded under the unchanged CSP).
- canvas.document.preview joins session-reader admission so session-only
  readers can render HTML previews.
- authorizeGatewayRequestPreDispatch moves unchanged into
  server-methods/request-authorization.ts with a synchronous
  consumeSessionTurn hook.

* fix(gateway): preserve pre-dispatch and preview script scheduling

Restore the ordinary pre-dispatch fence to main so mutation commit guards
retain handler-entry ordering for plugin contention and ACP cleanup.
Session file reads use non-committing request checks, including their
borrowed chat.send authorization, without consuming mutation callbacks.

Append deferred classic preview scripts after authored HTML in source
order. Keep module, async, and blocking scripts in place. Update forwarded
message fixtures for current renderer APIs while retaining file ownership
assertions.

Validation: all 12 requested test files and the HTML preview browser suite;
core, UI, UI-test, and source-test type lanes; copy-out oxlint and oxfmt over
all 63 branch-changed files; git diff --check. The existing Linux-only
non-UTF-8 filename test is skipped on macOS.

* fix(gateway): keep session file reads on the existing request guard

The previous commit also special-cased sessions.files.* in the router and
swapped their transport commit guard for a new non-committing check. That
was not needed: in-root file reads on main already revalidate through
retainSessionScopedRead, which runs the request's commit guard, and
production guards are caller-currency assertions. The actual regression was
only the pre-dispatch tail invoking assertInvocationCurrent for every
request, which the previous commit already restored to main.

Restore server-methods.ts, session-mutation-guards.ts and the turn-authority
test to their reviewed state; the host-read path again revalidates through
requestMutationAuthority.assertCurrent(), matching existing reads.

Validation: plugins.lifecycle-contention (2/2) and acp spawn (13/13) pass;
session-turn-authority, host-read and assets suites pass (23 tests);
tsgo:core and tsgo:test:src pass.

* fix(ui): keep deferred preview scripts in order with module scripts

Replace the end-of-document append path with in-place inline module
trampolines. Each trampoline inserts the original code as an inline classic
script, preserving document order with modules, classic globals, retained
attributes, and sloppy mode under the existing sandbox CSP and document guard.
Escape serialized code and attributes against HTML script termination.

Replace the srcdoc-only regression with the real session-file preview path,
mocked sessions.files.assets, and the actual sandbox host. Before the fix it
produced "undefined true in order"; afterward it produces "ready true in order"
and confirms blocking head scripts run before the body exists. Document the
script ordering behavior.

Validation (wall time): assets 9/9, 3.80s; full HTML preview E2E 3/3, 31.40s;
preview element 34/34, 6.92s; tsgo:ui 9.75s; tsgo:test:ui 85.04s.
Copy-out oxlint checked all 3 TypeScript files, 0.12s; copy-out oxfmt checked
all 4 changed files, 0.34s. git diff --check passed.

* test(agents): stub the moved pre-dispatch authorizer in shared announce mocks

openclaw#163513 introduced subagent-announce.requester-settle-dispatch-mocks.test-support.ts
with authorizeGatewayRequestPreDispatch stubbed on gateway/server-methods.js.
This branch moved that function to server-methods/request-authorization.ts,
so the stub stopped intercepting and both announce suites silently ran the
real authorizer. Stub it on its owning module, matching the other moved mocks.

Validation: requester-settle-dispatch (18) and requester-settle-watch (3)
pass; copy-out oxfmt and oxlint clean.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 3, 2026
File preview identities now include the session key. The mocked files response
still returned main while the pane used agent:main:main, so the active row could
never match after the preview resolved. Match the response to the requested
session, preserving the delayed-directory response and both content/selection
assertions. No production behavior changes.

Remote proof on captured main 1311a9c using the native UI E2E owner reproduced
the one original failure across 3 tests in 47s; the reviewed correction passed
all 3 in 22s. Combined fixture proof used Hetzner lease cbx_0ddfa2afe062,
run run_2fdec9b8159f9fdd9a8551bc1b942607. Direct review was clean.

Refs openclaw#163185, openclaw#162920.
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 docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. 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. security-sensitive-changed size: XL 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