Repository navigation
Derive Content in Body so Missed .appear Events Cannot Blank the Text - #84
Open
PSchmiedmayer wants to merge 3 commits into
Open
PSchmiedmayer wants to merge 3 commits into
PSchmiedmayer wants to merge 3 commits into
Conversation
.appear Events Cannot Blank the Text
Author
|
@gonzalezreal happy for any feedback or input here; let me know wha you think 🚀 |
There was a problem hiding this comment.
🟡 Changes recommended
The new memoization introduces verified stale-rendering cases (parser changes not invalidating parse cache; environment changes not invalidating TextBuilder cache).
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 2
- Review effort level: Lite
y-a-v-a
added a commit
to y-a-v-a/textual
that referenced
this pull request
Oct 22, 2026
StructuredText, InlineText, WithInlineStyle and TextFragment seeded their content from onChange(initial:), so every view first laid out empty. A List or a UIHostingConfiguration cell measures a row on that pass, and the row then changes height under it; a view that a lazy container materializes can miss the event altogether and stay blank. Each of them now derives its content in body through a Memo, as gonzalezreal#84 and gonzalezreal#90 propose. Adapted to the fork's streaming throttle: the markup is parsed in body only until the first change has been parsed, and later changes still go through the throttle, parsing inside the throttled operation so that the window keeps excluding the parse. The TextBuilder is keyed on the text environment as well as the content (gonzalezreal#84), and starts from the last container size, since the container may not resize again to report it when only the environment changes. In the renderer benchmarks this halves the TextBuilders a document builds once its content lands, and initial render with selection enabled is faster. Co-authored-by: Paul Schmiedmayer <PSchmiedmayer@users.noreply.github.com> Co-authored-by: Shai Mishali <shai@riverside.fm> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y7W6e4M3bCGaGpJzVY8c39
y-a-v-a
added a commit
to y-a-v-a/textual
that referenced
this pull request
Oct 22, 2026
Upstream main has had no new commits since 0.5.0 (2026-06-15), which the fork already contains. The activity since then is in open pull requests; the fixes among them are merged here, cherry-picked with their authorship and adapted where they overlap with the fork: - gonzalezreal#67, gonzalezreal#70, gonzalezreal#71, gonzalezreal#80: selection faults and crashes - gonzalezreal#92: TextBuilder stack overflow on iOS - gonzalezreal#83: caller attributes kept on code blocks - gonzalezreal#86: stale content after markup changes, keeping loaded attachments while streamed content resolves - gonzalezreal#91: attachment accessibility labels - gonzalezreal#84, gonzalezreal#90: content on the first layout pass, so List rows keep their height and ImageRenderer draws text Also fixes a fork bug the gonzalezreal#80 tests exposed (the selection model ignored a change to an empty layout collection) and two timing-dependent tests. Feature pull requests (gonzalezreal#69, gonzalezreal#78, gonzalezreal#79, gonzalezreal#81, gonzalezreal#82, gonzalezreal#88) are left out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y7W6e4M3bCGaGpJzVY8c39
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.
StructuredText,InlineText, andTextFragmentseed their content throughonChange(of:initial:)into@State.SwiftUI doesn't guarantee appear-family events (
onAppear,onChange(initial:),task) for every materialized view; a row created lazily inside a scroll container while content updates quickly in can miss them entirely. When that happens the view keeps rendering its empty initial state:bodyruns with the right markup, layout happens, but nothing is drawn and nothing reaches accessibility. We encountered when parsing streaming MD data updating frequently from LLMs.The PR purposes to replace the event-driven seeding with a small memoizing cache held in
@State: content is derived directly inbodyand parsed once per distinct markup value. Should not change any rendering behavior, if anything, first render now shows content one pass earlier, since it no longer waits for the initialonChangeround trip. Attachment resolution still runs throughtask(id:)as before.Two follow-ups from review, both about the caches reusing a result they should not:
MarkupParsernow has acacheKey(defaulting to the parser's type) thatAttributedStringMarkdownParserfills from its settings, andMarkupParseCachecompares it alongside the markup.TextBuilderwas kept across environment changes, so a colour scheme or dynamic type change only showed once something changed size.BuilderCachenow compares theTextEnvironmentValuestoo.Both come with tests.