Skip to content

fix(mobile): report interrupted native chat sends as delivery-unknown, not failed - #10021

Merged
AmethystLiang merged 3 commits into
mainfrom
fix-mobile-native-chat-cutover
Jul 23, 2026
Merged

AmethystLiang merged 3 commits into
mainfrom
fix-mobile-native-chat-cutover

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A mobile native-chat terminal.send interrupted mid-flight showed a definite "Message not sent" even when the desktop may have already delivered the text — inviting a manual resend and a double-delivered message. #9792 fixed this for physical ack-loss on direct sockets; this PR covers the three remaining interruption paths:

  • Logical relay↔direct cutover — migrateTo rejects in-flight requests with LogicalClientCutoverError; the chat send path now maps it to 'unknown' (held unconfirmed + verified via transcript echo) instead of 'rejected'. Never retried: terminal.send is non-idempotent, and a cutover cannot tell whether the frame was written.
  • Suspend/close of a half-open session — the stable logical client blanket-rejected in-flight pendings with plain 'Client suspended'/'Client closed', preempting the physical layer's accurate delivery-unknown marking (the marked rejection landed second on a settled promise and was dropped). suspendActiveSession fires exactly on network handoff with a half-open relay. The logical client now lets the physical close() settle in-flight requests, so post-write failures surface marked and pre-write failures stay a truthful definite 'rejected'. Pre-send guards and the migrateTo cutover-error contract (relied on by idempotent retry callers like worktree-create-retry) are unchanged.
  • Relay path never marked ambiguity at all — mobile-relay-rpc-session timeout/close/link-failure rejections were unmarked, so even plain ack-loss over relay (the original fix(mobile): stop reporting delivered chat messages as "Message not sent" #9792 scenario) read as a definite failure there. Post-write rejections are now marked; sound because a pending entry only exists after its frame reached the authenticated E2EE link.

User-visible copy: the main chat send holds 'unknown' as "Delivery unconfirmed — check chat before retrying" (existing behavior, now reachable on these paths). Permission responses, ask answers, and cancel-Escape now say "Response/Answer/Cancel unconfirmed — check chat before retrying" instead of a definite "not sent" on ambiguous outcomes; they still return not-accepted (card stays visible) and never retry.

Also consolidates a private copy of isLogicalClientCutoverError in worktree-create-retry.ts into the shared export.

Screenshots

No visual layout change — only error-toast copy on ambiguous outcomes (strings above).

Testing

  • pnpm lint (mobile)
  • pnpm typecheck (mobile)
  • pnpm test (mobile: 312 files, 2267 passed / 2 skipped)
  • pnpm build — not run; change is mobile-only (Expo app), no desktop build impact
  • Added regression tests: logical suspend preserves the physical delivery-unknown mark while close keeps pre-write failures definite; relay session marks timeout/close/link-failure rejections; cutover (instanceof + cross-bundle message match) → 'unknown'; permission/answer surfaces report ambiguity honestly

AI Review Report

Adversarial review of the original one-line cutover fix traced the full rejection flow through stable-logical-rpc-client, rpc-client, and mobile-relay-rpc-session. Main risks checked: double-send (none — no caller retries on 'unknown'/false; verified all four send surfaces), false-definite failures (found on suspend/close and the whole relay path — fixed here), false-ambiguous regressions (pre-write failures verified to stay unmarked: connect-waiter and pre-send rejections still map to 'rejected'), and the migrateTo retry contract for idempotent callers (unchanged; covered by existing tests). Also verified the rejectPending mark cannot leak through getFailure() consumers (guarded to only mark when requests were actually pending, and those consumers classify by message/instanceof).

Cross-platform: mobile-only (React Native/Expo) — no Electron, desktop shortcuts, path handling, or shell behavior touched; no platform-conditional code paths involved. Runs identically on iOS/Android/web targets since all changes are transport/state logic.

Security Audit

No new input handling, command execution, path handling, auth, or dependency surface. The delivery-unknown mark is a module-private WeakSet membership on existing error objects — no new error-message parsing beyond the pre-existing cutover message match, no data added to errors, nothing logged or transmitted. E2EE relay framing and credential flows untouched. No follow-up needed.

Notes

Accepted precision limit: a cutover can reject a request whose frame never left the device (still waiting for connect); that now reads "unconfirmed" instead of a clean "not sent". Safe direction — costs one check-chat, can never cause a double-send.

Made with Orca 🐋

…, not failed

A terminal.send interrupted mid-flight showed a definite "Message not sent"
even when the desktop may have already delivered the text. Three paths were
misclassified as definite failures:

- Logical relay/direct cutover: migrateTo rejects in-flight requests with
  LogicalClientCutoverError, which mapped to 'rejected'. Now maps to 'unknown'
  (held unconfirmed + transcript-echo verification; never retried since
  terminal.send is non-idempotent).
- Suspend/close of a half-open session: the stable logical client blanket-
  rejected in-flight pendings with plain 'Client suspended'/'Client closed',
  preempting the physical layer's delivery-unknown marking. It now lets the
  physical close settle them, so post-write failures stay marked and pre-write
  failures stay definite.
- Relay path: mobile-relay-rpc-session never marked delivery ambiguity at all
  (timeout, close, link failure). Post-write rejections are now marked;
  pending entries only exist after the frame reached the authenticated link.

Permission, ask-answer, and cancel-Escape surfaces now show "unconfirmed —
check chat before retrying" instead of a definite "not sent" on ambiguous
outcomes (still not-accepted, never retried). Also consolidates a private
copy of isLogicalClientCutoverError in worktree-create-retry.

Co-authored-by: Orca <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 08909185-1478-4026-acd5-c567df25b218

📥 Commits

Reviewing files that changed from the base of the PR and between cfd6530 and 23129eb.

📒 Files selected for processing (15)
  • mobile/src/session/mobile-native-chat-permission-send.test.ts
  • mobile/src/session/mobile-native-chat-permission-send.ts
  • mobile/src/session/mobile-native-chat-send.test.ts
  • mobile/src/session/mobile-native-chat-send.ts
  • mobile/src/session/use-mobile-native-chat-answer-send.test.ts
  • mobile/src/session/use-mobile-native-chat-answer-send.ts
  • mobile/src/session/use-mobile-native-chat-controller.ts
  • mobile/src/tasks/worktree-create-retry.ts
  • mobile/src/transport/mobile-relay-rpc-session.test.ts
  • mobile/src/transport/mobile-relay-rpc-session.ts
  • mobile/src/transport/stable-logical-rpc-client.test.ts
  • mobile/src/transport/stable-logical-rpc-client.ts
  • resources/skills/current-manifest.json
  • resources/skills/release-mapping.json
  • resources/skills/snapshot-registry.json
🚧 Files skipped from review as they are similar to previous changes (10)
  • mobile/src/tasks/worktree-create-retry.ts
  • mobile/src/transport/stable-logical-rpc-client.test.ts
  • mobile/src/session/use-mobile-native-chat-answer-send.ts
  • mobile/src/session/use-mobile-native-chat-answer-send.test.ts
  • mobile/src/transport/stable-logical-rpc-client.ts
  • mobile/src/session/mobile-native-chat-permission-send.ts
  • mobile/src/session/mobile-native-chat-permission-send.test.ts
  • mobile/src/transport/mobile-relay-rpc-session.test.ts
  • mobile/src/transport/mobile-relay-rpc-session.ts
  • mobile/src/session/mobile-native-chat-send.ts

📝 Walkthrough

Walkthrough

Mobile RPC transport now preserves delivery-unknown classification for timeouts, closures, suspensions, and pending-request failures. Native chat sends classify outcomes as accepted, rejected, or unknown, and permission, answer, and cancel flows report distinct errors and avoid stale writes. Tests cover these paths and updated payloads. Skill manifests, release mappings, and snapshot registries also record new revisions and application releases.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: interrupted native chat sends are now reported as delivery-unknown instead of failed.
Description check ✅ Passed The description follows the template and covers summary, screenshots, testing, AI review, security, and notes, with only minor template-specific detail gaps.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch fix-mobile-native-chat-cutover

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
resources/skills/current-manifest.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

resources/skills/release-mapping.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

resources/skills/snapshot-registry.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
mobile/src/session/mobile-native-chat-permission-send.ts (1)

39-52: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract a shared outcome→message helper. Both sites implement the identical unknown→unconfirmed-message / rejected→not-sent-message / return-only-if-accepted branching, differing only in the action label; one shared helper would keep this consistent as more chat actions adopt the outcome contract.

  • mobile/src/session/mobile-native-chat-permission-send.ts#L39-L52: replace the inline if/else if outcome branching with a shared helper, e.g. reportUnconfirmedSendOutcome(outcome, 'Response', args.onSendError).
  • mobile/src/session/use-mobile-native-chat-controller.ts#L175-L191: replace the inline if/else if outcome branching in handleNativeChatCancelAsk with the same shared helper, e.g. reportUnconfirmedSendOutcome(outcome, 'Cancel', onSendError).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1f93899e-6cae-4e5b-81d8-758236c423da

📥 Commits

Reviewing files that changed from the base of the PR and between adc0203 and cfd6530.

📒 Files selected for processing (12)
  • mobile/src/session/mobile-native-chat-permission-send.test.ts
  • mobile/src/session/mobile-native-chat-permission-send.ts
  • mobile/src/session/mobile-native-chat-send.test.ts
  • mobile/src/session/mobile-native-chat-send.ts
  • mobile/src/session/use-mobile-native-chat-answer-send.test.ts
  • mobile/src/session/use-mobile-native-chat-answer-send.ts
  • mobile/src/session/use-mobile-native-chat-controller.ts
  • mobile/src/tasks/worktree-create-retry.ts
  • mobile/src/transport/mobile-relay-rpc-session.test.ts
  • mobile/src/transport/mobile-relay-rpc-session.ts
  • mobile/src/transport/stable-logical-rpc-client.test.ts
  • mobile/src/transport/stable-logical-rpc-client.ts

@AmethystLiang
AmethystLiang force-pushed the fix-mobile-native-chat-cutover branch from cfd6530 to 0c79c9a Compare July 23, 2026 02:21
@AmethystLiang
AmethystLiang merged commit 3708c4f into main Jul 23, 2026
15 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…, not failed (stablyai#10021)

* fix(mobile): report interrupted native chat sends as delivery-unknown, not failed

A terminal.send interrupted mid-flight showed a definite "Message not sent"
even when the desktop may have already delivered the text. Three paths were
misclassified as definite failures:

- Logical relay/direct cutover: migrateTo rejects in-flight requests with
  LogicalClientCutoverError, which mapped to 'rejected'. Now maps to 'unknown'
  (held unconfirmed + transcript-echo verification; never retried since
  terminal.send is non-idempotent).
- Suspend/close of a half-open session: the stable logical client blanket-
  rejected in-flight pendings with plain 'Client suspended'/'Client closed',
  preempting the physical layer's delivery-unknown marking. It now lets the
  physical close settle them, so post-write failures stay marked and pre-write
  failures stay definite.
- Relay path: mobile-relay-rpc-session never marked delivery ambiguity at all
  (timeout, close, link failure). Post-write rejections are now marked;
  pending entries only exist after the frame reached the authenticated link.

Permission, ask-answer, and cancel-Escape surfaces now show "unconfirmed —
check chat before retrying" instead of a definite "not sent" on ambiguous
outcomes (still not-accepted, never retried). Also consolidates a private
copy of isLogicalClientCutoverError in worktree-create-retry.

Co-authored-by: Orca <[email protected]>

* chore(skills): regenerate skill-bundle manifest artifacts

---------

Co-authored-by: Orca <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant