Skip to content
This repository was archived by the owner on Sep 16, 2026. It is now read-only.

fix(web): improve accessibility - #185

Closed
leoisadev1 wants to merge 2 commits into
mainfrom
fix/ui-accessibility-final
Closed

leoisadev1 wants to merge 2 commits into
mainfrom
fix/ui-accessibility-final

Conversation

@leoisadev1

Copy link
Copy Markdown
Member

Adds ARIA labels, keyboard navigation, and focus management. Updates from #180.

- Add proper ARIA labels to chat message bubbles indicating sender
- Add role='article' to message bubbles for better screen reader context
- Enhance model selector with comprehensive ARIA attributes and keyboard loop navigation
- Add ARIA labels to combobox trigger, search input, and all options
- Improve OpenRouter modal with proper ARIA relationships and focus management
- Add aria-describedby for error messages and modal description
- Add aria-busy state for submit button during save
- Add aria-label to scroll-to-bottom button in chat panel

These changes ensure keyboard users and screen reader users can fully interact with the chat interface.
…cements

The visible text already includes pricing and context information, so the aria-label should only contain the option label to prevent screen readers from announcing the same information twice.
@leoisadev1

Copy link
Copy Markdown
Member Author

Merging changes via direct commit to main due to branch issues

@leoisadev1 leoisadev1 closed this Nov 3, 2025

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

Enhanced web accessibility across three components by adding ARIA labels, keyboard navigation improvements, and proper semantic roles.

Key Changes

  • Chat Messages Panel: Added dynamic ARIA labels identifying message senders ("Assistant message"/"User message"), semantic role="article" for proper document structure, and labeled scroll-to-bottom button
  • Model Selector: Implemented circular keyboard navigation with loop prop, comprehensive ARIA attributes (aria-haspopup, aria-label, aria-selected, role="option"), and simplified option labels to prevent duplicate screen reader announcements
  • OpenRouter Modal: Strengthened form accessibility with ARIA relationships (aria-describedby), focus management (onOpenAutoFocus), validation states (aria-invalid, aria-required), and loading indicators (aria-busy)

Observations

All changes follow WCAG best practices and maintain backward compatibility. The implementation correctly uses native HTML semantics combined with ARIA attributes where appropriate. The simplified aria-label on model selector options (addressing reviewer feedback) prevents redundant announcements while maintaining context.

Confidence Score: 5/5

  • This PR is safe to merge with no risks - purely additive accessibility enhancements
  • All changes are non-breaking accessibility improvements that enhance the user experience for assistive technology users. The implementation follows WCAG guidelines, uses standard ARIA attributes correctly, and the components properly spread props to accept these attributes. No logic changes or potential side effects.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
apps/web/src/components/chat-messages-panel.tsx 5/5 Added ARIA labels and semantic role attributes to message bubbles and scroll button for screen reader accessibility
apps/web/src/components/model-selector.tsx 5/5 Enhanced keyboard navigation with loop prop and comprehensive ARIA attributes for model selection interface
apps/web/src/components/openrouter-link-modal.tsx 5/5 Improved modal accessibility with ARIA relationships, focus management, and proper form validation states

Sequence Diagram

sequenceDiagram
    participant User as User/Screen Reader
    participant ChatPanel as ChatMessagesPanel
    participant ModelSelector as ModelSelector
    participant OpenRouterModal as OpenRouterLinkModal
    
    Note over User,OpenRouterModal: Chat Message Accessibility
    User->>ChatPanel: Navigate to message
    ChatPanel->>User: Announce "Assistant message" or "User message" (aria-label)
    ChatPanel->>User: Identify as article (role="article")
    User->>ChatPanel: Request scroll to bottom
    ChatPanel->>User: Button labeled "Scroll to bottom of conversation"
    
    Note over User,OpenRouterModal: Model Selection Accessibility
    User->>ModelSelector: Focus on trigger button
    ModelSelector->>User: Announce "Select AI model. Current selection: {model}"
    User->>ModelSelector: Open dropdown (Enter/Space)
    ModelSelector->>User: Announce "listbox" popup (aria-haspopup)
    User->>ModelSelector: Search models (focus on input)
    ModelSelector->>User: Input labeled "Search AI models"
    User->>ModelSelector: Navigate options (Arrow keys)
    Note over ModelSelector: Loop enabled for circular navigation
    ModelSelector->>User: Announce each option with aria-selected state
    User->>ModelSelector: Select model (Enter)
    ModelSelector->>User: Close dropdown and update selection
    
    Note over User,OpenRouterModal: OpenRouter Modal Accessibility
    User->>OpenRouterModal: Open modal
    OpenRouterModal->>User: Focus on API key input (onOpenAutoFocus)
    OpenRouterModal->>User: Announce modal description (aria-describedby)
    User->>OpenRouterModal: Enter invalid API key
    OpenRouterModal->>User: Mark input as invalid (aria-invalid)
    OpenRouterModal->>User: Announce error alert (role="alert")
    OpenRouterModal->>User: Link error to input (aria-describedby)
    User->>OpenRouterModal: Submit form
    OpenRouterModal->>User: Button shows busy state (aria-busy)
Loading

3 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

leoisadev1 added a commit that referenced this pull request Nov 26, 2025
- Add isMounted state to defer hydration-sensitive operations
- Add suppressHydrationWarning to ScrollArea components
- Guard all scroll/resize effects until after hydration completes
- Prevent infinite loops by debouncing ResizeObserver callbacks
- Only update isAtBottom state when value actually changes
- Defer scroll-to-bottom button render until after hydration

Fixes React error #418 (hydration mismatch) and #185 (max update depth)
that occurred when reloading the page after stream completion.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
leoisadev1 added a commit that referenced this pull request Nov 26, 2025
…432)

- Add isMounted state to defer hydration-sensitive operations
- Add suppressHydrationWarning to ScrollArea components
- Guard all scroll/resize effects until after hydration completes
- Prevent infinite loops by debouncing ResizeObserver callbacks
- Only update isAtBottom state when value actually changes
- Defer scroll-to-bottom button render until after hydration

Fixes React error #418 (hydration mismatch) and #185 (max update depth)
that occurred when reloading the page after stream completion.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <[email protected]>
leoisadev1 added a commit that referenced this pull request Nov 26, 2025
…lare Insights

The previous fix (#432) addressed some React 19 hydration issues but missed the root
cause of the infinite loop (error #185): the virtualizer.measureElement callback creates
a new function reference on every render, triggering re-measurements that cause state
updates, which causes more re-renders.

Changes:
- Wrap virtualizer.measureElement in useCallback to create a stable ref callback
- Guard measurement with isMounted check to skip during hydration
- Disable virtualization entirely until after mount (isMounted && messages.length > 20)
- Add Cloudflare Insights to CSP script-src to fix blocked beacon.min.js

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
leoisadev1 added a commit that referenced this pull request Nov 26, 2025
…lare Insights (#433)

The previous fix (#432) addressed some React 19 hydration issues but missed the root
cause of the infinite loop (error #185): the virtualizer.measureElement callback creates
a new function reference on every render, triggering re-measurements that cause state
updates, which causes more re-renders.

Changes:
- Wrap virtualizer.measureElement in useCallback to create a stable ref callback
- Guard measurement with isMounted check to skip during hydration
- Disable virtualization entirely until after mount (isMounted && messages.length > 20)
- Add Cloudflare Insights to CSP script-src to fix blocked beacon.min.js

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <[email protected]>
leoisadev1 added a commit that referenced this pull request Nov 27, 2025
React 19's compiler optimizations can eliminate virtualizer.getVirtualItems()
calls when the return value appears unused. This causes the virtualizer to
not render items correctly, leading to infinite re-render loops (error #185)
and hydration mismatches (error #418).

Fix: Store virtualizer in a ref and access through virtualizerRef.current
to prevent React 19 from optimizing away the virtualizer state updates.

Reference: TanStack/virtual#743

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
leoisadev1 added a commit that referenced this pull request Nov 27, 2025
React 19's compiler optimizations can eliminate virtualizer.getVirtualItems()
calls when the return value appears unused. This causes the virtualizer to
not render items correctly, leading to infinite re-render loops (error #185)
and hydration mismatches (error #418).

Fix: Store virtualizer in a ref and access through virtualizerRef.current
to prevent React 19 from optimizing away the virtualizer state updates.

Reference: TanStack/virtual#743

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <[email protected]>
leoisadev1 added a commit that referenced this pull request Nov 27, 2025
EMERGENCY FIX: The @tanstack/react-virtual library causes infinite re-render
loops during hydration in React 19, even with the virtualizerRef workaround
from PR #434. The error occurs INSIDE the library code, not in our wrapper.

This completely disables virtualization until @tanstack/react-virtual
officially supports React 19.

References:
- TanStack/virtual#743
- TanStack/virtual#924

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
leoisadev1 added a commit that referenced this pull request Nov 27, 2025
…435)

EMERGENCY FIX: The @tanstack/react-virtual library causes infinite re-render
loops during hydration in React 19, even with the virtualizerRef workaround
from PR #434. The error occurs INSIDE the library code, not in our wrapper.

This completely disables virtualization until @tanstack/react-virtual
officially supports React 19.

References:
- TanStack/virtual#743
- TanStack/virtual#924

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <[email protected]>
leoisadev1 added a commit that referenced this pull request Nov 27, 2025
- Fix virtualListContainerStyle useMemo in chat-messages-panel.tsx and app-sidebar.tsx
  - Use computed totalSize value as dependency instead of function call
  - Prevents infinite re-renders from dependency array function calls

- Fix useChatReadStatus hydration mismatch
  - Use requestAnimationFrame to delay localStorage access until after hydration
  - Add hasMountedRef to ensure localStorage operations only happen client-side
  - Return stable empty values during SSR to match server render
leoisadev1 added a commit that referenced this pull request Nov 27, 2025
- Fix virtualListContainerStyle useMemo in chat-messages-panel.tsx and app-sidebar.tsx
  - Use computed totalSize value as dependency instead of function call
  - Prevents infinite re-renders from dependency array function calls

- Fix useChatReadStatus hydration mismatch
  - Use requestAnimationFrame to delay localStorage access until after hydration
  - Add hasMountedRef to ensure localStorage operations only happen client-side
  - Return stable empty values during SSR to match server render
leoisadev1 added a commit that referenced this pull request Nov 27, 2025
… errors

- Defer AppSidebar rendering until after client mount in dashboard-layout-inner.tsx
  - AppSidebar uses hooks that access localStorage (useChatReadStatus) and
    Convex real-time data (useChatList) which causes hydration mismatches
  - Show placeholder div during SSR to prevent layout shift

- Remove @tanstack/react-virtual from chat-messages-panel.tsx entirely
  - The library causes infinite re-render loops (error #185) and
    hydration mismatches (#418) with React 19
  - Virtualization was already disabled (shouldVirtualize = false)
  - Now the code and dependency are completely removed

Fixes React errors #418 (hydration mismatch) and #185 (max update depth)
leoisadev1 added a commit that referenced this pull request Nov 27, 2025
… errors (#439)

- Defer AppSidebar rendering until after client mount in dashboard-layout-inner.tsx
  - AppSidebar uses hooks that access localStorage (useChatReadStatus) and
    Convex real-time data (useChatList) which causes hydration mismatches
  - Show placeholder div during SSR to prevent layout shift

- Remove @tanstack/react-virtual from chat-messages-panel.tsx entirely
  - The library causes infinite re-render loops (error #185) and
    hydration mismatches (#418) with React 19
  - Virtualization was already disabled (shouldVirtualize = false)
  - Now the code and dependency are completely removed

Fixes React errors #418 (hydration mismatch) and #185 (max update depth)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant