Skip to content

refactor(ui): simplify outbox custody and draft persistence - #133409

Merged
steipete merged 1 commit into
mainfrom
steipete/outbox-cleanup-a26147
Aug 30, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/outbox-cleanup-a26147

Conversation

@steipete

@steipete steipete commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Related: #133052 (durable attachment outbox), #133067 (canonical session recovery).

What Problem This Solves

Maintainer-requested cleanup of the Control UI outbox after the attachment and recovery repairs. Sending, editing, previewing, recovering, and retiring queued messages had accumulated duplicate delivery-version checks, draft revision calculations, snapshot shapes, and repeated storage projections. That duplication makes the durability boundary harder to maintain without improving the user experience.

Why This Change Was Made

Keep attachment preparation responsible for attachment updates rather than reconstructed queue rows; each delivery owner retains its own captured destination and delivery state. Consolidate the common delivery-version comparison, revision baseline, and durable write snapshot in their existing owners, remove obsolete wrappers/fields, and carry already-prepared facts instead of rereading or reparsing them.

The narrower admission/removal fences remain distinct. Cleanup still follows verified metadata persistence and examines active plus recovery references across principals; it uses the exact retention-filtered object that was serialized. Draft recovery retains its transaction and identity checks while parsing each record once and skipping destination reads that cannot be used.

Production LOC: +136 / -275, net -139 across 19 files. Tests: +19 / -23, net -4 across six files. Total: net -143 across 25 files. This is not a storage redesign: metadata v4, IndexedDB v2, legacy imports, byte limits, retention, and separate draft/queue lifetimes are unchanged. No configuration, schema, dependency, cache, or index additions.

User Impact

No intended user-visible behavior change. Complete attachment batches remain durable before admission and fully hydrated before transport. Offline reload, explicit recovery confirmation, duplicate-tab uncertainty, credential isolation, native-lock ownership, and stale-write/edit/connection fences retain their existing behavior. There is no partial-send or volatile-storage fallback.

Evidence

  • Exact-head CI passed on attempt 1: run 33324603156, including the required openclaw/ci-gate, for 997c18351662adeccbcf9bceeff2a89b354649e9.
  • ClawSweeper review found no correctness/security defects. Its CI-completion and read-latest-review rank-up move is complete. The storage classifier does not correspond to a schema/record change; the preserved migration/upgrade contracts are covered below.
  • Fresh isolated Codex autoreview: scoped-clean at P0, no findings, after the final source adjustment. Four independent architecture-cleanup reviews preceded implementation.
  • Current-main drift checked through 86b6ec0afa2c64d2019ffdb681760b433b2e10b1: all 25 touched files retain their baseline blobs; adjacent placement-cancellation changes do not consume the changed internal APIs.
  • 540 focused tests passed across nine owner/sibling files, including outbox identity, concurrent hydration admission, persistence, send/submit, pending inputs, row editing, and New Session drafts.
  • 35 native Chromium tests passed across seven files using the real browser storage/Web Locks implementation with a mocked Gateway. Coverage includes the original two-large-PNG steering case, exact bytes/run IDs through offline reload, lost-ACK no-replay, blocked IndexedDB upgrade, duplicate tabs, corrupt/wrong-owner bundles, legacy migration, explicit ambiguous-target recovery, delayed admission versus newer composer input, and reconnect/edit ordering.
  • All 25-path changed gates passed: formatting, types, lint/styles, i18n, architecture/coercion/dependency guards, and unused exports.
  • pnpm build passed before the final fresh-object serialization adjustment; the final pnpm ui:build, all focused tests, native browser tests, and changed gates passed afterward. Final startup JavaScript gzip: 345,896 bytes, below the unchanged 346,761-byte enforcement limit.
  • Initial native collection was blocked by a missing installed dependency file. pnpm install --frozen-lockfile repaired the install without changing manifests or lockfiles. The separate Vite manifest-finalization error-masking defect is recorded as a follow-up and excluded from this PR.
Reproduce focused proof

Unit/owner proof used OPENCLAW_VITEST_MAX_WORKERS=3 and a dedicated filesystem-module-cache directory:

OPENCLAW_VITEST_MAX_WORKERS=3 node scripts/run-vitest.mjs ui/src/lib/chat/outbox-store.test.ts ui/src/pages/chat/outbox-identity.test.ts ui/src/pages/chat/outbox-blob-recovery.test.ts ui/src/pages/chat/composer-persistence.test.ts ui/src/pages/chat/chat-send.test.ts ui/src/pages/chat/chat-send-submit.test.ts ui/src/pages/chat/chat-pending-inputs.test.ts ui/src/pages/chat/queued-message-edit.test.ts ui/src/pages/new-session/draft-persistence.test.ts --run

Native browser proof used a separate filesystem-module-cache directory:

OPENCLAW_VITEST_MAX_WORKERS=3 node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/chat-outbox-capacity.e2e.test.ts ui/src/e2e/chat-outbox-payloads.e2e.test.ts ui/src/e2e/chat-outbox-recovery.e2e.test.ts ui/src/e2e/composer-draft-store.e2e.test.ts ui/src/e2e/composer-recovery-fences.e2e.test.ts ui/src/e2e/new-session-page.draft-handoff.e2e.test.ts ui/src/e2e/chat-flow.queue-edit.e2e.test.ts
pnpm ui:build

Changed checks ran node scripts/check-changed.mjs -- with the 25 changed paths; no baseline or budget files were modified.

@steipete steipete self-assigned this Aug 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 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: M maintainer Maintainer-authored PR labels Aug 30, 2026
@steipete
steipete marked this pull request as ready for review August 30, 2026 17:12
@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 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 1:19 PM ET / 17:19 UTC.

ClawSweeper review

What this changes

The PR consolidates Control UI outbox attachment-custody and composer-draft persistence helpers without intending to change sending, recovery, or draft behavior.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

No actionable correctness defect was found in the introduced refactor. This PR remains open for normal maintainer handling because it is member-authored, carries the protected maintainer label, and its exact-head CI is still running.

Priority: P3
Reviewed head: 997c18351662adeccbcf9bceeff2a89b354649e9
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-negative refactor with no source-level correctness finding; exact-head CI and the unavailable later review comment remain landing checks.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored cleanup is exempt from the external-contributor proof gate; its submitted evidence maps the changed payload owner to native-browser storage/Web Locks tests and the reviewed source retains caller-side delivery and ownership fences.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored cleanup is exempt from the external-contributor proof gate; its submitted evidence maps the changed payload owner to native-browser storage/Web Locks tests and the reviewed source retains caller-side delivery and ownership fences.
Evidence reviewed 6 items Introduced scope and merge result: The pinned PR commit has merge-base 706965a; the verified test merge has the supplied current-main base and PR head as parents, and changes the same 25 UI files.
Attachment update ownership: Payload preparation now returns only attachment-related changes, while the caller merges those changes into its captured queue row after its connection, ownership, and edit fences still hold.
Shared revision invariant: All reviewed revision consumers use the same committed-versus-latest-attempt helper, preserving the existing distinction needed to prevent stale draft writes after a failed attempt.
Findings None None.
Security None None.

How this fits together

The Control UI keeps unsent messages, drafts, and attachment references in browser storage, then restores and delivers them through the active chat session. These changes simplify the shared code that preserves ownership and revision fences across reloads and split panes.

flowchart LR
  A[Composer input] --> B[Draft and outbox persistence]
  B --> C[Attachment custody]
  C --> D[Queued-message actions]
  D --> E[Chat delivery]
  B --> F[Reload recovery]
Loading

Decision needed

Question Recommendation
Should this member-authored Control UI storage refactor land once exact-head CI completes and the latest ClawSweeper rank-up guidance is resolved? Land after validation: Merge after the exact reviewed head is green and any outstanding rank-up move is applied or explicitly skipped.

Why: The source review found no mechanical blocker, but the protected maintainer label requires explicit maintainer handling for a persistence-sensitive UI refactor.

Before merge

  • Resolve merge risk (P1) - The supplied context reports a later ClawSweeper comment whose body is not available to this review; read and address any rank-up moves before landing.
  • Resolve merge risk (P1) - Required checks are still in progress on the reviewed head, so merge readiness is not yet established.
  • Complete next step (P2) - No narrow repair is indicated; keep this active for protected maintainer review and exact-head CI completion.
Agent review details

Security

None.

PR surface

Source -139, Tests -4. Total -143 across 25 files.

View PR surface stats
Area Files Added Removed Net
Source 19 136 275 -139
Tests 6 19 23 -4
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 25 155 298 -143

Review metrics

Metric Value Why it matters
Production versus test LOC production +136/-275 (net -139); tests +19/-23 (net -4) The refactor is materially net-negative in production code while retaining focused coverage of the shared storage and concurrency boundaries.

Stored data model

Persistent data-model change detected: serialized state: ui/src/lib/chat/outbox-recovery.ts, serialized state: ui/src/lib/chat/outbox-store-retirement.ts, serialized state: ui/src/lib/chat/outbox-store.ts, unknown-data-model-change: ui/src/lib/chat/outbox-store.ts, vector/embedding metadata: ui/src/pages/chat/composer-persistence.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the narrow owner-boundary refactor, then land it only after exact-head CI is green and the latest ClawSweeper review guidance has been applied or explicitly skipped.
  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 narrow owner-boundary refactor, then land it only after exact-head CI is green and the latest ClawSweeper review guidance has been applied or explicitly skipped.

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

Not applicable: this PR is a refactor rather than a report of a distinct user-facing defect; its changed ownership paths are covered by focused source-level and browser-storage tests.

Is this the best way to solve the issue?

Yes: returning attachment-only updates from the payload owner and merging them at each captured delivery owner removes duplicate reconstruction without weakening the existing ownership or revision fences.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a focused internal cleanup with no intended user-visible behavior change.
  • 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: This member-authored cleanup is exempt from the external-contributor proof gate; its submitted evidence maps the changed payload owner to native-browser storage/Web Locks tests and the reviewed source retains caller-side delivery and ownership fences.

Label justifications:

  • P3: This is a focused internal cleanup with no intended user-visible behavior change.
  • 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: This member-authored cleanup is exempt from the external-contributor proof gate; its submitted evidence maps the changed payload owner to native-browser storage/Web Locks tests and the reviewed source retains caller-side delivery and ownership fences.

Evidence

What I checked:

  • Introduced scope and merge result: The pinned PR commit has merge-base 706965a; the verified test merge has the supplied current-main base and PR head as parents, and changes the same 25 UI files. (87f9d7291917)
  • Attachment update ownership: Payload preparation now returns only attachment-related changes, while the caller merges those changes into its captured queue row after its connection, ownership, and edit fences still hold. (ui/src/pages/chat/outbox-payloads.ts:124, 997c18351662)
  • Shared revision invariant: All reviewed revision consumers use the same committed-versus-latest-attempt helper, preserving the existing distinction needed to prevent stale draft writes after a failed attempt. (ui/src/lib/chat/outbox-store-draft-state.ts:56, 997c18351662)
  • Behavioral regression coverage: The updated tests continue to cover delayed payload ownership changes, captured destinations after default changes, coalesced hydration, split-pane draft conflicts, and queued-edit action fencing. (ui/src/pages/chat/chat-send.test.ts:7433, 997c18351662)
  • Feature-history routing: Recent merged Control UI outbox repairs include the main-session recovery repair and the attachment-custody repair; this refactor is explicitly adjacent to those owners rather than an obsolete duplicate. (ui/src/pages/chat/outbox-payloads.ts:56, d708507a498b)
  • No Codex-runtime dependency signal: The introduced paths are all Control UI storage and chat files; the PR does not import, execute, generate from, or claim compatibility with the sibling Codex runtime or protocol. (ui/src/pages/chat/outbox-payloads.ts:1, 997c18351662)

Likely related people:

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

Rank-up moves

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

  • Complete exact-head CI and read the latest ClawSweeper comment before merging.

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.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready maintainer review for exact head 997c18351662adeccbcf9bceeff2a89b354649e9.

CI run 33324603156, attempt 1 is successful, including the required GitHub Actions-owned openclaw/ci-gate. The committed patch is byte-identical to the final independently reviewed candidate. Fresh isolated Codex autoreview is P0 scoped-clean, with no findings; native review artifacts validate for this exact head.

Read the complete latest ClawSweeper review. Its rank-up move—complete exact-head CI and read the latest review—is satisfied. The current live comment list has no later unread review body. No source repair was requested by that review. Maintainer decision: land this bounded, behavior-preserving refactor after native gates.

The stored-data classifier is not a migration change: metadata remains v4, shared IndexedDB remains v2, persisted record fields/keys and existing byte/retention limits remain unchanged. This patch neither adds an embedding/vector store nor combines draft and queued-payload lifetimes. The exact retention-filtered object now feeds cleanup after the same write/read-back verification; raw previous/recovery/legacy reference validation and held-lock deletion authority remain intact.

Local proof: 540 focused owner/sibling tests, 35 native Chromium mocked-Gateway tests, all 25-path changed gates, and final UI build passed. Native proof uses real IndexedDB and Web Locks, including offline bytes/run IDs, lost-ACK no-replay, duplicate tabs, migration/recovery, stale edits/drafts, and the original two-large-image steering scenario. It is not authenticated operator-Gateway proof; no operator service or credentials were used. The PR Evidence section contains the exact reproducible test commands and build qualification.

Production +136/-275 (net -139); tests +19/-23 (net -4). No budget/baseline/schema/config/dependency changes. The separate Vite failed-build diagnostic follow-up remains excluded. Main drift through native baseline 6f3b26f6a3bbd7c67c75574d1cc291a5e8243858 leaves all 25 baseline files unchanged; no neighboring main edit consumes the removed/narrowed APIs. No rebase or admin bypass is needed.

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: 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