She really didn't...I'm not picking on Tilly, I'm a huge Tilly fan.... She did the best she could given the circumstances, and so did the crew the scenes just looked a bit off, too easy.
She could have cloaked the moment the ship was detected, she could have run away, she could have moved the ship after it cloaked instead of sitting in the exact same spot, she could have locked down the computer, she could have ordered Stamets to be sitting in the jump cage ready to go at a microseconds notice, she could have ordered everyone to arm themselves in case of boarding parties, she could have tried to fight since the Chain was trying to take the ship intact and would have been at a major disadvantage in a military conflict.