Commit Graph

12966 Commits

Author SHA1 Message Date
Georges-Antoine Assi
2eb2b5973e refactor(streaming): share the claim query params, mark-and-start the exit save pull in one call, and drop no-op casts (simplify)
- 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>
2026-09-24 17:49:59 -04:00
Georges-Antoine Assi
d99c3c5f7b fix(streaming): report a failed archive resume, stop duplicate stream entry, and fold emulator case in core checks (code-review)
- 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>
2026-09-24 17:43:30 -04:00
Georges-Antoine Assi
ffdbe79032 Merge remote-tracking branch 'origin/master' into streaming-patches-5
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>
2026-09-24 11:37:10 -04:00
Georges-Antoine Assi
5634e4b2ab Merge pull request #4552 from sdornan/feat/surface-save-sync-conflicts
feat(sync): surface save conflicts detected by negotiate
2026-09-24 11:15:22 -04:00
Georges-Antoine Assi
c591ffc163 feat(sync): name the ROM in sync:conflict and log failed sync emits
Every sync:conflict emitter now sends rom_name, so the v2 toast names the
game without hunting through frontend caches. Push-pull emits from the
conflict branch with the matched save's rom_id and comparison reason
instead of rom_id=0. All emit_sync_* helpers go through
socket_handler.emit_to_user, so a broker failure is logged rather than
counted as a failed sync.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 11:05:42 -04:00
Georges-Antoine Assi
cf113a8fd7 simplify: emit negotiate conflicts sequentially under one deadline
With the emits off the response path, the semaphore and gather fan-out
bought nothing. The conflict tests share the module-level negotiate helper
and an emit patch, and the toast tests share their install and fire setup.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 10:56:05 -04:00
Georges-Antoine Assi
419372ac6c review: emit negotiate conflicts from a background task
asyncio.run in the threadpool drove the process-wide socket write manager
from a throwaway loop, racing the main loop and leaking Redis pools. The
events now go out after the response on the app loop. Also logs timeouts
distinctly, corrects the connection comments, and unmounts test hosts.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 10:53:07 -04:00
Georges-Antoine Assi
be31b99f1b Merge remote-tracking branch 'origin/master' into feat/surface-save-sync-conflicts
# Conflicts:
#	frontend/src/v2/layouts/AppLayout.vue
2026-09-24 10:41:34 -04:00
Georges-Antoine Assi
f6607c8ede Merge pull request #4537 from rommapp/renovate/major-mariadb
chore(deps): update mariadb docker tag to v13
2026-09-24 10:31:24 -04:00
Zurdi
91eb4bd22c Merge pull request #4748 from rommapp/claude/audit-log
feat(audit): record what users do and show it in Logs › Events
2026-09-24 15:43:23 +02:00
zurdi
c2c2dd6380 refactor(audit): address Greptile's second review
- The audit read endpoint keeps the access decision but hands the
  category filter to the DB handler, which expands it to actions.
- Trim the log viewer's header comment to two lines and drop its
  em-dashes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 13:03:45 +02:00
zurdi
fabbeef3f1 fix(audit): address the Greptile review
- Record a firmware or rom delete once its row is gone, with whether the
  file actually left the disk, even when cleaning up after it fails.
- Record a download only once there's a response to send, so a missing
  file or a failed zip isn't logged.
- Release a download's, sign-in's or reset request's dedupe claim when its
  event can't be stored, so a retry records it.
- Count the games a collection actually gained or lost.
- Queue the reset-request event before the email, which stops the tasks
  after it when it fails.
- Let an event's data be a lookup, run inside the recorder's error
  handling, for the hide, unhide and permission events.
- Follow a query change while the Events tab stays open, and don't show a
  load error once it has closed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 12:55:23 +02:00
zurdi
6ffaf53281 chore(audit): mark the audit action names as bandit false positives
Bandit's B105 reads the password-reset and client-token action names as
hardcoded passwords.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 12:42:16 +02:00
zurdi
05f3888307 docs(audit): apply the second pr-ready review polish
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 10:34:12 +02:00
zurdi
92f9776772 refactor(audit): apply the second pr-ready simplify pass
- Event log: watch the scroller's own container and web font loads through
  vueuse, re-measure only for a font the rows use, and keep the measurers
  when only the width changes.
- Measure each word once on one shared canvas, and stop counting lines at
  the clamp.
- Set the row geometry once on the list, from one source for the padding
  and gap, instead of on every row.
- Share the file-and-size detail between downloads and player loads, read
  the collection cover change off the saved data, and use recorded_events()
  in the play-session test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 10:28:24 +02:00
zurdi
a779fa41f7 fix(audit): apply the second pr-ready code review
- 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>
2026-09-24 10:18:57 +02:00
zurdi
1e8dba617f feat(v2): stack event details on phones and search as you type
- On a phone each event lists its title, detail, author and where from,
  in that order; the title and detail wrap to two lines, and the list
  sizes every row from how its text wraps at the row's width and fonts.
- The event's icon sits on a solid disc of its category's color.
- The event search runs once typing pauses, like the gallery's, instead
  of waiting for a Search button; Enter still searches straight away.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 10:14:01 +02:00
zurdi
5cccceea60 fix(audit): close the gaps left open by the pr-ready review
- A failed login keeps the attempted username only when it names an
  account, so a password typed into the username box is never stored.
- Gunicorn trusts X-Forwarded-For only from loopback and private ranges
  (FORWARDED_ALLOW_IPS, documented in env.template), so a client can no
  longer choose the address the audit log and rate limits see.
- A player's fetch (purpose=play) is recorded as rom.player_load instead
  of being skipped, so the marker can't hide a download.
- Play-session ingest treats a rom hidden from the caller as unknown, so
  its session and rom.play event don't name it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 08:08:53 +02:00
zurdi
72c4dc7ecb docs(audit): apply the pr-ready review polish
Trim comments to what the code can't say, type the remaining test
fixtures, and document the audit_events table, GET /api/audit-events
and the cleanup_audit_log task in the backend architecture guide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 02:49:27 +02:00
zurdi
d9d65d8b56 refactor(audit): apply the pr-ready simplify pass
- record() takes the request as its actor, and a target can be a
  function: the lookups that name it now run inside the recorder's error
  handling, and for downloads only once the dedupe lets them record.
  That also restores the minimal visibility query on the file route.
- One changed_fields/change pair for rom, user, collection and platform
  edits, one collection helper, AuditActor.anonymous, a shared
  count_in_window and current_device_id, one test helper for recorded
  events and one fixture for audit events.
- The describers share simple/counted/visibility builders and the
  eventData readers with notifications, join lists per locale, and treat
  any *.delete as unlinked.
- EventLog builds one item list with the phase folded in, keeps each
  event's sentence across pages, formats days once, and loads users
  through the users store.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 02:45:12 +02:00
zurdi
6298e7bf8c fix(audit): apply the pr-ready code review
- Hide events on roms of a hidden platform from non-admins.
- Pin later pages to the highest matching id the API returns, not the
  first row's: rows are ordered by when they happened, so a play synced
  late has a higher id than newer events and was dropped.
- Cap recorded failed sign-ins per address, dedupe reset requests and
  record them in the background with the email, and hash claim keys.
- Keep another user's private collection by id only in bulk downloads.
- Check a Range start without int(), which raises past 4300 digits.
- Clear the list when a reload fails, load more only once it's shown,
  report a cover change only when the user made one, label only rom and
  platform unhides, accept an actor kind the API doesn't know.
- One client IP helper, date-fns for today and yesterday, one time
  formatter for the list, no em-dashes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 02:30:47 +02:00
zurdi
0afc141c0f fix(v2): scroll long log lines sideways again
The log tab is as wide as its longest line, so a phone can scroll to the
end of one; the toolbar stays pinned to the left edge meanwhile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 02:12:21 +02:00
zurdi
8700b005b7 feat(v2): move the audit log into Logs as an Events tab
Logs now opens on Events (admins only), with the backend log a tab away
at ?tab=logs. Events reads as a timeline: grouped by day, the time and a
category-tinted icon on a rail, then the sentence and who, what, where.
Both tabs scroll as one piece under fixed tabs: the toolbar scrolls away
with the rows, and the log shows its newest line on top, holding still
while you read further down. The event list is windowed and pulls the
next page in as its end comes into view.

An admin keeps the page when DISABLE_LOGS_VIEWER turns the log off. The
settings content also sits closer under the nav bar on phones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 02:07:04 +02:00
zurdi
f416cc4f04 feat(v2): show the audit log as a list of events
Each event is one row: an icon tinted by its category (red when
something failed), the sentence, its detail, then who, the device and
the address on one line, with the time on the right. No column labels,
so a phone reads it like the notifications inbox.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 01:56:28 +02:00
zurdi
3b71d1c6d1 feat(v2): audit log page for admins
Settings › System › Audit log lists what every user, and RomM itself,
did, newest first: who, what (a sentence built from the event, linking
to its target while it exists), when, and the device and address it
came from. Filters for user, category, date range and a search live in
the URL; later pages stay pinned to the first so new events don't shift
them. Only admins see the entry, and the route guard turns away anyone
else, including a group granted users.read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 01:52:02 +02:00
zurdi
c2a72b322e feat(audit): search the audit log by IP address too
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 01:46:16 +02:00
zurdi
1aa614c321 fix(audit): report only the rom fields a user edited
A save turns null cover and manual urls into empty strings, and a rename
re-derives the sort name; neither is an edit of its own. Also fixes the
test helpers the first local run caught.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 01:33:29 +02:00
zurdi
66deda768c feat(audit): record scans, tasks, sign-ins and account changes
Scans leave a start and an end with their stats, or who stopped them;
manual task runs, sign-ins by session, token and OIDC, failed sign-ins
(one per address and username a minute), password resets, account and
permission changes, client tokens and device approvals each leave an
event. UI settings saves and avatar changes are left out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 01:24:36 +02:00
zurdi
b65ca93bfb feat(audit): record library and collection changes
Uploads, physical adds, edits, manual matches, unmatches and deletes of
roms and their files, platform and firmware changes, config changes and
collection edits each leave an event. An edit that moves a provider id
is a match; a save that changes nothing is not recorded. Favourites are
left out, since every heart toggle is a collection add or remove.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 01:19:22 +02:00
zurdi
283c92c278 feat(audit): record downloads and plays
A ROM, file or bulk download is recorded once per caller within ten
minutes, and only when a transfer starts from the first byte, so range
requests and retries don't multiply it. In-browser players mark their
fetch with purpose=play, and the session they report becomes a rom.play
event instead. Feeds and QR links still count as downloads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 01:14:34 +02:00
zurdi
0afbe2ef57 feat(audit): add the audit_events table, recorder and read API
A persistent record of what users, or RomM itself, did. Admins read
everyone's events through GET /api/audit-events; anyone else gets only
their own. Events older than AUDIT_LOG_RETENTION_DAYS (90 by default,
0 keeps them) are pruned nightly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 01:05:59 +02:00
Zurdi
eaba9c70d1 Merge pull request #4743 from rommapp/claude/rq-workers-restart-loop-588783
fix(docker): stop the watchdog from spawning duplicate RQ workers
2026-09-24 00:01:21 +02:00
zurdi
5cd71a244c simplify: pin the RQ worker PID write with a plain substring check
The test checks the one line the watchdog relies on, next to the keepalive
pair instead of between it, and the comment states RQ's late write once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 21:17:21 +02:00
zurdi
ce36d3f0fb review: guard the RQ worker PID file and comment it where it is written
Adds a test that start_rq_worker records $! instead of passing --pid, and
moves the comment next to the line it explains.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 21:14:34 +02:00
Zurdi
3c5f1d0202 Merge pull request #4740 from rommapp/fix/scan-keeps-hash-source-tags
fix(scan): keep a hash source's tags when a scan skips it
2026-09-23 21:12:46 +02:00
zurdi
87ab23fd38 fix(docker): record the RQ workers' PID as soon as they start
The watchdog restarts any process whose PID file is missing, and RQ's --pid
writes that file only after importing the worker class. Since RomMWorker
imports tasks.tasks (and with it config, SQLAlchemy and the auth and socket
handlers), reaching that point takes seconds on a cold, bytecode-less image,
so on a slower host the watchdog started a fresh pair of workers every 5 s
and each one lived on as a duplicate. The init script now writes $! like it
does for the cron scheduler and the watchers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 21:12:09 +02:00
zurdi
56a9609303 fix(scan): read a kept blob only when it holds lists of strings
Addresses Greptile's review: an edit of a ROM's raw metadata stores
whatever JSON it is given, so a skipped source's stored blob can be a
list or a string, and a dump_* value a bare string. Reading it assumed an
object and would have crashed the ROM's scan or split a tag into
characters; anything else is now read as no tags.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 19:25:56 +02:00
zurdi
9cf751df29 refactor(scan): simplify kept hash-source tags after review
- A kept tag only fills an empty region or language slot: the row's
  value may come from a source the scan didn't ask either (a gamelist),
  and a hash source's old answer mustn't replace it. Fresh answers still
  work as before.
- A rehash that drops the Hasheous match now does so before the tags are
  resolved, so the ROM doesn't take tags from the match it's losing.
- One reader for this scan's blob and the stored one, every tag field
  recorded (empty lists included), and one ordered list of claims instead
  of a dict plus a list.
- The applied sources and the hash sources are ordered in one pass, since
  each pass rereads config.yml, instead of adding a read per ROM.
- Tests: one fixture per lookup, the blob assertion folded into the
  translated-dump test, and new ones for the gamelist case and the
  dropped Hasheous match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 19:13:42 +02:00
zurdi
a961143de1 fix(scan): address the code review of kept hash-source tags
- A handler reporting a tag field as null records no tags instead of
  raising in the middle of the ROM's scan.
- One home each for the tag fields and the blob keys their dump tags are
  kept under, which the writer and the reader both use.
- Test a HASHES scan, which never asks ScreenScraper again and used to
  drop its dump tags every time, and a fresh answer without our dump
  replacing the tags the blob kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 19:07:06 +02:00
zurdi
59920403ae fix(scan): keep a hash source's tags when a scan skips it
The regions, languages and tags a hash-matched source (ScreenScraper,
Hasheous) gave a ROM were only known while that source answered. A scan
that didn't ask it, such as an UPDATE with only IGDB selected or an
UNMATCHED scan of a ROM Hasheous already matched, rebuilt the tags from
the filename and the sources it did ask, and dropped them: the row can't
say which of its tags came from where.

Each hash source now keeps the tags its dump gave in its own blob
(dump_regions, dump_languages, dump_tags), and a scan that doesn't hear
from a source the ROM still carries the id of reads them from there. A
complete rescan still clears the id and blob of a source it drops, so
those tags go with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 19:02:35 +02:00
Sam Dornan
d7f226934b fix(roms): order lettered discs like numbered ones (#4738)
* fix(roms): order lettered discs like numbered ones

"(Disc A)", "(Disc B)" didn't match the disc tag pattern, so a lettered
set fell back to plain file-name order. A bonus file whose name sorted
earlier could then take the first playlist slot and boot instead of
disc A, and mixed-case names ordered wrongly. Lettered discs now count
from A as 1. The letter needs a space after the word, so "(CDi)" is not
read as disc 9.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkUQt5fewjBenaaUMD4XpG

* fix(roms): match only ASCII letters as a disc letter

With re.I alone, [a-z] case-folds non-ASCII letters too: "(Disc İ)"
crashed ord() with a two-code-point lowercase and "(Disc ſ)" became
disc 287. Also trim the pattern comment and docstring to the repo's
comment limits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkUQt5fewjBenaaUMD4XpG

* fix(roms): keep Unicode whitespace in disc tags matching

re.ASCII on the whole pattern also narrowed \s, so "(Disc 2)" with a
non-breaking space lost its disc number. Scope the ASCII flag to the
disc letter alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkUQt5fewjBenaaUMD4XpG

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 11:57:02 -05:00
Zurdi
f11725b835 Merge pull request #4735 from rommapp/claude/notification-channels
feat: forward notifications to webhooks, Discord, ntfy and email
2026-09-23 18:56:29 +02:00
zurdi
167eab5e81 fix: address Greptile's review of notification channels
- A queued delivery checks the channel is still confirmed before it
  sends, so mail doesn't reach an address swapped in since it was queued.
- A redirect counts as a failed delivery, naming where it pointed, since
  redirects aren't followed and it used to be recorded as sent.
- The per-user channel cap is counted and inserted under a lock on the
  user's row, so concurrent adds can't go past it.
- The Channels tab drops a reload that raced a change made meanwhile,
  reverts only `enabled` when a toggle is refused, and holds the delete
  button while its request runs.
- Trim the migration's docstring to one sentence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 18:43:10 +02:00
Zurdi
9091d37552 Merge pull request #4739 from rommapp/claude/gallery-list-right-gap-bb0f25
fix(v2): run desktop list rows to the screen edges
2026-09-23 18:40:44 +02:00
zurdi
45e723facb fix(v2): paint the gallery list row focus inside the row (Greptile review)
Addresses Greptile on #4739:
- The gamepad focus halo is an outward box-shadow, so pulling only the
  outline inward still left it clipped at the scroller's edge. Key and
  pad focus now paint as an inset ring, as AssetGroupHead already does
  for the same clip.
- Trim the IndexShell list bleed comment to two lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 18:39:08 +02:00
zurdi
6f5c1f21b5 test: share one fake Redis keyspace between the sync and async caches
Outside tests one Redis serves both, but each fakeredis client got a
keyspace of its own, so the endpoint tests' flush between tests only
cleared the sync one. A confirmation-code cooldown set through the async
cache in one test then answered the next test's first code with a 429.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 18:33:47 +02:00
zurdi
a16429114d fix(v2): run desktop platform and collection list rows to the screen edges
The platforms and collections index lists had the same gap the gallery
list had: on desktop the rows sat inside the shell's gutter while the
pinned column header's glass ran edge to edge. IndexShell now publishes
its list bleed at every breakpoint, not only on phones and tablets, and
the column rows and headers take that gutter back as padding, so the
columns line up with the toolbar on both sides. With no AlphaStrip here
the bleed is symmetric.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 18:31:09 +02:00
zurdi
3d055ff6b9 refactor(v2): tidy the desktop list bleed (simplify)
- The shell bleeds the column header itself, as it already does in
  compact mode, so GameListHeader needs no modifier of its own. Its
  min-width lives in the same desktop rule, so the compact placeholder
  value for `--r-list-min-w` goes.
- The list min-width no longer counts the rows' leading padding, which
  sits in the gutter they bleed into.
- A bled row keeps at least its `--r-space-3` leading padding.
- The row's focus ring is the global one pulled inside by its width,
  so it keeps its modality gating and per-modality width.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 18:24:54 +02:00
zurdi
9fec08ed31 docs: say why the code cooldown isn't per channel without the alternative
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 18:23:34 +02:00
zurdi
355a1a3314 fix(v2): inset the gallery list row focus ring (code-review)
Now that desktop list rows run to the scroller's left edge, the generic
outset focus ring lost its left side to the scroller's clip. Paint it
inset, as the platform and collection rows already do. Also drop a
`left: 0` on the pinned header glass that changed nothing, since the
scroller clips that overhang anyway.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 18:19:31 +02:00