Catalog search and browse flows
Catalog discovery connects remote music data and the local library to screens that help people find, inspect, save, and play music. The main paths are home recommendations, search, browse pages, charts, detail pages, history, and library views. The music-discovery page gives the wider product context; innertube-client and external-content-services cover the service boundary.
Discovery model
Remote catalog items
Remote results use shared catalog item types for songs, albums, artists, playlists, podcasts, and episodes. Screens use these items for display and navigation, while song-like items can also become player metadata and queue entries.
References: app/…/HomeScreen.kt• L912-1023 app/…/OnlineSearchResult.kt• L233-361
Local library items
Local results use database-backed songs, albums, artists, playlists, and podcast records. Library screens apply the selected filter, sort order, and content rules to these records, then expose them as lists or mixed discovery sections.
References: app/…/LibraryViewModels.kt• L74-126 app/…/LibraryViewModels.kt• L129-175 app/…/LibraryViewModels.kt• L200-241
Catalog request flow
The catalog flow starts with a screen request, obtains either remote or local data, applies user content rules, and presents items as playable media or links to a detail screen. A continuation extends a remote list without changing the screen’s item model.
flowchart LR
A[User opens a discovery screen] --> B{Remote or local source}
B -->|Remote| C[Catalog page or search result]
B -->|Local| D[Library or history records]
C --> E[Filter and map catalog items]
D --> E
E --> F[Screen list or section]
F --> G{User action}
G -->|Play| H[Queue or player metadata]
G -->|Open| I[Album, artist, playlist, podcast, or browse screen]
References: app/…/OnlineSearchViewModel.kt• L89-115 app/…/LibraryViewModels.kt• L93-114 app/…/NavigationBuilder.kt• L136-280
Home and explore flows
Home recommendations
The home flow combines personalized local signals with remote home content. It shows quick picks, recent or forgotten listening, similar recommendations, account playlists, community playlists, and remote sections. The screen can load the first useful content quickly, then add heavier recommendation sections in the background.
References: app/…/HomeViewModel.kt• L441-575 app/…/HomeScreen.kt• L663-681 app/…/HomeScreen.kt• L1026-1063
Explore content
Explore adds broad discovery content such as new releases and moods or genres. It is loaded as part of the home discovery state and becomes another home section when its data is ready.
References: app/…/HomeViewModel.kt• L493-505 app/…/HomeScreen.kt• L1039-1063
Home content variants
Home chips replace the default remote sections with a focused feed. A selected chip can also load podcast-specific saved shows and episodes for later. Refresh keeps the selected variant instead of silently returning to the default feed.
References: app/…/HomeViewModel.kt• L607-654 app/…/HomeViewModel.kt• L685-707
Search flows
Online search
Online search supports an all-results summary and focused result types. The available result groups include songs, videos, albums, artists, playlists, podcasts, episodes, and profiles. Each group can load more remote items, while the all-results view keeps the service’s sections together.
References: app/…/OnlineSearchViewModel.kt• L40-50 app/…/OnlineSearchViewModel.kt• L118-190 app/…/OnlineSearchResult.kt• L456-541
Local search
Local search stays inside the library and uses the local database rather than the remote catalog. The search entry point lets the user switch between local and online sources, so the same query can lead to different result models and screens.
References: app/…/SearchScreen.kt• L127-173 app/…/SearchScreen.kt• L288-305 app/…/LibraryViewModels.kt• L83-114
Search history
Search terms are stored locally when search-history pause is disabled. Search input also recognizes direct YouTube URLs and sends videos to playback or opens the matching playlist, album, or artist without a catalog search.
References: app/…/SearchScreen.kt• L133-173 app/…/OnlineSearchResult.kt• L178-197
Browse and chart flows
Generic browse pages
Browse pages handle a remote browse identifier and flatten its grouped results into one catalog list. The resulting items can open album, playlist, or artist pages, which makes browse a general link from service-provided collections into app screens.
References: app/…/BrowseViewModel.kt• L19-42 app/…/BrowseScreen.kt• L66-145
Charts
Charts present ranked remote sections such as trending music and top music videos. The screen keeps the sections grouped for display and appends later chart sections when the service provides a continuation.
References: app/…/ChartsViewModel.kt• L18-63 app/…/ChartsScreen.kt• L212-374
Entity detail flows
Artist pages
An artist page is a remote profile with songs, albums, related items, and subscription state, supplemented by local songs and albums when the artist exists in the library. The page can start from cached data, refresh from the remote catalog, and open more items through an artist-specific browse route.
References: app/…/ArtistViewModel.kt• L58-117 app/…/ArtistViewModel.kt• L143-257 app/…/ArtistScreen.kt• L539-683
Album pages
An album page centers on a local album record and its songs. Opening an online album fetches its current catalog data, updates the local record, and exposes alternate versions as further album links.
References: app/…/AlbumViewModel.kt• L23-61 app/…/AlbumScreen.kt• L188-218 app/…/AlbumScreen.kt• L469-505
Playlist pages
Playlist links split into online, local, cached, automatic, and top-playlist destinations. Discovery items use the online route; library items use local views; podcast library cards can point to service-managed automatic playlists such as episodes for later or new episodes.
References: app/…/NavigationBuilder.kt• L258-327 app/…/HomeScreen.kt• L944-958 app/…/LibraryPodcastsScreen.kt• L224-246
Podcast pages
Podcast discovery uses podcast and episode items from the remote catalog. A podcast page loads the show and its episodes, supports episode search and playback, and links to the host artist page. Saving the show updates the local library and can sync that choice to the remote account.
References: app/…/OnlinePodcastViewModel.kt• L29-71 app/…/OnlinePodcastViewModel.kt• L75-123 app/…/OnlinePodcastScreen.kt• L169-231
Library flows
Library sections
The library is one entry point with views for mixed library content, playlists, songs, albums, artists, and podcasts. Each view uses its own content rules while the parent keeps the active category and view mode.
References: app/…/LibraryScreen.kt• L26-82
Library songs, albums, artists, and playlists
These library views read local records and expose filters and sort choices that change the stream shown to the user. Sync actions refresh the matching remote-owned category, while missing album or artist details can be filled from the remote catalog so local screens remain useful.
References: app/…/LibraryViewModels.kt• L93-126 app/…/LibraryViewModels.kt• L147-195 app/…/LibraryViewModels.kt• L218-305
Library podcasts
The podcast library separates saved episode shows, subscribed channels, and downloaded episodes. It combines remote podcast-channel data with locally bookmarked channels, while saved and downloaded episodes remain local playback collections.
References: app/…/LibraryViewModels.kt• L452-590 app/…/LibraryPodcastsScreen.kt• L213-345
History flows
Local history
Local history comes from playback events in the database. The screen groups events into time ranges, removes duplicate songs within each group, applies the video-content setting, and supports text search, selection, and queue playback.
References: app/…/HistoryViewModel.kt• L42-90 app/…/HistoryScreen.kt• L156-175 app/…/HistoryScreen.kt• L314-432
Remote history
Remote history is available when the user is signed in. The app fetches grouped service history and lets the same screen search, play, and manage those remote songs through remote item actions.
References: app/…/HistoryViewModel.kt• L92-103 app/…/HistoryScreen.kt• L225-313
Screen navigation
Catalog destinations
Navigation carries the identifiers that connect discovery items to detail screens. Album, artist, playlist, podcast, search, and browse routes preserve the remote or local identity needed by the destination view model.
References: app/…/NavigationBuilder.kt• L76-184 app/…/NavigationBuilder.kt• L186-345
Change checklist
When these files or sections are changed, remember to consider these:
- Keep remote item types and their navigation targets aligned. A new catalog item must have a clear open, play, or menu action in the shared result handling.
- Keep continuation handling aligned between the view model and the screen trigger. A changed continuation contract can stop search, home, or chart lists from extending.
- Keep local and remote library state aligned when save, like, subscribe, or podcast actions change. The detail screen and the library view must observe the same updated identity.
- Keep content filters consistent across initial loads, refreshes, and appended pages. Otherwise hidden videos, explicit items, or shorts can return after pagination.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A remote page returns items with missing IDs or duplicate IDs | Lists show repeated rows or navigation keys collide | Screens de-duplicate catalog items before display. |
| A continuation is consumed without retaining the new continuation | Infinite scroll stops after one page | Search, home, and charts replace the stored continuation after each append. |
| A signed-out user selects remote history or account-only podcast data | The remote view has no usable content | The history screen only offers remote history when the account cookie indicates sign-in. |
| A detail fetch fails while no cached or local record exists | The destination has no content to render | Detail screens expose loading or error states, and artist pages can use cached data first. |
| A content setting changes after data load | Results can show items the user chose to hide | View models observe content preferences and rebuild their exposed flows. |
Key files
| File | Why to read it |
|---|---|
| app/…/HomeViewModel.kt | Main source for personalized, remote, account, and podcast discovery data. |
| app/…/HomeScreen.kt | Shows how discovery sections become user-facing cards, lists, navigation, and playback. |
| app/…/OnlineSearchViewModel.kt | Defines the remote search summary, filters, metadata completion, and pagination state. |
| app/…/OnlineSearchResult.kt | Shows result groups, item actions, and the search-to-detail or playback paths. |
| app/…/LibraryViewModels.kt | Defines the local library streams for songs, albums, artists, playlists, and podcasts. |
| app/…/LibraryScreen.kt | Shows the library category model and its screen-level routing. |
| app/…/ArtistViewModel.kt | Shows the remote artist page, cache use, local supplements, and subscription state. |
| app/…/AlbumViewModel.kt | Shows the remote album refresh into the local album model. |
| app/…/HistoryViewModel.kt | Defines local and remote history state. |
| app/…/NavigationBuilder.kt | Maps catalog identifiers to application-facing destinations. |