Skip to content

feat(chat): edit queued messages and get rejected sends back in the composer - #197908

Merged
obviyus merged 2 commits into
mainfrom
feat/chat-edit-queued
Nov 12, 2026
Merged

obviyus merged 2 commits into
mainfrom
feat/chat-edit-queued

Conversation

@obviyus

@obviyus obviyus commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #197846

What Problem This Solves

A message queued in native chat (iOS and macOS) can only be retried or deleted. To fix a typo you have to delete the message and retype it. When the Gateway rejects a send for good, the text sits in a red "Not sent" bubble instead of coming back to you.

User Impact

  • Edit: touch and hold a queued message, or a failed one, and choose Edit. The message leaves the queue and its text and attachments go back into the composer, below anything you were already typing.
  • Restore: when the Gateway definitely rejected a send and chat history proves it never arrived, the message goes back into an empty composer by itself, with a note: "Not sent: . Your message is back in the composer."
  • Never loses or duplicates text: a message that may already have been delivered is never moved.

Why This Change Was Made

PR #197846 gave each chat a saved draft. Edit is one store operation that, in a single transaction, removes the outbox row and appends its text and attachments to that draft. It uses the same canonical-proof lock as cancel, so a row that chat history shows as delivered is removed as confirmed and the draft is not touched. Rows whose delivery is unknown (delivery_unconfirmed, branch-parked) offer no Edit, and the store refuses them too.

Auto-restore is an automatic Edit with stricter gates:

  • Rejection kind: the final attempt was rejected, or the row expired after a single attempt with no unacknowledged send.
  • Proof of absence: a complete chat history page (or applied delta) for the same agent and session was requested after the failure was first seen and after the last connection change, and the turn never appeared in history this view has observed.
  • Safe moment: the chat is on screen and active, the composer is empty, and the merge fits the draft limits without evicting other drafts' attachments. Edit, as a user action, may evict.

The gates are re-checked inside the draft write chain, right before the composer changes. A refusal (another view claimed the row, or the draft is full) is remembered for that failure, so it is not retried on every history load.

Accepted edges (named in code):

  • A refused move that races a keystroke or session switch can leave the text in the draft next to its row.
  • A second macOS window on the same draft keeps last-writer-wins.
  • A rejected first message in an empty chat restores on the next full history load, not immediately.

Evidence

Simulator (iOS 27, isolated local Gateway): pair, stop the Gateway, send a message (it queues), touch and hold it.

Build Menu on the queued message After choosing Edit
main with #197846 Copy, Select Text, Reply, Delete (no Edit)
this PR adds Edit queued bubble gone, text in the composer with the cursor at the end

Screenshots are in the PR comments, taken on this head (a333ce50c09).

Tests: every restore gate was disabled one at a time, and its test failed:

  • history requested before the failure was seen
  • history requested before a connection change
  • a turn history already showed (cumulative, including across an empty delta)
  • another agent's row (it neither restores here nor blocks a provable row)
  • incomplete and lagging pages
  • a branch-parked ambiguous live send
  • a restore over the gateway draft budget (never evicts)
  • had_unacknowledged_send
  • the pinned failure version
  • typing while a restore is on its way (the recheck inside the write chain)
  • a restore proved before the draft binds lands when it binds

Edit cases: a queued row, a failed row, a proven-delivered row (removed as confirmed, draft untouched), unconfirmed and branch-parked rows (no Edit), a session switch during the move (no error shown in the new chat), and attachments that keep their stored positions.

Suites: the OpenClawKit store and outbox suites pass. Full-run failures are limited to audio and TLS timing tests that also fail on the base and pass in isolation. iOS chat suites pass, except one audio render case that also fails on the base. The macOS app builds. i18n verify reports no changes.

Reviews: three second-model review rounds. All findings applied, including the final round's low items, after a simplify pass that shares the attachment SQL with the draft insert path and makes restore use the same Edit rule.

End to end, with an upgrade from v2026.11.3 (see the PR comment): messages queued on v2026.11.3, including one with a photo, survive the upgrade. Edit moves the text and the full photo into a draft that survives a kill and relaunch. A real Gateway rejection (archived session, three attempts) restores the first message into the empty composer. The second stays "Not sent" because the composer is no longer empty, and Edit then appends it below.

@clawsweeper

clawsweeper Bot commented Nov 12, 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.

@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator Author

Simulator before/after (iOS 27, isolated local Gateway, message queued while the Gateway is stopped). Before = main with #197846; after = this PR head a333ce50c09.

Before: queued message menu has Copy, Select Text, Reply, Delete; no Edit

After: queued message menu adds Edit

After choosing Edit: the queued bubble is gone and the text is back in the composer

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: ios App: ios size: XL labels Nov 12, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Adds editing of queued messages and automatic restoration of provably rejected sends into the native chat composer.

Example: Two queued messages are rejected because their session is archived.

  • Before: Both messages remain Not sent, with Retry and Delete actions.
  • After: The first returns to the empty composer with an explanation; Edit appends the second below it.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, coherent feature with production-entry-point and stable-upgrade evidence; no concrete contributor-facing blocker remains.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): Inspected iOS simulator screenshots and the same-head upgrade account show queued-message Edit, photo draft persistence after relaunch, real archived-session rejection recovery, preservation of the next failed message, and manual append.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Native chat users must delete and retype queued messages to correct them, while rejected messages remain outside the composer.
Reason: The maintainer-authored direction supplies concrete recovery value using the recently merged draft owner without adding configuration or a new schema.

Merge readiness

✅ Ready for maintainer review

This PR provides useful native-chat recovery through existing storage owners, with no blocking correctness or security findings.

Priority: P2
Reviewed head: a333ce50c09cfc1e4ce0ed88383545edf7f98ebf

Before merge

None.

Findings

None.

Agent review details

How this fits together

The shared Swift chat UI connects iOS and macOS composers to the durable SQLite outbox and draft store; Gateway history supplies delivery evidence before automatic recovery.

flowchart TD
  A[Native message menu] --> B[Chat view model]
  C[Gateway history] --> B
  B --> D[Existing cancellation transaction]
  D --> E[SQLite outbox]
  D --> F[SQLite composer draft]
  F --> G[Visible composer]
Loading

Technical review

Best possible solution:

Land the shared transactional Edit and restore path while retaining existing delivery-uncertainty protections.

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

Current-main source and the inspected before screenshot establish the missing Edit action; the contributor supplies after-change simulator evidence rather than a reviewer-executed reproduction.

Is this the best way to solve the issue?

The implementation keeps one durable owner, shares cancellation's canonical-proof transaction, and preserves ambiguous sends instead of introducing a competing queue or draft store.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 0e57ae4cb187.

Provenance checked

  • Durable composer drafts and attachment budgets keeps the original intent (8ef78ec: Preserve per-session text and attachments across restarts through client-state.sqlite and one shared draft write chain.)
  • Cancellation and canonical delivery proof keeps the original intent (bdf71d7: Unify native client storage while preserving durable work and canonical-proof coordination; this PR shares that existing transaction boundary.)
  • Failed-message recovery actions changes intended behavior with a stated reason (4b7661e: Keep terminally rejected commands visible with explicit retry/delete recovery; this PR explains why Edit and guarded restoration improve that experience.)
  • Incremental history reconciliation keeps the original intent (2065cee: Reuse accepted history cursors and preserve canonical ordering without repeated full downloads; restoration consumes that owner’s accepted full-page or delta evidence.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Pinned change and current main: Reviewed the introduced merge-base-to-head hunks and original owner code; fetched main retains Retry and Delete without this Edit or automatic restore capability. (apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+Outbox.swift:367, a333ce50c09c)
  • Atomic transfer through existing owners: The transfer uses the existing canonical-proof lock and one immediate transaction to append draft text and attachments and remove the outbox row; claimed, unconfirmed, and branch-parked rows are refused. (apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatComposerDraftStore.swift:210, a333ce50c09c)
  • Real behavior and upgrade evidence: Inspected the before/after Edit images and all five upgrade images in the author's proof comment. The documented iOS 27 run upgrades from v2026.11.3, preserves queued text and a 900,780-byte photo, retains the edited draft after relaunch, exercises archived-session rejection, and shows automatic restoration followed by manual append. (a333ce50c09c)
  • Prior review requests resolved: The earlier review covered this same head and listed no findings; the new production-entry-point rejection and stable-upgrade evidence addresses both retained rank-up requests. (a333ce50c09c)
  • Merged draft foundation: The merged durable draft PR established client-state.sqlite draft ownership, attachment budgets, and the shared write chain that this PR reuses. (apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatComposerDraftStore.swift:321, 8ef78ec2dc4e)
  • Exact-head checks and merge state: GitHub reports the reviewed head mergeable and clean; its CI, dependency-review, and security-sensitive-review status contexts are successful, with no failing reported checks. (a333ce50c09c)

Likely related people:

  • Ayaan Zaidi: Raw commit 8ef78ec adds apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatComposerDraftStore.swift:214 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8ef78ec2dc4e; files: apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatComposerDraftStore.swift)
  • Peter Steinberger: Raw commit 06789ca adds apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatTranscriptCache.swift:952 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 06789ca4c2ed; files: apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatTranscriptCache.swift)

PR surface

Source +554, Tests +718, Docs +1. Total +1273 across 17 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 12 653 99 +554
Tests 4 723 5 +718
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 17 1377 104 +1273

Preflight source

Source 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

Metric Value Why it matters
Production versus test changes Production +646/-97; tests +723/-5 Growth covers the atomic transfer, native presentation, and distinct delivery, history, attachment-budget, and lifecycle boundaries while reusing existing storage and write-chain owners.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: Useful native-chat recovery and editing improvement with limited scope; existing Retry and Delete remain available.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-12T20:49:26.454Z sha a333ce5 :: blocked before merge. :: none

Reviewed November 12, 2026, 4:18 PM ET / 21:18 UTC (Revision 2).

@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator Author

End-to-end proof on a333ce50c09 (iPhone simulator, iOS 27, isolated local Gateway), upgrading from v2026.11.3. This covers the ClawSweeper request.

  1. v2026.11.3, Gateway stopped: queue A "Edit me…", B "Restore me…" and C "Photo edit…" with a 901 KB photo. All three show Queued.
  2. Install this PR over v2026.11.3, still offline: no onboarding and the settings are kept. All three rows are still queued, C's photo is still attached, and the draft tables were added.
  3. Edit on C: the row leaves the queue. The composer holds C's text and the photo; the stored draft attachment is 900,780 bytes, the full photo. After killing and relaunching the app, the draft and photo are still there.
  4. Real Gateway rejection: with the app closed, archive the session (openclaw sessions archive) and start the Gateway. On launch every chat.send is rejected with INVALID_REQUEST … Session … is archived, three times per row, and chat.history still answers.
    • A reached its final rejection while the composer was empty. A history page proved it never arrived, so its text went back into the composer with "Not sent: … Your message is back in the composer."
    • B was rejected next, but the composer now held A's text, so B was not moved. It stays "Not sent" with Edit, Retry Send and Delete.
  5. Edit on B: the outbox is now empty, and the draft is "Edit me after upgrade…" + blank line + "Restore me after upgrade…".

The session was unarchived afterwards and the simulator deleted.

v2026.11.3 offline: messages queued, one with a 901 KB photo

After upgrading to this PR, offline: still queued, photo intact

Edit on the photo message, then kill and relaunch: text and photo in the composer

Real Gateway rejection: first message restored into the empty composer with the Not sent notice; the next stays Not sent

Edit on the failed message appends it below the restored text

@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 12, 2026
@obviyus
obviyus merged commit 21479e2 into main Nov 12, 2026
111 checks passed
@obviyus
obviyus deleted the feat/chat-edit-queued branch November 12, 2026 21:25
@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 13, 2026
…omposer (openclaw#197908)

* feat(chat): edit queued messages and restore rejected sends to the composer

* fix(chat): restore on draft bind and keep edit errors in their own chat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: ios App: ios docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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