refactor(database, connections): dedup post-connect setup, extract StoredConnection model#1571
Merged
Merged
Conversation
…up commands, schema/db restore)
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
Two behavior-preserving Tier-1 architecture refactors. Both build green; the connect/reconnect change was manually verified in the running app (connect + reconnect + startup commands), and the model extraction is covered by the existing
ConnectionStorageCodable tests.1. Shared post-connect setup (DatabaseManager)
The post-connect sequence (apply query timeout, run startup commands; restore schema/database on reconnect) was duplicated across
reconnectDriver,reconnectSession, andconnectToSession. Extracted into two helpers,applyTimeoutAndStartupCommandsandrestoreSchemaAndDatabase.Each call site keeps its own distinct pre-connect orchestration (tunnel rebuild, password prompt, connect error handling) and passes its exact original arguments (for example
connectToSessionkeepsresolvedConnection.startupCommandsandconnection.name), so behavior is unchanged. Net+42 / -52.2. Extract StoredConnection model
ConnectionStorage.swiftwas a 988-line file mixing connection CRUD, 8 kinds of Keychain secret storage, migrations, and the 420-lineStoredConnectionCodable model. MovedStoredConnectionto its own file.ConnectionStorage.swiftis now 565 lines, under all SwiftLint limits. Pure move, no logic change.Verification
ConnectionStorageCodable round-trip is covered by existing tests in CI.Notes
This is the safe, verifiable slice of Tier 1. The remaining items (split the 8 Keychain secret methods into a
ConnectionSecretsStore, the DI singleton sweep, and theMainContentCoordinatorgod-object split) are higher-risk and were deliberately deferred to dedicated work where the running app can be driven to verify password, connection, and UI behavior.