Repository navigation
Android TV: Plans screen (Step 2) - #9378
Conversation
On a TV with the TV_SHELL define, Plans fills the whole 960x540 inside the safe margins (Figma "Android TV / Plans (full screen)") instead of the centred phone column that overflowed at 540dp: the Lantern Pro logo and benefits on the left, not focusable; the plan cards, "Get Lantern Pro" and the three-dot menu's items as links on the right; close top left. The best-value plan is preselected and the button takes focus once the plans load, so buying the default plan is one press. Layout and focus only: the button does what it does on a phone. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- The Best Value badge is placed from the card's own width on TV, so the plan list's small-device rule no longer sees a narrowed viewport. - The TV screen keeps its size under the on-screen keyboard. - Restore and checkout run one at a time from the remote. - Initial focus waits for the route to be current and the viewer not to have moved; on a load error Retry is a button that takes it. - The close button's ring is no longer clipped at the safe margin. - Tests for each, and the route sets pin Plans as a full-screen route with its own layout. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- Restore and checkout exclude each other through the loading overlay they both show (it is not a route, so keys reach the screen while it runs); "Get Lantern Pro" counts the cards as ready only while they show and checks again on the press. - The benefits column gives way on a narrower TV and the right column scrolls by focus when it does not fit; the columns keep their physical order in right-to-left locales. - The first link has focus while the plans load; the button takes over when they show (again after a reload), unless the viewer moved. - AppTextButton takes an optional focusNode; the badge width note says what the TV caller passes and why. - Tests for each. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Review round 3 on the TV screen: its focus bookkeeping grew a flag per state and kept slipping. It is now one derivation: the state the cards render (a reload shows the spinner even with plans or an error kept from before) picks the control that has focus on its own (first link, Retry, or "Get Lantern Pro"); a change of target places focus through the shared tvRequestFocus, which also reveals it; and the placed marker clears when that control loses focus, so a viewer who left and came back owns it. Billing availability is read inside the links builder, so the store's products arriving rebuilds them; the benefits column clips on a short TV. Tests: a restore held in flight blocks a second store operation and checkout until it ends; a four-plan list on a 853x480 TV keeps the focused control in view; a reload disables the button and hands focus back; a retry that fails again returns to Retry; a viewer who left the placed control and came back keeps it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…irst ends Review round 4: AppPurchase exposes hasActiveSession (set at a purchase or restore's start, cleared on every end), and the TV screen's guard reads it alongside the loading overlay, so checkout cannot start while a restore's callbacks are still registered. Back and Close wait while an operation runs, since leaving would strand the app-wide overlay. Each link has its own focus node, chosen once per placement, so billing arriving later does not move focus. D-pad moves on this screen reveal with the shell's inset through the same reading-order policy. Tests: a restore held in flight blocks a second one and Back until the store ends it through the purchase stream; billing arriving later leaves a focused link alone; the narrow TV test measures the visible part against the right column's own viewport on a shorter screen; the refetch fake publishes the real fetch's states. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Review round 5: the purchase session's callbacks outlive a cancelled or deferred checkout on purpose (a later receipt), so a guard on them would have kept Back, Close and both store actions blocked after a cancel. The guard is the loading overlay again, which both flows show from their first line and hide on every end; AppPurchase.hasActiveSession is gone. The promo and license links wait with the rest while an operation runs, Close pops through the Navigator like the shell's arrow, and a link this screen placed focus on that disappears hands it to the first link left. Tests: Back, Close and the other links held during a restore, then the next restore and Back after the store ends it; idle Close leaves Plans. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ry build Restore Purchase was a second store operation a remote could stack on a checkout, and the shared purchase flow has no airtight way to fence that from this screen (it hides its overlay before cleanup and keeps its session for deferred Play payments). Settings keeps Restore on TV. With one store operation left, focus needs no per-kind bookkeeping: each build asks for the state's target through _tvInitialFocus, which is a no-op while the viewer holds a control and the way back when nothing does (a control that left the screen with focus, say). The links no longer rebuild on the store's products arriving. Tests: the Restore, billing-arrival and in-flight-restore cases go; a manual loading-overlay case holds Back, Close and the promo link until it hides, and an applied referral code hands focus from the vanished promo link to the button. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The screen's overview names the one phone menu item TV leaves out, and the busy-guard comment says when the overlay comes down on a purchase (the store's answer; the account refresh runs with it down, as on a phone). A test pins that no Restore link shows with store billing available; the focus hand-back test makes the promo link the only control that ever held focus, so Flutter's own history cannot satisfy it; the plans-refetch doc sits on its class again. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Comments say where the phone shows Restore Purchase (under the button, not in the menu) and when a checkout's overlay comes down (once the checkout settles, a purchase only after the backend acknowledges its receipt). The overlay test presses the button too, which without its guard would start the purchase flow; the focus hand-back test's comment says how the referral code is applied. The Plans smoke test expects no Restore link on the TV shell's Plans. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The busy-guard comment covers the receipt-verification failure path (the overlay comes down then too, and the acknowledger retries in the background); the overlay test presses the license link as well, which without its guard would leave Plans through the app router. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Comments say Settings offers Restore on TV to accounts that are not Pro, as on a phone, and that a purchase's overlay comes down once its receipt is handled, locally or at the backend. The overlay test presses Close through its handler, since a tap stops at the overlay's barrier that keys pass. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
There was a problem hiding this comment.
🔵 Needs a closer look
The TV checkout and Back/Close guards rely on real Play Billing overlay timing, but tests only simulate the overlay, leaving purchase completion, cancellation, and deferred payments unverified on a billing-capable TV.
No open issues 🎉
What changed in this PR
Adds a full-screen Android TV Plans layout on top of the TV shell, gated by TV_SHELL, while retaining the existing phone and desktop paths.
Changes:
- Adds a two-column TV layout with remote-friendly focus, scrolling, Close, and promo/license links; Restore Purchase remains in Settings.
- Guards checkout-related controls and navigation while the loading overlay is visible.
- Extends shared buttons and plan cards with optional focus and badge-sizing inputs, with tests for TV layout, focus, and navigation.
| File | Description |
|---|---|
test/features/plans/plans_tv_test.dart |
Adds TV layout, focus, activation, scrolling, and checkout-guard tests. |
test/core/router/tv_route_builder_test.dart |
Verifies Plans uses its own full-screen layout. |
lib/features/plans/plans.dart |
Implements the TV layout, focus handling, and checkout guards. |
lib/features/plans/plans_list.dart |
Passes optional badge-sizing input to plan cards. |
lib/features/plans/plan_item.dart |
Supports badge positioning independently of viewport width. |
lib/core/router/tv_route_builder.dart |
Lets Plans bypass the centered phone-width frame. |
lib/core/common/app_buttons.dart |
Adds optional focus nodes to shared buttons. |
integration_test/plans/plans_smoke_test.dart |
Expects no Restore Purchase link on TV Plans. |
Review effort: Balanced
Android TV: Plans screen (Step 2)
Builds on the TV shell PR (#9372); this PR targets its branch, so the diff shows the Plans screen plus the small shared pieces it needs (the TV route builder's own-layout set, an optional focus node on the two shared buttons, and the Plans smoke test's expectation). On a TV with
TV_SHELL, a build with in-app payments lays the Plans screen out across the whole 960x540 (Figma "Android TV / Plans (full screen)") instead of the centred phone column, which on the Lantern_TV emulator ran past the bottom of the 540dp screen with the three-plan catalog (the shell PR's list of unconverted screens has the screenshot). A build without in-app payments keeps its license-only body, now without the centred column either.TvShell). The benefits column takes at most its 380dp design width, gives way on a narrower TV and clips on a short one; the right column scrolls by focus when it does not fit. Left, not focusable: the Lantern Pro logo and the existingFeatureList. Right: the existingPlansListView,PrimaryButton, then the three-dot menu's items as focusable links: promo/referral code (until a code is applied) and Lantern Pro license. No ⋮ on TV, and no Restore Purchase link: it would be a second store operation the remote could stack on a checkout, and the shared purchase flow has no airtight way to fence that from this screen (the review rounds below); on TV, Restore stays in Settings, which offers it as on a phone, to accounts that are not Pro while store billing is available.TvShell) and follows the one state the cards render: the first link while they load (a reload shows the spinner even with plans or an error kept from before), Retry (a button on TV) on a load error, "Get Lantern Pro" once they show. Every build places that target through the sharedtvRequestFocus(which also scrolls it into view) when nothing on the screen has focus, or focus is still where the screen put it; it never takes focus from a viewer who moved it (a viewer who left the placed control and came back owns it), nor while a dialog covers the screen. D-pad moves reveal through the shell's reading-order policy and inset.PrimaryButtongains an optionalfocusNode;tvOwnLayoutRoutesin the TV route builder lets a full-screen route skip the centred column.PlanItem/PlansListViewtake an optionalcardWidthfor the Best Value badge (null on the phone), so TV never narrows the viewport the list's small-device rule reads. The TV scaffold keeps its size under the on-screen keyboard. A store (Play Billing) checkout shows the app-wide loading overlay, which is not a route and lets keys through, so while it is up the button, the promo and license links, Back and Close wait (a second press would start another checkout; the promo dialog's flow hides the same overlay; the license link replaces Plans for a signed-out viewer, aroundPopScope, or pushes the license screen over it; leaving would strand the overlay). The store flow shows it from its first line and hides it once the checkout settles; a purchase's account refresh then runs with it down, as on a phone. The sideloaded flow leaves Plans for sign-up or payment selection instead, so there is nothing to hold. Close pops through the Navigator like the shell's arrow. "Get Lantern Pro" counts the cards as ready only while they show (a value kept during a foreground reload, when the list shows its spinner, is not; a background refresh keeps the cards and the button) and checks again on the press.AppTextButtongains an optionalfocusNode(null everywhere else); each TV link has its own.Verified on the Lantern_TV emulator (arrows, Enter, Back only)
Re-checked on the final build (after the Restore link was dropped): Plans opens from the upsell with the badge inside the best-value card and focus on the button; Up reaches the plans, Down the links.
Focus order as observed on that emulator, with the cards in the order its three-plan catalog returns them: Get Lantern Pro → (Up) One Month → One Year → Two Year → (Up) X; (Down from the button) promo link → (Right) license link (Down when the links wrap). OK on One Year moved the selection without leaving the screen. Back returns to Home with the upsell focused. Phone Plans unchanged.
Known gap: when the focused plan is also the selected plan, the focus ring and the selection border share the same edge; the ring is drawn on top but reads only a little stronger. Figma draws the ring outside the card with a gap, which the card could get by passing
AppFocusable'sringPadding(zero today).Testing
flutter analyze --no-pub --no-fatal-infos --no-fatal-warnings: 0 errors, 0 warnings.flutter test: the whole suite passes, includingtest/features/plans/plans_tv_test.dart(TV layout; initial focus on the button; the close button present, never the initial focus, and leaving Plans when pressed; OK on a plan selects without leaving; the badge's text inside its card's horizontal bounds; OK on the promo link opens the code dialog; the layout builds without error under a bottom inset; Retry focused on a load error; the Stack around Close does not clip; a four-plan list on an 853x400 TV keeps the button, the promo link and the first card inside the viewport; a reload disables the button and hands focus back; a retry that fails again returns to Retry; a viewer who left the placed control and came back keeps it; the button, links, Back and Close held while the loading overlay is up, then Back leaves; a control that leaves the screen with focus hands it back to the state's target; idle Close leaves Plans; cards arriving under the code dialog or after the viewer moved leave focus alone; right-to-left order) and the route sets pinning Plans as full-screen with its own layout.make android-debug-cion theLantern_TVemulator, driven withadb shell input keyeventonly: the focus order above; the phone emulator's Plans screen unchanged.Risk
tvShellEnabled, except:PrimaryButtonandAppTextButtongain an optionalfocusNode(null everywhere else);PlanItem/PlansListViewgain an optionalcardWidth(null on the phone); the shared plans-list loading/error helper the phone body calls with the same arguments as before; and the four TV focus nodes, created and disposed with every Plans state on every platform (unused off TV).lib/features/plans/plans.dart, which gains a second layout for TV next to the phone one; the two share the plan list, button and callbacks, so a change to one path should be checked on the other.How to revert
Revert the merge commit; no migrations, flags or config.
Pre-PR review (local Codex gate)
CODEX GATE: verdict=findings critical=0 important=0 minor=3 preexisting=0 reviewed=381a8456294e5eeb3ed363ec4e763f37d1fefe7139; the commit after it (c615204e4) fixes round 10's three minor findings and had no Codex round of its ownapprove. Round 10 left no critical or important finding the branch introduced; its three minors (two comments, a test press stopped by the overlay's barrier) are fixed in the final commit. One important finding stands dismissed with a reason (the shared flow's post-purchase window, below); rounds 1–6 before the Restore decision are summarised under Step back.coderabbitCLI is not installed on this machineSTEP BACK r3: same-area — rounds 1–6 kept finding a new way for the TV screen's Restore link and a checkout to overlap from the remote, or for the shared purchase flow to release the screen's guard before its own cleanup (it hides its overlay before the account check and keeps its session for deferred Play payments). Instead of a seventh fence, the Restore link leaves the TV layout (Settings keeps it), which also lets the focus bookkeeping collapse to one rule.PlansListViewinto its small-phone carousel (r1) →cardWidthonPlanItem/PlansListView, no viewport overrideresizeToAvoidBottomInset: falsemounted, so a dialog over Plans lost focus (r1) →ModalRoute.isCurrentclipBehavior: Clip.noneTvNotInitialFocuskeeps Close from first focus outsideTvShell(r1) → the screen places focus itself; comment correctedAsyncValuecounted as ready while the cards showed their spinner (r2, r3) →_tvPlansReadyon the rendered branch, rechecked on the press; Retry focus only when the cards render the errorTvShelltvRequestFocusPopScopeguard, so the test pins the pairAppRouter—tv_route_builder_testpins Plans in both route sets, and the own-layout branch is one line covered bytv_frame_test's disabled case; a routed Plans test needs the app's provider graphappRouter, which the widget test does not host; the promo dialog activation is coveredAppPurchaseis a refactor of shared purchase code outside this layout PRtvRequestFocus, covered bytv_shell_test; the links are the last content, so there is no room below them for the inset to show_isRestoreFlowfieldcanUseStoreBilling()alone, while Android Plans also waits forAppPurchase.isStoreBillingAvailable(a product query); a slow query fails the catalog check on a Play build (prediction unchanged from the merge-base; this branch only adds the TV exclusion)processPurchasehides the loading overlay before awaiting the account refresh and clearing the purchase callbacks; Back (disposing Plans) or a second tap in that window reaches a disposed screen or orphans the second checkout, on every platform🤖 Generated with Claude Code