Skip to content

fix(mobile): a refused update serves the cached generation while the host is up - #22237

Merged
Jinwoo-H merged 6 commits into
mainfrom
ota-fu-failed-update-fallback
Sep 22, 2026
Merged

Jinwoo-H merged 6 commits into
mainfrom
ota-fu-failed-update-fallback

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​741 $\color{#cf222e}{\Huge{\mathbf{−}}}$​11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​730
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​238 $\color{#cf222e}{\Huge{\mathbf{−}}}$​67 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​171

On the page shell (inert today, EXPO_PUBLIC_MOBILE_SHELL=ota only), a refused update walled the workspace even though an intact, previously accepted generation was on disk. Found by the emulator run's failed-update drill: truncate one asset of a newer generation and the shell painted "Try again" while the host was reachable, while the very same cached generation is served the moment the host goes away.

Cause. onDownloadFailed only fell back to the cache for a transport-side failure; a bundle-side refusal (a truncated asset rejects with a plain error) skipped the cache and returned the failed state.

Fix. The branch is now on what is on disk, not on which side refused. Nothing cached: the refusal is still the screen. Something cached: the shell serves it through the same "open by its own routes" path the offline branch uses (extracted as one function, both call sites), and surfaces a dismissible HostRouteNoticeBanner above the page: "Couldn't update the workspace from this host. Showing the last version that worked." No retry is promised because none happens until the next entry into the flow. The refused generation is never staged, committed or persisted, and the notice is cleared on every flow entry.

Compat guard. A reachable host may have moved past the cached generation (that is usually why an update exists), so before serving, cachedGenerationWall judges the cached generation's own manifest facts against the host's capabilities and status. Outside the protocol window → the compat wall with its verdict, exactly as a fresh manifest would get. It runs only when the gate verdict is open, so an empty capability list from a host that did not answer stays the native-route rule rather than becoming a bundle-unavailable wall. CachedGeneration now carries compat (the parsed manifest's schema/protocol fields, which every readable generation already has).

Tests. Reducer suite (refused-update cases moved into mobile-web-shell-refused-update-decision.test.ts): red on main for "opens the cached generation rather than walling a host it can still reach" and "walls the cached generation the host has moved past rather than serving it". New end-to-end suite over the real store and a fake disk: 4 → all green, including the wall case reading the manifest back off the committed tree. Screen tests for the banner, mutation-probed.

Two max-lines forced moves, no behaviour change: two byte-identical onCacheRead branches merged; the refused-update describe block moved to its own file.

…host is up

A newer generation that fails to fetch or stage was refused with a named
reason and then painted a wall with "Try again" over an intact generation
already on disk — the same one the offline branch opens without being asked
the moment the host goes away.

`onDownloadFailed` now branches on what is cached rather than on which side
refused: with nothing on disk the refusal is still the screen, and with a
generation on disk it is opened through the offline branch, judged by its own
route list. The refused generation is never staged, committed or persisted, and
nothing about the refusal is written, so the next launch asks the host again.

The bundle-side refusal is named as a dismissible notice above the page, on the
existing host-route banner. It says what happened and promises no retry,
because the shell schedules none.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…h before serving it

The fallback served a cached generation on the strength of the offline rule,
which skips the compat check because a host nobody can reach cannot have
changed. On this path the host has just answered, and an update usually exists
precisely because it moved — so bytes that were inside the protocol window when
they were written may be outside it now.

`CachedGeneration` now carries the three fields the compat verdict reads,
projected in `openCache` off the manifest stored beside the assets. That
manifest is never absent: `readActiveGeneration` answers null for a generation
whose manifest did not parse, and the read schema requires all three.

`cachedGenerationWall` lives beside `gateVerdict`, because only an `open` gate
is judged further. The other verdicts already have answers there: an absent
capability is the native-route rule, and an unreadable status leaves the same
empty list, so walling on either would be the `bundle-unavailable` wall that
file exists to keep off a host that simply did not reply.

A generation outside the window now earns the wall with its verdict, not the
download-failed screen, and nothing is deleted: the bytes are intact and a
newer host is not what makes them wrong.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: ec4b8c7b-c444-4eeb-b370-193ff4670b00

📥 Commits

Reviewing files that changed from the base of the PR and between b8ea9bf and f494ecc.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 5af427dc-fcd5-4df2-a1de-148ac62c74de

📥 Commits

Reviewing files that changed from the base of the PR and between 5d037e9 and b8ea9bf.

📒 Files selected for processing (6)
  • mobile/src/components/HostRouteNoticeBanner.test.tsx
  • mobile/src/components/HostRouteNoticeBanner.tsx
  • mobile/src/mobile-web-shell/MobileWebShellScreen.test.tsx
  • mobile/src/mobile-web-shell/mobile-web-shell-gates.ts
  • mobile/src/mobile-web-shell/mobile-web-shell-refused-update-decision.test.ts
  • mobile/src/mobile-web-shell/mobile-web-shell-session.ts

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


📝 Walkthrough

Walkthrough

The mobile web shell now preserves compatible cached generations when an update download is refused. It records compatibility metadata, blocks incompatible cached generations, and exposes an update-failed notice through the session hook. The screen renders a dismissible failure banner without remounting the served page. Tests cover fallback activation, cache preservation, retry and relaunch behavior, compatibility walls, and notice dismissal.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to b8ea9

Refused updates can preserve a compatible cached generation and show a dismissible accessible notice. The current change has no remaining merge-blocking risk.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the cause, fix, compatibility guard, user-visible behavior, and test coverage, but it does not follow the required template. It omits the required Linked Issue, Visual Proof, … Rewrite the description using the repository template. Add an issue link after “Fixes #”, attach before-and-after visual proof or state N/A with a reason, complete the Testing section and checkboxes, provide AI disclosure when applicable, c…
Docstring Coverage ⚠️ Warning Docstring coverage is 61.76% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 34 functions across 14 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: serving the cached generation when a mobile update is refused while the host remains reachable.
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: Description check

Explanation

The description explains the cause, fix, compatibility guard, user-visible behavior, and test coverage, but it does not follow the required template. It omits the required Linked Issue, Visual Proof, Testing, AI Disclosure, Review, boundary, Notes, and Checklist sections.

Resolution

Rewrite the description using the repository template. Add an issue link after “Fixes #”, attach before-and-after visual proof or state N/A with a reason, complete the Testing section and checkboxes, provide AI disclosure when applicable, complete Review and Agent skill upstream boundary, address the Notes items, and complete the Checklist.

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: e419496b-364f-4a42-8f10-13b525fea1b2

📥 Commits

Reviewing files that changed from the base of the PR and between 59c0d55 and 5d037e9.

📒 Files selected for processing (12)
  • mobile/src/mobile-web-shell/MobileWebShellScreen.test.tsx
  • mobile/src/mobile-web-shell/MobileWebShellScreen.tsx
  • mobile/src/mobile-web-shell/catch-all-page-route-states.test.tsx
  • mobile/src/mobile-web-shell/mobile-web-shell-failed-update-fallback.test.ts
  • mobile/src/mobile-web-shell/mobile-web-shell-gates.ts
  • mobile/src/mobile-web-shell/mobile-web-shell-refused-update-decision.test.ts
  • mobile/src/mobile-web-shell/mobile-web-shell-session-contract.ts
  • mobile/src/mobile-web-shell/mobile-web-shell-session-effects.ts
  • mobile/src/mobile-web-shell/mobile-web-shell-session-test-fixtures.ts
  • mobile/src/mobile-web-shell/mobile-web-shell-session.test.ts
  • mobile/src/mobile-web-shell/mobile-web-shell-session.ts
  • mobile/src/mobile-web-shell/use-mobile-web-shell-session.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@pullfrog pullfrog 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.

ℹ️ No critical issues — one edge-case ordering inconsistency inline.

Reviewed changes

Reviewed f5b35f1 and 5d037e9 in full (all 12 files).

  • Refused-update fallback — onDownloadFailed now branches on what is on disk rather than which side refused. With a cached generation it opens it through the extracted openByOwnRoutes helper (previously the transport-only branch), tagging updateNotice: 'update-failed' for a bundle-side refusal and no notice for a transport drop; with nothing cached the refusal screen is unchanged.
  • Compat guard on the cached generation — the new cachedGenerationWall re-judges the cached manifest against the host's stated window, but only when gateVerdict is open, so a host that simply did not answer stays the native-route rule instead of becoming a bundle-unavailable wall. CachedGeneration.compat carries the three fields this needs, populated from the stored manifest and refreshed on a same-build hit.
  • Notice surface — updateNotice is cleared by every flow entry and by retry, and the screen renders a dismissible HostRouteNoticeBanner above the page. Keying the dismiss on sessionId is sound: session ids are 32 random bytes, so a later refusal cannot be silenced by an earlier tap.
  • Tests — reducer suite for the decision, a new end-to-end suite over the real store and a fake disk (including the wall case read back off the committed tree), and screen tests for the banner and its dismissal. No retry affordance is promised, matching the reducer.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

The compat wall ran before the route question, so a cached generation that does
not carry this route — or predates route listing entirely, `routes: undefined` —
earned a terminal `bundle-incompatible` wall where the answer is `native-route`.
`onManifestRead` has always taken the other order: a route that stays native has
nothing to wall about. `openByOwnRoutes` now asks the route first and applies
the wall only on the served branch, and the update notice moved to `served`, so
a native answer carries no notice about a screen it is not showing.

The other half is the verdict the gates hold at the moment of the refusal. A
`fetching` session does not await the gates, so a refusal can land under a
verdict the flow never started on. `gateState` is now the one mapping from a
gate verdict to a screen, shared by the entry into the flow and by the fallback,
so the two cannot answer the same verdict differently: a host that stopped
serving a bundle is `native-route`, a status that went unreadable says so and
re-arms, a dial in progress or a pending status waits in `checking`, an
unreachable host keeps the offline rule and serves the cache unjudged, and
`open` is the only answer that leaves a host to judge the generation against.

That inverts two round-2 assertions that expected the cached page to be served
when the capability list had gone empty. Both were wrong for the same reason:
an empty list is the gate's question, not a verdict about a bundle.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…tone

The banner is inserted into a screen that is already on screen, so a reader who
has moved past the top of the list never arrives at it. It carried no live
region and no role, so nothing carried it to them.

The urgency follows `tone` rather than being assertive for everything. The
failure tone is an action that did not happen — a refused worktree action, or
the shell's refused update — and interrupts with `alert` and an assertive
region. The notice tone is a bounced route, context for a list already being
read, and waits its turn politely; interrupting for that would train people to
ignore the first. No role on that arm: React Native has no `status` role, so the
polite region is the whole of the answer.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

Reviewed the delta since the prior pullfrog review (5d037e9 → b8ea9bf): two fix commits and a merge of main.

  • Fixed the compat-wall ordering the prior review flagged — openByOwnRoutes now asks the cached bundle's own route list before the wall, so an unserved route (or one from before routes was listed, routes: undefined) answers native-route with no notice instead of a terminal bundle-incompatible wall.
  • Unified the gate-verdict-to-screen mapping into gateState, shared by startFlow and onDownloadFailed, so a refusal landing under gates that moved mid-download answers the same native-route / wall / status-unreadable / checking the rest of the shell gives; cachedGenerationWall now takes the caller's already-computed verdict and applies only on the served branch.
  • Announced the notice banner — alert and assertive for the failure tone, polite with no role for the default notice tone, with a dedicated component test.
  • Inverted the two round-2 cases that asserted activating for a host that stopped advertising the bundle capability to native-route, matching gateVerdict everywhere else.

Verification: the focused suites (27 tests) and the full mobile/src/mobile-web-shell directory (68 files / 1159 tests) both pass on b8ea9bf.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

Reviewed the new head f494ecc. The only commit added since the prior review is a merge of origin/main; the PR's net diff (14 files) is byte-identical to b8ea9bf, so there are no author-side changes. Re-ran the shell suites on the merged head (69 files / 1162 tests) and they pass.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H merged commit 3d76c22 into main Sep 22, 2026
23 checks passed
@Jinwoo-H
Jinwoo-H deleted the ota-fu-failed-update-fallback branch September 22, 2026 12:39
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