According to AP, the ship was able to issue a mayday and passengers of the bridge were warned: https://apnews.com/article/baltimore-bridge-collapse-53169b3...
> The operators of the ship issued a mayday call moments before the crash that took down the Francis Scott Key Bridge, enabling authorities to limit vehicle traffic on the span, Maryland’s governor said.
I don't know how long "moments" was, but presumably about as much warning as any automated system could provide.