Repository navigation
fix: local videos fail to play inline in chat and rejected media links show as raw text - #164137
Conversation
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.
|
🦞👀 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. |
|
Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 5:27 AM ET / 09:27 UTC (Revision 4). ClawSweeper reviewWhat this changesThe 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 Review scores
Verification
How this fits togetherAssistant 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]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +258, Tests +312, Docs +15. Total +585 across 35 files. View PR surface stats
Review metrics
Technical reviewBest 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. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
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.
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.
|
Merged via squash.
|
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.
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.
…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.
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.
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:/pathnow play inline in the Control UI up to 4 GiB with seeking, and aMEDIA: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
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.OutboundMediaAccess,resolveOutboundAttachmentFromUrl) is unchanged frommain. Descriptor access lives in the host-onlyHostOutboundMediaAccess, and large local audio/video staging lives inresolveWebchatAttachmentFromUrl, used only by webchat display staging. No new SDK contract.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;
mainatca77256127e6vs this branch.Before, local file (
main): the 46 MB clip fails the 16 MB cap.Before, portal workaround (
main): the agent opens a portal and theMEDIA:line renders as a raw link.After, local file: inline player; played, then seeked to 1:35 in the Control UI (
readyState4, 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, rejected reference: one assistant message with a "Media not attached" card, no raw link, and a single transcript row (no
:assistant-mediaduplicate).Focused tests (local, one file at a time,
--maxWorkers=1):src/media/parse.test.ts198 passed (3 s)src/gateway/server-methods/chat-reply-media.large-video.test.ts1 passed (105 s): 32 MiB sparse MP4, no whole-file allocation, header swap after MIME validation is ignored, 206 seek rangesrc/gateway/server-methods/chat-reply-media.test.ts35 passed (46 s)src/gateway/server-methods/chat.directive-tags.test.ts132 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.ts33,src/infra/outbound/payloads.test.ts59,src/agents/embedded-agent-subscribe.directive-delivery.test.ts26, plus store, read-scope, local-media-access, managed-image-attachments and UI attachment suites from the first commitpnpm tsgo,pnpm tsgo:ui, oxfmt 0.68.0 checkNot run locally: full
check:changedand full suites (left to CI).