Repository navigation
perf(mobile): open a session with parallel startup RPCs and a pre-warmed terminal engine - #19260
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe change centralizes host status probing and capability extraction. Host routes now mount under a pending compatibility cover and unmount when blocked. Session reads start in parallel, while worktree activation waits for protocol verification. Terminal engines now prewarm during loading and pending states, measure the real frame once, and reserve tab-bar space when required. Tests cover status retries, startup ordering, route gating, prewarm geometry, and viewport refitting. Merge Risk: ⚪ Minimal · up to Mobile session startup now parallelizes initial reads, gates activation on compatibility, and prewarms the terminal engine. The covered startup, gating, and viewport behaviors leave no concrete current-head merge-blocking risk. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the motivation, implementation, risks, and verification, but it omits most required template sections, including ELI5, What Changed, Linked Issue with an issue number, Visual Proof or N/A, Testing checkboxes, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist. Resolution Complete the required template sections. Add an ELI5 summary, move or summarize the implementation under What Changed, provide a Linked Issue in the form
✨ Finishing Touches 💡 1📝 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 |
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 74184455-4012-47fe-a305-145d8e79ab5a
📥 Commits
Reviewing files that changed from the base of the PR and between c3a7008 and 05269d9a94b5a9984eacd1ac4ef9c0e46344febf.
📒 Files selected for processing (22)
config/scripts/check-changed-code-quality.mjsmobile/src/components/HostProtocolGate.test.tsmobile/src/components/HostProtocolGate.tsxmobile/src/components/codex-reset-credit-capability.test.tsmobile/src/components/codex-reset-credit-capability.tsmobile/src/session/MobileSessionActiveContent.tsxmobile/src/session/TerminalEnginePrewarm.test.tsmobile/src/session/TerminalEnginePrewarm.tsxmobile/src/session/mobile-session-frame-styles.tsmobile/src/session/mobile-session-route-parity.test.tsmobile/src/session/mobile-session-startup-parallelism.test.tsmobile/src/session/mobile-session-startup-source.test.tsmobile/src/session/terminal-prewarm-frame-geometry.test.tsmobile/src/session/terminal-prewarm-refit-debt.test.tsmobile/src/session/use-mobile-session-foundation.tsmobile/src/session/use-mobile-session-startup.tsmobile/src/session/use-mobile-session-tab-reconciliation.tsmobile/src/session/use-mobile-session-terminal-subscription-foundation.tsmobile/src/transport/host-status-gates.tsmobile/src/transport/runtime-status-probe.test.tsmobile/src/transport/runtime-status-probe.tsmobile/src/worktree/home-host-worktree-fetch.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.
There was a problem hiding this comment.
ℹ️ No critical issues — a couple of points worth confirming before merge.
Reviewed changes — parallel session-startup RPCs, a shared single status.get, and a pre-warmed terminal engine with tab-bar geometry pinned by a suite of real-hook tests.
- Routes mount under the pending overlay —
HostProtocolGatestops holding children back, sosession.tabs.listandterminal.listfly alongsidestatus.get; a blocked verdict unmounts them. - Single shared
status.get—host-status-gatesmoves tostartRuntimeStatusProbe(fail-open on first miss, retry underneath); tab reconciliation reads capabilities from the gate instead of re-probing. - Startup writes gated on the verdict —
worktree.activatemoves to its own effect keyed onprotocolVerified. - Terminal engine pre-warm — an inert
TerminalWebViewboots during loading, reserves the tab-bar band, and latches the first pane's viewport measurement. - Geometry + parity tests — frame-height, refit-debt, and route-parity assertions pin the tab-bar height and the zero-refit claim.
ℹ️ Pre-warm boots a terminal engine for every session, including terminal-free ones
The prewarm is mounted unconditionally in the showLoadingState branch, which is !terminalsLoaded && visibleTabs.length === 0 — true for every cold open before terminal.list/session.tabs.list return, including sessions that resolve to a browser, markdown, or file tab with no terminal. The comment in TerminalEnginePrewarm ("a session still resolving its tabs already knows it is heading for a terminal") is not accurate for that branch: at that point the route does not know whether a terminal exists. The cost is bounded (the prewarm unmounts once terminals load), but it means an extra WebView + xterm bundle load and its memory for every non-terminal session. Worth confirming that is an accepted tradeoff.
ℹ️ Nitpicks
- The prewarm's bare
TerminalWebViewgets notextScaleorterminalTheme, someasureFitDimensionsruns at the default text scale; users with a persisted zoom still pay theterminal.updateViewportrefit the prewarm is meant to avoid (the frame-height refit corrects it, so it is a perf gap, not a correctness bug). The refit-debt test only drivestextScale: 1. startRuntimeCapabilityProbeis now a thin wrapper overstartRuntimeStatusProbe, so itsok:falsehandling silently changed from "retry" to "settle and stop". Its only remaining caller,useCodexResetCreditCapability, is not exercised against anok:falseresponse through the wrapper (the new test coversstartRuntimeStatusProbewith anonUnavailablehandler instead).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
573d502 to
a7b9a5f
Compare
|
@coderabbitai review |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the delta since the prior pullfrog review: a compatVerified gate, a corrected pre-warm handoff, and tab-bar/reconnect geometry alignment.
- Added
compatVerifiedso fail-open is not a passing verdict —host-status-gatesnow setscompatVerifiedonly whenonStatusevaluated a real reply;use-mobile-session-foundationcomputesprotocolVerified = !statusPending && compatVerified && compatVerdict.kind === 'ok'. This resolves both prior CodeRabbit findings and the fail-open flash: a transientstatus.getmiss now keeps capabilities atnull(checking) instead offalse. - Made the pre-warm open the engine before handing it over —
TerminalEnginePrewarmnow callsinit+awaitReadyonce the pane is laid out and web-ready, so the one-shotmeasureFitDimensionsno longer answersnull; it also acceptstextScaleand both call sites pass the saved value, resolving the default-text-size nitpick. - Aligned the tab-bar reservation and added a reconnect branch —
MobileSessionActiveContentreadstabStripRows(the header's own list) instead ofvisibleTabs, and renders a reconnect-with-cache label instead of the pre-warm so cached scrollback is never replayed into a fresh WebView.
The new tests are real regression tests — the gate tests fail if fail-open claims verification, and the pre-warm tests fail against the pre-init code and against a default text size.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: ea2d7a32-7f3e-4bbd-92c2-a54ce93638bd
📥 Commits
Reviewing files that changed from the base of the PR and between 05269d9a94b5a9984eacd1ac4ef9c0e46344febf and a7b9a5f.
📒 Files selected for processing (9)
mobile/src/components/HostProtocolGate.test.tsmobile/src/session/MobileSessionActiveContent.tsxmobile/src/session/TerminalEnginePrewarm.test.tsmobile/src/session/TerminalEnginePrewarm.tsxmobile/src/session/mobile-session-route-parity.test.tsmobile/src/session/mobile-session-startup-source.test.tsmobile/src/session/terminal-prewarm-frame-geometry.test.tsmobile/src/session/use-mobile-session-foundation.tsmobile/src/transport/host-status-gates.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Rate Limit Exceeded
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — a rebase onto main (which reverted #19258's cached-reconnect strip via #19265) required dropping the reconnect branch and realigning the tab-bar reservation from tabStripRows back to visibleTabs.
- Dropped the
reconnectViewState/tabStripRowsplumbing fromMobileSessionActiveContent— the reconnect-with-cache branch and thetabStripRows-based reservation are gone; the content readsvisibleTabsagain, matching the header's ownvisibleTabs.length > 0mount condition. - Re-aligned the frame-geometry test — the "mounts the tab bar only once a tab is visible" assertion and the reservation complement now pin
visibleTabson both the header and the content, so the two cannot drift. - Re-derived the route-parity hashes/counts — the extraction-parity snapshots were recomputed after the branch removal.
The compatVerified gate, the pre-warm init/awaitReady + textScale handoff, and the shared single status.get probe are unchanged from the prior review. Header (visibleTabs.length > 0) and content (visibleTabs.length > 0 ? 0 : MOBILE_SESSION_TAB_BAR_HEIGHT) are consistent, so the reservation remains correct against the rebased base. The five touched test files pass (45 tests).
…med terminal engine Startup RPCs now fan out in parallel and the xterm engine pre-warms inside the real terminal frame while they are in flight, so the first pane inherits a warm WebView and an already-measured viewport instead of paying a round trip for it. The pre-warm opens its engine before measuring: web-ready only reports that the bundle loaded, and the WebView answers a measure with null until a terminal exists. It also pre-warms at the user's saved text size, because cell size is what the frame height gets divided by. Host writes such as worktree.activate wait for an evaluated status.get reply. Navigation still fails open when a host cannot answer one, but that fallback no longer reads as a passing compatibility verdict.
a7b9a5f to
f799992
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the delta since the prior pullfrog review: the pre-warm defers its frame-height read until the engine is ready, and a regression test pins the resize-during-startup case.
- Deferred the height read to handoff —
TerminalEnginePrewarmnow readsframeHeightRef.currentinside theawaitReadycontinuation instead of snapshotting it beforeengine.init, so a rotation or split-screen resize that lands while the engine is coming up is the height the one-shot measurement reports. - Added a failing-first resize regression test —
TerminalEnginePrewarm.test.tsdriveslayout → web-ready → resize → engine-readyand asserts the measured height is the post-resize frame, which fails against the pre-change capture-then-init ordering.
The fix is correct: handleLayout keeps writing frameHeightRef.current on every non-zero layout even after the measuredRef latch fires, so the deferred read always sees the pane's final frame, and the unmount guard (engineRef.current !== engine) still drops stale handoffs.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
The pattern it covers (a variable number of timers cleared through one cleanup) predates #19260 and is unchanged by the revert; dropping the entry only re-exposed a pre-existing finding to the changed-code gate.
…aller, verified re-land (#19348) * Revert "feat(mobile): time relay dial stages so diagnostics say where a slow connect went (#19245)" This reverts commit 83b1558. * Revert "perf(mobile): race the direct and relay dials from t=0 on every reconnect (#19308)" This reverts commit ceafdca. * Revert "feat(mobile): draw the last known tab strip while a session reconnects (mobile pass) (#19281)" This reverts commit 643571d. * Revert "perf(mobile): open a session with parallel startup RPCs and a pre-warmed terminal engine (#19260)" This reverts commit c374132. * Revert "perf(mobile): cut the relay reconnect critical path and admit dead sockets faster (mobile pass) (#19280)" This reverts commit e628090. * chore: keep the react-doctor suppression for the startup timers The pattern it covers (a variable number of timers cleared through one cleanup) predates #19260 and is unchanged by the revert; dropping the entry only re-exposed a pre-existing finding to the changed-code gate.

Why
After the relay session connects, the phone serialized a
status.getprotocol gate, thensession.tabs.listandterminal.list, plus a secondstatus.getfrom a capability probe, and only then booted the terminal engine. Each round trip is tens of milliseconds in-region and one to three seconds on a far cell, so that serialization was most of the remaining time to a visible terminal.What
status.get. A blocked verdict still replaces the subtree. Startup writes (worktree.activate) sit in their own effect gated on!statusPending && compatVerified && compatVerdict.kind === 'ok', so a blocked desktop is never mutated. The third term is a tightening over main: a host that cannot answerstatus.getstill fails open for navigation, but that fallback verdict no longer counts as a passing one, so it no longer receives the activation. A transient failure is unaffected, because the probe retries and a later reply flips the flag. Only a host that definitively rejectsstatus.getloses the activation, and such a host already reports no capabilities, so the route was running in its most conservative mode regardless.session.tabs.listandterminal.listare issued together with per-call error isolation; a session change mid-flight discards both results.status.getis gone: tab reconciliation reads capabilities from the gate. The probe reports the whole status and retries only an unanswered request; an error reply settles. Cold-openstatus.getcount 2 → 1, serialized round trips before first paint 3 → 1.web-readyonly reports that the xterm bundle loaded, and the WebView answersmeasurewith null until a terminal exists, so it callsinitand awaitsawaitReadyfirst. It also mounts at the user's saved text size, because cell size is what the frame height gets divided by. The tab bar's rendered height is unchanged from main (the explicit height added earlier was removed after a border-box review). A test drives the real refit hook on a single-terminal cold open and asserts zeroterminal.updateViewportand zero resubscribes; measured against the unreserved box it sends exactly one.effect-needs-cleanupon the startup file) is listed in the changed-code gate's suppression map; the map keys by file, and the effect's timers are all cleaned up.Verification
mobile:tsc --noEmit,vitest run(520 files, 4238 tests),oxlint,oxfmt --check;check:code-quality:changedandcheck:react-doctor:changedclean. Re-run after rebase on main.initordering, and the fail-open-reads-as-verified seam acrosshost-status-gates.tsand the foundation hook).Not for merge until the owner gives the go.