Skip to content

v0.22.0 — fold before the first child, and no more "Loading…" flicker

Latest

Choose a tag to compare

@tya5 tya5 released this 14 Aug 23:44

Checking #14 (filed by reyn) confirmed the report — and verifying it turned up two more defects, one of them worse than the reported one.

1. A group can be declared folded before its first child exists (#14)

set_collapsed silently discarded the state on an entry with no children, so "this group starts folded" could not be said at the moment it was known. A host had to watch its own append_child and fold on the first one.

One guard was doing two jobs — recording the intent, and skipping a redraw that would change no pixels — and the second erased the first. Now the state is recorded on any live entry, and only the notify/re-present half is skipped:

group = model.append(ToolCall("search"))
group.collapse()                       # no children yet; the intent is kept
group.append_child(LogLine("hit 1"))   # born folded

The issue's Proposal A, essentially as written. Good report — the deferred-application argument (an entry's own collapsed never affects its own visibility, only its descendants') was exactly right.

2. A parent now re-presents when it gains or loses a child

Since 0.21.0 the presenter receives the entry, so a header's body may draw entry.children — a ▸/▾ chevron, a "12 steps" count. Nothing invalidated that presentation, so a header kept rendering group (0) with no chevron forever after its first child arrived. Child insertion and removal now bump the parent's revision, on the same reasoning that already applied to folding.

3. update() no longer blinks the entry through the "Loading…" placeholder

The worst of the three, and pre-existing rather than new.

_band_ids is only refreshed by _present_visible, which a plain append never calls — so an entry presented by the paint path was classified off-band while fully on screen, and update() took the off-screen branch and released its presentation. Every streamed chunk painted a frame of the placeholder over content the reader was mid-sentence in.

Measured: 5 of 5 immediate paints after update() rendered "Loading..."; now 0.

Two changes — band membership is computed rather than read from a set that may be stale, and a re-present keeps drawing the previous body until the new one lands. The placeholder is for an entry that has never had a body, not for one that has.

Consumers streaming via patch_rows were unaffected, since that path stores synchronously. The memory optimisation the band check exists for is intact and now covered by a test: an entry genuinely out of view still releases its body on update().


222 tests, mypy strict, ruff — green on Python 3.11 / 3.12 / 3.13.