Skip to content

feat: add configurable scroll optimization - #1761

Open
SivanCola wants to merge 2 commits into
charmbracelet:mainfrom
SivanCola:feat/scroll-optimization-option
Open

feat: add configurable scroll optimization#1761
SivanCola wants to merge 2 commits into
charmbracelet:mainfrom
SivanCola:feat/scroll-optimization-option

Conversation

@SivanCola

Copy link
Copy Markdown

Summary

  • add WithScrollOptimization(enabled bool) as a public ProgramOption
  • preserve the current default: enabled on non-Windows platforms and disabled on Windows
  • keep the resolved policy when the cursed renderer is reset
  • cover explicit overrides, platform defaults, reset behavior, and emitted VT output

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

  • go test ./...
  • go vet ./...
  • renderer output test confirms disabled mode emits no scroll, insert-line, or delete-line optimization sequences
  • renderer reset test confirms the selected policy persists

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant