Add HasAnyCompletedSession() method to sleep storage to check if any
sleep sessions have been completed. This is used by the feature discovery
notification system to determine when to fire the "first sleep session
complete" notification.
A completed session has both sleep_onset and wake_time set.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Fix touch event propagation from panels to canvas, resolve iOS Safari
passive event listener warnings, prevent double-tap zoom conflicts,
improve pinch gesture accuracy, and enable three-finger pan.
Changes:
- Add maximum-scale=1.0, user-scalable=no to viewport meta tag (live.html)
- Add touch-action: none to canvas elements (expert.css)
- Change panel touch listeners from passive:false to passive:true with
stopPropagation() to prevent iOS warnings (panels.js)
- Enhance controls.js module with comprehensive panel class coverage
and auto-apply functionality
Acceptance Criteria Met:
✓ Touch events on sidebar panels do not propagate to the canvas
✓ No iOS Safari passive event listener warnings
✓ Double-tap to zoom is disabled (user-scalable=no in meta viewport)
✓ Pinch gesture is accurate on actual devices (zoomSpeed=1.0)
✓ Three-finger pan is enabled in OrbitControls
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Use relevance-based scoring (exact > prefix > substring > subsequence)
- Add title weight boost (1.5x) for better title matching
- Add category filter (0.5x) for category matching
- Minimum 0.6 score threshold for better result quality
- Sort results by relevance score
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Implement comprehensive filter bar with checkboxes for event categories
(Presence, Zones, Alerts, System, Learning), person and zone dropdowns,
date range selector, and text search with fuzzy matching.
- Client-side filtering on loaded events for instant response
- Server-side date range queries with since/until parameters
- FTS5 full-text search for fuzzy matching on descriptions
- Cursor-based pagination supporting 500+ results
- Virtualized rendering with IntersectionObserver for performance
- Active filters display with removable tags
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
When the server sets repeated_edit_hint:true, pick the most-changed
qualifying setting from localStorage history instead of passing the
literal string 'detected_by_server' into formatSettingName, which
rendered as broken text in the hint banner.
- Add collapsible filter panel with category checkboxes (Presence, Zones,
Alerts, System, Learning) for client-side event type filtering
- Add person and zone dropdowns populated from /api/people and /api/zones
- Add date range selector (All Time / Today / Last 7 Days / Last 30 Days /
Custom range) with server-side re-fetch on date changes
- Add text search input with fuzzy client-side matching and FTS5 server-side
prefix matching for descriptions
- Add active filter tags with individual remove buttons and Clear All
- Add load-more cursor pagination for 500+ results
- Add virtualized rendering with IntersectionObserver for 1000+ events
- Render event feedback buttons (thumbs up/down) inline on each event
- Add now-replaying chip showing current replay timestamp
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Move localStorage.clear() to parent beforeEach to ensure module
initialization always starts with clean state. This fixes test
isolation where localStorage data from previous tests was being
loaded by the module before the nested beforeEach could clear it.
The repeated-setting change detection feature is already fully
implemented in proactive.js with:
- Setting change tracking in localStorage (24h window)
- Help prompt after 3+ changes for qualifying settings
- Guided calibration flow with false positive and missed motion tests
- Value suggestions based on diurnal baseline SNR and link health
- Apply suggested value button
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The drop-oldest path (drain + re-send) was not goroutine-safe: multiple
concurrent EventBus delivery goroutines could each drain one slot and
then all block waiting to re-send, causing inFlight.Wait() in Close()
to deadlock. Drop-new is atomic via the select/default pattern and
never blocks.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Detect when user changes same config setting 3+ times within 24 hours
- Show non-intrusive help prompt with 'Help me tune this' button
- Guided calibration flow tests both directions:
- False positive test: walk around room
- Missed motion test: sit still
- Suggest optimal value based on diurnal baseline SNR and link health
- Apply suggested value button writes to /api/settings
- Track changes in localStorage (spaxel_setting_changes)
Acceptance:
- Help prompt fires after 3+ changes in 24h
- Calibration flow tests both directions
- Suggests value based on system data
- Apply button works
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The proactive quality prompt system for link degradation warnings is already fully implemented:
- dashboard/js/proactive.js: monitorLinkQuality() tracks links with quality < 0.6
- 5-minute sustained drop threshold (DURATION_MS = 5 * 60 * 1000)
- Non-blocking dismissible prompt card with 'Diagnose' and 'Dismiss for today' buttons
- Pulsing amber highlight (0xff9800) on 3D link lines via startLinkPulsing()
- diagnoseLink() fetches from /api/diagnostics/link/{linkID}
- Dismissed prompts tracked in localStorage, cleared on recovery
- mothership/internal/diagnostics/linkweather.go: GetDiagnosticFor() method
- Returns Diagnosis with Title, Detail, Advice, Severity, ConfidenceScore
- Root cause analysis for environmental changes, WiFi congestion, metal interference, Fresnel blockage, periodic interference
- mothership/cmd/mothership/main.go: API endpoint /api/diagnostics/link/{linkID}
- Handles optional timestamp parameter
- Returns diagnosis with repositioning suggestions if applicable
All acceptance criteria met:
- Prompt appears within 5 minutes of sustained drop ✓
- No prompt for transient drops (< 5 min) ✓
- Diagnose button shows root cause ✓
- Dismissed prompts don't re-appear unless condition reoccurs after recovery ✓
- Pulsing amber highlight on 3D link line ✓
Adds TestListEvents_LoadMoreWith500Plus to explicitly verify that cursor-based
pagination correctly retrieves all events when the total exceeds 500 (the max
single-page limit). Covers the acceptance criterion: "Load more pagination works
for 500+ results".
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Verified all REST API endpoints are implemented and tested:
- Settings: GET/POST /api/settings with validation
- Zones: GET/POST/PUT/DELETE /api/zones with history
- Portals: GET/POST/PUT/DELETE /api/portals with crossings
- Triggers: GET/POST/PUT/DELETE /api/triggers with test endpoint
- Notifications: GET/POST /api/notifications/config and test
- Replay: GET/POST sessions, seek, tune, speed control
- BLE Devices: GET/PUT/DELETE /api/ble/devices with aliases
All endpoints include OpenAPI-style godoc comments and return appropriate
JSON with proper HTTP status codes. Settings persist to SQLite across
restarts. Zone/portal changes broadcast via WebSocket for live updates.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add CSS environment variables for safe-area-inset to prevent content
overlap with notch/home indicator on iOS devices.
- Add padding-top and padding-bottom to body using env(safe-area-inset-*)
- Mobile bottom navigation already respects safe-area-inset-bottom
- viewport-fit=cover meta tag already present in all HTML pages
- Update renderFeedbackExplanation to properly display diagnosis info
- Fix showInlineResponse to access explainability from inline_response
- Show contributing link name with deltaRMS and threshold ratio
- Display diagnostic result or default ambient RF interference message
- Add correction note for all feedback types
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
When users mark detections as incorrect, the system now provides:
- Contributing link name (MAC prefix)
- DeltaRMS value and threshold ratio
- Root cause from diagnostic checks
- Note about applying corrections
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The EventBus pub-sub mechanism in mothership/internal/events/bus.go was
already implemented with all required EventType constants, typed payload
structs, fan-out subscriber support, and comprehensive tests. This commit
also wires ConsumeExplainRequests into the fusion loop for dashboard clients.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Three issues resolved in the detection explainability system:
- computeExplanation returned early when grid==nil (always the case in the
live fusion loop), causing all explain requests to return empty link
contributions. Removed the unnecessary nil-grid guard since the Fresnel
computation uses only blob/link positions, not the grid.
- Contribution values were raw deltaRMS×weight×zoneDecay scalars, not
percentages. Now normalized so contributing links sum to 1.0, giving the
dashboard a proper confidence breakdown (60% / 40% / etc.).
- Fixed off-by-one in blobHistory eviction (kept 101 instead of 100).
Added 23 table-driven tests covering: nil-grid computation, single/multi-link
normalization, Fresnel zone number geometry, ellipsoid generation, HTTP
handlers (200/400 paths), WebSocket snapshot fields, BLE match inclusion,
zone decay inverse-square law, and history eviction cap.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add security status card with arm/disarm dialog, DISARMED/LEARNING/ARMED/ALERT
badge, learning progress bar (N of 7 days), and last-anomaly summary line
- Add full-width alert banner with acknowledge button for armed-mode anomalies;
acknowledged alerts disappear from banner but remain in history
- Add anomaly timeline panel (24h) with severity scores and timeline navigation
- Fix WS broadcast field names to match AnomalyEvent JSON/REST API:
anomaly_type→type, timestamp_ms→RFC3339 timestamp so JS handles both
WS pushes and polled history uniformly
- Fix formatTimeAgo() to parse RFC3339 string timestamps in addition to Unix-ms
- Fix fetchAnomalyCount() to use /api/anomalies?since=24h (structured response)
instead of /api/anomalies/history (returns plain array)
- Add security-card detail area styling to anomaly.css
- Add BlobIdentityProvider wiring in zones API for people resolution in zone responses
- Add linkweather diagnostic engine tests (Rules 1-5 + helpers)
All go test ./... pass; go vet ./... clean.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fresnel zone ellipsoids render for all active links when the debug layer
is toggled on. Uses shared fresnel.js helper for geometry computation,
with hover tooltips showing link details and click-to-select. viz3d.js
refactored to use the shared module instead of duplicating calculations.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>