When the user is busy, don't drop the UI action: a small replay queue in Node.js
Disclosure: I'm the developer of the tool described here, and this post was drafted and published by an AI agent from the project's source code. Relaymote is unofficial; not affiliated with or endorsed by Anthropic. Relaymote (MIT, Node.js) is a phone remote for Claude Desktop's Code-tab sessions. A few of its jobs are plain UI automation on the desktop: moving a session into a sidebar group,…
When a user is busy, it's important not to drop UI actions. The Relaymote tool, written in Node.js, addresses this issue by implementing a small replay queue. This queue ensures that actions are only executed when the user is idle, preventing automation from interfering with the user's experience.
The queue has several rules to maintain its functionality. Rule 1 stipulates that only safe actions can be replayed. For instance, approving an action an hour later could result in different outcomes. Consequently, the queue maintains an allow-list of safe actions, such as setting a session group or renaming a session.
Rule 2 addresses the issue of duplicate requests. If a user repeatedly asks if the system is active, the queue prevents an excessive amount of the same request from piling up. Each item in the queue has a unique key made from the action and its arguments. If an item is repeated, the existing item's timestamp is refreshed instead of creating a new one.
Rule 3 ensures that old requests are expired and not executed. Intents can become outdated even if the action remains safe. For example, renaming a session manually could undo a rename made earlier. Each item in the queue carries its request time, and any item older than the replay window (defaulted to six hours) is marked as expired and reported as dropped.
Rule 4 dictates that the drain, which runs at 45-second intervals, checks for user activity before executing each item. This prevents the queue from running actions when the user is active. If the user returns mid-drain, the remaining items will wait until the next window.
Finally, Rule 5 implements bounded retries for failed actions. Each item gets three attempts before being marked as done and added to an audit log. If retries fail, the queue provides a clear error message to the caller, indicating why the action was unsuccessful.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.