medium priority low complexity frontend pending frontend specialist Tier 2

Acceptance Criteria

The sidebar navigation item for the driver assignment list renders a DeclarationStatusBadge overlay when the pending count is greater than zero
When pending count is zero the badge is not rendered (no empty badge visible)
The badge count reflects the real-time value from a Riverpod StreamProvider or AutoDisposeProvider that polls or subscribes to pending declaration counts
The provider updates automatically when a coordinator completes a declaration flow (within the same session) without requiring a full app restart or manual refresh
The badge uses the DeclarationStatusBadge widget from task-001 — it is not a custom inline implementation in the navigation widget
The badge count is capped at display '99+' when the actual count exceeds 99
The badge is positioned at the top-right corner of the nav item icon without overlapping adjacent nav items
On low-bandwidth / offline state, the badge shows a neutral indicator (no count) rather than an error badge — the absence of data should not alarm the user
The DriverFeatureFlagGuard governs whether the driver assignment nav item (and its badge) appears at all — when the flag is disabled the entire nav entry is hidden
Screen readers announce the badge count as part of the nav item label, e.g. 'Driver assignments, 3 pending declarations'

Technical Requirements

frameworks
Flutter
Riverpod
Dart
apis
DeclarationStatusService.watchPendingCount(orgId)
FeatureFlagProvider (driver flag)
data models
DeclarationPendingCount
FeatureFlag
performance requirements
Provider must not trigger a full sidebar rebuild on every count change — use select() or a targeted ConsumerWidget scope to isolate the badge rebuild
Count query must not block sidebar initial render — use AsyncValue.when with a loading state that shows no badge
security requirements
Pending count query must be scoped to the authenticated coordinator's organization — never return cross-org counts
The Riverpod provider must be invalidated on user logout to prevent stale counts leaking across sessions
ui components
DeclarationStatusBadge (reused from task-001)
SidebarNavigationItem
BadgeOverlay

Execution Context

Execution Tier
Tier 2

Tier 2 - 518 tasks

Can start after Tier 1 completes

Implementation Notes

Implement the count provider as a StreamProvider.autoDispose that listens to DeclarationStatusService.watchPendingCount() — autoDispose ensures the subscription is cancelled when the sidebar is off-screen on platforms that unload it. Wrap the badge overlay using a Stack widget on the nav icon, not by modifying the DeclarationStatusBadge widget itself, to preserve the badge widget's single responsibility. For the '99+' cap, apply it at the provider layer (map count > 99 to a displayString '99+') rather than inside the badge widget so the badge remains a pure display component. For accessibility, use Semantics(label: 'Driver assignments, $count pending declarations', child: ...) on the nav item wrapper.

Testing Requirements

Write widget tests for: (1) badge renders with correct count when provider emits count > 0; (2) badge is absent when provider emits count == 0; (3) badge displays '99+' when count exceeds 99; (4) nav item is hidden when feature flag is disabled; (5) screen reader semantics label includes the count. Write unit tests for the Riverpod provider ensuring it maps service stream emissions to the correct count value and handles stream errors gracefully. Use ProviderContainer with overrides to inject mock service in all tests.

Component
Declaration Status Badge
ui low
Epic Risks (3)
high impact medium prob technical

The declaration acknowledgement screen has the most complex accessibility requirements of any screen in this feature: scrollable long-form legal text, a conditional checkbox that is only enabled after reading, and a timestamp capture. Incorrect focus management or missing semantics annotations could fail VoiceOver navigation or cause the screen reader to announce the checkbox as available before the driver has scrolled, undermining the legal validity of the acknowledgement.

Mitigation & Contingency

Mitigation: Build the acknowledgement screen against the WCAG 2.2 AA checklist from the start, not as a post-hoc audit. Use semantics-wrapper-widget and live-region-announcer from the platform's accessibility toolkit. Include a VoiceOver test session in the acceptance criteria with a tester using the screen reader.

Contingency: If WCAG compliance cannot be fully achieved within the sprint, ship the screen with a documented list of accessibility gaps and a follow-up sprint commitment. Do not block the declaration workflow launch if the core interaction works but a non-critical semantics annotation is missing.

medium impact medium prob integration

Drivers receive a push notification with a deep link to the declaration acknowledgement screen for a specific assignment. If the deep link handler does not correctly route to the right screen and assignment context — particularly when the app is launched cold from the notification — the driver may see a blank screen or the wrong declaration.

Mitigation & Contingency

Mitigation: Implement and test all three notification scenarios: app foregrounded, app backgrounded, and cold start. Use the platform's existing deep-link-handler infrastructure. Add integration tests that simulate notification tap events and assert correct screen and data loading.

Contingency: If cold-start deep link routing proves unreliable, implement a notification-centre fallback where the driver can find the pending declaration from the notification centre screen, ensuring the workflow can always complete even if the direct deep link fails.

medium impact low prob technical

If the driver-feature-flag-guard has any rendering edge case — such as a brief flash of driver UI before the flag value is loaded, or a guard that fails open on a flag service error — driver-specific UI elements could be momentarily visible to coordinators in organizations that have not opted in, causing confusion and potentially a support escalation.

Mitigation & Contingency

Mitigation: Default the guard to rendering nothing (not a loading indicator) until the flag value is definitively resolved. Treat flag service errors as flag-disabled to fail closed. Write widget tests covering the loading, disabled, and enabled states including the error case.

Contingency: If fail-closed cannot be guaranteed within the sprint, add a server-side RLS check on the driver assignment endpoints so that even if the UI guard leaks, the data layer refuses to return driver data for organizations without the flag enabled.