Skip to content

Conversation

@mukherja04
Copy link
Contributor

Implemented user-visible connection/status feedback and a "mic on but no audio received" detector, plus a few small state/UX fixes discovered during integration

mukherja04 and others added 5 commits November 19, 2025 16:58
Removed comments related to audio chunk timestamps and inactivity checks.
Removed commented-out code related to mic activity tracking and inactivity monitoring.
Removed comment about microphone audio status.
last_suffix = pcm_data.slice(-(pcm_data.length % 128))

// update last audio timestamp and mark that we've received at least one audio chunk
this.lastAudioTimestamp = Date.now();
Copy link
Contributor

Choose a reason for hiding this comment

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

Date.now() is subject to the user's device time changing (not monotonic). Perhaps performance.now() would make sense instead?

const state: any = store.getState();
const listening = state.ControlReducer?.listening === true;
const micNoAudio = state.ControlReducer?.micNoAudio === true;
if (listening) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this checked before showing the snackbar? Is it necessary to fetch state from redux here?

We generally want to limit the use of getState() outside of redux.

const thresholdMs = 3000;
if (this.inactivityInterval == null) {
const { store } = require('../../../store');
this.inactivityInterval = setInterval(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

It feels to me like a timeout would be more natural here rather than an interval.

e.g. Set timeout of thresholdMs and reset timeout every time audio chunk is received. On timeout fired, micNoAudio to true.

Semantically, micNoAudio means no audio received for thresholdMs.

const thresholdMs = 3000;
try {
if (listening) {
try { (window as any).__hasReceivedAudio = false; } catch (e) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

I hesitate to pollute to window namespace with additional props. I don't think it is necessary to do so in order to implement mic activity.

It seems to me that the logic for setting the micNoAudio flag can be fully encapsulated within the recognizers themselves. This portion here would simply be fetching listening and micNoAudio from redux and showing/hiding the snackbar if both are true in useEffect. Am I missing something?

@mukherja04 mukherja04 closed this Dec 7, 2025
@mukherja04 mukherja04 deleted the anish branch December 7, 2025 06:56
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