chat.nvim Gives Its Neovim AI Assistant a Sense of Time
chat.nvim adds scheduled tasks to its Neovim AI assistant, using libuv timers and an event-driven design to give AI a genuine sense of time.
chat.nvim, a Neovim AI assistant plugin, has added scheduled tasks to break the passive nature of most mainstream AI tools, which only respond when prompted. The new feature lets users say things like 'remind me in an hour' and have the AI actually follow through by reaching out proactively at the right moment.
The design boils down to three steps: remembering a task, triggering it at the correct time, and injecting the resulting message into the session as if the user had typed it. All time expressions—relative delays, absolute points, and recurring intervals—are normalized internally into Unix timestamps, removing the need for branching logic. Instead of polling, the system uses Neovim's built-in libuv library to arm one independent, event-driven timer per task, keeping CPU overhead at zero while waiting.
To prevent rhythm drift in recurring tasks after restarts, the next trigger time is recalculated from the creation timestamp and execution count rather than simply adding an interval to the current time. Since libuv timers cap out at roughly 24.8 days, longer delays (up to a 30-day maximum) are handled through relay timers. The most important architectural choice is decoupling the scheduling engine from execution: the engine's only job is to push a message into a queue when the time arrives, ignoring LLM calls or session state entirely. A separate message queue waits for the AI session to go idle before delivering the message, and all tasks are persisted to disk so they survive Neovim restarts.
The project demonstrates that adding a genuine sense of time to AI systems doesn't require heavy infrastructure—just careful abstraction and separation of concerns.