Conversation
… types - Add aria-label to all icon-only buttons in ChatView - Add aria-label to chat textarea - Add type="button" to control buttons - Add aria-hidden="true" to decorative SVGs - Remove unused chatMode variable
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| .find((message) => message.role === "assistant"); | ||
| if (!latestAssistant || !latestAssistant.text.trim()) return; | ||
|
|
||
| queueAssistantSpeech(latestAssistant.id, latestAssistant.text, !chatSending); | ||
| queueAssistantSpeech( | ||
| latestAssistant.id, | ||
| latestAssistant.text, | ||
| !chatSending, | ||
| ); | ||
| }, [msgs, chatSending, agentVoiceMuted, queueAssistantSpeech]); | ||
|
|
||
| useEffect(() => { |
There was a problem hiding this comment.
Potential for Repeated Assistant Speech Queuing
The useEffect in this range queues assistant speech whenever msgs, chatSending, agentVoiceMuted, or queueAssistantSpeech change. If these dependencies change rapidly (e.g., due to fast state updates), the same assistant message could be queued multiple times, potentially resulting in overlapping or repeated speech playback.
Recommendation:
Consider tracking the last spoken message ID and only queue speech if the latest assistant message is new or has changed. For example:
const lastSpokenIdRef = useRef<string | null>(null);
useEffect(() => {
if (agentVoiceMuted) return;
const latestAssistant = [...msgs].reverse().find((message) => message.role === "assistant");
if (!latestAssistant || !latestAssistant.text.trim()) return;
if (lastSpokenIdRef.current === latestAssistant.id) return;
lastSpokenIdRef.current = latestAssistant.id;
queueAssistantSpeech(latestAssistant.id, latestAssistant.text, !chatSending);
}, [msgs, chatSending, agentVoiceMuted, queueAssistantSpeech]);This ensures each assistant message is only queued once.
Summary of ChangesHello @Dexploarer, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the accessibility of the chat interface for screen reader users by adding crucial ARIA attributes to various interactive elements. It also improves the semantic structure of the HTML and includes minor code clean-up, ensuring a more robust and user-friendly experience without altering the visual appearance. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request primarily focuses on enhancing accessibility within the ChatView component by adding type="button" and aria-label attributes to various interactive elements, including buttons for custom actions, avatar visibility, agent voice control, voice input, chat message input, and chat control actions (stop generation, stop speaking, send message). It also includes minor code changes such as removing an unused chatMode variable and reformatting a queueAssistantSpeech function call for better readability. The review comment suggests improving the maintainability of the newly added title and aria-label attributes for the avatar and mute/unmute buttons by defining their label texts in variables to avoid repetition.
| <button | ||
| type="button" | ||
| className={`w-7 h-7 flex items-center justify-center border rounded cursor-pointer transition-all bg-card ${ | ||
| avatarVisible | ||
| ? "border-accent text-accent" | ||
| : "border-border text-muted hover:border-accent hover:text-accent" | ||
| }`} | ||
| onClick={() => setState("chatAvatarVisible", !avatarVisible)} | ||
| title={avatarVisible ? "Hide avatar" : "Show avatar"} | ||
| aria-label={avatarVisible ? "Hide avatar" : "Show avatar"} | ||
| > | ||
| <svg | ||
| width="14" | ||
| height="14" | ||
| viewBox="0 0 24 24" | ||
| fill="none" | ||
| stroke="currentColor" | ||
| strokeWidth="2" | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| aria-hidden="true" | ||
| > | ||
| <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"> | ||
| <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" /> | ||
| <circle cx="12" cy="7" r="4" /> | ||
| {!avatarVisible && <line x1="3" y1="3" x2="21" y2="21" />} | ||
| </svg> | ||
| </button> | ||
|
|
||
| {/* Mute / unmute agent voice */} | ||
| <button | ||
| className={`w-7 h-7 flex items-center justify-center border rounded cursor-pointer transition-all bg-card ${ | ||
| agentVoiceMuted | ||
| ? "border-border text-muted hover:border-accent hover:text-accent" | ||
| : "border-accent text-accent" | ||
| }`} | ||
| onClick={() => { | ||
| const muting = !agentVoiceMuted; | ||
| setState("chatAgentVoiceMuted", muting); | ||
| if (muting) voice.stopSpeaking(); | ||
| }} | ||
| title={agentVoiceMuted ? "Unmute agent voice" : "Mute agent voice"} | ||
| <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" /> | ||
| <circle cx="12" cy="7" r="4" /> | ||
| {!avatarVisible && <line x1="3" y1="3" x2="21" y2="21" />} | ||
| </svg> | ||
| </button> | ||
|
|
||
| {/* Mute / unmute agent voice */} | ||
| <button | ||
| type="button" | ||
| className={`w-7 h-7 flex items-center justify-center border rounded cursor-pointer transition-all bg-card ${ | ||
| agentVoiceMuted | ||
| ? "border-border text-muted hover:border-accent hover:text-accent" | ||
| : "border-accent text-accent" | ||
| }`} | ||
| onClick={() => { | ||
| const muting = !agentVoiceMuted; | ||
| setState("chatAgentVoiceMuted", muting); | ||
| if (muting) voice.stopSpeaking(); | ||
| }} | ||
| title={agentVoiceMuted ? "Unmute agent voice" : "Mute agent voice"} | ||
| aria-label={ | ||
| agentVoiceMuted ? "Unmute agent voice" : "Mute agent voice" | ||
| } | ||
| > | ||
| <svg | ||
| width="14" | ||
| height="14" | ||
| viewBox="0 0 24 24" | ||
| fill="none" | ||
| stroke="currentColor" | ||
| strokeWidth="2" | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| aria-hidden="true" | ||
| > | ||
| <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"> | ||
| <polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5" /> | ||
| {agentVoiceMuted ? ( | ||
| <line x1="23" y1="9" x2="17" y2="15" /> | ||
| ) : ( | ||
| <> | ||
| <path d="M19.07 4.93a10 10 0 0 1 0 14.14" /> | ||
| <path d="M15.54 8.46a5 5 0 0 1 0 7.07" /> | ||
| </> | ||
| )} | ||
| {agentVoiceMuted && <line x1="17" y1="9" x2="23" y2="15" />} | ||
| </svg> | ||
| </button> | ||
| </div> | ||
| <polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5" /> | ||
| {agentVoiceMuted ? ( | ||
| <line x1="23" y1="9" x2="17" y2="15" /> | ||
| ) : ( | ||
| <> | ||
| <path d="M19.07 4.93a10 10 0 0 1 0 14.14" /> | ||
| <path d="M15.54 8.46a5 5 0 0 1 0 7.07" /> | ||
| </> | ||
| )} | ||
| {agentVoiceMuted && <line x1="17" y1="9" x2="23" y2="15" />} | ||
| </svg> | ||
| </button> |
There was a problem hiding this comment.
To improve maintainability and avoid repetition, consider defining the label text for these buttons in variables and reusing them for both title and aria-label attributes.
For example:
const avatarButtonLabel = avatarVisible ? 'Hide avatar' : 'Show avatar';
const muteButtonLabel = agentVoiceMuted ? 'Unmute agent voice' : 'Mute agent voice';
// ... in your JSX
<button
// ... for avatar
title={avatarButtonLabel}
aria-label={avatarButtonLabel}
>
{/* ... */}
</button>
<button
// ... for mute
title={muteButtonLabel}
aria-label={muteButtonLabel}
>
{/* ... */}
</button>
💡 What:
aria-labelto:aria-hidden="true"to decorative SVGs within these buttons.type="button"to control buttons to prevent accidental form submission and satisfy linter.chatModevariable.🎯 Why:
📸 Before/After:
♿ Accessibility:
PR created automatically by Jules for task 5376162015197212800 started by @Dexploarer