Repository navigation
feat(chat): keep composer drafts across app restarts - #197846
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR preserves native Apple chat drafts and attachments across app restarts using the existing client-state database. Example: Type “Draft survives restart 1794505244” in iOS chat, terminate the app, and relaunch.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this useful maintainer-authored feature remains absent on main, and both earlier failed-write findings are resolved without a remaining actionable finding. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe shared Apple chat view model receives composer edits, persists them by Gateway and session, and transfers submitted content to the existing outbox or live send pipeline. flowchart LR
A[Apple chat composer] --> B[Shared chat view model]
B --> C[Draft persistence]
C --> D[Client state SQLite]
D --> B
B --> E[Durable outbox]
B --> F[Live Gateway send]
Technical reviewBest possible solution: Retain the shared SQLite draft owner, successful-write custody tracking, and transactional transfer to the existing outbox. Do we have a high-confidence way to reproduce the issue? Current-main source establishes memory-only native drafts, and the inspected simulator screenshots support the reported restart loss and restored-text behavior; no target code was executed. Is this the best way to solve the issue? Extending the existing durable client-state owner is appropriate, and the revised implementation retains failed writes without introducing a competing persistence system. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 76024435027d. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +752, Tests +462, Docs +41. Total +1255 across 25 files. Added test files: 2. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 12, 2026, 2:17 PM ET / 19:17 UTC (Revision 2). |
|
Addressed the ClawSweeper findings on
Upgrade from v2026.11.3 (iPhone simulator, local Gateway):
After the failed-write fix, the kill/relaunch draft check passed again on this head. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
* feat(chat): keep composer drafts across app restarts * chore(i18n): record the draft store's reuse of the attachment size string * fix(chat): keep draft text and attachments when a draft save fails






Problem
Native chat (iOS and macOS) kept composer drafts only in memory (
draftsBySession). If the app is killed, crashes, or iOS terminates it in the background, whatever you were typing is lost, and so are any picked attachments. On iOS a pending attachment also blocked switching sessions, because nothing else would keep it.Solution
Composer drafts are stored per session in
client-state.sqlite, the client-owned store that already holds the chat outbox. The schema was approved by the iOS owner.client-state-composer-drafts-v11):composer_drafts(text, revision, updated time per gateway and session key) andcomposer_draft_attachments(same columns asoutbox_attachments).watch_message_forget) does the same when an older build performs the Forget.main/global, its routing) is known, so nothing is stored under a key that later changes. Text typed before the load arrives is appended to the loaded draft.docs/reference/database-schemas/personal-data.mddescribes the new tables, retention (until sent, cleared, or the Gateway is forgotten), and Forget.Impact
What you type in a chat, including picked attachments, is still there after an app restart, a crash, or iOS ending the app in the background. Switching sessions with a pending attachment works. Older app versions ignore the new tables.
Evidence
Simulator (iOS 27, isolated local Gateway): type a message into a chat, terminate the app, relaunch.
main(5d6a026)Screenshots are in the PR comments.
Upgrade from v2026.11.3 (simulator, local Gateway): queue a message offline on v2026.11.3 → install this PR over it → relaunch offline: no onboarding, message still "Queued" → Gateway back: reconnects and delivers it → type a draft, kill, relaunch: draft is back. Screenshots in the PR comments.
Tests: each new test fails with its fix removed and passes with it.
Suites: OpenClawKit chat suites pass. Two
ChatMediaVideoPlayerTeststiming failures under parallel load pass when run alone, and that file is unrelated. iOS: 560 Swift Testing tests in 12 suites and 9 XCTest tests pass. macOS:swift build --product OpenClawsucceeds.Reviews: a second-model design review and code review. All findings are applied: unbound text survives a switch, one draft key for revisions, a send captured before load, a test rewrite, macOS pending checks, a shared write chain across view-model rebuilds, and saving on macOS quit.
Accepted edge cases, named in code:
Size: production +710/−31 (two new files), tests +391/−7, docs +39/−1.