Skip to content

[LUM-745] Guard @Published property writes against no-op mutations to prevent SwiftUI attribute graph hang#24556

Merged
tkheyfets merged 1 commit into
mainfrom
devin/1775746264-fix-gateway-published-cascade
Apr 9, 2026
Merged

[LUM-745] Guard @Published property writes against no-op mutations to prevent SwiftUI attribute graph hang#24556
tkheyfets merged 1 commit into
mainfrom
devin/1775746264-fix-gateway-published-cascade

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot commented Apr 9, 2026

Fixes an app hang (Sentry VELLUM-ASSISTANT-MACOS-DH) caused by redundant @Published property writes in GatewayConnectionManager triggering unnecessary SwiftUI attribute graph invalidation. The @Published wrapper fires objectWillChange on 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 @Published writes with equality checks to suppress no-op mutations, extending the pattern already used by setConnected() (guard isConnected != connected) to assistantVersion, keyFingerprint, isConnecting, and isUpdateInProgress. Also removes a redundant else if branch in performHealthCheck() that wrote assistantVersion even 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 @Observable migration: GatewayConnectionManager has Combine subscribers outside SwiftUI ($isConnected.sink, consumers in ConversationManager, 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:

  • Apple: ObservableObject — documents that objectWillChange fires before any @Published mutation, with no equality check
  • Sentry issue: VELLUM-ASSISTANT-MACOS-DH (event 7392246713)

Review & Testing Checklist for Human

  • Build in Xcode locally — CI skips macOS/Swift checks, so a local build is required to confirm this compiles.
  • Verify keyFingerprint guard doesn't affect credential invalidation: The side-effect block (if let oldFingerprint, oldFingerprint != newFingerprint) uses the independently-captured oldFingerprint local variable — confirm it still fires correctly with the guarded property write.
  • Test: connect/disconnect cycle — verify connection status updates correctly in the UI after connecting and disconnecting.
  • Test: health check loop — verify version and connection status still update when the assistant version actually changes.

Notes

  • Same @Published cascade pattern as LUM-735 (MACOS-DE). The fix pattern is identical — guard writes with equality checks.
  • The health check runs every 15s (or every 2s during updates), making assistantVersion and isConnected no-op writes the primary source of unnecessary invalidation.
  • Non-Equatable published properties (latestMemoryStatus, latestModelInfo, permissionMode) are not guarded by this PR since they are written less frequently and would require adding Equatable conformance.

Link to Devin session: https://app.devin.ai/sessions/75c3a7510f2142029eb678ae055245c0
Requested by: @tkheyfets


Open with Devin

@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown
Contributor Author

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@tkheyfets
Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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>
@devin-ai-integration devin-ai-integration Bot force-pushed the devin/1775746264-fix-gateway-published-cascade branch from 93efff3 to 145039f Compare April 9, 2026 20:22
@tkheyfets tkheyfets merged commit 700b3b8 into main Apr 9, 2026
7 checks passed
@tkheyfets tkheyfets deleted the devin/1775746264-fix-gateway-published-cascade branch April 9, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant