Skip to content

fix(ios): preserve first chat send during agent discovery - #159404

Merged
joshavant merged 2 commits into
mainfrom
fix/ios-chat-send-hydration
Sep 27, 2026
Merged

joshavant merged 2 commits into
mainfrom
fix/ios-chat-send-hydration

Conversation

@joshavant

@joshavant joshavant commented Sep 27, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes an iOS chat message remaining in the draft or disappearing when the app discovers its default agent during Send.

User Impact

An accepted message keeps its conversation and remains visible through reply completion. Switching accounts, sessions, or explicitly selected agents still invalidates the old send.

Why This Change Was Made

Reserve the draft before asynchronous work starts, and defer initial agent discovery until the accepted turn settles. The chat owner observes completion directly, so a fast send cannot leave discovery waiting for a SwiftUI redraw. The final change contains no investigation logging.

Evidence

  • Controlled native reproduction demonstrated both lost-send races on the original implementation. A separate started-acknowledgment case caught an optimistic message disappearing before saved history arrived.
  • Native regression: seven scenarios covering both timing windows, delayed history, automatic agent discovery after completion, and account/session/explicit-agent isolation. All passed in 0.480s; Xcode test command 35.125s, incremental build 53.816s. CI: all three methods passed in 0.747s (seven scenarios).
  • All 37 related existing shared chat tests passed (send, offline delivery, reply handling, and attachment ownership).
  • Scoped repository checks passed, including 419-file iOS SwiftLint; independent review found no actionable P0–P2 findings.
  • Full stock native release qualification passed at 025bdaa4d87b67a23a6ba1f0c95f40993d575198 in 670.520s: fresh-install setup/relaunch and chat round-trip/control overview. This uses the real local Gateway and native app with a synthetic provider. No store upload is part of this verification.
  • The existing CI smoke/full selector now includes the new regression. All 23 workflow tests passed (5.733s test body, 15.70s command), with no added test cases or process boots. Workflow lint and independent review passed. PR CI passed on c83463b104bb739f03839811e719d04a7799e4f6 (run36294543287), with no failed or pending checks.
  • Hosted candidate qualification run36294566820 passed fresh-install setup, then failed at input.typeText() before the first Send. Its saved proof lacks XCTest’s specific typing error. This PR’s Send repair was not reached by that failure.
  • A separate diagnostic branch based on this exact PR head added passive, sanitized focus/editor/XCTest tracing without changing waits, retries, assertions, or release behavior. Its local qualification passed in 545.881s; hosted run36297040875 passed in 29m31s. The hosted trace captured all four successful typing calls, stable keyboard focus, and preserved presentation during default-agent discovery. These successful runs do not establish the cause or repair of the earlier intermittent typing failure. No diagnostic instrumentation is included in this PR.
  • The instrumented hosted baseline also passed both release qualification scenarios; it did not reproduce the original hosted failure. The deterministic regression establishes the repaired Send races, not the cause of every earlier release failure.

Controlled native before/after

Both captures render the real chat tab with synthetic text and the same held-health/default-agent-discovery schedule. The probe enters text through the native input and invokes the composer resolver’s Send callback directly; the full release qualification above separately exercises the UI flow.

Before After
Zero sends; draft retained; no submitted message. One send; submitted message visible; composer empty.
Before: message remains in the draft After: submitted message remains visible

The model-choice hint in both captures comes from the minimal synthetic Gateway fixture. The capture probe and temporary diagnostic logging are excluded from this PR.

@clawsweeper

clawsweeper Bot commented Sep 27, 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.

@joshavant
joshavant marked this pull request as ready for review September 27, 2026 04:11
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 27, 2026
@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 27, 2026, 2:02 AM ET / 06:02 UTC (Revision 5).

ClawSweeper review

What this changes

The branch captures an iOS chat draft before asynchronous sending, defers automatic agent discovery while the accepted turn is pending, and adds native regression coverage to CI.

Merge readiness

✅ Ready for maintainer review

Current main still has the accepted-send race. The branch addresses a distinct failure left after the earlier typing fix, and the native evidence supports keeping it as the active fix.

Priority: P1
Reviewed head: c83463b104bb739f03839811e719d04a7799e4f6

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Direct native captures, focused boundary coverage, and a small owner-level repair provide strong review confidence.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): Prepared native before/after captures show the changed composer and transcript outcome under held agent discovery; the PR also reports a stock native chat round trip, and exact-head CI runs the new boundary regression. No stored-data contract changes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): Prepared native before/after captures show the changed composer and transcript outcome under held agent discovery; the PR also reports a stock native chat round trip, and exact-head CI runs the new boundary regression. No stored-data contract changes.
Evidence reviewed 8 items Current main still has the race: Current main schedules draft capture inside the asynchronous send task; it lacks the branch's synchronous reservation.
Introduced send reservation: The proposed send path captures the draft and marks submission pending before scheduling asynchronous work.
iOS ownership guard: Automatic default-agent discovery defers replacement while submission or a run is pending, subject to account, selected-agent, session, and routing checks.
Findings None None.
Security None None.

How this fits together

The iOS chat owner binds the composer to a shared chat model and a Gateway agent route. Draft text and discovered agent identity enter that handoff; sent messages and transcript rows come out of it.

flowchart LR
A[Chat composer] --> B[Shared send model]
C[Gateway agent discovery] --> D[iOS chat owner]
B --> D
D --> E{Accepted turn pending}
E -->|Yes| F[Keep turn visible]
E -->|No| G[Apply discovered route]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +2, Config +1, Other +396. Total +399 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 2 0 +2
Docs 0 0 0 0
Config 1 1 0 +1
Generated 0 0 0 0
Other 4 407 11 +396
Total 6 410 11 +399

Review metrics

Metric Value Why it matters
Production and test growth production +30 net lines; tests +368 net lines The owner-side observation addresses the timing race, while most added code exercises its send and isolation outcomes.

Technical review

Best possible solution:

An accepted send should retain its captured conversation and visible message through settlement, then adopt the discovered agent route; explicit account, session, and agent changes should still invalidate stale sends.

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

Yes. The controlled native before capture shows the message left in the composer, and current main retains the asynchronous draft-capture path that permits the race.

Is this the best way to solve the issue?

Yes. The change repairs the existing send and iOS ownership handoff, with boundary tests for the context changes that must invalidate a pending send.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5e1a2cf4ea76.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The reported race can suppress a user's first iOS chat send during agent discovery.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): Prepared native before/after captures show the changed composer and transcript outcome under held agent discovery; the PR also reports a stock native chat round trip, and exact-head CI runs the new boundary regression. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. Prepared native before/after captures show the changed composer and transcript outcome under held agent discovery; the PR also reports a stock native chat round trip, and exact-head CI runs the new boundary regression. No stored-data contract changes.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. Prepared native before/after captures show the changed composer and transcript outcome under held agent discovery; the PR also reports a stock native chat round trip, and exact-head CI runs the new boundary regression. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • joshavant: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (4 earlier review cycles)
  • reviewed 2026-09-27T04:18:04.660Z sha 025bdaa :: blocked before merge. :: none
  • reviewed 2026-09-27T04:37:50.608Z sha c83463b :: needs maintainer review before merge. :: none
  • reviewed 2026-09-27T05:07:36.462Z sha c83463b :: needs maintainer review before merge. :: none
  • reviewed 2026-09-27T05:16:18.228Z sha c83463b :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added 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. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 27, 2026
@joshavant
joshavant merged commit 8043765 into main Sep 27, 2026
163 of 164 checks passed
@joshavant
joshavant deleted the fix/ios-chat-send-hydration branch September 27, 2026 06:11
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 28, 2026
…59404)

* fix(ios): preserve first chat send during agent discovery

* test(ios): run send hydration regression in CI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: ios App: ios P1 High-priority user-facing bug, regression, or broken workflow. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M 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