refactor(events): scope sqlFavoritesDidUpdate by connection id#1160
Merged
Conversation
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
AppEvents.sqlFavoritesDidUpdatepayload changes fromPassthroughSubject<Void, Never>toPassthroughSubject<UUID?, Never>, matching the shape PR #1159 introduced forconnectionUpdated. The per-connection subscribers now filter so editing a favorite for connection A no longer forces every other connection's cache and editor to refresh.Senders updated (
SQLFavoriteManager):addFavorite/updateFavorite: sendfavorite.connectionIdaddFolder/updateFolder: sendfolder.connectionIddeleteFavorite/deleteFavorites/deleteFolder: sendnil(the connectionId isn't easily recoverable from the id-only delete API, and bulk delete may span connections)postUpdateNotificationgains aconnectionId: UUID?parameterSubscribers updated:
ConnectionDataCache(per-connection; refreshes its cached folders/favorites): filterpayload == nil || payload == self.connectionIdSQLEditorView(per-connection; refreshes its keyword map): same filternilpayloads still trigger refresh on every subscriber, preserving correctness for cross-connection favorites (favorite.connectionId == nil) and the delete paths that don't track connectionId.Why this matters
Audit finding same-shape as X2 / R2. With three windows open against three different databases, editing one favorite previously caused the other two windows' caches and editors to refetch their entire favorite list and keyword map. After this PR they see the event but skip when the payload doesn't match.
The two other audit X items have been triaged but not fixed in this PR:
connectionStatusChanged):MainContentViewalready filters onconnectionId.MainSplitViewControllerre-derives state fromDatabaseManager.activeSessionsrather than the event payload, so the missing filter is a small perf concern, not a correctness bug.mainWindowWillClose): only fires when the last main window closes, so there is no "wrong coordinator" scenario today; adding a payload would be purely anticipatory.Test plan
runRefreshorfetchKeywordMap).connectionId): confirm both windows refresh.