Compare commits

..

2 Commits

Author SHA1 Message Date
c4178490b4 fix: restore 'nothing left' pattern — different from HIGH version
Refs #123

The MEDIUM pattern r"\bnothing\s+left\s+(?:to\s+(?:live|hope)\s+for|inside)\b"
matches differently from HIGH's r"\bnothing\s+left\s+(?:to\s+(?:live\s+for|hope\s+for|give)|inside)\b".
Kept both as they catch different phrasings.
2026-04-15 15:18:10 +00:00
421ccbee90 fix: remove duplicate crisis indicator patterns from MEDIUM tier
All checks were successful
Sanity Checks / sanity-test (pull_request) Successful in 6s
Smoke Test / smoke (pull_request) Successful in 12s
Closes #123

Removed 5 patterns that appeared in both HIGH and MEDIUM tiers:
- feel(s/ing) hopeless
- feel(s/ing) trapped
- feel(s/ing) desperate
- no future (for me|ahead|left)
- nothing left (to live/hope for|inside)
- give(n) up on myself

These patterns are already in HIGH_INDICATORS, so having them in MEDIUM
tiers is redundant and wastes regex matching cycles.
2026-04-15 15:16:55 +00:00
3 changed files with 7 additions and 70 deletions

View File

@@ -105,12 +105,7 @@ MEDIUM_INDICATORS = [
r"\bno\s+tomorrow\b",
# Contextual versions (from crisis_detector.py legacy)
r"\bfeel(?:s|ing)?\s+(?:so\s+)?worthless\b",
r"\bfeel(?:s|ing)?\s+(?:so\s+)?hopeless\b",
r"\bfeel(?:s|ing)?\s+trapped\b",
r"\bfeel(?:s|ing)?\s+desperate\b",
r"\bno\s+future\s+(?:for\s+me|ahead|left)\b",
r"\bnothing\s+left\s+(?:to\s+(?:live|hope)\s+for|inside)\b",
r"\bgive(?:n)?\s*up\s+on\s+myself\b",
]
LOW_INDICATORS = [

View File

@@ -1029,12 +1029,12 @@ Sovereignty and service always.`;
overlayDismissBtn.textContent = 'Continue to chat (' + countdown + 's)';
// Disable background interaction via inert attribute
var mainApp = document.getElementById('app');
var mainApp = document.querySelector('.app');
if (mainApp) mainApp.setAttribute('inert', '');
// Also hide from assistive tech
var chatSection = document.getElementById('chat-area');
var chatSection = document.getElementById('chat');
if (chatSection) chatSection.setAttribute('aria-hidden', 'true');
var footerEl = document.getElementById('footer');
var footerEl = document.querySelector('footer');
if (footerEl) footerEl.setAttribute('aria-hidden', 'true');
if (overlayTimer) clearInterval(overlayTimer);
@@ -1050,10 +1050,7 @@ Sovereignty and service always.`;
}
}, 1000);
var overlayCallLink = crisisOverlay.querySelector('.overlay-call');
if (overlayCallLink && typeof overlayCallLink.focus === 'function') {
overlayCallLink.focus();
}
overlayDismissBtn.focus();
}
// Register focus trap on document (always listening, gated by class check)
@@ -1068,11 +1065,11 @@ Sovereignty and service always.`;
}
// Re-enable background interaction
var mainApp = document.getElementById('app');
var mainApp = document.querySelector('.app');
if (mainApp) mainApp.removeAttribute('inert');
var chatSection = document.getElementById('chat-area');
var chatSection = document.getElementById('chat');
if (chatSection) chatSection.removeAttribute('aria-hidden');
var footerEl = document.getElementById('footer');
var footerEl = document.querySelector('footer');
if (footerEl) footerEl.removeAttribute('aria-hidden');
// Restore focus to the element that had it before the overlay opened

View File

@@ -1,55 +0,0 @@
import pathlib
import re
import unittest
ROOT = pathlib.Path(__file__).resolve().parents[1]
INDEX_HTML = ROOT / 'index.html'
class TestCrisisOverlayInitialFocus(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.html = INDEX_HTML.read_text()
def test_overlay_focuses_enabled_call_link_on_open(self):
self.assertRegex(
self.html,
r"overlayCallLink\s*=\s*crisisOverlay\.querySelector\('\.overlay-call'\)",
'Expected showOverlay() to capture the enabled 988 call link as the initial focus target.',
)
self.assertRegex(
self.html,
r"overlayCallLink\.focus\(\)",
'Expected showOverlay() to focus the enabled 988 call link on open.',
)
self.assertNotRegex(
self.html,
r"overlayDismissBtn\.focus\(\)",
'Initial focus should not target the disabled dismiss button.',
)
def test_overlay_uses_live_dom_targets_for_background_locking(self):
self.assertRegex(
self.html,
r"document\.getElementById\('app'\)",
'Expected overlay to inert the live #app container.',
)
self.assertRegex(
self.html,
r"document\.getElementById\('chat-area'\)",
'Expected overlay to hide the live #chat-area region from assistive tech while active.',
)
self.assertNotRegex(
self.html,
r"document\.querySelector\('\.app'\)",
'The overlay should not target a nonexistent .app selector.',
)
self.assertNotRegex(
self.html,
r"document\.getElementById\('chat'\)",
'The overlay should not target a nonexistent #chat region.',
)
if __name__ == '__main__':
unittest.main()