fix(panel): a write's late answer draws nothing over a list pushed since it was sent
Follow-up to #3297, from Devin's review there, which came in after it merged.
What was wrong
Since #3297, the Automations list is pushed by the host and isn't read again after a write. A write's answer still lands in the list at once, but nothing compared it with the pushes. So a slow answer could overwrite a newer push and stay there. For example: window A toggles an automation off and its answer is slow; window B turns it on; A gets the push showing On, then A's late Off answer lands and shows Off.
Change
useAutomations counts the lists it's pushed. A write on an automation the list already holds (change, toggle, delete, new secret) lands its answer only if no push arrived after it was sent. A create's answer always lands, because its page opens on it. It's added only if no push has already carried the new automation (from Devin's review here). Dropping the answer loses nothing: if that push came from before the write committed, the commit itself is pushed next, within about a second.
Checks
- New page tests: a push arriving before a held create still opens the created automation, and a switch whose answer arrives after a push (another window renamed the automation) leaves the pushed list as it is. It fails without the fix.
automations-page.test.tspasses (86); panel typecheck and biome are clean.
Made with Luke