Commit Graph

73 Commits

Author SHA1 Message Date
Zach Clendenen
6ebc323ac2 fix(streaming): name the ended claim's stamp in a termination notice
A re-claim of the same container keeps its key, so the container alone cannot tell the tab that lost its claim from the tab holding the next one.
2026-09-18 13:21:12 -05:00
Zach Clendenen
eaf1ee3c6f fix(streaming): settle a webstation save-and-exit pull on any exit answer
The exit writes the save dump before it answers, so an answer without a state is as final as one with. The broker's outcome now says whether it settled, and the no-change release test covers only the answered case, which is what its name says.
2026-09-18 13:16:52 -05:00
Zach Clendenen
be68050f3f fix(streaming): stamp the launch pushes with the claim they belong to
With one container per platform a second tab re-claims the same container, so the container alone cannot tell a tab its own launch-ready from the claim that replaced it.
2026-09-18 12:56:30 -05:00
Zach Clendenen
e4548b771c fix(streaming): keep retrying a webstation exit pull the exit never confirmed
A webstation exit that timed out or failed may still be writing its save dump, so taking its first answer as final could leave the archive uncollected. The stop now reports whether the broker answered, and only an answered exit or a confirmed save-and-exit takes one fetch. The claim test now makes a real claim while the pull runs.
2026-09-18 12:53:20 -05:00
Zach Clendenen
0c5e536889 fix(streaming): stop storing a desktop's room no route reads
The desktop view takes its room from the claim POST and re-claims on reload, and the status poll never answers for a desktop, so the stored room was a dead write.
2026-09-18 12:23:05 -05:00
Zach Clendenen
99b44b52fa fix(streaming): keep a named save-and-exit to a game of its platform
Save-and-exit went through the release route's resolution, which ends whatever a named container holds, so naming a shared container could save and kill a desktop or another platform's game. A release still ends anything named; save-and-exit now matches only a game of the path's platform.
2026-09-18 12:17:01 -05:00
Zach Clendenen
a62d1158ad fix(streaming): keep retrying a save pull the broker has not confirmed finished
A per-emulator broker acks DELETE /launch before the emulator has flushed its saves, and a blocking save-and-exit that timed out or failed may still be killing it, so one answer from those pulls could miss the session's saves. Only a webstation exit, which answers once its dump is written, and a confirmed blocking save-and-exit take the first answer as final.
2026-09-18 12:13:11 -05:00
Zach Clendenen
11eabe6431 docs(streaming): fit the branch's comments and docstrings in two lines
The repo caps a comment at two lines and a docstring at one sentence plus Args and Returns. Several comments and docstrings this branch wrote or edited ran to three lines or more, so they are tightened, with parameter notes moved under Args.
2026-09-18 12:03:10 -05:00
Zach Clendenen
157df721c6 refactor(streaming): list /config rows from the pools a claim walks
The config endpoint re-derived the key filter and case-insensitive platform grouping that the pool helpers own, so the Play button row and the claim could drift apart. It now reads the first container of each platform's first pool from the same helper.
2026-09-18 11:28:03 -05:00
Zach Clendenen
79be00ceb0 refactor(streaming): require a platform when scoping a session lookup
Every caller names the platform, so the None default and the branch it fed only widened the signature.
2026-09-18 11:23:19 -05:00
Zach Clendenen
36844e6c93 fix(streaming): take one answer from a save pull once the emulator has stopped
The pull retries to wait out an emulator still writing its saves, but every teardown stops the emulator first, so a pull after an exit with nothing new ran all five attempts and held the player's next claim for about twelve seconds. Only a background save-and-exit, where the broker may still be saving, keeps retrying.
2026-09-17 20:10:07 -05:00
Zach Clendenen
2512069345 fix(streaming): mark the exit save pull before the teardown stops the emulator
The release and abandoned teardowns only marked the pull after the stop, the card evacuation and the state pull. On a pool the player's next claim landed on a free sibling in that window, found nothing pending and hydrated from the archive before last. The mark now goes down as soon as the teardown owns the container, and a teardown that ends without starting the pull clears it.
2026-09-17 20:08:48 -05:00
Zach Clendenen
52893d301d fix(streaming): let a save pull clear only the mark it was given
The marker was one bare flag per user and ROM, so when two pulls overlapped the first to finish deleted the mark the second had set, and a claim behind the second stopped waiting for it. Each mark now carries a token and the clear is a compare-and-delete.
2026-09-17 20:06:55 -05:00
Zach Clendenen
8127fc11ae docs(streaming): fit the force-release note in two lines 2026-09-17 18:56:26 -05:00
Zach Clendenen
adf891b091 docs(streaming): place the force-release note before the quiesce
The note is written once the drain marker is held, so "before the drain"
pointed a reader at the wrong step.
2026-09-17 18:40:48 -05:00
Zach Clendenen
4f2d1198f2 docs(streaming): tighten the comments this branch grew
Several notes had run to four or more lines, a couple of them recounting
how the code was reordered rather than what it does now.
2026-09-17 16:59:38 -05:00
Zach Clendenen
f425fb5553 refactor(streaming): read the joinable filter from one place
The join walk and the joinable listing each spelled out what makes a
session joinable, kept in step by a comment. Both now ask access.
2026-09-17 16:56:34 -05:00
Zach Clendenen
e8c96f8aa8 refactor(streaming): drop arguments no caller varies
resolve_owned_session's include_desktop was never passed, and the two
teardown helpers and stamp_launched defaulted arguments every caller
supplies. The 409 builder's holder snapshot no longer reuses the name of
the container above it.
2026-09-17 16:53:46 -05:00
Zach Clendenen
85079be5c5 fix(streaming): name RetroArch in the emulator labels
The labels map covers the ids a surface is handed rather than resolves,
and a save written under RetroArch carries "retroarch". With no entry
the asset chip showed the bare id.
2026-09-17 16:50:31 -05:00
Zach Clendenen
b80d9af68c fix(streaming): scope the ended-session notice to the claim asked about
The tombstone is keyed per container, so the status poll walked a pool
reading any notice it found: an admin desktop's, or one from another
platform the container serves. A game tab then tore itself down with a
reason belonging to a claim it never held. The notice records the ended
claim's platform and kind, so the walk now applies the same scope the
live-session lookup uses.
2026-09-17 16:47:01 -05:00
Zach Clendenen
5021ef2fa0 fix(streaming): label the Play! emulator and the asset chips
Play! served PS2 sessions under the raw id "play", since it was missing from
the emulator display names, and the save and state chips showed whatever id
the broker recorded because the names never reached the frontend.

/config now ships the display names, and the chips and core group heads label
an id through them, falling back to the id for one the backend does not name.
2026-09-17 16:09:13 -05:00
Zach Clendenen
5233649ebd fix(streaming): join the session the caller asked for
An unnamed join stopped at the first pool member holding a live session, so a
desktop, another platform's game, the caller's own session or a ROM they cannot
see masked the session they were offered and the join answered 404 or handed
back somebody else's room.

The walk now skips a member that fails the same filter the joinable listing
applies and keeps looking, and the Join button carries the container of the row
it came from into the stream URL so the join names its session outright.
2026-09-17 15:59:57 -05:00
Zach Clendenen
f512bead7f fix(streaming): hold a claim until the last session's saves are filed
An exit pulls the in-game save archive off the container in a detached task,
so a claim landing right behind the release hydrated the container from the
archive before last and the player lost the session they just finished.

The teardown marks the pull pending in Redis before spawning it and clears the
marker when the task ends, and a claim waits the marker out before hydrating.
The wait is capped so a wedged pull costs one stale hydrate rather than a claim
that never answers.
2026-09-17 15:49:33 -05:00
Zach Clendenen
010e0fba4a fix(streaming): let a tab that missed launch-ready find its way in
The room URL only ever existed in the launch-ready push, so a socket that
dropped while the game was coming up left the tab loading forever over a
session that was running, with no way out but a release.

The session now records the room the launch answered with, the status poll
reports it along with the container it was found on, and a loading tab enters
the stream on that answer.
2026-09-17 15:36:05 -05:00
Zach Clendenen
c2e599439f fix(streaming): answer with the container a claim would win
/config listed containers with no key, so a platform whose only container is
misconfigured showed a Play button that could never stream, and it listed a
platform twice when two records spelled it in different case.

configured_emulator read the first record in the file rather than the first
member of the platform's pool, so the slot ceilings a save or load is checked
against could come from an emulator no claim ever reaches.
2026-09-17 15:28:42 -05:00
Zach Clendenen
13e65ec375 fix(streaming): leave no ended notice when a player retakes their own session
A crashed tab leaves a stale session, and pressing Play again sweeps it.
The sweep left the same notice a force-release does, which went to the
user, whose only tab was the one that had just claimed the container: it
read the push as its own session ending and handed the claim straight
back.

The takeover now names the claimant, and the sweep skips the notice when
it is the owner coming back. A takeover by anyone else still leaves it.
2026-09-17 15:07:24 -05:00
Zach Clendenen
e3b529e214 fix(streaming): carry container and desktop on the session-ended notice
The termination notice named only the platform, so a tab could not tell
which of the account's claims had ended. One room carries them all: a
player holding two sessions from a pool, or an admin with a desktop open
alongside a game, tore down the wrong screen.

The notice now names the container it ended and whether that claim was a
desktop. Stream.vue ignores a desktop notice and one for a container it
did not claim; Desktop.vue gains the listener it never had, so a
force-released desktop says so at once instead of at the next heartbeat.

The tombstone also moves ahead of the drain in both teardown paths: the
session is over the moment the marker lands, and a poll during the
seconds of broker round trips that follow found no reason at all.
2026-09-17 15:04:27 -05:00
Zach Clendenen
dd6b949b6a fix(streaming): bind release and heartbeat to the caller's claim
A claim is the holder plus the moment they took it, so a tab that missed
its own takeover could still act on the claim that replaced it: its
unload release ended the new session and its beat kept it alive. Both
routes now take the claimed_at the claim answered with, and a mismatch
reads as a session the caller no longer holds: the release is a no-op and
the heartbeat reports ended, with the termination notice the displaced
tab needs.

Admin releases from the settings and activity panels end whatever is
running and send no stamp.
2026-09-17 14:50:32 -05:00
Zach Clendenen
9984f7dd27 fix(streaming): scope session lookups to the platform and skip desktops
A container can serve several platforms while holding one session, so a
lookup that starts from the caller has to match the platform it was asked
about. Otherwise a ps2 session shadows the same container's ngc row: the
claim reads as a duplicate and 409s, status reports it active on a
platform the caller holds nothing on, and an unnamed heartbeat or release
lands on it.

A desktop session is only reachable when the caller names its container,
which is what the desktop view does, so a game tab no longer beats or
releases an admin's desktop, and a desktop no longer blocks its admin's
own game claim. Occupancy is still the reservation's job: the claim walk
just fails that container's SET NX and moves on.
2026-09-17 14:44:15 -05:00
Zach Clendenen
84660d3c4b Merge remote-tracking branch 'upstream/master' into streaming-patches-5 2026-09-17 13:02:43 -05:00
Zach Clendenen
08f1e0001e simplify(pr-ready step 3): group dialable containers per platform in one place, point the claim comment at interchangeable_with 2026-09-17 11:46:22 -05:00
Zach Clendenen
9c1e9f4d75 fix(streaming): put every container in a pool, claim from the first
A platform's containers are now grouped into pools of interchangeable
members (same emulator, memory card sync, save picker and protocol), so a
lone container is a pool of one instead of a skipped non-member. Game claims,
status, heartbeats and joins still walk only the first pool, which matches
the containers they reached before.

The "not a pool member" warning fired on every lookup, one container at a
time. It now fires once per config and names every container a game claim
can never reach. Named lookups (desktop, admin release, named heartbeat)
already reach a container in any pool.
2026-09-17 11:42:18 -05:00
Zach Clendenen
c62af75621 polish(pr-ready step 4): trim the heartbeat and named-container comments 2026-09-17 09:53:01 -05:00
Zach Clendenen
e2e35835db simplify(pr-ready step 3): run a named heartbeat through the pool's lookup, reuse the store heartbeat and entry_for_platform
A named container is a one-entry candidate list, so the heartbeat has one lookup
and one status answer instead of a closure branching on the key, and it no longer
reads the session twice. The desktop view beats through the store wrapper, and
configured_emulator shares the platform match.
2026-09-17 09:41:31 -05:00
Zach Clendenen
398c088d49 polish(pr-ready step 4): wrap the fleet row's state line and actions, trim prose
At 320px the End session button ran past the row, and below md the state
line truncated away who holds the session. The actions now wrap and the
state line wraps at every width. Docstrings and the xs comment are cut to
the repo's two-line limit.
2026-09-17 08:19:22 -05:00
Zach Clendenen
bdd661d30a simplify(pr-ready step 3): share the per-platform entry lookup, build the state line in one place
entry_for_platform backs both container_for_session and
resolve_named_container, and the fleet row's state line is assembled in
sessionState instead of split across template blocks.
2026-09-17 08:14:41 -05:00
Zach Clendenen
339308d586 fix(streaming): resolve a named container by key, not through the pool
An admin ending a session names the container, but the lookup went through
containers_for_platform, which drops any container that disagrees with the
head of the pool. A second container with a different emulator, card sync,
save picker or protocol then 404'd on release, surfacing as "Could not end
the session." in the fleet panel, while its session kept holding it.

The named lookup now goes through containers_by_key and only checks that the
container serves the platform. Owner checks are unchanged.
2026-09-17 07:58:07 -05:00
Georges-Antoine Assi
d16aa85968 Merge branch 'master' into streaming-patches-3
AssetList moved its timestamp into <AssetTimestamp> and gained
groupBySlot on master, so the picker's `timestamp` prop now feeds the
component's date and both props coexist. The "updated" | "created" type
and its accessor join Asset's other shared helpers in v2/utils/assets,
where AssetPreview takes them too, since the old local name collided
with the AssetTimestamp component.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-16 19:12:34 -04:00
Georges-Antoine Assi
bf6f9db02a fix(streaming): serialize one player's claims on a platform
The ownership check and the reservation that follows it are separate Redis
round trips, so two concurrent claims from one player could each read no
session of their own and then win a different member of the pool, leaving
the second one unreachable. A per-player, per-platform gate held across the
pair makes the loser read the winner's session instead of a free container.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-16 17:38:47 -04:00
Zach Clendenen
4e327fd72e simplify(pr-ready step 3): cut the clears_stale_saves comments to the why
Each of them had grown a paragraph explaining where the broker flag lives
and when to reach for it, which the config example already covers.
2026-09-15 23:33:39 -05:00
Zach Clendenen
9cef7f2f29 review(pr-ready step 2): pool on the picker capability, not the raw flag
Two legacy broker containers serving the same emulator stopped pooling when
one carried a clears_stale_saves the resolver had just logged as having no
effect. Comparing supports_save_picker folds in the webstation gate, so it
is the same test for a webstation pair and inert for the rest.
2026-09-15 23:31:52 -05:00
Zach Clendenen
5e217c7f64 feat(streaming): let an operator declare whether their broker clears saves
The save picker was gated on a hardcoded set of emulators mirroring the
webstation broker's `clears_stale_saves`, a value that lives in another
repo. A broker release that turns it on for a new emulator needed a RomM
code change before the picker appeared, and an operator on a fork or a
newer broker could not turn it on at all. The other direction was worse
because it was silent: if the broker stopped clearing, the pick still
validated, the archive still uploaded, and the container's own newer
files overwrote it with no error anywhere.

`clears_stale_saves` now joins `memory_card_sync` in
PLATFORM_OVERRIDE_KEYS, resolved per container in `_resolve_one`, which
leaves the emulator table as the default rather than the authority. It
also joins the pool-interchangeability check, since the picker is
advertised from the head of the pool and a member that keeps its own
files would take the pick and discard it.
2026-09-15 23:22:27 -05:00
Zach Clendenen
14f847dc57 Merge remote-tracking branch 'upstream/master' into pr-ready-851cea
# Conflicts:
#	frontend/src/v2/views/Player/Stream.vue
2026-09-15 17:29:00 -05:00
Zach Clendenen
f58a7ad7e0 polish(pr-ready step 4): trim the comments and name the resolve helper for its answer
Cut the docstrings and comments this branch added down to the one non-obvious
fact each, in the resolver and in the tests alike, and rename the new helper to
_claimable_broker_host so it says what it returns next to _derive_broker_host.
2026-09-15 17:09:59 -05:00
Zach Clendenen
1b3caebabf simplify(pr-ready step 3): flatten the container resolve and compare protocols by name
Move the three ways a raw entry fails to resolve into one helper with a guard
clause each, so none of them has to unset a broker host a sibling branch set.

The subfolder match moves onto WebstationProtocol, next to the normalization it
has to agree with, and interchangeable_with compares protocol names, the
discriminator the record already uses elsewhere.
2026-09-15 17:05:08 -05:00
Zach Clendenen
9a4b644c01 review(pr-ready step 2): let a player reclaim their own stale container
The holder gate added with the pool ran before the stale-takeover walk, so a
player whose tab crashed was refused their own container until its TTL lapsed.
Block only on a live holder, and when the holder's own session is stale narrow
the candidates to that container so the existing takeover path reclaims it.

Also widen the proxy path check to compare the host's URL path, so a container
on another origin mounted at a path that disagrees with its subfolder is
refused the same way a bare path already was.
2026-09-15 16:57:37 -05:00
Zach Clendenen
df6ded2786 fix(streaming): refuse a proxied container whose host and subfolder disagree
A same-origin entry sends the browser to `host`, but activate answers with
the room URL the broker built from its own SUBFOLDER, and that is an
absolute path, so urljoin lets it replace the path `host` carries. The two
values are therefore not independent: both have to be the container's own
SUBFOLDER.

Get them wrong and nothing complains. A container mounted at /streaming-2
while declaring /streaming resolves, claims its own key, and hands the
player a URL the proxy routes to whoever owns /streaming: a different
container, mid-session, with no trace of it in either log. The likeliest
way in is a second pool member proxied at its own path with `subfolder`
left to its default.

Resolve the entry, log it, and clear broker_host so it cannot be claimed,
matching how the other unusable configurations are handled. It stays in
the fleet view, where the operator can see what is wrong with it. A full
URL `host` is untouched; it carries an origin of its own for that absolute
path to land on, so there the two are free to differ.
2026-09-15 13:30:34 -05:00
Zach Clendenen
50027b64ed fix(streaming): pool same-origin webstation containers across subfolders
interchangeable_with() compared protocol by instance identity, and
WebstationProtocol is interned per exact subfolder — so two containers
proxied at different subfolders, the normal way to run a same-origin
pool, were never recognized as pool members. Compare by type instead;
capabilities are class-level constants, so type equality is what
"same shape" actually means.
2026-09-15 12:49:08 -05:00
Georges-Antoine Assi
c0001bd27d style(streaming): trim the save-picker comments and the emulator compare
review-polish pass over the save-picker change.

Two comments carried more prose than the rule allows. The emulator comparison
re-normalized a value ResolvedContainer already lowercases at resolve time,
which the sibling state resolver relies on, so it now reads the same way.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 12:09:45 -04:00
Georges-Antoine Assi
1c5255df1f refactor(streaming): resolve the picked save once and list it like a save
simplify pass over the save-picker change.

The claim validated the pick, dropped the resolved row and passed the bare id
down two layers, where hydration fetched and re-checked the same save. It now
carries the row the way the resume state and the memory card already are, so
the restorability rule has one home and the claim one lookup.

The picker holds the picked id rather than the row, so an id that is no longer
on offer falls back to the newest by construction instead of through a watch,
and the list of archives uses AssetList, the variant meant for saves, rather
than the tile strip whose thumbnail area a save never fills.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 11:58:59 -04:00