fix: emit scroll commands before glyphs in CLI mode (#2577)#2918
Open
deths74r wants to merge 1 commit intodankamongmen:masterfrom
Open
fix: emit scroll commands before glyphs in CLI mode (#2577)#2918deths74r wants to merge 1 commit intodankamongmen:masterfrom
deths74r wants to merge 1 commit intodankamongmen:masterfrom
Conversation
In notcurses_rasterize_inner(), rasterize_core(phase=0) was emitting all damaged glyph cells BEFORE rasterize_scrolls() emitted terminal scroll commands. This caused the subsequent scroll to shift just-written characters up, desyncing lastframe from the actual terminal state. On the next render, those cells would be incorrectly skipped. This manifested as intermittent "disappearing strings" in CLI mode -- the first character of output would vanish after scrolling. Fix: move rasterize_scrolls() before rasterize_core(phase=0) so the terminal scrolls first and glyphs land at their correct positions. Also uncomment the logendy adjustment in rasterize_scrolls() which was disabled with a FIXME note. This ensures the logical end-of-output cursor position is updated after scrolls, preventing stale cursor parking and goto_location() elision bugs. Fixes dankamongmen#2577
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
Fixes #2577 (disappearing strings in CLI mode).
In
notcurses_rasterize_inner(),rasterize_core(phase=0)was emitting all damaged glyph cells beforerasterize_scrolls()emitted terminal scroll commands. This caused the subsequent scroll to shift just-written characters up by one row, desyncinglastframefrom the actual terminal state. On the next render, those cells would be incorrectly skipped becauselastframethought they were already displayed.This manifested as intermittent "disappearing strings" in CLI mode — the first character of output would vanish after a scroll event.
Changes
Move
rasterize_scrolls()beforerasterize_core(phase=0)so the terminal scrolls first and glyphs land at their correct final positions.Uncomment the
logendyadjustment inrasterize_scrolls()which was disabled with aFIXME probably need this to take place at the end of cycle...note. This ensures the logical end-of-output cursor position is updated after scrolls, preventing stale cursor parking andgoto_location()elision bugs.How to reproduce
After enough rounds to trigger terminal scrolling, the first character of the prompt or response text disappears intermittently.
Testing
Tested with a CLI-mode application (Vessel AI coding assistant) that writes styled prompts and streams LLM responses token-by-token with per-token renders. Before the fix, first-character clipping occurred intermittently after scrolling. After the fix, no clipping observed across extended sessions.