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

grain.social/grain

photography-focused photo sharing platform

grain.social
1 collaborator
0
2

next: a screen tapped open opens on the first tap

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

What changes

A screen opens on the first tap. On next.grain.social, a tapped location, a camera or place on Explore, or someone else's gallery often came back to the screen it was tapped on, and a second tap was needed to open it. Now the first tap opens it, at a phone's size and at a desktop's.

A tap right after a scroll opens. A tap on a list item within 300 ms of the list's last scroll event did nothing, even when the scroll had already stopped. A touch is now dropped only while the scroller is still moving: it moved within the last 100 ms and the browser hasn't said it came to rest (scrollend). A tap that stops a glide still opens nothing.

A rail's tab takes one tap on a touch screen. The rail's tooltips show on hover only where a pointer can hover. On an iPad, or a phone on its side, iOS treated a first tap that showed a tooltip as a hover.

The change is vendor/hud at HUD's 2318f42 (branch app/taps-2: two commits on app/shell's d36a4eb, which feature/hud already vendors). Against feature/hud, only web/shell/src/Shell.svelte, web/shell/src/Nav.svelte and web/renderer/src/view/taps.ts change, plus COMMIT.

Why

On a phone, the web shell reads ahead the links it shows, and on a desktop it reads ahead the link a pointer rests on. So the answer for a tapped screen is often already there. If that answer taught the shell a new handle (names.learn), the shell ran renamed() to rewrite the URL. renamed() read SvelteKit's page.state, but a shallow goto pushes the history entry, awaits, and only then sets page.state. So renamed() saw the screen the tap came from and replaced the new entry with it. The URL and the screen went back. On the second tap the handle was already known, so the screen opened. A trace on the live site shows pushState /location/… followed within 1 ms by replaceState / with Home's state, and no request. The shell now keeps the entry it made or came to (entered), and enter and renamed read that.

The 300 ms window went because it outlasted the scroll. A glide moves every frame, so 100 ms with no movement, or the browser's scrollend, means it has stopped. I counted only a scrollend that comes before the touch, because a touch that stops a glide brings a scrollend of its own after it lands.

How it was checked

  • The Grain next app was built locally against next.grain.social's HUD, signed out, read only. Each run loads a fresh page and taps once. The before build is feature/hud with HUD 2cc4a36, and the after build has the same three files changed:
    • Chromium, iPhone 13, touch: 21/30 before, 30/30 after. Location 0/3 → 3/3, Explore camera 0/6 → 6/6.
    • WebKit, iPhone 13, touch: 14/20 before, 19/20 after. Location 1/2 → 2/2, Explore camera 0/4 → 4/4.
    • Chromium, 1440 px, mouse (hover, then click): 18/20 before, 20/20 after. Location 0/2 → 2/2.
    • The one WebKit miss after is the probe's fault: reloading / after a story restored the story pager, and the tap closed it.
  • Tap after a scroll, Chromium at a phone's size, on a name 120–300 ms after the last scroll event: 1 of 12 opened before, 12 of 12 after.
  • The live site shows the same miss: location 0/3 on the first tap.
  • HUD's tests:
    • The shell SSR test's history now sets here only once the move settles, as SvelteKit does. A new case opens a link read ahead whose answer teaches a handle, on the first click, at the handle's URL. It fails without the fix, as did "Home chosen again".
    • The renderer SSR test covers a glide, a touch that stops a glide, a tap as soon as the scroll rests, and a tap a moment after the last move.
    • npm run ssr, npm run check, npm run unit, just lint pass.
  • node next/check-apps.mjs passes at 2318f42. npm run check and npm run build in next/ passed, and so did the Grain iOS simulator build, at the first vendor (2f1855e, the same changes on an earlier app/shell). The first-tap run on that build was 30/30.
  • hud_core::operator::load at 2318f42 loads both next.grain.social's live apps and this branch's next/.
  • iOS, signed out, on the simulator: an XCUITest made 5 first taps each on card body, name, avatar, location, tabs, Explore tile and place, story strip and gallery author, plus taps while Home refreshes, after Back, and after a fling. Every first tap opened. No pop followed a push. A tap during a glide stops the glide, as UIKit does in any app, and taps 0–1000 ms after the glide opened 20/20. This change touches no iOS behaviour.

Shortcomings

  • No iOS cause was found signed out. Signed in wasn't tried, because there's no test account. If it still happens on the phone, it needs a signed-in repro.
  • A tap on a feed's photo opens nothing, and a card with a content warning takes one tap to reveal and one to open. Both are by design, and both can read as "tap twice".
  • Headless Chromium gives no momentum, so a tap during a real glide was checked only by the renderer test.
  • On the web, the story strip's items are buttons. A tap on one before the page hydrates is lost. Throttled ×4 that window is 0.3–0.5 s; on a fast phone it's 0.02–0.2 s.
  • hud-next doesn't need a new HUD for this change, which is all client code.

Review

Start with vendor/hud/web/shell/src/Shell.svelte (entered), then vendor/hud/web/renderer/src/view/taps.ts.

Approved

This pull bumps the vendored HUD to 2f1855e and adjusts ios/Grain/Shell.swift to HUDKit's new Route.Screen return type. I read the changes you pointed to: Shell.svelte, taps.ts and the Shell.swift signature.

  • First-tap fix: entered is set in enter and in the effect that follows navigation.here. enter and renamed read it ahead of navigation.here, so a shallow goto that hasn't set page.state yet no longer gets the old entry written back over the new one. That matches the cause you describe.
  • Scroll window: the taps.ts check drops a tap only when the scroller moved within 100 ms of touch-down and no scrollend came after that move and before the touch. That keeps a tap that stops a glide dropped, as intended.
  • Stale entered: the effect returns early when navigation.here is not an app entry, so entered would keep an older value in that case. I haven't confirmed it can matter, and it doesn't block this.
  • Other bumped files: I didn't read the other vendored files (pager, stack, routes, Swift HUDKit) line by line. They come from HUD's own app/shell changes, and your notes say Grain's next/ doesn't use them yet.
Approved

My earlier approval at c53286a stands. The head moved to 923a8fe, and I read what came in since.

The pull's own change still bumps the vendored HUD (COMMIT now 2318f42), which carries the entered fix in Shell.svelte and the taps.ts scroll window I already reviewed.

The iOS changes in Shell.swift and StoryPager.swift are not part of this pull. They come from the base. That covers the story pager and under routes, the story views in next/, and the async Route.screen(resolve:) in the vendored HUDKit. pull_diff shows next/grain.social.json is not among the files this pull changes. Those changes fit the new HUD API.

The one new vendored change is in Pager.svelte: the .peek button gets position: absolute and a --off style. It is small and unrelated to the tap fix, and I saw nothing wrong with it.

On the stale entered: the history only holds an entry that isn't the app's (navigation.here undefined) before the shell makes its first one, at hydration, and entered is undefined until then, so enter and renamed fall back to navigation.here as before. After that, every entry the browser goes back or forward to is one the app made. Leaving it as is.

Merged as e181718
Part of a stack of 2
  1. next: a screen tapped open opens on the first tap Landed as e181718
  2. main