Skip to content

test(ui): stop new-session draft restore racing durable persistence - #125548

Merged
steipete merged 1 commit into
mainfrom
steipete/fix-new-session-draft-restore-race
Aug 18, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/fix-new-session-draft-restore-race

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

ui/src/e2e/new-session-page.prompt-attachments.e2e.test.ts ("restores a text-only prompt in a fresh page")
fails intermittently on CI — it blocked PR #125498 twice, once as a timeout and once as
AssertionError: expected '' to be 'restore this text-only prompt after r…'. The empty string is the tell:
the draft was gone, not late.

await firstMessage.fill(text);
await firstPage.reload();
await expect.poll(() => firstMessage.inputValue()).toBe(text);

git blame attributes these lines to 6b72d65ffe4 / #125332, which introduced both durable draft
persistence and this test. That feature persists through NewSessionDraftPersistence into the durable
composer draft store, which is loaded by dynamic import() and written asynchronously to IndexedDB. So
fill() returning proves only that the input holds the text — it says nothing about a snapshot existing. A
reload that beats the write destroys the draft, and the poll then waits for a value that no longer exists.

Why This Change Was Made

The test synchronized on an action (fill returned) instead of on the state that action is supposed to
produce (a persisted snapshot). That is the same defect already fixed in #125441 (a pid file written before
the process was running) and #125456 (a Save click racing form-state commit); this is the third instance of
the pattern.

The fix waits on the persisted snapshot itself, using the existing exported readDurableComposerDraft
reader — scoped by gateway URL, recovery scope, and route parameters — and verifying the exact text and
attachment count after the IndexedDB transaction commits. Sibling cases that fill-then-reload get the same
treatment, including incognito retirement, which waits for its persisted tombstone.

Deliberately not done: raising the poll timeout, inserting a sleep, retrying the reload, or weakening the
assertion. Each would have stopped the failure without removing the race, leaving a test that passes whether
or not drafts actually survive a restart — which is the entire behavior #125332 shipped.

User Impact

None. Test-only; production is untouched.

Evidence

Ten consecutive runs, since one green run proves nothing about a race:

10/10 passed
pnpm test ui/src/e2e/new-session-page.prompt-attachments.e2e.test.ts
 Test Files  1 passed (1)
      Tests  15 passed (15)

pnpm check:changed green; Codex autoreview clean.

reviewMetrics — production vs test LOC: production 0, tests +69 / −0 — pure addition, so no existing
assertion was relaxed. The bulk is a reusable persisted-draft probe in new-session-page.test-support.ts.

No CHANGELOG.md edit — release-only per repo policy; test-only change.

@clawsweeper

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 18, 2026 03:06
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: S maintainer Maintainer-authored PR labels Aug 18, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. labels Aug 18, 2026
@clawsweeper

clawsweeper Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 11:42 PM ET / August 18, 2026, 03:42 UTC.

ClawSweeper review

What this changes

The PR makes New Session browser E2E tests wait for the durable composer-draft record before reloading or completing an Incognito transition.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for maintainer landing. The patch correctly synchronizes the flaky browser E2E assertions with the IndexedDB commit they exercise; no actionable patch defect was found. The branch is mergeable but behind main and its aggregate gate remains queued.

Priority: P3
Reviewed head: 9ffe05a52320dbfc4766a4ad03dcfaa9db2cc241

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The owner-boundary synchronization is sound and narrowly scoped; final readiness depends on the queued aggregate gate and refreshed merge result.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored test-only PR is supported by its reported repeated real-Chromium E2E runs and current UI E2E checks; the external-contributor proof gate does not apply.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored test-only PR is supported by its reported repeated real-Chromium E2E runs and current UI E2E checks; the external-contributor proof gate does not apply.
Evidence reviewed 5 items Current-main gap: Current main fills the composer and immediately reloads, so it has no assertion that the asynchronous durable snapshot exists before navigation.
Persistence owner: A user mutation snapshots state and launches the IndexedDB write asynchronously; the commit occurs after the store transaction completes.
Patch checks the owned fact: The new helper reads the durable record using the same gateway owner, recovery scope, and route key, and the store reader resolves only after its IndexedDB transaction completes.
Findings None None.
Security None None.

How this fits together

Control UI persists unsent New Session text and attachments in browser-local IndexedDB, then restores them after a reload. The E2E suite drives the composer and verifies recovery through the same durable store.

flowchart LR
  A[Composer edit] --> B[New Session persistence]
  B --> C[Browser IndexedDB]
  D[E2E test] --> E[Durable draft check]
  C --> E
  E --> F[Reload or Incognito change]
  F --> G[Draft restoration assertion]
Loading

Before merge

  • Resolve merge risk (P1) - The branch is behind current main and the aggregate CI gate is still queued; landing should use a refreshed merge result with exact-head checks green.
  • Complete next step (P2) - No repair is needed; the protected maintainer PR needs ordinary final landing review after its queued aggregate gate and merge refresh complete.
Agent review details

Security

None.

PR surface

Source +61, Tests +8. Total +69 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 61 0 +61
Tests 1 8 0 +8
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 69 0 +69

Review metrics

Metric Value Why it matters
Production vs test LOC production +0/-0; test/test-support +69/-0 All added code is E2E synchronization support; runtime behavior and persisted-data contracts are unchanged.

Stored data model

Persistent data-model change detected: serialized state: ui/src/e2e/new-session-page.test-support.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the durable-record readiness check and land it after the refreshed merge result and aggregate gate are green.
  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 durable-record readiness check and land it after the refreshed merge result and aggregate gate are green.

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

Yes—current main visibly reloads after input without waiting for the asynchronous durable write, while the persistence owner commits through IndexedDB after that action returns.

Is this the best way to solve the issue?

Yes—the helper verifies the persisted snapshot itself, avoiding sleeps, retries, or weaker restoration assertions.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a focused test-reliability repair with no direct production behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored test-only PR is supported by its reported repeated real-Chromium E2E runs and current UI E2E checks; the external-contributor proof gate does not apply.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the merged durable-composer-draft feature and the current E2E synchronization repair. (role: feature introducer and recent area contributor; confidence: high; commits: 6b72d65ffe4f, 9ffe05a52320; files: ui/src/pages/new-session/draft-persistence.ts, ui/src/lib/chat/composer-draft-store.runtime.ts, ui/src/e2e/new-session-page.prompt-attachments.e2e.test.ts)

Rank-up moves

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

  • Wait for the queued aggregate gate, then validate the refreshed merge result before landing.

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-18T03:12:43.484Z sha 2ba7bd1d999ce9ee9a0e7f7b9d572395568b41ec :: needs maintainer review before merge. :: none

@steipete steipete self-assigned this Aug 18, 2026
@steipete
steipete force-pushed the steipete/fix-new-session-draft-restore-race branch from 2ba7bd1 to 9ffe05a Compare August 18, 2026 03:35
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready verification for 9ffe05a52320dbfc4766a4ad03dcfaa9db2cc241:

  • Rebased cleanly onto then-current origin/main (a0c5937fd19debeaad89f7a9869e69b524dbdd5a); no conflicts. The inherited chat-pane-render.ts max-lines failure is absent on this base (600 lines), with no change or suppression in this PR.
  • Exact-head CI: node scripts/watch-pr-ci.mjs 125548 9ffe05a52320dbfc4766a4ad03dcfaa9db2cc241 → green, run https://github.com/openclaw/openclaw/actions/runs/32096038830.
  • Fresh review: .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main --stream-engine-output → clean, no accepted/actionable findings.
  • Native landing flow: scripts/pr review-init 125548, scripts/pr review-artifacts-init 125548, and scripts/pr review-validate-artifacts 125548 → READY FOR /prepare-pr, zero findings.
  • OPENCLAW_TESTBOX=1 scripts/pr prepare-run 125548 → passed with gates_mode=hosted_exact_or_recent_parent; the exact hosted gate was reused, so no separate Testbox lease or run ID was allocated.
  • Latest ClawSweeper rank-up move applied: the aggregate exact-head gate completed and the native prepare flow validated the refreshed merge result.

Known proof gaps: none for this test-only change. Production LOC is +0/-0; E2E test and test-support LOC is +69/-0.

@steipete
steipete merged commit aa2d3df into main Aug 18, 2026
143 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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 P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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