Assist replays last TTS response when server URL switches between internal and external

Open
#7,802 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
57/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
android, kotlin
Domain
mobile

Research direction

Start in common/src/main/kotlin/io/homeassistant/companion/android/common/assist/AssistViewModelBase.kt around playAudio() and inspect how urlFlow().flatMapLatest handles a URL switch. Then read AudioUrlPlayer playback flow and its STATE_ENDED handling. Reproduce by finishing a streaming TTS response and switching between internal and external URLs; done when the response does not replay and playback resources are released.

Written by the indexing model from the issue text.

Description

Assist bug

Home Assistant Android app version(s):
2026.10.1-full (same code in 2026.11.1)

Android version(s):
17

Device model(s):
Samsung Galaxy Z Fold7 (SM-F966U1)

Home Assistant version:
2026.10.4

Last working Home Assistant release (if known):
Unknown

Description of problem, include YAML if issue is related to notifications:
HA app is my default assistant (voice pipeline, streaming TTS). After a response finishes, the same response plays again from the start every time the app switches between internal and external URL (leaving or joining home Wi-Fi). Happened 3 times in 13 minutes with the screen off. No new pipeline runs on the server.

Looks like playAudio() wraps the player in urlFlow().flatMapLatest, so every URL change restarts playback of the same TTS path:
https://github.com/home-assistant/android/blob/2026.10.1/common/src/main/kotlin/io/homeassistant/companion/android/common/assist/AssistViewModelBase.kt#L370-L382

AudioUrlPlayer also doesn't close its flow on STATE_ENDED, so the collection (and audio focus) stays alive as long as AssistActivity does.

Companion App Logs:

11:30:33.261 D ServerConnectionStateProviderImplKt: Using internal URL
11:30:33.262 D AudioUrlPlayer$playAudio: Flow closed, releasing player
11:30:33.333 I ExoPlayerImpl: Init ff433e0 [AndroidXMedia3/1.11.1]
11:30:36.428 D AudioUrlPlayer$playAudio$1$player: Stream playback ended

dumpsys audio (original response at 11:17:20, then 3 replays):
11:17:20 new player piid:8687 io.homeassistant.companion.android usage=USAGE_ASSISTANT
11:24:02 new player piid:8719 io.homeassistant.companion.android usage=USAGE_ASSISTANT
11:25:13 new player piid:8727 io.homeassistant.companion.android usage=USAGE_ASSISTANT
11:30:33 new player piid:8743 io.homeassistant.companion.android usage=USAGE_ASSISTANT

Screenshot or video of problem:
N/A

Additional information:
Force stop clears it.

Dominant language
Kotlin
Stars
4k
Forks
1.1k
Avg merge
2d 7h
Merged PRs (30d)
124

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from home-assistant/android

All issues in home-assistant/android

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.