Reduce TUI frame stalls under tool activity - #358
Merged
Conversation
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Investigation
The repro points at zarvis tool calls and expand/collapse. User traces showed the remaining visible freezes were inside
render:terminal_replay, with two clicked expand/collapse frames spending about 328-330 ms in replay and about 343-345 ms in total draw time.The bisected regression commit was
23f120d(Group adjacent tool calls in clients). The remaining expand/collapse issue was the grouping unit itself: bootstrap and transcript replay could build largeToolGroupitems. Clicking one child output mutated the group item, so the renderer had to re-synthesize and replay all grouped siblings rather than one affectedToolBlock.The terminal TUI now keeps tool calls as independent top-level blocks. That trades grouped chrome for bounded frame work: clicking or updating one tool block invalidates one block, not a potentially large group. The existing spec now says grouping is still allowed for clients that can keep updates bounded, but terminal-style renderers should prefer independently invalidated blocks.
Other fixes in this PR address earlier stalls found while narrowing the issue:
feed_task_startrecognizes pending PTY text already rendered by the previous frame. If pending text was flushed into aPtyChunk, the renderer reuses the rendered prefix metrics.Tests
cargo test -p agentd-cli notification_drain_stops_on_count_or_time_budgetcargo test -p agentd-cli run_loop_notification_drain_uses_time_budgetcargo test -p agentd-cli run_loop_select_biases_input_ahead_of_notificationscargo test -p agentd-cli running_tool_signature_ignores_elapsed_seconds_until_controls_appearcargo test -p agentd-cli running_tool_block_shows_keyboard_hints_not_buttonscargo test -p agentd-cli replay_full_scales_with_history_sizecargo test -p agentd-cli replay_full_rows_grow_does_not_reprocess_historycargo test -p agentd-cli zarvis_steady_state_render_is_cheap_with_many_itemscargo test -p agentd-cli expanded_tool_output_is_capped_inlinecargo test -p agentd-cli tool_result_history_preview_is_boundedcargo test -p agentd-cli zarvis_tool_expand_collapse_rebuilds_only_retained_suffix -- --nocapturecargo test -p agentd-cli zarvis_tool_start_reuses_already_rendered_pending_text -- --nocapturecargo test -p agentd-cli zarvis_tool_start_reuses_partially_rendered_pending_text -- --nocapturecargo test -p agentd-cli ungrouped_tool_update_stays_bounded -- --nocapturecargo test -p agentd-cli live_tool_start_after_render_stays_append_onlycargo test -p agentd-cli live_late_tool_use_hydration_after_render_stays_append_onlycargo test -p agentd-cli adjacent_same_tool_task_starts_stay_separate_blockscargo test -p agentd-cli late_tool_use_hydration_stays_separate_from_previous_blockcargo test -p agentd-cli many_small_events_stay_fast_as_history_grows -- --nocapturecargo test -p agentd-cli pty_render -- --nocapturegit diff --checkcargo buildNote:
cargo fmt --check --package agentd-clistill reports existing formatting drift in unrelated CLI files, so I did not apply repo-wide formatting churn.