diff --git a/patches/README.md b/patches/README.md index 31393e06c9fb911f20d303b3c4a128e79aecb5cd..752e30ff29e4df957b03b6b8123863fdfcd46c82 100644 --- a/patches/README.md +++ b/patches/README.md @@ -35,6 +35,62 @@ ``` If `git apply --check` fails after a `sourcehut-refresh`, upstream has changed that file — re-derive the patch against the new context and update the copy in `~/data/home/phoebe-lab/srht/patches/` first, then re-import here. +### `core-nav-groups.patch` + +**Repo:** `core.sr.ht`  ·  **Files:** `srht/app/nav.py` (new), `srht/app/flask.py`, `srht/templates/nav.html`, `scss/nav.scss`, `scss/dark.scss` + +**Problem.** The service switcher — the strip of service names between the brand and the login box — is a flat row listing every `*.sr.ht` section in the config. That works at eight services and stops working at fourteen: on a laptop the tail slides under the login box, and every service the instance gains makes it worse. Two further defects underneath the overflow: + +- **The two halves disagree about order.** The strip is rendered twice: here in Jinja, and in Go by `sr-ht-ecore/chrome` for the instance's own services. Python sorts *stably* and gives every non-canonical service the same key, so they come out in config-file order; Go's ini parser is a `map[string]Section` and has thrown that order away before it sees the file, so it falls back to the alphabet. On the running config `go` is second in one half and seventh in the other. +- **Nothing in the row says what anything is.** After the four canonical names it is just an alphabet, so a reader cannot tell that `cov` and `bench` are what came out of a build while `go` is a module proxy. + +**Fix.** The row becomes a pinned subset plus a grouped remainder behind a `+N` counter, with both the subset and the grouping declared in `config.ini` rather than in code: + +```ini +[sr.ht] +nav-groups=code work ci output account +nav-pinned=git builds artifacts + +[bench.sr.ht] +nav-group=output +``` + +The taxonomy lives in the config *because* there are two renderers — a copy of it in each would drift exactly the way the navbars themselves did before `sr-ht-ecore` existed. Members sort alphabetically inside a group in both halves, and that is what closes the ordering divergence: the alphabet is the one order neither parser can take away. + +Three properties worth knowing before touching it: + +- **An unedited config renders correctly.** With no `nav-groups` and no `nav-pinned` the panel is one unnamed alphabetical list and the row holds only the current service — no key is required, nothing 500s, and nothing is hidden that was not reachable before. This is also the precondition for the patch ever being acceptable upstream. +- **No JavaScript.** The panel is `
`/``; this repo builds no bundles and the Go half has to print the same markup, so anything else would have to be written twice in two languages and would be the first thing to diverge. +- **`api.sr.ht` is excluded** alongside `paste` and `pages`. The federated GraphQL gateway serves no pages of its own; it is listed *before* the instance deploys one, because a section appearing in the config is all it takes for a service to enter the switcher. + +The logic lives in a new module, `srht/app/nav.py`, rather than in more lines of `flask.py`. That keeps the patch's contact with upstream down to three small hunks — an import, one list entry, three context keys — and it gives the Go half a single function to be compared against. + +**Status.** Written 2026-08-23 against `docs/SPEC.nav.md` in `sr-ht-ecore` (stages 0–1); **not applied anywhere yet.** The Go half is already released in `sr-ht-ecore/chrome`; this patch is the statement of the Python half, and how it reaches production is still an open decision — see below. + +**How it would reach production, and why that is not settled.** The spec's chapter 7 says to add the patch to `source=` in `sr.ht-apkbuilds/sr.ht/core.sr.ht/APKBUILD`. That is wrong for this instance, and the reason is worth writing down because it applies to every future core.sr.ht patch: + +- `~/data/home/sourcehut/sr.ht-apkbuilds` is a read-only clone of **upstream's** repo (its only remote is `git.sr.ht/~sircmpwn/sr.ht-apkbuilds`), and its `core.sr.ht` APKBUILD still pins `0.83.0` while the instance runs **0.84.5**. Nothing here builds core.sr.ht from it. +- The apk comes from `~bigbes/srht-upstream`, a channel that **mirrors upstream's prebuilt packages** (`mirror.sr.ht` → `apk-mirror` → Garage → the channel). No local build step exists to hook a patch into. +- The mechanism actually in use for core.sr.ht is `phoebe-lab/srht/scripts/patch-*.py` — idempotent scripts that rewrite the *installed* files in `Dockerfile.base`. `nav.html` is already patched twice that way, by `patch-nav-brand.py` and `patch-nav-register.py`, and neither touches the `