Fix the alphabet index bucketing by display name instead of Emby SortName #16

Merged
kyuno merged 1 commit from fix/alphabet-index-sort-order into master 2026-09-16 21:44:45 +02:00
Owner

Summary

  • Root cause of the reported out-of-order headers (e.g. A, B, T, B, L): getLibraryItems/getArtists order the array by Emby's SortBy: SortName (which strips leading articles like "The"/"Le"/"L'"), but never fetched each item's actual SortName value — so alphaIndex.ts had to bucket by the raw display name instead, and any article-stripped title landed in a completely different bucket than where Emby had actually placed it in the array, throwing a spurious heading (and a duplicate of the real one right after) into the middle of an otherwise-correct run.
  • Fix: getLibraryItems/getArtists now also request Fields: SortName; new ItemDto.sortName carries it through (server/src/types.ts, client/src/types.ts), falling back to name for every other endpoint that doesn't request it (same shape durationTicks/indexNumber already use); alphaIndex.ts buckets by sortName, not name.

Test plan

  • npm run typecheck — clean (client + server)
  • npm run test (server) — 147/147 passing
  • npm run build (client) — clean
  • Reproduced the exact reported bug first: a small fake item list in Emby's own SortName order with one title ("The Bunker", sortName "Bunker") positioned between two other B titles — confirmed it produced the same A, B, T, B, L heading sequence against the old bucket-by-name code, then confirmed the fix collapses it to the correct A, B, L against the identical input.

🤖 Generated with Claude Code

## Summary - Root cause of the reported out-of-order headers (e.g. `A, B, T, B, L`): `getLibraryItems`/`getArtists` order the array by Emby's `SortBy: SortName` (which strips leading articles like "The"/"Le"/"L'"), but never fetched each item's actual `SortName` value — so `alphaIndex.ts` had to bucket by the raw display name instead, and any article-stripped title landed in a completely different bucket than where Emby had actually placed it in the array, throwing a spurious heading (and a duplicate of the real one right after) into the middle of an otherwise-correct run. - Fix: `getLibraryItems`/`getArtists` now also request `Fields: SortName`; new `ItemDto.sortName` carries it through (`server/src/types.ts`, `client/src/types.ts`), falling back to `name` for every other endpoint that doesn't request it (same shape `durationTicks`/`indexNumber` already use); `alphaIndex.ts` buckets by `sortName`, not `name`. ## Test plan - [x] `npm run typecheck` — clean (client + server) - [x] `npm run test` (server) — 147/147 passing - [x] `npm run build` (client) — clean - [x] Reproduced the exact reported bug first: a small fake item list in Emby's own SortName order with one title (`"The Bunker"`, sortName `"Bunker"`) positioned between two other B titles — confirmed it produced the same `A, B, T, B, L` heading sequence against the old bucket-by-name code, then confirmed the fix collapses it to the correct `A, B, L` against the identical input. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
kyuno added 1 commit 2026-09-16 21:37:01 +02:00
Fix the alphabet index bucketing by display name instead of Emby SortName
Some checks failed
Publier l'image Docker / test (pull_request) Failing after 4s
Publier l'image Docker / publish (pull_request) Has been skipped
6b6a57a5f7
Emby orders (and this app already asked it to) by SortName, which
strips leading articles - an item like The Bunker sorts among the Bs
there, but the index was bucketing by the raw display name, throwing a
spurious T heading into the middle of that run. getLibraryItems/
getArtists now also fetch SortName, ItemDto carries it through, and the
index buckets by that instead - the same key Emby actually used to
order the array, not a guess that usually matches it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
kyuno merged commit 292fec9c19 into master 2026-09-16 21:44:45 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: kyuno/watchparty#16
No description provided.