Skip to content

feat: add History view with YouTube Music API#171

Merged
sozercan merged 4 commits intosozercan:mainfrom
pukuba:add-listening-history
Apr 7, 2026
Merged

feat: add History view with YouTube Music API#171
sozercan merged 4 commits intosozercan:mainfrom
pukuba:add-listening-history

Conversation

@pukuba
Copy link
Copy Markdown
Contributor

@pukuba pukuba commented Apr 5, 2026

Summary

image
  • Add a History section in the sidebar that displays listening history fetched from YouTube Music's FEmusic_history API endpoint
  • Songs are grouped by time period (Today, Yesterday, This Week, etc.) as provided by the API
  • No local storage — data comes directly from YouTube Music's server
  • History refreshes automatically when navigating to the tab after playing a new song, and includes a manual refresh button with spinning animation
  • Smart refresh: skips UI update when data hasn't changed to prevent scroll jitter

Changes

Category Files
API YTMusicClient.swiftPaginatedContentType.history, getHistory() with ttl: nil (no cache)
Protocol Protocols.swift — history methods added to YTMusicClientProtocol
ViewModel HistoryViewModel.swift — follows HomeViewModel pattern with background continuation loading
View HistoryView.swift — song list with SongThumbnailView, playQueue, refresh button
Wiring MainWindow.swift, Sidebar.swiftNavigationItem.history
Mocks MockUITestYTMusicClient.swift, MockYTMusicClient.swift — history stubs
Infra DiagnosticsLogger.swift, AccessibilityIdentifiers.swift
i18n Localizable.xcstrings + 4x .strings — "History" in en/ko/ar/tr
Tests HistoryViewModelTests.swift — 4 tests

🤖 Generated with Claude Code

@pukuba pukuba force-pushed the add-listening-history branch from 18d3eec to 99ff97f Compare April 5, 2026 09:33
@sozercan
Copy link
Copy Markdown
Owner

sozercan commented Apr 6, 2026

@pukuba can we use YouTube’s history here instead of local only?

@pukuba
Copy link
Copy Markdown
Contributor Author

pukuba commented Apr 6, 2026

That's a great idea! Using the YouTube Music FEmusic_history API would be much better — it would show history from all devices and stay consistent with the YouTube Music app. I'll rework this to fetch from the API instead of local-only tracking. Thanks for the suggestion!

@pukuba pukuba marked this pull request as draft April 7, 2026 01:53
Add `FEmusic_history` to PaginatedContentType and expose getHistory(),
getHistoryContinuation(), and hasMoreHistorySections on YTMusicClient.
History requests skip the API cache (ttl: nil) since history changes
with every song played. The fetchPaginatedContent TTL parameter is
now configurable with a default of APICache.TTL.home, so existing
endpoints are unaffected.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@pukuba pukuba force-pushed the add-listening-history branch from 58f72dc to f110d9c Compare April 7, 2026 03:27
@pukuba pukuba changed the title feat: add local listening history feat: add History view with YouTube Music API Apr 7, 2026
@pukuba pukuba force-pushed the add-listening-history branch 5 times, most recently from db7121b to 0618fbe Compare April 7, 2026 06:30
Display listening history fetched from YouTube Music's FEmusic_history
endpoint in a new sidebar section. Songs are grouped by time period
(Today, Yesterday, This Week, etc.) with SongThumbnailView and
playQueue integration.

- HistoryViewModel follows HomeViewModel pattern with background
  continuation loading and smart refresh (skips update when unchanged)
- HistoryView with LikedMusicView-style header, refresh button
  (spinning animation), auto-refresh on tab entry when track changed,
  and 3s delayed refresh after song click
- Localized History, Refresh, songs today in en, ko, ar, tr
- 4 unit tests for ViewModel

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@pukuba pukuba force-pushed the add-listening-history branch from 0618fbe to 46ab65e Compare April 7, 2026 06:52
@pukuba pukuba marked this pull request as ready for review April 7, 2026 07:02
@sozercan sozercan merged commit 3759f1e into sozercan:main Apr 7, 2026
6 checks passed
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.

2 participants