Preserve rich formatting with AI rewrites - #63
Merged
Merged
Conversation
This update introduces improvements to the AI selection handling, ensuring that rich formatting and block structures are preserved during selection rewrites. Key changes include the addition of a new context for whole-block selections, which allows for the retention of markdown formatting, and the implementation of tests to verify the correct behavior of these features. - Added support for preserving rich formatting in AI selection rewrites. - Introduced a new context for whole-block selections in the AI controller. - Updated tests to validate the preservation of formatting and block structures.
This commit enhances the handling of whitespace in markdown content by introducing a more efficient trimming function. The `trimMarkdownEnvelope` function has been implemented to remove leading and trailing whitespace while preserving the integrity of the content. Additionally, a new test has been added to validate the performance of the `stripBlockAnnotations` function, ensuring it can handle long internal whitespace runs effectively. Key changes: - Refactored whitespace trimming logic in markdown processing. - Added `isMarkdownEnvelopeWhitespace` utility function. - Introduced a performance test for `stripBlockAnnotations` to handle large whitespace scenarios.
Member
Author
|
bugbot run |
This commit introduces a new test case to ensure that consecutive blank lines are preserved when stripping echoed annotations from markdown content. The test validates the behavior of the `normalizeFlowMarkdownOutput` function, enhancing the overall robustness of markdown processing. Key changes: - Added a test for maintaining consecutive blank lines in `flowMarkdown.test.ts`. - Adjusted the `stripBlockAnnotations` function to improve whitespace handling by removing unnecessary replacements.
Member
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 82e288c. Configure here.
janglad
requested review from
MatteoGauthier,
krijnrijshouwer and
noudadrichem
September 24, 2026 14:04
krijnrijshouwer
approved these changes
Sep 25, 2026
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.
Preserves rich formatting, lists, images, and whitespace during AI selection rewrites. Keeps partial selections scoped and retains their existing marks.
Note
Medium Risk
Changes AI rewrite routing, model context, and markdown ingest/normalization on a core editing path; behavior is heavily tested but regressions could affect selection scope or formatting round-trips.
Overview
Expands inline AI rewrites so whole-block selections (headings, lists, images, tables, etc.—not just paragraphs) route through markdown scoped-range replacement, with host chrome blocks trimmed from the scope. Partial selections stay partial: the model and egress inventory only see the highlighted text, and
resolveCommonSelectionMarkscarries shared bold/italic/underline through text-splice and suggestion streaming.Flow markdown prompts now allow the rich GFM subset Pen can round-trip and tell the model to preserve structure;
normalizeFlowMarkdownOutputandstripBlockAnnotationsstop collapsing internal blank lines and preserve NBSP empty paragraphs.Ingest reconstructs empty paragraphs from Pen’s extra newline separators, parses
<u>underline marks, and suggest mode skips redundant format suggestions on newly inserted blocks. Spec and fidelity docs updated accordingly.Reviewed by Cursor Bugbot for commit 82e288c. Bugbot is set up for automated code reviews on this repo. Configure here.