fix(coordinator,sync,plugins): bundled MED bug fixes + dead AppKit import drop#1177
Merged
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
Five small audit fixes bundled into one PR (per request to reduce per-PR review overhead):
E4 —
SchemaProviderRegistry.retainleak on throwaway coordinatorsMainContentCoordinator.initunconditionally calledservices.schemaProviderRegistry.retain(for:). SwiftUI body re-evaluation creates throwaway coordinators that@Statediscards beforemarkActivated; those instances retained the schema provider but never released it (deinit's never-activated branch did call release, which on its own was an over-release for any future scenario where retain is conditional).The retain now lives in
markActivated(gated by a one-shot flip of_didActivate), pairing with the existingreleaseinteardown/deinit. The never-activated deinit branch no longer calls release for an instance that never retained.C1 —
databaseDidConnecttask writes into tearing-down coordinatorMainContentCommandActions.handleDatabaseDidConnectspawned aTaskthat capturedselfstrongly and calledcoordinator?.Xafter each step. Afterawait coordinator?.refreshTables(), the task continued to callcoordinator?.initRedisKeyTreeIfNeeded()even if the user had disconnected mid-fetch and the coordinator was tearing down.Fix: capture
[weak coordinator], guard!coordinator.isTearingDownat top, and re-check after theawaitso the trailing init call is skipped on teardown.C2 —
SyncCoordinator.observeLocalChangesschedules new task before previous unwindsThe sink did
syncTask?.cancel(); syncTask = Task { ... }, so the new task started its 2s sleep before the cancelled previous task'stry? Task.sleephad returned. Result: brief overlap with two live sync tasks during rapid local changes.Fix:
previousTask?.valuebefore starting its own sleep, so previous fully unwinds first.syncNowgains its ownguard !syncStatus.isSyncingso it short-circuits if a sync is already in progress (the call-site!isSyncingcheck could race with the actor hop).P1 — built-in plugins skipped pluginKitVersion check
The
if source == .userInstalledguard inPluginManager.validatePluginKitVersionmade the version equality check apply only to user-installed plugins. A built-in whoseInfo.plistTableProPluginKitVersionfell behind would load anyway and crash on the first new protocol-witness method call (per theEXC_BAD_INSTRUCTIONnote in CLAUDE.md). Now the check applies to all sources; built-ins ship together so this catches developer error before release.1.3a — drop unused
import AppKitfromModels/Settings/AppSettings.swiftPure data structures; no AppKit usage. The other Models the audit flagged either really do use AppKit (
ColumnIdentitySchemareferencesNSUserInterfaceItemIdentifier) or rely onColor(nsColor:)which would require visual-equivalent replacements (ConnectionToolbarState); both are out of scope for a clean drop.Skipped from this bundle (with reasons)
switchSeqcounter): the global-counter property is intentional for cross-coordinator log correlation; per-instance + instance-id is a stylistic choice not a correctness fix.MainSplitViewController): 46 access sites for what audit flagged LOW; net noise.PluginQueryResult.expectedRowCount): adds a new field to a struct that crosses the plugin/host transport boundary; needs every distributed plugin rebuilt with the new ABI.Test plan
MainContentCoordinator(any tab switch should do); confirmSchemaProviderRegistry.purgeUnuseddoes not log under-released errors.refreshTables, close the window. Confirm the trailinginitRedisKeyTreeIfNeededlog line does not appear.TableProPluginKitVersion; confirm it now refuses to load withpluginOutdatedrather than crashing.