Skip to content

refactor(events): scope queryHistoryDidUpdate and linkedSQLFoldersDidUpdate by connection id#1161

Merged
datlechin merged 1 commit into
mainfrom
refactor/history-and-linked-folder-events-uuid-payload
May 9, 2026
Merged

refactor(events): scope queryHistoryDidUpdate and linkedSQLFoldersDidUpdate by connection id#1161
datlechin merged 1 commit into
mainfrom
refactor/history-and-linked-folder-events-uuid-payload

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

Two more Void-payload AppEvents subjects with per-connection subscribers gain a UUID? payload, matching the pattern from PRs #1159 and #1160.

queryHistoryDidUpdate

PassthroughSubject<Void, Never> -> PassthroughSubject<UUID?, Never>.

  • QueryHistoryManager.addHistory(...) sends entry.connectionId (history entries always carry a non-nil connectionId).
  • deleteHistory(id:) and clearAllHistory() send nil (the connection isn't easily recoverable from the id-only delete API; clearAllHistory legitimately spans all connections).
  • HistoryPanelView is per-connection and now skips events that don't match its connectionId.

Previously, executing a query on connection A reloaded every other open window's history panel.

linkedSQLFoldersDidUpdate

PassthroughSubject<Void, Never> -> PassthroughSubject<UUID?, Never>.

  • SQLFolderWatcher.scheduleFullRescan(...) and scheduleDebouncedRescan() rescan across all enabled folders, so they always send nil. The shape change is forward-looking so any future per-folder rescan path can carry the affected connection id without re-shaping the bus.
  • Subscribers ConnectionDataCache, MainContentCoordinator.checkOpenTabsForExternalModification, and SQLEditorView now apply payload == nil || payload == self.connectionId. Today every event still carries nil so the filter is a no-op for the rescan path; once any sender starts emitting a specific id (e.g. a future per-folder reload), per-connection subscribers will short-circuit unrelated events automatically.

Why this matters

Audit X-shape pattern, continuing the work in PRs #1148, #1159, #1160. After this PR the only remaining Void-payload subjects on AppEvents are genuinely global (themeChanged, accessibilityTextSizeChanged, editorSettingsChanged, dataGridSettingsChanged, aiSettingsChanged, terminalSettingsChanged, licenseStatusDidChange, syncChangeTracked, mcpAuditLogChanged, pluginsRejected, linkedFoldersDidUpdate, mainWindowWillClose).

Test plan

  • Open two windows on two different connections. Run a query on connection A and confirm only connection A's history panel reloads.
  • Delete a history entry; both panels reload (since the sender passes nil).
  • Clear all history; both panels reload.
  • Modify a linked SQL file on disk; confirm watcher fires and the open windows' caches refresh.
  • swiftlint --strict clean.

@datlechin datlechin merged commit 1ce8692 into main May 9, 2026
2 checks passed
@datlechin datlechin deleted the refactor/history-and-linked-folder-events-uuid-payload branch May 9, 2026 17:58
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