Skip to content

🎤 fix: Keep Microphone Icon Visible On Initial Chat Render - #13788

Merged
danny-avila merged 2 commits into
devfrom
claude/exciting-engelbart-40118e
Jun 16, 2026
Merged

danny-avila merged 2 commits into
devfrom
claude/exciting-engelbart-40118e

Conversation

@danny-avila

Copy link
Copy Markdown
Collaborator

Summary

AudioRecorder returned null whenever the parent ChatForm's textAreaRef was still unset, which is always the case on the first paint of a new chat or a page refresh. Because populating a ref does not trigger a re-render and AudioRecorder is memo-wrapped, the microphone icon stayed missing until some unrelated prop change (disabled, isSubmitting, ask) forced a re-render.

This removes the early-return guard and instead renders the button in a disabled state while the ref is unset, so the icon is always visible.

Changes

  • client/src/components/Chat/Input/AudioRecorder.tsx
    • Removed the if (!textAreaRef.current) { return null; } guard.
    • Changed the button's disabled prop to disabled={disabled || !textAreaRef.current}.

Why this is safe

textAreaRef was only ever read by that guard — the STT hook (useSpeechToText) and both handleStartRecording/handleStopRecording never touch textAreaRef.current, so there is no functional dependency on the ref being populated.

Closes #13786

AudioRecorder returned null while the parent ChatForm's textAreaRef was still null on first paint, hiding the mic icon until an unrelated re-render. Render the button disabled instead so the icon is always present.

Closes #13786
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eb5787e7c2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

aria-label={localize('com_ui_use_micrphone')}
onClick={isListening === true ? handleStopRecording : handleStartRecording}
disabled={disabled}
disabled={disabled || !textAreaRef.current}

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 Badge Stop deriving the disabled state from a ref

On an initial chat render where textAreaRef.current is still null, this renders the microphone button with disabled set, but the later ref assignment does not trigger a React re-render. That means users who try to click the now-visible mic immediately after loading a chat can still get a permanently disabled button until some unrelated state/prop change occurs, preserving the same first-render usability regression in a different form. Since the handlers do not depend on the textarea ref, the button should not be disabled based on this ref value.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch — fixed in d39b6b9. You're right that the ref assignment never triggers a re-render, so deriving disabled from textAreaRef.current could leave the button stuck disabled. Since neither the STT hook nor the start/stop handlers read the ref, I removed the dependency entirely: disabled={disabled}, and dropped the now-unused textAreaRef prop from the component and its call site in ChatForm.

Per Codex review: deriving the button's disabled state from textAreaRef.current could leave the mic permanently disabled until an unrelated re-render, since assigning a ref does not trigger one. The handlers never read the ref, so remove the dependency entirely along with the now-unused prop.
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: d39b6b9dd1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

Copy link
Copy Markdown
Contributor

GitNexus: ❌ deploy failed

The deploy failed — the previous index (if any) continues to be served.
Deploy run

@danny-avila danny-avila linked an issue Jun 16, 2026 that may be closed by this pull request
1 task
@danny-avila
danny-avila merged commit b91c1c2 into dev Jun 16, 2026
19 checks passed
@danny-avila
danny-avila deleted the claude/exciting-engelbart-40118e branch June 16, 2026 15:06
fuuuzzy pushed a commit to fuuuzzy/LibreChat that referenced this pull request Jun 18, 2026
…-AI#13788)

* 🎤 fix: Keep Microphone Icon Visible On Initial Chat Render

AudioRecorder returned null while the parent ChatForm's textAreaRef was still null on first paint, hiding the mic icon until an unrelated re-render. Render the button disabled instead so the icon is always present.

Closes LibreChat-AI#13786

* 🎤 refactor: Drop Unused textAreaRef Dependency From AudioRecorder

Per Codex review: deriving the button's disabled state from textAreaRef.current could leave the mic permanently disabled until an unrelated re-render, since assigning a ref does not trigger one. The handlers never read the ref, so remove the dependency entirely along with the now-unused prop.
ThomasVuNguyen pushed a commit to ThomasVuNguyen/LibreChat that referenced this pull request Jul 15, 2026
…-AI#13788)

* 🎤 fix: Keep Microphone Icon Visible On Initial Chat Render

AudioRecorder returned null while the parent ChatForm's textAreaRef was still null on first paint, hiding the mic icon until an unrelated re-render. Render the button disabled instead so the icon is always present.

Closes LibreChat-AI#13786

* 🎤 refactor: Drop Unused textAreaRef Dependency From AudioRecorder

Per Codex review: deriving the button's disabled state from textAreaRef.current could leave the mic permanently disabled until an unrelated re-render, since assigning a ref does not trigger one. The handlers never read the ref, so remove the dependency entirely along with the now-unused prop.
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.

[Bug]: Microphone Icon doesn`t show on new Chat

1 participant