Skip to content

fix: eliminate functionally dumb features — make every SOS path foolproof#110

Draft
NITISH-R-G wants to merge 1 commit into
mainfrom
cursor/foolproof-emergency-fixes-a74d
Draft

fix: eliminate functionally dumb features — make every SOS path foolproof#110
NITISH-R-G wants to merge 1 commit into
mainfrom
cursor/foolproof-emergency-fixes-a74d

Conversation

@NITISH-R-G
Copy link
Copy Markdown
Owner

Description

Brutally honest audit of every feature from the perspective of someone bleeding on a highway at 2 AM. Found 12 issues ranging from fake dispatch channels to misleading UI to missing 112 auto-dial. Every fix makes the app actually work in a real emergency instead of just looking good on paper.

CRITICAL fixes (Sprint 1 — life-safety)

Issue What was broken Fix
Fake nearby_services Future.delayed(3s, () => true) — always showed "success" without doing anything Real Supabase sos_broadcasts table insert + migration + RLS
No 112 auto-dial Only dialed user's saved contact — never actual emergency services _callEmergencyContact() now dials 112 FIRST, then personal contact
SMS payload dropped Twilio function's buildSmsBody never included the payload field Added CTX: {payload} to SMS body so dispatchers see triage context
Voice overclaims Said "SOS dispatched" even when SMS failed — dangerous false reassurance speakTriageSummary now takes smsSucceeded param; warns to "dial 112 now" on failure

HIGH-priority honesty fixes (Sprint 2)

Issue What was broken Fix
Vital Scan lies Dashboard: "Check heart rate & oxygen saturation" — it's manual entry only Renamed to "Vital Entry" with honest subtitle + removed PPG footer
SMS vitals placeholder Structured SMS always sent C?B?Bl? — never used entered vitals _resolveVitals() now reads from VitalSignsService when available
Camera triage dead "not auto-analyzed in this build" — photo was captured but never sent to AI Wired _analyzeWithGemma4()aiTriage.triageWithScenePhoto()
BLE "mesh" is not mesh Called "mesh" implying multi-hop relay — it's one-hop beacon (~30m) Renamed to "BLE beacon (nearby alert)" with honest range disclaimer

MEDIUM improvements (Sprint 3)

  • Quick-action bar on incident screen (PHOTO + SOS buttons at top)
  • Bengali/Marathi countdown messages (were falling back to English)
  • Rich auto-SOS transcript: "Automatic crash SOS at coordinates, accelerometer severity N/5, driver may be incapacitated" instead of generic "Emergency SOS triggered"
  • Deleted 5 orphaned files (0 imports each): bystander_radar, multi_agent_coordinator, scene_security_service, gemini_http, india_government_crash_contribution_service

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

  • Manual code review of all changed files
  • Unit Tests (Flutter not available in CI environment)
  • Integration Tests
  • Manual Smoke Test (on physical device)

Static analysis: All changes follow existing patterns. No new imports that don't exist in pubspec.yaml. Migration follows existing schema conventions with proper RLS.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Files changed (16)

Services (7 modified/deleted):

  • emergency_orchestrator.dart — real nearby broadcast, 112 auto-dial, honest BLE naming, SMS outcome to voice
  • voice_assistant_service.dart — honest TTS (success/failure), bn/mr locale support
  • ai_triage_service.dart — rich sensor-context transcript for auto-SOS
  • structured_sms_service.dart — real vitals from VitalSignsService
  • Deleted: gemini_http.dart, multi_agent_coordinator.dart, scene_security_service.dart, india_government_crash_contribution_service.dart

UI (4 modified/deleted):

  • dashboard.dart — honest subtitles for Vital Entry + BLE Chat + Capture Scene
  • incident_reporting_screen.dart — quick-action bar + Gemma 4 vision triage
  • vital_scan_screen.dart — honest footer replacing PPG claim
  • Deleted: bystander_radar.dart

Backend (2):

  • sms-dispatch/index.ts — include payload in SMS body
  • 20260517000000_sos_broadcasts.sql — new table for real nearby broadcasts

Localization (2):

  • app_en.arb, app_hi.arb — vital scan string updates
Open in Web Open in Cursor 

…roof

CRITICAL fixes (Sprint 1):
- Remove fake 'nearby_services' (was Future.delayed(3s, true)) — replaced
  with real Supabase sos_broadcasts insert + migration + RLS
- Auto-dial 112 (India ERSS) on every SOS — previously only dialed user's
  saved contact, never actual emergency services
- Fix SMS dispatch function dropping payload field — triage context was
  never included in the Twilio SMS body
- Voice assistant no longer says 'SOS dispatched' when SMS failed — now
  tells the driver to dial 112 manually if dispatch didn't succeed

HIGH-priority honesty fixes (Sprint 2):
- Vital Scan: dashboard said 'Check heart rate & oxygen saturation' for
  manual-entry-only screen — renamed to 'Vital Entry' with honest subtitle
- Remove PPG footer text that contradicted the honest 'manual only' banner
- Wire real VitalSignsService data into structured SMS (was placeholder
  C?B?Bl? — now sends HR/RR/SpO2 when bystander recorded them)
- Capture Scene: wire camera photo into actual Gemma 4 vision triage —
  was 'not auto-analyzed in this build', now calls triageWithScenePhoto()
- Rename BLE 'mesh' to 'beacon' — honest about one-hop range (~30m),
  no relay, no encryption on wire

MEDIUM improvements (Sprint 3):
- Add quick-action bar (PHOTO + SOS) to incident reporting screen
- Add Bengali/Marathi countdown messages (were falling back to English)
- Improve auto-SOS triage transcript: 'Automatic crash SOS at <coords>,
  accelerometer severity N/5, driver may be incapacitated' instead of
  generic 'Emergency SOS triggered'
- Remove 5 orphaned files with zero imports: bystander_radar,
  multi_agent_coordinator, scene_security_service, gemini_http,
  india_government_crash_contribution_service

Phase 3 [CRITICAL]: life-safety path audited per rulebook

Co-authored-by: Nitish R.G. <NITISH-R-G@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants