Skip to content

feat(chat): render user and agent media in native chat - #1119

Merged
karkarl merged 2 commits into
openclaw:mainfrom
calebeden:calebeden-investigate-media-rendering
Aug 19, 2026
Merged

feat(chat): render user and agent media in native chat#1119
karkarl merged 2 commits into
openclaw:mainfrom
calebeden:calebeden-investigate-media-rendering

Conversation

@calebeden

@calebeden calebeden commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes two native chat media problems:

  • User attachments could reappear as duplicate or raw Gateway media-envelope bubbles instead of reconciling with the local preview.
  • Assistant media could appear as a raw MEDIA: path instead of rendering as native chat content.

Why This Change Was Made

The chat pipeline now preserves typed user and assistant media metadata across live events, reset, backfill, and history. Assistant media is resolved only through authenticated Gateway contracts. Model-provided paths are never treated as Windows filesystem paths or arbitrary URLs.

Assistant-media HTTP authentication is connection-owned and separate from WebSocket authentication. Requests remain scoped to the active Gateway authority and connection generation.

User Impact

Users can send image attachments without duplicate media echoes and view assistant-generated images directly in native chat. Images have bounded inline previews, accessible loading and unavailable states, Retry, and a lightbox. Unsupported media remains visible as a safe fallback card without exposing raw Gateway paths.

Evidence

Prepared current head: bf763987a45c0b5859226537c7524c72b650d77c

Rebased onto origin/main at 428db773d8beb7d1c7452a68f4224dd43e3c76e4.

  • Full repository build passed.
  • Shared tests: 3,785 passed, 32 skipped, 0 failed.
  • Tray tests: 2,688 passed, 0 failed.
  • Connection tests: 660 passed, 0 failed.
  • WinUI/UI/accessibility tests: 143 passed, 0 failed.
  • Functional UI tests: 19 passed, 0 failed.
  • Real-process integration tests: 22 passed, 0 failed.
  • Focused Shared media/security/HTTP/auth tests: 23 passed, 0 failed.
  • Focused Tray live/reset/backfill/history/media/rendering tests: 60 passed, 0 failed.
  • Claude Opus 4.6 and GPT-5.3 Codex adversarial reviews found no verified critical or high-severity defect in the final delta.

Picture Proof

Native chat rendering a user image and authenticated assistant image at current head

The screenshot is intentionally cropped to the media cards and generic connection state. It contains no endpoint, token, device name, filesystem or WSL path, or PII.

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Validation

  • ./build.ps1
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore
  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore
  • Complete Connection, WinUI/UI/accessibility, functional UI, and real-process integration projects
  • Focused malicious-input, media HTTP/auth, rendering, live/reset/backfill/history, queue, persistence, and deduplication selections

Known timing noise was cleared rather than waived. A queued-send timing test passed five targeted reruns and the subsequent complete suite. Prior telemetry, virtualization, and camera timing flakes also passed targeted and complete reruns.

Real Behavior Proof

  • Environment: isolated Windows ARM64 tray and isolated WSL Gateway 2026.6.34, protocol 4
  • PR head tested: bf763987a45c0b5859226537c7524c72b650d77c
  • QR setup-code reconnect through Tray MCP: passed
  • Gateway restart and tray/node reconnect: passed
  • User PNG paste: bounded local decode rendered and the Gateway echo correlated without a duplicate row
  • Assistant Gateway-side PNG: resolved through authenticated attach.grant and same-origin HTTP, decoded, and rendered inline
  • Reset sequence: reset, verified tray-originated post-reset user turn, then distinct assistant media rendered under the new reset generation
  • Post-reset Gateway history retained 3 messages
  • Screenshot link verified after upload: yes
  • Not verified or blocked: none for the changed media behavior

Security Impact

  • New permissions or capabilities? (Yes/No): No
  • Secrets or tokens handling changed? (Yes/No): Yes
  • New or changed network calls? (Yes/No): Yes
  • Command or tool execution surface changed? (Yes/No): No
  • Data access scope changed? (Yes/No): Yes

Assistant media retrieval uses same-Gateway authenticated requests. Shared token is preferred, followed only by a current non-bootstrap device token; otherwise media HTTP remains disabled. Strong credentials are endpoint-provenance gated and cleared before reconnect reauthorization. Redirects are disabled. Managed ticket paths, exact host and port, traversal, MIME families, connection generation, encoded and streamed byte sizes, and decoded image dimensions are validated. File URIs, UNC paths, authority changes, fragments, backslashes, and traversal are rejected. Credentials, tickets, paths, response bodies, and media bytes are not logged or displayed.

Local previews are bounded to 32 entries, 64 MiB total, and 10 MiB per item with FIFO eviction and an encoded-length precheck. Gateway references cannot access local preview bytes.

Compatibility and Migration

  • Backward compatible? (Yes/No): Yes
  • Config or environment changes? (Yes/No): No
  • Migration needed? (Yes/No): No
  • Upgrade steps: N/A

Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.
  • I left unresolved only conversations that still need maintainer judgment.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. labels Aug 7, 2026
@clawsweeper

clawsweeper Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codex review: needs changes before merge. Reviewed August 19, 2026, 7:18 PM ET / 23:18 UTC.

ClawSweeper review

What this changes

This branch adds typed media parsing, Gateway-backed media retrieval, attachment-echo correlation, and native chat rendering for user and assistant media.

Merge readiness

Blocked by patch quality or review findings - 6 items remain

This PR has credible current-head UI proof, but it still resolves assistant media when its independently authorized HTTP credential is absent. That conflicts with the stated fail-closed media boundary and is a P1 merge blocker.

Priority: P2
Reviewed head: bf763987a45c0b5859226537c7524c72b650d77c

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The live UI evidence is strong, but the missing fail-closed credential guard is a merge-blocking security defect.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): The PR body provides a current-head screenshot plus a redacted live Gateway and tray exercise covering local echo reconciliation, authenticated assistant-image rendering, reconnect, reset, and history.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): The PR body provides a current-head screenshot plus a redacted live Gateway and tray exercise covering local echo reconciliation, authenticated assistant-image rendering, reconnect, reset, and history.
Evidence reviewed 5 items Resolver remains fail-open without HTTP credentials: The media resolver checks connection state but not whether an independently authorized assistant-media HTTP credential exists, then proceeds to structured RPC or legacy HTTP resolution.
Regression test codifies unauthenticated retrieval: The new test expects a Ready result and two legacy-media requests with no Authorization header when no explicit HTTP credential is supplied.
Bootstrap connection intentionally has no media HTTP token: The connection test establishes that bootstrap-only setup produces an empty interactive HTTP token and a null assistant-media credential, making the resolver path reachable in the state that should be disabled.
Findings 1 actionable finding [P1] Block media resolution without an authorized HTTP credential
Security Needs attention Assistant media can resolve without its authorized HTTP token: A client with no assistant-media credential still sends legacy metadata and byte requests, despite the intended bootstrap and provenance safeguards withholding that credential.

How this fits together

The tray chat converts Gateway messages and local attachments into native conversation rows. This change carries media metadata through connection-scoped retrieval and safe WinUI rendering so users see previews instead of raw media paths or duplicate echoes.

flowchart LR
  A[Gateway chat events] --> B[Typed media projection]
  C[Local attachments] --> B
  B --> D[Connection-scoped authorization]
  D --> E[Bounded media retrieval]
  E --> F[Native chat timeline]
  B --> F
Loading

Before merge

  • Block media resolution without an authorized HTTP credential (P1) - ResolveAssistantMediaAsync starts resolution even when the manager intentionally withheld the interactive media credential. The new no-credential test confirms that legacy media can return Ready after unauthenticated requests. Return unavailable before either resolution branch and change that test to require zero requests.
  • Resolve security concern: Assistant media can resolve without its authorized HTTP token - A client with no assistant-media credential still sends legacy metadata and byte requests, despite the intended bootstrap and provenance safeguards withholding that credential.
  • Resolve merge risk (P1) - A bootstrap-only or otherwise withheld-media-credential client can still send assistant-media resolution requests, rather than returning an unavailable card before any Gateway RPC or HTTP request.
  • Complete next step (P2) - The P1 blocker has a narrow mechanical repair and a directly contradictory regression test.
  • Improve patch quality - Reject blank assistant-media credentials before starting structured or legacy resolution.
  • Improve patch quality - Replace the no-credential success test with coverage that confirms no RPC or HTTP request is made.

Findings

  • [P1] Block media resolution without an authorized HTTP credential — src/OpenClaw.Shared/OpenClawGatewayClient.AssistantMedia.cs:22-25
  • [high] Assistant media can resolve without its authorized HTTP token — src/OpenClaw.Shared/OpenClawGatewayClient.AssistantMedia.cs:22
Agent review details

Security

Needs attention: The new credentialed media path is fail-open when its separate HTTP credential is absent.

Review metrics

Metric Value Why it matters
Patch scope 43 files, +5,757/-280 lines The change spans chat state, rendering, Gateway authorization, and tests, so the credential boundary is especially important.
Production versus test growth production +3,353/-241, tests +2,398/-39 The substantial test investment is useful, but one focused test currently asserts the unsafe no-credential behavior.

Merge-risk options

Maintainer options:

  1. Fail closed for missing media credentials (recommended)
    Return unavailable before any assistant-media RPC or HTTP request when the independently authorized media credential is blank, then replace the no-credential success test with a zero-request regression test.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Add a media-resolution credential guard and regression coverage proving no Gateway RPC or HTTP request occurs when interactive media authentication is empty.

Technical review

Best possible solution:

Require a current, independently authorized assistant-media credential before either media-resolution path starts, and retain the existing safe unavailable-card behavior when it is absent.

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

Yes. The included handler test constructs a connected client without an assistant-media credential and demonstrates that legacy media still resolves successfully with no Authorization header.

Is this the best way to solve the issue?

No. The rendering and provenance design is sound in direction, but the resolver must reject missing authorized media credentials before sending either structured or legacy retrieval requests.

Full review comments:

  • [P1] Block media resolution without an authorized HTTP credential — src/OpenClaw.Shared/OpenClawGatewayClient.AssistantMedia.cs:22-25
    ResolveAssistantMediaAsync starts resolution even when the manager intentionally withheld the interactive media credential. The new no-credential test confirms that legacy media can return Ready after unauthenticated requests. Return unavailable before either resolution branch and change that test to require zero requests.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 428db773d8be.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides a current-head screenshot plus a redacted live Gateway and tray exercise covering local echo reconciliation, authenticated assistant-image rendering, reconnect, reset, and history.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The PR body provides a current-head screenshot plus a redacted live Gateway and tray exercise covering local echo reconciliation, authenticated assistant-image rendering, reconnect, reset, and history.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦞 diamond lobster and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (screenshot): The PR body provides a current-head screenshot plus a redacted live Gateway and tray exercise covering local echo reconciliation, authenticated assistant-image rendering, reconnect, reset, and history.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P2: This is a substantial user-visible chat improvement with a bounded but merge-blocking credential defect.
  • merge-risk: 🚨 auth-provider: Assistant-media retrieval adds a separate authorization token whose absence is not currently enforced at the resolver.
  • merge-risk: 🚨 security-boundary: The patch turns Gateway-originated media references into authenticated network requests and must fail closed when that authorization is unavailable.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦞 diamond lobster and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (screenshot): The PR body provides a current-head screenshot plus a redacted live Gateway and tray exercise covering local echo reconciliation, authenticated assistant-image rendering, reconnect, reset, and history.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides a current-head screenshot plus a redacted live Gateway and tray exercise covering local echo reconciliation, authenticated assistant-image rendering, reconnect, reset, and history.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The PR body provides a current-head screenshot plus a redacted live Gateway and tray exercise covering local echo reconciliation, authenticated assistant-image rendering, reconnect, reset, and history.

Evidence

Security concerns:

  • [high] Assistant media can resolve without its authorized HTTP token — src/OpenClaw.Shared/OpenClawGatewayClient.AssistantMedia.cs:22
    A client with no assistant-media credential still sends legacy metadata and byte requests, despite the intended bootstrap and provenance safeguards withholding that credential.
    Confidence: 0.99

Acceptance criteria:

  • [P1] ./build.ps1.
  • [P1] dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore.
  • [P1] dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore.
  • [P1] dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore --filter FullyQualifiedName~OpenClawGatewayClientAssistantMediaTests.

What I checked:

Likely related people:

  • Barbara Kudiess: Recent main history includes the connection protocol work and the chat runtime-state extraction that this PR extends. (role: recent connection and chat-state contributor; confidence: high; commits: 428db773d8be, f8a8825ccbb4; files: src/OpenClaw.Connection/GatewayConnectionManager.cs, src/OpenClaw.Tray.WinUI/Chat/OpenClawChatDataProvider.cs)
  • Scott Hanselman: Recent main history covers listener-provenance and credential-handoff hardening adjacent to the new media-token path. (role: recent credential-boundary contributor; confidence: high; commits: a51029ef6f77; files: src/OpenClaw.Connection/GatewayConnectionManager.cs)
  • Régis Brid: The native chat timeline and message reconciliation surface originates in this contributor's merged chat work. (role: major native-chat contributor; confidence: medium; commits: 5505a85da7df, 3fdfbfad837f; files: src/OpenClaw.Tray.WinUI/Chat/OpenClawChatDataProvider.cs, src/OpenClaw.Tray.WinUI/Chat/ReactorChatTimeline.cs)

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-08-07T18:00:42.362Z sha f8e07d1 :: needs real behavior proof before merge. :: [P1] Use the HTTP credential contract for media downloads
  • reviewed 2026-08-07T21:35:55.217Z sha 69c4358 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-07T21:45:44.757Z sha a5f614e :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-07T22:06:03.717Z sha a5f614e :: needs real behavior proof before merge. :: [P1] Reject legacy media when HTTP credentials are absent
  • reviewed 2026-08-10T18:58:10.088Z sha a5f614e :: needs real behavior proof before merge. :: [P1] Require an HTTP credential before resolving media

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 7, 2026
@calebeden calebeden changed the title feat(chat): render user and assistant media in native chat feat(chat): render user and agent media in native chat Aug 7, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. label Aug 7, 2026
@calebeden
calebeden marked this pull request as ready for review August 10, 2026 18:51
@clawsweeper

clawsweeper Bot commented Aug 10, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

calebeden and others added 2 commits August 19, 2026 14:28
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Bound local preview memory, enforce guarded local image decoding, preserve media metadata across history and reset reconciliation, and keep runtime V2 credential upgrades without allowing downgrades.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4f74b3dc-62de-4bf8-abee-aae3915b2f89
@karkarl karkarl added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Aug 19, 2026
@karkarl
karkarl force-pushed the calebeden-investigate-media-rendering branch from a5f614e to bf76398 Compare August 19, 2026 23:11
@clawsweeper clawsweeper Bot added proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 19, 2026
@karkarl
karkarl merged commit a76c852 into openclaw:main Aug 19, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P2 Normal priority bug or improvement with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants