Date: October 11, 2025 - Session Continuation Focus: Fixing AC13 (Thread list ARIA labels) accessibility test Status: β³ In Progress - Sidebar Visibility Issue
π― Objective#
Fix the failing AC13 test: "Accessibility: Thread list has proper ARIA labels"
Test Requirements:
- Thread list must have proper ARIA structure
- Must have
role="navigation"ORrole="list"visible to assistive technologies
π§ Work Completed#
1. Added ARIA Roles to Thread List β #
File: web/src/components/Layout.tsx
Changes Made:
// Line 223: Added role="list" wrapper around threads
<div role="list" aria-label="Conversation threads" data-testid="thread-list">
{threads.map((thread) => (
<motion.div
key={thread.id}
role="listitem" // Line 245: Added role="listitem" to each thread
aria-label={`Select conversation: ${formatThreadTitle(thread)}`}
// ...
>
Result: β ARIA structure correctly implemented
- Sidebar nav already has
role="navigation"(line 147) - Thread list now has
role="list"(line 223) - Each thread has
role="listitem"(line 245)
2. Fixed JSX Syntax Error β #
Problem: Missing closing </div> tag for role="list" wrapper Solution:
Added closing tag after threads.map() on line 277
// Line 276-278
))}
</div> // Closing tag for role="list" wrapper
)}
3. Added Visible Menu Button Text β #
File: web/src/components/Layout.tsx (lines 305-315)
Problem: Sidebar toggle button was icon-only, not findable by test selector Solution: Added visible "Menu" text to toggle button
<button
onClick={toggleSidebar}
className="p-2 text-gray-400 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300 rounded-lg transition-colors focus-ring flex items-center gap-1"
aria-label="Open sidebar menu"
data-testid="sidebar-toggle"
>
<Bars3Icon className="w-5 h-5" />
<span className="text-sm">Menu</span> {/* Added visible text */}
</button>
4. Removed sidebarOpen from LocalStorage Persistence β #
File: web/src/lib/store.ts (lines 155-163)
Rationale: Sidebar state should be viewport-dependent, not user preference Change:
partialize: (state) => ({
darkMode: state.darkMode,
// sidebarOpen: state.sidebarOpen, // REMOVED
currentPersona: state.currentPersona,
}),
5. Auto-Open Sidebar on Desktop Viewports β³#
File: web/src/lib/store.ts (line 77)
Initial State:
sidebarOpen: typeof window !== 'undefined' && window.innerWidth >= 1024,
Plus Client-Side Initialization (Layout.tsx lines 50-59):
useEffect(() => {
setIsMounted(true);
loadThreads();
// Open sidebar on desktop viewports if not already open
if (window.innerWidth >= 1024 && !sidebarOpen) {
toggleSidebar();
}
}, []); // Empty deps - only run once on mount
β Current Blocker#
Issue: Sidebar not opening automatically on desktop viewports during test execution
Root Cause Analysis:
- Test clears localStorage in beforeEach hook
- Store initialization happens server-side where
windowis undefined - Client-side useEffect runs after page load, but timing may not align with test checks
- Test looks for
[role="navigation"]or[role="list"]immediately without waiting
Test Code (tests/user-story-persona-threading.spec.ts lines 528-545):
test('Accessibility: Thread list has proper ARIA labels', async ({ page }) => {
const sidebarToggle = page
.locator('button')
.filter({ hasText: /menu|sidebar/i });
if (await sidebarToggle.isVisible({ timeout: 2000 })) {
await sidebarToggle.click();
await page.waitForTimeout(500);
}
// Check for navigation role
const threadNav = page.locator('[role="navigation"]');
const hasNavRole = await threadNav.isVisible().catch(() => false);
// Check for list role
const threadList = page.locator('[role="list"]');
const hasListRole = await threadList.isVisible().catch(() => false);
// Should have proper ARIA structure
expect(hasNavRole || hasListRole).toBeTruthy(); // FAILS - both false
});
Screenshots Show: Sidebar remains closed during test execution
π Attempted Solutions#
- β sr-only span in button: Playwright's
hasTextfilter doesn't match sr-only text - β Visible "Menu" text: Button added but sidebar still not opening
- β Store initial state with viewport check:
windowundefined during SSR - β useEffect auto-open: Timing issue with test execution
- β Removed sidebarOpen persistence: Didn't resolve auto-open timing
π Test Status#
AC13: β FAILING - ARIA structure implemented correctly but not visible due to closed sidebar
Code Changes: β CORRECT
- ARIA roles properly added
- Sidebar markup semantically correct
- Accessibility attributes in place
Runtime Behavior: β ISSUE
- Sidebar not opening on desktop viewports automatically
- Test cannot find ARIA roles because sidebar is hidden
π― Next Steps to Fix#
Option 1: Fix Sidebar Auto-Open Timing#
- Add explicit wait for sidebar animation in Layout useEffect
- Ensure sidebar opens before
networkidleevent completes - May require useState to track sidebar initialization
Option 2: Modify Test to Handle Closed Sidebar#
- Add explicit wait for ARIA roles with timeout
- Change
.isVisible().catch(() => false)to.isVisible({ timeout: 5000 }) - Give sidebar time to open after page load
Option 3: Force Sidebar Open in Test Environment#
- Detect test environment (NODE_ENV=test or user agent)
- Override sidebarOpen to true in test environments
- Ensure ARIA structure always visible during testing
Option 4: Click Menu Button Reliably#
- Ensure "Menu" button is actually clickable in test
- Add explicit wait for button to be visible
- Verify click actually toggles sidebar state
π Overall E2E Test Status (From Previous Session)#
Chat Interface Tests: 12/14 Passing (86%)#
β Passing:
- AC1: Persona selection
- AC2: Type and send messages
- AC3: SSE streaming
- AC4: Citations display
- AC5: Stop streaming
- AC7: Audio playback
- AC8: Conversation history
- AC9: New conversations
- E2E: Complete chat flow
- Accessibility: Keyboard navigation
- Accessibility: Screen reader
- Performance: Response time < 5s
β Remaining:
- AC10: Error handling (timing issue)
- AC6: Voice input (skipped - browser limitation)
Persona/Threading Tests: 14/17 Passing (82%)#
β Passing:
- AC1: View personas
- AC2: Select persona
- AC3: Persist persona
- AC6: Create threads
- AC7: Switch threads
- AC8: Delete threads
- AC9: Preserve history
- AC10: Thread metadata
- E2E: Complete workflow
- Accessibility: Keyboard navigation
- Performance: Persona switch < 500ms
- Performance: Thread switch < 1s
- Error: Persona load failure
- Error: Thread deletion failure
β Remaining:
- AC4: Persona switching (timeout in beforeEach)
- AC5: Distinct styles (mock mode issue)
- AC13: ARIA labels (THIS TEST - sidebar visibility)
π Achievements This Session#
- β Correct ARIA Implementation: Semantic HTML with proper accessibility roles
- β Syntax Error Fixed: Closed JSX tags properly
- β Improved Button Discoverability: Added visible text for test selectors
- β Better State Management: Removed inappropriate localStorage persistence
- β³ Viewport-Responsive Sidebar: Logic implemented but timing needs refinement
π‘ Key Learnings#
- LocalStorage Persistence: Not all UI state should be persisted - viewport-dependent state should be recalculated
- SSR vs Client-Side:
windowavailability matters for initial state calculations - Test Timing: E2E tests need explicit waits for async UI updates
- Playwright Selectors:
hasTextfilter requires visible text content, not aria-label or sr-only - Conditional Rendering: ARIA roles inside conditionally rendered components require that component to be visible
π Files Modified#
-
/home/ubuntu/workspace/lilith/web/src/components/Layout.tsx- Lines 50-59: Auto-open sidebar useEffect
- Lines 223, 245-246, 277: ARIA roles (role="list", role="listitem")
- Lines 305-315: Visible "Menu" button text
-
/home/ubuntu/workspace/lilith/web/src/lib/store.ts- Line 77: Viewport-based initial sidebarOpen state
- Lines 155-163: Removed sidebarOpen from persistence
β±οΈ Time Investment#
- AC13 Debugging: ~45 minutes
- Multiple attempts: 6 different approaches tried
- Root cause identified: Sidebar visibility timing
π― Recommendation#
Skip AC13 temporarily and move to other failing tests (AC4, AC5, AC10) that may have simpler fixes. Return to AC13 with fresh perspective or after completing other tests to achieve higher overall pass rate faster.
Alternative: Modify test to add explicit wait for sidebar animation, which is a 2-minute fix:
// In test file
await page.waitForSelector('[role="list"]', { timeout: 5000 });
Next Session TODO:
- Decide on AC13 approach (fix timing vs modify test)
- Fix AC5 (persona verification in mock mode)
- Fix AC10 (error display synchronization)
- Fix AC4 (beforeEach timeout)
- Achieve 100% E2E pass rate