fix: replace AlignmentBarrierLayout with _FrameLayout to stop alignment cascade and message disappearing#24530
Merged
Conversation
…nt cascade Remove AlignmentBarrierLayout — custom Layout containers between the outer modifier chain and the ScrollView disrupt SwiftUI's internal scroll infrastructure, causing intermittent cell materialization failures (messages disappearing on send, resize, or scroll). Replace .frame(maxWidth:).frame(maxWidth: .infinity) with a single .frame(width: min(containerWidth, chatColumnMaxWidth)). _FrameLayout returns bounds.midX for alignment without querying children, stopping the O(n) explicitAlignment cascade at the source. The old _FlexFrameLayout pattern cascaded alignment queries through the entire LazyVStack subtree on every layout pass, causing 34-70s hangs. - Remove AlignmentBarrierLayout.swift (no longer used) - Restore pre-LUM-800 modifier chain order on ScrollView - Update AGENTS.md anti-pattern rule Co-Authored-By: ashlee@vellum.ai <ashlee@vellum.ai>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
ashleeradka
approved these changes
Apr 9, 2026
This was referenced Apr 9, 2026
Closed
devin-ai-integration Bot
added a commit
that referenced
this pull request
Apr 9, 2026
The 6 .frame(maxWidth:) sites this PR changed are all siblings or alternatives in the VStack, not ancestors of the LazyVStack. The FlexFrame alignment cascade only propagates through ancestor nodes to children — SwiftUI does not query alignment across siblings. The dangerous ancestor-level FlexFrames were already fixed in PR #24530. Reverting to avoid resize regressions (missing centering layer, rigid .frame(width:) preventing fluid resize). Co-Authored-By: ashlee@vellum.ai <ashlee@vellum.ai>
5 tasks
Jasonnnz
pushed a commit
that referenced
this pull request
Apr 10, 2026
Adds CI-enforced guard tests that scan Swift source files for three known LazyVStack performance anti-patterns: 1. FlexFrameLayout (.frame(maxWidth:) / .frame(maxHeight:)) in cell hierarchy 2. motionVectors transitions (.transition(.move(edge:))) in cell hierarchy 3. withAnimation in scroll handlers (motionVectors cascade) Prevents regression of fixes from PRs #24321, #24375, #24411, #24446, #24530, #24570, #24589. Part of #24613. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3 tasks
Jasonnnz
added a commit
that referenced
this pull request
Apr 10, 2026
* test: add SwiftUI performance guard tests for LazyVStack anti-patterns Adds CI-enforced guard tests that scan Swift source files for three known LazyVStack performance anti-patterns: 1. FlexFrameLayout (.frame(maxWidth:) / .frame(maxHeight:)) in cell hierarchy 2. motionVectors transitions (.transition(.move(edge:))) in cell hierarchy 3. withAnimation in scroll handlers (motionVectors cascade) Prevents regression of fixes from PRs #24321, #24375, #24411, #24446, #24530, #24570, #24589. Part of #24613. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: add missing cell files to LAZY_VSTACK_CELL_FILES and remove PR references Adds the 10 allowlisted file basenames to the cell hierarchy list so the allowlist is actually consulted. Removes historical PR numbers from the file header comment per AGENTS.md guidance. Co-Authored-By: Claude <noreply@anthropic.com> * fix: use grep -E for portable ERE alternation in FlexFrame guard BSD grep (macOS default) doesn't support \| in BRE mode. Switch to grep -E with | for alternation so the guard works for local dev too. Co-Authored-By: Claude <noreply@anthropic.com> * fix: add SubagentEventsReader to cell files and escape dots in transition grep Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Vellum Assistant <assistant@vellum.ai> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3 tasks
devin-ai-integration Bot
added a commit
that referenced
this pull request
May 1, 2026
The blanket prohibition was based on AlignmentBarrierLayout (PR #24530) which had specific scroll infrastructure issues. FixedWidthLayout is functionally identical to _FrameLayout for width constraining — it just blocks alignment cascades. The updated guidance distinguishes between proven-safe FixedWidthLayout and untested new Layout types. Co-Authored-By: ashlee@vellum.ai <ashlee@vellum.ai>
ashleeradka
added a commit
that referenced
this pull request
May 2, 2026
…nt cascade into BottomAlignedMinHeightLayout (#29212) * fix(chat): replace _FrameLayout with FixedWidthLayout to stop alignment cascade into BottomAlignedMinHeightLayout .frame(width:) on the ScrollView wrapper creates _FrameLayout whose placeSubviews calls commonPlacement → ViewDimensions[guide], triggering explicitAlignment on the entire child subtree. The cascade flows through BottomAlignedMinHeightLayout.sizeThatFits, measuring the full ScrollView content — causing 2s+ hangs (82 events, 10 users in Sentry MACOS-JG). .fixedWidth() uses FixedWidthLayout (Layout protocol) which returns nil from explicitAlignment, blocking both the _FrameLayout cascade and the .overlay(alignment: .bottom) implicit ZStack alignment query. Fixes VELLUM-ASSISTANT-MACOS-JG Co-Authored-By: ashlee@vellum.ai <ashlee@vellum.ai> * docs: refine AGENTS.md guidance on custom Layout outside ScrollView The blanket prohibition was based on AlignmentBarrierLayout (PR #24530) which had specific scroll infrastructure issues. FixedWidthLayout is functionally identical to _FrameLayout for width constraining — it just blocks alignment cascades. The updated guidance distinguishes between proven-safe FixedWidthLayout and untested new Layout types. Co-Authored-By: ashlee@vellum.ai <ashlee@vellum.ai> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.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.
Summary
Removes
AlignmentBarrierLayout— a customLayoutcontainer that was wrapping theScrollViewto block alignment query cascades. While it successfully prevented the O(n)explicitAlignmenthang, it disrupted SwiftUI's internal scroll infrastructure, causing messages to disappear on send, resize, scroll, and conversation switch (intermittently at first, then constantly after the LUM-811 streaming cache change increased body re-evaluation frequency).Root cause of the hang was
_FlexFrameLayout, not alignment queries reaching theLazyVStackdirectly. The fix replaces the two.frame(maxWidth:)modifiers (which create_FlexFrameLayout) with a single.frame(width:)(which creates_FrameLayout)._FrameLayoutreturnsbounds.midXfor alignment without querying children — the cascade stops here without needing any customLayoutin the view hierarchy.Changes
MessageListView.swift— RemoveAlignmentBarrierLayoutwrapper; unwrapScrollViewand all scroll modifiers back to the outer chain. Replace.frame(maxWidth: chatColumnMaxWidth).frame(maxWidth: .infinity)with.frame(width: containerWidth > 0 ? min(containerWidth, chatColumnMaxWidth) : chatColumnMaxWidth).AlignmentBarrierLayout.swift— Deleted (no other usages in the codebase).AGENTS.md— Replace barrier documentation with_FrameLayoutvs_FlexFrameLayoutguidance. Explicitly warns against customLayoutbarriers nearScrollView.Resulting modifier chain
No
AlignmentBarrierLayout. No.frame(maxWidth:)on this path.Review & Testing Checklist for Human
CI skips macOS builds — all items require local Xcode verification. Clean build recommended (Cmd+Shift+K, delete DerivedData).
explicitAlignmenthits in theLazyVStacksubtree. The_FrameLayoutblocking the cascade is based on SwiftUI internals analysis (Apple doesn't document this explicitly) — the spindump is the definitive check..frame(maxWidth: 808).frame(maxWidth: .infinity)made the scroll area fill the full window width (scrollbar at window edge) with content centered at 808pt. The new.frame(width: computed)makes the scroll area exactlymin(containerWidth, 808)wide. Verify: (a) chat column is centered and capped at 808pt on wide windows, (b) scrollbar position is acceptable, (c) fills correctly on narrow windows.containerWidthgoes from 0 → actual. The fallback is 808pt (MainWindowView.minWidthis 800, so this should be safe).Notes
HStack+Spacerconversions from LUM-800 remain as defense-in-depth — they prevent any future.frame(maxWidth:)added above from cascading into cells..overlay(alignment: .bottom)forScrollToLatestOverlayViewis safe: it applies to the result of.frame(width:), and_FrameLayoutwith a definite width does not query children for alignment.PodRuntimeTestsCI failure (AppleContainersPodRuntimemacOS 26.0 availability) is pre-existing and unrelated.Link to Devin session: https://app.devin.ai/sessions/ef66aadc67724413b3b5ede76cf20ca9
Requested by: @ashleeradka