Plan: a dumb TV, and the station on Linux
Superseded 2026-11-03. The Swift server (
StationServer,RelayServer,antenna-tower-server,control-room, the Manager's launchd helper and MCP assistant) was replaced by the Go tower intower/(ADR 0005). What follows is history.
Written 2026-11-01, to pick up on the Mac mini. Self-contained: the notes Claude keeps are per machine, so what matters from them is here. Background: packages.md, linux-server.md, sport-channels.md, ADR 0003.
Where it stands #
All committed and pushed; 3149625 is the latest code. Nothing since
4e6b294 has been installed or tried on a real TV, a real provider or R2.
| Done | Commit |
|---|---|
StationCore: models and clients out of Sources/Shared |
dea6f24 |
StationServer: the tower's parts |
4d3f3a0 |
The packages build and test on Linux (just linux-check) |
1c06abd |
public narrowed to what another module uses |
140a004 |
antenna-tower-server, Tower.serve(), just tower-image |
20df8b3 |
StationJobs: the Manager's jobs |
56adabd |
| Screens only play what the control room sorted | aedc8f3 |
Sport rules out of the screens' apps: RetroSports |
3149625 |
Install order matters. Update the Manager before the TVs. Until it has
run one refresh with the new code, always-on sport streams stay off on an
updated TV, because they wait for the published shows.
Status, 2026-11-02 #
Built in one unattended pass, each step its own commit on main. Built and
type-checked on the Mac; none of it run on a TV, against a real tower or
provider, on Linux, or by the Manager's signed tests (no Docker, and the
keychain was locked to codesign).
| Section | State |
|---|---|
1. ChannelSchedule |
Done, including removing eventGames (no backward compatibility, by decision) and moving Game, Event, EventSchedule, Showing to RetroSports. The TV app's dependencies hold no RetroSports or StationJobs. The strings check on a tvOS binary wasn't run (no tvOS runtime). |
| 2. Fewer keys to screens | Done: app=screen on GET settings, stationOnlyKeys, the R2 watch snapshot. iCloud and a manager-profile phone's full snapshot still carry them, as decided. |
| 3. UI packages | StationUI (all of Sources/Shared) and ManagerUI (Sources/Manager) are packages; the apps are shells; the tower builds from its own sources, with no UI and no VLCKit. Players (On Demand's engines and VLC) is its own package too. Not done: narrowing public (everything is public for now, see docs/packages.md). |
| 4. Control room | control-room pairs, runs the jobs and serves MCP with the settings-only tools (JobToolkit). Not done: the lineup's tools (channels, groups, numbers, feeds, test_stream, add_sport_channel) still need StationModel, so AssistantServer stays in the Manager. The protocol is shared. |
| 5. Live | Read-ahead on BSD sockets, STATION_PROXY, the Linux CI workflow and images, deploy/docker-compose.yml, antenna-tower export (the tower helper writes the bundle, as it holds the station on the Mac) and import, both untested. Not done, and not mine to do: pushing to the homelab GitOps repo, the test station, the move. |
just linux-check has since run (Swift 6.3 on Ubuntu, in OrbStack): RetroLineup
(237 tests), RetroRelay (43) and Station (8, including the socket listener and
the MCP server over real sockets) pass, and every Station product, the control
room included, builds. Still never run on Linux: pairing, avahi-publish,
import, a real provider.
Next, in order: run just linux-check (needs Docker); pair the control room
with a test tower; install the Manager, then the TVs; then narrowing public.
Decisions already made #
- The TV is dumb, for App Review. No sport rules, Jev or folder sorting in
a screen's app. Anything sports goes in
RetroSportsorStationJobs, neverSources/Shared,TVApp,iOS,StationCoreor theRetroLineuptarget. - Providers stay on the TV. Logins and Xtream code are fine: other IPTV apps (UHF) do that. Don't move them for review's sake.
- Stale schedules: a screen plays the last sort however old. Past 90 minutes the coming-up card says how old; with none, it waits for the guide.
- Tower = broadcast, control room = logic. The jobs and the assistant go in a second headless service, not the tower (ADR 0003 decision 7).
- Swift, not Go. (Reversed 2026-11-02 for the tower: see
ADR 0005,
tower/.) The server shares its models, formats and parsing with the apps. Shrink the image with the Static Linux SDK if size matters. - Three kinds of channel: linear (one stream and its guide), app (the station draws it) and multi (one number, several things, a mini guide).
- Commit straight to main. One design question at a time, lettered options with a recommendation.
- Use the review notes honestly: a player for your own IPTV subscriptions and Plex, set up from a Mac. Guideline 2.3.1 rules out hidden features.
1. ChannelSchedule replaces eventGames #
The next job. The goal is that "games" is gone from the screens: on a TV a sport channel is just a multi channel with a schedule. Option (A) was agreed: sport and always-on channels only, shaped so groups can fold in later.
/// What a channel has on, as the control room worked it out.
public struct ChannelSchedule: Codable, Equatable, Sendable {
var channel: IPTVChannel // as scheduled for, like EventGames.channel
public var asOf: Date
public var items: [Item] // in the channel's order: by entry, then start
public struct Item: Codable, Equatable, Sendable {
public var id: String // stable: "game-<streamID>" or "stream-<id>", as OnAir.id
public var title: String
public var detail: String? // the source's own note on the row: "MLB 04"
public var entry: Int // index in channel.entries, for the order of onAir
public var start: Date? // nil: no time (an always-on stream, or a group's member)
public var end: Date? // "live until 5:00 PM"
public var dated: Bool // false: the day wasn't given
public var plays: [Play] // best first
}
public struct Play: Codable, Equatable, Sendable {
public var source: Source
public var broadcast: String // "NFL PPV 4K", "Rangers Broadcast"; copies on other logins share it
public var foreign: Bool // commentary in another language
}
public enum Source: Codable, Equatable, Sendable {
case channel(id: String) // a group's member: unused for now
case stream(id: String) // one of the channel's own streams
case feed(IPTVFeed) // login, stream id and name: all `feeds(for:)` and `FeedChoice` read
}
}
Checked against what the TV reads, the sketch needed these, now in it:
- Stale schedules. A screen plays the last sort however old, and sorts are
up to 30 minutes apart, so the control room never filters by "now". It
publishes every showing as its own timed item, and the TV filters by time:
onAirkeeps itsisLivecheck, and only the sport rules leave. - Broadcasts.
Game.broadcastsandfeeds(preferring:)(used byEventChannelViewandStationMenu) are derived from folder names and quality tags, which is sport logic. The control room names each play'sbroadcast; the TV groups plays by that name in order, and puts the chosen group's plays first with the rest as backups. - Feeds.
Source.feedcarries anIPTVFeed, soiptv.feeds(for:)andFeedChoice.labelneed nothing from the sport's slots. The feed's note ("Spanish", "Away Feed") goes intobroadcast, not a field of its own. foreignis onPlay, so the Feed page can tag it.- The entry.
entryIndex(of:)readsslot.source, which the TV can't see any more, soItem.entrycarries it andonAirjust sorts by it. - A stable id.
Item.id. - A stream's showing. The item's
title, andendfor "live until"; with nostartorendthe row says "always on". A stream with several showings gets one item each. - The row's note.
Item.detail, for "MLB 04", whichdetail(_ game:…)reads fromfeeds[0].slot.event.slot. - Guide blocks.
GuideStorelaysGames.blocksout throughEventSchedule, which is moving toRetroSports(step 4): write the block layout overChannelScheduleitems first, then move.
Users to change, all TV-linked:
Packages/Station/Sources/StationCore/Channels/Events/EventGames.swift.../Channels/IPTV/IPTVChannel.swift:onAir,OnAir,entryIndex,onNow.../Channels/Guide/GuideStore.swift: sport rows andGames.blocksSources/Shared/Channels/Events/EventChannelView.swiftSources/Shared/Channels/Groups/GroupChannelView.swift:GameRowView,GameBarSources/Shared/Station/StationModel.swiftandStationMenu.swiftEventFeedPick, inEventChannelView.swift.../Core/SettingsSync.swift: the keys
PlexLibrary.swift is unrelated: it only matches on the genre "Game Show".
Steps:
- Add
ChannelScheduletoStationCore, and a builder inStationJobsthat turns[Game]andshowsinto it. - Publish both
eventGamesand a newchannelScheduleskey fromEventRefresher, so TVs and the Manager can update apart. Add the key toSettingsSync. - Move the TV callers to
ChannelSchedule. Rename while there: event channel view to a multi-channel name,GameRowViewto an item row, and on-screen "Game" to something neutral. - Move
Game,Games.blocks,Event,EventScheduleandShowingtoRetroSports. The guide's block layout needs a generic version over items.IPTVEntry.folder(EventSource)stays: it's only a folder reference. - Once every TV has updated, stop publishing
eventGamesand remove its key.
Check when done: search the tvOS binary, as for 3149625:
strings -a ".build/Build/Products/Debug-appletvos/Rabbit Ears.app/Rabbit Ears.debug.dylib" \
| grep -cE 'SportSorter|SportJudge|EventParser|ScheduleIndex|RetroSports'
Do the same for EventGames, Game and on-screen words such as "PPV".
2. Stop sending sports data to screens #
sportSettings, eventSchedules, sportSchedule, sportJudged and
sportGuides still reach TVs, which don't read them. This is tidying, not a
review matter: review never sees synced data unless given a demo station.
eventSchedules and sportGuides are the large ones.
- The server can't tell a screen from a Manager:
isManager(device)is about profiles, and a phone with a manager profile is still a screen. A device should say what it is: anapp=query onGET settings, next tobuild, or a kind saved at pairing. - Add
SettingsSync.stationOnlyKeys, and filter them inRemoteServer(GET settings, about line 279) asmanagerOnlyKeysis. - The R2 mirror has two snapshots (
StationMirror.writeSettings): filterwatch. A manager-profile phone readsfulland would still get them. Either accept that or add a third snapshot. Accepting it is simpler. - iCloud: screens on the old route still get them through
SettingsSync.keys. Make the list depend onAppKind, or leave it until iCloud goes.
3. Finish the reorganization: UI packages #
This is what started the work: Sources/Shared shouldn't be a grab bag. The
models, clients, server and jobs have left it, but it still holds 67 files and
about 18,600 lines of views, players and view models, and every app compiles
all of it. Agreed end state: per-app UI packages, Sources/Shared gone, and
the app folders holding only @main, plists and assets.
Do it after sections 1 and 2, so views aren't moved and then rewritten.
Today:
| Folder | Lines | Goes to |
|---|---|---|
Sources/Shared |
18,600 | StationUI and Players, by who uses each file |
Sources/Manager |
9,900 | ManagerUI (done 2026-11-02) |
Sources/iOS |
2,200 | stays the phone's, or a PhoneUI |
Sources/TVApp, Remote, AntennaTower |
under 150 | stay as thin shells |
Likely packages, in Packages/Station or a new Packages/StationUI:
StationUI: the themes' colours and views, the guide, channel screens, menus,StationModeland the other view models (TV, Mac TV and phone).Players: AVKit and VLC, the only target that links VLCKit. Its 3 modules (VLCKit,TVVLCKit,MobileVLCKit) are chosen by platform.ManagerUI: the Manager's windows and panes.
Decide from the code, not this list:
- List which app actually uses each file in
Sources/Shared. A file only one app needs goes with that app. The Manager compilesSharedtoday, but may use little of it: 13 Manager files nameStationModel. StationModelis the knot (about 1,300 lines). Everything UI reaches it, and it reaches players, audio, modules andRemoteLink. Move it withStationUI, and put players behind a protocol soStationUIdoesn't link VLC. Check whether the Manager needs all of it: the assistant was the main reason, and that goes in section 4.- Split
Playersfirst: it's the most isolated (11 files import AVKit, AVFoundation or VLC), and the cleanest dependency to cut. - Then
StationUI, thenManagerUI. One commit per move, every app building. - Rename as you go, using the three kinds of channel: linear, app, multi.
- Move the channel screens onto
ChannelModulewhen touched (docs/channel-modules.md); don't rewrite them for this.
Watch for:
- The
publicpass. The rewriting tools have to be rebuilt first, or use the compiler loop in packages.md. Views needpublicfar less than models: the apps only reach root views, so most of a UI package can stay internal. - Assets and fonts: code in a package still finds
Bundle.mainassets, which stay in the apps' catalogs.Bundle.moduleonly if they move. #if os(...)carries over fine;#if MANAGERand#if RELAYcan't. OnlyManagerMain.swiftandTowerMain.swifthave them, and both stay in the apps.- The tower's target. When the Manager's code leaves
Sources/Manager, make the tower build fromStationServeralone, without VLCKit. just check-tvoslists modules by hand: add each new one.project.ymlneeds each product on each target.
Done when Sources/Shared is deleted, Sources/Manager is a shell, the
tower links no UI, and all four apps build with the checks below.
4. The control room on Linux #
Plan in linux-server.md, stage 6. A headless Manager client:
control-room, an executable inPackages/Station, built likeantenna-tower-server:AppKind.current = .controlRoom, the sameSTATION_DATAhandling (move it to a shared helper), and an image.- First start pairs with the tower, from environment: say
STATION_SERVERandSTATION_PAIR_CODE, usingRemoteLink. It needs a manager profile. - It runs
EventRefresher;isControlRoomalready says yes for.controlRoom. CheckRemoteLink.start()andSettingsSyncwork with no app around, and that a Mac Manager doesn't also run the jobs. - Jev's key needs nothing new:
typesafeAPIKeyis manager-only and already syncs for the jobs, wherever they run. - The assistant, the largest piece: rewrite
AssistantTools(1,400 lines) against the settings and jobs instead ofStationModel, on Hummingbird. Same tool names and arguments (docs/mcp.md). Then removeAssistantServer.
Done: the tower's Xcode target builds from Sources/AntennaTower alone.
5. Getting the server live #
- Read-ahead on Hummingbird.
ReadAheadServer's listener isNWListenerbehind#if canImport(Network); on LinuxstartListenerreturns nil, so titles play from their address. Add a Linux route with range requests. Leave the Apple path alone at first. - CI and deploy. A Forgejo job for
just linux-checkand the image, then the homelab GitOps repo (thedeploy-app-to-homelabskill):network_mode: host, a/datavolume, and the host's/var/run/dbusand/var/run/avahi-daemon/socketforavahi-publish. - A test station beside the Mac mini, with its own R2 prefix and keys, until screens, invites and the mirror check out.
- The move:
antenna-tower import <bundle>from the Mac mini (not written), the new address published, and the Mac's Manager joining as a client. See linux-server.md, stage 4.
Decided:
- Host: luigi, plain Docker, so
network_mode: hostand the avahi socket work as planned. - On Demand downloads: a shared media directory on luigi, mounted into the tower and added as a Plex library.
- VPN route: a Gluetun sidecar. Only provider requests go through its
proxy, so the tower keeps host networking for mDNS. This needs a proxy
setting the provider clients read (
StreamingFetchand the Xtream client); not written.
6. Later #
- The web Manager (linux-server.md, stage 5).
- Fold groups into
ChannelSchedule; splitxtreaminto linear and multi. - The Static Linux SDK, for a smaller image than today's 417 MB.
- On Linux: HEIC posters, the VPN check, tests that need a listener.
- swift-format and SwiftLint's
analyzein the justfile; Periphery is too conservative aboutpublicto rely on. - Fix the two failing tests in
ModuleSettingsTests: they expect no Sleep row, but the row has been unconditional since1199bb1.
Never run yet: the Linux gunzip in GuideFiles, avahi-publish against a
real daemon, and StreamingFetch against a real provider.
How to work here #
just linux-check # needs Docker; makes rabbit-swift-linux:6.3 once
just check-tvos
swift test --package-path Packages/RetroLineup
swift test --package-path Packages/RetroRelay
xcodegen generate
Build each app without signing; the tvOS and iOS schemes need
-destination generic/platform=tvOS or iOS:
xcodebuild -project RetroTV.xcodeproj -scheme RetroTV-Manager -destination platform=macOS \
-configuration Debug -derivedDataPath .build CODE_SIGNING_ALLOWED=NO build -quiet
The Manager's tests must be signed, or the host hangs:
xcodebuild -project RetroTV.xcodeproj -scheme RetroTV-Manager -destination platform=macOS \
-derivedDataPath .build DEVELOPMENT_TEAM=J35P7AJDN7 BUNDLE_PREFIX=tech.phin \
-allowProvisioningUpdates test
Pitfalls met so far:
- The tools that did the
publicpasses (swift-syntax rewriters and scripts) were in a temporary folder and aren't in the repo. packages.md has the recipe;-diagnostic-styledoesn't reach swift's emit-module step, so notes need reading from the drawn output. - A compiler timeout ("unable to type-check…") across modules usually hides a
member that isn't
public. - A memberwise init that's internal shows up as "missing argument for
parameter 'from'": the call fell through to
init(from:). - The default shell is zsh:
$VARholding several paths doesn't split. project.ymlhasRetroTV-Manageras a scheme first and a target later.- The tower's Xcode target compiles
Sources/Manager, so a new module the Manager imports must be linked there too.
Phin Tech docs
Rabbit Ears Manager in the store →