Repository navigation
Answer "on screen" and "cover room" once, and give packages the place hold - #1013
Conversation
… hold Three surfaces still measured for themselves what #982/#992 made shared. - On screen: `shownRect`'s clip walk now applies each ancestor's visible band, its shown band less the `.lf-pinned` covers stuck in it, so every reading built on it (read acknowledgement, the thread card's being-read check, arrival checks, chrome placement) answers the same way. The thread card had asked only `leaf-thread-list`, so on any other surface it saw nothing being read. read.js drops its own thread-list special case. A cover counts only for the scroller it sticks in, and never hides itself or what it holds. - Cover room: `declareCoverRoom(host, property, covers)` in geometry.js observes the covers and keeps the tallest's height on the host for a `scroll-padding` or `scroll-margin` to read. The thread list's run headings and each `lf-diff` file header use it, replacing two hand-rolled ResizeObserver paints. Observing the covers rather than reading them at reconcile forces no layout, so the thread list no longer needs its panel-open gate. The diff's row `scroll-margin` now applies only where its header pins. - Place hold: widget-api exports `placeKeeper` and `declareCoverRoom`, and packages.md documents both. No package hand-rolled place preservation. Behavior that moved: `--lf-head-room` is the heading's exact rendered height rather than a rounded `offsetHeight`, so `test_the_room_a_run_heading_takes_follows_the_reader_drawing_the_panel` compares numbers. Chrome no longer counts a box under a stuck run heading as shown. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
left a comment
There was a problem hiding this comment.
geometry.js now says shownRect "is the one reading of whether something is on screen", and skills/leaf/assets/AGENTS.md names each lf-diff file header as a cover beside the thread list's run headings. The reading cannot see that cover. coversOf finds covers with scroller.querySelectorAll(PINNED) and bandLess decides ownership with cover.contains(item); neither crosses a shadow boundary, while clipped's own walk does (a.parentElement ?? a.getRootNode()?.host). lf-diff's <summary> sits in a shadow tree and wears no .lf-pinned, so a row stuck behind its file header still reads as shown and chrome placed on shownRect paints behind the header. The cut reaches packages too: references/packages.md now hands declareCoverRoom to package authors, whose covers live in shadow trees by construction, so a package cover can take landing room and can never take band. So of the two covers this PR declares, one participates in the unified answer and one cannot — either let declareCoverRoom be what makes something a cover for both readings, or say in the geometry header that the on-screen reading sees light-DOM .lf-pinned only. (containsAcross in passages.js is the crossing form of that contains call.)
clipped caches covers as elements rather than rects, so bandLess reads getBoundingClientRect() on every cover of every covered ancestor once per item. The comment above shownRect states what the cache is for — "two style reads per ancestor rather than two per item per ancestor" — and a cover's rect is as stable across one pass as its band is. Read acknowledgement walks every rendered body against the list's whole heading set on each pass, which is the shape that cost before. Caching [cover, rect] pairs in the clips entry keeps the item filter and drops the per-item reads.
The panel-open gate is gone and nothing takes over what its second half was holding. The removed comment called it "a rule rather than an optimization": shut, every heading measures zero, so the number written is the absence of a panel rather than the room a heading takes. The observer writes exactly that number now — in Chrome an ancestor going display: none delivers a resize with blockSize 0, so --lf-head-room becomes 0px while the panel is shut instead of holding the last real measurement. Reopening restores it, but requestAnimationFrame callbacks run ahead of the resize-observer steps in the same frame, so a frame the opening gesture schedules still reads 0px. Observing genuinely answers the forced-layout half of that rationale; this half wants a sentence saying why it stopped mattering, or a retained value.
The review of #1013 found that the on-screen reading found covers by querying light-DOM `.lf-pinned`, so `lf-diff`'s file header, which lives in a shadow tree, took landing room but never counted as covering its rows. The declaration is now the definition: `declareCoverRoom` registers each cover, `visibleBand` and the clip walk read the declared covers, and both ownership (the scroller a cover sticks in) and self-exclusion climb out of shadow trees. `lf-diff` declares its headers only where they pin. The clip walk also builds each pass's cover boxes once, so read acknowledgement no longer reads every heading's rect per message. A cover that stops rendering keeps the room it last measured, so a frame that runs before the panel's reopening is observed still reads the room. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
left a comment
There was a problem hiding this comment.
declareCoverRoom is now the one door a box becomes a cover through, and coversByScroller can shut it permanently. When a clip pass sees a declared cover detached, letGo drops it from declaredCovers and unobserves it, but leaves the host's room.covers entry standing — unlike the observer's own !target.isConnected branch, which pairs letGo with room.covers.delete(target). declareCoverRoom then skips re-registration for anything prior already holds (if (prior.has(cover)) continue;), so the same element put back and re-declared is never added to declaredCovers again and never observed again. The band stops excluding it while --lf-head-room keeps the height it last measured: the cover still reserves landing room, and chrome, read acknowledgement and arrival checks go back to calling what passes under it shown — the split this PR exists to close, reappearing silently in the direction that looks correct.
Against caeac74a, under tests/runtime/'s DOM:
scroller.append(heading);
declareCoverRoom(scroller, "--lf-head-room", [heading]);
assert.equal(visibleBand(scroller).top, 30); // passes
heading.remove();
visibleBand(scroller); // a clip pass while the node is out
scroller.append(heading);
declareCoverRoom(scroller, "--lf-head-room", [heading]);
assert.equal(visibleBand(scroller).top, 30); // fails: 0The eager release is what breaks the pairing, and the observer already does the job without it — that is what the removed comment ("Leaving the document is a resize to nothing, which is where a cover whose host went with it stops being observed, so a re-render needs no release") named, and the !target.isConnected branch still honours it. Skipping the detached cover in the pass is enough; the inline suggestion is that.
I could not name a shipped path that reaches it: renderThreads, stageManifest and loadManifestEntry's entry.details.replaceChildren(entry.details.firstElementChild, …) all put the node back inside the same task, so no clip pass interleaves. It is declareCoverRoom as public API that carries the risk — this PR exports it through widget-api.js and documents it in references/packages.md, and a package that reattaches a cover across an await (a header swapped in after a fetch, a two-frame reveal) and re-declares it gets a box that reserves room and covers nothing, with no error anywhere.
Separately, holds(cover, item) is under(item, cover) from ./shadow.js — seven lines below the upFrom this commit started importing from that same module. containsAcross in passages.js and its private copy in visual-parts.js are two more of the same walk; calling under keeps the count where it is rather than adding a fourth.
The other three points from the last round are answered: the shadow-boundary cut closes through stuckIn/holds climbing with upFrom and lf-diff declaring its summaries, the per-item rect reads collapse into the COVERS entry on the clips map, and the checkVisibility() gate in the observer retains the room across a shut panel.
Selection run here
npm run test:runtime 76 passed; tests/test_render_read_state.py 18 passed; tests/test_render_conversations.py -k "head_room or read or pinned or cover" 53 passed.
The second review of #1013 found that a clip pass released a detached cover from the declared set while its host still listed it, so the same node put back and declared again was never registered or observed again: it kept reserving landing room while no longer counting as covering anything. The pass now only skips a detached cover, and the observer alone lets covers go. Self-exclusion uses `under` from shadow.js instead of a fourth copy of the walk. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…nd use one shadow climb (#1028) The root `lf-tabs` strip becomes a declared cover, and one reading of "stuck" makes document covers count at all. Private copies of the shadow-crossing climb and containment check now use the ones in `shadow.js`. ## Causes - **The root strip measured its own room.** `lf-tabs` kept `--lf-root-tab-clear` with its own `ResizeObserver`, so the strip was never a cover: the on-screen readings (`shownRect`, read acknowledgement, arrival checks, chrome placement) counted what it hid as shown. - **Document covers never counted as stuck.** `insetBand` took a cover as stuck only when it straddled the scroller's top edge. A document's covers stick under the banner at `top: var(--lf-banner-h)`, so they never reach the root's edge. Measured on the root-tabs fixture, with the strip stuck at 42–89px, `visibleBand(document.scrollingElement).top` stayed 0. The same holds for each pinned `lf-diff` file header in the document, which #1013 declared, so that declaration had no effect in any live page. - **Containment had three spellings.** `passages.js` exported `containsAcross(ancestor, node)`, `visual-parts.js` kept a private copy of it, and `projection/data.js` had a third (`containedBy`). `shadow.js`'s `under(node, root)` answers the same question. The parent climb (`upFrom`) was also restated in seven places, "the node's stand-in in tree X" in three, and the rendered-tree climb through slots in two. ## Changes - **`lf-tabs`** declares its strip through `declareCoverRoom(document.documentElement, "--lf-root-tab-clear", …)` while it is the root set, and withdraws it when it stops being root. Only a set that declared withdraws, so a tab set nested in a root panel cannot clear the root's strip. The hand-rolled observer and the clear-on-disconnect path are gone, because a cover that leaves the document is let go on its own. - **`insetBand`** also counts a cover as stuck when it sits at or above the sticky inset it is held at (`stickyTop` / `stickyBottom`, read from the cover's computed style in `coversByScroller`). A stuck cover takes the band from the edge to its foot, including the inset, which is the room kept clear for the banner. The straddle rule still applies, so the thread list's negatively inset run headings behave as before. - **`declareCoverRoom` measures a host's first covers as they are declared.** A first observation arrives after the frame's layout. The old `lf-tabs` code wrote the strip's height during its own render, so the initial fragment landing read `--lf-root-tab-clear` as `0px` and stopped a strip's height short. A cover that replaces another starts at the room its host already keeps, so a thread-list reconcile still forces no layout. `leaf-agent`'s review found this, and a runtime fold test pins it. The test fails with the measurement removed. - **`declareCoverRoom`** registers its property through `setRuntimeRootStyle` when the host is `<html>`, so revision activation treats it as runtime-owned, as the old `lf-tabs` code did. - **Containment cutover.** `containsAcross` and its copies are deleted, and every call site uses `under(node, root)`, with the argument order swapped. Its rationale comment moved beside `under`. Private `parentAcross`, `up`, and inline `parentElement ?? getRootNode().host` climbs use `upFrom`, including those in `render-checks/` through `widget-api.js`. A new `hostIn(node, root)` in `shadow.js` replaces the three "climb out until this tree" loops in `passages.js`, `asks/view.js`, and `conversation/placement.js`. A new `renderedParent` (the slot a slotted node renders in, else `upFrom`) replaces the two rendered-tree climbs in `anchor-travel.js` and `margin-projection.js`. - **`scrollerFor`.** The code is right: a widget in a reply resolves to `.lf-threads`, checked in the browser, because `mountPanelReadingRegion` registers the list as the panel's bounded reading region. The comment now says why. ## Behavior that moved - Content under a stuck root tab strip, or under a stuck `lf-diff` file header in the document, now reads as off screen. While such a cover is stuck, the banner band above it reads as off screen too. `test_a_stuck_root_tab_strip_hides_what_passes_under_it` pins the strip case, with the unstuck strip at the page top as its control. - After the root set leaves, `--lf-root-tab-clear` stays at `0px` instead of being removed. The theme's fallback is `0px`, so nothing reads the two differently. ## Left as is Where no cover is stuck, the banner itself is still not a cover: content under the translucent banner reads as on screen. Making the banner a cover of the root is a product call about the veil, and it would move every on-screen reading near the page top. ## Tests - `npm run test:runtime`: the `insetBand` fold gains the sticky-inset case, both stuck and passing through. - New browser test above. After merging main, focused `--run-nightly` runs of the widgets, navigation, anchors, projection, and read-state files: 628 passed. An earlier run before the merge also covered the conversations and controls files, with one failure that failed the same way on the merge base. Everyday `uv run pytest tests`: 1373 passed. - pre-commit. > _This was written by Claude Code on behalf of max-sixty_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Three surfaces still measured for themselves what #982 and #992 made shared.
Changes
shownRect's clip walk now applies each ancestor's visible band: its shown band less the covers stuck in it. Every reading built onshownRectanswers the same way: read acknowledgement, the thread card's being-read check, arrival checks, and chrome placement. The thread card had only askedleaf-thread-list, so on any other surface it found nothing being read.read.jsdrops its own thread-list special case. A cover belongs to the scroller it sticks in and never hides itself or its contents. Both of those checks climb out of shadow trees.declareCoverRoom(host, property, covers)ingeometry.jsis now the one way a box becomes a cover. It registers the covers for the visible band, observes them, and keeps the tallest one's height on the host, where ascroll-paddingorscroll-marginreads it. The thread list's run headings and each pinnedlf-difffile header now use it in place of two hand-rolled ResizeObserver paints. Because the covers are observed rather than measured at reconcile, no layout is forced. A cover that stops rendering, for example when the panel is shut, keeps the room it last measured. The diff's rowscroll-marginnow applies only where its header pins.widget-api.jsexportsplaceKeeperanddeclareCoverRoom, andreferences/packages.mddocuments both. No package was hand-rolling place preservation.lf-board'sscrollTostops an in-flight smooth scroll; it does not hold a place.Behavior that moved
--lf-head-roomis now the heading's exact rendered height, not a roundedoffsetHeight.test_the_room_a_run_heading_takes_follows_the_reader_drawing_the_panelnow compares numbers.test_pressing_a_page_mark_stands_in_the_thread_it_opens[long]This test passes on 89902be. I bisected it: it fails at 591e06a and passes at 6802d69 (#999). #999 re-lands the reply in a microtask after a read receipt, because read acknowledgement reflows the prose the reader was just landed in. The unread rail's 8px inline inset and the read boundary both change layout. This PR leaves that re-land in place. Making read marks layout-neutral would change how read and unread messages look.
Tests
npm run test:runtime: 76 passed. A new case covers cover ownership and self-exclusion; I confirmed it fails when either rule is removed.uv run pytest tests: 1368 passed.--run-nightlyacross chrome contracts, navigation, read state, conversations, anchors, margin, widgets, controls, projection, aim, commands, options, gate, and drafts: 1323 passed after the head-room test fix.🤖 Generated with Claude Code