Repository navigation
perf(ai-chat): scroll the transcript without stutter - #3432
Merged
Merged
Conversation
Code blocks were each a full SourceEditor, built every time a row scrolled into the lazy stack and sized by an estimate that ignored the gutter, so they cut off lines and caught the scroll. They are now selectable text in the editor's font and colors, colored off the main actor from the editor's own grammar. Markdown comes from Foundation's parser, so content indented under a list item stays in the item and tables parse as GFM. Parses after a row's first frame run off the main actor. The end of the transcript is measured outside the lazy stack, so the reply is followed while the reader is at the end and left alone once they scroll up. Typing publishes on the draft only, reasoning text streams again, and image thumbnails are downsampled once.
Signed-off-by: Dat Ngo Quoc <datlechin@gmail.com>
Signed-off-by: Dat Ngo Quoc <datlechin@gmail.com>
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.
Why
Scrolling the AI chat stuttered. Each fenced code block embedded a full
SourceEditor, rebuilt every time its row scrolled into the lazy transcript (16 to 24 ms each), and sized by an estimate that ignored the gutter, so blocks cut off lines and caught the scroll. The hand-written markdown parser pushed content indented under a list item out of the list, and the at-bottom sentinel inside the lazy stack left streaming replies unfollowed.Change
Verified
MarkdownDocumentTests.listItemHoldsIndentedContentpins the reported reply. Animation Hitches over one scripted scroll of a 24-turn transcript, Debug: 650 to 1,567 ms before, 8 to 25 ms after.TrailingPaneStateTestsnow changes the model instead of typing, which no longer publishes on the view model.Screenshots
Not in this PR
TextViewController+Lifecycle.swift:96-135,GutterView.swift:268,TextView+Setup.swift:45-53).