Epic: #113 · Milestone: MC7 — TV shell
Why
There is no pointer in the living room. ~/Code/Tools/craft/packages/zig/src/tv.zig (1,154 lines) implements a tvOS/Android-TV-style focus engine — the semantics to port into HomeOS Craft (kernel/src/lib/craft_lib.home), per the HIG in #50.
Tasks
- Focusable widget attribute; spatial candidate search (distance + alignment + overlap weighting, direction cones), explicit
focus-up/down/left/rightoverrides, focus traps for modals, focus memory per container, default focus per screen. - Input pipeline: key events from keyboard/CEC/HID/IR/phone normalised to the remote grammar (
Up, Down, Left, Right, Select, Back, Menu, PlayPause, …+ long-press after 500 ms + repeat), one dispatcher, screen-level handler chain, global shortcuts (Home, Menu). - Back stack / router: push/pop screens with transition tokens; deep links used by the phone remote.
- Scroll: focused-item-centred scrolling for rows, paging for grids, virtualisation with an overscan of 1 row.
- Focus animation (scale/shadow/parallax) driven by motion tokens; reduced-motion switch.
- Headless tests: a scripted key sequence over a fixture screen must land on the expected element (QEMU x86 + host unit tests of the pure logic).
Acceptance
Fixture screens (grid, rows, modal, OSK) pass the scripted-navigation tests; input-to-focus-change ≤ 1 frame in the histogram.