Skip to content

fix(android): discard audio prepared after leaving chat - #432

Closed
plotarmordev wants to merge 1 commit into
leepokai:devfrom
plotarmordev:fix/17-android-discard-late-prepared-audio
Closed

plotarmordev wants to merge 1 commit into
leepokai:devfrom
plotarmordev:fix/17-android-discard-late-prepared-audio

Conversation

@plotarmordev

Copy link
Copy Markdown
Contributor

Summary

A small follow-up to #364 (voice notes and audio in chat), Android only.

On Android, if you left a chat while a voice note was still loading, the player could finish preparing after its card was gone and start playing with nothing on screen to stop it. SharedAudio now checks whether the card was released when the player comes back from preparing; if so, it releases that player right away and never starts it.

  • SharedAudio.kt: release a player that finishes preparing after the card was released, instead of keeping and starting it.
  • SharedAudioTest.kt: a regression test that releases a card while its sound prepares, then checks that the player is released, never plays, and that a second release does nothing.
  • Docs: docs/features/file-attachments.md and the user manual's web/content/docs/conversations.mdx.

iPhone and desktop are unaffected: they already drop a note that loads after its card is gone, and #364's iPhone tests cover a card closed mid-load. The terminal UI doesn't play audio.

I left the version bump and the WhatsNew.md sections for you to add when you release; my release notes are below.

Validation

  • Android: :app:testDebugUnitTest passes with SharedAudioTest at 10/10, including the new test.
  • Not run on the emulator: the race depends on when the system's media player finishes preparing, which I can't time from a UI test, so the unit test holds the prepare step open to reproduce it.

What's New: iPhone

zh-Hant

en-US

What's New: Android

zh-Hant

  • 在語音訊息載入時離開聊天,該語音不會在離開後才開始播放。

en-US

  • Leaving a chat while a voice note is loading no longer lets it start playing afterward.

@github-actions github-actions Bot added bug Something isn't working P2: medium Real problem with a workaround or limited reach. Fix when convenient. labels Nov 12, 2026
@greptile-apps

greptile-apps Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Low impact] The change is limited to Android audio cards in chat.

The code change looks sound, but the required Android check against a real host must be completed before merging.

Findings

  1. P2 Real playback remains unchecked ▶

Summary

Type: bug fix | Areas: Android, web, docs | Priority: P2: medium

Prevents Android audio from starting when preparation finishes after its card is released.

  • Android voice notes stop before playback when their card leaves.

plotarmordev explicitly deferred the version bump and release-note files to release and supplied Android release-note bullets.

Reviews (1) · Last reviewed commit: "fix(android): discard audio prepared aft..." · Reviewed by Greptile

Comment on lines +62 to +68
@Test fun `a card released while its sound prepares releases it without playing`() = runBlocking {
val opening = CompletableDeferred<Unit>()
val prepared = CompletableDeferred<Sound>()
val audio = SharedAudio(load = { File("note.m4a") }, open = { _, _ ->
opening.complete(Unit)
prepared.await()
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Real playback remains unchecked

The new test covers the delayed return from open, but the PR reports no Android emulator run against a real host. The repository requires end-to-end checks on the affected client, not only unit tests.

Keep this deterministic regression test, then check normal playback and leaving the chat in the Android app against a real host. Add the results to Validation before merging. The emulator check does not need to reproduce the exact race.

Context Used: Codync is a monorepo: host/ (Rust host, owns the logic), apps/ios (SwiftUI), apps/android (Kotlin + Compose), apps/desktop (Electron + React), host/src/tui (terminal UI), relay/, cloud/, web/, docs/. Follow CLAUDE.md and AGENTS.md. Start the PR summ... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@plotarmordev

Copy link
Copy Markdown
Contributor Author

Moved to #433: same commit (70aba75), opened from the branch my tooling tracks. Closing this one so there's a single open PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working P2: medium Real problem with a workaround or limited reach. Fix when convenient.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant