# Safety and cost guards in reload, lens polling, revert and completion Status: accepted ## Context Several UI paths touch shared state or expensive resources: `/reload` rewrites the system prompt (which invalidates the provider prompt cache); the lens poll takes the LSP manager lock, which a starting server can hold; `/diff` revert writes to user files that may have been edited by hand; `@file` completion needs a large file list; the keyboard-protocol query must precede the alternate screen. ## Decision - `/reload` leaves the agent's prompt untouched when it is unchanged, since a rewrite would drop the prompt cache. - The lens poll uses a 200 ms timeout on the status call because the manager lock can be held while a server starts. - Reverting a file refuses when its content is not what the agent left, so manual edits are never overwritten; files the agent created are deleted. - Command/argument completion is live, but `@file` completion waits for Tab because the file list is big; Enter on an empty or complete token passes through and submits. - The keyboard-enhancement support query runs before entering the alternate screen. ## Consequences Prompt cache stays warm, the UI never blocks on a slow server, and user edits are protected. Status can be stale by one poll when the lock is busy. Code: crates/hx-tui/src/lib.rs (reload handler, lens_tick, completion), crates/hx-tui/src/review.rs:revert, crates/hx-tui/src/popup.rs