Skip to content

Android TV: Plans screen (Step 2) - #9378

Merged
jigar-f merged 11 commits into
derek/tv-two-panel-shellfrom
derek/tv-plans-screen
Nov 26, 2026
Merged

jigar-f merged 11 commits into
derek/tv-two-panel-shellfrom
derek/tv-plans-screen

Conversation

@Derekf5

@Derekf5 Derekf5 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

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.

  • Two columns inside the 48/27dp safe margins, in physical order in right-to-left locales (text keeps its direction, as in 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 existing FeatureList. Right: the existing PlansListView, 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.
  • Close (X) top left, focusable with the ring, its ring unclipped at the safe margin. Focus is the screen's own (it takes the whole screen, outside 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 shared tvRequestFocus (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.
  • The best-value plan is preselected (as before); "Get Lantern Pro" takes focus once the plans have loaded, so buying the default plan is one press.
  • Up/Down move through plans, button and links. OK on a plan selects it only; OK on the button continues exactly as on a phone (Play Billing or the sideloaded flow; nothing new after the press).
  • PrimaryButton gains an optional focusNode; tvOwnLayoutRoutes in the TV route builder lets a full-screen route skip the centred column. PlanItem/PlansListView take an optional cardWidth for 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, around PopScope, 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. AppTextButton gains an optional focusNode (null everywhere else); each TV link has its own.
  • Phone and desktop paths are unchanged (the phone body only gained a shared helper for the plans list's loading and error states).

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's ringPadding (zero today).

Testing

  • flutter analyze --no-pub --no-fatal-infos --no-fatal-warnings: 0 errors, 0 warnings.
  • flutter test: the whole suite passes, including test/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-ci on the Lantern_TV emulator, driven with adb shell input keyevent only: the focus order above; the phone emulator's Plans screen unchanged.
  • Not tested: Play Billing on TV (the emulator image has no Play Store) and the sideloaded webview checkout (ticketed separately, unchanged here).

Risk

  • Every change is behind tvShellEnabled, except: PrimaryButton and AppTextButton gain an optional focusNode (null everywhere else); PlanItem/PlansListView gain an optional cardWidth (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).
  • Riskiest file: 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)

  • Rounds: 10 (the ceiling) — final: CODEX GATE: verdict=findings critical=0 important=0 minor=3 preexisting=0 reviewed=38
  • Reviewed at: 1a8456294e5eeb3ed363ec4e763f37d1fefe7139; the commit after it (c615204e4) fixes round 10's three minor findings and had no Codex round of its own
  • Exit: not approve. 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.
  • CodeRabbit: not run — unavailable: the coderabbit CLI is not installed on this machine
  • Description check: 16 claims corrected
  • Step back: STEP 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.
  • Fixed:
    • [codex] lib/features/plans/plans.dart — the synthetic MediaQuery width for the Best Value badge switched PlansListView into its small-phone carousel (r1) → cardWidth on PlanItem/PlansListView, no viewport override
    • [codex] lib/features/plans/plans.dart — the TV Scaffold resized for the on-screen keyboard though its columns cannot shrink (r1) → resizeToAvoidBottomInset: false
    • [codex] lib/features/plans/plans.dart — the deferred focus request only checked mounted, so a dialog over Plans lost focus (r1) → ModalRoute.isCurrent
    • [codex] lib/features/plans/plans.dart — Close drawn outside the Stack was clipped (r1) → clipBehavior: Clip.none
    • [codex] lib/features/plans/plans.dart — comment claimed TvNotInitialFocus keeps Close from first focus outside TvShell (r1) → the screen places focus itself; comment corrected
    • [codex] lib/features/plans/plans.dart — fixed-width columns with no check of the available size (r2) → the benefits column gives way on a narrow TV and clips on a short one; the right column scrolls by focus
    • [codex] lib/features/plans/plans.dart — a retained AsyncValue counted as ready while the cards showed their spinner (r2, r3) → _tvPlansReady on the rendered branch, rechecked on the press; Retry focus only when the cards render the error
    • [codex] lib/features/plans/plans.dart — focus placed once per route, and lost when a loading transition removed the focused control (r2, r3, r5, r6) → every build asks for the state's target; a viewer who moved keeps it
    • [codex] lib/features/plans/plans.dart — RTL swapped the columns while Close stayed physical-left (r2) → physical order, as in TvShell
    • [codex] lib/features/plans/plans.dart — automatic focus skipped the reveal D-pad moves get (r3) → tvRequestFocus
    • [codex] lib/features/plans/plans.dart — the remote could leave Plans, or open the license screen, while a store flow owned the loading overlay (r4, r5) → Back, Close and both links wait while it is up
    • [codex] lib/features/plans/plans.dart — the guard read the purchase session's callbacks, which a cancelled Play checkout keeps (r5) → back to the overlay's visibility
    • [codex] lib/features/plans/plans.dart — Restore and checkout could overlap from the remote; billing arriving late moved focus; the guard released before the purchase flow's own cleanup (r1, r2, r3, r4, r6) → the Restore link leaves the TV layout, so no second store operation starts from this screen
    • [codex] lib/features/plans/plan_item.dart — the badge API said the caller passes the card's width while the TV caller added 32px (r2) → the card's real width
    • [codex] lib/features/plans/plans.dart — docstring said nothing takes focus while loading (r3) → the first link does; docstring corrected
    • [codex] test/features/plans/plans_tv_test.dart — tests asserted presence without the badge's placement, activations, visibility inside the viewport, refetch with a retained value, or the overlay guard (r1, r3, r4, r5, r6) → tests for each, with the refetch fake publishing the real fetch states
    • [codex] test/features/plans/plans_tv_test.dart:105 — every test ran with store billing unavailable, where the phone's menu hides Restore anyway (r7) → a test with billing available pins that TV shows no Restore link
    • [codex] test/features/plans/plans_tv_test.dart:350 — the focus hand-back test could pass on Flutter's own focus history (r7) → the promo link is the only control that ever held focus; the test fails when the screen places focus only once
    • [codex] lib/features/plans/plans.dart:291, test/features/plans/plans_tv_test.dart:41 — the overview called the screen layout-and-focus-only though TV drops Restore; the refetch fake's doc sat on the referral fake (r7) → both corrected
    • [codex] lib/features/plans/plans.dart:292, :526 — comments put the phone's Restore in the menu (it sits under the button) and said the overlay hides "when the store answers" (a purchase waits for the backend's receipt acknowledgment first) (r8) → both corrected
    • [codex] test/features/plans/plans_tv_test.dart:342 — the overlay test never pressed the button, so dropping its guard left the suite green (r8) → Select on the button while the overlay is up; the test fails without the guard
    • [codex] test/features/plans/plans_tv_test.dart:374 — comment said the referral code is applied under the dialog (r8) → says the test applies it as the dialog's submit does once closed
    • [codex] integration_test/plans/plans_smoke_test.dart:121 — the Plans smoke test expected the Restore link wherever store billing is available, which a TV-shell build omits (r8) → expects none on the TV shell
    • [codex] lib/features/plans/plans.dart:527 — the guard comment left out the receipt-verification failure path, where the overlay also comes down (r9) → covered
    • [codex] test/features/plans/plans_tv_test.dart:342 — the overlay test never pressed the license link, so dropping its guard left the suite green (r9) → pressed too; the test fails without the guard
    • [codex] lib/features/plans/plans.dart:293, :528 — comments said Settings keeps Restore on TV without its not-Pro condition, and tied a purchase's overlay to the backend's answer though an empty receipt fails locally first (r10) → both corrected
    • [codex] test/features/plans/plans_tv_test.dart:360 — the overlay test tapped Close, which the overlay's barrier swallows (r10) → Close pressed through its handler; its own check is backed by the PopScope guard, so the test pins the pair
  • Dismissed:
    • [codex] test/features/plans/plans_tv_test.dart:76 — a routed test that pushes Plans through AppRouter — tv_route_builder_test pins Plans in both route sets, and the own-layout branch is one line covered by tv_frame_test's disabled case; a routed Plans test needs the app's provider graph
    • [codex] test/features/plans/plans_tv_test.dart:202 — pressing Select on Close and License — those route through appRouter, which the widget test does not host; the promo dialog activation is covered
    • [codex] lib/features/plans/plans.dart (store guard) — the overlay's visibility rather than a guard the purchase service owns — a second checkout can only start from this screen's controls, and the flow shows the overlay from its first line to every end; moving ownership into AppPurchase is a refactor of shared purchase code outside this layout PR
    • [codex] test/features/plans/plans_tv_test.dart (short-TV test) — does not measure the 27dp inset — the policy is the shell's tvRequestFocus, covered by tv_shell_test; the links are the last content, so there is no room below them for the inset to show
    • [codex] lib/features/plans/plans.dart:526 — the checkout guard releases when a purchase hides the overlay, before the shared flow's account refresh and callback cleanup — that window is the shared purchase flow's and is the same on a phone (Back or a second tap after the overlay hides); the TV guard adds nothing the phone lacks and takes nothing away, and closing it means holding the app-wide overlay through a core call with no deadline inside the shared flow, a phone-visible change outside this layout PR (listed below)
  • Pre-existing (not introduced here, worth filing):
    • docs/purchases/google-play-purchase-flow.md:141 — lists Settings as the only manual restore entry point (Plans offered restore on the phone before this branch) and names an obsolete _isRestoreFlow field
    • lib/features/plans/plans.dart:110 — the comment says the country-code event changes billing availability; Play Billing eligibility follows the build channel
    • integration_test/plans/plans_smoke_test.dart:121 — the smoke test predicts the phone's Restore link from canUseStoreBilling() alone, while Android Plans also waits for AppPurchase.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)
    • lib/features/plans/plans.dart:898 — processPurchase hides 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

Derek Frech and others added 11 commits November 25, 2026 07:15
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>
Copilot AI balanced review requested due to automatic review settings November 25, 2026 13:55
@coderabbitai

coderabbitai Bot commented Nov 25, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 239b7188-0471-4dda-8e0e-c16d1acc2144

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
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Copilot AI 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.

🔵 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

@jigar-f
jigar-f merged commit 8184840 into derek/tv-two-panel-shell Nov 26, 2026
9 of 10 checks passed
@jigar-f
jigar-f deleted the derek/tv-plans-screen branch November 26, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants