Trucking Dispatch Alerts β Developer Guide
Purposeβ
This document explains how trucking dispatch alerts are produced, transported through the schedule payload, and rendered in the dispatch modal.
The current design separates:
- Actionable/review alerts that should drive dispatcher workflow
- Data-quality/info alerts that should be visible without looking like operational failures
- Workflow state that persists on the
Legdocument and controls review UX
High-level flowβ
flowchart LR
legData[LegAndRouteData] --> timingCalc[TruckingEventTimeService]
timingCalc --> schedulerEvent[ScheduleEventTimeRange]
schedulerEvent --> dispatchModal[DispatchEventModal]
dispatchModal --> workflowUpdate[LegAlertWorkflowUpdate]
workflowUpdate --> refetch[ScheduleRefetch]
refetch --> dispatchModal
Primary filesβ
APIβ
@attunelogic-api/src/services/schedule/trucking-event-time.service.js@attunelogic-api/src/controllers/schedule/index.js@attunelogic-api/src/models/Leg.js
Service web appβ
@attunelogic-service/src/modals/DispatchEventModal.tsx@attunelogic-service/src/shared/Scheduler/types/common.ts
Alert payload contractβ
Trucking schedule events keep the legacy warnings array for compatibility, but now also include structured alert metadata in timeRange.alerts.
Example shape:
{
"timeRange": {
"start": "2026-04-05T21:30:00.000Z",
"end": "2026-04-06T20:24:38.000Z",
"multiDay": true,
"alerts": [
{
"code": "hos_rest_required",
"type": "action_required",
"severity": "high",
"message": "Trip exceeds the FMCSA 11-hour driving window and requires overnight rest planning.",
"actionable": true
}
],
"warnings": [
"Trip exceeds the FMCSA 11-hour driving window and requires overnight rest planning."
],
"requiresAttention": true
}
}
Alert typesβ
Recommended/current type meanings:
action_required: dispatch should take actionneeds_review: dispatch should review before releasedata_quality: timing confidence or route data issueinfo: useful context without urgency
How requiresAttention worksβ
requiresAttention should only be derived from actionable/review alerts, not from every warning string.
That means:
- HOS and workflow-driving alerts should set
requiresAttention = true - fallback timing or stale cache alerts should stay visible without setting
requiresAttention = true
Workflow persistence modelβ
The workflow state persists on Leg.alertWorkflow.timingAlert.
Current fields:
needsReviewreviewStatusreviewedAtreviewedByrestPlanStatusplanNotes
This keeps workflow persistence separate from the transient alert classification while avoiding a second alert storage model.
Current workflow statesβ
pendingreviewedresolvedignored
Important nuanceβ
reviewed does not always mean βfully complete.β
A leg can be:
- reviewed and complete
- reviewed but still waiting on a rest-plan decision
The UI should therefore use both reviewStatus and restPlanStatus / needsReview when deciding whether follow-up is still open.
Modal rendering rulesβ
The dispatch modal currently uses three layers:
1. Compact alert summaryβ
- shown near the top of the details tab
- collapsed by default to reduce noise
- shows alert count, review status, and rest-plan status
2. Expanded alert detailβ
- shows actionable alert content and informational notes separately
- only visible when the summary is expanded
3. Workflow panelβ
- drives dispatcher actions such as review, ignore, message driver, or rest-plan follow-up
- can collapse into a summary state after the main workflow action is taken
Customer-facing visual rulesβ
- Amber: follow-up still needed
- Blue: reviewed and currently complete
- Gray: ignored / muted
Keep the review state and the rest-plan state visually separate. A leg may be reviewed while still needing rest-plan follow-up.
Current action behaviorβ
Mark Reviewed: marks the alert as reviewedMessage Driver: opens communications without changing workflow persistenceAdd Rest Plan: marks rest-plan follow-up as needed and opens plan notesIgnore: mutes the alert workflowIgnore Rest Plan: clears the rest-plan follow-up while keeping the alert reviewed
Implementation guardrailsβ
- Preserve
warningsfor any older consumers - Keep schedule response shape backward compatible
- Treat structured
alertsas additive metadata, not a replacement transport - Keep workflow persistence on
Leg.alertWorkflow.timingAlert - Prefer optimistic UI updates in the modal so colors/status change immediately after action
Recommended future alert codesβ
Operational / workflow:
hos_rest_requiredstarted_after_appointmentappointment_missedmulti_day_unplannedrest_plan_missing
Data quality / confidence:
route_timing_fallbackroute_timing_stale_cachemissing_route_durationmissing_location_data
Testing guidanceβ
When verifying changes, cover at least:
- actionable alert produces
requiresAttention = true - data-quality-only alert produces
requiresAttention = false - reviewed-complete workflow renders blue
- reviewed-with-follow-up renders blue review state plus amber follow-up state
- ignored workflow renders gray
- collapsed alert summary expands and contracts without hiding required follow-up actions