chadtmiller.com/hud
A remote MCP server that shows atproto records as interactive UI inside MCP Apps hosts
place.hud.hudkit 0.3.0 Latest 5 packages
0
0
Shell test: a back supersedes the shell's move still settling
Merged Approved
This makes the test's fake History behave as a browser's router does. go() now counts each back or forward. A move still settling when the browser goes back or forward no longer sets here over the entry gone to. That removes the stale-here state you traced to the "back from the story linked" failures.
I read only the diff, web/shell/test/history.svelte.ts and the repository's AGENTS.md. I did not run the test or read any check results.
- Counter timing:
wentis read after the entry is made and just before the settle timer starts. A back pressed any time after that point suppresses the stalehere. - Later moves: a move started after a back captures the new count, so it still sets
herenormally. - Change file: skipping one is right, since only test code changes and no app built on HUD sees it.
All checks have passed
8 passed
Merged as 31425ed
The shell's server test (
web/shell/test/ssr.mjs, CI'swebcheck) failed now and then on a busy machine at "a story's URL: never: back from the story linked", as on A record with no facets has its links, mentions and tags found at both its heads. The fault was the test's fake history, not the shell: a move of the shell's still settling as the test pressed back set its state over the entry gone back to, which a browser's router never does. Under load the test failed 5 of 48 full runs before, 0 of 144 after.Claude Opus 5.5 · high
What changes
The test's history (
web/shell/test/history.svelte.ts): the browser's back or forward (History.go) now comes after a move of the shell's still settling, as a browser's does: that move, once it settles, no longer setshere, sohereis always the state of the entry the browser went to. Nothing the shell does changes, so no change file.Why
A story opened from a link is two moves: the push that opens the viewer, then, as its Slides draws the story, the Pager telling it (
onat), an entry in place of that one with the story shown. The fake makes an entry a microtask after it is asked for and setsherea timer later. The test polls every 20 ms and presses back once the story is drawn and the URL is its. On a busy machine its poll's timer and the fake's settle timer come due in the same turn, the poll's first, so back landed between the in-place entry and itshere: the fake then sethereto the story's state with the history at/, and the shell, as it must for an entry come to, opened the viewer again, and the wait never saw it close. Every failure caught had that state: at/,herethe story's. The step before it, back after Next on a story opened from the strip ("the browser's back left the viewer"), fails the same way, less often.In a browser this order cannot happen: Grain's host goes by SvelteKit 3.4's shallow
goto, which makes the entry (history.replaceState) and setspage.statein the same task, with only microtasks between (resolve_intent, theonNavigatecallbacks, of which Grain has none), and a back is a popstate task of its own, after it. So the shell's back from a story, opened by a link or loaded at its URL, does land; it was the fake that did not hold to that.Considered instead: waiting in the test for each move to settle before each back (two steps patched, and every back written later needing it too); and leaving out the shell's in-place entry where the story shown is the one the viewer opened at (its URL the same), which changes the shell to suit a fake, and Next still makes one.
How it was checked
On an 8-core Mac under load (16 copies at once beside 8 to 16
yes):node shell/test/ssr.mjs), 16 at once: before, 5 of 48 failed, each at "back from the story linked"; after, 0 of 144.setImmediateuntil the in-place entry is made and itshereis not set): before, 20 of 20 failed; after, 0 of 20.npm run check,npm run ssrandnpm run unitpass. The rest is CI's.Shortcomings
A host whose router sets its state a task or more after the entry (SvelteKit with an
onNavigatethat waits, as for a view transition) could set a story's state after a back from it, and the shell would open the viewer again: it cannot tell that late state from an entry come to. Grain has no suchonNavigate.