Repository navigation
Preview session workspace images and unsupported files - #95956
Conversation
There was a problem hiding this comment.
Pull request overview
Adds end-to-end session workspace file preview + lightweight editing: the gateway can now return richer file metadata (preview kind, encoding, mime type) and accept text-file writes; the web UI can open workspace files as either an inline image preview, a metadata-only view, or an editable text area, and save changes back through the gateway.
Changes:
- Extend gateway protocol
SessionFileEntrywith preview metadata, and addsessions.files.setparams/result schemas + validators. - Implement
sessions.files.sethandler with optimistic conflict detection (baseUpdatedAtMs) and safe workspace writes; return image previews as base64. - Add UI sidebar support for editable workspace text files (reset/save, dirty state) and unsupported-file metadata rendering, plus tests.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| ui/src/ui/views/markdown-sidebar.ts | Adds an editable text-file sidebar rendering branch (textarea + save/reset UI). |
| ui/src/ui/types.ts | Extends SessionWorkspaceFileEntry with preview metadata; adds SessionWorkspaceSetResult. |
| ui/src/ui/sidebar-content.ts | Extends markdown sidebar content model to optionally include editableTextFile editor state/actions. |
| ui/src/ui/markdown.test.ts | Adds unit test coverage for the editable text-file sidebar rendering and interactions. |
| ui/src/ui/app-render.ts | Adds workspace file open/save flows, editor state caching, unsupported metadata view, and image data-URL rendering. |
| src/gateway/server-methods/sessions-files.ts | Adds preview kind + encoding detection, image/base64 previews, and implements sessions.files.set with conflict checks and safe writes. |
| src/gateway/server-methods/sessions-files.test.ts | Expands handler tests to cover text edits, conflict detection, image previews, unsupported metadata, and path safety. |
| src/gateway/server-methods.ts | Registers sessions.files.set as a lazily loaded core handler. |
| src/gateway/methods/core-descriptors.ts | Assigns sessions.files.set an operator.admin scope. |
| src/gateway/method-scopes.test.ts | Verifies sessions.files.set remains admin-gated. |
| scripts/protocol-gen-swift.ts | Updates Swift generator defaults for new optional SessionFileEntry fields. |
| packages/gateway-protocol/src/schema/types.ts | Exposes SessionsFilesSetParams / SessionsFilesSetResult schema-backed TS types. |
| packages/gateway-protocol/src/schema/sessions.ts | Adds preview metadata schemas + sessions.files.set params/result schemas. |
| packages/gateway-protocol/src/schema/protocol-schemas.ts | Registers the new set params/result schemas in the protocol schema registry. |
| packages/gateway-protocol/src/index.ts | Exports the new set schemas/types and validator (validateSessionsFilesSetParams). |
| apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift | Regenerates Swift models for the new file entry fields and sessions.files.set types. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 62f0487343
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 62f0487343
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
5a0c46c to
368744a
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Codex review: needs maintainer review before merge. Reviewed July 29, 2026, 9:07 AM ET / 13:07 UTC. ClawSweeper reviewWhat this changesThe PR classifies session workspace files as text, allowlisted images, or unsupported binaries, sends safe preview metadata through the Gateway protocol, and renders images or metadata fallback in the Control UI. Merge readinessThis is a focused, well-proven continuation of the session workspace file work: the previously merged editor PRs cover text viewing and CAS editing, while this PR supplies the remaining image and unsupported-binary preview path. The current branch is cleanly mergeable but behind current Priority: P2 Review scores
Verification
How this fits togetherSession workspace file reads are opened through filesystem-safe Gateway helpers, classified by the Gateway, and returned over the Gateway protocol to the Control UI file detail panel. The panel preserves the existing text editor, renders only allowlisted base64 images, and presents metadata when a binary is not safe for inline preview. flowchart LR
A[Workspace file] --> B[Filesystem-safe file reader]
B --> C[Gateway preview classifier]
C --> D[Session file protocol response]
D --> E[Control UI file panel]
E --> F[Text editor]
E --> G[Allowlisted image preview]
E --> H[Unsupported binary metadata]
Decision needed
Why: The implementation is a new cross-client Gateway protocol and Control UI capability, and the protected maintainer label requires explicit human ownership despite strong proof and no identified patch defect. Before merge
Agent review detailsSecurityNone. PR surfaceSource +231, Tests +517, Docs 0, Other +32. Total +780 across 13 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Rebase the narrowed image/binary preview implementation onto current Do we have a high-confidence way to reproduce the issue? Not applicable: this PR adds a new session-file preview capability rather than repairing a reported current-main failure. The supplied real-browser evidence covers the intended text, PNG, and unsupported-BMP outcomes on the PR head. Is this the best way to solve the issue? Yes, conditionally: extending the existing AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f65c933287eb. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (15 earlier review cycles; latest 8 shown)
|
|
Current-main scope update: #104757 ( The still-useful part of this PR is image/binary preview classification ( Please rebase on current |
368744a to
706a2f7
Compare
86f6830 to
d5c9117
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
315b5b8 to
acf7b0f
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
acf7b0f to
b22197d
Compare
|
Documentation rank-up applied on top of the reviewed code. Exact PR head:
The docs-only exact head also has fresh sanitized browser proof: AWS Crabbox run The parent code head remains fully green across architecture, native i18n, protocol regeneration, 68 gateway tests, 24 Control UI tests, UI type checks, focused E2E lint, and GitHub CI. The PR body now points to the exact docs head GIF, screenshots, WebM, and manifest. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Co-authored-by: Colin <[email protected]>
|
Merged via squash.
|
What Problem This Solves
Session workspace files already support bounded viewing and hash-CAS text editing. Binary files were the remaining gap: current
mainconverts non-UTF-8 bytes to replacement-character text, while users need real previews for browser-safe images and a truthful metadata-only state for everything else.Why This Change Was Made
This is a full current-main rewrite of the original contribution. It keeps the established
sessions.files.*owner boundary, fs-safe path controls, and 256 KiB content cap while adapting the protocol, generated Swift client, Control UI, tests, and docs to the current architecture.User Impact
Implementation
mimeType,contentEncoding, andpreviewKindfields toSessionFileEntry.AgentsWorkspaceFile.encoding: AnyCodableAPI with a compile-time compatibility test.previewKindcompatible with pre-feature Gateways, which continue to display their string content as text.Dependency Contract
The implementation was verified directly against the pinned
file-type22.0.1 package source, types, and README.fileTypeFromBufferis magic-byte based and returnsundefinedwhen unmatched. Its source recognizes all five allowed image MIME types and also recognizes several strict-text formats; the Gateway explicitly preserves those text formats instead of treating every detected non-image MIME as binary.Maintainer Decision
Feature-owner approval is explicit: @steipete approved landing the bounded five-format image preview with metadata-only fallback. The branch was rebuilt from current
mainate92da4c8ba9a2f890a10fa4660df1acb439635b0; subsequent default-branch movement is not being chased with another proof-invalidating rebase because exact-head CI run 30448239999 validated the synthetic merge against the then-current integration tree, and the latest ClawSweeper review found the touched-file merge clean with no code finding.Evidence
Exact maintained head:
1d9a1b8595218287f8f4a4b618a6e12a1147c085tbx_01kyps07zg97k2kwfhz79kh4yvpassed the exact real-browser flow: text preview, decoded PNG (naturalWidthandnaturalHeightboth nonzero), and metadata-only BMP fallback..artifacts/control-ui-e2e/chat-file-links/.pnpm protocol:checkpassed after the clean commit, including registry, Swift, Kotlin, protocol-since, and generated-drift gates.pnpm check:changedandpnpm buildpassed on the kept Testbox. The changed gate covered core/UI/app typechecks, full relevant lint/guards, Control UI i18n, protocol boundaries, and native-related tests; the production build passed its package, Plugin SDK, Control UI, and performance gates.openclaw/ci-gate; macOS Swift passed on its cached attempt-two rerun, and iOS build plus release screenshots passed.Visual Reference
The screenshots below show the same supported-image and unsupported-binary states as the exact current-head capture; they are retained from the earlier behavior-equivalent implementation because GitHub already hosts them on the PR proof repository.
Docs / Release Note
The Control UI documentation now names the supported formats, the 256 KiB inline limit, and metadata-only binary fallback.
Release-note context: session workspace files can now preview browser-safe images and show honest metadata for unsupported binaries without changing text editing.