Android supports fstrim but it only works if the phone is idle for a long time while charging
It's not so. On newer versions, Android runs fstrim with a daily schedule, provided that the conditions meet. Or it should run on a reboot if not run for 3+ days. See this answer for details and how you can run fstrim manually.
FRAGMENTATION ON FLASH MEMORY:
You can try to boot directly into recovery instead of flashing image: fastboot boot recovery.img
If it doesn't work, go for flashing factory firmware in bootloader or Emergency Download mode. Here are the detailed instructions for Xiaomi devices.
TWRP allows backup for devices with no external MicroSD Card. Therefore TWRP does always exclude Internal Storage from backup. They recommend manually copy Internal Storage via USB-MTP (which makes sense after creating TWRP backup because it contains TWRP Backup folder too). If you know how to unpack/repack recovery.img you can add this fix (experimental) ...
The ROM you provided does not contain a valid scatter file or recovery.img so you can not use SP Flash Tool.
I recommend you to make a backup of boot, copy the boot.emmc.win to PC, then to another phone and patch it with Magisk Manager apk
After successful patching, copy the patched file back to PC
Reboot the phone to bootloader, and flash the ...