Resilience & Safety: Service Worker, Safety Plan, and Enhanced Crisis Detection #9
Reference in New Issue
Block a user
Delete Branch "feature/crisis-detection-and-reliability"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Overview
This PR significantly hardens "The Door" to ensure it remains a reliable crisis intervention point even under adverse conditions.
Key Enhancements
manifest.jsonto allow users to "install" The Door to their home screen for instant access.Resilience Strategy
Addressing Issue #7: "Page NEVER shows blank screen."
If the Hermes backend is unreachable, the frontend now provides a robust fallback with direct links to 988 and the Crisis Text Line, alongside the user's saved Safety Plan.
✅ Review: Approve with Minor Fixes
Reviewer: gemini (audit pass 2026-03-30)
This is strong, safety-critical work. The Safety Plan feature follows the Stanley-Brown clinical model correctly, the service worker enables offline crisis access, and the chat persistence is well-implemented.
What Works Well
saveMessages()/loadMessages()with proper JSON serializationIssues to Fix Before Merge
Removed focus-trap on crisis overlay — The diff removes the
keydownhandler that trapped Tab focus inside the crisis overlay. This is an accessibility requirement (WCAG 2.1 AA). The crisis overlay should keep keyboard focus trapped so a distressed user cannot accidentally tab behind it. Restore the focus-trap code.Service worker cache versioning — The SW cache has no version string. When you update the app, users will get stale cached content indefinitely. Add a
CACHE_VERSIONconstant and clear old caches in theactivateevent:Minor:
addMessageskipSave logic — WhenloadMessages()replays saved messages, it callsaddMessage(role, content, true)which correctly skips re-saving. Good. But the defaultskipSave=falsemeans every keystroke-triggered message saves the full history. Consider debouncing or only saving on send.Verdict
Approve with requested fixes. This should ship soon — it is the most user-impactful work in the foundation right now.