- Retry the exit once when a broker boots the wrong core and the first exit
fails: the broker refuses every activate while that game runs, and the
released claim leaves nothing behind to stop it.
- Stamp the launch's core tier on the session and report it through the
status poll, so a tab that missed launch-ready still warns about an
untested or broken core, once.
- Translate the core-untested and core-blocked warnings in every locale.
- Replace the inline bytes-to-text decodes with redis_handler.as_text
- Add utils.auth.token_device_id for a request's token-bound device
- Look up a group's member tokens in one query and close them in one pass
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* chore(mypy): switch to strict mode with listed exceptions
Replace the hand-picked flags with `strict = True`, turning off only the
four flags that aren't clean yet (disallow_any_generics,
warn_return_any, disallow_untyped_calls, disallow_untyped_decorators).
Any other strict flag, including those future mypy releases add to the
preset, is on by default.
That turns on no_implicit_reexport, strict_equality and extra_checks:
- Import each name from the module that defines it. About 240 test
sites patched a dependency through the module that imported it
(`scan_module.fs_rom_handler`); they now import the same object from
its source, so every patch targets what it did before. Tests that
replace a module attribute are unchanged.
- handler.streaming.memory_cards re-exports store_memory_card_version
explicitly, since endpoints call it there and tests patch it there.
- mutagen gets implicit_reexport, as it re-exports without __all__.
- Test comparisons build typed values (CoverResult, a typed expected
dict, enum .value) and the CORS lookup casts for its identity check.
- One ss_handler ** spread keeps a coded ignore: extra_checks wants its
NotRequired dump_* keys spelled out, and the media dict never has them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PLzXae5up2pYXRoBjfjn2G
* chore(mypy): give every generic its type arguments
Drop disallow_any_generics from the strict-mode exceptions and fix the
347 bare generics it reports, 230 of them in app code.
- Bare `dict` becomes `dict[str, Any]`: update payloads, raw provider
JSON and endpoint bodies map string keys to mixed values, so the Any is
real and now written down. The OpenAPI document is unchanged.
- Rom query filters take and return RomSelect; _music_facet_joins and
_exclude_hidden are generic over the Select they're given, and
_build_hash_selects returns id-only selects.
- Redis clients are typed by what they return: the decoding caches are
Redis[str], the RQ connection and binary cache Redis[bytes].
- The rest get explicit parameters: Row, Pattern, ColumnElement,
QueryableAttribute, SpooledTemporaryFile, Task, Future and friends.
Precise types reached callers that had been getting Any, which surfaced:
- The LaunchBox cache writer is fed binary-cache pipelines.
- The flashpoint and IGDB request helpers return raw JSON of varying
shape, not always a dict.
- The rom search endpoint returned dicts under a list[SearchRomSchema]
annotation; it now validates them into that schema.
- The audit filter's id subquery selects strings.
- In tests the binary cache is the non-decoding fake shared with
async_cache, so it is cast to Redis[bytes] rather than changed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PLzXae5up2pYXRoBjfjn2G
* test(upload): assert cleanup against the patched upload directory
The 409 test checked config's ROM_UPLOAD_TMP_BASE while the fixture patches
the endpoint's copy to tmp_path/uploads, so it passed even if cleanup failed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PLzXae5up2pYXRoBjfjn2G
* chore(mypy): keep the row type through the ROM filter helpers
filter_roms and its helpers also receive select(Rom.id) membership queries,
so they now take and return the caller's Select type instead of narrowing to
RomSelect. merged_ra_metadata mixes scalar and list values.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PLzXae5up2pYXRoBjfjn2G
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* chore(mypy): switch to strict mode with listed exceptions
Replace the hand-picked flags with `strict = True`, turning off only the
four flags that aren't clean yet (disallow_any_generics,
warn_return_any, disallow_untyped_calls, disallow_untyped_decorators).
Any other strict flag, including those future mypy releases add to the
preset, is on by default.
That turns on no_implicit_reexport, strict_equality and extra_checks:
- Import each name from the module that defines it. About 240 test
sites patched a dependency through the module that imported it
(`scan_module.fs_rom_handler`); they now import the same object from
its source, so every patch targets what it did before. Tests that
replace a module attribute are unchanged.
- handler.streaming.memory_cards re-exports store_memory_card_version
explicitly, since endpoints call it there and tests patch it there.
- mutagen gets implicit_reexport, as it re-exports without __all__.
- Test comparisons build typed values (CoverResult, a typed expected
dict, enum .value) and the CORS lookup casts for its identity check.
- One ss_handler ** spread keeps a coded ignore: extra_checks wants its
NotRequired dump_* keys spelled out, and the media dict never has them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PLzXae5up2pYXRoBjfjn2G
* test(upload): assert cleanup against the patched upload directory
The 409 test checked config's ROM_UPLOAD_TMP_BASE while the fixture patches
the endpoint's copy to tmp_path/uploads, so it passed even if cleanup failed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PLzXae5up2pYXRoBjfjn2G
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
State names were built with toISOString() in the browser, and save,
streaming save and memory card names with datetime.now(timezone.utc) on
the server, so every timestamp in an asset's file name was UTC. States
now use the browser's local time and server-named assets use the
server's local time (the container's TZ). Matching and ordering read the
stored file_name and the DB timestamps, so existing files are unaffected.
Fixes#4726
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- A label longer than the request limit no longer becomes a container's
name, so every published name is one the desktop endpoint accepts. The
limit moves to handler.streaming.config as CONTAINER_NAME_MAX_LENGTH.
- A label equal to another container's key in any case no longer names
its container, matching the case-insensitive lookup.
- An oversized broker manifest now fails the import build instead of
being dropped, which lost the state typing of the base's entries.
- A broker error body is read against a 5 second deadline, like every
other broker read.
- Type the _labelled test helper.
- config: one _keys_by_label grouping serves both the unique-label map
and the shared-label warning.
- claim_session: one abort-and-raise for either refused pick; the
newest-save lookup is a single conditional expression.
- launch: pick refusal fields off one optional ImportRefusedError.
- imports: skip_state is always true for a foreign save archive; drop an
unreachable KeyError and the unused str form of _read_member.
- webstation: ImportSpec.state_channel is a Literal.
- Stream.vue: the 400 refusal hint folds into the generic server branch;
pickableStates drops a guard nativeStreamStates already has.
Security (from the step 1 audit):
- Inflate zip entries a chunk at a time, so an entry whose header
understates its size fails the CRC check instead of inflating in full.
- Cap the broker manifest at 1 MiB before reading it.
- Rebuild copied entries as regular files, keeping only permission bits,
so a symlink entry cannot ride into the container.
Code review (xhigh):
- Bound the broker error body read at 1 MiB and truncate what is logged
and returned.
- De-duplicate refusal hints in Stream.vue.
- Unpack only save members as zips; a zip-shaped state stays whole.
- Pick the newest state off an archive by created_at.
- Run newest_restorable off the event loop.
- Name a carried base entry by its staged path in the manifest.
The streaming config now ships import_kinds per container, from the broker's
cached import-spec, so the picker hides foreign saves and states a broker would
refuse instead of failing them after the launch starts.
On DuckStation and RPCS3, a save pick other than the newest archive no longer
lets that archive's own exit state stand in for the picked state: the state
rides the import archive, or the resume is reported lost where the broker
cannot import it.
- build ImportRefusalSchema directly in the broker, dropping the mirror dataclass and the asdict conversion
- replace the resume_via_import/resume_needs_import pair with one ResumeImport literal
- stage base and foreign zips through a shared helper, parse each member once, and read the base only when something is imported
- ImportSpec.kinds is a set of names, and a successful import-spec answer is cached briefly so one claim asks once
- show the suggested emulator's display name in the refusal hint
- trim long comments and the dangling spec reference
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- recheck import-spec right after the win; refuse a foreign save/state the won broker will not import instead of sending it natively
- only route an older native exit state through the import archive when the broker takes archive-channel states
- withhold resume_slot from activate when the import was lost
- import_spec: webstation-only, ACK timeout, catch http.client errors
- keep a foreign archive's own state out of a save import; preserve member timestamps and modes
- fix cs_CZ/pl_PL plural forms, a stale picker comment, and change-history docstrings
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Declare the container and claimed_at query params once, with named length limits.
- Add lifecycle.start_exit_save_pull for the two callers that mark and start back to back.
- Build every claim query on the frontend through one claimParams helper.
- Drop PlayerState casts that narrowed nothing in the launch socket handlers.
- Reuse _load_session in the _drain test helper.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Exit-state emulators with no uploaded archive no longer send a resume slot or report resume=true.
- isCoreCompatible compares emulator ids case-insensitively, like grouping and labels.
- launch-ready skips enterStream when a status poll already entered the stream.
- A Desktop heartbeat answered after a release no longer overwrites the exited state.
- Drop the notice_in_scope alias, reuse session_is_desktop, trim over-long comments.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Deleting a save or state removed its thumbnail row and file unconditionally,
so a save and a state sharing a stem lost the shared preview when either one
went. Every delete path (single and bulk deletes, slot pruning, streaming
history pruning) now goes through release_thumbnail, which keeps:
- a thumbnail another save or state still matches by name, checked in SQL the
way their thumbnail lookup matches, so it follows the database collation;
- a gallery screenshot that only shares the stem by chance;
- the file, when dropping the row, if another row spells the same file in a
different case on a case-insensitive filesystem.
Renaming reuses the same is_bound check to decide whether a thumbnail is
shared, replacing the casefold helper.
Addresses Greptile's review on #4749.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Port the branch's emulator labels and live-state flag onto master's typed
streaming schemas, and carry the labelled state reason into
useSaveStateTabs now that the EmulatorJS view delegates to it.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Re-measure the phone event rows whenever a web font finishes loading,
and when a scrollbar narrows the rows, not only at mount.
- Log only the kind of an audit claim key when Redis fails, since a
failed sign-in's key holds the text typed as the username.
- Make play-session ingest take the caller's permissions explicitly, so
no caller skips the hidden-rom check by leaving them out.
- Read an empty collection cover URL as no cover, as the other fields do.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A failed LaunchBox or Switch TitleDB download, or an unreadable LaunchBox
archive, now fails the task instead of returning empty stats, so its
starter hears it failed rather than finished.
- The inbox replays changes made while a fetch is in flight onto its
response, so a push, read or dismissal is not undone by an older list.
- A refused mark-read turns its rows unread again, and the inbox view tries
each row once a visit so a failing server is not asked in a loop.
- Recipient resolution and sender attribution move from the endpoint into
notification_handler.
- SendNotificationSection inherits attributes again, and record_termination
loses a docstring sentence the code already says.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- One home for pushing to a user's room: `SocketHandler.emit_to_user`, on a
write-only manager kept per event loop and on the server's own channel.
Streaming's push_to_user and the sync and scan emitters use it too.
- Notifications are stored in one transaction per send, so a broadcast is one
commit, and pushed concurrently. Recipients are resolved from id and
enabled only, and the actor is loaded with just the fields it shows.
- notify_user_or_admins holds the "whoever started it, else the admins"
rule both the scan and the task runner applied by hand.
- A scan notifies from finish(), so no exit path can forget it.
- `data` is never null, dropping its guards; the toast host, the inbox and
the admin form share one tone icon map; the inbox icon uses RAvatar.
- The store keeps its list when a socket echo changes nothing, and small
dead parameters and duplicated lists are gone.
- The socket reconnect after a logout moved from the inbox to AppLayout,
since every v2 feature depends on the socket's identity.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Toasts disappear after a few seconds, and nothing reaches a user who has no
tab open. Notifications are now stored per user and kept until dismissed, so
what a background job or another user did is waiting the next time RomM is
opened.
Backend:
- `notifications` table (0130) with kind, level, data, actor and read_at, capped
at the newest 200 per user.
- /api/notifications: list, mark read, dismiss one, dismiss all.
- notify()/notify_admins() store the row and push `notifications:new` to the
user's socket room; read/dismiss push to the user's other tabs.
- Producers: a scan's end (to whoever started it; an unattended scan tells
the admins when it failed or found new games), a manual task's end (to who
ran it; a scheduled task's failure to the admins), an admin ending someone's
stream, and an admin changing someone's role.
Frontend (v2):
- Unread count badge on the navbar avatar, and a Notifications entry in the
user menu and settings sidebar.
- Notifications view: marks what it shows read, links each row to what it is
about, dismiss one or all.
- Live toast for a new notification, except scans, which already toast.
- The text is rendered from the kind in the reader's language (18 locales).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>