Fade-In content for AI GPT (Resolves #2648) #2673
Open
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.
Fade-In content for AI GPT (Resolves #2648)
This PR adds a few tools to facilitate piece-by-piece fade-in of text and blocks generated by an LLM.
This PR adds an attribution called
CreatedAtAttribution
which can be applied to text segments and nodes.This PR adds a
FadeInStyler
, which looks forCreatedAtAttribution
s, and then sets the opacity of the text segment, or the whole node. TheFadeInStyler
users aTicker
to keep marking itself as dirty until it no longer sees any content that needs to fade in.For text, the opacity is applied by an
OpacityAttribution
. TheFadeInStyler
appliesOpacityAttribution
s as needed, during a given frame.Added an
opacity
property to all document component view models.I added a
metadata
property to view models, even though I didn't really want to. I wasn't sure where else to stick the "createdAt" property. I could have declared an explicit "createdAt" property on eachNode
. Maybe that's a better move. I'm not sure. Using an explicit property requires that we define it for every node and include it in the copy mechanism. However, creating ametadata
property now creates confusion between view model metadata and document node metadata. I'm open to thoughts on that.Fixes
We seemed to be missing some calls to
copy()
onAttributedText
within some view models. This resulted in one styler mutating the text appearance in another styler.Unrelated New Things
This PR adds a few new edit requests to insert content at the end of a document. They're a matter of a convenience. LLMs will want to insert at the end of a document, instead of using the caret, because the user might drag a selection while the content is generating, which would disrupt any insertions based on caret position.
Breaking Changes
This PR also changes
SuperReader
to take anEditor
instead of aDocument
and aSelectionNotifier
. This is because LLMs will need to continuously feed content into the document. Rather than expect developers to use two different modes of input betweenSuperEditor
andSuperReader
, we'll use anEditor
inside of both, but simply prevent user interactions from altering the document within aSuperReader
.Example
The PR code can be used as follows to achieve the fade-in effect.
Setup the
SuperReader
with aFadeInStyler
.Insert content, as desired, and make sure to provide a
createdAt
value.