Skip to content

fix: local videos fail to play inline in chat and rejected media links show as raw text - #164137

Merged
steipete merged 6 commits into
mainfrom
steipete/inline-playback-failure-abcea4
Oct 3, 2026
Merged

steipete merged 6 commits into
mainfrom
steipete/inline-playback-failure-abcea4

Conversation

@steipete

@steipete steipete commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: asking the agent to show a local video inline in the Control UI either fails ("Delivery failed" for anything over 16 MB) or, when the agent works around it with a portal URL, leaves a raw MEDIA:http://… link in the chat with no warning.

User Impact

User impact: local audio and video attached with MEDIA:/path now play inline in the Control UI up to 4 GiB with seeking, and a MEDIA: reference the gateway refuses (plain http, private/LAN hosts, credentials in the URL) shows a visible "Media not attached" card that says what to do instead of a dead link. Channel outbound limits are unchanged.

Why This Change Was Made

  • Rejected MEDIA: references used to fall through the parser as plain text. The parser now strips the directive line and reports how many references it rejected, and that count feeds the existing reply media failure contract (invalid-reference), so webchat, channels and the TUI all get the same visible outcome.
  • Webchat display staging now streams local audio/video from the admitted file descriptor into managed media instead of buffering it, under a 4 GiB display cap selected explicitly by the webchat display path. The trusted-local boundary and every channel cap stay as they were; the existing managed media route already serves byte ranges.
  • A webchat reply whose only directive was rejected had no media URLs, so the indexed transcript rewrite refused to match and the dispatcher appended a duplicate assistant row. The rewrite now also identifies the turn by its rejected-reference count.
  • Streaming stays internal: the public plugin SDK (OutboundMediaAccess, resolveOutboundAttachmentFromUrl) is unchanged from main. Descriptor access lives in the host-only HostOutboundMediaAccess, and large local audio/video staging lives in resolveWebchatAttachmentFromUrl, used only by webchat display staging. No new SDK contract.
  • The portal tool description now says portals are for apps and dev servers, not files, and points at MEDIA:<path>. In live testing the model stopped proposing the portal workaround.

Evidence

Live, isolated local gateways with a real model (Claude Sonnet 5) and a synthetic 46 MB test clip; main at ca77256127e6 vs this branch.

Before, local file (main): the 46 MB clip fails the 16 MB cap.

before: local video delivery failed

Before, portal workaround (main): the agent opens a portal and the MEDIA: line renders as a raw link.

before: raw portal link

After, local file: inline player; played, then seeked to 1:35 in the Control UI (readyState 4, no media error). Screenshot taken after seeking to 0:42 (burned-in timecode). Direct range read: 206 Partial Content, Content-Range: bytes 40000000-40000099/46170658, video/mp4.

after: inline video at 0:42

After, rejected reference: one assistant message with a "Media not attached" card, no raw link, and a single transcript row (no :assistant-media duplicate).

after: media not attached card

Focused tests (local, one file at a time, --maxWorkers=1):

  • src/media/parse.test.ts 198 passed (3 s)
  • src/gateway/server-methods/chat-reply-media.large-video.test.ts 1 passed (105 s): 32 MiB sparse MP4, no whole-file allocation, header swap after MIME validation is ignored, 206 seek range
  • src/gateway/server-methods/chat-reply-media.test.ts 35 passed (46 s)
  • src/gateway/server-methods/chat.directive-tags.test.ts 132 passed (70 s); the new rejected-media rewrite test fails on the pre-fix code (2 rows instead of 1)
  • src/auto-reply/reply/reply-media-paths.test.ts 33, src/infra/outbound/payloads.test.ts 59, src/agents/embedded-agent-subscribe.directive-delivery.test.ts 26, plus store, read-scope, local-media-access, managed-image-attachments and UI attachment suites from the first commit
  • pnpm tsgo, pnpm tsgo:ui, oxfmt 0.68.0 check

Not run locally: full check:changed and full suites (left to CI).

Route policy-rejected MEDIA references through shared reply failure receipts
and managed attachment errors without exposing rejected URLs in visible text.
Preserve literal directive examples in prose and code.

Stream authorized local audio/video through the media store under a built-in
4 GiB webchat display limit. Preserve channel limits, trusted-local access,
validated header bytes, and durable file/directory publication. Keep the
existing managed HTTP Range route for inline playback and seeking.

Clarify that portals preview apps and development servers; attach files with
MEDIA paths. Document the display limits and visible rejection behavior.

Validation: 532 tests across 12 targeted Vitest files, core/UI and test
shard typechecks, scoped lint/format, and line-cap checks. Full build was
stopped during declaration generation before the final stream corrections;
live/browser proof and review remain with the coordinator.
Route rejected MEDIA directive failures through one payload helper, report
only a rejected-reference count from the parser, and select the webchat
local audio/video cap with an explicit option instead of overriding the
requester's message provider.
A webchat reply whose only MEDIA directive was rejected carried a failure
card but no media URLs, so the indexed transcript rewrite refused to match
and the dispatcher appended a duplicate assistant row. Match the turn by
its rejected-reference count as well.
@clawsweeper

clawsweeper Bot commented Oct 3, 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: L labels Oct 3, 2026
@steipete
steipete marked this pull request as ready for review October 3, 2026 07:32
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. 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 Oct 3, 2026
@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 5:27 AM ET / 09:27 UTC (Revision 4).

ClawSweeper review

What this changes

The branch streams authorized local audio and video into Control UI chat players, shows actionable notices for rejected media references, and prevents duplicate assistant transcript entries.

Merge readiness

✅ Ready for maintainer review

This PR remains useful because current main still has the reported limitations. The previous SDK blocker is resolved, and no blocking introduced defect was found.

Priority: P2
Reviewed head: fd047741ff0d1f93cd2143967d2048fdfdafde56

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, well-demonstrated work with the prior SDK concern resolved and no blocking correctness finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The inspected before/after Control UI images show failed delivery becoming an inline video and rejected text becoming a failure card; captured browser state and the 206 range response support actual playback and seeking through the Gateway media path. The latest revision relocates this same behavior internally. Existing attachment records retain their shape and accepted codes, with additive failure handling and no schema migration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The inspected before/after Control UI images show failed delivery becoming an inline video and rejected text becoming a failure card; captured browser state and the 206 range response support actual playback and seeking through the Gateway media path. The latest revision relocates this same behavior internally. Existing attachment records retain their shape and accepted codes, with additive failure handling and no schema migration.
Evidence reviewed 10 items Pinned introduced change: Reviewed the merge-base-to-head delta. The original head's raw parent is d182cf9. The supplied stale test merge was not used to infer removal of current-main behavior.
Previous SDK concern resolved: The latest commit removes descriptor access and the additional limit from the public attachment contracts. HostOutboundMediaAccess and webchat staging retain the behavior internally; load-options.ts, outbound-attachment.ts, and plugin SDK files have no introduced delta against the pinned base. A local historical-blob fetch failed with HTTP 403; GitHub's read-only compare endpoint supplied the latest revision patch.
Streaming and transport fallback: Webchat staging verifies native audio/video header bytes, preserves those inspected bytes during copying, disposes the descriptor, and falls back to the existing buffered attachment owner when native access is unavailable. Remote workspace namespaces do not fall through to stale native copies.
Findings None None.
Security None None.

How this fits together

Assistant replies supply media references to the Gateway, which checks file access and stages attachments for chat display. The Control UI plays managed media through the authenticated media route and renders attachment failures.

flowchart TD
  A[Assistant reply] --> B[Parse media references]
  B --> C[Rejected reference notice]
  B --> D[Check local file access]
  D --> E[Stream into managed storage]
  E --> F[Authenticated seekable media route]
  F --> G[Control UI player]
  C --> H[Chat failure card]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +258, Tests +312, Docs +15. Total +585 across 35 files.

View PR surface stats
Area Files Added Removed Net
Source 27 387 129 +258
Tests 7 346 34 +312
Docs 1 21 6 +15
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 35 754 169 +585

Review metrics

Metric Value Why it matters
Local display ceiling 16 MiB → 4 GiB for local audio/video The larger ceiling is confined to native local display staging; channel, remote URL, and buffered transport caps remain intact.
Production versus test growth production +258 lines, tests +312 lines Production growth has a stated purpose in bounded streaming, descriptor ownership, and shared failure propagation.

Technical review

Best possible solution:

Keep large-file staging within the Gateway's display path, preserve existing channel and plugin contracts, and use the shared failure receipt for rejected references.

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

Yes, source establishes the current-main failure paths: local audio/video hits the existing size caps, and policy-rejected MEDIA URLs remain visible text. The supplied before/after run corroborates both; this reviewer did not execute them.

Is this the best way to solve the issue?

Yes. An internal webchat staging adapter preserves the public SDK and transport limits while the existing reply failure contract supplies consistent notices.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.

Label justifications:

  • P2: This repairs a bounded chat media-display problem with demonstrated user impact.
  • 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 (live_output): The inspected before/after Control UI images show failed delivery becoming an inline video and rejected text becoming a failure card; captured browser state and the 206 range response support actual playback and seeking through the Gateway media path. The latest revision relocates this same behavior internally. Existing attachment records retain their shape and accepted codes, with additive failure handling and no schema migration.
  • proof: sufficient: Contributor real behavior proof is sufficient. The inspected before/after Control UI images show failed delivery becoming an inline video and rejected text becoming a failure card; captured browser state and the 206 range response support actual playback and seeking through the Gateway media path. The latest revision relocates this same behavior internally. Existing attachment records retain their shape and accepted codes, with additive failure handling and no schema migration.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. The shared parser changes visible Telegram reply text for rejected MEDIA directives; the larger playback limit is webchat-only.

Evidence

What I checked:

  • Pinned introduced change: Reviewed the merge-base-to-head delta. The original head's raw parent is d182cf9. The supplied stale test merge was not used to infer removal of current-main behavior. (fd047741ff0d)
  • Previous SDK concern resolved: The latest commit removes descriptor access and the additional limit from the public attachment contracts. HostOutboundMediaAccess and webchat staging retain the behavior internally; load-options.ts, outbound-attachment.ts, and plugin SDK files have no introduced delta against the pinned base. A local historical-blob fetch failed with HTTP 403; GitHub's read-only compare endpoint supplied the latest revision patch. (src/media/read-capability.ts:24, fd047741ff0d)
  • Streaming and transport fallback: Webchat staging verifies native audio/video header bytes, preserves those inspected bytes during copying, disposes the descriptor, and falls back to the existing buffered attachment owner when native access is unavailable. Remote workspace namespaces do not fall through to stale native copies. (src/media/webchat-attachment.ts:27, fd047741ff0d)
  • Access and publication safeguards: Local opening revalidates canonical roots, excluded remote roots, file size, and current read scope. Streaming enforces the byte cap and current scope during writes; guarded publication retains synchronous authority checks and atomic, durable publication. (src/media/store.ts:619, fd047741ff0d)
  • Inspected real behavior evidence: Inspected all four prepared images from the captured PR body: failed local delivery, the raw portal directive, an inline 44 MB video visibly displaying its burned-in 0:42 frame, and the actionable rejection card. The captured body additionally records readyState 4, no media error, and a 206 response for bytes 40000000–40000099 of the 46170658-byte MP4. Together these exercise Gateway staging, media serving, and browser playback rather than merely startup or mocked rendering.
  • Existing-state compatibility: The attachment failure representation retains its existing fields and accepted codes, adding invalid-reference without changing the database schema or rewriting existing settings. The modified UI case still renders the existing unsupported-format record; the Gateway regression exercises replacement of the existing assistant row rather than appending a duplicate. (ui/src/lib/chat/message-normalizer-attachments.ts:21, fd047741ff0d)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • sxh313: 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 (3 earlier review cycles)
  • reviewed 2026-10-03T07:38:13.254Z sha 0d88946 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-03T08:44:32.096Z sha 2f0c1a0 :: blocked before merge. :: none
  • reviewed 2026-10-03T08:56:39.219Z sha d182cf9 :: blocked before merge. :: none

Merge main 6f85fa9 without rebasing.
Keep the simplified data URL parser and flattened saved-original flow,
while preserving the shared media-kind helpers and local audio/video
playback ceiling. Remote, data URL, and untrusted-local limits remain
unchanged; the existing trust guard runs before high-limit ingestion.

Validation: core and UI typechecks passed; managed attachments 56/56,
large-video regression 1/1, reply media 35/35, and prepared harness
source delivery 10/10 passed with --maxWorkers=1. oxfmt 0.68.0 passed
on the five files with merged changes. Test wall times: 94.91s, 68.08s,
50.48s, and 90.97s respectively.
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Oct 3, 2026
The outside-workspace store test mocked readLocalFileSafely, which local
saves no longer call after streaming through openLocalFileSafely; mock the
seam the store actually uses. The opener type has no external importers.
Keep descriptor access in HostOutboundMediaAccess and webchat staging in resolveWebchatAttachmentFromUrl. Restore the public media access and attachment contracts to origin/main while preserving the 4 GiB local audio/video display cap, trusted-local policy, and outbound channel limits.
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Oct 3, 2026
@steipete
steipete merged commit 42e9715 into main Oct 3, 2026
150 checks passed
@steipete
steipete deleted the steipete/inline-playback-failure-abcea4 branch October 3, 2026 09:38
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

MarMarLabs added a commit to MarMarLabs/openclaw that referenced this pull request Oct 3, 2026
216 upstream commits, including cloud workers for enterprise repositories
(openclaw#160108), which adds core config fields, so the core count goes from 2492
to 2501 and the core hash changes. The only Feishu change upstream is
extensions/feishu/package.json, which this branch does not touch.

Two generated conflicts, docs/.generated/config-baseline.counts.json and
config-baseline.sha256, regenerated from this merge rather than
hand-merged. build:docker ran in a separate detached checkout of this
commit. Counts core 2492 to 2501, channel 3788 and plugin 4468. The core
and plugin hashes match upstream/main and the channel hash stays this
branch's, as predicted. The generated channel metadata did not change, and
the three generated-file checks pass there.

Feishu: 102 files and 1519 tests pass in the extension project. In the
database-workers project 240 of 241 pass. The one failure, "routes
oversized presentation media through one media send and chunked fallback
text" in outbound-delivery.test.ts, fails the same way on upstream/main
db01f6d with this branch absent. openclaw#164137 added openFile to the
outbound media access and that test compares mediaAccess exactly. It is
left as upstream has it. The forwarder test and the routing guards pass,
454 tests. tsgo:core, tsgo:extensions, tsgo:extensions:test,
tsgo:test:root, the line-cap, max-lines and assertion-safety ratchets
against upstream/main, oxlint and oxfmt on the 43 changed code files all
pass.
steipete added a commit that referenced this pull request Oct 3, 2026
Commit 42e9715 (#164137) made the core outbound media resolver
return a bounded native openFile alongside localRoots, readFile, and
workspaceDir. Feishu and iMessage forward the core-resolved access to
their senders unchanged, but their real-core delivery tests deep-compared
it against the caller-supplied object, so both failed deterministically.
These files only run in changed-extension PR lanes, so hourly main
stayed green (surfaced on PR #164103, run 37132997751).

Keep the comparison exact-shape and expect openFile as a function; the
identity checks on localRoots and readFile are unchanged. Sibling channel
tests that reach the core resolver (Discord, Slack, WhatsApp, Matrix,
MSTeams, Telegram, ClickClack, Feishu send authority) already pass.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
…s show as raw text (openclaw#164137)

* fix(media): report rejected directives and stream local playback

Route policy-rejected MEDIA references through shared reply failure receipts
and managed attachment errors without exposing rejected URLs in visible text.
Preserve literal directive examples in prose and code.

Stream authorized local audio/video through the media store under a built-in
4 GiB webchat display limit. Preserve channel limits, trusted-local access,
validated header bytes, and durable file/directory publication. Keep the
existing managed HTTP Range route for inline playback and seeking.

Clarify that portals preview apps and development servers; attach files with
MEDIA paths. Document the display limits and visible rejection behavior.

Validation: 532 tests across 12 targeted Vitest files, core/UI and test
shard typechecks, scoped lint/format, and line-cap checks. Full build was
stopped during declaration generation before the final stream corrections;
live/browser proof and review remain with the coordinator.

* refactor(media): centralize reply media failure metadata

Route rejected MEDIA directive failures through one payload helper, report
only a rejected-reference count from the parser, and select the webchat
local audio/video cap with an explicit option instead of overriding the
requester's message provider.

* fix(gateway): rewrite rejected-media replies in place

A webchat reply whose only MEDIA directive was rejected carried a failure
card but no media URLs, so the indexed transcript rewrite refused to match
and the dispatcher appended a duplicate assistant row. Match the turn by
its rejected-reference count as well.

* fix(media): keep descriptor opener type private and test the open seam

The outside-workspace store test mocked readLocalFileSafely, which local
saves no longer call after streaming through openLocalFileSafely; mock the
seam the store actually uses. The opener type has no external importers.

* refactor(media): keep local media streaming out of the plugin SDK

Keep descriptor access in HostOutboundMediaAccess and webchat staging in resolveWebchatAttachmentFromUrl. Restore the public media access and attachment contracts to origin/main while preserving the 4 GiB local audio/video display cap, trusted-local policy, and outbound channel limits.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
Commit 5c36f7f (openclaw#164137) made the core outbound media resolver
return a bounded native openFile alongside localRoots, readFile, and
workspaceDir. Feishu and iMessage forward the core-resolved access to
their senders unchanged, but their real-core delivery tests deep-compared
it against the caller-supplied object, so both failed deterministically.
These files only run in changed-extension PR lanes, so hourly main
stayed green (surfaced on PR openclaw#164103, run 37132997751).

Keep the comparison exact-shape and expect openFile as a function; the
identity checks on localRoots and readFile are unchanged. Sibling channel
tests that reach the core resolver (Discord, Slack, WhatsApp, Matrix,
MSTeams, Telegram, ClickClack, Feishu send authority) already pass.
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: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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