From f72fdf7565d18b044f035fa6aca9ae8dbba34fc6 Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Thu, 23 Apr 2026 20:31:53 -0700 Subject: perf: Reduce AI TUI rendering overhead for long conversations (#3447) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes keystroke lag in Atuin AI that scales with conversation length. After extended use (many turns, lots of tool calls with output viewports), pressing a key had noticeable delay before the letter appeared. Three layers of optimization: - **Skip `sync_view_state` for `InputUpdated`** — every keystroke was cloning all events, tools, and archived data even though no FSM state changed. Uses `handle.update_tracked()` (eye_declare 0.5) to skip rebuilds when values haven't actually changed. - **Pre-compute turns and `has_command` on the driver thread** — the view function was rebuilding the full turn structure from raw events and scanning for `suggest_command` tool calls 3× per render frame. Now computed once per FSM state change and cached in ViewState. - **Commit-based element tree pruning** — turns that scroll into terminal scrollback are tracked via `on_commit` and filtered from the element tree, keeping rendering work proportional to visible content. Turn views are now direct children of the root VStack (not nested inside AtuinAi) so `detect_committed` can see them. --- crates/atuin-ai/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/atuin-ai/Cargo.toml') diff --git a/crates/atuin-ai/Cargo.toml b/crates/atuin-ai/Cargo.toml index 90e64b2a..377017b7 100644 --- a/crates/atuin-ai/Cargo.toml +++ b/crates/atuin-ai/Cargo.toml @@ -45,7 +45,7 @@ async-stream = "0.3" uuid = { workspace = true } tui-textarea-2 = "0.10.2" unicode-width = "0.2" -eye_declare = "0.4.3" +eye_declare = "0.5" ratatui-core = "0.1" ratatui-widgets = "0.3" thiserror = { workspace = true } -- cgit v1.3.1