Skip to content

Add ES-DE <sortname> import and edit support for ROM ordering#3460

Merged
gantoine merged 14 commits into
masterfrom
copilot/support-sortname-tag-es-de
Jun 18, 2026
Merged

Add ES-DE <sortname> import and edit support for ROM ordering#3460
gantoine merged 14 commits into
masterfrom
copilot/support-sortname-tag-es-de

Conversation

Copilot AI commented May 31, 2026

Copy link
Copy Markdown
Contributor

ES-DE gamelist.xml imports were ignoring <sortname>, so collections with Kanji/Hanzi titles could not preserve the intended library ordering. This change imports that field, uses it for ROM name sorting without changing the displayed title, and exposes it as an editable ROM field.

  • Import ES-DE sort metadata

    • Parse <sortname> from gamelist.xml
    • Preserve it in gamelist metadata and on the ROM record as sort_name
  • Use sort_name for ordering

    • Prefer Rom.sort_name over Rom.name when ordering by name
    • Keep name as the display title; only sort behavior changes
  • Persist the new field

    • Add a migration introducing nullable roms.sort_name
  • Expose sort_name for editing

    • Include sort_name in ROM read/update API schemas
    • Add sort_name to the ROM edit dialog so it can be changed manually
    • Clear sort_name when metadata is unmatched
  • Cover the new behavior

    • Add parser coverage for <sortname>
    • Add DB-level coverage proving name ordering follows sort_name when present
    • Add endpoint coverage for editing and clearing sort_name
<game>
  <path>./akumajou-dracula.zip</path>
  <name>悪魔城ドラキュラ</name>
  <sortname>Akumajou Dracula</sortname>
</game>

With this imported, the ROM still displays as 悪魔城ドラキュラ, but name sorting uses Akumajou Dracula. The imported sort title can also be reviewed and edited later from the ROM edit form.

Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for sortname tag in ES-DE gamelist.xml import Add ES-DE <sortname> import support for ROM ordering May 31, 2026
Copilot AI requested a review from gantoine May 31, 2026 13:48
@gantoine

gantoine commented May 31, 2026

Copy link
Copy Markdown
Member

@copilot include this issue in your work, where we expose sort_name as an editable field: #742

Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>

Copilot AI commented May 31, 2026

Copy link
Copy Markdown
Contributor Author

@copilot include this issue in your work, where we expose sort_name as an editable field: #742

Addressed in 3f98aa1: sort_name is now exposed through the ROM update API and edit dialog, and unmatching metadata clears it as well.

Copilot AI changed the title Add ES-DE <sortname> import support for ROM ordering Add ES-DE <sortname> import and edit support for ROM ordering May 31, 2026
@gantoine gantoine added the on-hold Pending further research or blocked by another issue label May 31, 2026
@gantoine gantoine marked this pull request as ready for review May 31, 2026 17:21
Copilot AI review requested due to automatic review settings May 31, 2026 17:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds ES-DE <sortname> support so imported ROMs can keep a display title while using a separate value for name-based ordering.

Changes:

  • Adds sort_name to the ROM model, migration, API schemas, update endpoint, and frontend edit form.
  • Parses ES-DE <sortname> from gamelist.xml and persists it during scans.
  • Updates ROM name ordering logic and backend tests for sorting/import/update behavior.

Reviewed changes

Copilot reviewed 15 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
backend/alembic/versions/0082_add_rom_sort_name.py Adds nullable roms.sort_name column.
backend/models/rom.py Adds sort_name ORM field.
backend/handler/database/roms_handler.py Uses sort_name as the effective name-sort key when present.
backend/handler/metadata/base_handler.py Extends metadata ROM payload typing with sort_name.
backend/handler/metadata/gamelist_handler.py Parses <sortname> into gamelist metadata and ROM data.
backend/handler/scan_handler.py Initializes and preserves sort_name during scan updates.
backend/endpoints/roms/__init__.py Accepts, updates, and clears sort_name through the ROM update endpoint.
backend/endpoints/responses/rom.py Exposes sort_name in ROM response schemas.
backend/tests/handler/test_db_handler.py Adds DB-level coverage for sort_name ordering.
backend/tests/handler/metadata/test_gamelist_handler.py Adds parser coverage for <sortname>.
backend/tests/endpoints/roms/test_rom.py Adds endpoint coverage for editing and clearing sort_name.
frontend/src/services/api/rom.ts Includes sort_name in ROM update form data.
frontend/src/components/common/Game/Dialog/EditRom.vue Adds editable Sort name field to the ROM dialog.
frontend/src/locales/en_US/rom.json Adds English label for Sort name.
frontend/src/locales/en_GB/rom.json Adds British English label for Sort name.
frontend/src/__generated__/models/SimpleRomSchema.ts Regenerates frontend simple ROM schema with sort_name.
frontend/src/__generated__/models/DetailedRomSchema.ts Regenerates frontend detailed ROM schema with sort_name.
frontend/src/__generated__/models/Body_update_rom_api_roms__id__put.ts Regenerates update request schema with sort_name.
Files not reviewed (3)
  • frontend/src/generated/models/Body_update_rom_api_roms__id__put.ts: Language not supported
  • frontend/src/generated/models/DetailedRomSchema.ts: Language not supported
  • frontend/src/generated/models/SimpleRomSchema.ts: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread frontend/src/locales/en_US/rom.json Outdated
Comment thread frontend/src/services/api/rom.ts Outdated
Comment thread backend/handler/metadata/base_handler.py Outdated
@gantoine gantoine removed the on-hold Pending further research or blocked by another issue label Jun 18, 2026
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Test Results (postgresql)

    1 files  ±    0      1 suites  ±0   5m 34s ⏱️ + 5m 19s
1 664 tests +1 654  1 664 ✅ +1 664  0 💤 ±0  0 ❌ ±0 
1 666 runs  +1 656  1 666 ✅ +1 666  0 💤 ±0  0 ❌ ±0 

Results for commit 8922c2d. ± Comparison against base commit c84e91d.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Test Results (mariadb)

    1 files  ±    0      1 suites  ±0   4m 43s ⏱️ + 4m 27s
1 664 tests +1 654  1 664 ✅ +1 664  0 💤 ±0  0 ❌ ±0 
1 666 runs  +1 656  1 666 ✅ +1 666  0 💤 ±0  0 ❌ ±0 

Results for commit 8922c2d. ± Comparison against base commit c84e91d.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
17804 12946 73% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
backend/endpoints/responses/rom.py 94% 🟢
backend/endpoints/roms/_init_.py 70% 🟢
backend/handler/database/roms_handler.py 66% 🟢
backend/handler/metadata/base_handler.py 98% 🟢
backend/handler/metadata/gamelist_handler.py 61% 🟢
backend/handler/scan_handler.py 66% 🟢
backend/models/rom.py 94% 🟢
TOTAL 78% 🟢

updated for commit: 8922c2d by action🐍

gantoine and others added 4 commits June 18, 2026 09:28
Collapse the separate `sort_name` column into `name_sort_key`, which is now
the single user-settable sort field: always normalized and indexed for fast
ordering, derived from `name` by default, and overridable. A new
`name_sort_key_custom` boolean marks user/metadata overrides so they survive
renames and rescans.

- Drop the `roms.sort_name` column; repurpose migration 0085 to add
  `name_sort_key_custom`.
- Derive the key via `@validates("name")` unless pinned custom; the edit
  dialog, unmatch flow, and ES-DE gamelist <sortname> set custom keys.
- update_rom / scan_rom keep the columns in sync explicitly (bulk update and
  construction bypass / reorder the validator).
- Frontend: edit field drives name_sort_key (empty when auto), api sends the
  override only when custom, regenerated types updated.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Drop the name_sort_key_custom flag/migration in favour of a flagless rule: a
key is "custom" when it no longer equals compute(name). Apply that consistently
across all three write paths so a manual sort key survives renames while a
derived key keeps following the name:

- @validates re-derives on name assignment only when the stored key still
  matches the derived value; direct name_sort_key assignment stores a
  normalized custom key (or reverts to derived when cleared). Handles both
  kwarg orders at construction.
- update_rom mirrors the same check for the bulk update() path it bypasses.
- The edit endpoint only writes the key when the user actually changed the
  field, delegating the untouched case to update_rom.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
gantoine and others added 4 commits June 18, 2026 11:42
Backfill the `sort-key` key (added to en_US/en_GB) across the remaining 15
locale rom.json files with translations, so check_i18n_locales passes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 33 out of 37 changed files in this pull request and generated 4 comments.

Files not reviewed (4)
  • frontend/src/generated/models/Body_update_rom_api_roms__id__put.ts: Generated file
  • frontend/src/generated/models/DetailedRomSchema.ts: Generated file
  • frontend/src/generated/models/RomGamelistMetadata.ts: Generated file
  • frontend/src/generated/models/SimpleRomSchema.ts: Generated file

Comment thread frontend/src/components/common/Game/Dialog/EditRom.vue Outdated
Comment thread backend/alembic/versions/0084_add_roms_search_and_sort_indexes.py
Comment thread backend/alembic/versions/0084_add_roms_search_and_sort_indexes.py Outdated
Comment thread backend/alembic/versions/0084_add_roms_search_index.py
@gantoine gantoine merged commit 1e97483 into master Jun 18, 2026
18 checks passed
@gantoine gantoine deleted the copilot/support-sortname-tag-es-de branch June 18, 2026 18:00
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.

[Feature] Support for <sortname> tag in ES-DE gamelist.xml import

3 participants