Repository navigation
v0.21.0 — nested groups & folding
FlowView owns the tree. Entries nest to any depth, a parent folds its subtree away, and a parent stays an ordinary entry throughout — same presenter, same gutter, no special-casing anywhere in the view.
group = model.append(ToolCall("search"))
step = group.append_child(LogLine("hit 1"))
model.extend([LogLine("hit 2"), LogLine("hit 3")], parent=group)
group.collapse() # fold the subtree; the header stays
model.set_collapsed_many(groups, True) # many subtrees, ONE reflowRead the shape with entry.parent / children / depth / ancestors() / descendants(). Document order is preorder, and visible_entries() is one O(entries) pass regardless of depth — a folded subtree is contiguous, so it's skipped wholesale.
Folding is O(1) in what you fold
Descendants of a folded parent simply aren't in the laid-out set: no height, no paint, and — if never expanded — no present() at all, so a collapsed-by-default group is free until opened. Folding keeps every descendant's cached presentation, so it never re-presents what it hides. Only the header re-presents, since its body may draw the chevron.
collapsed is independent of hidden
hidden is about this entry (the filtering primitive); collapsed is about its subtree. A search filter and a fold now compose instead of fighting over one flag — unfolding a group does not resurrect entries a filter hid. entry.visible reports the combination.
Fold keys
Under the existing vim z prefix: za (toggle), zo, zc, zR (unfold all), zM (fold all). za/zo/zc act on the current entry if it heads a group, else the nearest ancestor that does — so they fold the group you are in, as in vim. All callable directly (toggle_fold(), close_all_folds(), …). New FlowView.Collapsed message.
Breaking
FlowPresenter.presentreceives theEntry, not the item:async def present(self, entry: Entry[T], width: int). Migration is mechanical — readentry.itemwhere you readitem. Once FlowView owns depth and fold state, a body that indents or draws a ▸/▾ chevron has no other way to see them, and mirroring them into your item would be the same fact stored twice. It also removes the long-standing asymmetry withFlowDecorator.decorate, which always took the entry.insert/insert_many's index is a position among siblings. Identical for a flat model; only meaningful once you passparent=.- Removing an entry removes its subtree — a child cannot outlive the parent that positions it.
Worth knowing
FlowView { scrollbar-gutter: stable; }A fold that shrinks content below the viewport height removes the scrollbar, which widens the body — and width is part of the presentation cache key, so everything re-presents. Measured on a 50-entry group: 0 presents with the gutter reserved, 12 without. Not fold-specific (hide() did it too), and not something FlowView can paper over, since the width genuinely changed.
FlowView never indents, never draws chevrons or tree guides, and never renders a parent differently. entry.depth is data; the drawing is yours. See examples/groups.py.
Also fixed: README's "Keys & focus" claimed FlowView "defines no BINDINGS of its own", which stopped being true in 0.14.0.
Closes #13. Full changelog: https://github.com/tya5/textual-flowview/blob/main/CHANGELOG.md