Repository navigation
fix(ios): preserve structured follow-ups across queued delivery - #132689
Solvely-Colin wants to merge 24 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
There was a problem hiding this comment.
Pull request overview
This PR hardens iOS “active-run follow-up” actions (Steer / Queue / Interrupt) so that when a send must be persisted and replayed (offline, reconnect, cold launch), the original structured intent (session identity, queue mode, reply target, leaf expectation, and settings fence) is durably captured, revalidated, and only delivered when the Gateway explicitly supports the structured send-context contract.
Changes:
- Advertises a new Gateway capability (
chat-send-context-contract) and extends admission validation to fence stale/replaced session follow-ups. - Adds iOS durable outbox schema/migrations (v9–v11) and client-side send-context persistence/decoding to preserve structured follow-up meaning across replay.
- Updates iOS transport + UI behavior (composer capability gating, run snapshot adoption, outbox flush validation, accessibility labels) and adds targeted test coverage.
Reviewed changes
Copilot reviewed 40 out of 40 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/gateway/server/ws-connection/connect-hello.ts | Advertise the new server capability in the hello payload. |
| src/gateway/server.auth.default-token.suite.ts | Asserts the capability is present in hello for default-token auth suite. |
| src/gateway/server-methods/chat.directive-tags.test.ts | Adds regression tests around stale sessions and reconnect behavior for structured sends. |
| src/gateway/server-methods/chat-send-admission.ts | Tightens admission fencing for supplied sessionId and active-leaf expectations. |
| packages/gateway-protocol/src/server-capabilities.ts | Adds CHAT_SEND_CONTEXT_CONTRACT capability constant. |
| apps/shared/OpenClawKit/Tests/OpenClawKitTests/ChatTranscriptCacheStoreTests.swift | Extends cache/outbox tests for new persisted session settings + send context and migrations. |
| apps/shared/OpenClawKit/Tests/OpenClawKitTests/ChatGatewayRequestTests.swift | Verifies request params for structured send-context fields and history decoding tolerance. |
| apps/shared/OpenClawKit/Tests/OpenClawKitTests/ChatComposerParityTests.swift | Adds parity tests for structured reply behavior and capability UI/accessibility sizing. |
| apps/shared/OpenClawKit/Sources/OpenClawKit/GatewayPush.swift | Adds Swift-side enum case for the new gateway capability string. |
| apps/shared/OpenClawKit/Sources/OpenClawChatUI/ClientDatabases.swift | Registers/defines outbox migrations v9–v11 (send context + structured claim fencing). |
| apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+TransportEvents.swift | Preserves run activity state for follow-up flows across terminal events/acks. |
| apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+Sending.swift | Builds structured send context, reserves active follow-up outbox rows, and gates follow-ups/attachments. |
| apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+RunSnapshot.swift | Uses authoritative active run IDs to avoid incorrectly replacing local pending runs. |
| apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+Outbox.swift | Persists/flushes structured context, validates session before delivery, and updates retry/parking behavior. |
| apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+HistoryReconciliation.swift | Updates displayed leaf expectation + effective queue mode from session info in history payload. |
| apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+ComposerCapabilities.swift | Adds structured-send capability awareness and refines “next run” hints/notices. |
| apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel.swift | Tracks leaf expectation / effective queue mode and follow-up run activity preservation state. |
| apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatView.swift | Adjusts retry UI gating and ensures reply targets retain transcript IDs. |
| apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatTransport.swift | Replaces targeted-send API with context-based send API; adds structured-send capability hooks. |
| apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatTranscriptCacheContracts.swift | Centralizes outbox constants/error mapping used by UI + cache. |
| apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatTranscriptCache+PortableShaping.swift | Extracts portable cache shaping, capping large diff/tool payloads. |
| apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatTranscriptCache+OutboxDecoding.swift | Adds decoding/encoding helpers for send-context fields stored in SQLite outbox rows. |
| apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatTranscriptCache.swift | Persists send-context columns, increments structured retry auth, emits richer outbox change events. |
| apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatSessions.swift | Removes legacy OpenClawChatSendTarget in favor of OpenClawChatSendContext. |
| apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatSendContext.swift | Introduces OpenClawChatSendContext, OpenClawChatQueueMode, and leaf expectations. |
| apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatReply.swift | Adds transcript-level reply identity to avoid embedding quote text in structured sends. |
| apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatModels.swift | Extends session info payload with leaf/queue fields and decodes unknown modes safely. |
| apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatMessageViews.swift | Adds new outbox status labels/help text for changed-session and upgrade-required states. |
| apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatGatewayRequest.swift | Adds request params for send-context contract fields (sessionId, queueMode, etc.). |
| apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatComposerCapabilities.swift | Adds structuredSendAvailable to composer capability catalog. |
| apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatComposer+CleanControls.swift | Updates send button accessibility labels for active follow-up modes; adjusts disable gating. |
| apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatComposer+Capabilities.swift | Shows “tool changes apply…” message only when a follow-up is active. |
| apps/ios/UITests/OpenClawSnapshotUITests.swift | Adds UI snapshot proof for “active response composer morphs to follow-up” behavior. |
| apps/ios/Tests/IOSGatewayChatTransportTests.swift | Adds coverage for capability detection and structured context in local fixture history. |
| apps/ios/Sources/Chat/IOSGatewayChatTransport+ComposerCapabilities.swift | Loads structured-send availability and includes it in capability catalog. |
| apps/ios/Sources/Chat/IOSGatewayChatTransport.swift | Wires route leases and outbox routing to context-based send API with capability gating. |
| apps/ios/Sources/Chat/AppleReviewDemoChatTransport.swift | Extends fixture transports to accept/send structured send context and record it in history. |
| apps/.i18n/native-source.json | Updates native i18n source index for moved/added localized strings. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| private func rejectUnsupportedStructuredCommand( | ||
| _ command: OpenClawChatOutboxCommand, | ||
| outbox: any OpenClawChatCommandOutbox) async -> OutboxFlushDisposition | ||
| { | ||
| let reason = OpenClawChatSQLiteTranscriptCache.outboxClientUpgradeRequiredError | ||
| let update = await outbox.markCommandFailedIfPresent( | ||
| id: command.id, |
| case let .failed(reason): | ||
| reason != OpenClawChatSQLiteTranscriptCache.outboxChangedSessionError && | ||
| reason != OpenClawChatSQLiteTranscriptCache.outboxClientUpgradeRequiredError |
| guard lastError != Self.outboxChangedSessionError, | ||
| lastError != Self.outboxClientUpgradeRequiredError | ||
| else { return .nonRetryable(reason: lastError) } |
794ddb9 to
69b8f11
Compare
|
Codex review: needs real behavior proof before merge. Reviewed September 1, 2026, 2:57 PM ET / 18:57 UTC. ClawSweeper reviewWhat this changesThe PR persists structured iOS follow-up context in the local outbox and replays it through Gateway admission after reconnect or app relaunch. Warning SQLite table change This PR modifies persisted SQLite tables in Merge readiness⛔ Blocked until stronger real behavior proof is added - 6 items remain Keep open: the source-level session and authority fences are coherent, but exact-head evidence does not demonstrate the PR’s central reconnect/cold-launch delivery behavior or stale-session rejection in a real native flow. Priority: P2 Review scores
Verification
How this fits togetherThe iOS composer places unavailable follow-ups in a local SQLite outbox, then a leased Gateway route validates the saved context before sending. Gateway admission must reject work tied to a replaced session before it can reach an active run. flowchart LR
A[iOS composer] --> B[Local outbox]
B --> C[Reconnect or relaunch]
C --> D[Leased Gateway route]
D --> E[Session and settings fence]
E -->|valid| F[Gateway admission]
F --> G[Follow-up delivery]
E -->|stale| H[Visible parked message]
Before merge
Findings
Agent review detailsSecurityNeeds attention: No direct security bypass was found, but the persisted authority context needs real final-effect proof before a security-boundary change is cleared. PR surfaceSource +22, Tests +56, Other +2311. Total +2389 across 44 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the existing native and Gateway fences, then attach exact-head evidence for cold-launch/reconnect delivery and replaced-session parking before merge. Do we have a high-confidence way to reproduce the issue? No: source and focused tests establish the owner boundary, but the supplied images only show an active foreground follow-up and not queued recovery or stale-session rejection. Is this the best way to solve the issue? Unclear: the owner-boundary implementation is consistent with the native sibling and Gateway contract, but its central persistent recovery behavior lacks exact-head real-flow proof. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f512082aa343. LabelsLabel changes:
Label justifications:
EvidenceSecurity concerns:
Acceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (21 earlier review cycles; latest 8 shown)
|
69b8f11 to
1e55770
Compare
1e55770 to
0c3ea68
Compare
0c3ea68 to
3bfa44d
Compare
This reverts commit da86266.
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Summary
This makes iOS Steer, Queue, and Interrupt follow-ups durable across reconnect and cold launch. The exact structured intent the user authorized is retained with the queued command; if its session, route, active leaf, settings, or Gateway capability no longer matches, the app parks it visibly instead of silently sending something different.
Fresh behavior proof
This is new exact-head evidence for the behavior owned by this PR—not reused composer-styling footage.
▶ Watch the fresh 20-second active-response follow-up capture · Immutable final-head proof bundle
What changes
ChatSendContextwith each queued iOS command: delivery mode, session/route identity, active-leaf expectation, reply target, and admitted settings.Persistence and compatibility
client-state.sqliteoutbox/transcript store.Exact-head validation
Stop → compose follow-up → send → Stop remains active).ChatTranscriptCacheStoreTests: 62/62 passed.Review notes
+1470/-413(net+1057); tests+1426/-116; generated i18n+13/-4.quinaryLabelColor→quinaryLabel); hosted CI uses Xcode 26.6. Stack-owned Swift and iOS validation pass.