Repository navigation
perf(mobile): coalesce duplicate concurrent home-screen requests - #9888
Conversation
📝 WalkthroughWalkthroughAdds 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
2e00e2e to
5d2a6c8
Compare
Co-authored-by: Orca <[email protected]>
…ght read Single-flight returned the in-flight promise to any trigger that arrived mid-read, so a distinct refresh requested while a slow read was on the wire was silently answered by the older response and never re-read the latest state (UI could stay one refresh cycle stale). Coalesce mid-flight triggers into exactly one trailing follow-up (latest params win) whose fresh result is delivered to those callers. Co-authored-by: Orca <[email protected]>
5d2a6c8 to
233380c
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
mobile/src/transport/request-single-flight.test.ts (1)
27-126: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover the remaining single-flight state transitions.
Add cases proving latest params reach the trailing request, a trigger during that trailing request queues exactly one more read, and synchronous
sendRequestthrows reject cleanly. These are core advertised behaviors but are not asserted here.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 6444d34f-5add-4452-b100-ea6b61225f3f
📒 Files selected for processing (3)
mobile/app/index.tsxmobile/src/transport/request-single-flight.test.tsmobile/src/transport/request-single-flight.ts
…blyai#9888) * perf(mobile): coalesce overlapping home requests Co-authored-by: Orca <[email protected]> * fix(mobile): queue a trailing follow-up for triggers during an in-flight read Single-flight returned the in-flight promise to any trigger that arrived mid-read, so a distinct refresh requested while a slow read was on the wire was silently answered by the older response and never re-read the latest state (UI could stay one refresh cycle stale). Coalesce mid-flight triggers into exactly one trailing follow-up (latest params win) whose fresh result is delivered to those callers. Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Orca <[email protected]>
What
On the mobile home screen (
mobile/app/index.tsx), the focus effect and the connected-state wiring independently launch overlapping one-shot requests —stats.summary,worktree.ps,accounts.list,settings.get,preflight.check,linear.status— so a cold connect + focus could fire the same batch twice, including the heavyworktree.ps.Fix: route those one-shots through a new
sendSingleFlightRequest(client, hostId, requestKind, params?)helper that coalesces concurrent identical requests into one shared promise (keyed by client identity + host + request kind), evicting the entry when it settles. Triggers, reconciliation, subscriptions, and error handling are unchanged — only genuine concurrent duplicates are collapsed.ELI5
When you opened the app's home screen while it was connecting, it sometimes asked the computer the same few questions twice at once. Now duplicate simultaneous questions share a single answer.
Proof of zero regression
sendRequestthrow becomes a rejected promise. Different clients/hosts/kinds never share.mobile/app/h/[hostId]/index.tsxhas zero diff (kept separate from perf(mobile): gate host polling on foreground/background #9857).request-single-flight.test.ts(concurrent sharing, eviction after success, shared-failure propagation + retry, client/host/kind isolation), full mobile suite green,typecheck/oxlint(within max-lines) /oxfmt --checkclean.Proof of perf improvement
Removes duplicate concurrent one-shots on cold-connect/focus — most importantly a second
worktree.ps(a full multi-repo process scan) and a secondaccounts.list/stats.summary— cutting redundant host CPU + relay/cellular bytes + a radio burst, larger over SSH/relay or with many worktrees.Made with Orca 🐋