"Move between nearby devices..." works randomly
I have a 2019 Intel iMac and a 2020 MacBook Air (MBA), both running the latest Mac OS 15.4 (24E248).
The MBA is always with me. In the morning I place it on the side of iMac, which is in my office. Usually, I can use a single mouse (and keyboard) to control the two devices: I move the iMac mouse towards the MBA screen and it magically appears in the MBA screen.
But every once in a while this stops working. Then it starts again, then stops, etc.
For example, this morning this feature worked. Then, all of a sudden, it stopped working without any particular "software" or "hardware" event happening.
After a couple or reboots of the two machines, it is still NOT working.
Why? And what do I need to check to understand what is happening?
The option Settings -> Displays -> Advanced -> "Allow your pointer and keyboard to move ... " is already checked on both devices. Bluetooth is on, the two machines are on the same network connected via a cable.