Skip to content

fix(ui): keep agent file saves intact during refresh - #130468

Merged
steipete merged 2 commits into
mainfrom
codex/qa-agent-file-lifecycle-20260826
Aug 27, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/qa-agent-file-lifecycle-20260826

Conversation

@steipete

@steipete steipete commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users saving files in Settings → Agents → Files would see older content return when an overlapping refresh finished. The write had succeeded on disk, but the editor's saved baseline and draft could be replaced by the stale read. A delayed file-list response or unrelated agent publication could also restore obsolete “missing file” metadata after the file was created.

Why This Change Was Made

File reads and writes now share one lifecycle owner that retires same-file reads at write admission and settlement. Confirmed results update the canonical agent-file metadata cache, retire older list requests, and rebuild the full list after invalidation. This removes the duplicate local metadata merge and the redundant post-save refresh. Read/write errors retain their own ownership instead of being overwritten by unrelated metadata publications.

Production LOC: +94/-88 (net +6). Tests and test support: +568/-71. The small production increase introduces the missing canonical metadata publication seam and per-file write ordering while consolidating the two request paths; there is no new configuration, dependency, storage format, or protocol change.

Provenance: the independent file read/write and local metadata paths date to commit 2a68bcb (2026-02-03; code author and committer @gumadeiras; no linked PR found). The shared-cache/page-cache split and metadata error copying were introduced in #100024 (2026-07-04; code author, PR author, and merger @shakkernerd), then carried forward with generation checks and post-save refresh in #102745 (2026-07-09; code author, PR author, and merger @steipete-oai). No bot merger was involved. This repair preserves the newer-draft protections from #105359 and the explicit refresh behavior from #127086.

User Impact

Successful saves stay visible when older requests settle. Newly created files remain present, newer unsaved typing is preserved, and failed saves or metadata rebuilds remain visible with the correct error. Explicit later refreshes still adopt current server content; switching agents and reconnecting do not leak results across owners.

Evidence

AI-assisted with Codex; the final source and proof were independently inspected. Fresh structured autoreview reported no actionable findings.

  • The new race regression failed on the original source: after Save, the editor reverted to server revision 3. The same Chromium flow now retains Saved latest instructions.
  • 85 focused owner/component and serialized-harness tests passed, covering earlier and during-write reads, stale read errors, failed saves, newer drafts, different files, client/capability replacement, cache invalidation, metadata publication, rendered error precedence, and both held/one-shot fixture settlement contracts.
  • All 14 Chromium flows across the Agent Files and device-dispatch files passed, including an isolated real Gateway that writes and reads back the selected agent's actual workspace file and the forced late-recovery cloud restoration order. The overlapping-refresh race flow also passed 3 repeated stress runs. No live provider or channel credentials were needed.
  • pnpm ui:build passed, including 768 finalized sidecars and the startup performance budget: 341,458 bytes gzip against a 341,845-byte limit.
  • The final scoped changed-file gate passed. Earlier local checks exposed an unused response type and test fixture/type-library mismatches; these were corrected to use the real get/set response union, the loader's actual state type, and the existing deferred helper. No assertions or gates were weakened.

Hosted CI also exposed an existing remembered-cloud-destination fixture race in the new-session browser suite. Four unchanged local runs passed, then a controlled recovery-scope schedule reproduced the exact failing assertion: the fixture held only the first catalog request, allowing a replacement request to receive the default empty catalog. An opt-in held-method fixture now releases all admitted requests together with consistent catalog data, preserving existing one-shot deferrals. The original browser assertion remains, with the problematic schedule made deterministic. Both new helper cases failed before the repair; all 15 helper tests and the 11-case browser file passed afterward. This adds no production behavior change or timeout increase.

OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs ui/src/pages/agents/files.test.ts ui/src/pages/agents/agent-file-lifecycle.test.ts ui/src/pages/agents/agents-page.test.ts ui/src/lib/agents/index.test.ts
OPENCLAW_CAPTURE_UI_PROOF=1 OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/agent-file-lifecycle.e2e.test.ts
pnpm ui:build
node scripts/run-vitest.mjs ui/src/test-helpers/control-ui-e2e.mock-gateway.test.ts ui/src/test-helpers/control-ui-e2e.deferral.test.ts
OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/new-session-page.device-dispatch.e2e.test.ts
node scripts/check-changed.mjs --base 99a2434f7b89c682f934326be9f7cc786f7ddeca -- CHANGELOG.md ui/src/lib/agents/index.ts ui/src/pages/agents/files.ts ui/src/pages/agents/files.test.ts ui/src/pages/agents/agents-page.ts ui/src/pages/agents/agent-file-lifecycle.test.ts ui/src/pages/agents/agents-page.test.ts ui/src/e2e/agent-file-lifecycle.e2e.test.ts ui/src/e2e/new-session-page.device-dispatch.e2e.test.ts ui/src/test-helpers/control-ui-e2e.ts ui/src/test-helpers/control-ui-e2e.deferral.test.ts

Before: the older refresh restores stale text after a confirmed save.

Before: stale refresh overwrites the visible saved text

After: the confirmed save remains visible after the older read settles.

After: saved instructions remain intact

After: a created file remains present after a stale list response and unrelated agent refresh.

After: canonical metadata keeps the created file present

Screenshots contain synthetic test data only. Exact-head CI and Workflow Sanity passed; repository-native preparation and merge completed at fc6cf5e6907d.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: L maintainer Maintainer-authored PR labels Aug 26, 2026
@steipete steipete self-assigned this Aug 26, 2026
@steipete steipete closed this Aug 26, 2026
@steipete steipete reopened this Aug 26, 2026
@steipete
steipete marked this pull request as ready for review August 26, 2026 22:46
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 7:28 PM ET / 23:28 UTC.

ClawSweeper review

What this changes

The PR centralizes Agent Files read/write settlement so stale refreshes cannot overwrite a confirmed save or restore obsolete file metadata.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. Current main lacks this distinct response-ownership repair, and the patch has no supported correctness finding; it is maintainer-owned protected work with exact-head CI still incomplete.

Priority: P2
Reviewed head: e4ad93db97fccb96503400c3c06dd7582bb955df

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a focused owner-boundary repair with relevant unit and browser coverage; only exact-head CI remains pending.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository identifies the author as a MEMBER, so the external-contributor proof gate does not apply; the PR nevertheless supplies focused browser and isolated-Gateway evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository identifies the author as a MEMBER, so the external-contributor proof gate does not apply; the PR nevertheless supplies focused browser and isolated-Gateway evidence.
Evidence reviewed 6 items Write/read ownership: The shared request function advances a per-file write revision at write admission and settlement, so reads from either side of a write cannot publish stale content.
Canonical metadata owner: Confirmed file responses now update the Agent capability’s canonical list and retire older list-request owners before publication.
Caller and real-boundary coverage: The page Save action calls the shared file lifecycle, while the E2E test delays a read/list response, saves, and also exercises an isolated real Gateway workspace write/readback.
Findings None None.
Security None None.

Live Verification

Command: OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/agent-file-lifecycle.e2e.test.ts

Result: FAIL (failed) — step 1 run OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/agent-file-lifecycle.e2e.test.ts: previous terminal command was still running after 30 seconds: "OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/agent-file-lifecycle.e2e.test.ts"

RUN  v4.1.11 /tmp/clawsweeper-live-proof-130468-IIZPKx/target

[vitest] still running with no output for 30000ms.

Assertions:

  • FAIL expect_output: preserves drafts and confirmed saves across overlapping refreshes

How this fits together

The Control UI’s Agent Files page reads and writes workspace files through Gateway APIs, then updates the editor and shared file-list cache. This change controls which delayed responses may publish into those visible states.

flowchart LR
  A[Agent Files editor] --> B[Read and write lifecycle]
  B --> C[Gateway file APIs]
  C --> D[Response ownership check]
  D --> E[Shared file metadata cache]
  D --> F[Editor draft and saved base]
  E --> G[Agent Files UI]
  F --> G
Loading

Before merge

  • Resolve merge risk (P1) - Exact-head CI is still in progress, so this review is not a merge-ready verdict until the required checks complete green.
  • Complete next step (P2) - This protected maintainer-owned PR needs normal exact-head CI completion and maintainer merge handling, not an automated repair branch.
Agent review details

Security

None.

PR surface

Source +6, Tests +350, Docs +2. Total +358 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 3 94 88 +6
Tests 4 378 28 +350
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 474 116 +358

Review metrics

Metric Value Why it matters
Production versus tests production +94/-88 (net +6); tests +378/-28 The small production increase creates the canonical metadata-publication seam and write ordering while replacing duplicated settlement paths.

Stored data model

Persistent data-model change detected: vector/embedding metadata: CHANGELOG.md. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: canonical
Canonical: #130468
Summary: This PR covers the remaining overlap between a confirmed save and a stale file read/list response; earlier Agent Files fixes cover adjacent races.

Members:

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

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the single capability-owned metadata publication and per-file revision boundary, then merge only after the exact PR head completes its required CI.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the single capability-owned metadata publication and per-file revision boundary, then merge only after the exact PR head completes its required CI.

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

Yes, source provides a focused delayed-read/delayed-list path in the Agent Files E2E suite; it was not executed here because this is a read-only review.

Is this the best way to solve the issue?

Yes. Moving confirmed metadata publication into the shared Agent capability removes the page-local split, while per-file write revisions reject the stale reads that caused the overwrite.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository identifies the author as a MEMBER, so the external-contributor proof gate does not apply; the PR nevertheless supplies focused browser and isolated-Gateway evidence.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This repairs a bounded but user-visible Agent Files consistency failure in the Control UI.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository identifies the author as a MEMBER, so the external-contributor proof gate does not apply; the PR nevertheless supplies focused browser and isolated-Gateway evidence.

Evidence

What I checked:

Likely related people:

  • steipete: Current PR history and prior merged Agent Files refresh/save repairs show sustained ownership of this lifecycle. (role: recent area contributor; confidence: high; commits: e4ad93db97fc, 0a0d343cf299, 35b527c5bb2d; files: ui/src/pages/agents/files.ts, ui/src/pages/agents/agents-page.ts, ui/src/e2e/agent-file-lifecycle.e2e.test.ts)
  • gumadeiras: The original Agents dashboard commit is the earliest directly available history for this feature area. (role: initial feature author; confidence: medium; commits: 2a68bcbeb32e; files: ui/src/pages/agents/files.ts)
  • shakkernerd: The supplied merged Control UI architecture refactor is the stated origin of the shared-cache/page-cache split this repair consolidates. (role: adjacent architecture contributor; confidence: medium; commits: 65e12328aa20; files: ui/src/lib/agents/index.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let the exact-head CI, including the Control UI E2E lanes, complete green on e4ad93d.

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 (1 earlier review cycle)
  • reviewed 2026-08-26T22:53:46.328Z sha e4ad93d :: found issues before merge. :: [P2] Remove the release-owned changelog entry

@steipete

Copy link
Copy Markdown
Contributor Author

Read the current ClawSweeper review and rank-up move for e4ad93d.

  • Changelog removal is intentionally skipped as a narrowly scoped owner-directed exception: the maintainer explicitly requested this entry for this user-visible QA repair. The one-line note and its separator are retained under that direction; the PR body also carries the release context. This does not change repository-wide release ownership.
  • The +6 production lines are the missing canonical metadata publication and per-file write-ordering ownership. The duplicate local metadata merge and separate read/write settlement logic were removed. The review itself confirms that the page-local merge cannot retire shared stale list work.
  • No persistent data model changes exist. The changelog hunk contains only this Agent Files release note; no vector, embedding, database, schema, or migration code is changed.
  • The review's embedded test output reports all 10 file-owner tests passing. Its surrounding proof runner reports a terminal-wait/output-expectation failure, not a failing test assertion. Independently verified final proof remains 70 focused tests, all 3 Chromium flows (including real isolated Gateway save/readback), three repeated overlap-race runs, the production UI build, and the full scoped gate.

Exact-head CI is still finishing. Two initial CI jobs were interrupted by runner shutdowns with exit 143, without lint diagnostics; they will be retried on the unchanged source before native preparation. No required gate is being bypassed.

Named follow-up: ClawSweeper proof-harness terminal/output handling and changelog-based data-model classification should be investigated separately. The bot's live-proof lane is not counted as passing proof here.

@steipete steipete closed this Aug 26, 2026
@steipete steipete reopened this Aug 26, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 26, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Exact-head CI is green for 2875ea9f2c664e6480fb8721bfd042015684424b: CI run33025302406 completed successfully, including all four browser shards, the real-Gateway lane, baseline ratchets, lint, types, build, and CI gate. Workflow Sanity also passed.

The earlier manual fallback runs failed on runner shutdowns and a missing GitHub merge ref, not a source diagnostic. A later browser run exposed a separate existing test-fixture race; we reproduced it with the original assertion and repaired the fixture's request ownership instead of retrying unchanged tests. The final head passed85 focused owner/harness tests,14 Chromium flows, the full11-file changed gate, and a fresh isolated Codex review of the complete PR diff. No production behavior or timeout was changed by the fixture fixup.

The latest ClawSweeper comment remains a review-started placeholder. The last completed review is under12hours old; its changelog and production-size dispositions are recorded above. Its failed outer proof harness is not counted as passing evidence. The public PR body includes inspected before/after images and the actual proof commands. Proceeding through the repository-native prepare and merge gates; no checks or enforced review rules are waived.

@steipete
steipete merged commit fc6cf5e into main Aug 27, 2026
113 of 114 checks passed
@steipete
steipete deleted the codex/qa-agent-file-lifecycle-20260826 branch August 27, 2026 00:20
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
* fix(ui): keep agent file saves intact during refresh

* test(ui): hold catalog requests through recovery startup
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 maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant