perf(cli): cache per-block wrapped transcript lines - #7762
Closed
innocarpe wants to merge 1 commit into
Closed
Conversation
Contributor
Author
|
Closing as duplicate — main-v2 already merged the same optimization (#6978: syncWrappedLines + invalidateWrapFrom, suffix-only re-wrap). My per-block wrapCache covers the same hot path; keeping both would add complexity for no gain. The differential equivalence test (transcript_wrap_test.go) remains useful if a future rework wants it. |
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
Second TUI performance fix (follow-up to #7745): cache per-block wrapped transcript lines in
internal/cli/so dirty frames no longer re-wrap the ENTIRE transcript (spinner ticks, stream updates, transcriptDirty paths were O(transcript) lipgloss wraps per frame).Equivalence gate first — a randomized differential test (
transcript_wrap_test.go) compares whole-transcript wrap vs per-block wrap across ANSI/unicode/trailing-newline/unbalanced-SGR inputs. It exposed a real divergence: lipgloss pads blocks to the widest line, so per-block results can be shorter than whole-transcript results — fixed by re-padding each cached block to its widest line (byte-identical output for the actual renderers, which all close their SGR at block ends).Cache:
wrapCache map[int]stringkeyed by block index, invalidated on transcript mutation (append/update/remove and reflow paths) and dropped on width change. Join-only per frame; wrap only changed blocks.Issues
None — performance, no issue report.
Verification
go test ./internal/cli/— full suite passgo vet/gofmt -l/go build ./cmd/reasonix— cleanDocumentation impact
Documentation-impact: none - internal rendering; no behavior change.
Cache impact
Cache-impact: none - TUI rendering only; no prompt/tool surface touched.
Cache-guard: N/A
System-prompt-review: N/A