feat: add configurable scroll optimization - #1761
Open
SivanCola wants to merge 2 commits into
Open
Conversation
Problem: applications cannot disable renderer scroll primitives for terminals that mishandle scroll, insert-line, or delete-line sequences. Root cause: the renderer derives the policy directly from runtime.GOOS whenever its terminal renderer is reset. Fix: add WithScrollOptimization, resolve the existing platform default at Program startup, and persist the selected policy across renderer resets. Verification: go test ./...; go vet ./...
Ensure ordinary frame updates use cell diff output when scroll optimization is disabled, including after a renderer reset.
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
Motivation
Bubble Tea currently decides this policy inside cursedRenderer.reset by calling SetScrollOptim(runtime.GOOS != "windows"). That protects Windows terminals but gives applications no way to disable scroll-region, insert-line, or delete-line optimizations for another incompatible display terminal.
Reasonix issue esengine/DeepSeek-Reasonix#8090 exposed the missing capability boundary. An application-level ClearScreen after every viewport shift had originally been added to avoid stale rows in Warp, but on Windows/ConPTY that workaround produced a visible normal-render plus clear-and-redraw pair. A renderer policy is a more appropriate solution than an asynchronous application-level clear.
The option is intentionally tri-state internally so omitting it keeps existing behavior. Explicit true and false override the platform default. WithoutRenderer remains unaffected.
Verification