Channel modules, and the MBTA channel
Design agreed and built 2026-09-27.
A station channel used to be wired up in five places: a ChannelKind case, a
branch in StationModel.advanceFlavor() for up/down, a settings struct with its
own load and save, its key added by hand to SettingsSync.keys, and in the
Manager a Pane case and hand-written assistant tools. A channel module
puts all of that in one place. The MBTA channel was the first, then the World
channel; Weather, Radio,
Screensavers and the rest still wire themselves up by hand, and move over one at
a time when they're next touched.
Decisions #
- New channels first. The framework is proved on the MBTA channel; the working channels aren't rewritten to use it now.
- A module declares everything once, in two parts (split 2026-10-29 so
the server can know modules without their views; see
docs/packages.md):- Its definition (
ModuleDefinition, inStationCore'sStation/ModuleDefinitions.swift; the MBTA's isTransitChannel):id(kept forever: the channel's number and name are stored by it),name,guideTitleandtoolName;pages, which up/down steps through. The channel stays on the page picked, remembered on each device (modulePage.<id>, not synced);Settings, aModuleSettingstype: Codable, stored under itskeyand synced automatically (ChannelModules.settingsKeysis added toSettingsSync.keys). Itsfieldsdescribe each setting for the tools, andvalidated()tidies or refuses what it's given. Listing it inChannelModules.allputs it on the dial (asChannelKind.module(id)), in the TV Guide and in sync.
- Its screen (
ChannelModule, inPackages/Sources/StationUI/Station/ChannelModules.swift; the MBTA's isTransitModule): names itsDefinition, and hasview(page:context:)and optionallyplayPause(page:). An on/off setting given atitleis also a switch in the channel's Select menu. Listed inModuleScreens.all.
- Its definition (
- The Manager side is a
ManagerModule(Packages/Sources/ManagerUI/ManagerModules.swift): its definition asModule, itsiconandpane(), listed inManagerModules.all. The sidebar shows modules under Channels. - Its tools are mostly generated. Every module gets
get_<toolName>(the settings, what each field means, and the pages) andset_<toolName>(only the fields given change; null puts one back to its default;validated()checks the result). A module adds hand-written tools only for what settings can't express, throughtools(). The merge isModuleSettingsJSON.apply, tested without touching real settings. - Each module writes its own pane. A form generated from the fields would handle the MBTA's station search and line toggles badly.
The MBTA channel #
TransitModule (id transit, tools mbta) has three pages:
- Departures: the countdown board, as before, now from your stations.
- Nearby: a live map over a dark Apple Maps base, framed on your stations and the bus radius around the weather location. Lines are the MBTA's shapes in their colors (commuter rail's purple lifted a little to show on the dark map); trains are dots and buses are route-number tags, each with an arrow for its compass heading. It refreshes every 10 seconds while it's on screen, and vehicles glide between updates.
- Subway: a T-map style diagram (
TransitSchematic, in RetroLineup) of the Red, Mattapan, Orange, Blue and Green (B–E) lines, with every train on it.
Settings (TransitSettings, key mbta): stations (MBTA place ids),
busRadiusKm (0 for no buses, up to 10), systemRoutes (the diagram's lines;
null for all of them), stationNames (names on both maps) and busNumbers
(route numbers on the Nearby map's buses; off, they're plain yellow dots).
Play/Pause on a map page steps through the four ways to label the maps and says
which on screen: it's saved and synced, so the Manager shows it too, and the
maps redraw at once (TransitLive watches the setting) rather than at their
next refresh. Modules get Play/Pause through playPause(page:); the channel
isn't live, so ad block has no use for it there. A 10 km radius holds over a thousand bus stops, so
the routes serving them are looked up 150 stops at a time. The Manager's MBTA pane edits them; find_mbta_stations
and list_mbta_lines find the ids the tools take.
The diagram #
We looked for an SVG to use. The best, MBTA_Rapid_Transit.svg by Mliu92 on
Wikimedia Commons (CC BY-SA 4.0), is from 2018 (no Green Line Extension) and
portrait, which is unreadable squeezed onto a TV. Generating a layout from the
geography alone (a log-squeezed "fisheye") was tried and dropped for the same
look. So the layout is modeled on that SVG and re-laid for a wide screen:
the same style (lines at 45° and 90°, white station dots, bolder transfers) and
arrangement, with the Extension added and the southern branches turned east.
Being derived from it, the layout is CC BY-SA 4.0, credited on screen.
- Only ends, transfers and corners are pinned (
Waypoints). The stations between are spaced evenly along the line in the order the MBTA's route patterns give them, so a new station finds its place without editing the layout. - A corner says where its station's name goes, and where the names of the unpinned stations after it go: none on the closely spaced Green branches and Mattapan, where they'd be unreadable.
- A train is placed between the two stations on its line it's nearest on the
real map, as far along as it really is between them. Its arrow follows the
line the way it's running (the vehicle's
direction_id), not its compass heading, which means nothing on a diagram. - Commuter rail was left off: at a size that shows it, downtown is unreadable, and you were fine without it. The Silver Line isn't on it either.
- Some names are shortened as the T's own maps do ("Hynes", "Mass Ave").
- The layout is tested: every segment runs at 45° or 90° and stays on the map.
The World channel #
Built 2026-09-27. WorldModule (id world, tools world): the Earth by day
(NASA's Blue Marble Next Generation) with its city lights by night (VIIRS Black
Marble) showing through wherever the sun is down, easing through dusk from 3°
above the horizon to 9° below. The line between day and night is drawn softly
and moves with the sun (redrawn every minute; Sun in RetroLineup, NOAA's
low-precision formulas), and a sun marks the point it's straight above.
- Pages: the World, then North America, South America, Europe, Africa, Asia and Oceania. Each continent's box keeps shapes true at its middle latitude on the 1280 × 604 map; Asia and Oceania cross the date line, so their imagery comes in two pieces. Imagery is fetched from NASA's GIBS map service once per page and kept on disk: it's the same picture every day.
- Over the map: the last day's earthquakes from USGS (a ring sized by magnitude, red in its first hour, fading to yellow over the day), the ISS (wheretheiss.at, every 15 seconds, with its trail this session), and local times for a few cities on each page with a sun or moon for each.
- Settings (
WorldSettings, keyworld):earthquakes,minMagnitude(1, 2.5 or 4.5 usually; the matching USGS day feed is used),issandcityClocks. The Manager's World pane edits them;get_world/set_worldare generated. - Aurora (NOAA SWPC's OVATION forecast, every 5 minutes): a green glow, magenta where strongest, blended from the 1° grid and brightest on the night side.
- Rain radar (RainViewer, every 10 minutes): their Web Mercator tiles redrawn onto the flat map row by row. Only where countries have radar; RainViewer no longer offers satellite clouds, and serves one colour scheme.
- Planes (OpenSky Network): every plane in the air, as specks on the World page and arrows on the continents, flying on at their own speed and heading between updates. They come through Antenna Tower's relay (originally the Manager's relay, manager-relay.md), which holds the OpenSky login and fetches for every screen at once; without a relay, anonymously every 15 minutes.
- Areas (
WorldArea, inareas): places you add in the Manager's World pane or withadd_world_area("02155", 100 miles), found once with Apple's place search and kept as a name, a middle and a radius. Each is a page after the continents: as tall as the radius north and south, and as wide as the screen's shape allows with shapes true. Its day side is Apple's satellite imagery (sharper than NASA's up close), its night side the city lights; planes get their flight numbers where there's room, a house marks the middle, and the strip shows the day's sunrise, sunset and daylight (Sun.riseAndSet). With more than seven pages, the header's page strip says "3 of 9" instead. - Select menu: every module's on/off setting with a
titleis a row in the channel's Select menu (StationMenu.Row.moduleToggle), so each layer can be flipped from the remote; it saves and syncs like any other change. - Lightning was left out for now: the live worldwide source (Blitzortung) wants permission for apps, and NOAA's (GLM) covers only the Americas and comes as science files. If Blitzortung agree, the idea is one connection from the Manager (or the homelab), relayed to every Apple TV on the home network.
- The header is
ModuleHeader, shared with the MBTA channel: a badge, the page's title, the time and the page strip.
Phin Tech docs
Rabbit Ears Manager in the store →