You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf(renderer): avoid server round-trip on display toggles and incremental fold updates (#377)
* perf(renderer): avoid server round-trip on display toggles
Replace ui.render_output() with ui.render_output_from_cache() for
toggle_reasoning_output, toggle_tool_output, and toggle_max_messages.
Instead of fetching the full session from the server on every toggle,
re-render from state.messages that are already in memory. Falls back
to the server fetch if no cached messages are available.
* perf(renderer): incremental fold updates during streaming
Replace set_all_folds() with update_part_folds() in the streaming
update path to avoid rebuilding the entire fold list on every part
change. Maintain part_folds and global_folds caches in ctx for
incremental updates.
During streaming, only the affected part's fold ranges change - its
line_start stays the same. Update the cached entry for that part
and flatten the per-part cache rather than re-iterating all parts
in ctx.formatted_parts.
* perf(renderer): skip vim.deepcopy in cache re-render path
Add skip_deepcopy option to _render_full_session_data. The cache
re-render path (toggle) already owns the session_data reference and
executes synchronously, so deep copying is unnecessary overhead.
* perf(renderer): remove unnecessary vim.deepcopy in _render_full_session_data
All callers pass tables that are either fresh API responses (no other
references) or are used synchronously (no concurrent mutation window).
The deep copy served no actual protection - after storage, event handlers
mutate state.messages in-place anyway.
* fix(renderer): update fold ranges during append-only streaming
append_part_now writes new lines but did not update the part's fold
range, causing the fold's 'to' boundary to remain at its initial value.
As content grew during streaming, new lines appeared outside the fold.
Call update_part_folds after appending so the fold range tracks the
actual content extent.
* refactor(renderer): address review feedback - extract folds_equal, simplify update_part_folds loop
- Extract folds_equal() helper function with nil-guard
- Simplify update_part_folds loop by assigning ctx.part_folds first
- Add 3 test cases for update_part_folds: absolute range computation,
unchanged fold short-circuit, and multi-part fold merging
* fix: sort folds by from value for deterministic output order
pairs() iteration order is non-deterministic across LuaJIT builds,
causing the merged fold list order to vary. Sort by from value so the
output is always predictable.
Also fix the merge test to use was_called_with with the sorted order.
0 commit comments