high priority low complexity frontend pending frontend specialist Tier 7

Acceptance Criteria

All interactive elements (CTA button, dismiss action) have a minimum touch target of 44x44dp verified via layout inspector
Every Semantics widget has a non-empty label describing its purpose; screen reader (TalkBack/VoiceOver) announces card title, scenario type, and CTA action in logical order
All text/background contrast ratios meet WCAG 2.2 AA minimum 4.5:1 for normal text and 3:1 for large text, verified with a color-contrast tool against the dark card background
Badge colors (wellbeing flags, scenario type) meet 3:1 contrast against their container background
Dynamic state changes (new prompt appearing, dismissed state) trigger a live region announcement via SemanticsService.announce or equivalent Flutter mechanism
Card passes flutter_test accessibility audit: tester.ensureSemantics() returns no violations
excludeSemantics is used on purely decorative icons/images so screen readers skip them
Focus order matches visual top-to-bottom layout (title → description → CTA → dismiss)
No accessibility regression introduced on previously passing widget tests

Technical Requirements

frameworks
Flutter
flutter_test
data models
ScenarioPrompt
WellbeingFlag
performance requirements
Semantics tree must not introduce perceptible frame-time overhead; verify with Flutter DevTools Timeline
Widget rebuild count must not increase due to added Semantics wrappers
security requirements
Semantics labels must not expose internal IDs or raw database keys to assistive technology
ui components
ScenarioPromptNotificationCard
AppButton (CTA — must meet 44x44dp)
WellbeingFlagBadge
Semantics (Flutter built-in)
MergeSemantics (for grouped card region)

Execution Context

Execution Tier
Tier 7

Tier 7 - 84 tasks

Can start after Tier 6 completes

Implementation Notes

Use Flutter's Semantics widget with label, hint, and button role for the CTA. Wrap the entire card in MergeSemantics only if the card should be read as a single unit; otherwise keep individual Semantics nodes for finer screen-reader control. For live regions, call SemanticsService.announce(label, TextDirection.ltr) inside a post-frame callback when the prompt state changes. To fix contrast: pull color values from the existing design token system (do not hardcode) and verify token values against the dark background — if a token fails, update the token value rather than overriding locally.

For touch targets smaller than 44dp, wrap with a SizedBox(width: 44, height: 44) and use Semantics with onTap, or add padding inside the button widget. Use the Flutter Accessibility Scanner during manual testing on a physical device. Avoid setting excludeSemantics on non-decorative content.

Testing Requirements

Write or update widget tests in flutter_test: (1) call tester.ensureSemantics() before pumping the widget; (2) verify SemanticsNode tree contains expected labels for title, CTA, and dismiss using find.bySemanticsLabel; (3) assert hit-test area of CTA button is >= 44x44dp by inspecting RenderBox size; (4) simulate dynamic state change and assert SemanticsService.announce was called. Run flutter analyze --no-pub to catch any Semantics API misuse. No golden tests required for this task.

Component
Scenario Prompt Notification Card
ui medium
Epic Risks (2)
high impact medium prob technical

If the scheduler runs concurrently (e.g., two overlapping cron invocations due to edge function retry), duplicate prompts could be dispatched before the first run's history records are committed, breaking the deduplication guarantee.

Mitigation & Contingency

Mitigation: Use a Postgres advisory lock or unique constraint on (user_id, scenario_id, activity_ref) in the prompt history table to make concurrent writes idempotent; design the scheduler to check history inside a transaction.

Contingency: If concurrency issues persist in production, add a distributed lock via Supabase Edge Function concurrency limit (max_instances=1) for the evaluation function as a hard guard.

medium impact medium prob scope

Coordinators may find scenario configuration unclear if trigger conditions are expressed as raw JSON or technical terminology, leading to misconfiguration and irrelevant prompts being sent to peer mentors.

Mitigation & Contingency

Mitigation: Design the ScenarioConfigurationScreen to display human-readable descriptions of each template's trigger condition (e.g., 'Send 3 days after first contact if wellbeing concern was flagged') rather than raw rule properties; validate with an HLF coordinator in a design review before implementation.

Contingency: If coordinators still misconfigure rules after launch, add a preview mode that shows a simulated prompt based on a test activity before the rule is enabled.