Skip to content

feat(ios): steer queued chat messages into the running reply - #187078

Closed
jorge-monalee wants to merge 1 commit into
openclaw:mainfrom
jorge-monalee:ios-queue-steer
Closed

jorge-monalee wants to merge 1 commit into
openclaw:mainfrom
jorge-monalee:ios-queue-steer

Conversation

@jorge-monalee

Copy link
Copy Markdown
Contributor

Related: #168604

What Problem This Solves

Fixes: on iPhone, a message sent with Queue next while a reply is running goes straight into the Gateway's queue, so it can't be steered into that reply the way Control UI's queued messages can.

User Impact

User impact: while a reply runs, a Queue next message stays in the chat as Queued. Touch and hold it and choose Steer to send it into the running reply now, or press Command-Return with an empty draft on a hardware keyboard to steer the oldest queued message (Command-Return with a typed draft sends it). If you do nothing, queued messages send in order when the reply finishes.

Behavior change to note: Queue next messages now wait on the device instead of in the Gateway queue. If the app is closed or backgrounded before the reply finishes, they send the next time the app is active. Switching to another chat, or a run this view can't see, hands them to the Gateway queue as before. Tapping Send and Steer now are unchanged. The macOS app shares this chat code, so it gets the same hold and the Steer menu item, but not the shortcut. Easy to revert (two-way door): no schema change, no new Gateway request, and rows already queued keep working either way.

Why This Change Was Made

Control UI holds queued messages on the client until the run is idle and steers one by re-sending it with chat.send queueMode: "steer". The iOS durable outbox now does the same, reusing the existing queue_mode column and chat.send request:

 flush outbox
-  claim oldest queued row
+  claim oldest queued row, skipping Queue next rows of the visible running session
+    (watch run activity; when it settles, flush again → held rows send FIFO)
   chat.send(queueMode: row.queueMode)

+Steer (message menu, Command-Return)
+  queued followup row → steer   (only while still queued)
+  flush → steered row passes older held rows → chat.send(queueMode: steer)

Steering a message the Gateway has already queued still isn't possible from iOS; #160275 / #160593 propose a chat.steer request for that.

Evidence

  • Not run locally: Swift build and tests. No macOS host was available (the shared chat UI needs SwiftUI/UIKit). PR CI's macOS lanes run them. New and updated tests:
    • ChatViewModelBusySendTests › queue next waits for the visible reply then keeps FIFO (replaces the old busy-followup FIFO test, which expected Queue next to go to the Gateway right away): the row stays queued and steerable during the run, then sends as followup, in order, once the run settles.
    • ChatViewModelBusySendTests › steering a queued message sends it into the running reply ahead of older queued messages: the menu path sends the newer row as steer while the older one stays queued, then the keyboard path steers the older one.
    • ChatCommandOutboxStoreTests › held queue next rows let later rows pass and steer only while queued: claim skips only the held session's followups, and the steer update is refused once a row has been claimed.
    • ChatComposerTextViewIOSTests › command return routes to send or steer outside text composition: Command-Return/Enter route to the handler, other modifiers and IME composition don't, and an unhandled key falls back to UIKit.
  • SwiftFormat 0.63.1 --lint --config config/swiftformat on the 10 changed Swift files: 0 need formatting. Changed Swift lines stay within the 120-column limit.
  • pnpm native:i18n:verify: pass (one new source entry, Steer; translations are left to the locale refresh workflow). Docs: oxfmt --check and docs:check-mdx pass, no spellcheck hits in docs/platforms/ios.md, and git diff --check is clean.
  • Local review: openclaw/agent-skills autoreview (2882b90, source-sha256 4cf7f15a…), branch mode, base dadf9122058, head 594e4ae5cb6, P0–P2, Claude engine (Codex CLI isn't logged in on any host available to me). Result: scoped-clean, no findings. I checked the three things the reviewer couldn't confirm: every input to run activity is observation-tracked (liveRunStateByRunID registers access and mutation by hand), a session switch resets all of them so held rows get released, and the only outbox conformers are the SQLite store and the test double.
  • pr-simplify pass: every hunk serves the feature. I dropped an unused accessibility identifier and a @discardableResult. The change is +255/−9 against the merge base: about 150 production lines (no new types, no migration) and 112 test lines.
  • Screenshots pending: send enabled during a run, the queued Queue next message, and its menu showing Steer. They need a macOS host with the iOS simulator and a seeded fixture Gateway. This PR stays a draft until they're added.

Queue next messages now wait on the device while the visible reply runs, as Control UI queued messages do, and can be steered from the message menu or with Command-Return on a hardware keyboard. Steering reuses chat.send with queueMode steer.
@clawsweeper

clawsweeper Bot commented Oct 28, 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 docs Improvements or additions to documentation app: ios App: ios size: M labels Oct 28, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 28, 2026
@clawsweeper

clawsweeper Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR holds explicit Queue next messages locally and adds menu and hardware-keyboard actions to steer them into an active reply.

Example: While an iPhone reply runs, queue “Use metric units,” then choose Steer from that message’s menu.

  • Before: The message has already reached the Gateway queue and cannot be steered through the native message menu.
  • After: The device-held message changes to steer mode and sends into the running reply.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation stays within existing owners, but an introduced ordering defect blocks correctness and native behavior remains unproven.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Feature · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: An iPhone user cannot change an already queued follow-up into steering through the native chat interface.
Reason: The capability has clear use, but achieves it by moving Queue next delivery from the Gateway to the device and changing inactive-app behavior.

Merge readiness

⛔ Blocked before merge - 3 items remain

This PR offers a distinct native-chat capability, but introduces a same-session ordering regression and needs an owner decision on device-held delivery.

Priority: P2
Reviewed head: 594e4ae5cb669a481300f51a1cd54e44fee4ed9c
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should explicit Queue next messages wait on the device, accepting delayed delivery while the native app is inactive?
  • Recommendation: Retain Gateway-owned queueing: Preserve delivery while the app is inactive and pursue native steering through the Gateway-owned queued-input capability tracked by fix(chat): safely steer an existing Gateway-queued input #160275.
  • Why: The PR explicitly changes the earlier Gateway-owned delivery contract for both Apple platforms, and no maintainer approval of that tradeoff appears in the discussion.

Before merge

  • Add real behavior proof - No supplied evidence exercises this native implementation after the change: the body leaves native screenshots and Swift execution pending, and the inspected images belong to the separate Control UI PR. Provide native before/after captures and app/Gateway output showing Queue next held during a reply, menu and Command-Return steering, ordered idle release, and background/relaunch recovery with existing queued data; redact credentials, IPs, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Preserve FIFO when an ordinary send follows a held message (P2) - With the session’s effective queue mode set to collect, the composer offers Queue next. Queue message A with that action, then tap ordinary Send for B while the reply is still running. A has queueMode followup and is excluded here, while B enters the same outbox with nil queueMode and passes this predicate. B reaches the Gateway’s collect queue before A is released, reversing their submission order without the user choosing Steer. Preserve same-session ordering for ordinary sends behind held rows, while allowing deliberate steering and unrelated sessions to proceed; update the store expectation that currently permits the default row to bypass and cover this mixed-send sequence.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

  • [P2] Preserve FIFO when an ordinary send follows a held message — apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatTranscriptCache.swift:620

Tests

  • Missing end-to-end proof: Native app proof must show holding, menu and keyboard steering, FIFO release, and lifecycle recovery; the new Swift cases have no supplied execution or baseline comparison.
Agent review details

How this fits together

The shared Apple chat composer feeds a gateway-scoped SQLite outbox; the view model claims durable messages and sends them through existing route leases to Gateway chat.send.

flowchart LR
  Composer[Apple chat composer] --> Model[Chat view model]
  Menu[Message Steer action] --> Model
  Model --> Store[SQLite outbox]
  Store --> Lease[Existing route lease]
  Lease --> Gateway[Gateway chat.send]
  Gateway --> Reply[Active reply or followup]
Loading

Technical review

Best possible solution:

Preserve same-session FIFO in the existing outbox and agree on whether Queue next may wait for the app to become active.

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

Source establishes the failure: with effective queue mode collect, enqueue A through Queue next and then B through ordinary Send; A is filtered out while B’s nil-mode row remains claimable. No target code was executed.

Is this the best way to solve the issue?

Reusing the existing durable outbox is a focused implementation, but its scheduling policy must preserve ordinary same-session ordering rather than treating every non-followup row as an intentional bypass.

Full review comments:

  • [P2] Preserve FIFO when an ordinary send follows a held message — apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatTranscriptCache.swift:620
    With the session’s effective queue mode set to collect, the composer offers Queue next. Queue message A with that action, then tap ordinary Send for B while the reply is still running. A has queueMode followup and is excluded here, while B enters the same outbox with nil queueMode and passes this predicate. B reaches the Gateway’s collect queue before A is released, reversing their submission order without the user choosing Steer. Preserve same-session ordering for ordinary sends behind held rows, while allowing deliberate steering and unrelated sessions to proceed; update the store expectation that currently permits the default row to bypass and cover this mixed-send sequence.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 700930378c79.

Provenance checked

Testing

Proof path: none.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 4b7661e adds apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+Outbox.swift:247 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4b7661e9a0c4; files: apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+Outbox.swift)
  • cavit99: Raw commit bda23f6 adds apps/shared/OpenClawKit/Tests/OpenClawKitTests/ChatViewModelOutboxTests.swift:1145 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: bda23f641542; files: apps/shared/OpenClawKit/Tests/OpenClawKitTests/ChatViewModelOutboxTests.swift)
  • Vincent Koc: Raw commit 455a9d6 adds apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatComposerTextViewIOS.swift:208 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 455a9d678baa; files: apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatComposerTextViewIOS.swift)

PR surface

Source +140, Tests +106, Docs 0. Total +246 across 12 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 8 145 5 +140
Tests 3 109 3 +106
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 255 9 +246

Review metrics

Metric Value Why it matters
Production versus test Swift changes Production +144/-5; tests +109/-3 Growth reuses the existing composer, outbox, SQLite store, and delivery path; no new module or storage schema is introduced.

Labels

Label changes:

  • add P2: This is a bounded native-chat feature with a concrete ordering defect, without evidence of an urgent released regression.
  • add merge-risk: 🚨 message-delivery: The claim filter can deliver a later ordinary message before an earlier Queue next message in the same conversation.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: This is a bounded native-chat feature with a concrete ordering defect, without evidence of an urgent released regression.
  • merge-risk: 🚨 message-delivery: The claim filter can deliver a later ordinary message before an earlier Queue next message in the same conversation.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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.

Reviewed October 28, 2026, 7:33 PM ET / 23:33 UTC.

@jorge-monalee

Copy link
Copy Markdown
Contributor Author

Closing this in favor of keeping Queue next in the Gateway queue. Holding messages on the device delays delivery while the app is inactive, and it caused the ordering bug ClawSweeper found.

Steering a queued message from iOS should use the chat.steer request from #160275 instead. A small iOS change can add the Steer action once that lands.

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 merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant