Skip to content

Sync upstream and bring latest maps design - #2

Closed
zasbu wants to merge 23 commits into
mainfrom
fix/maps-upstream
Closed

zasbu wants to merge 23 commits into
mainfrom
fix/maps-upstream

Conversation

@zasbu

@zasbu zasbu commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • sync the branch with sourcejump/sourcejump:main
  • bring the latest maps page, map cards, podiums, boards, zones, and responsive layout
  • include the matching API changes, generated contracts, SQLx cache, and maps E2E coverage

Validation

  • npm test -- --run src/features/maps/mapPodiums.test.ts
  • SQLX_OFFLINE=true cargo check -p sourcejump-api

The upstream repository does not currently grant this account permission to push a PR branch directly.

akanora and others added 23 commits November 7, 2026 21:58
A server skips submitting runs that aren't faster than the player's
SourceJump PB (docs/domain.md), but reading those meant one leaderboard
request per player, style and track on every map change.
GET /v1/maps/{map}/personal-bests?players= takes up to 64 SteamID64s and
answers every style and track at once, with each best's rank, under the
same ETag as the map's records.

docs/api.md drops three sentences that repeat other docs, to stay within
its size budget.
The board's top 25 comes with the map, so a player further down had to page
with "Show more" to find themselves. The board now asks for their entry
(the leaderboard's existing `player=`) and pins it under the top, set apart,
until "Show more" reaches it. Only on the 2.0 board, which is the one that
ranks them, and only when they aren't already in the top.

TableRow gets `separated` for a row that starts a group apart.
Every query that needed a track's current tier repeated "newest assignment
first, take one" against map_tiers, in 14 places across 8 files. The
current_map_tiers view (migration 0052) says it once. Conditions on map_id
and track still reach the primary key through it, so a single lookup reads
the same index rows as before. Behavior is unchanged; whether tiers are in
force (the tiers policy) is still each caller's call.
tokio's Unix signals don't exist on other systems, so the API didn't compile
on Windows at all, which kept contributors there from running its tests or
the API itself. On Unix nothing changes: systemd still stops it with SIGTERM
and in-flight requests finish. Elsewhere it stops with Ctrl+C.
A session lasts 30 days from its last use, and signing out ended only the
browser it came from, so a session left on someone else's computer stayed
signed in with no way to end it. POST /v1/auth/sign-out-everywhere ends
every session of the signed-in player and clears this browser's cookie;
like sign-out, it needs our Origin, and without a live session it only
clears the cookie. The account menu has "Sign out everywhere" under
"Sign out", as a plain form post like it.

docs/site-api.md drops where the auth endpoints are served from (Caddy or
Next.js), which docs/deploy.md has, to stay within its size budget.
Links to SourceJump get shared on Discord all the time, but pages set only a
title, so a preview said nothing about the record. Map, run and player pages
now set a description and Open Graph and Twitter card tags: a map's tier,
the world record of the board it opens on and its players; a run's time,
style, track and place; a player's finished maps and world records. Map and
run previews show the map's cover, player previews the avatar. They reuse
the pages' own per-request reads, so a preview costs no extra API request.

An unexpected failure while rendering a page now shows a "Something went
wrong" page with "Try again", inside the site's header and footer, instead
of Next.js's bare error screen.
Build the API on Windows: listen for SIGTERM only on Unix
Read the tier in force from one view instead of 14 copies
Show link previews for maps, runs and players, and an error page
Show signed-in players their own place on a map's leaderboard
Give servers their players' personal bests on a map in one request
Shared links showed text only, or a raw cover. Each map with a cover now gets one stored 1200×630 JPEG link
card (cover, wordmark, tier icon, name), drawn in the API and named by content so caches keep it for good. Only
data that rarely changes goes on it, so cards don't go stale and there is one per map however many runs are
linked; run links use their map's card. A job draws a card when the cover or tier in force changes and deletes
the one it replaces. It sleeps until triggers on map_images, map_tiers and policies wake it, with an hourly
fallback pass.

Pages without a card (maps without a cover, players, everything else) show web/public/link-card.jpg, drawn from
the home header by the API's new site-card command so it matches. The web app now gets its public address at
build time (SJ_SITE_URL, set by just deploy) for the whole addresses link previews need.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Give link previews a card per map and a site-wide card
A deploy runs `next build` with no API to reach, and nothing ran it before then. Doing so showed three
components that read the API while the site was being prerendered: the home page's latest records and
servers, the server list and the daily totals charts. With the API unreachable the build failed there.

They now wait for a request first (`connection()`), as `currentRuleset` already does, so the pages stay
dynamic and nothing from build time lands in the static shell. CI runs `next build` after the tests, so a page
that does this again fails a pull request instead of a deploy. It stays out of `just check`, as it writes
the `.next/` that `next dev` is using.
Git for Windows defaults to core.autocrlf=true, which checks text files out with CRLF. Checks that compare
bytes then fail on a clean checkout: the doc budget counts the CR bytes (api.md and site-api.md go over
10000), and the committed OpenAPI spec no longer matches the generated one. `eol=lf` keeps the working tree
LF on every OS. The repository's contents don't change: everything was already committed as LF.
A server with a broken clock (finished_at 0 is 1970) could have its runs placed
at the start of a board's history, where they win ties and rewrite WR history.
No ranked run can be older than the ruleset version it names or the server that
sent it, so check_ruleset now refuses one with a 422, allowing the same 5
minutes of clock slack as for times ahead. servers.created_at rather than the
key's: runs queued under a replaced key are still valid.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ingest recounts the standings last, under the standings lock, with the statement limit lifted. Behind a
full recount (a points or tiers policy published, or a new formula after a deploy), which takes seconds,
each run with a new personal best waited the whole time while holding its map's row and one of the request
pool's ten connections. Enough runs arriving then would take every connection, and the whole site would
stall until the recount finished.

The ingest now waits at most 2 s for the lock (`lock_timeout`, for the rest of its transaction). Past that the
run is rolled back and the server gets a 500, which plugins treat as temporary: they keep the run queued and
send it again, and the ingest's idempotency stores and counts it once. Other recounts (tiers, bans,
invalidation, the full recount itself) still wait as before.
Refuse runs that finished before their ruleset or server existed
Stop a run being stored from waiting behind a full recount
Check out every text file with LF line endings
Build the site in CI, and read live data at request time
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

This PR changes files under .github/ or .preview/, so it can't be merged into a preview branch automatically. Remove those changes, or ask a maintainer to merge it.

@zasbu zasbu closed this Nov 9, 2026
@zasbu
zasbu deleted the fix/maps-upstream branch November 9, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants