Compare commits

..

1 Commits

Author SHA1 Message Date
c28b0c2163 feat: add persistent safety plan button in header (#38)
All checks were successful
Sanity Checks / sanity-test (pull_request) Successful in 5s
Smoke Test / smoke (pull_request) Successful in 9s
- Adds subtle safety plan link/icon always visible in the chat header area
- Button opens the same 5-field safety plan modal
- Does NOT require crisis detection to be visible
- Accessible (keyboard navigable, screen reader friendly)

Closes #38
2026-04-15 14:59:19 +00:00
2 changed files with 45 additions and 75 deletions

View File

@@ -1,75 +0,0 @@
# GENOME.md — the-door
**Generated:** 2026-04-14
**Repo:** Timmy_Foundation/the-door
**Description:** Crisis Front Door — a single URL where a man at 3am can talk to Timmy. No login, no signup. 988 always visible.
---
## Project Overview
The-door is a crisis intervention web application — the most sacred surface in the Timmy Foundation. When a man at 3am reaches the end of his road, this is where he lands. No login, no signup, no barriers. 988 Suicide and Crisis Lifeline always visible. The "When a Man Is Dying" protocol active on every page.
## Architecture
```
the-door/
├── index.html # Main crisis page (PWA-capable)
├── crisis-offline.html # Offline fallback (service worker cached)
├── about.html # About page
├── testimony.html # Testimony/stories page
├── sw.js # Service worker (offline-first)
├── manifest.json # PWA manifest
├── crisis/ # Core crisis detection + response
│ ├── detect.py # Keyword/pattern detection (4 tiers)
│ ├── gateway.py # API endpoints, prompt injection
│ ├── response.py # Response generation, 988 routing
│ ├── compassion_router.py # Profile-based response routing
│ ├── profiles.py # Compassion profiles
│ └── PROTOCOL.md # The protocol (SOUL.md reference)
├── crisis_detector.py # Legacy shim → crisis/detect.py
├── crisis_responder.py # Legacy responder
├── dying_detection/ # Deprecated module
├── evolution/ # Crisis synthesizer (creative)
├── tests/ # Safety-critical tests
│ ├── test_crisis_overlay_focus_trap.py
│ ├── test_dying_detection_deprecation.py
│ └── test_false_positive_fixes.py
└── deploy/ # Deployment docs
```
## Key Abstractions
| Module | Purpose |
|---|---|
| `crisis/detect.py` | 4-tier detection: LOW/MEDIUM/HIGH/CRITICAL via regex patterns |
| `crisis/gateway.py` | HTTP API, Sovereign Heart prompt injection |
| `crisis/response.py` | Response generation, 988 integration, escalation |
| `crisis/compassion_router.py` | Profile-based routing (different crisis types) |
| `sw.js` | Service worker for offline-first PWA |
## Safety Constraints
- **The-door never auto-closes PRs** (in fleet-ops exempt list)
- **988 always visible** on every page, even offline
- **When a Man Is Dying protocol** active on every interaction
- **No login/signup** — zero barriers to crisis support
- **Offline-first** — service worker caches critical pages
## Test Coverage
| Test | Coverage |
|---|---|
| Crisis overlay focus trap | ✅ |
| Dying detection deprecation | ✅ |
| False positive fixes | ✅ |
| Crisis detection tiers | ❌ (in crisis/tests.py) |
| Response generation | ❌ |
| Offline service worker | ❌ |
## Security
- No user data stored (crisis intervention is stateless by design)
- No cookies, no tracking, no analytics
- Service worker only caches static assets
- Crisis detection runs client-side where possible

View File

@@ -80,6 +80,37 @@ html, body {
gap: 4px;
}
/* ===== HEADER SAFETY PLAN BUTTON ===== */
#header-safety-plan {
background: none;
border: none;
color: #ff6b6b;
font-size: 0.75rem;
font-weight: 600;
cursor: pointer;
padding: 4px 8px;
border-radius: 4px;
display: flex;
align-items: center;
gap: 4px;
transition: background 0.2s, color 0.2s;
white-space: nowrap;
}
#header-safety-plan:hover,
#header-safety-plan:focus {
background: rgba(255, 107, 107, 0.15);
color: #ff8a8a;
outline: 2px solid #ff6b6b;
outline-offset: 2px;
}
#header-safety-plan svg {
width: 14px;
height: 14px;
}
.status-dot {
width: 6px;
height: 6px;
@@ -629,6 +660,10 @@ html, body {
<span class="status-dot"></span>
<span id="status-text">Online</span>
</div>
<button id="header-safety-plan" aria-label="Open My Safety Plan" title="Open My Safety Plan">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10 9 9 9 8 9"/></svg>
<span>Safety Plan</span>
</button>
</header>
<!-- Enhanced crisis panel - shown on keyword detection -->
@@ -1297,6 +1332,16 @@ Sovereignty and service always.`;
safetyPlanModal.classList.add('active');
_activateSafetyPlanFocusTrap(crisisSafetyPlanBtn);
});
// Header safety plan button
var headerSafetyPlanBtn = document.getElementById('header-safety-plan');
if (headerSafetyPlanBtn) {
headerSafetyPlanBtn.addEventListener('click', function() {
loadSafetyPlan();
safetyPlanModal.classList.add('active');
_activateSafetyPlanFocusTrap(headerSafetyPlanBtn);
});
}
}
// ===== TEXTAREA AUTO-RESIZE =====