# Critical Fixes Needed ## Issues Identified from Testing ### 1. Max Retries Modal Not Appearing **Problem**: The modal doesn't show when max retries are hit, even though the error appears in logs. **Root Causes**: 1. The `onUserActionRequired` callback registration has a dependency issue - it runs once on mount but doesn't properly persist 2. The Durable Object emits the event but the frontend WebSocket handler might not be invoking the callback 3. The modal state (`showMaxRetriesDialog`) might not be triggering due to React rendering issues **Fixes Required**: - Fix the callback registration in `useEffect` to not depend on `onUserActionRequired` - Add console logging in the callback to verify it's being called - Ensure the modal is properly mounted and not blocked by other UI elements - Test with a simpler direct state setter instead of callback pattern ### 2. Terminal Panel Visual Hierarchy **Current Issues**: - Commands (`$ cat readme`) blend with output - `[TOOL]` system messages are cyan but don't stand out enough - No clear separation between command execution blocks - Timestamps are small and hard to read - ANSI codes are preserved but overall readability is poor **Improvements Needed**: - **Commands**: Make input lines more prominent with brighter color, maybe add `>` prefix - **Output**: Slightly dimmed compared to commands - **System messages**: Different background or border to separate from regular output - **Spacing**: Add subtle separators between command blocks - **Typography**: Slightly larger monospace font, better line height ### 3. Agent Panel Visual Hierarchy **Current Issues**: - Status badges blend together - THINKING / AGENT / USER labels all look similar - No clear distinction between message types - Dense text makes it hard to scan **Improvements Needed**: - **THINKING messages**: Use collapsible UI (shadcn Collapsible) for long reasoning - **Message types**: Stronger color differentiation (blue for thinking, green for agent, yellow for user) - **Spacing**: More padding between messages - **Status indicators**: Level complete events should be more prominent - **Timestamps**: Slightly larger and better positioned ## Implementation Plan ### Phase 1: Fix Max Retries Modal (Critical) 1. **Update `terminal-chat-interface.tsx`**: ```typescript // Remove dependency on onUserActionRequired in useEffect useEffect(() => { onUserActionRequired((data) => { console.log('🚨 USER ACTION REQUIRED:', data) // Debug log if (data.reason === 'max_retries') { setMaxRetriesData({ level: data.level, retryCount: data.retryCount, maxRetries: data.maxRetries, message: data.message, }) setShowMaxRetriesDialog(true) } }) }, []) // Empty dependency array ``` 2. **Add debug logging** in `useAgentWebSocket.ts`: ```typescript if (agentEvent.type === 'user_action_required' && userActionCallbackRef.current) { console.log('📣 Calling user action callback with:', agentEvent.data) userActionCallbackRef.current(agentEvent.data) } ``` 3. **Verify DO emission** - add logging in `BanditAgentDO.ts`: ```typescript console.log('🚨 Emitting user_action_required event:', { reason: 'max_retries', level, retryCount: this.state.retryCount, maxRetries: this.state.maxRetries, }) this.broadcast({...}) ``` ### Phase 2: Improve Terminal Visual Hierarchy 1. **Update terminal line rendering** in `terminal-chat-interface.tsx`: ```tsx // Add stronger visual distinction