5.5 KiB
Work Summary: Navigation Reorganization & Real-Time Notification Optimization
Date: 2026-02-04
Status: Complete
Overview
This session addressed two key UI improvements:
- Reorganized the navigation bar into logical sections with visual dividers
- Optimized the EventsPage to use WebSocket notification data directly instead of making redundant API calls
Changes Made
1. Navigation Bar Reorganization
File: attune/web/src/components/layout/MainLayout.tsx
Reorganized the navigation into four distinct sections with visual dividers:
Section 1: Dashboard
- Dashboard (home) - Gray color
Section 2: Component Management (Cool Colors)
- Actions - Cyan (blue-green)
- Rules - Blue
- Triggers - Violet (blue-purple)
- Sensors - Purple
Section 3: Runtime Logs (Warm Colors)
- Execution History - Fuchsia (purple-red)
- Enforcement History - Rose (red-pink)
- Event History - Orange (red-orange)
Section 4: Configuration
- Keys & Secrets - Gray
- Pack Management - Gray
Visual Enhancements:
- Color-coded navigation items with matching hover states
- Active items have glowing shadow effects (
shadow-lg shadow-{color}-900/50) - Thin dividers (
border-t border-gray-700) separate sections - Smooth transitions on all color changes (
transition-all duration-200) - Icon colors match the theme when inactive
Benefits:
- Clear visual hierarchy helps users understand functional groupings
- Color coding makes navigation more intuitive and visually interesting
- Maintains dark theme aesthetic while adding personality
2. Event Notifications Optimization
File: attune/web/src/pages/events/EventsPage.tsx
Problem: The EventsPage was invalidating React Query cache on every WebSocket notification, causing unnecessary API calls to refetch the entire event list.
Solution: Modified the notification handler to use the complete event data already present in the notification payload.
Implementation Details:
- Direct Cache Updates: Changed from
queryClient.invalidateQueries()toqueryClient.setQueryData()to update the cache directly - Complete Data in Notifications: The database trigger already sends all necessary fields:
id,trigger,trigger_ref,rule,rule_refsource,source_ref,payload,created
- Filter Awareness: Only adds new events to the list if:
- User is on page 1 (where new events appear)
- Event matches current trigger filter (if any)
- Total Count Updates: Updates pagination total on all pages when events arrive
Database Trigger: notify_event_created() in migrations/20260130000001_add_rule_to_event.sql
- Already sends complete event data in the
datafield - No database changes needed
3. Verification of Other History Pages
Confirmed Already Optimized:
- ExecutionsPage: Uses
useExecutionStream()hook which updates cache directly - EnforcementsPage: Uses
useEnforcementStream()hook which updates cache directly
Both of these pages were already using the notification data directly thanks to earlier optimization work documented in migration 20260203000003_add_rule_trigger_to_execution_notify.sql.
Benefits
Navigation Improvements
- Better UX: Users can quickly identify different functional areas
- Visual Interest: Color coding breaks up monotony of dark sidebar
- Logical Grouping: Related features are grouped together with clear separations
Notification Optimization
- Performance: Eliminates redundant API calls on every event creation
- Real-time: Updates appear instantly without server round-trip
- Bandwidth: Reduces network traffic significantly during high event volume
- Consistency: All three history pages now use the same optimized pattern
Technical Notes
Color Palette Used
- Cool Colors (Components): cyan-300/400, blue-300/400, violet-300/400, purple-300/400
- Warm Colors (Logs): fuchsia-300/400, rose-300/400, orange-300/400
- Neutral (Dashboard/Config): gray-300/400
Notification Data Flow
PostgreSQL NOTIFY trigger → Notifier Service → WebSocket → React Query Cache
↓
Direct update (no API call)
Type Safety
- All changes maintain full TypeScript type safety
- Uses generated API types (
EventSummaryfrom OpenAPI client) - Notification payload properly typed via
Notificationinterface
Testing Recommendations
-
Navigation:
- Verify all sections display with correct colors
- Test collapsed sidebar shows colored icons with tooltips
- Confirm dividers appear between sections only
-
Event Notifications:
- Monitor network tab while events are created
- Verify no GET requests to
/api/eventson event creation - Confirm new events appear at top of list on page 1
- Test filter behavior (events matching filter appear immediately)
Future Considerations
- Navigation: Could add section titles when sidebar is expanded for additional clarity
- Notifications: Consider implementing optimistic updates for event creation from UI
- Performance: If event volume is extremely high, consider rate-limiting UI updates
Files Modified
attune/web/src/components/layout/MainLayout.tsx(navigation reorganization + colors)attune/web/src/pages/events/EventsPage.tsx(notification optimization)
No Breaking Changes
All changes are backwards compatible and don't affect:
- API contracts
- Database schema
- Service interfaces
- Existing notification infrastructure