Repository navigation
feat(ui): editable file panel with CodeMirror and sessions.files.set hash-CAS writes - #104757
Conversation
Dependency GuardThis PR changes dependency-related files. Maintainers should confirm these changes are intentional. Changed files:
Maintainer follow-up:
|
Dependency graph changes notedThis PR includes dependency graph changes. The dependency guard is informational because the PR author is a repository admin or a member of
Security review is still recommended before merge when the dependency graph change is intentional. |
8260a5c to
dfbc9f5
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8260a5c610
ℹ️ 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".
| const canEdit = | ||
| typeof file.hash === "string" && | ||
| hasUniformLineEndings(file.content) && | ||
| isGatewayMethodAdvertised(state, "sessions.files.set") !== false && | ||
| hasOperatorAdminAccess(state.hello?.auth ?? null); |
There was a problem hiding this comment.
Route Markdown files through the editable file view
Because this edit gate is below the .md/.markdown/.mdx early return above, opening a Markdown file without a line target (for example from the workspace rail or Show in Files) still returns kind: "markdown" instead of a kind: "file" sidebar with the edit payload. Even when the Gateway returns a hash and advertises sessions.files.set to an admin, the Edit button never appears for those common doc files, so the new in-browser edit flow misses the doc-typo use case unless the user happens to open a line-specific link.
Useful? React with 👍 / 👎.
|
Codex review: needs real behavior proof before merge. Reviewed July 11, 2026, 8:33 PM ET / July 12, 2026, 00:33 UTC. Summary PR surface: Source +997, Tests +430, Docs +1, Config +6, Other +589. Total +2023 across 28 files. Reproducibility: yes. for the review findings: exact current-head source inspection deterministically shows the Markdown early return and the nullable capability check enabling edits. Review metrics: 2 noteworthy metrics.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review findings
Review detailsBest possible solution: Adopt one canonical, positively advertised Do we have a high-confidence way to reproduce the issue? Yes for the review findings: exact current-head source inspection deterministically shows the Markdown early return and the nullable capability check enabling edits. Is this the best way to solve the issue? No, not yet: hash-CAS existing-file writes are a reasonable bounded design, but this branch is not fail-closed on capability discovery, misses common Markdown edits, and has not been selected over the competing contract. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2e6c1090c1d4. Label changesLabel justifications:
Evidence reviewedPR surface: Source +997, Tests +430, Docs +1, Config +6, Other +589. Total +2023 across 28 files. View PR surface stats
Security concerns:
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
Review history (2 earlier review cycles)
|
69142a4 to
262b643
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 262b6437d5
ℹ️ 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".
| const canEdit = | ||
| typeof file.hash === "string" && | ||
| hasUniformLineEndings(file.content) && | ||
| isGatewayMethodAdvertised(state, "sessions.files.set") !== false && |
There was a problem hiding this comment.
Require sessions.files.set advertisement for edits
When hello.features.methods is absent, isGatewayMethodAdvertised returns null, and this !== false check treats that as permission to show Edit. In that compatibility case the user gets an Edit button for a gateway that may only support sessions.files.get, and the save path then fails with an unknown sessions.files.set request instead of staying read-only; require === true for this new mutation method.
Useful? React with 👍 / 👎.
|
Merged via squash.
|
…hash-CAS writes (openclaw#104757) * feat(gateway): add sessions.files.set workspace file write with hash CAS (openclaw#104698) * feat(ui): CodeMirror file editor panel with CAS save + clickable tool-card paths (openclaw#104698) * fix(gateway): issue the file CAS hash only for strict-UTF-8 text (openclaw#104698) * docs(web): document the editable file detail panel (openclaw#104698) * fix(gateway,ui): round-trip BOM and CRLF bytes through the file editor (openclaw#104698) * fix(ui): keep mixed-line-ending files read-only in the file editor (openclaw#104698) * fix(ui): re-gate editability when a conflict reload returns non-editable content (openclaw#104698) * fix(gateway): reject NUL bytes in sessions.files.set replacement content (openclaw#104698) * fix(gateway,ui): regenerate protocol bindings, fix prod types and lint for file editor (openclaw#104698)
Closes #104698
What Problem This Solves
The Control UI file detail panel (from #100615) is read-only, and file paths in tool cards are dead text. Operators reviewing an agent's work cannot make a small correction to a file the agent just touched — a doc typo, a config value — without leaving the browser, which is impossible when the workspace lives on a remote gateway host ("Open in editor" cannot reach it).
Why This Change Was Made
sessions.files.setRPC (operator.admin) that overwrites one existing workspace file with compare-and-swap semantics on a sha256 content hash.sessions.files.getnow returns that hash for strict-UTF-8 text files (the hash doubles as the editability signal — binary previews never get one, andsetindependently rejects non-text targets so replacement-character re-encoding can never corrupt a binary file). Writes go through the same fs-safe root as reads (realpathed root, symlink/hardlink rejection, path containment, 256 KB UTF-8 cap); no create/delete. The workspace-browser module explicitly deferred general writes to a "separately reviewed mutation contract" — this PR is that contract, following theagents.files.setadmin-scope precedent. Protocol change is additive (no version bump).sessions.files.setadvertisement +operator.admin) adds dirty tracking, Cmd/Ctrl-S save, and a conflict banner with Reload / Overwrite when the file changed on disk since load. CodeMirror ships as a lazy Vite chunk (file-editor-view46 kB + per-language chunks), loaded on first panel open.root: document(see the inline comment infile-editor-view.ts).User Impact
Operators with admin scope can view and edit workspace text files directly from chat context on any gateway, with agent-write conflict safety. Read-only operators and older gateways see the unchanged read-only viewer (the edit affordance is capability-gated). File references in tool cards become navigable like chat prose links already were.
Evidence
Screenshots (mock gateway harness,
agent:alphafixture):Validation:
sessions-files+agents-workspacesuites green locally (both shards) and 40/40 on Blacksmith Testbox (Linux) for the initial RPC coverage. Cases: CAS happy path, stale-hash conflict withcurrentHash, missing file, >256 KB rejection,../escape + symlink containment (no write outside root), binary preview without a hash, binary write rejection even with a matching byte hash, UTF-8 BOM byte round-trip, andsetskipping the transcript scan.chat-sidebar,chat-tool-cards) green; new Chromium browser suite (chat-sidebar-file-view.browser.test.ts) 7/7 covering render/target-line decoration, edit→dirty→save, CRLF round-trip through save, in-flight-save dirty tracking, conflict→Reload, edit-mode drop when a reload returns non-editable content, and read-only-while-reloading (skips cleanly in the jsdom shard, which also collects*.browser.test.ts).chat-file-links.e2e.test.tsgreen with no selector changes (the CodeMirror line decorations keep thefile-view__line--target/data-linecontract).vite buildgreen; CodeMirror in a separate lazy chunk (file-editor-view-*.js46.25 kB gzip 13.25 kB; language definitions split per language).sessions.files.gethashes andsessions.files.set.setrejects non-text targets), UTF-8 BOMs were silently dropped on save (ignoreBOMdecode), CRLF/CR files were normalized to LF on save (EditorState.lineSeparator+sliceDocserialization), mixed-line-ending files now stay read-only (hasUniformLineEndingsgate), a conflict Reload re-checks that gate and drops edit mode when the latest content no longer qualifies, andsetrejects NUL-containing replacement content so the API never writes a file its own editability checks classify as binary.npm shrinkwrap guardlane fails in this environment on npm 12/Node 26 — it fails identically againstmain's untouched lockfile, so it is environmental; hosted CI (Linux Node 24) is authoritative. Two Blacksmith Testbox leases died mid-check:changed(infra outage); all other local lanes were green.