Skip to content

feat: handle Google Assistant voice queries (Android Auto voice commands) - #868

Open
sinful1992 wants to merge 4 commits into
eddyizm:developmentfrom
sinful1992:feat/aa-voice-search
Open

feat: handle Google Assistant voice queries (Android Auto voice commands)#868
sinful1992 wants to merge 4 commits into
eddyizm:developmentfrom
sinful1992:feat/aa-voice-search

Conversation

@sinful1992

@sinful1992 sinful1992 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

What

Voice requests — "Hey Google, play <artist/album/song> on Tempus" — arrive as a media item carrying only requestMetadata.searchQuery. That field was never read anywhere: the queue resolver fell through to session-metadata lookup, found nothing playable, and playback silently did nothing. Voice control is arguably the most important interaction while driving, so this makes it work:

  • Exact artist match → starts a self-extending instant mix for that artist (same mechanism as the browse-tree Instant Mix).
  • Exact album match → plays that album.
  • Anything else → queues the songs matching the query.
  • Empty query ("play some music") → shuffles random songs, same behaviour as the Random browse node.

Matching is done against the server via the existing search3 repository call; no new endpoints or settings.

Notes

  • Guarded to items with a blank mediaId, so taps on regular browse/search results are unaffected.
  • Any resolution failure degrades to an empty queue instead of throwing, so Assistant reports it couldn't play rather than the session erroring.
  • Works for Assistant on the phone as well, not just in the car.

Testing

  • assembleDebug builds clean.
  • Ran on-device: "play <artist>" starts a mix that keeps extending, "play <album>" plays the album in order, "play <song title>" queues the matching songs, and "play some music" shuffles the library.

Summary by CodeRabbit

  • New Features
    • Added support for voice-based media searches from spoken queries (including Android Auto voice queries).
    • Empty voice queries now return a randomized selection of songs.
    • Voice searches can match artists or albums, starting an instant mix for artists and playing album tracks for albums.
  • Bug Fixes
    • Improved resilience for unsuccessful or invalid voice-query routing by returning no results instead of interrupting playback.

Voice requests ("Hey Google, play <artist/album/song> on Tempus")
arrive as a media item carrying only requestMetadata.searchQuery, which
was never read: the queue resolver fell through to session-metadata
lookup, found nothing playable, and playback silently did nothing.

Resolve the spoken query against the server instead: an exact artist
match starts a self-extending instant mix, an exact album match plays
the album, anything else queues the matching songs, and an empty query
("play some music") shuffles random songs like the Random browse node.
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 11b34009-da07-40b6-b2dc-4844f36fff57

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Voice-query requests with blank media IDs now use a dedicated resolver that searches album and artist results, supports random playback for empty queries, and returns artist mixes, album tracks, or playable matches.

Changes

Voice Query Resolution

Layer / File(s) Summary
Voice-query request routing
app/src/tempus/java/com/cappielloantonio/tempo/service/MediaLibraryServiceCallback.kt
Detects voice-query requests and routes them to resolveVoiceQuery with a trimmed query.
Voice-query search and playback matching
app/src/tempus/java/com/cappielloantonio/tempo/service/MediaLibraryServiceCallback.kt
Searches album and artist results, resolves empty queries to random songs, returns artist mixes, album tracks, or playable matches, converts asynchronous library results into item lists, and returns an empty list on errors.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MediaLibrarySessionCallback
  participant resolveVoiceQuery
  participant automotiveRepository
  participant MediaServiceExtensionRegistry

  MediaLibrarySessionCallback->>resolveVoiceQuery: pass trimmed search query
  resolveVoiceQuery->>automotiveRepository: search album and artist results
  automotiveRepository-->>resolveVoiceQuery: return library results
  resolveVoiceQuery->>MediaServiceExtensionRegistry: set TracksChangedExtension handler for artist match
  resolveVoiceQuery-->>MediaLibrarySessionCallback: return resolved media items
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding support for Google Assistant voice queries in Android Auto.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@sinful1992

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@app/src/tempus/java/com/cappielloantonio/tempo/service/MediaLibraryServiceCallback.kt`:
- Around line 286-289: Wrap the empty-query
`getRandomSongs(ConstantsAA.MAX_SHUFFLE_ITEMS)` flow in the same
`Futures.catching` error-handling pattern used by the non-empty query path,
returning an empty item list when resolution fails while preserving the existing
successful `toItemList` behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 79cb66b8-22dc-4f2e-be40-11cb53ba8522

📥 Commits

Reviewing files that changed from the base of the PR and between 3fe7074 and 88d3bdf.

📒 Files selected for processing (1)
  • app/src/tempus/java/com/cappielloantonio/tempo/service/MediaLibraryServiceCallback.kt

@eddyizm
eddyizm changed the base branch from main to development July 12, 2026 14:42
A voice query that does not exactly match any artist or album title
(e.g. a misheard artist name) previously fell through to the playable-songs
filter; when the search returned only browsable artist/album entries the
resolved queue was empty, so the Assistant announced playback but nothing
played. Now, when there is no exact match and no playable song results,
the first artist (or album) returned by the server search is used instead.
@MaFo-28

MaFo-28 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

My comment to the PR #877 would be more appropriate here: #877 (comment)

Voice queries that resolve to an artist now size the mix from the
artist's library (small/medium/large tiers) like the browse path,
instead of a hardcoded medium mix. Artists that don't qualify for a
mix (fewer than two albums or too few tracks) fall back to queueing
one of their albums in random order instead of entering the mix
builder.
@sinful1992

Copy link
Copy Markdown
Contributor Author

Implemented in e9031e3.

One clarification first: the voice path was already going through the same deferred process as browse — it called getInstantMix, which queues a single random track tagged INSTANTMIX_SOURCE + "[count]" + artistId and lets TracksChangedExtension build the rest once playback starts, so there was no long wait before music. What it wasn't doing was the browse path's sizing and gating, which is now mirrored:

  • The mix size is computed from the artist's library exactly like getArtistAlbum does (small/medium/large tiers based on total track count) instead of the hardcoded medium mix.
  • An artist that wouldn't get an Instant Mix entry in browse (fewer than 2 albums, or under MIN_TRACKS_SMALL_MIX total tracks) no longer enters the mix machinery at all — per your suggestion, it falls back to queueing one of their albums in random order (for a single-album artist, that means their album, shuffled). This also keeps the voice path away from the InstantMixBuilder single-album case that fix: IndexOutOfBoundsException in Instant Mix for single-album artists #877 covers, so both layers are now in place.

Implementation-wise there's a new getInstantMix(artistId) overload that does one getArtist fetch, applies the gate and tiering, and then reuses the same mix-opener flow as the existing two-arg version (extracted into a shared helper, no behavior change for browse).

@tvillega

Copy link
Copy Markdown
Contributor

I think this solves #603.

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.

3 participants