Skip to content

Show only the letters that have items in the alphabet bar - #1975

Open
SergeiAK wants to merge 1 commit into
damontecres:mainfrom
SergeiAK:alphabet-present-letters
Open

SergeiAK wants to merge 1 commit into
damontecres:mainfrom
SergeiAK:alphabet-present-letters

Conversation

@SergeiAK

@SergeiAK SergeiAK commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Description

The bar shows every letter of the interface language, whatever the library actually holds. In
English that is 27 entries, # and the 26 Latin letters. In languages that add their own script
on top of Latin the bar more than doubles: 60 entries in Russian — the same 26 Latin letters plus
33 Cyrillic ones — and 49 in Hebrew.

On my library that plays out like this. Russian interface, 539 movies, 31 of the 60 entries in
use. The bar does not fit on screen, and two thirds of it does nothing: you hold a direction
through letters that lead nowhere.

This change asks the server which letters are in use and shows only those. The counting reuses
the request the grid already pages through, with nameStartsWith=<letter> and limit=0, so the
server answers each one with a count and no rows; a letter is kept when its count is not zero.
# stands for everything that sorts before the first real letter, which is where a jump to #
lands today.

The counts run five at a time, once, when the grid opens with sort-by-name, and are cached per
filter, so flipping the sort direction or returning to the library does not repeat them.
Presence is deliberately checked with nameStartsWith instead of being derived from
nameLessThan offsets: that way it does not depend on the order of jump_letters agreeing with
the server's collation. In values-ru the letter Ё sits between Е and Ж, while the server
sorts ё after я, so an offset-based check would have declared everything from Ж to Я
empty.

When counting is not possible the bar stays exactly as it is today: a request that cannot be
narrowed by name, a failed count, or a library where none of the listed letters match. The
alphabet itself still comes from the interface language, and the letter string is read in the
composition, so it follows the per-user language on Android versions below 13 as well.

Related issues

Follows up on discussion #1765, where the request was to stop showing letters a library has
no titles for.

Not related to #968: this does not change where a jump lands, only which letters are offered.

Testing

Jellyfin 10.11.11. Two boxes: an Amlogic S905X4 on Android 14 and a Shield Pro 2019 on
Android 11, which covers both the framework and the AppCompat per-app-locale paths.

  • Movies library, 539 items, Russian UI: 60 letters → 31. Matches the per-letter counts
    computed independently against the server, letter for letter, including the gaps at Ё and
    Й, and the Latin K, T, Z that survive because the server strips leading articles
    ("The Three Flavours Cornetto Trilogy" sorts under T).
  • Series library, 99 items: 60 → 24, again an exact match, with no Latin letters at all.
  • Filters: a "1930s" decade filter narrows the same library to 4 items and the bar to
    # В Л С. Clearing the filter restores the full set.
  • Sorting: switching to "Date added" hides the bar as before; switching back to name brings it
    straight back from the cache, with no new requests.
  • List layout: same narrowed bar as the grid.
  • Jumping to a letter still lands on the first item of that letter.
  • Per-app language: with the app set to English while the system stays Russian, the same
    library shows # K T Z — the English alphabet narrowed to what it has. Checked on Android 11,
    where the per-app locale comes from AppCompat rather than the framework.
  • Unit test for the narrowing helper (FilterPresentLettersTest).
  • Not covered: music artists, since I have no music library. That path is the same code with
    GetArtistsRequest.

Cost, measured on my server over LAN: the 60 counts take 72 ms each on average (median 69 ms,
max 148 ms), 4.3 s in total if run one after another, so roughly 0.9 s of wall time at five in
flight. On the Amlogic box over Wi-Fi the pass finished before the grid's first paint in both a
cold start and a warm run: a 20 fps screen recording shows the grid's first frame already
carrying the narrowed bar, so the bar never appears at full length and then jumps.

Scope is library folders, grid and list view — the "Library" and "Collections" tabs both go
through CollectionFolderView. Favorites, genres and studios keep the full alphabet, since
jumpLetters is an optional parameter on CardGrid. Happy to wire the others the same way.

Two things come with the bar being data-driven. The current-letter highlight now looks the
focused item's letter up in the bar instead of mapping through a hardcoded A–Z, so it works
in Cyrillic, Greek and Hebrew locales; before, the circle sat on # for every non-Latin title.
And AlphabetButtons keys its per-button FocusRequester/InteractionSource lists on the
letters, since the letters can now change while the composable is alive.

The gain scales with how much of its alphabet a library leaves unused. Of the 31 locales that
define the letter string, 20 carry the plain 27 entries; the rest add a script of their own:
ru 60, iw 49, sk 43, six Nordic and Slavic locales 30–31. Two replace Latin instead of
extending it, uk with 34 entries and el with 25. On a plain English library the trim is
smaller but real, # included. One honest limit: when the titles are in a script the interface
language does not cover, most letters have no items and the bar gets short — those letters were
not useful before either, since they all jump into the same narrow region, but it is a visible
change.

Screenshots

Before, Russian UI: the bar carries all 60 entries and runs past the bottom of the screen.
alphabet-before-movies

After: 31 entries, the ones the library actually has.
alphabet-after-movies

With a decade filter leaving 4 titles, the bar is # В Л С.
alphabet-after-filter

With the app language set to English on the same Cyrillic library, the bar is # K T Z.
alphabet-shield-en-ui

AI or LLM usage

The code was written with Claude (Claude Code): the per-letter counting in
CollectionFolderViewModel, the rememberJumpLetters helper and the pass-through parameter in
CardGrid. I reviewed every line and can explain it. The measurements above were taken on my
own devices and cross-checked against my server. This description was drafted with the same
assistant from my notes and then corrected by me.

🤖 Generated with Claude Code

@SergeiAK
SergeiAK force-pushed the alphabet-present-letters branch from 6549e9b to 4cbf19b Compare September 15, 2026 18:22
@SergeiAK

Copy link
Copy Markdown
Contributor Author

Friendly check-in, since this has been open for four weeks and v1.0.9 has shipped in the meantime.
No rush — I know the release took priority. I'll rebase onto the current main this week so the
diff stays clean. Questions about the approach are welcome.

The bar listed every letter of the UI language, so a Russian library
scrolled through 60 letters to reach the 15 that had titles.

The library view now counts the items per letter with the same request
the pager uses (`nameStartsWith`, `limit=0`, so the server answers with a
COUNT and no rows) and hands the bar only the letters with a non-zero
count. `#` covers everything sorting before the first real letter, which
is where jumping to it lands. Counts run five at a time and are cached
per filter; if a filter cannot be counted (`/Persons`) or a request
fails, the bar keeps every letter as before.

The alphabet still comes from the UI language: the letter string is a
resource resolved in the composition, so it follows the per-user UI
language on every Android version.

While the bar is data-driven, the current-letter highlight looks the
letter up in the bar instead of a hardcoded `A`-`Z`, so it works for
Cyrillic, Greek and Hebrew locales too; and the per-button focus state
in `AlphabetButtons` is keyed on the letters, since they can now change.

Favorites, genres, studios and collections keep the full alphabet.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@SergeiAK
SergeiAK force-pushed the alphabet-present-letters branch from 4cbf19b to 6af817e Compare October 12, 2026 12:18

This branch has not been deployed

No deployments
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.

1 participant