Repository navigation
Conversation
… fresh miss budget, persist the relay endpoint before booking a refresh
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Status probe re-asks a refused
status.get—startRuntimeStatusProbenow treats anok:falsereply as a failed attempt worth retrying at the 15 s ceiling instead of settling permanently, soworktree.activateand every capability can upgrade after a transient host failure or a relay-surfaced error frame. - Fresh miss budget per resume probe —
RpcSessionLivenessWatchdog.probeNow(…, 'resume')zeroesmissedProbesbefore starting the urgent probe, so a second app-resume nudge in the urgent window no longer inherits the first probe's miss. - Endpoint persisted before the refresh gate lifts —
MobileRelayCredentialRefreshmovesrefreshed = truebelowawait persistResolvedRelay(…), so a failed endpoint write no longer lifts the fresh-credential gate and firesonRefreshedagainst a pre-rotation cell. confirmingbudget comment corrected —relay-dial-stage.tsnow documents that the live session publishesconnectedon stage entry and bounds the resume confirm itself at 12 s; the 35 s entry stays for stage-table totality. TherelayDialStageBudgetMssignature (keyof typeof RELAY_DIAL_STAGE_BUDGET_MS) is type-equivalent to the previousExclude<..., 'opening'>and lets the table drive the accepted param names.- Tests — failing-first tests for the probe re-ask and the per-resume miss budget; both reproduce the mutation first.
ℹ️ Credential-refresh reorder ships without a regression test
The persist-before-gate-lift change in mobile-relay-credential-refresh.ts is the one behavioral adjustment here with no covering test (the probe and watchdog fixes both got failing-first tests; MobileRelayCredentialRefresh has no test file at all). The contract it now relies on — a failed persistResolvedRelay must neither lift the gate nor fire onRefreshed — is asserted only by the inline comment. The reorder itself is trivially correct and I found no bug, so this isn't blocking; a small async-ordering test pinning that contract would harden it against a future regression.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
📝 WalkthroughWalkthroughThe changes update relay refresh completion ordering and derive relay dial budget parameter types from the budget constant. Resume probes now preserve miss counts across repeated urgent probes and re-arm after booked misses. Runtime status probes retry answered error responses after 15 seconds. Tests cover relay refresh recovery, liveness budgets, and runtime status retries. Merge Risk: 🔵 Low · up to Relay refresh now waits for endpoint persistence before completing, but its test suite does not verify that the newly resolved relay endpoint is the value persisted. This is a bounded coverage gap that should be addressed before relying on the test to prevent stale-endpoint regressions. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the problems, changes, and tests, but it does not follow the required template. It omits the ELI5, Linked Issue, Visual Proof, Review, Agent skill upstream boundary, Notes, and Checklist sections, and it does not include a required Resolution Add all required template sections. Include an ELI5 summary, a What Changed section, a
✨ 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 |
…er credential refresh ordering A resume zeroed the miss count unconditionally, so a burst of resumes or a user tapping reconnect on a dead relay socket never reached a verdict. The clean budget now comes only from the profile switch. New tests for MobileRelayCredentialRefresh pin that the gate lifts only after the endpoint persists and that a failed persist leaves a retry, not a wedge.
There was a problem hiding this comment.
Important
The "fresh miss budget per resume probe" fix is no longer in the code — the headline of this PR contradicts what it merges.
Reviewed changes
- Credential-refresh ordering now has a regression test —
mobile-relay-credential-refresh.test.tswas added covering the happy-path order plus both failure paths (a failed persist keeps the gate closed, and a later run re-enters instead of staying wedged). This addresses the prior review's open observation. - Watchdog reworked to keep the miss budget across repeated resumes — the
probeNowper-resumemissedProbes = 0reset was dropped, so a burst of resumes (AppState flaps, a user tapping reconnect on a dead socket) no longer zeroes the budget on every tap and stalls the verdict.
⚠️ The description now describes behavior the code no longer has, and #19280 goes unfixed
The second commit removed if (urgent) this.missedProbes = 0 from probeNow, leaving rpc-session-liveness-watchdog.ts a comment-only diff against main. But the title still advertises a "fresh miss budget per resume probe", the body still says probeNow(…, 'resume') "resets the miss count", and the Tests section still claims "two resume probes each tolerate one miss (fails on main)". None of that is true of the committed code — both new watchdog tests pass against main unchanged.
The consequence: back-to-back resumes (the iOS active/inactive/active pair #19280 described) once again share a single miss budget, so a live session with two cold-radio slow answers is terminated — the exact symptom this PR was opened to fix. That may be the right trade-off against the dead-socket-never-terminates regression the reset introduced, but the description must say so.
Technical details
# Reconcile the description with the reverted watchdog change
## Affected sites
- PR title — claims "fresh miss budget per resume probe"; the final code keeps the budget across repeated resumes.
- PR body "What" — says `probeNow(…, 'resume')` resets the miss count; it no longer does.
- PR body "Tests" — says "two resume probes each tolerate one miss"; the committed tests assert the opposite.
- mobile/src/transport/rpc-session-liveness-watchdog.ts:114 — `probeNow` no longer zeroes `missedProbes`; only `startProbe`'s profile switch (`profile !== this.profile`) does.
- mobile/src/transport/rpc-session-liveness-watchdog.test.ts:259 and :290 — both pass on `main`; they document existing behavior, not a regression.
## Required outcome
- Update the title and body to state that back-to-back resume probes intentionally share a miss budget, and drop the "fails on main" claim.
- Confirm whether leaving #19280's original symptom unfixed is the intended resolution.
## Open questions for the human (optional)
- Is the profile-switch reset a sufficient standalone answer for #19280, or should a "new observation" be distinguished from a "repeated tap" (e.g. a short debounce)?
ℹ️ Nitpicks
mobile-relay-credential-refresh.test.ts"lifts the gate and starts the relay race only after the endpoint is durable" asserts an event order the pre-fix code also produces —completeRefresh/onRefreshedfire infinallyafterpersistResolvedRelayregardless of whererefreshedis assigned, so only the two failure-path tests actually pin the reorder.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
… tap burst cannot starve the verdict
There was a problem hiding this comment.
Important
The delta is clean, but the PR description still contradicts the committed watchdog behavior — the item flagged last round is unaddressed and this commit makes it worse.
Reviewed changes
- Kept an in-flight urgent probe's deadline —
RpcSessionLivenessWatchdog.probeNow(…, 'resume')now returns early when a resume lands while a'resume'-profile probe is already in flight, so a tap burst or AppState flap no longer re-arms the 2 s clock and starves the death verdict. The prior commit preserved the miss budget across repeated resumes; this adds deadline preservation, closing the dead-socket-never-terminates regression. - Rewrote the repeated-resume regression test as a timed loop — a resume every 1.5 s on a black-holed socket now asserts the verdict still lands. On
maineach resume re-arms the deadline so termination never fires, making this genuinely failing-first against the un-patched watchdog. - Added a no-op refresh test —
MobileRelayCredentialRefreshnow also asserts an unforcedrunwith a fresh credential rotates nothing, pinning the needs-rotation gate the hoistedneedsRotationmock newly exposes.
⚠️ Description still does not match the committed watchdog
The title/body reconciliation requested in the prior review is still outstanding, and this commit's guard change widens the gap. The title still advertises a "fresh miss budget per resume probe"; the body's "What" still says probeNow(…, 'resume') "resets the miss count"; and "Tests" still claims "two resume probes each tolerate one miss (fails on main)". None of that describes the committed code: repeated resumes are now swallowed wholesale, and the committed test asserts a dead socket still terminates (which fails on main because main re-arms the deadline every resume, not because of a shared budget).
Technical details
# Reconcile the PR description with the final watchdog semantics
## Affected sites
- PR title — "fresh miss budget per resume probe"; the code does not grant repeated resumes a fresh budget.
- PR body "What" — `probeNow(…, 'resume')` does not reset the miss count; only `startProbe`'s profile switch does.
- PR body "Tests" — the committed test is not "two resume probes each tolerate one miss"; it is "repeated resumes on a dead socket still reach a verdict".
- mobile/src/transport/rpc-session-liveness-watchdog.ts:133 — the new `if (urgent && this.probing && this.profile === this.urgentProfile) return` guard.
## Required outcome
- Update the title and body to state that a resume landing while an urgent probe is in flight is a no-op (deadline and budget both preserved), and that the profile switch — not the resume itself — is what grants a clean budget.
- Drop or correct the "fails on main" framing to match the new test's actual mechanism.DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…ow, one re-arm per miss Keeping the deadline unconditionally gave a real resume at 3.9 s only the last 100 ms of the previous probe and killed a socket that answered at 4.1 s. Each booked miss now buys exactly one re-arm, so a tap burst still reaches a verdict within (limit × timeout) + one window per miss.
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: 09ce0861-654f-41fc-8418-2b3aed9f3376
📒 Files selected for processing (3)
mobile/src/transport/mobile-relay-credential-refresh.test.tsmobile/src/transport/rpc-session-liveness-watchdog.test.tsmobile/src/transport/rpc-session-liveness-watchdog.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.
| persistResolvedRelay: | ||
| overrides.persistResolvedRelay ?? | ||
| (async () => { | ||
| order.push('persist') | ||
| }), |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Assert the persisted relay endpoint.
The fixture records only that persistResolvedRelay ran. It discards the callback argument. The happy-path test will therefore pass if the implementation persists a stale or unrelated endpoint. Capture the argument and assert that it equals rotated.relay in the ordering test.
There was a problem hiding this comment.
Important
The PR description still contradicts the committed watchdog behavior, and this commit widens the gap by adding a rearmedAtMiss re-arm rule the description never mentions.
Reviewed changes
- Replaced the unconditional resume no-op with one-re-arm-per-miss —
RpcSessionLivenessWatchdog.probeNow(…, 'resume')now re-arms the urgent deadline when a miss has been booked since the last re-arm (rearmedAtMiss), giving a resume at 3.9 s a fresh 2 s window instead of the previous probe's final 100 ms, while a tap burst with no new miss still keeps the in-flight probe's deadline. - Added a failing-first test for the resume-after-miss case — the new test exits the urgent window at 3.9 s, delivers inbound traffic at 4.1 s, and asserts no termination; it fails against the prior commit's unconditional
return. The repeated-resume loop was extended to 9 s and its comment rederived for the re-arm bound.
⚠️ Description still does not describe the committed watchdog
The title/body reconciliation requested in the two prior reviews remains outstanding, and this commit makes it worse: the plain no-op guard is now a rearmedAtMiss re-arm rule that appears nowhere in the description. The title still advertises a "fresh miss budget per resume probe"; the body's "What" still says probeNow(…, 'resume') "resets the miss count"; the "Tests" section still claims "two resume probes each tolerate one miss (fails on main)". None of that is what the code does: the miss count is never reset by probeNow (only startProbe's profile switch is), a resume landing while an urgent probe is in flight is a no-op unless a miss was booked since the last re-arm, and each booked miss buys exactly one re-arm.
Technical details
# Reconcile the PR description with the re-arm rule
## Affected sites
- PR title — "fresh miss budget per resume probe"; the code grants one fresh window per booked miss, not per resume.
- PR body "What" — says `probeNow(…, 'resume')` "resets the miss count"; it no longer does under any condition.
- PR body "Tests" — says "two resume probes each tolerate one miss"; the committed tests are "repeated resumes on a dead socket still reach a verdict" and "a resume after a tolerated miss gets a fresh window".
- mobile/src/transport/rpc-session-liveness-watchdog.ts:139 — the `rearmedAtMiss` guard is the actual mechanism and should be the thing the description documents.
## Required outcome
- Update the title and body to state that a resume during an in-flight urgent probe is a no-op unless a miss was booked since the last re-arm, that each booked miss buys exactly one re-arm, and that the profile switch — not the resume — is what grants a clean budget.
- Correct the "fails on main" framing to match each test's actual mechanism.
## Open questions for the human (optional)
- Does the one-re-arm-per-miss rule now sufficiently resolve #19280's back-to-back-resume symptom, or should a "new observation" (cold radio) still be distinguished from a "repeat tap"?ℹ️ Nitpicks
rearmedAtMissis reset innoteAuthenticatedInboundand on thestartProbeprofile switch, but not instart(),stop(), or the idle-background reset inhandleProbeTimeout— the three other places that zeromissedProbes. It is safe today only because every path back into the urgent profile passes through the profile switch; resetting it alongsidemissedProbesin those three sites would keep the invariant symmetric.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Closed with #19348, which reverts the mobile pass this PR fixes bugs inside. The mobile reconnect work will be re-landed one narrow, device-verified change at a time. |

Follow-ups to #19260, #19280, and #19308 from the post-merge adversarial review. Four findings, each reproduced against main; the two behavioural ones have failing-first tests.
Why
status.geterror reply withheldworktree.activateand every capability for the life of the connection. The status probe stopped outright onok:false, the gate then failed open withcompatVerified: false, and nothing ever upgraded it. Before perf(mobile): open a session with parallel startup RPCs and a pre-warmed terminal engine #19260 activation fired unconditionally and the old capability probe retried an error reply with backoff. After it, an internal host failure, an older host that does not know the method, or an error frame the relay surfaced meant a headless host never hydrated its tabs and screencast, quick commands, agent history, and query-reply input stayed off until the socket was replaced.saveHoststill lifted the fresh-credential gate and firedonRefreshed, which now dials relay in any non-connected state against the pre-rotation cell. The credential itself was already durable, so the blast radius was one dial against a stale cell.confirmingstage budget comment was wrong. It described a 30 s bound; the session bounds the confirm at 12 s and publishesconnectedin the same turn it enters the stage. Comment corrected; the entry stays so the bound's stage table remains total.What
runtime-status-probe.ts: anok:falsereply re-asks at the 15 s ceiling instead of stopping. Unanswered requests still back off from 1 s; cutover still re-asks at 250 ms.onUnavailablealways reports a retry armed.rpc-session-liveness-watchdog.ts:probeNow(…, 'resume')resets the miss count before starting the urgent probe.mobile-relay-credential-refresh.ts:refreshed = truemoves belowawait persistResolvedRelay(...).relay-dial-stage.ts: comment only.Tests
oklands (fails on main, which asserted the probe stopped).vitest(4323),tsc,oxlint,oxfmt --checkclean.