Status: done (2026-11-25)
Priority: 3
Size: M
Arch: debt
Phase: implement
Design ref: The player, commands and views (Family tree: shows the genealogy of any entity, from one pawn to a whole culture: Decided; Performance: must stay fast: Decided, how Open; Keeping the family tree fast: Proposed); Claims, ownership and territory (One scope model: Agreed, 30 Oct).
Goal: layoutTree in src/page/treelayout.js lays out every pawn ever born on each open and draws every node. It takes about 10 ms for the 818 founding pawns of populous medium, and calls S.unions.filter per pawn, inside a sort comparator too, so it grows with pawns × unions; a 150-year run holds several thousand records and the SVG holds a node for each. Show the tree for a scope (VB-043) and draw only what is on screen. Depends on VB-043; if it is not done, mark this blocked.
Touches: page/treelayout (layoutTree, layoutScope, layoutLine, findPath, layoutPath); page/family (treeLinks, renderTree, drawTree, centreTree, pickTreeChip, pickTreePerson, renderTreeInfo); sim (Sim); src/body.html; tests/smoke.js
Acceptance criteria (draft, pending QUESTIONS.md, VB-095):
st.unions or st.pawns.docs/slices.md, section 3.5; the slices Decided by Kim): moved to slice 5, arch debt (from claims). blocked until the slice’s plan (VB-184) confirms, rewrites or closes it; its questions in QUESTIONS.md wait for that plan, which may reframe them.src/page/family.js, layoutLine): the tree opens on the selected pawn’s line (ancestors 2 up and 1 down, father’s line, mother’s line, descendants), siblings and further generations fold behind chips that open in place, and “Everyone” keeps the old whole-tree layout. Populous tiny, seed 7, in Chromium: year 40 (463 records) 3.8 ms a render against 98 ms for everyone; year 60 (759 records) 9 ms against 565 ms. Still open here: scope levels (household, village, culture), the indexes for the whole-tree layout, and drawing only what is on screen.src/page/treelayout.js, findPath): “Path to…” or a shift-click draws the way from the selected person up to the nearest shared ancestors and down to the other, or, with no shared ancestor, the shortest chain of parents, children and spouses; a caption names the relation and the kinship coefficient. Populous tiny, seed 7, year 40: 4.3 ms a render. Kim, 9 Nov: with no pawn selected the tree should open on the player’s pawn, once the player has one (today it shows everyone).QUESTIONS.md (“VB-095”: what the tree opens on) stands as proposed and is not reframed by slice 5: the village level reads VB-043’s graph. Waits for VB-043 (and through it for Kim’s bodies decision).
Notes:layoutTree is in src/page/treelayout.js (still S.unions.filter per pawn), as is layoutLine (called from src/page/family.js), and the design ref points at v0.4’s section 15; of criteria 1 and 2 the line view delivers the selected pawn’s line, 2 up and 1 down, as the default, its mode buttons and chips that open in place, while the village as default, the household, village and culture levels and folding outside a scope remain open.Sim.inScope (dim claims: the people are the same under every dimension but kin’s, and it is the cheapest), their spouses, 2 up and 1 down; a shown person’s unshown children fold behind “+ n more” under them (kids:<id>), folded again only by a change of level or person; “Earlier generations” raises up.layoutTree takes an optional subset and chips, and reads Sim.spousesOf (added to the facade) and the child index; every view’s links are treeLinks, with boxes; drawTree draws only what falls in the scroll window plus 600 px, again after a pan of half that; a page with no layout (jsdom) draws everything. tests/smoke.js checks the scopes, a chip and the windowing.findPath and layoutPath read Sim.spousesOf too, so no tree layout passes over st.unions (smoke checks the source); a dead person chosen is shown but not counted among a scope’s living. Declined: keyboard reach of nodes outside the window (Tab meets only what is drawn; the person chosen stays drawn).