~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/hud

A remote MCP server that shows atproto records as interactive UI inside MCP Apps hosts

0
0

A feed in the web shell pages as it is scrolled

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/hud:web/auto-page

A feed, grid or camera in the web shell (next.grain.social) loads its next page by itself as you scroll near its foot, as Grain's iOS and Android apps do. The Load more button stays as the fallback.

Claude Opus 5.5 · high

What changes

Paging on scroll: where a screen's tree has a next, its LoadMore foot watches itself with an IntersectionObserver against the level's own scroller (its nearest ancestor that scrolls, view/window.ts's scroller, now exported), its margin a screen below (rootMargin: 0px 0px 100% 0px). As it comes within that, the next page loads, with no button press. LoadMore takes auto for this. The shell's Stack sets it for the level in front alone (inFront): the sheet's while one is open, otherwise the top of the stack with no pager over it, in the tab on show, and not while its call is made again (refreshing, or swapped).

When it doesn't load: while a page is on its way (the observer is let go and made again once the page lands, so a page too short to fill the view brings the next), after an error (the error shows with Try again, and nothing loads until it's pressed), under another screen or inert, and where navigator.connection.saveData is set (the button alone pages). It starts only in an effect, so the page the server draws is the page hydrated.

The button: stays in every case, for the keyboard, screen readers, a page with no script and errors.

docs/views.md (The frame) says so, and a patch changeset is in .changeset/.

Why

The web asked for a button press each page where the native kits page as the foot comes near (Grain's iOS LevelScreen.swift, .onAppear on the foot, and Android's LevelScreen.kt, within 2400 px of the end). An observer on the foot, re-made after each page, keeps it to one page at a time without a scroll listener, and opt-in auto keeps LoadMore's other hosts (the MCP view in a frame, which its host sizes to its content, and the workspace's tiles) as they are.

Other lists: a screen's one paged list is its tree's page list (List, Covers, Gallery or Player), which this covers, grids included. Messages keeps its own "Load earlier messages" button at its top, as HUDKit's and the Android kit's do. Grain's Explore grid is a join of 18 with no next, so nothing pages it on any platform.

How it was checked

  • npm run check, npm run unit, npm run ssr, node harness/docs.mjs.
  • web/shell/test/ssr.mjs adds a long feed in the browser with a fake IntersectionObserver: its foot shown loads the next page once (shown twice at once, one call), a screen over it (inert) loads nothing, a failed page shows its error with Try again and loads nothing more when shown again, and Try again loads the last page and the foot goes. With auto taken out of the Stack, it fails.
  • Chromium (Playwright) against a local build: a release HUD (HUD_WORKSPACE=off, HUD_APPS Grain's next/ from origin/feature/hud) and Grain's next/ built on this branch's packed @hud/*, signed out, at 390 and 1440. Scrolled by the wheel alone, Home, chadtmiller.com's profile grid and the Apple iPhone 16 Pro camera each loaded two pages more with no button pressed, and an element in view at the moment each page was asked for was at the same place (0 px) once it appended. Explore has no Load more to page.

Shortcomings

  • Explore's grid doesn't page (Grain's view, a fixed 18).
  • Not run here: just check's Rust side and e2e (no Rust changed), left to CI.

autopage-camera-1440-page2.png

Approved

This adds an opt-in auto prop to LoadMore. With it set, an IntersectionObserver on the foot loads the next page once the foot is within a screen of the scroller. The shell's Stack sets auto only for the level in front and settled (inFront).

I read the whole diff and found nothing that must change.

  • Effect: it re-runs when loading, error or auto changes. That gives one page at a time, a fresh observer after each page, and a stop on error until Try again. The foot is only observed inside $effect, so SSR and hydration are unaffected.
  • Scroller: scroller() returns null for the page. A null root with a percentage rootMargin then uses the viewport, which is what you want there.
  • Checks: the ssr test covers one call when the foot is shown twice, no load under an inert screen, and no repeat load after an error. The docs page and the changeset are both present.
  • Not run: I didn't run the checks or the Rust side. The body says just check's Rust side and e2e are left to CI.
Merged as 511366c