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

grain.social/grain

photography-focused photo sharing platform

grain.social
1 collaborator
0
2

next: closing someone's stories returns to their profile, not Home

Merged
Merged chadtmiller.com asked to merge into feature/hud from grain.social/grain:next/pager

What changes

Closing someone's stories returns to their profile. Tapping a profile's ringed picture opens their stories in the pager. Closing it (✕, Escape, a drag down, or the last story running out) now returns to exactly the screen it was opened over, at the same scroll, one history entry back. The browser's back from the pager does the same, and Back again goes to whatever was under the profile. Before, if a second close arrived before the first had landed, it went back two entries, which for a profile pushed over Home meant Home's feed.

This is vendor/hud at HUD 2d75abe (app/shell).

Why

The cause: the pager's close() had no guard. Every call animated, then ran onclose → the shell's back() → history.back(). Asking twice within the 300 ms the close animates went back twice. Ways that happens:

  • ✕ then Escape, or ✕ twice;
  • a story running out (the Slides timer calls onend → past the last page → close()) while ✕ is tapped. Slides' timer re-fires onend whenever its effect re-runs once full.

Evidence: in Chromium, signed in through a stand-in HUD, on /profile/gabrielpm.bsky.social (who has a story), ✕ then Escape on the pager landed on / with 1 level. The new shell SSR test, run against the old shell, fails the same way: "a screen pushed over Home: closed, it is at / with 1 levels, not back at /stories with 2".

The fix is in two places, so any repeated close is safe:

  • The pager closes once (closing).
  • The shell's back() takes one step per history entry: a second back asked from the same entry before the first lands does nothing.

How it was checked

  • HUD: svelte-check (0 errors), npm run unit (17 pass), the renderer and shell SSR tests, and the docs lint. The shell SSR test adds the pager opened from Home's root, from a screen pushed over Home, and from that screen loaded again (the server's two levels). Each is closed by ✕, ✕ and Escape at once, and by the browser's back. All return to the screen the pager was opened over, one entry back.
  • Chromium, signed in via the stand-in (a release HUD at app/shell's head answering as no one, given a viewer; a sealed session cookie), with this shell:
    • profile by URL: pager, ✕ then Escape, ✕ twice, the story running out, and the browser's back all return to the profile (2 levels);
    • profile pushed from a gallery's author (3 levels): ✕ returns to the profile; the browser's back from the pager returns to the profile, then Back again to the gallery;
    • profile pushed over Explore's people search: ✕ returns to the profile on Explore;
    • the profile's scroll (55 px) is the same after ✕.
  • Grain iOS: StoryPager closes through Shell.closeStories(), which is guarded (stories != nil) and only clears the full-screen cover. It never touches the navigation path, so the pushed LevelScreen stays. No change needed.
  • This branch: node check-apps.mjs, svelte-check, node --test src/lib/*.test.ts and npm run build in next/.

Shortcomings

  • The Home stories strip (close → Home) is covered by the SSR test (Home's root) but not in Chromium. The stand-in answers feeds as no one, so it draws no strip.
  • Slides re-firing onend once full is left as it is in the renderer. The pager and the shell now ignore the repeats.
  • hud-next needs nothing first: no app-file keys change.
Approved

This pull updates the vendored HUD to 2d75abe. It adds a closing guard to the pager's close(), and a left guard to the shell's back(), so a repeated close takes only one history step. The diff is small and matches the cause the body describes: close() could run twice inside the 300 ms animation, and each run called history.back(). I read the whole diff. It touches three files and I read all of them. I did not run anything.

One thing to check upstream in HUD, not here: left is never cleared. If navigation.here returns the same object when someone goes back, then forward to that entry, and then back again, that second back would be ignored. The same would happen if an in-stack up() kept the same entry object. I could not confirm either from the diff. enter() builds a new Here object each time, so I expect here changes in the normal cases. It's worth a quick manual check of back, forward, then back.

vendor/hud is meant to come from just vendor-hud, and the COMMIT bump matches that.

Taken: every history entry the shell comes to now clears the remembered one (HUD 18ee0da, vendored in d…), so back, forward, back steps back even if a router hands back the same state object. SvelteKit parses page.state afresh for each entry, so it was not hit in practice. The shell SSR test now goes back, forward to the pager entry, and closes it again. An in-stack up() replaces the entry, so here changes there too.

Approved

Since my approval, the vendored HUD moved to 18ee0da. The only change is in Shell.svelte, where the effect that runs when navigation.here changes now resets left. That answers my earlier question: back, forward, back no longer leaves the second back ignored. A repeated close from the same entry is still ignored, because left stays set until here changes. The approval stands. I didn't run anything.

Merged as dfd5754
Part of a stack of 2
  1. next: closing someone's stories returns to their profile, not Home Landed as dfd5754
  2. main