Commit Graph

6 Commits

Author SHA1 Message Date
Spinnich
82caaf87a9 fix(platforms): address review feedback on PR #3855
Bound the user-authored fields. `description` (TEXT) and `custom_name`
(VARCHAR(400)) had no length constraint, so an oversized value reached the
database and surfaced as an unhandled DataError, turning a bad request into
a 500. Both are now validated against the column limits, which are defined
next to the columns so the bounds can't drift from the schema. The
`custom_name` case predates this branch but shares the line of code.

Make platform updates a true partial update. The shared API service took a
whole Platform object and sent every field, so the v1 rename drawer replayed
whatever description it happened to be holding; if another client had changed
the description in the meantime, renaming silently reverted it. The service
now takes explicit optional fields, so omitting one means "leave it alone"
rather than "write back my cached copy".

Watch the two form fields independently. Re-seeding both whenever either
canonical value changed meant a socket update touching only the name threw
away an unsaved description edit, and vice versa.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-20 20:01:05 +00:00
Spinnich
98e8ae7599 feat(platforms): add editable platform descriptions
Custom platforms could only be distinguished by name, which is often not
enough context (e.g. a "Sega - Genesis/Mega Drive (Unofficial)" folder
holding aftermarket and unlicensed dumps). Platforms now carry an
optional free-text description, mirroring collections.

The column is nullable and defaults to "", matching custom_name, so a
rescan (which merges a freshly scanned Platform over the existing row)
leaves it untouched. update_platform patches only the fields sent, so an
omitted description is preserved and an empty string clears it.

Surfaced in the v2 UI only: the Settings tab name form now covers both
custom_name and description, and PlatformHead renders the description as
a chip alongside the metadata chips. v1 is frozen and gets no new UI, but
round-trips the field unchanged through the shared API service.

Closes #3402

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-20 19:00:30 +00:00
Georges-Antoine Assi
a67132a908 Surface never-scanned platform folders in the scan picker
A platform folder created on disk (optionally bound in Library
Management) has no database row until its first scan imports a ROM, so
it was invisible to the scan platform picker and a first scan could not
be triggered for it. The picker also filtered to rom_count > 0, hiding
even zero-ROM database platforms (e.g. those created via romm-cli).

Backend:
- Add GET /platforms/filesystem returning folders on disk without a
  database row yet (locally-resolved metadata, id -1, rom_count 0).
- scan_platforms / the scan socket now accept platform_fs_slugs so a
  folder can be scanned by slug; database platforms stay accepted by id.

Frontend (v2):
- Fetch filesystem folders, key the scan picker by fs_slug, include
  zero-ROM database platforms, and tag never-scanned folders.

Fixes #3832

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-19 22:13:16 -04:00
Georges-Antoine Assi
0158097389 fix(platform): accept embedded custom_name body on platform update
Removing the aspect_ratio body field left update_platform with a single
scalar Body() param. FastAPI stops embedding a lone scalar body, so the
endpoint began expecting a bare JSON string while the frontend keeps
sending {"custom_name": "..."}, producing a 422 when editing a
platform's display name in v2.

Restore the embedded-key contract with Body(embed=True), matching the
frontend payload and every sibling update endpoint. Regenerate the
frontend types (restores the Body_update_platform model) and add an
endpoint regression test.

AI assistance: written with Claude Code (Opus 4.8).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 09:21:10 -04:00
Georges-Antoine Assi
ed6f9f5907 cleanup endpoint tests 2026-03-14 23:56:46 -04:00
Michael Manganiello
ba21cbc1e1 misc: Separate tests folder from backend code
Create separate `tests/` folder for all tests. This will also simplify
not copying tests code into the Docker image.
2025-08-08 12:49:13 -03:00