Skip to content

fix(ui): harden workspace file editing - #104885

Merged
steipete merged 13 commits into
mainfrom
codex/control-ui-file-draft-retention
Jul 12, 2026
Merged

steipete merged 13 commits into
mainfrom
codex/control-ui-file-draft-retention

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

The shared Control UI session workspace file editor landed in #104757, but several hardening gaps remained: unsaved drafts disappeared during navigation, Markdown bypassed the editor, edit capability detection was permissive, and concurrent saves could accept one stale hash through alternate file routes.

Follow-up to #104757 and #104698.

Why This Change Was Made

  • Retain every unsaved draft for the browser-tab lifetime until it is saved or explicitly discarded.
  • Scope draft identity by Gateway, split pane, session, workspace root, and the canonical file path returned by the Gateway.
  • Open Markdown in the same lazy CodeMirror editor as other text files.
  • Show editing only when the connection has operator.admin and explicitly advertises sessions.files.set.
  • Require lowercase 64-character SHA-256 CAS tokens and reject non-round-trippable UTF-16 input.
  • Serialize the low-frequency save CAS sequence process-wide, covering lexical aliases and nested workspace roots before re-reading and writing.

User Impact

Workspace files in the shared Chat session detail sheet can be edited more safely: drafts survive file/panel/session navigation, do not leak across Gateways or panes, Markdown is editable, and concurrent or stale saves fail with a conflict instead of silently overwriting newer content. Read-only and older Gateways remain read-only.

Evidence

  • Blacksmith Testbox tbx_01kx9zc1a6mtayd31efzyxa3k0 / Actions run 29175453736: 56 gateway assertions and 62 UI assertions, including 9 Chromium editor tests.
  • Blacksmith Testbox tbx_01kx9zrrhnb1nhjvscfssfb229 / Actions run 29175625303: final 58 gateway assertions, including lexical-alias and nested-root concurrency regressions.
  • Blacksmith Testbox tbx_01kxa0az0cwdzxycd893vevqpn / Actions run 29175869485: exact-head pnpm check:changed green across typechecks, formatting, core/UI/packages/scripts lint, dependency and policy guards, and runtime import cycles.
  • Production Control UI build emitted a separate file-editor-view chunk (46.44 kB), preserving lazy loading.
  • Fresh branch autoreview: no accepted/actionable findings; patch judged correct.

AI-assisted implementation and validation by Codex.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime scripts Repository scripts size: L maintainer Maintainer-authored PR labels Jul 12, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for the current PR head:

  • corepack pnpm test src/gateway/server-methods/sessions-files.test.ts — 58 assertions passed on Testbox tbx_01kx9zrrhnb1nhjvscfssfb229 (Actions run 29175625303), including stale-hash, lexical-alias, and nested-workspace-root concurrency cases.
  • corepack pnpm --dir ui test src/pages/chat/components/chat-session-workspace.test.ts src/pages/chat/components/chat-sidebar-file-view.browser.test.ts src/pages/chat/components/chat-sidebar.test.ts src/pages/chat/components/chat-tool-cards.test.ts — 62 assertions passed, including 9 Chromium tests, on Testbox tbx_01kx9zc1a6mtayd31efzyxa3k0 (Actions run 29175453736).
  • corepack pnpm --dir ui build — passed; CodeMirror remains in the separate 46.44 kB file-editor-view chunk.
  • env OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 corepack pnpm check:changed — passed on Testbox tbx_01kxa0az0cwdzxycd893vevqpn (Actions run 29175869485), including all typechecks, formatting, core/UI/packages/scripts lint, dependency/policy guards, and runtime import-cycle checks.
  • Fresh autoreview after all fixes: clean, no accepted/actionable findings.

Known gap: the filesystem CAS contract protects OpenClaw writers and detects stale content before write; as documented in #104757, arbitrary external writers still have the normal final-syscall race window.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 12, 2026
@clawsweeper

clawsweeper Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 11, 2026, 10:22 PM ET / July 12, 2026, 02:22 UTC.

Summary
The PR retains canonically scoped workspace-file drafts, tightens edit capability and SHA-256 validation, canonicalizes returned paths, rejects non-round-trippable text, and serializes compare-and-swap writes process-wide.

PR surface: Source +113, Tests +290, Docs +3, Other +5. Total +411 across 13 files.

Reproducibility: yes. The pre-patch source clearly permits the reported draft-loss, unknown-capability, alias-concurrency, malformed-hash, and surrogate-encoding paths, and the branch adds focused regressions for them; I did not independently run the interactive UI flow.

Review metrics: 1 noteworthy metric.

  • Protocol validation: 2 hash fields tightened. Both returned file hashes and save CAS tokens now require canonical lowercase 64-character SHA-256 values.

Stored data model
Persistent data-model change detected: serialized state: packages/gateway-protocol/src/schema/sessions.ts, serialized state: src/gateway/server-methods/sessions-files.test.ts, unknown-data-model-change: src/gateway/server-methods/sessions-files.test.ts, unknown-data-model-change: src/gateway/server-methods/sessions-files.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: same_root_cause
Canonical: #104757
Summary: This PR addresses hardening gaps in the workspace editor introduced by the merged canonical implementation.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦪 silver shellfish
Patch quality: 🦞 diamond lobster
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add a short redacted interactive browser recording covering draft retention, Markdown editing, and stale-save conflict behavior.
  • Refresh the branch or exact-head merge review against current main.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR provides strong automated Testbox, Chromium-test, mock-Gateway, build, and check evidence, but no after-fix recording, screenshots, logs, or live output from an interactive real browser setup; add redacted proof and update the PR body to trigger a fresh review, or ask a maintainer to comment @clawsweeper re-review.

Risk before merge

  • [P1] The branch is behind current main, so maintainers should refresh the exact-head review after GitHub recomputes the current merge result, even though read-only merge-tree analysis found no code conflict.
  • [P1] The submitted evidence consists of automated Testbox tests, a mock Gateway/browser harness, and build/check output; it does not demonstrate the changed interaction in an interactive real browser setup.

Maintainer options:

  1. Decide the mitigation before merge
    Preserve the centralized update primitive and canonical draft identity, refresh the branch or merge review against current main, and add a short redacted real-browser recording showing a draft surviving navigation, Markdown editing, and a stale-save conflict before merge.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] The code has no actionable review finding, but the protected maintainer-labeled PR still needs real interactive proof and a refreshed current-main merge review before landing.

Security
Cleared: The patch tightens the authorization, path-identity, text-validation, and stale-write boundaries without adding a dependency or supply-chain execution surface.

Review details

Best possible solution:

Preserve the centralized update primitive and canonical draft identity, refresh the branch or merge review against current main, and add a short redacted real-browser recording showing a draft surviving navigation, Markdown editing, and a stale-save conflict before merge.

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

Yes. The pre-patch source clearly permits the reported draft-loss, unknown-capability, alias-concurrency, malformed-hash, and surrogate-encoding paths, and the branch adds focused regressions for them; I did not independently run the interactive UI flow.

Is this the best way to solve the issue?

Yes. One canonical filesystem update primitive plus one canonical, scoped in-memory draft store is the narrowest maintainable fix and avoids per-route locks or duplicated component state.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4eb1f5225c5f.

Label changes

Label changes:

  • add P2: This is bounded but meaningful hardening against draft loss and stale workspace-file overwrites in an operator workflow.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦪 silver shellfish and patch quality is 🦞 diamond lobster.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR provides strong automated Testbox, Chromium-test, mock-Gateway, build, and check evidence, but no after-fix recording, screenshots, logs, or live output from an interactive real browser setup; add redacted proof and update the PR body to trigger a fresh review, or ask a maintainer to comment @clawsweeper re-review.

Label justifications:

  • P2: This is bounded but meaningful hardening against draft loss and stale workspace-file overwrites in an operator workflow.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦪 silver shellfish and patch quality is 🦞 diamond lobster.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR provides strong automated Testbox, Chromium-test, mock-Gateway, build, and check evidence, but no after-fix recording, screenshots, logs, or live output from an interactive real browser setup; add redacted proof and update the PR body to trigger a fresh review, or ask a maintainer to comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +113, Tests +290, Docs +3, Other +5. Total +411 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 6 179 66 +113
Tests 4 297 7 +290
Docs 2 6 3 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 1 7 2 +5
Total 13 489 78 +411

What I checked:

Likely related people:

  • steipete: Introduced and merged the workspace editor, sessions.files.set contract, and central workspace filesystem helper in commit 82667a6, so the current-main history directly connects this person to the affected behavior beyond authoring this follow-up. (role: feature introducer and merger; confidence: high; commits: 82667a66e57a; files: src/gateway/server-methods/workspace-fs.ts, src/gateway/server-methods/sessions-files.ts, ui/src/pages/chat/components/chat-sidebar.ts)
  • chengzhichao-xydt: Recent history on the shared workspace filesystem path includes the canonical relative-path normalization and containment helpers adjacent to the updated read/write behavior. (role: recent adjacent contributor; confidence: medium; commits: dfeb15261db3; files: src/gateway/server-methods/workspace-fs.ts, ui/src/pages/chat/components/chat-sidebar.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • 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.

@steipete
steipete merged commit 68f0eee into main Jul 12, 2026
185 of 190 checks passed
@steipete
steipete deleted the codex/control-ui-file-draft-retention branch July 12, 2026 02:25
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 12, 2026
* fix(ui): retain unsaved workspace file drafts

* fix(ui): reset restored draft hash

* fix(ui): keep all unsaved file drafts

* fix(ui): harden workspace file editing

* fix(ui): canonicalize workspace file identity

* fix(gateway): serialize workspace file saves globally

* chore: keep release notes in PR body

* docs: refresh generated docs map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant