Derive chrome budgets from an explicit fixed-row list - #375
Conversation
provider-setup.ts's listHeight() subtracted a flat 14 from the terminal height, justified only by a comment naming roughly nine rows plus slack — a guess that had to be re-guessed by hand whenever a row was added or removed. shell.ts already avoids this by summing its ZoneId budget from PAINT_ORDER, so factor that reducer into a shared geometry/chrome-budget.ts and have both call sites use it. provider-setup.ts now names each fixed row it reserves in a CHROME_ROWS list and derives its budget by summing it. A test mounts the surface and checks root's child count against CHROME_ROWS plus the alternate-step rows, so a row added to root without a matching entry fails there instead of only showing up as garbled text on a short terminal. landing.ts mounts its boxes into zones shell.ts already sizes via PAINT_ORDER, so it carries no fixed-row budget of its own. stream.ts has no renderable tree at all. Neither needed changes.
|
Parking this. The derived chrome budget ships a regression: The child-count test cannot catch it: a row added to This approach was also already tried and reverted on main today for the same underlying reason. Main now carries the flat |
Summary
provider-setup.ts'slistHeight()subtracted a flat14fromthe terminal height, justified by a comment naming roughly nine
rows plus unspecified slack — a guess re-guessed by hand whenever
a row was added or removed.
shell.tsalready avoids this: it sums itsZoneIdbudget fromPAINT_ORDERviaresolveGeometry. That reducer is now factoredinto
src/tui-opentui/geometry/chrome-budget.ts(chromeBudget),and both
resolve.ts'ssumChromeandprovider-setup.ts'slistHeight()call it.provider-setup.tsnow names each fixed row it reserves in aCHROME_ROWSlist and derives its list-viewport budget by summingit, rather than carrying a magic integer.
root's childcount against
CHROME_ROWS(minusroot's own padding) plus thenamed alternate-step rows (
loginBox/inputFrame/telemetry), soa row added to
rootwithout a matching entry in either list failsthere — structurally, not just as garbled text on a short terminal.
landing.tsandstream.tsper the issue:landing.tshands its boxes to
shell.ts, which places them inside zonesresolveGeometryalready sizes, so it carries no fixed-row budgetof its own.
stream.tshas no renderable tree at all (puredata/layout functions). Neither needed changes.
provider-setup.tsthroughresolveGeometry—that screen runs before a shell exists and was examined/rejected
on real grounds; this stays the narrower convergence the issue
asks for.
Stacks on #370 (
cl-5412-picker-scroll, still open/unmerged),which already adds
flexShrink: 0toprovider-setup.ts's twelvedirect root children and replaces the flat
12inlistHeight()with its own local named-term derivation. This branch was cut from
origin/mainbefore #370, so it still touches the flat magicnumber rather than #370's local derivation — expect a merge conflict
in
listHeight()when #370 lands; the fix is to point #370's localsum at the shared
chromeBudget(CHROME_ROWS)helper added here.Verification
bun run typecheck— passesbun run build— passesbun run test(canonical, excludesvendor/) — 4038 pass, 0 failbun test ./src ./tests ./evals --randomize --seed 42— 4038pass, 0 fail (run twice to confirm stability)
provider-setup.tsat 24/16/12/8/6 rows via the headlessharness before and after the change: output is byte-identical
between the old flat-
14budget and the new derived one at everyheight tested (the derived budget still lands in the same
[LIST_ROWS_MIN, LIST_ROWS_MAX]clamp range). One renderingartifact at height 24 in the ad hoc capture script reproduces
identically on unpatched
origin/main, so it predates and isunrelated to this change — not something this issue's scope covers.
Closes CL-5599