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

grain.social/grain

photography-focused photo sharing platform

grain.social
1 collaborator
0
2

next: Create opens its form where you are, and a form opens once

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

What changes

Create opens its form where you are. Pressing Create in the sidebar or rail no longer pushes a For You screen with a back arrow over Home. The shell makes the action's call in the background (read ahead as the button is hovered or pressed) and draws only its New gallery form over the screen you're on. That's the same modal the feed's + opens. No screen is pushed and no history entry is made. Once you post, the new gallery opens (/profile/{actor}/gallery/{rkey}, the first record the form made that a route names). Cancel closes it and nothing moves.

A form opens once. compose is a one-time request. The shell no longer keeps it in a stack level's call, a history entry, a URL or its memory of screens. Trees it remembers have their open mark taken off, and it strips compose from entries an older shell saved, too. Read-ahead is still keyed by the exact call, so an answer read with compose is only taken by the load that opens the form. So reloading, going back or forward, or choosing a tab again never reopens a form. That covers Create and Your story ("compose": true) alike.

This is vendor/hud at HUD 756fb4c (app/shell). It also brings 9fcffeb, stories loading their next pictures ahead, which is already on app/shell.

Why

To reproduce: on next.grain.social, signed in, press Create, then Cancel, then reload. The form opens again on every reload. The frame's action is getFeed (foryou) with "compose": "New gallery". The shell pushed that call as a screen and saved each level's call in the history entry (goto(..., { state: { here } })). On reload, afterNavigate → stacks[tab].sync(here) read the call again with compose still in it, and the restored screen opened its form again. The URL /feeds/for-you has no compose. The shell's SSR test, run against the old shell, shows it: "Create pushed a screen: 2 levels", "Create made a history entry", "loaded again after Create: a form opened again", "a call was made with compose again".

The fix is general and lives in HUD's shell and renderer, so any HUD app gets it. Grain's app file is unchanged. The action still names the same call, so hud-next needs no new keys.

How it was checked

  • HUD: npm run check (svelte-check, 0 errors), npm run unit (16 pass, with new tests of plain and recordAt against Grain's routes) and npm run ssr. The shell's SSR test now also mounts the shell signed in against a fake server. Create opens the form over the feed with no level pushed and no entry made. Cancel, then reload: no form and no compose call. A link opening a screen at a form opens it once, and back, forward and reload don't reopen it. An older entry holding compose, reloaded, opens nothing. No history entry holds compose. Sending the action's form opens the new record's screen.
  • This branch: node check-apps.mjs, npm run check, the unit tests and npm run build in next/.
  • In a browser: a release HUD built at 756fb4c on :8931 (HUD_WORKSPACE=off, HUD_APPS a copy of this next/) and this build of next/ on :5931, driven signed out in Chromium. Home, Explore, a gallery opened from the feed, then back, forward and reload all draw the right levels. No history state holds compose, no dialog opens, and the console shows no errors. The signed-in Create path can't be signed into locally, so the SSR test covers it, as above.

Shortcomings

  • Pressing Create waits for the For You call before the form shows, which is quick once it has been read ahead on hover. A cheaper call for the action (a view holding just the New gallery form) would show it sooner. That would be a change to the app file.
  • HUDKit and the Android app don't draw the frame yet. HUDKit keeps no navigation across launches and opens a form once per screen in that screen's memory, so it doesn't have this bug. Android has no navigation stack yet. docs/views.md says both should open the action as a sheet over the screen on show.
  • The vendored HUDKit changes come from 9fcffeb (stories preload), not this fix. The Grain iOS app wasn't built for this pull.

Review

Start with HUD's web/shell/src/Shell.svelte (act, formSent, plainPlace) and Stack.svelte (newLevel, load, keep).

Approved

This updates vendor/hud to HUD 756fb4c. The frame's Create action now makes its call in the background and draws only the form over the current screen. No level or history entry is pushed. compose is stripped from stacks, history entries and remembered trees, so reloading, going back or forward, or choosing a tab again can't reopen a form.

I read the shell changes in full: Shell.svelte (act, formSent, plainPlace), Stack.svelte (newLevel, load, keep, sync, swap), routes.ts and its test, Nav.svelte, frame.ts and COMMIT. The logic holds up:

  • plain is applied wherever a call becomes stack, history or URL state: enter, sync, swap, newLevel.
  • The opening call is sent once, in load.
  • keep and unopenedEntry unmark stored trees.
  • recordAt binds every path token before it accepts a route.

I did not read the renderer files (Compose.svelte, opened.ts, Tree.svelte, Gallery, Picture, Slides, preload.ts) or the HUDKit Swift files and tests. They are vendored from HUD, and AGENTS.md says vendored code isn't edited here. Your described HUD-side tests and the next check cover them.

Nothing here needs to change. One non-blocking note: act() leaves the previous composing tree in place until the new call answers, so a quick double-press while the form is open is only guarded by acting. That is fine in practice.

Thanks. On the note: while the form is open it's a modal dialog, so the page under it, Create included, is inert and can't be pressed again. Before it opens, acting drops a second press while the call is on its way. Leaving it as is.

Added d5b99b6 (HUD 969d9b5): New gallery's Location results now open as a popover in the top layer, placed against the field. They drop below it, or flip above it where there's more room, so the form's scroll and its Cancel/Post bar no longer cut them off. I checked it in Chromium with a harness of the same form at 900×640 (flipped above) and 900×900 (dropped below, over the footer), and picking a place still works. svelte-check, the renderer and shell SSR tests, and next's check and build all pass.

Approved

Since my approval, the only change is a vendor/hud bump to 969d9b5. It touches PlaceField.svelte and COMMIT. The place suggestions now float in the top layer as a popover, placed against the search input, so the form's scroll area and buttons can't cut them off. This is renderer code vendored from HUD, so I read it only for whether it breaks what I approved. It doesn't touch the Create or compose logic.

The popover is shown once and positioned again on scroll and resize, and its listeners are removed when the list goes away. I found nothing that needs to change.

Merged as 7be46e7
Part of a stack of 2
  1. next: Create opens its form where you are, and a form opens once Landed as 7be46e7
  2. main