Teach a calm alternative
Once the view is managed, teach what to do when something happens.
Say "thank you" and reward the first look
Set a treat jar by the window. When your dog notices something outside and before they bark, say "yes" and drop a treat. You are paying for noticing quietly. Over time the sidewalk becomes a signal for food, not a signal to sound the alarm.
If barking has started, interrupt kindly
Say your dog's name once, walk toward them in a relaxed way, and lure them away from the window with a treat toss. Reward them on a mat or bed. Do not shout, since shouting sounds like you are barking too.
Practice with a helper
Ask a friend to walk by the window at a distance while you stand ready with treats. Reward quiet. Repeat with the friend closer. This is counterconditioning in practice: the trigger predicts something good.
Build the habit in tiny pieces
Do three short sessions a day. In the first, just practice the mat: toss a treat onto it, reward your dog for stepping on, and add a few seconds of lying down. In the second, add a distraction you control, like a quiet knock on a wall. In the third, play a recorded sound of footsteps or a doorbell at low volume while the dog is on the mat. Slowly raise the volume as long as your dog stays loose.
When a dog is truly alarmed, they will not take treats. That is your sign to calm the setting, not push the dog. Back up a step and make the trigger smaller.
Keep a log for two weeks. Note the time of the bark bursts. Often there is a pattern, like the school bus or the delivery truck, and you can set up a chew or a game five minutes before it starts.