Skip to content

fix(ui): avoid recapturing chat drafts during UI updates - #146884

Merged
vincentkoc merged 1 commit into
mainfrom
perf/chat-draft-restore-capture-20260913
Sep 13, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
perf/chat-draft-restore-capture-20260913

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 13, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes: ordinary chat UI updates repeatedly prepare a draft recovery snapshot even after restoration has already been admitted for that session.

User Impact

The composer avoids redundant snapshot work during UI updates. Draft restoration still protects edits made while stored content is loading. No configuration or migration is required.

Why This Change Was Made

The existing restoration owner checks whether the scope needs restoration before requesting snapshot preparation. Preparation remains synchronous, before admission state changes or storage yields, and captures the snapshot used when the current draft wins. Scope, generation, revision, and ownership checks stay in their existing owner.

Production changes: +38/-27 (net +11), to move preparation behind the single admission boundary without weakening recovery ordering. Tests: +216.

Evidence

  • Independent owner/dependency review is clear.
  • New composer tests cover repeated calls while restoration is pending and settled, reset and scope changes, and a synchronous newer edit racing a higher stored revision.
  • A native IndexedDB browser regression checks that the baseline is captured before a new edit. It uses the updated internal API and is candidate safety coverage; the actual-composer capture test is the unchanged-production baseline reproduction.
  • Required autoreview and the test-only lint correction review completed with no actionable P0–P2 findings. The browser race case was moved unchanged to the recovery-fences suite, and the Promise executor now discards its unused return value.
  • Signed head 041ca72b8d80ed348e43085f1487bdbc18e5d600 preserves the tested patch on f513c0f345f7f2514c49ccfbc00adc3f78b9a755, which includes the canonical CI guard and file-tab test repairs.
  • Linux proof passed 59 unit tests and 16 Chromium/IndexedDB cases, including the moved native-storage race. Substituting both original restoration owners reproduced three unwanted captures at the no-recapture assertion. Candidate source was restored and verified clean.
  • Fresh hosted CI and native preparation remain pending.
  • This change reduces synchronous snapshot preparation. No end-to-end latency improvement has been measured.

@vincentkoc vincentkoc self-assigned this Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: M maintainer Maintainer-authored PR labels Sep 13, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review September 13, 2026 08:37
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 7:21 AM ET / 11:21 UTC (Revision 2).

ClawSweeper review

What this changes

The Control UI prepares chat draft recovery snapshots only when restoration is admitted, while preserving edits made during storage loading.

Merge readiness

✅ Ready for maintainer review

Keep open: current main still performs the redundant snapshot work, and this focused patch preserves restore ordering without introducing a blocking defect.

Priority: P2
Reviewed head: 041ca72b8d80ed348e43085f1487bdbc18e5d600

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with relevant regression coverage and no supported blocking finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate, and no material authority change triggers additional proof. Reported composer and native IndexedDB runs cover capture suppression and preservation of a newer edit; no end-to-end latency improvement is claimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate, and no material authority change triggers additional proof. Reported composer and native IndexedDB runs cover capture suppression and preservation of a newer edit; no end-to-end latency improvement is claimed.
Evidence reviewed 7 items Restore preparation remains synchronous: The existing scope guard now precedes prepare(); preparation still completes before the restore generation changes or asynchronous storage work begins. The subsequent scope, signature, revision, and generation checks remain unchanged.
Production caller and lifecycle: UI invalidation calls persistChangedState(). The composer supplies the deferred preparation callback, retains the captured snapshot for current-draft-wins persistence, and resets restore admission on explicit restoration and owner transitions.
Still necessary on current main: Fetched main still constructs the baseline snapshot before calling the durable restore owner, whose already-restored guard consequently cannot avoid that preparation.
Findings None None.
Security None None.

How this fits together

The Control UI’s composer persistence connects chat edits and UI updates to browser draft storage. Its restore owner checks session scope and draft revisions before applying saved content.

flowchart TD
  A[Chat edits and UI updates] --> B[Composer persistence]
  B --> C{Restore already admitted?}
  C -->|Yes| D[Skip snapshot preparation]
  C -->|No| E[Capture current draft synchronously]
  E --> F[Read browser draft storage]
  F --> G{Scope and edit still current?}
  G -->|Yes| H[Reconcile saved and current draft]
  G -->|No| D
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +11, Tests +216. Total +227 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 38 27 +11
Tests 2 216 0 +216
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 254 27 +227

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +11 lines; tests +216 lines The small production increase moves snapshot preparation behind the existing admission boundary; added coverage protects skipped work and synchronous edit ordering.

Technical review

Best possible solution:

Keep restore admission in the existing persistence owner and capture its baseline synchronously only when a restore will actually start.

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

Yes, from source: repeated UI invalidations reach snapshot preparation before the current-main restore guard. The PR reports a failing original-owner regression; this review did not execute tests.

Is this the best way to solve the issue?

Yes. Moving preparation behind the existing admission guard removes redundant work while retaining synchronous baseline capture and the established restore checks.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 32bf352734f0.

Labels

Label justifications:

  • P2: This is a bounded Control UI performance repair without evidence of an urgent user-facing outage.
  • 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 MEMBER-authored PR is exempt from the external-contributor proof gate, and no material authority change triggers additional proof. Reported composer and native IndexedDB runs cover capture suppression and preservation of a newer edit; no end-to-end latency improvement is claimed.

Evidence

What I checked:

  • Restore preparation remains synchronous: The existing scope guard now precedes prepare(); preparation still completes before the restore generation changes or asynchronous storage work begins. The subsequent scope, signature, revision, and generation checks remain unchanged. (ui/src/pages/chat/durable-composer-persistence.ts:263, 041ca72b8d80)
  • Production caller and lifecycle: UI invalidation calls persistChangedState(). The composer supplies the deferred preparation callback, retains the captured snapshot for current-draft-wins persistence, and resets restore admission on explicit restoration and owner transitions. (ui/src/pages/chat/composer-persistence.ts:1096, 041ca72b8d80)
  • Still necessary on current main: Fetched main still constructs the baseline snapshot before calling the durable restore owner, whose already-restored guard consequently cannot avoid that preparation. (ui/src/pages/chat/composer-persistence.ts:1096, 32bf352734f0)
  • Latest-release comparison: The supplied latest release, v2026.9.4, also accepts an already-prepared baseline; it does not contain this lazy preparation contract. (ui/src/pages/chat/durable-composer-persistence.ts:253, 3a9d69db306c)
  • Focused regression coverage: The complete introduced tests cover pending and settled restore admission, reset, scope changes, and a synchronous newer edit racing a higher stored revision. The browser case uses native IndexedDB and the production restore owner. The captured PR body reports 59 unit and 16 Chromium cases passing, plus three unwanted captures when substituting the original owners; these runs were not independently executed during this read-only review. (ui/src/e2e/composer-recovery-fences.e2e.test.ts:21, 041ca72b8d80)
  • Area history and routing: Current-main history shows repeated draft-persistence work by Peter Steinberger; GitHub commit metadata identifies steipete for the recent draft-preservation commit. This supports routing, without establishing introduction of the redundant-capture behavior. (ui/src/pages/chat/durable-composer-persistence.ts, bc6c22ebafe3)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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-09-13T08:44:43.773Z sha cd140d6 :: needs maintainer review before merge. :: none

@vincentkoc
vincentkoc force-pushed the perf/chat-draft-restore-capture-20260913 branch from cd140d6 to 041ca72 Compare September 13, 2026 11:12
@vincentkoc
vincentkoc merged commit ccfd237 into main Sep 13, 2026
130 checks passed
@vincentkoc
vincentkoc deleted the perf/chat-draft-restore-capture-20260913 branch September 13, 2026 11:31
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit to zachisfine/openclaw that referenced this pull request Sep 13, 2026
* temp/pr-146799: (70 commits)
  test: reuse explicit fallback config fixtures (openclaw#146948)
  fix(computer): return fresh window observations after actions (openclaw#146822)
  refactor(feishu): remove unreachable requester topic selection (openclaw#146904)
  improve(gateway): reduce CPU spent listing agent-owned sessions (openclaw#137745)
  fix(ui): avoid recapturing chat drafts during UI updates (openclaw#146884)
  fix(ui): show system uptime in the debug overlay (openclaw#146960)
  fix(retry): honor waits beyond the native timer limit (openclaw#145718)
  fix(ui): keep chat history idle when run status changes (openclaw#146802)
  fix(ui): reuse persisted text during chat streaming (openclaw#146831)
  refactor(qa): share harness drift result construction (openclaw#146903)
  test(agents): coordinate settings lock contention (openclaw#146949)
  fix(worker): avoid repeatedly serializing screenshot history (openclaw#146907)
  fix(secrets): stop buffered upload writes after cancellation (openclaw#146840)
  perf(doctor): avoid unnecessary state runtime imports (openclaw#146926)
  improve: reduce compaction request estimation work (openclaw#146961)
  fix(ci): wait for forwarded avatar imports before assertions (openclaw#146729)
  perf(workers): skip configured Git author lookups (openclaw#146833)
  fix: admit borrowed memory writes through the agent database owner (openclaw#146760)
  fix(discord): prevent voice playback gaps and stale turn controls (openclaw#146798)
  improve: reduce worktree filesystem stalls and archive syncs (openclaw#146906)
  ...
vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit 'ccfd2377cd07d1ad3a583ba64d08e29a065f7061': (1587 commits)
  fix(ui): avoid recapturing chat drafts during UI updates (#146884)
  fix(ui): show system uptime in the debug overlay (#146960)
  fix(retry): honor waits beyond the native timer limit (#145718)
  fix(ui): keep chat history idle when run status changes (#146802)
  fix(ui): reuse persisted text during chat streaming (#146831)
  refactor(qa): share harness drift result construction (#146903)
  test(agents): coordinate settings lock contention (#146949)
  fix(worker): avoid repeatedly serializing screenshot history (#146907)
  fix(secrets): stop buffered upload writes after cancellation (#146840)
  perf(doctor): avoid unnecessary state runtime imports (#146926)
  improve: reduce compaction request estimation work (#146961)
  fix(ci): wait for forwarded avatar imports before assertions (#146729)
  perf(workers): skip configured Git author lookups (#146833)
  fix: admit borrowed memory writes through the agent database owner (#146760)
  fix(discord): prevent voice playback gaps and stale turn controls (#146798)
  improve: reduce worktree filesystem stalls and archive syncs (#146906)
  fix(ui): avoid extra chat rail work while replies stream (#146883)
  improve(ui): speed up populated Usage timelines (#146947)
  test(gateway): retain auth recovery failure diagnostics (#146925)
  fix(tests): create private temporary home directories (#146931)
  ...

# Conflicts:
#	test/tsconfig/tsconfig.core.test.agents-other.json
#	test/tsconfig/tsconfig.core.test.agents-root.json
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
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: M 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