[LUM-745] Guard @Published property writes against no-op mutations to prevent SwiftUI attribute graph hang#24556
Merged
Conversation
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:
|
Contributor
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
…ent SwiftUI attribute graph cascade Co-Authored-By: tkheyfets <timur@vellum.ai>
93efff3 to
145039f
Compare
tkheyfets
approved these changes
Apr 9, 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.
Fixes an app hang (Sentry VELLUM-ASSISTANT-MACOS-DH) caused by redundant
@Publishedproperty writes inGatewayConnectionManagertriggering unnecessary SwiftUI attribute graph invalidation. The@Publishedwrapper firesobjectWillChangeon every setter call regardless of value equality — when this happens while the attribute graph is already mid-update, it creates a re-entrant transaction that hangs the main thread for 2000ms+.Guards all hot-path
@Publishedwrites with equality checks to suppress no-op mutations, extending the pattern already used bysetConnected()(guard isConnected != connected) toassistantVersion,keyFingerprint,isConnecting, andisUpdateInProgress. Also removes a redundantelse ifbranch inperformHealthCheck()that wroteassistantVersioneven when the value was unchanged.Why this is safe: All changes are additive equality guards — they only suppress writes when the new value equals the current value. No state transitions or side effects are skipped.
Why not
@Observablemigration:GatewayConnectionManagerhas Combine subscribers outside SwiftUI ($isConnected.sink, consumers inConversationManager,AppDelegate). A previous attempt to change this class's isolation model was reverted (PR #21711). The no-op guard approach fixes the root cause without architectural risk.References:
objectWillChangefires before any@Publishedmutation, with no equality checkReview & Testing Checklist for Human
keyFingerprintguard doesn't affect credential invalidation: The side-effect block (if let oldFingerprint, oldFingerprint != newFingerprint) uses the independently-capturedoldFingerprintlocal variable — confirm it still fires correctly with the guarded property write.Notes
@Publishedcascade pattern as LUM-735 (MACOS-DE). The fix pattern is identical — guard writes with equality checks.assistantVersionandisConnectedno-op writes the primary source of unnecessary invalidation.Equatablepublished properties (latestMemoryStatus,latestModelInfo,permissionMode) are not guarded by this PR since they are written less frequently and would require addingEquatableconformance.Link to Devin session: https://app.devin.ai/sessions/75c3a7510f2142029eb678ae055245c0
Requested by: @tkheyfets