We could ask how they managed to do that... But I wont...
The rain/light sensor is at the front of the mirror housing (if you look at the windscreen from the outside you will see the sensors).
So I would imagine it's either been knocked out of place or will need a replacement mirror housing.
If it's further up, the 'tube' as you say, sounds like the electical wiring for the auto light/rain sensor, not sure if this is something you can buy seperately - will wait for someone who knows more to post on this thread...