Skip to content

fix: expose 'active_no_data' health status for hijacked/silent audio devices#3326

Merged
louis030195 merged 1 commit into
mainfrom
fix/3144-active-no-data-health-status
May 10, 2026
Merged

fix: expose 'active_no_data' health status for hijacked/silent audio devices#3326
louis030195 merged 1 commit into
mainfrom
fix/3144-active-no-data-health-status

Conversation

@louis030195

@louis030195 louis030195 commented May 10, 2026

Copy link
Copy Markdown
Collaborator

Problem

When a Bluetooth audio device (e.g. AirPods) is hijacked by another app or becomes silent, the zero-fill watchdog detects this and triggers an automatic reconnect after 30 seconds. However, the health endpoint still reports the device as 'ok', making it impossible for users or the UI to know there's an issue until the watchdog fires.

Root cause

The health check didn't distinguish between a device that is:

  • Actively capturing audio (ok)
  • Active but producing no data due to hijack (active_no_data)

The watchdog already tracks these hijack/silence events in the stream_timeouts metric, but this wasn't surfaced in the health status.

Fix

Add logic to detect stream_hijacked condition (stream_timeouts > 0) and report active_no_data status instead of ok. This allows:

  1. Users/UI to see the device is degraded while recovering
  2. Better diagnostics of transient Bluetooth issues
  3. Clearer distinction in logs and monitoring

The watchdog will automatically trigger a reconnect; this just makes the transient state visible.

Changes

  • Added stream_hijacked check in health.rs using stream_timeouts > 0
  • Updated audio_status logic to emit active_no_data when hijack detected
  • Enhanced health detail logs to explain the condition
  • Added comprehensive unit test with both positive and negative cases

Confidence: 8/10

  • Fix is straightforward: single condition check in existing health logic
  • Leverages existing, proven watchdog metric (stream_timeouts)
  • No side effects: new status only emitted when watchdog has already fired
  • Test coverage verifies both hijacked and normal states
  • No behavior changes to actual reconnection logic (that already works)

Verification (Tier T1)

Test output:

running 3 tests
test routes::health::tests::audio_status_active_no_data_when_stream_timeouts_nonzero ... ok
test routes::health::tests::health_response_is_cloneable ... ok
test routes::health::tests::health_cache_fresh_then_stale ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 356 filtered out; finished in 0.00s

Sources (multi-source)

Fixes #3144


auto-generated by issue-solver pipe

…devices

Fixes #3144

## Problem
When a Bluetooth audio device (e.g. AirPods) is hijacked by another app or
becomes silent, the zero-fill watchdog detects this and triggers an automatic
reconnect after 30 seconds. However, the health endpoint still reports the
device as 'ok', making it impossible for users or the UI to know there's an
issue until the watchdog fires.

## Root cause
The health check didn't distinguish between a device that is:
- Actively capturing audio (ok)
- Active but producing no data due to hijack (active_no_data)

The watchdog already tracks these hijack/silence events in the stream_timeouts
metric, but this wasn't surfaced in the health status.

## Fix
Add logic to detect stream_hijacked condition (stream_timeouts > 0) and
report 'active_no_data' status instead of 'ok'. This allows:
1. Users/UI to see the device is degraded while recovering
2. Better diagnostics of transient Bluetooth issues
3. Clearer distinction in logs and monitoring

The watchdog will automatically trigger a reconnect; this just makes the
transient state visible.

## Verification (Tier T1)
- New unit test: `audio_status_active_no_data_when_stream_timeouts_nonzero`
- All existing health check tests pass
- cargo test --lib -p screenpipe-engine health: 3/3 tests pass
@louis030195 louis030195 merged commit f2e309e into main May 10, 2026
11 of 20 checks passed
@louis030195 louis030195 deleted the fix/3144-active-no-data-health-status branch May 10, 2026 16:45
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.

Audio recording silently stops mid-session when Bluetooth device (AirPods) is reused by another app, despite "ON" status

1 participant