feat: terminal rendering improvements#5
Merged
Poorgramer-Zack merged 3 commits intomainfrom Jan 9, 2026
Merged
Conversation
- Fix text descender clipping by removing hardcoded line height - Add full-line background painting to reduce horizontal line gaps - Implement pixel-aligned cell size calculation (floor width, ceil height) - Add anti-aliasing disabled flag to prevent edge artifacts - Refactor terminal resize handling to use onResize callback - Move padding from Container to TerminalView for proper layout - Add theme pre-loading to avoid flash of default theme on startup - Improve line positioning calculation for consistent renderin
There was a problem hiding this comment.
Pull request overview
This PR addresses terminal rendering quality issues on high-DPI displays by fixing text descender clipping, reducing horizontal line gaps, and refactoring the resize mechanism. The changes also add comprehensive AGENTS.md documentation files across the codebase.
Key Changes:
- Removed hardcoded line height to allow proper descender rendering (y, p, g, q, j)
- Implemented pixel-aligned positioning with triple-layer background painting to eliminate gaps
- Replaced polling-based terminal resize with event-driven callback mechanism
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
packages/xterm/lib/src/ui/render.dart |
Added full viewport background painting and pixel-aligned line positioning using floorToDouble() |
packages/xterm/lib/src/ui/painter.dart |
Modified cell size calculation (floor width, ceil height), added per-line background strips with 1px overlap, disabled anti-aliasing |
lib/features/terminal/views/terminal_component.dart |
Removed height: 1.0 from TerminalStyle, removed polling-based resize logic, moved padding to TerminalView |
lib/features/terminal/bloc/terminal_bloc.dart |
Added terminal.onResize callback for automatic PTY resizing |
packages/xterm/AGENTS.md |
New documentation file describing xterm package structure and conventions |
packages/flutter_pty/AGENTS.md |
New documentation file for PTY bindings package |
lib/features/terminal/AGENTS.md |
New documentation for terminal feature module |
lib/features/workspace/AGENTS.md |
New documentation for workspace feature module |
lib/features/settings/AGENTS.md |
New documentation for settings feature module |
lib/core/AGENTS.md |
New documentation for core services and utilities |
AGENTS.md |
Root-level project documentation |
.opencode/opencode.jsonc |
Configuration file for OpenCode integration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
[PR] Terminal Rendering Improvements: Text Descenders, Line Gaps, and Layout Stability
Description:
This PR addresses several terminal rendering quality issues affecting text clarity and visual consistency, particularly on Windows with high-DPI displays.
1. 📝 Text Descender Clipping Fix
Issue: Characters with descenders (y, p, g, q, j) were being clipped by the following line, making text difficult to read.
Root Cause: The
TerminalStylewas usingheight: 1.0, which doesn't provide sufficient vertical space for descenders in monospaced fonts.Solution:
height: 1.0fromTerminalStyleinterminal_component.dartResult: ✅ Text descenders now render correctly without clipping.
2. 🎨 Horizontal Line Gap Reduction
Issue: Visible horizontal gaps appeared between terminal rows, especially noticeable during initial load of TUI applications like OpenCode on dark backgrounds.
Root Cause: Sub-pixel positioning and anti-aliasing artifacts caused 1-2 pixel gaps between consecutive lines when Y-coordinates didn't align perfectly to pixel boundaries.
Solution:
render.dartto cover the entire terminal area before painting cellsfloorToDouble()for all Y-coordinate calculations to ensure pixel-perfect alignmentisAntiAlias = falseon all background paint objects to prevent edge blurringfloorToDouble()to prevent horizontal stretching in ASCII artceilToDouble()to prevent vertical gapsResult:
3. 🔄 Terminal Resize Refactor
Issue: The previous resize implementation used a
Future.delayedpolling mechanism that was fragile and could miss resize events.Solution:
terminal_component.darttoterminal_bloc.dartterminal.onResizecallback inTerminalBloc._createTerminalNode()RenderTerminalnow directly triggers PTY resize via the callback whenautoResize: true_lastColsand_lastRowsstate trackingResult: ✅ Automatic terminal resizing now works reliably without polling.
4. 🖼️ Layout and Padding Improvements
Changes:
Containerpadding interminal_component.dartand passed padding directly toTerminalViewdidChangeDependenciesoverride to load theme before first frame, preventing flash of default theme on startupmarkNeedsPaint()to_onTerminalChange()inrender.dartto ensure repaints on terminal updatesTechnical Details
Modified Files:
_measureCharSize(): ExplicitfloorToDouble()for width,ceilToDouble()for heightpaintLine(): Added full-line background strip with 1px overlappaintCellBackground(): Removed early return for normal cells, addedisAntiAlias = false_paint(): Full viewport background painting before line iterationfloorToDouble()for pixel alignmentmarkNeedsPaint()to_onTerminalChange()height: 1.0fromTerminalStyleContainertoTerminalView.paddingdidChangeDependencies()for theme pre-loadingterminal.onResizecallback for automatic PTY resizeVerification
dart analyzeon xterm package - No errors foundKnown Limitations