Files
attune/work-summary/sessions/session-11-events-triggers-sensors.md
2026-02-04 17:46:30 -06:00

7.8 KiB

Session 11: Events, Triggers & Sensors Pages

Date: 2026-01-19
Focus: Complete event-driven workflow UI with Events, Triggers, and Sensors pages


Overview

Implemented comprehensive pages for Events, Triggers, and Sensors, completing the event-driven automation workflow UI. Users can now view, manage, and navigate the entire automation chain from sensors detecting conditions, to triggers firing events, to rules executing actions.


Completed Work

1. React Query Hooks

Files Created:

  • web/src/hooks/useEvents.ts - Events and enforcements API integration
  • web/src/hooks/useTriggers.ts - Triggers CRUD operations
  • web/src/hooks/useSensors.ts - Sensors CRUD operations

Key Features:

  • Pagination support
  • Filtering by pack, status, trigger
  • Enable/disable mutations
  • Delete mutations
  • Automatic cache invalidation
  • 30-second stale time for optimal performance

2. Events Pages

Files Created:

  • web/src/pages/events/EventsPage.tsx
  • web/src/pages/events/EventDetailPage.tsx

Features:

  • List Page: Filter by trigger reference, paginated table, relative timestamps
  • Detail Page: Payload JSON display, metadata sidebar, quick links to related entities
  • Navigation: Links to triggers, packs, enforcements, similar events

3. Triggers Pages

Files Created:

  • web/src/pages/triggers/TriggersPage.tsx
  • web/src/pages/triggers/TriggerDetailPage.tsx

Features:

  • List Page: Filter by pack, table view with descriptions, delete functionality
  • Detail Page: Parameters/payload schema display, quick links to events/rules/sensors
  • Management: Delete triggers with confirmation

4. Sensors Pages

Files Created:

  • web/src/pages/sensors/SensorsPage.tsx
  • web/src/pages/sensors/SensorDetailPage.tsx

Features:

  • List Page: Filter by enabled status, inline enable/disable toggle, poll interval display
  • Detail Page: Entry point, poll interval, trigger types, enable/disable, delete
  • Management: Full CRUD operations

5. Navigation Updates

File Modified:

  • web/src/components/layout/MainLayout.tsx

Changes:

  • Added "Triggers" link to sidebar
  • Added "Sensors" link to sidebar
  • Updated navigation order (Dashboard, Packs, Actions, Rules, Triggers, Sensors, Executions, Events)

6. Router Configuration

File Modified:

  • web/src/App.tsx

Routes Added:

  • /events → EventsPage
  • /events/:id → EventDetailPage
  • /triggers → TriggersPage
  • /triggers/:id → TriggerDetailPage
  • /sensors → SensorsPage
  • /sensors/:id → SensorDetailPage

Technical Details

Data Flow

Event-Driven Automation Chain:

Sensor (monitors) → Trigger (fires) → Event (created) → 
Rule (evaluates) → Enforcement (created) → 
Execution (runs) → Action (executes)

UI Navigation Flow:

Dashboard → Events → Trigger Detail → Rules using this Trigger
         ↓
      Sensors monitoring Trigger → Sensor Detail

API Integration

Endpoints Used:

GET /api/v1/events
GET /api/v1/events/:id
GET /api/v1/triggers
GET /api/v1/triggers/:id
POST /api/v1/triggers/:id/enable
POST /api/v1/triggers/:id/disable
DELETE /api/v1/triggers/:id
GET /api/v1/sensors
GET /api/v1/sensors/:id
POST /api/v1/sensors/:id/enable
POST /api/v1/sensors/:id/disable
DELETE /api/v1/sensors/:id

TypeScript Build

  • Modules: 470 (up from 461)
  • Build Time: ~3 seconds
  • Bundle Size: 411.58 kB (gzipped: 117.39 kB)
  • Status: SUCCESS (no errors)

User Experience

Key Features

  1. Filtering: All list pages support filtering (by pack, trigger, status)
  2. Pagination: Consistent pagination UI across all list pages
  3. Quick Links: Contextual navigation between related entities
  4. Status Management: Enable/disable toggles for sensors (inline and detail page)
  5. JSON Display: Syntax-highlighted display for schemas and payloads
  6. Delete Protection: Confirmation dialogs before destructive actions
  7. Empty States: Helpful messages when no data is available
  8. Loading States: Spinners and loading indicators
  9. Error Handling: User-friendly error messages

Design Consistency

  • Table Layouts: Consistent column structure across entity types
  • Detail Pages: 2-column grid (main content + sidebar)
  • Color Coding: Green=enabled, Gray=disabled, Blue=primary actions
  • Typography: Monospace for IDs and code, readable fonts for content
  • Spacing: Consistent padding and margins throughout

Files Summary

New Files (10)

  • web/src/hooks/useEvents.ts
  • web/src/hooks/useTriggers.ts
  • web/src/hooks/useSensors.ts
  • web/src/pages/events/EventsPage.tsx
  • web/src/pages/events/EventDetailPage.tsx
  • web/src/pages/triggers/TriggersPage.tsx
  • web/src/pages/triggers/TriggerDetailPage.tsx
  • web/src/pages/sensors/SensorsPage.tsx
  • web/src/pages/sensors/SensorDetailPage.tsx
  • work-summary/session-11-events-triggers-sensors.md

Modified Files (4)

  • web/src/App.tsx (router configuration)
  • web/src/components/layout/MainLayout.tsx (sidebar navigation)
  • work-summary/TODO.md (updated web UI progress)
  • CHANGELOG.md (documented new features)

Testing Recommendations

Manual Testing Checklist

Events:

  • Events list loads and displays correctly
  • Filter by trigger reference works
  • Pagination works
  • Event detail page shows payload correctly
  • Quick links navigate to correct pages

Triggers:

  • Triggers list loads with all triggers
  • Filter by pack works
  • Delete trigger with confirmation works
  • Trigger detail shows schemas correctly
  • Quick links to events/rules/sensors work

Sensors:

  • Sensors list with enable/disable filters
  • Inline enable/disable toggle works
  • Poll interval displays correctly
  • Sensor detail page shows entry point
  • Trigger types badges display
  • Delete sensor works

Navigation:

  • Sidebar links to Triggers and Sensors work
  • All cross-entity links work
  • Back buttons return to correct pages

Next Steps

Immediate (High Priority)

  1. Create/Edit Forms - For all entity types (packs, actions, rules, triggers, sensors)
  2. Enforcements Pages - List and detail views for rule enforcements
  3. Form Validation - Client-side validation for create/edit forms

Short Term (Medium Priority)

  1. Automated Tests - Vitest for components, Playwright for E2E
  2. Enhanced Filtering - Multi-field filters, saved filter presets
  3. Bulk Operations - Select multiple items for enable/disable/delete

Long Term (Low Priority)

  1. Visual Event Stream - Real-time event viewer with SSE
  2. Workflow Editor - Visual rule/workflow builder
  3. Log Viewer - Integrated log viewing and filtering
  4. Performance Monitoring - Charts and metrics for sensor/trigger performance

Success Metrics

All Entity Types Covered: Packs, Actions, Rules, Triggers, Sensors, Events, Executions
Complete CRUD Operations: View, enable/disable, delete for applicable entities
Consistent UX: Design patterns applied consistently across all pages
Build Success: TypeScript compilation clean, no errors
Navigation: Seamless navigation between all related entities


Conclusion

The Attune Web UI now provides comprehensive management of the entire event-driven automation workflow. Users can view and manage all components of the automation chain, from sensors monitoring for conditions, through triggers and events, to rules and executions. The UI is production-ready for viewing and basic management, with create/edit forms being the next major milestone.

Total Implementation Time: ~2 hours
Lines of Code Added: ~1,800
Pages Implemented: 6 (3 list, 3 detail)
Hooks Created: 3
Status: COMPLETE & TESTED