Skip to content

fix(mobile): prevent duplicate queued sends after chat remount - #39809

Merged
nwparker merged 1 commit into
mainfrom
nwparker/REL-scan
Nov 8, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/REL-scan

Conversation

@nwparker

@nwparker nwparker commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Reopening a mobile chat while an offline-queued message was still sending could deliver the same instruction twice. The shared chat queue now admits one pending send across screen instances.

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​35 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​35
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​15 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​8

What Changed

  • Claim a queued message synchronously in the shared queue before dispatch; refuse missing entries or a queue with a send already in progress.
  • Skip a sending head during automatic drain, and apply the shared claim to manual Send Now too.
  • Add one regression covering remount, rejected duplicate/manual dispatch, and successful delivery of the next queued message after settlement.

Why

The screen-local draining flag resets on remount while the queue survives. Owning the claim in that shared queue preserves ordering and prevents a second structured send from getting a fresh message ID.

Linked Issue

Release-scan P1 finding F01, introduced by #39423.

Visual Proof

N/A — internal queue ownership and delivery fix; no visual or interaction design changes. The hook regression exercises the remount behavior.

Testing

  • Regression failed before the fix: the first message was delivered twice after remount. It passes with the fix and delivers the next message after the pending send settles.
  • ORCA_BACKGROUND_LAUNCH=1 pnpm --dir mobile test src/session/native-chat/composer/use-mobile-native-chat-offline-sends.test.ts src/session/native-chat/composer/mobile-native-chat-draft-persistence.test.ts src/session/use-mobile-structured-native-chat-send-bridge.test.ts --maxWorkers=2 — 22 tests passed across the focused runs.
  • Production queue + structured-send bridge reproduction — accepted-send control and pending-send remount case passed.
  • Mobile application and test typechecks, lint, formatting, changed-code quality, and flaky-test ratchet passed.
  • After rebasing onto current main: ORCA_BACKGROUND_LAUNCH=1 pnpm check:changed --maxWorkers=2 — all 15 selected checks passed.
  • Manually tested on a device (not performed)
  • Automated regression added; failed before the fix with hardcoded expected delivery order.

Risk

Level: Low. A bad admission guard could leave queued messages waiting. The regression verifies settlement allows the next message through; existing failure, handback, and Resume tests pass. The change is platform-independent and keeps existing chat scope keys for local, remote, and folder workspaces. It changes no stored schema or wire contract. A plain revert backs it out.

Review

Self-reviewed the shared claim, remount lifetime, manual dispatch, and queue settlement paths. Native-device and rendered navigation testing were not performed.

Agent skill upstream boundary

  • Not applicable; no upstream skill-installer content copied.

Checklist

  • Small and focused: three files.
  • User-facing trigger, fix, risk, and validation described.
  • Cross-platform, remote, mobile, folder-workspace, and backward-compatibility impact considered.
  • Applicable local checks passed; full PR workflow must pass before merge.

@coderabbitai

coderabbitai Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The offline send start function now returns a boolean and refuses to start when the requested ID is absent or another send is already in progress. Dispatch marks a send as draining only after a successful start. Automatic dispatch skips a queue head that is paused or already sending. A new test covers repeated dispatch attempts while a send remains pending across a hook remount.

Merge Risk: Minimal · up to d403d

No actionable current-head issue is established. The reported native-device testing remains outstanding, but the change is mergeable after normal checks.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title "fix(mobile): prevent duplicate queued sends after chat remount" matches the main change. The PR claims queued offline messages in the shared queue before dispatch, so a remounted mobile cha…
Description check Passed The description follows the repository template and covers the required sections. It has an ELI5 section, a What Changed section, a Why section, a Linked Issue reference (Release-scan P1 finding F01, …
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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.
Full details: Title check

Explanation

The title "fix(mobile): prevent duplicate queued sends after chat remount" matches the main change. The PR claims queued offline messages in the shared queue before dispatch, so a remounted mobile chat no longer delivers the same queued message twice. The title is specific, concise, and uses a conventional-commit style. It does not list files or use vague terms.

Full details: Description check

Explanation

The description follows the repository template and covers the required sections. It has an ELI5 section, a What Changed section, a Why section, a Linked Issue reference (Release-scan P1 finding F01, introduced by #39423), Visual Proof marked N/A with a reason, a Testing section with commands and results, a Risk section with a level (Low) and a revert path, a Review section, the agent skill boundary checkbox, and a completed checklist. The Linked Issue entry does not give a GitHub issue number (it cites a release-scan finding and a PR number instead), and the 'Fixes #' line from the template was replaced. The AI Disclosure section is missing. The 'Manually tested on a device' box is unchecked and noted as not performed. The Testing section also reports a failing-before-fix run only in prose, and the 'hardcoded expected delivery order' note is unclear.

Resolution

Optional improvements: add a Linked Issue with a real GitHub issue number (the template asks for 'Fixes #' with an actual issue, and outside contributors need one), fill in or mark N/A the AI Disclosure section, and clarify the note about the 'hardcoded expected delivery order' in the Testing section.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 3 files.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dd86833f-6f76-4e18-9ade-48ed29c0861e
Commits

Reviewing files that changed from the base of the PR and between 0da741a and d403d75.

Files selected for processing: 3

  • mobile/src/session/native-chat/composer/mobile-native-chat-offline-sends.ts
  • mobile/src/session/native-chat/composer/use-mobile-native-chat-offline-sends.test.ts
  • mobile/src/session/native-chat/composer/use-mobile-native-chat-offline-sends.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@nwparker
nwparker merged commit fca1d7b into main Nov 8, 2026
46 of 51 checks passed
audichuang pushed a commit to audichuang/orca that referenced this pull request Nov 8, 2026
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