perf(render): speed up write-streaming previews and harden edge cases#136
Merged
perf(render): speed up write-streaming previews and harden edge cases#136
Conversation
Optimize write-tool streaming updates while hardening edge cases and improving test signal-to-noise. - keep per-language fontify buffers in sync, initialize mode once, and skip expensive tail extraction/redraw when only trailing partial-line text changes - centralize pending-tool overlay body replacement and apply visual-line/byte capping consistently for raw and language-aware tails - handle empty/same-size rewrites plus zero-limit edge cases safely (zero max-lines, zero width, zero-line tail requests) - add regressions for partial-line fast paths, fallback behavior, preview bounds, and edge-case truncation/tail semantics - make === Unit Tests === Ran 644 tests, 644 results as expected, 0 unexpected (2026-02-22 14:23:15+0100, 23.904274 sec) terse on green runs while preserving full diagnostics on failures; add for full ERT output - update AGENTS test guidance and adjust tests to capture/assert expected minibuffer messages instead of leaking log noise
e41d1a0 to
00b13c3
Compare
dnouri
added a commit
that referenced
this pull request
Feb 25, 2026
Optimize write-tool streaming updates while hardening edge cases and improving test signal-to-noise. - keep per-language fontify buffers in sync, initialize mode once, and skip expensive tail extraction/redraw when only trailing partial-line text changes - centralize pending-tool overlay body replacement and apply visual-line/byte capping consistently for raw and language-aware tails - handle empty/same-size rewrites plus zero-limit edge cases safely (zero max-lines, zero width, zero-line tail requests) - add regressions for partial-line fast paths, fallback behavior, preview bounds, and edge-case truncation/tail semantics - make === Unit Tests === Ran 644 tests, 644 results as expected, 0 unexpected (2026-02-22 14:23:15+0100, 23.904274 sec) terse on green runs while preserving full diagnostics on failures; add for full ERT output - update AGENTS test guidance and adjust tests to capture/assert expected minibuffer messages instead of leaking log noise
dnouri
added a commit
that referenced
this pull request
Feb 26, 2026
Optimize write-tool streaming updates while hardening edge cases and improving test signal-to-noise. - keep per-language fontify buffers in sync, initialize mode once, and skip expensive tail extraction/redraw when only trailing partial-line text changes - centralize pending-tool overlay body replacement and apply visual-line/byte capping consistently for raw and language-aware tails - handle empty/same-size rewrites plus zero-limit edge cases safely (zero max-lines, zero width, zero-line tail requests) - add regressions for partial-line fast paths, fallback behavior, preview bounds, and edge-case truncation/tail semantics - make === Unit Tests === Ran 644 tests, 644 results as expected, 0 unexpected (2026-02-22 14:23:15+0100, 23.904274 sec) terse on green runs while preserving full diagnostics on failures; add for full ERT output - update AGENTS test guidance and adjust tests to capture/assert expected minibuffer messages instead of leaking log noise
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
This PR improves performance and correctness of streaming previews for
writetool calls in the chat render path.The core change is to avoid expensive redraw work when a delta only extends the trailing partial line (which does not affect the visible complete-line tail), while still keeping the fontify buffer synchronized.
What changed
pi-coding-agent--display-tool-streaming-texthot path:pi-coding-agent--fontify-initialize-buffer-modepi-coding-agent--tool-streaming-replace-overlay-bodyWhy
Large write streams were paying too much per-delta work and had edge cases where preview state could become stale or inconsistent (especially around empty or rewritten content).
User impact
writetool callsValidation
Standard gates
make check(639/639)make test-integration(17/17)make test-gui(13/13)Additional perf/regression campaign
Executed
tmp/TODO-perf-issues-test-plan.mdend-to-end (TP-01..TP-36), including:emacs -nwtargeted and full unit runsAll TP steps passed with evidence recorded in the plan file.
Note: the line
pi-coding-agent: fontify mode init error for python: (error "boom")seen in some test logs is expected from intentional failure-path tests.