This patch improves the reliability of my setup, where I have a Dell monitor that also acts as a KVM (so if I switch the input, it also switches the plugged USB devices to that input). Before I had to restart kanshi.service after sleep in swayidle, otherwise I would get a black screen almost half of the time (that I assume is because kanshi would see no monitors after waking up from sleep). With this patch I can put my device to sleep, switch inputs, get back and see kanshi setting the proper screen/refresh rate 100% of the time, while before sometimes I would get my monitor set to 60Hz (the default, but not what I configured in kanshi), because I assume kanshi would not get the unplug/plug event reliably. Or maybe it got one, but the monitor was still "disconnected", because this laptop is in a dock that supplies DisplayPort/HDMI via its USB-C connector and this itself takes a while to initialize after sleep (something like 2 seconds). So this is my feedback about this patch, it does make everything more reliable to me. Would be great to see it merged.
I'd like to understand _why_ it doesn't work on your system, rather than merging a workaround I don't understand. Can you obtain Sway debug logs of a cycle where it doesn't work?