Skip to content

feat(web): jump to a letter in title-ordered library browse - #2346

Merged
Quick104 merged 8 commits into
mainfrom
feat/web-library-letter-bar
Oct 12, 2026
Merged

Quick104 merged 8 commits into
mainfrom
feat/web-library-letter-bar

Conversation

@Quick104

@Quick104 Quick104 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #2130
Related issue: N/A
Validation tasks: none

In the web app, the only way to reach a title partway through a large library is to scroll there, flip the sort, or search for it by name. This adds an A–Z bar to library browse when the list is sorted by title. Choosing a letter scrolls the full list to that letter's first title. Letters with no titles are greyed out.

Approach

Jump within the list instead of filtering it. The v2 browse already accepts name_prefix, but filtering the grid to one letter hides the rest of the list and loses the reader's place. The grid is virtualized and loads distant windows with seek, so all a jump needs is each letter's position. A new additive v2 operation provides it:

  • POST /api/v2/catalog/letters (queryCatalogLetters) takes a browse's library, type, rule groups, and title order. It returns each letter that has titles, with its count and the zero-based position of its first title, plus the exact total. It also returns the runs of consecutive titles under one letter, which tell which letter any list position is under even when the database collation sorts some of a letter's titles apart from the rest. getCatalogSearchCapabilities reports letter_index: true.
  • Titles file under their sort title, the same key name_prefix matches, so "The Hobbit" files under H. Accented Latin initials fold to their base letter, and digits, symbols, and other scripts go under #.
  • Positions come from ROW_NUMBER() over the same query plan, ORDER BY, and tie-break that the cursor pager and seek use. They therefore match the list under any database collation. The cost is one sort of the filtered result, comparable to an exact count, with the same 10-second deadline as a window seek. It covers the query source in title order only; other sorts and search text are refused, and the web hides the bar when the browse carries a query_limit.

Web. The bar is a fixed rail on the right edge of the viewport at every width, compact on phones like a contacts index. It is one tab stop: arrow keys, Home and End, or typing a letter move between letters that have titles, and Enter or Space jumps. Each letter is labelled with its title count, the current letter has aria-current, and a status region announces the jump. On a touchscreen, dragging along the rail jumps as the finger passes each letter.

The grid scrolls the target row to just below whichever sticky header is showing. It also takes its height from the index's exact total instead of the estimate it grows while scrolling. The letter index is cached like the browse and refreshed with it, scoped to the library that changed. During a scan, a letter-index read that is already running finishes before the next one starts instead of being cancelled, and a failed refresh shows the usual refresh notice. The current letter follows the runs. The URL stays the source of truth for sort and filters; a jump is an action, not state.

Apple and Android already have A–Z, implemented as a name_prefix filter. Follow-ups to adopt the jump are linked below. jellycompat needs nothing: Jellyfin clients use NameStartsWith, which already matches the sort title.

Validation

  • Postgres tests run against a migrated disposable database, run locally on both an en_US.utf8 and a C database. They check that the letters and runs match the cursor pager in both directions and with a rule filter, and that a seek to each position lands on that letter. They cover articles, accents (including Romanian ș and ț), digits and symbols, a non-Latin title, a blank sort title, and the episode scope. Both are added to scripts/ci/db-contracts.txt.
  • Handler tests cover request parsing, the default order, validation errors on body locations, and the capability flag. The contract artifacts, fixtures, ledger, and web types are regenerated.
  • Web tests cover the bar's letters, greyed letters, jumps, announcements, keyboard movement, the current letter across interleaved runs, grid sizing from the exact total, the refresh notice, and when library browse shows the bar. A test of the scan sweep checks that a running letter-index read is not restarted.
  • On a Silo dev deployment with 1,540 titles (the template's 32 plus 1,508 synthetic ones), checked in a desktop browser and an iPhone-sized viewport:
    • clicking, tapping, and the keyboard each land on the chosen letter's first row with that letter marked current;
    • the rail clears the page tabs and the scroll-to-top button, and wraps into two columns in phone landscape;
    • the console shows no errors.
  • Full local gate, re-run after the review fixes and merging main: Go build, vet, gofmt, make lint-changed, web lint, format, build and budget, and the contract, fixture, route-inventory, ledger, path, and case checks pass. make test-go passes except two internal/mediasample tests that run the local FFmpeg; they fail the same way on main. make test-web passes.

Evidence

Before and after on desktop and phone web, from the same library, sort, and data, with recordings of each jump.

Evidence: https://evidence.siloserver.org/r/silo-server/issue-2130/

Risks

  • The letter index sorts the whole filtered result on each request. Responses are cached for ten minutes and refreshed only when that library changes, but a very large library with personalized filters pays a sort per open.
  • The letter index and the browse pages are separate reads, and the index is not fenced to the browse's window snapshot. If a scan adds titles between the two, later positions are off by that many until both refresh. The grid takes the larger of the two totals, so it never hides a title the pages return.
  • When the database collation interleaves titles (a leading # or apostrophe sorted among letters, accented initials after Z under C), a letter's titles may not all be contiguous. The jump goes to the first one, the count still covers them all, and the current letter follows the runs. A # title sorted among the H titles therefore marks # while it is the last title in the top row. On such a database, runs grows with the number of interleaved titles.
  • During a long scan on a large library, the letter index is read again as soon as the previous read finishes, for each viewer on a title-sorted browse.
  • Additive v2 operation and capability field only; v1 is untouched.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

Follow-ups

AI Disclosure

  • Harness: Claude Code (Claude Agent SDK), running in T3 Code
  • Tool(s): Claude Code, including Claude Code subagents
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, at a maintainer's direction; maintainer review pending
  • Adversarial review: before the PR, three read-only Claude Code subagents reviewed the diff. They found a Space-key focus bug, a wrong current letter after jumps near the end, accented capitals filed under # on C-ctype databases, the desktop header covering the target row, per-frame style reads, and a case-colliding file name; all were fixed. After opening, a Codex gpt-6.1-sol review of c2bb53d found two more issues, both fixed in 1f1ca25: the rail was unreadable in phone landscape, and the jump highlight stuck after scroll-to-top. Kody's review of 1f1ca25 found five more, fixed in 3f1e94f: Romanian ș and ț filed under #, the current letter wrong where the collation interleaves letters, the grid sized from the estimated runway, scan refreshes restarting the letter index, and no notice when it failed to refresh. A sixth was already handled. Kody's review of 654bbc0 found that, with a letter index trailing the browse, scrolling back from far pages could shrink the grid below titles it had already shown; fixed in 2f9ab4e.

🤖 Generated with Claude Code

Quick104 and others added 2 commits October 11, 2026 20:43
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add queryCatalogLetters, a v2 letter index giving each letter's count and
first list position for a title-ordered query-source browse, and an A–Z
bar on web library browse that scrolls the virtualized grid to a letter.

Closes #2130

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 9 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f17a1a5b-198e-4dcc-8a25-12310b80f51a

📥 Commits

Reviewing files that changed from the base of the PR and between 5b1c87e and 0f600fe.


📒 Files selected for processing (6)
  • web/src/components/ItemGrid.scroll.test.tsx
  • web/src/components/ItemGrid.tsx
  • web/src/components/catalog/LetterBar.test.tsx
  • web/src/components/catalog/LetterBar.tsx
  • web/src/pages/LibraryBrowse.test.tsx
  • web/src/pages/LibraryBrowse.tsx

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3fe0e862-a9a9-4db6-b555-0aed42ee7f3d

📥 Commits

Reviewing files that changed from the base of the PR and between 654bbc0 and 5b1c87e.


📒 Files selected for processing (6)
  • contracts/api/v2/openapi.json
  • internal/apiv2/catalog_items.go
  • scripts/ci/db-contracts.txt
  • web/src/api/v2/schema.ts
  • web/src/hooks/queries/catalog.test.tsx
  • web/src/hooks/queries/catalog.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.



📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The change adds a catalog letter-index API and uses its title counts and positions to provide A–Z navigation in web library grids. The index supports title sorting, filters, and ascending or descending order. The web browse adds letter jumps, active-letter tracking, and index refresh handling.

Changes

Catalog letter index and API

Layer / File(s) Summary
Compute title-letter indexes
internal/catalog/letter_index.go, internal/catalog/query_executor.go, internal/catalog/letter_index_db_test.go, internal/catalog/letter_index_test.go, scripts/ci/db-contracts.txt
The catalog query executor derives letter buckets and consecutive runs from title-sorted results. Resolver validation restricts supported request scopes. Tests compare index positions with cursor-paged results for movies and episodes.
Expose the letter-index API
internal/apiv2/catalog_letters.go, internal/api/handlers/catalog_items_service.go, internal/apiv2/catalog_items.go, internal/apiv2/router.go, internal/apiv2/catalog_search_capabilities.go, contracts/api/v2/openapi.json, contracts/api/v2/fixtures/*, web/src/api/v2/*, docs/catalog-api.md, internal/apiv2/*test.go, internal/api/testdata/media_routes.txt, internal/contractledger/ledger_test.go
The API accepts a profile-scoped query and returns the total, letter counts and positions, and consecutive runs. The capability response identifies letter-index support. Contracts, fixtures, documentation, and tests describe the operation and its request and response.
Fetch and refresh letter-index data
web/src/hooks/queries/catalog.ts, web/src/hooks/queries/keys.ts, web/src/lib/queryInvalidation.ts, web/src/hooks/queries/mediaSurfaceRefresh.ts, web/src/hooks/queries/mediaSurfaceRefresh.test.ts, web/src/pages/LibraryLoadError.test.tsx
The web query layer fetches and caches letter indexes by library, type, and query fingerprint. Library-scoped invalidation includes letter queries and schedules a follow-up invalidation after matching in-flight reads settle.
Navigate library grids by letter
web/src/pages/LibraryBrowse.tsx, web/src/pages/LibraryBrowse.test.tsx, web/src/components/catalog/*, web/src/components/ItemGrid.tsx, web/src/components/Layout.tsx, web/src/components/LibraryHeader.tsx
The browse page displays the letter bar for eligible title-sorted results and uses index positions for grid jumps. The bar supports keyboard and touch or pen navigation. The grid reports its visible row and scrolls with sticky-header offsets. Tests cover navigation and browse states.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Viewer
  participant LibraryBrowse
  participant useCatalogLetters
  participant CatalogLettersAPI
  participant CatalogIndex
  participant ItemGrid
  Viewer->>LibraryBrowse: Open an eligible title-sorted browse
  LibraryBrowse->>useCatalogLetters: Request letter index
  useCatalogLetters->>CatalogLettersAPI: POST catalog query
  CatalogLettersAPI->>CatalogIndex: Compute title buckets and runs
  CatalogIndex-->>CatalogLettersAPI: Return index data
  CatalogLettersAPI-->>useCatalogLetters: Return CatalogLetters
  useCatalogLetters-->>LibraryBrowse: Provide letters and positions
  LibraryBrowse-->>Viewer: Display letter bar
  Viewer->>LibraryBrowse: Select a letter
  LibraryBrowse->>ItemGrid: Scroll to indexed title position
Loading

Suggested reviewers: rhainland


Merge Risk: ⚪ Minimal · up to 5b1c8

No merge-blocking issue was established for the letter jump feature; it is ready for normal checks.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 46.15% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 30 files. (2 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Issue #2130 is active and directly linked. The PR adds the web letter rail with a # bucket, sort-title grouping, compact short-screen layout, keyboard and touch navigation, and disabled empty letter…
Out of Scope Changes check Passed The API, catalog query-plan support, cache invalidation, grid scrolling, letter rail, documentation, fixtures, and tests directly support issue #2130. The changes do not add unrelated client implement…
Title check Passed The title clearly summarizes the primary change: adding letter-based navigation to title-ordered library browse.
Description check Passed The description directly explains the feature, implementation, validation, risks, and related follow-ups.

Full details: Docstring Coverage

Explanation

Docstring coverage is 46.15% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 30 files. (2 skipped: 2 unsupported.)


✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Adversarial review (gpt-6.1-sol, reviewed c2bb53d)

Two verified web findings: the rail compresses below its label height in landscape on phones, and the current-letter marker can stay pinned after scrolling back to the top. Verification used the source and a harness for the scroll listeners. Focused catalog/API Go checks passed; the two PostgreSQL checks skipped because no test database was configured. Web tests and browser rendering were unavailable.

AI disclosure: Codex, gpt-6.1-sol, at a maintainer's direction.

Comment thread web/src/pages/LibraryBrowse.tsx Resolved
…marker

The rail wraps into two columns when the viewport is too short for 27
readable rows, and a chosen letter stays current only while the page
remains scrolled to the bottom, so scroll-to-top and scrollbar drags hand
the highlight back to the top row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread internal/catalog/letter_index.go Resolved
Comment thread web/src/hooks/queries/catalog.ts Resolved
Comment thread web/src/pages/LibraryBrowse.tsx Resolved
Comment thread web/src/pages/LibraryBrowse.tsx Resolved
Comment thread web/src/pages/LibraryBrowse.tsx Resolved
@silo-triage silo-triage Bot added api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase enhancement New feature or request go Pull requests that update go code javascript Pull requests that update javascript code priority: P2 Limited scope, workaround exists, or polish triaged High-confidence review completed; does not mean fixed, validated, or accepted for release. labels Oct 12, 2026
Quick104 and others added 2 commits October 12, 2026 09:36
Address review findings on the letter bar:

- The letter index also reports runs of consecutive titles under one
  letter, so the bar marks the right letter where the database collation
  sorts some of a letter's titles apart (accented initials under C,
  non-Latin titles after Z).
- Fold Romanian ș and ț to S and T.
- Size the grid from the index's exact total instead of the pager's
  estimated runway, which could add up to five pages of empty slots.
- Let a running letter-index read finish during a scan, then read once
  more, instead of cancelling and restarting it on every sweep.
- Show a refresh notice when the letter index fails to refresh.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

Comment thread web/src/hooks/queries/catalog.ts Resolved
Quick104 and others added 2 commits October 12, 2026 11:52
The grid sizes itself from the larger of the letter index's total and the
items known to exist. Known items counted only the pages in the current
window, so after scrolling back from the end a letter index that trailed
the browse could shrink the grid below titles it had already shown. Keep
the furthest loaded end for the browse and its snapshot instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…er-bar

# Conflicts:
#	scripts/ci/db-contracts.txt
@silo-kody

silo-kody Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌
⚠️ 1 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Preserve optional store capabilities through production wrappers

- Reserve the bar and the grid's padding from the first render of a
  title-ordered browse, with every letter greyed until the index lands,
  so the grid no longer reflows and the bar no longer pops in.
- Count the first row at least half visible below the sticky header as
  the top row. On a long list the scroll can settle a fraction of a pixel
  short of a jump's offset, and flooring counted the row hidden under the
  header, so a jump to Q marked P.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104
Quick104 merged commit 984295b into main Oct 12, 2026
8 checks passed
@Quick104
Quick104 deleted the feat/web-library-letter-bar branch October 12, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase enhancement New feature or request go Pull requests that update go code javascript Pull requests that update javascript code priority: P2 Limited scope, workaround exists, or polish triaged High-confidence review completed; does not mean fixed, validated, or accepted for release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature] A-Z jump bar on web library grids

1 participant