Skip to content

fix(tui): skip audio init when no playback device - #51842

Closed
aydemir wants to merge 1 commit into
anomalyco:devfrom
aydemir:alsa-device-guard
Closed

aydemir wants to merge 1 commit into
anomalyco:devfrom
aydemir:alsa-device-guard

Conversation

@aydemir

@aydemir aydemir commented Sep 28, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #41763

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

On Linux hosts without an audio playback device (Termux/Android, soundless servers), any attention sound makes the native backend print ALSA diagnostics to stderr, overwriting the TUI.

I added a probe (new packages/tui/src/audio-device.ts) that looks for a PCM playback node under /dev/snd before Audio.create runs. If none exists, audio is skipped with a debug line and nothing touches the native backend. Non-Linux behavior is unchanged, and nothing changes when a device is present. The notification leg of attention.notify is untouched — only the sound leg can now come back false early.

How did you verify your code works?

  • New packages/tui/test/audio-device.test.ts: playback detect, capture/mixer-only reject, unreadable /dev/snd, non-Linux skip — 5/5 standalone.
  • End to end on an audio-less aarch64 host playing a real bundled mp3 through the TUI audio path: before 36 ALSA lines (same signature as tui: ALSA errors flood and corrupt the terminal during interaction #41763), after 0.
  • Live decision table with a stub renderer and the real audio module: blurred gives notification:true/sound:false, focused gives notification:false (by design)/sound:false, both with 0 ALSA lines.
  • Field check on Termux (Android 16) with the patched binary and sounds on: no ghost text across tool calls.

Screenshots / recordings

Not a UI change — the fix removes stray stderr text. No screenshot applies.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Sep 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@aydemir

aydemir commented Sep 28, 2026

Copy link
Copy Markdown
Author

End-to-end evidence on an audio-less aarch64 Linux host, playing a real bundled mp3 through the TUI audio path:

Before (dev audio.ts): 36 lines of ALSA diagnostics on stderr, same signature as #41763 (cannot find card '0' ... Unknown PCM default), then start fails with status -5.
After (this PR): 0 ALSA lines. Output is just 'tui audio skipped: no playback device', load returns null, nothing touches the native backend.

Note: full bun test suite and typecheck still need a complete dependency install; the new audio-device.test.ts was verified standalone (5/5) since @OpenTui packages came out of bun install missing their root files in this environment (repaired locally from a clean fetch, unrelated to this diff).

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Sep 28, 2026
@github-actions github-actions Bot closed this Sep 28, 2026
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.

tui: ALSA errors flood and corrupt the terminal during interaction

1 participant