Repository navigation
feat(ui): preserve composer drafts across restarts - #125332
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 8:53 PM ET / August 18, 2026, 00:53 UTC. ClawSweeper reviewWhat this changesAdds scoped browser-local IndexedDB persistence so Control UI composer text and staged attachments survive a restart and are retired after their owning lifecycle events. Merge readinessNo blocking correctness finding was found. This maintainer-labeled PR remains the active candidate for the paired draft-recovery feature and needs maintainer approval plus completion of exact-head checks before landing. Priority: P2 Review scores
Verification
How this fits togetherControl UI chat and New Session composers collect unsent text and attachments. This PR derives a credential-and-session scope, stores the draft locally in IndexedDB, restores it after restart, and retires it after send, creation, removal, deletion, or Incognito transitions. flowchart LR
A[Composer text and attachments] --> B[Gateway credential and session scope]
B --> C[Browser-local draft store]
C --> D[Restart or route restore]
D --> E[Composer restored]
A --> F[Send, remove, delete, or Incognito]
F --> G[Durable draft retired]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +1588, Tests +1012, Docs +2. Total +2602 across 30 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one browser-local, credential-scoped draft owner with the documented retention bounds and lifecycle retirement, then land after maintainer approval and exact-head checks complete. Do we have a high-confidence way to reproduce the issue? Yes. Current main lacks the three durable-draft modules, and focused real-Chromium E2Es exercise fresh-page restart restoration and cleanup at the owning UI boundary. Is this the best way to solve the issue? Yes. Device-local, credential-scoped storage solves restart recovery without introducing Gateway, protocol, server-storage, or configuration surface. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3dd95d7bf790. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Rebased head Exact post-rebase/post-fix proof:
LOC classification: production +1,564/-71; tests +739/-8; docs +4/-2 across 27 files. Positive production growth is the new durable browser-storage capability, Blob hydration and CAS fencing, and the lifecycle owners needed to retire data after send/create/removal/deletion/Incognito transitions. The behavior is entirely browser-local. Real Chromium with a mocked Gateway exercises the owning boundary; there is no Gateway API, SQLite, protocol, config, dependency, or cross-device surface requiring a live Gateway. |
|
Head:
This is a test-only correction; production behavior is unchanged. Separately, GitHub's major outage affected CI availability, but it did not cause this real test failure. |
Accept the committed predecessor or a known in-flight local write ID atomically so New Session writes can start before teardown without spurious local-lineage conflicts. Reset cached lineage when authoritative storage is missing and re-snapshot the still-current edit.
|
Latest P1 resolved in 0fd719f967d, now the exact PR head. New Session transactions start before teardown, while CAS atomically accepts only the committed predecessor or a known in-flight local predecessor; authoritative missing records reset stale lineage and re-snapshot the still-current edit. Proof: full UI 685 files / 9,766 passed / 1 skipped; all draft E2E green; focused lineage/teardown/New Session 18/18 with repeated stress green; architecture, docs, and check-changed green; final fresh P1 autoreview clean. All Before merge items and rank-up moves are addressed. The PR remains open and unmerged; no re-review requested. |
|
Merged via squash.
|
Closes #125330
AI-assisted: yes
What Problem This Solves
A browser or app restart currently loses unsent Control UI text and staged image/file attachments in both existing-session and New Session composers. Users must reconstruct the message and select the attachments again before they can continue.
Why This Change Was Made
A browser-local IndexedDB owner now stores composer text and native attachment Blobs atomically. It reuses the existing session scope and compare-and-swap semantics, isolates records by the exact Gateway credential recovery scope and session, agent, or New Session target, excludes Incognito, bounds retained storage, and clears durable data only at the lifecycle owner boundaries for successful send or session creation, attachment removal, and session deletion.
The final lineage repair starts New Session writes before teardown while preserving atomic compare-and-swap behavior. CAS accepts only the committed revision/write ID or a known in-flight local predecessor ID; missing nonzero predecessors and unrelated same-revision writers still conflict. Completed local IDs leave the lineage set, and an authoritative missing record clears stale lineage before the still-current edit is re-snapshotted. Incognito remains memory-only until a real normal-mode edit, and oversized text-only fallback keeps the committed lineage identity.
This is device-local browser persistence, not cross-device or server syncing. There are no Gateway API, SQLite, protocol, config, or dependency changes.
Owner decision: Peter requested image draft restart persistence and accepts bounded browser-local retention (7 days / 20 scopes / 25 MiB); no server sync.
The production growth is the new durable browser-storage capability: attachment Blob ownership, compare-and-swap fences, and separate lifecycle owners for existing-session and New Session composers cannot be expressed as a smaller extension of the prior memory-only path.
User Impact
Control UI drafts and attachments now return after browser or app restarts in the same browser profile, login, and session or New Session target. Drafts expire after 7 days, retain at most 20 scopes per owner, and cap attachments at 25 MiB per draft. Clearing site data and using Incognito/private profiles still loses drafts by design.
When a draft's attachments exceed the durable cap, the browser preserves the exact text and omits only attachment payloads that cannot be persisted, with a visible warning in the current tab.
Release-note context: Control UI drafts and attachments now survive browser/app restarts in the same browser profile.
Evidence
Before the final repair, New Session could defer a newer attachment snapshot behind an earlier IndexedDB write, allowing page teardown before the newer transaction was registered. Commit 0fd719f967d starts each transaction immediately and preserves strict atomic local-lineage CAS.
Validation:
pnpm test:ui— 685 files; 9,766 passed / 1 skipped.pnpm check:architecture— passed with 0 runtime cycles and 0 Madge cycles.pnpm docs:check-mdx— passed.pnpm check:changed— complete proportionalcoreTests,ui, anddocslanes passed.git diff --check— passed..agents/skills/autoreview/scripts/autoreview --mode local --max-priority P1— final fresh review clean; no accepted/actionable findings.LOC classification: Production +1,680/-92; Tests +1,050/-38; Docs +4/-2.
The browser proof uses a mocked Gateway with real Chromium. No live Gateway was needed because this change has no Gateway surface.
Restored after restart — New Session
Cleared after successful submission/removal — New Session
Restored after restart — existing session
Cleared after successful submission/removal — existing session